-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(parser): add built-in schemas (#1788)
* add dynamodb schema * add alb * add parser to v2 build * fix test * add alb * add built-in schema * add more tests for schemas * remove index export * add cloudwatch with base64 zlip transform * add throw test case * formatting * add kafka schema * restructured tests * add vpc lattice and lattice v2 * s3 event notification should extend eventbridge * s3 sqs should extend from sqs * simplify cloudwatch extract from string * keep message as string, instead of empty object * fix detail type of eb and field names * remove duplicated entries * fix homepage URL in readme * improved test coverage * key and value are always present * cleanup unnecessary definitions, widen peerDep version req * Update packages/parser/src/schemas/cloudwatch.ts Co-authored-by: Andrea Amorosi <dreamorosi@gmail.com> * clean up events, some fields are imaginary * fix api gw * fix broken IP addresses in examples * add more tests to api gw * fix apigw2 add more tests * add optional scopes to apigwv2 * add optional field back to api gw, stricter methods for vpc lattice * add test for messageId refinement * remove redundant entry * fix sqs * add dmarcPolicy for ses * added tests * moved cw function from kinesis, fix imports * add parser to build step in ci * use any safely here * removed console logs * name, add datetime to strings * narrow string to datetime * refine to url * imports, remove try/catch * add .js extension to imports * moved comment, fixed path * rename event filename to fix events --------- Co-authored-by: Andrea Amorosi <dreamorosi@gmail.com>
- Loading branch information
1 parent
f54e1b5
commit 20cde95
Showing
137 changed files
with
4,951 additions
and
27 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
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
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
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 |
---|---|---|
|
@@ -27,4 +27,4 @@ | |
}, | ||
"body": "{\"user\":\"xyz\",\"productId\":\"123456789\"}", | ||
"isBase64Encoded": false | ||
} | ||
} |
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 |
---|---|---|
|
@@ -4,4 +4,4 @@ | |
"name": "foo", | ||
"productId": 10000 | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -4,4 +4,4 @@ | |
"name": "Foo" | ||
}, | ||
"productId": 10000 | ||
} | ||
} |
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 |
---|---|---|
|
@@ -23,4 +23,4 @@ | |
"awsRegion": "us-east-2" | ||
} | ||
] | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
File renamed without changes.
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,22 @@ | ||
import { z } from 'zod'; | ||
|
||
const AlbSchema = z.object({ | ||
httpMethod: z.string(), | ||
path: z.string(), | ||
body: z.string(), | ||
isBase64Encoded: z.boolean(), | ||
headers: z.record(z.string(), z.string()).optional(), | ||
queryStringParameters: z.record(z.string(), z.string()).optional(), | ||
requestContext: z.object({ | ||
elb: z.object({ | ||
targetGroupArn: z.string(), | ||
}), | ||
}), | ||
}); | ||
|
||
const AlbMultiValueHeadersSchema = AlbSchema.extend({ | ||
multiValueHeaders: z.record(z.string(), z.array(z.string())), | ||
multiValueQueryStringParameters: z.record(z.string(), z.array(z.string())), | ||
}); | ||
|
||
export { AlbSchema, AlbMultiValueHeadersSchema }; |
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,110 @@ | ||
import { z } from 'zod'; | ||
|
||
const APIGatewayCert = z.object({ | ||
clientCertPem: z.string(), | ||
subjectDN: z.string(), | ||
issuerDN: z.string(), | ||
serialNumber: z.string(), | ||
validity: z.object({ | ||
notBefore: z.string(), | ||
notAfter: z.string(), | ||
}), | ||
}); | ||
|
||
const APIGatewayEventIdentity = z.object({ | ||
accessKey: z.string().nullish(), | ||
accountId: z.string().nullish(), | ||
apiKey: z.string().nullish(), | ||
apiKeyId: z.string().nullish(), | ||
caller: z.string().nullish(), | ||
cognitoAuthenticationProvider: z.string().nullish(), | ||
cognitoAuthenticationType: z.string().nullish(), | ||
cognitoIdentityId: z.string().nullish(), | ||
cognitoIdentityPoolId: z.string().nullish(), | ||
principalOrgId: z.string().nullish(), | ||
sourceIp: z.string().ip().optional(), | ||
user: z.string().nullish(), | ||
userAgent: z.string().nullish(), | ||
userArn: z.string().nullish(), | ||
clientCert: APIGatewayCert.nullish(), | ||
}); | ||
|
||
const APIGatewayEventRequestContext = z | ||
.object({ | ||
accountId: z.string(), | ||
apiId: z.string(), | ||
authorizer: z | ||
.object({ | ||
claims: z.record(z.string(), z.any()).nullish(), | ||
scopes: z.array(z.string()).nullish(), | ||
}) | ||
.nullish(), | ||
stage: z.string(), | ||
protocol: z.string(), | ||
identity: APIGatewayEventIdentity, | ||
requestId: z.string(), | ||
requestTime: z.string(), | ||
requestTimeEpoch: z.number(), | ||
resourceId: z.string().nullish(), | ||
resourcePath: z.string(), | ||
domainName: z.string().nullish(), | ||
domainPrefix: z.string().nullish(), | ||
extendedRequestId: z.string().nullish(), | ||
httpMethod: z.enum([ | ||
'GET', | ||
'POST', | ||
'PUT', | ||
'PATCH', | ||
'DELETE', | ||
'HEAD', | ||
'OPTIONS', | ||
]), | ||
path: z.string(), | ||
connectedAt: z.number().nullish(), | ||
connectionId: z.string().nullish(), | ||
eventType: z.enum(['CONNECT', 'MESSAGE', 'DISCONNECT']).nullish(), | ||
messageDirection: z.string().nullish(), | ||
messageId: z.string().nullish(), | ||
routeKey: z.string().nullish(), | ||
operationName: z.string().nullish(), | ||
}) | ||
.refine( | ||
(input) => { | ||
return ( | ||
!input.messageId || (input.messageId && input.eventType === 'MESSAGE') | ||
); | ||
}, | ||
{ | ||
message: 'messageId is available only when `eventType` is MESSAGE', | ||
} | ||
); | ||
|
||
const APIGatewayProxyEventSchema = z.object({ | ||
version: z.string().optional(), | ||
authorizationToken: z.string().optional(), | ||
identitySource: z.string().optional(), | ||
methodArn: z.string().optional(), | ||
type: z.enum(['TOKEN', 'REQUEST']).optional(), | ||
resource: z.string(), | ||
path: z.string(), | ||
httpMethod: z.enum([ | ||
'GET', | ||
'POST', | ||
'PUT', | ||
'PATCH', | ||
'DELETE', | ||
'HEAD', | ||
'OPTIONS', | ||
]), | ||
headers: z.record(z.string()).optional(), | ||
queryStringParameters: z.record(z.string()).optional(), | ||
multiValueHeaders: z.record(z.array(z.string())).optional(), | ||
multiValueQueryStringParameters: z.record(z.array(z.string())).optional(), | ||
requestContext: APIGatewayEventRequestContext, | ||
pathParameters: z.record(z.string()).optional().nullish(), | ||
stageVariables: z.record(z.string()).optional().nullish(), | ||
isBase64Encoded: z.boolean().optional(), | ||
body: z.string().optional(), | ||
}); | ||
|
||
export { APIGatewayProxyEventSchema, APIGatewayCert }; |
Oops, something went wrong.