File tree 8 files changed +87
-0
lines changed
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:
85
85
| ** SesSchema** | Lambda Event Source payload for Amazon Simple Email Service |
86
86
| ** SnsSchema** | Lambda Event Source payload for Amazon Simple Notification Service |
87
87
| ** SqsSchema** | Lambda Event Source payload for Amazon SQS |
88
+ | ** TransferFamilySchema** | Lambda Event Source payload for AWS Transfer Family events |
88
89
| ** VpcLatticeSchema** | Lambda Event Source payload for Amazon VPC Lattice |
89
90
| ** VpcLatticeV2Schema** | Lambda Event Source payload for Amazon VPC Lattice v2 payload |
90
91
Original file line number Diff line number Diff line change 112
112
"require" : " ./lib/cjs/schemas/sqs.js" ,
113
113
"import" : " ./lib/esm/schemas/sqs.js"
114
114
},
115
+ "./schemas/transfer-family" : {
116
+ "require" : " ./lib/cjs/schemas/transfer-family.js" ,
117
+ "import" : " ./lib/esm/schemas/transfer-family.js"
118
+ },
115
119
"./schemas/vpc-lattice" : {
116
120
"require" : " ./lib/cjs/schemas/vpc-lattice.js" ,
117
121
"import" : " ./lib/esm/schemas/vpc-lattice.js"
323
327
" ./lib/cjs/envelopes/sqs.d.ts" ,
324
328
" ./lib/esm/envelopes/sqs.d.ts"
325
329
],
330
+ "schemas/transfer-family" : [
331
+ " ./lib/cjs/schemas/transfer-family.d.ts" ,
332
+ " ./lib/esm/schemas/transfer-family.d.ts"
333
+ ],
326
334
"envelopes/vpc-lattice" : [
327
335
" ./lib/cjs/envelopes/vpc-lattice.d.ts" ,
328
336
" ./lib/esm/envelopes/vpc-lattice.d.ts"
Original file line number Diff line number Diff line change @@ -61,5 +61,6 @@ export {
61
61
SnsNotificationSchema ,
62
62
} from './sns.js' ;
63
63
export { SqsSchema , SqsRecordSchema } from './sqs.js' ;
64
+ export { TransferFamilySchema } from './transfer-family.js' ;
64
65
export { VpcLatticeSchema } from './vpc-lattice.js' ;
65
66
export { 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 {
38
38
SnsEvent ,
39
39
SnsSqsNotification ,
40
40
SqsEvent ,
41
+ TransferFamilyEvent ,
41
42
VpcLatticeEvent ,
42
43
VpcLatticeEventV2 ,
43
44
} from './schema.js' ;
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ import type {
37
37
SnsSqsNotificationSchema ,
38
38
SqsRecordSchema ,
39
39
SqsSchema ,
40
+ TransferFamilySchema ,
40
41
VpcLatticeSchema ,
41
42
VpcLatticeV2Schema ,
42
43
} from '../schemas/index.js' ;
@@ -129,6 +130,8 @@ type SqsEvent = z.infer<typeof SqsSchema>;
129
130
130
131
type SqsRecord = z . infer < typeof SqsRecordSchema > ;
131
132
133
+ type TransferFamilyEvent = z . infer < typeof TransferFamilySchema > ;
134
+
132
135
type VpcLatticeEvent = z . infer < typeof VpcLatticeSchema > ;
133
136
134
137
type VpcLatticeEventV2 = z . infer < typeof VpcLatticeV2Schema > ;
@@ -171,6 +174,7 @@ export type {
171
174
SnsRecord ,
172
175
SqsEvent ,
173
176
SqsRecord ,
177
+ TransferFamilyEvent ,
174
178
VpcLatticeEvent ,
175
179
VpcLatticeEventV2 ,
176
180
} ;
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