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
- Loading branch information
1 parent
387eab4
commit a7fcee8
Showing
4 changed files
with
224 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,98 @@ | ||
import { | ||
$array, | ||
$boolean, | ||
$const, | ||
$dict, | ||
$integer, | ||
$null, | ||
$object, | ||
$optional, | ||
$ref, | ||
$string, | ||
$union, | ||
$unknown, | ||
$validator, | ||
} from '@skyleague/therefore' | ||
import type { ThereforeSchema } from '@skyleague/therefore/src/lib/primitives/types' | ||
|
||
export const APIGatewayProxyEventHeaders = $dict($string) | ||
export const APIGatewayProxyEventMultiValueHeaders = $dict($array($string)) | ||
export const APIGatewayProxyEventPathParameters = $dict($string) | ||
export const APIGatewayProxyEventQueryStringParameters = $dict($string) | ||
export const APIGatewayProxyEventMultiValueQueryStringParameters = $dict($array($string)) | ||
export const APIGatewayProxyEventStageVariables = $dict($string) | ||
|
||
export const APIGatewayEventDefaultAuthorizerContext = $union([$const(undefined), $null, $dict($unknown)]) | ||
|
||
export const APIGatewayEventClientCertificate = $object({ | ||
clientCertPem: $string, | ||
serialNumber: $string, | ||
subjectDN: $string, | ||
issuerDN: $string, | ||
validity: $object({ | ||
notAfter: $string, | ||
notBefore: $string, | ||
}), | ||
}) | ||
|
||
export const APIGatewayEventIdentity = $object({ | ||
accessKey: $union([$string, $null]), | ||
accountId: $union([$string, $null]), | ||
apiKey: $union([$string, $null]), | ||
apiKeyId: $union([$string, $null]), | ||
caller: $union([$string, $null]), | ||
clientCert: $union([$ref(APIGatewayEventClientCertificate), $null]), | ||
cognitoAuthenticationProvider: $union([$string, $null]), | ||
cognitoAuthenticationType: $union([$string, $null]), | ||
cognitoIdentityId: $union([$string, $null]), | ||
cognitoIdentityPoolId: $union([$string, $null]), | ||
principalOrgId: $union([$string, $null]), | ||
sourceIp: $string, | ||
user: $union([$string, $null]), | ||
userAgent: $union([$string, $null]), | ||
userArn: $union([$string, $null]), | ||
}) | ||
|
||
export const APIGatewayEventRequestContextWithAuthorizer = (context: ThereforeSchema) => | ||
$object({ | ||
accountId: $string, | ||
apiId: $string, | ||
authorizer: context, | ||
connectedAt: $optional($integer, 'explicit'), | ||
connectionId: $optional($string, 'explicit'), | ||
domainName: $optional($string, 'explicit'), | ||
domainPrefix: $optional($string, 'explicit'), | ||
eventType: $optional($string, 'explicit'), | ||
extendedRequestId: $optional($string, 'explicit'), | ||
protocol: $string, | ||
httpMethod: $string, | ||
identity: $ref(APIGatewayEventIdentity), | ||
messageDirection: $optional($string, 'explicit'), | ||
messageId: $union([$string, $null, $const(undefined)]), | ||
path: $string, | ||
stage: $string, | ||
requestId: $string, | ||
requestTime: $optional($string, 'explicit'), | ||
requestTimeEpoch: $integer, | ||
resourceId: $string, | ||
resourcePath: $string, | ||
routeKey: $optional($string, 'explicit'), | ||
}) | ||
|
||
export const APIGatewayProxyEventBase = (context: ThereforeSchema) => | ||
$object({ | ||
body: $union([$string, $null]), | ||
headers: $ref(APIGatewayProxyEventHeaders), | ||
multiValueHeaders: $ref(APIGatewayProxyEventMultiValueHeaders), | ||
httpMethod: $string, | ||
isBase64Encoded: $boolean, | ||
path: $string, | ||
pathParameters: $union([$ref(APIGatewayProxyEventPathParameters), $null]), | ||
queryStringParameters: $union([$ref(APIGatewayProxyEventQueryStringParameters), $null]), | ||
multiValueQueryStringParameters: $union([$ref(APIGatewayProxyEventMultiValueQueryStringParameters), $null]), | ||
stageVariables: $union([$ref(APIGatewayProxyEventStageVariables), $null]), | ||
requestContext: APIGatewayEventRequestContextWithAuthorizer(context), | ||
resource: $string, | ||
}) | ||
|
||
export const APIGatewayProxyEvent = $validator(APIGatewayProxyEventBase(APIGatewayEventDefaultAuthorizerContext)) |
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,120 @@ | ||
/** | ||
* 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 APIGatewayProxyEventHeaders { | ||
[k: string]: string | undefined | ||
} | ||
|
||
export interface APIGatewayProxyEventMultiValueHeaders { | ||
[k: string]: string[] | undefined | ||
} | ||
|
||
export interface APIGatewayProxyEventPathParameters { | ||
[k: string]: string | undefined | ||
} | ||
|
||
export interface APIGatewayProxyEventQueryStringParameters { | ||
[k: string]: string | undefined | ||
} | ||
|
||
export interface APIGatewayProxyEventMultiValueQueryStringParameters { | ||
[k: string]: string[] | undefined | ||
} | ||
|
||
export interface APIGatewayProxyEventStageVariables { | ||
[k: string]: string | undefined | ||
} | ||
|
||
export type APIGatewayEventDefaultAuthorizerContext = null | null | { | ||
[k: string]: unknown | undefined | ||
} | ||
|
||
export interface APIGatewayEventClientCertificate { | ||
clientCertPem: string | ||
serialNumber: string | ||
subjectDN: string | ||
issuerDN: string | ||
validity: { | ||
notAfter: string | ||
notBefore: string | ||
} | ||
} | ||
|
||
export interface APIGatewayEventIdentity { | ||
accessKey: string | null | ||
accountId: string | null | ||
apiKey: string | null | ||
apiKeyId: string | null | ||
caller: string | null | ||
clientCert: APIGatewayEventClientCertificate | null | ||
cognitoAuthenticationProvider: string | null | ||
cognitoAuthenticationType: string | null | ||
cognitoIdentityId: string | null | ||
cognitoIdentityPoolId: string | null | ||
principalOrgId: string | null | ||
sourceIp: string | ||
user: string | null | ||
userAgent: string | null | ||
userArn: string | null | ||
} | ||
|
||
export interface APIGatewayProxyEvent { | ||
body: string | null | ||
headers: APIGatewayProxyEventHeaders | ||
multiValueHeaders: APIGatewayProxyEventMultiValueHeaders | ||
httpMethod: string | ||
isBase64Encoded: boolean | ||
path: string | ||
pathParameters: APIGatewayProxyEventPathParameters | null | ||
queryStringParameters: APIGatewayProxyEventQueryStringParameters | null | ||
multiValueQueryStringParameters: APIGatewayProxyEventMultiValueQueryStringParameters | null | ||
stageVariables: APIGatewayProxyEventStageVariables | null | ||
requestContext: { | ||
accountId: string | ||
apiId: string | ||
authorizer: null | null | { | ||
[k: string]: unknown | undefined | ||
} | ||
connectedAt?: number | undefined | ||
connectionId?: string | undefined | ||
domainName?: string | undefined | ||
domainPrefix?: string | undefined | ||
eventType?: string | undefined | ||
extendedRequestId?: string | undefined | ||
protocol: string | ||
httpMethod: string | ||
identity: APIGatewayEventIdentity | ||
messageDirection?: string | undefined | ||
messageId: string | null | null | ||
path: string | ||
stage: string | ||
requestId: string | ||
requestTime?: string | undefined | ||
requestTimeEpoch: number | ||
resourceId: string | ||
resourcePath: string | ||
routeKey?: string | undefined | ||
} | ||
resource: string | ||
} | ||
|
||
export const APIGatewayProxyEvent = { | ||
validate: require('./schemas/api-gateway-proxy-event.schema.js') as ValidateFunction<APIGatewayProxyEvent>, | ||
get schema() { | ||
return APIGatewayProxyEvent.validate.schema | ||
}, | ||
get errors() { | ||
return APIGatewayProxyEvent.validate.errors ?? undefined | ||
}, | ||
is: (o: unknown): o is APIGatewayProxyEvent => APIGatewayProxyEvent.validate(o) === true, | ||
assert: (o: unknown) => { | ||
if (!APIGatewayProxyEvent.validate(o)) { | ||
throw new AjvValidator.ValidationError(APIGatewayProxyEvent.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 './apigateway.type' |
5 changes: 5 additions & 0 deletions
5
src/lib/aws/apigateway/schemas/api-gateway-proxy-event.schema.js
Large diffs are not rendered by default.
Oops, something went wrong.