File tree Expand file tree Collapse file tree 8 files changed +87
-0
lines changed Expand file tree Collapse file tree 8 files changed +87
-0
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ Parser comes with the following built-in schemas:
8585| ** SesSchema** | Lambda Event Source payload for Amazon Simple Email Service |
8686| ** SnsSchema** | Lambda Event Source payload for Amazon Simple Notification Service |
8787| ** SqsSchema** | Lambda Event Source payload for Amazon SQS |
88+ | ** TransferFamilySchema** | Lambda Event Source payload for AWS Transfer Family events |
8889| ** VpcLatticeSchema** | Lambda Event Source payload for Amazon VPC Lattice |
8990| ** VpcLatticeV2Schema** | Lambda Event Source payload for Amazon VPC Lattice v2 payload |
9091
Original file line number Diff line number Diff line change 112112 "require" : " ./lib/cjs/schemas/sqs.js" ,
113113 "import" : " ./lib/esm/schemas/sqs.js"
114114 },
115+ "./schemas/transfer-family" : {
116+ "require" : " ./lib/cjs/schemas/transfer-family.js" ,
117+ "import" : " ./lib/esm/schemas/transfer-family.js"
118+ },
115119 "./schemas/vpc-lattice" : {
116120 "require" : " ./lib/cjs/schemas/vpc-lattice.js" ,
117121 "import" : " ./lib/esm/schemas/vpc-lattice.js"
323327 " ./lib/cjs/envelopes/sqs.d.ts" ,
324328 " ./lib/esm/envelopes/sqs.d.ts"
325329 ],
330+ "schemas/transfer-family" : [
331+ " ./lib/cjs/schemas/transfer-family.d.ts" ,
332+ " ./lib/esm/schemas/transfer-family.d.ts"
333+ ],
326334 "envelopes/vpc-lattice" : [
327335 " ./lib/cjs/envelopes/vpc-lattice.d.ts" ,
328336 " ./lib/esm/envelopes/vpc-lattice.d.ts"
Original file line number Diff line number Diff line change @@ -61,5 +61,6 @@ export {
6161 SnsNotificationSchema ,
6262} from './sns.js' ;
6363export { SqsSchema , SqsRecordSchema } from './sqs.js' ;
64+ export { TransferFamilySchema } from './transfer-family.js' ;
6465export { VpcLatticeSchema } from './vpc-lattice.js' ;
6566export { VpcLatticeV2Schema } from './vpc-latticev2.js' ;
Original file line number Diff line number Diff line change 1+ import { z } from 'zod' ;
2+
3+ /**
4+ *
5+ * Zod schema for AWS Transfer Family events.
6+ *
7+ * @example
8+ * ```json
9+ * {
10+ * "username": "testUser",
11+ * "password": "testPass",
12+ * "protocol": "SFTP",
13+ * "serverId": "s-abcd123456",
14+ * "sourceIp": "192.168.0.100"
15+ * }
16+ * ```
17+ *
18+ * TransferFamilySchema validates events coming from AWS Transfer Family.
19+ *
20+ */
21+ const TransferFamilySchema = z . object ( {
22+ username : z . string ( ) ,
23+ password : z . string ( ) ,
24+ protocol : z . string ( ) ,
25+ serverId : z . string ( ) ,
26+ sourceIp : z . string ( ) . ip ( ) ,
27+ } ) ;
28+
29+ export { TransferFamilySchema } ;
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ export type {
3838 SnsEvent ,
3939 SnsSqsNotification ,
4040 SqsEvent ,
41+ TransferFamilyEvent ,
4142 VpcLatticeEvent ,
4243 VpcLatticeEventV2 ,
4344} from './schema.js' ;
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ import type {
3737 SnsSqsNotificationSchema ,
3838 SqsRecordSchema ,
3939 SqsSchema ,
40+ TransferFamilySchema ,
4041 VpcLatticeSchema ,
4142 VpcLatticeV2Schema ,
4243} from '../schemas/index.js' ;
@@ -129,6 +130,8 @@ type SqsEvent = z.infer<typeof SqsSchema>;
129130
130131type SqsRecord = z . infer < typeof SqsRecordSchema > ;
131132
133+ type TransferFamilyEvent = z . infer < typeof TransferFamilySchema > ;
134+
132135type VpcLatticeEvent = z . infer < typeof VpcLatticeSchema > ;
133136
134137type VpcLatticeEventV2 = z . infer < typeof VpcLatticeV2Schema > ;
@@ -171,6 +174,7 @@ export type {
171174 SnsRecord ,
172175 SqsEvent ,
173176 SqsRecord ,
177+ TransferFamilyEvent ,
174178 VpcLatticeEvent ,
175179 VpcLatticeEventV2 ,
176180} ;
Original file line number Diff line number Diff line change 1+ {
2+ "username" : " value" ,
3+ "password" : " value" ,
4+ "protocol" : " SFTP" ,
5+ "serverId" : " s-abcd123456" ,
6+ "sourceIp" : " 192.168.0.100"
7+ }
8+
Original file line number Diff line number Diff line change 1+ import { describe , expect , it } from 'vitest' ;
2+ import { TransferFamilySchema } from '../../../src/schemas/transfer-family' ;
3+ import type { TransferFamilyEvent } from '../../../src/types/schema.js' ;
4+ import { getTestEvent } from '../helpers/utils' ;
5+
6+ describe ( 'Schema: TransferFamily' , ( ) => {
7+ const baseEvent = getTestEvent < TransferFamilyEvent > ( {
8+ eventsPath : 'transfer-family' ,
9+ filename : 'base' ,
10+ } ) ;
11+
12+ it ( 'parses a valid TransferFamily event' , ( ) => {
13+ // Prepare
14+ const event = structuredClone ( baseEvent ) ;
15+
16+ // Act
17+ const result = TransferFamilySchema . parse ( event ) ;
18+
19+ // Assess
20+ expect ( result ) . toStrictEqual ( event ) ;
21+ } ) ;
22+
23+ it ( 'throws if the event is not a valid TransferFamily event' , ( ) => {
24+ // Prepare
25+ const invalidEvent = {
26+ username : 'testUser' ,
27+ protocol : 'SFTP' ,
28+ serverId : 's-abcd123456' ,
29+ sourceIp : 'invalid-ip' ,
30+ } ;
31+
32+ // Act & Assess
33+ expect ( ( ) => TransferFamilySchema . parse ( invalidEvent ) ) . toThrow ( ) ;
34+ } ) ;
35+ } ) ;
You can’t perform that action at this time.
0 commit comments