This repository has been archived by the owner on Dec 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: upgrade dependencies * feat: add apigateway schemas * feat: add eventbridge schemas * feat: add firehose schemas * feat: add lambda schemas
- Loading branch information
1 parent
6929c08
commit 1f767c9
Showing
5 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { $boolean, $object, $optional, $ref, $string, $unknown, $validator } from '@skyleague/therefore' | ||
|
||
export const cognitoIdentity = $object({ | ||
cognitoIdentityId: $string, | ||
cognitoIdentityPoolId: $string, | ||
}) | ||
|
||
export const clientContextClient = $object({ | ||
installationId: $string, | ||
appTitle: $string, | ||
appVersionName: $string, | ||
appVersionCode: $string, | ||
appPackageName: $string, | ||
}) | ||
|
||
export const clientContextEnv = $object({ | ||
platformVersion: $string, | ||
platform: $string, | ||
make: $string, | ||
model: $string, | ||
locale: $string, | ||
}) | ||
|
||
export const clientContext = $object({ | ||
client: $ref(clientContextClient), | ||
Custom: $optional($unknown), | ||
env: $ref(clientContextEnv), | ||
}) | ||
|
||
export const context = $validator( | ||
$object({ | ||
callbackWaitsForEmptyEventLoop: $boolean, | ||
functionName: $string, | ||
functionVersion: $string, | ||
invokedFunctionArn: $string, | ||
memoryLimitInMB: $string, | ||
awsRequestId: $string, | ||
logGroupName: $string, | ||
logStreamName: $string, | ||
identity: $optional($ref(cognitoIdentity), 'explicit'), | ||
clientContext: $optional($ref(clientContext), 'explicit'), | ||
}) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import type { Context } from './context.type' | ||
|
||
import type { Context as LambdaContext } from 'aws-lambda' | ||
|
||
test('type is compatible', () => { | ||
const _test: Context = {} as unknown as LambdaContext | ||
// const _test2: LambdaContext = {} as unknown as Context | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/** | ||
* Generated by @skyleague/therefore@v1.0.0-local | ||
* Do not manually touch this | ||
*/ | ||
/* eslint-disable */ | ||
import AjvValidator from 'ajv' | ||
import type { ValidateFunction } from 'ajv' | ||
|
||
export interface CognitoIdentity { | ||
cognitoIdentityId: string | ||
cognitoIdentityPoolId: string | ||
} | ||
|
||
export interface ClientContextClient { | ||
installationId: string | ||
appTitle: string | ||
appVersionName: string | ||
appVersionCode: string | ||
appPackageName: string | ||
} | ||
|
||
export interface ClientContextEnv { | ||
platformVersion: string | ||
platform: string | ||
make: string | ||
model: string | ||
locale: string | ||
} | ||
|
||
export interface ClientContext { | ||
client: ClientContextClient | ||
Custom?: unknown | ||
env: ClientContextEnv | ||
} | ||
|
||
export interface Context { | ||
callbackWaitsForEmptyEventLoop: boolean | ||
functionName: string | ||
functionVersion: string | ||
invokedFunctionArn: string | ||
memoryLimitInMB: string | ||
awsRequestId: string | ||
logGroupName: string | ||
logStreamName: string | ||
identity?: CognitoIdentity | undefined | ||
clientContext?: ClientContext | undefined | ||
} | ||
|
||
export const Context = { | ||
validate: require('./schemas/context.schema.js') as ValidateFunction<Context>, | ||
get schema() { | ||
return Context.validate.schema | ||
}, | ||
get errors() { | ||
return Context.validate.errors ?? undefined | ||
}, | ||
is: (o: unknown): o is Context => Context.validate(o) === true, | ||
assert: (o: unknown) => { | ||
if (!Context.validate(o)) { | ||
throw new AjvValidator.ValidationError(Context.errors ?? []) | ||
} | ||
}, | ||
} as const |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './context.type' |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.