@awsless/validate 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -29,6 +29,7 @@ __export(index_exports, {
29
29
  minDuration: () => minDuration,
30
30
  positive: () => positive,
31
31
  precision: () => precision,
32
+ s3Event: () => s3Event,
32
33
  snsTopic: () => snsTopic,
33
34
  sqsQueue: () => sqsQueue,
34
35
  unique: () => unique,
@@ -129,11 +130,7 @@ var import_valibot6 = require("valibot");
129
130
  var snsTopic = (schema, message = "Invalid SNS Topic payload") => {
130
131
  return (0, import_valibot6.union)(
131
132
  [
132
- (0, import_valibot6.pipe)(
133
- schema,
134
- (0, import_valibot6.transform)((v) => [v])
135
- ),
136
- (0, import_valibot6.array)(schema),
133
+ // Prioritize the expected payload during production
137
134
  (0, import_valibot6.pipe)(
138
135
  (0, import_valibot6.object)({
139
136
  Records: (0, import_valibot6.array)(
@@ -145,7 +142,13 @@ var snsTopic = (schema, message = "Invalid SNS Topic payload") => {
145
142
  )
146
143
  }),
147
144
  (0, import_valibot6.transform)((v) => v.Records.map((r) => r.Sns.Message))
148
- )
145
+ ),
146
+ // These are allowed during testing
147
+ (0, import_valibot6.pipe)(
148
+ schema,
149
+ (0, import_valibot6.transform)((v) => [v])
150
+ ),
151
+ (0, import_valibot6.array)(schema)
149
152
  ],
150
153
  message
151
154
  );
@@ -208,27 +211,82 @@ var dynamoDbStream = (table, message = "Invalid DynamoDB Stream payload") => {
208
211
  );
209
212
  };
210
213
 
214
+ // src/schema/aws/s3-event.ts
215
+ var import_valibot8 = require("valibot");
216
+ var s3Event = () => {
217
+ const schema = (0, import_valibot8.object)({
218
+ event: (0, import_valibot8.string)(),
219
+ bucket: (0, import_valibot8.string)(),
220
+ key: (0, import_valibot8.string)(),
221
+ size: (0, import_valibot8.number)(),
222
+ eTag: (0, import_valibot8.string)(),
223
+ time: (0, import_valibot8.date)()
224
+ });
225
+ return (0, import_valibot8.union)(
226
+ [
227
+ // Prioritize the expected payload during production
228
+ (0, import_valibot8.pipe)(
229
+ (0, import_valibot8.object)({
230
+ Records: (0, import_valibot8.array)(
231
+ (0, import_valibot8.object)({
232
+ eventTime: (0, import_valibot8.pipe)((0, import_valibot8.string)(), (0, import_valibot8.toDate)()),
233
+ eventName: (0, import_valibot8.string)(),
234
+ s3: (0, import_valibot8.object)({
235
+ bucket: (0, import_valibot8.object)({
236
+ name: (0, import_valibot8.string)()
237
+ }),
238
+ object: (0, import_valibot8.object)({
239
+ key: (0, import_valibot8.string)(),
240
+ size: (0, import_valibot8.number)(),
241
+ eTag: (0, import_valibot8.string)()
242
+ })
243
+ })
244
+ })
245
+ )
246
+ }),
247
+ (0, import_valibot8.transform)((input) => {
248
+ return input.Records.map((record) => ({
249
+ event: record.eventName,
250
+ time: record.eventTime,
251
+ bucket: record.s3.bucket.name,
252
+ key: record.s3.object.key,
253
+ size: record.s3.object.size,
254
+ eTag: record.s3.object.eTag
255
+ }));
256
+ })
257
+ ),
258
+ // These are allowed during testing
259
+ (0, import_valibot8.pipe)(
260
+ schema,
261
+ (0, import_valibot8.transform)((v) => [v])
262
+ ),
263
+ (0, import_valibot8.array)(schema)
264
+ ],
265
+ "Invalid S3 Event payload"
266
+ );
267
+ };
268
+
211
269
  // src/validation/positive.ts
212
270
  var import_big_float2 = require("@awsless/big-float");
213
- var import_valibot8 = require("valibot");
271
+ var import_valibot9 = require("valibot");
214
272
  function positive(message = "Invalid positive number") {
215
- return (0, import_valibot8.check)((input) => (0, import_big_float2.isPositive)(input), message);
273
+ return (0, import_valibot9.check)((input) => (0, import_big_float2.isPositive)(input), message);
216
274
  }
217
275
 
218
276
  // src/validation/precision.ts
219
277
  var import_big_float3 = require("@awsless/big-float");
220
- var import_valibot9 = require("valibot");
278
+ var import_valibot10 = require("valibot");
221
279
  function precision(decimals, message = `Invalid ${decimals} precision number`) {
222
- return (0, import_valibot9.check)((input) => {
280
+ return (0, import_valibot10.check)((input) => {
223
281
  const big = (0, import_big_float3.parse)(input.toString());
224
282
  return -big.exponent <= decimals;
225
283
  }, message);
226
284
  }
227
285
 
228
286
  // src/validation/unique.ts
229
- var import_valibot10 = require("valibot");
287
+ var import_valibot11 = require("valibot");
230
288
  function unique(compare = (a, b) => a === b, message = "None unique array") {
231
- return (0, import_valibot10.check)((input) => {
289
+ return (0, import_valibot11.check)((input) => {
232
290
  for (const x in input) {
233
291
  for (const y in input) {
234
292
  if (x !== y && compare(input[x], input[y])) {
@@ -241,12 +299,12 @@ function unique(compare = (a, b) => a === b, message = "None unique array") {
241
299
  }
242
300
 
243
301
  // src/validation/duration.ts
244
- var import_valibot11 = require("valibot");
302
+ var import_valibot12 = require("valibot");
245
303
  function minDuration(min, message = "Invalid duration") {
246
- return (0, import_valibot11.check)((input) => input.value >= min.value, message);
304
+ return (0, import_valibot12.check)((input) => input.value >= min.value, message);
247
305
  }
248
306
  function maxDuration(max, message = "Invalid duration") {
249
- return (0, import_valibot11.check)((input) => input.value <= max.value, message);
307
+ return (0, import_valibot12.check)((input) => input.value <= max.value, message);
250
308
  }
251
309
  // Annotate the CommonJS export names for ESM import in node:
252
310
  0 && (module.exports = {
@@ -258,6 +316,7 @@ function maxDuration(max, message = "Invalid duration") {
258
316
  minDuration,
259
317
  positive,
260
318
  precision,
319
+ s3Event,
261
320
  snsTopic,
262
321
  sqsQueue,
263
322
  unique,
package/dist/index.d.cts CHANGED
@@ -1,47 +1,38 @@
1
1
  import * as valibot from 'valibot';
2
- import { BaseSchema, BaseIssue, ErrorMessage, InferOutput, InstanceIssue, InferInput, CheckIssue } from 'valibot';
2
+ import { GenericSchema, ErrorMessage, GenericIssue, BaseSchema, InferOutput, InferInput, CheckIssue } from 'valibot';
3
3
  export * from 'valibot';
4
4
  import { BigFloat } from '@awsless/big-float';
5
5
  import { UUID } from 'crypto';
6
6
  import { Duration } from '@awsless/duration';
7
7
  import { AnyTable, PrimaryKey, Infer } from '@awsless/dynamodb';
8
8
 
9
- type Schema$2 = BaseSchema<unknown, unknown, BaseIssue<unknown>>;
10
- type JsonIssue = BaseIssue<unknown>;
11
- type JsonSchema<T extends Schema$2> = BaseSchema<string, InferOutput<T>, JsonIssue>;
12
- declare const json: <T extends Schema$2>(schema: T, message?: ErrorMessage<JsonIssue>) => JsonSchema<T>;
9
+ type JsonSchema<T extends GenericSchema> = BaseSchema<string, InferOutput<T>, GenericIssue>;
10
+ declare const json: <T extends GenericSchema>(schema: T, message?: ErrorMessage<GenericIssue>) => JsonSchema<T>;
13
11
 
14
- type BigFloatIssue = BaseIssue<unknown>;
15
- type BigFloatSchema = BaseSchema<BigFloat | string | bigint | number, BigFloat, BigFloatIssue>;
16
- declare function bigfloat(message?: ErrorMessage<BigFloatIssue>): BigFloatSchema;
12
+ type BigFloatSchema = BaseSchema<BigFloat | string | bigint | number, BigFloat, GenericIssue>;
13
+ declare function bigfloat(message?: ErrorMessage<GenericIssue>): BigFloatSchema;
17
14
 
18
- type UuidIssue = BaseIssue<unknown>;
19
- type UuidSchema = BaseSchema<UUID, UUID, UuidIssue>;
20
- declare const uuid: (message?: ErrorMessage<UuidIssue>) => UuidSchema;
15
+ type UuidSchema = BaseSchema<UUID, UUID, GenericIssue>;
16
+ declare const uuid: (message?: ErrorMessage<GenericIssue>) => UuidSchema;
21
17
 
22
- type DurationIssue = InstanceIssue;
23
- type DurationSchema = BaseSchema<Duration, Duration, DurationIssue>;
24
- declare function duration(message?: ErrorMessage<DurationIssue>): DurationSchema;
18
+ type DurationSchema = BaseSchema<Duration, Duration, GenericIssue>;
19
+ declare function duration(message?: ErrorMessage<GenericIssue>): DurationSchema;
25
20
 
26
- type Schema$1 = BaseSchema<unknown, unknown, BaseIssue<unknown>>;
27
- type SqsQueueIssue = BaseIssue<unknown>;
28
- type SqsQueueSchema<S extends Schema$1> = BaseSchema<InferInput<S> | InferInput<S>[] | {
21
+ type SqsQueueSchema<S extends GenericSchema> = BaseSchema<InferInput<S> | InferInput<S>[] | {
29
22
  Records: {
30
23
  body: string | InferInput<S>;
31
24
  }[];
32
- }, InferOutput<S>[], SqsQueueIssue>;
33
- declare const sqsQueue: <S extends Schema$1>(schema: S, message?: ErrorMessage<SqsQueueIssue>) => SqsQueueSchema<S>;
25
+ }, InferOutput<S>[], GenericIssue>;
26
+ declare const sqsQueue: <S extends GenericSchema>(schema: S, message?: ErrorMessage<GenericIssue>) => SqsQueueSchema<S>;
34
27
 
35
- type Schema = BaseSchema<unknown, unknown, BaseIssue<unknown>>;
36
- type SnsTopicIssue = BaseIssue<unknown>;
37
- type SnsTopicSchema<S extends Schema> = BaseSchema<InferInput<S> | InferInput<S>[] | {
28
+ type SnsTopicSchema<S extends GenericSchema> = BaseSchema<InferInput<S> | InferInput<S>[] | {
38
29
  Records: {
39
30
  Sns: {
40
31
  Message: string | InferInput<S>;
41
32
  };
42
33
  }[];
43
- }, InferOutput<S>[], SnsTopicIssue>;
44
- declare const snsTopic: <S extends Schema>(schema: S, message?: ErrorMessage<SnsTopicIssue>) => SnsTopicSchema<S>;
34
+ }, InferOutput<S>[], GenericIssue>;
35
+ declare const snsTopic: <S extends GenericSchema>(schema: S, message?: ErrorMessage<GenericIssue>) => SnsTopicSchema<S>;
45
36
 
46
37
  type DynamoDBStreamInputRecord = {
47
38
  eventName: 'MODIFY';
@@ -77,11 +68,25 @@ type DynamoDBStreamOutputRecord<T extends AnyTable> = {
77
68
  keys: PrimaryKey<T>;
78
69
  old: Infer<T>;
79
70
  };
80
- type DynamoDBStreamIssue = BaseIssue<unknown>;
81
71
  type DynamoDBStreamSchema<T extends AnyTable> = BaseSchema<{
82
72
  Records: DynamoDBStreamInputRecord[];
83
- }, DynamoDBStreamOutputRecord<T>[], DynamoDBStreamIssue>;
84
- declare const dynamoDbStream: <T extends AnyTable>(table: T, message?: ErrorMessage<DynamoDBStreamIssue>) => DynamoDBStreamSchema<T>;
73
+ }, DynamoDBStreamOutputRecord<T>[], GenericIssue>;
74
+ declare const dynamoDbStream: <T extends AnyTable>(table: T, message?: ErrorMessage<GenericIssue>) => DynamoDBStreamSchema<T>;
75
+
76
+ type S3EventOutput = {
77
+ event: string;
78
+ time: Date;
79
+ bucket: string;
80
+ key: string;
81
+ size: number;
82
+ eTag: string;
83
+ };
84
+ type S3EventSchema = BaseSchema<S3EventOutput | S3EventOutput[] | {
85
+ Records: {
86
+ eventTime: string;
87
+ }[];
88
+ }, S3EventOutput[], GenericIssue>;
89
+ declare const s3Event: () => S3EventSchema;
85
90
 
86
91
  declare function positive<T extends BigFloat | number>(message?: ErrorMessage<CheckIssue<T>>): valibot.CheckAction<T, ErrorMessage<CheckIssue<T>>>;
87
92
 
@@ -92,4 +97,4 @@ declare function unique<T extends any[]>(compare?: (a: T[number], b: T[number])
92
97
  declare function minDuration(min: Duration, message?: ErrorMessage<CheckIssue<Duration>>): valibot.CheckAction<Duration, ErrorMessage<CheckIssue<Duration>>>;
93
98
  declare function maxDuration(max: Duration, message?: ErrorMessage<CheckIssue<Duration>>): valibot.CheckAction<Duration, ErrorMessage<CheckIssue<Duration>>>;
94
99
 
95
- export { type BigFloatSchema, type DurationSchema, type DynamoDBStreamSchema, type JsonSchema, type SnsTopicSchema, type SqsQueueSchema, type UuidSchema, bigfloat, duration, dynamoDbStream, json, maxDuration, minDuration, positive, precision, snsTopic, sqsQueue, unique, uuid };
100
+ export { type BigFloatSchema, type DurationSchema, type DynamoDBStreamSchema, type JsonSchema, type S3EventSchema, type SnsTopicSchema, type SqsQueueSchema, type UuidSchema, bigfloat, duration, dynamoDbStream, json, maxDuration, minDuration, positive, precision, s3Event, snsTopic, sqsQueue, unique, uuid };
package/dist/index.d.ts CHANGED
@@ -1,47 +1,38 @@
1
1
  import * as valibot from 'valibot';
2
- import { BaseSchema, BaseIssue, ErrorMessage, InferOutput, InstanceIssue, InferInput, CheckIssue } from 'valibot';
2
+ import { GenericSchema, ErrorMessage, GenericIssue, BaseSchema, InferOutput, InferInput, CheckIssue } from 'valibot';
3
3
  export * from 'valibot';
4
4
  import { BigFloat } from '@awsless/big-float';
5
5
  import { UUID } from 'crypto';
6
6
  import { Duration } from '@awsless/duration';
7
7
  import { AnyTable, PrimaryKey, Infer } from '@awsless/dynamodb';
8
8
 
9
- type Schema$2 = BaseSchema<unknown, unknown, BaseIssue<unknown>>;
10
- type JsonIssue = BaseIssue<unknown>;
11
- type JsonSchema<T extends Schema$2> = BaseSchema<string, InferOutput<T>, JsonIssue>;
12
- declare const json: <T extends Schema$2>(schema: T, message?: ErrorMessage<JsonIssue>) => JsonSchema<T>;
9
+ type JsonSchema<T extends GenericSchema> = BaseSchema<string, InferOutput<T>, GenericIssue>;
10
+ declare const json: <T extends GenericSchema>(schema: T, message?: ErrorMessage<GenericIssue>) => JsonSchema<T>;
13
11
 
14
- type BigFloatIssue = BaseIssue<unknown>;
15
- type BigFloatSchema = BaseSchema<BigFloat | string | bigint | number, BigFloat, BigFloatIssue>;
16
- declare function bigfloat(message?: ErrorMessage<BigFloatIssue>): BigFloatSchema;
12
+ type BigFloatSchema = BaseSchema<BigFloat | string | bigint | number, BigFloat, GenericIssue>;
13
+ declare function bigfloat(message?: ErrorMessage<GenericIssue>): BigFloatSchema;
17
14
 
18
- type UuidIssue = BaseIssue<unknown>;
19
- type UuidSchema = BaseSchema<UUID, UUID, UuidIssue>;
20
- declare const uuid: (message?: ErrorMessage<UuidIssue>) => UuidSchema;
15
+ type UuidSchema = BaseSchema<UUID, UUID, GenericIssue>;
16
+ declare const uuid: (message?: ErrorMessage<GenericIssue>) => UuidSchema;
21
17
 
22
- type DurationIssue = InstanceIssue;
23
- type DurationSchema = BaseSchema<Duration, Duration, DurationIssue>;
24
- declare function duration(message?: ErrorMessage<DurationIssue>): DurationSchema;
18
+ type DurationSchema = BaseSchema<Duration, Duration, GenericIssue>;
19
+ declare function duration(message?: ErrorMessage<GenericIssue>): DurationSchema;
25
20
 
26
- type Schema$1 = BaseSchema<unknown, unknown, BaseIssue<unknown>>;
27
- type SqsQueueIssue = BaseIssue<unknown>;
28
- type SqsQueueSchema<S extends Schema$1> = BaseSchema<InferInput<S> | InferInput<S>[] | {
21
+ type SqsQueueSchema<S extends GenericSchema> = BaseSchema<InferInput<S> | InferInput<S>[] | {
29
22
  Records: {
30
23
  body: string | InferInput<S>;
31
24
  }[];
32
- }, InferOutput<S>[], SqsQueueIssue>;
33
- declare const sqsQueue: <S extends Schema$1>(schema: S, message?: ErrorMessage<SqsQueueIssue>) => SqsQueueSchema<S>;
25
+ }, InferOutput<S>[], GenericIssue>;
26
+ declare const sqsQueue: <S extends GenericSchema>(schema: S, message?: ErrorMessage<GenericIssue>) => SqsQueueSchema<S>;
34
27
 
35
- type Schema = BaseSchema<unknown, unknown, BaseIssue<unknown>>;
36
- type SnsTopicIssue = BaseIssue<unknown>;
37
- type SnsTopicSchema<S extends Schema> = BaseSchema<InferInput<S> | InferInput<S>[] | {
28
+ type SnsTopicSchema<S extends GenericSchema> = BaseSchema<InferInput<S> | InferInput<S>[] | {
38
29
  Records: {
39
30
  Sns: {
40
31
  Message: string | InferInput<S>;
41
32
  };
42
33
  }[];
43
- }, InferOutput<S>[], SnsTopicIssue>;
44
- declare const snsTopic: <S extends Schema>(schema: S, message?: ErrorMessage<SnsTopicIssue>) => SnsTopicSchema<S>;
34
+ }, InferOutput<S>[], GenericIssue>;
35
+ declare const snsTopic: <S extends GenericSchema>(schema: S, message?: ErrorMessage<GenericIssue>) => SnsTopicSchema<S>;
45
36
 
46
37
  type DynamoDBStreamInputRecord = {
47
38
  eventName: 'MODIFY';
@@ -77,11 +68,25 @@ type DynamoDBStreamOutputRecord<T extends AnyTable> = {
77
68
  keys: PrimaryKey<T>;
78
69
  old: Infer<T>;
79
70
  };
80
- type DynamoDBStreamIssue = BaseIssue<unknown>;
81
71
  type DynamoDBStreamSchema<T extends AnyTable> = BaseSchema<{
82
72
  Records: DynamoDBStreamInputRecord[];
83
- }, DynamoDBStreamOutputRecord<T>[], DynamoDBStreamIssue>;
84
- declare const dynamoDbStream: <T extends AnyTable>(table: T, message?: ErrorMessage<DynamoDBStreamIssue>) => DynamoDBStreamSchema<T>;
73
+ }, DynamoDBStreamOutputRecord<T>[], GenericIssue>;
74
+ declare const dynamoDbStream: <T extends AnyTable>(table: T, message?: ErrorMessage<GenericIssue>) => DynamoDBStreamSchema<T>;
75
+
76
+ type S3EventOutput = {
77
+ event: string;
78
+ time: Date;
79
+ bucket: string;
80
+ key: string;
81
+ size: number;
82
+ eTag: string;
83
+ };
84
+ type S3EventSchema = BaseSchema<S3EventOutput | S3EventOutput[] | {
85
+ Records: {
86
+ eventTime: string;
87
+ }[];
88
+ }, S3EventOutput[], GenericIssue>;
89
+ declare const s3Event: () => S3EventSchema;
85
90
 
86
91
  declare function positive<T extends BigFloat | number>(message?: ErrorMessage<CheckIssue<T>>): valibot.CheckAction<T, ErrorMessage<CheckIssue<T>>>;
87
92
 
@@ -92,4 +97,4 @@ declare function unique<T extends any[]>(compare?: (a: T[number], b: T[number])
92
97
  declare function minDuration(min: Duration, message?: ErrorMessage<CheckIssue<Duration>>): valibot.CheckAction<Duration, ErrorMessage<CheckIssue<Duration>>>;
93
98
  declare function maxDuration(max: Duration, message?: ErrorMessage<CheckIssue<Duration>>): valibot.CheckAction<Duration, ErrorMessage<CheckIssue<Duration>>>;
94
99
 
95
- export { type BigFloatSchema, type DurationSchema, type DynamoDBStreamSchema, type JsonSchema, type SnsTopicSchema, type SqsQueueSchema, type UuidSchema, bigfloat, duration, dynamoDbStream, json, maxDuration, minDuration, positive, precision, snsTopic, sqsQueue, unique, uuid };
100
+ export { type BigFloatSchema, type DurationSchema, type DynamoDBStreamSchema, type JsonSchema, type S3EventSchema, type SnsTopicSchema, type SqsQueueSchema, type UuidSchema, bigfloat, duration, dynamoDbStream, json, maxDuration, minDuration, positive, precision, s3Event, snsTopic, sqsQueue, unique, uuid };
package/dist/index.js CHANGED
@@ -114,11 +114,7 @@ import {
114
114
  var snsTopic = (schema, message = "Invalid SNS Topic payload") => {
115
115
  return union3(
116
116
  [
117
- pipe5(
118
- schema,
119
- transform3((v) => [v])
120
- ),
121
- array2(schema),
117
+ // Prioritize the expected payload during production
122
118
  pipe5(
123
119
  object2({
124
120
  Records: array2(
@@ -130,14 +126,28 @@ var snsTopic = (schema, message = "Invalid SNS Topic payload") => {
130
126
  )
131
127
  }),
132
128
  transform3((v) => v.Records.map((r) => r.Sns.Message))
133
- )
129
+ ),
130
+ // These are allowed during testing
131
+ pipe5(
132
+ schema,
133
+ transform3((v) => [v])
134
+ ),
135
+ array2(schema)
134
136
  ],
135
137
  message
136
138
  );
137
139
  };
138
140
 
139
141
  // src/schema/aws/dynamodb-stream.ts
140
- import { array as array3, literal, object as object3, pipe as pipe6, transform as transform4, unknown, variant } from "valibot";
142
+ import {
143
+ array as array3,
144
+ literal,
145
+ object as object3,
146
+ pipe as pipe6,
147
+ transform as transform4,
148
+ unknown,
149
+ variant
150
+ } from "valibot";
141
151
  var dynamoDbStream = (table, message = "Invalid DynamoDB Stream payload") => {
142
152
  const unmarshall = () => pipe6(
143
153
  unknown(),
@@ -193,6 +203,61 @@ var dynamoDbStream = (table, message = "Invalid DynamoDB Stream payload") => {
193
203
  );
194
204
  };
195
205
 
206
+ // src/schema/aws/s3-event.ts
207
+ import { array as array4, date, number as number2, object as object4, pipe as pipe7, string as string4, toDate, transform as transform5, union as union4 } from "valibot";
208
+ var s3Event = () => {
209
+ const schema = object4({
210
+ event: string4(),
211
+ bucket: string4(),
212
+ key: string4(),
213
+ size: number2(),
214
+ eTag: string4(),
215
+ time: date()
216
+ });
217
+ return union4(
218
+ [
219
+ // Prioritize the expected payload during production
220
+ pipe7(
221
+ object4({
222
+ Records: array4(
223
+ object4({
224
+ eventTime: pipe7(string4(), toDate()),
225
+ eventName: string4(),
226
+ s3: object4({
227
+ bucket: object4({
228
+ name: string4()
229
+ }),
230
+ object: object4({
231
+ key: string4(),
232
+ size: number2(),
233
+ eTag: string4()
234
+ })
235
+ })
236
+ })
237
+ )
238
+ }),
239
+ transform5((input) => {
240
+ return input.Records.map((record) => ({
241
+ event: record.eventName,
242
+ time: record.eventTime,
243
+ bucket: record.s3.bucket.name,
244
+ key: record.s3.object.key,
245
+ size: record.s3.object.size,
246
+ eTag: record.s3.object.eTag
247
+ }));
248
+ })
249
+ ),
250
+ // These are allowed during testing
251
+ pipe7(
252
+ schema,
253
+ transform5((v) => [v])
254
+ ),
255
+ array4(schema)
256
+ ],
257
+ "Invalid S3 Event payload"
258
+ );
259
+ };
260
+
196
261
  // src/validation/positive.ts
197
262
  import { isPositive } from "@awsless/big-float";
198
263
  import { check } from "valibot";
@@ -242,6 +307,7 @@ export {
242
307
  minDuration,
243
308
  positive,
244
309
  precision,
310
+ s3Event,
245
311
  snsTopic,
246
312
  sqsQueue,
247
313
  unique,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/validate",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {
@@ -24,15 +24,15 @@
24
24
  }
25
25
  },
26
26
  "peerDependencies": {
27
+ "@awsless/big-float": "^0.1.5",
27
28
  "@awsless/duration": "^0.0.4",
28
29
  "@awsless/json": "^0.0.10",
29
- "@awsless/dynamodb": "^0.3.2",
30
- "@awsless/big-float": "^0.1.5"
30
+ "@awsless/dynamodb": "^0.3.2"
31
31
  },
32
32
  "devDependencies": {
33
- "@awsless/big-float": "^0.1.5",
34
- "@awsless/dynamodb": "^0.3.2",
35
33
  "@awsless/duration": "^0.0.4",
34
+ "@awsless/dynamodb": "^0.3.2",
35
+ "@awsless/big-float": "^0.1.5",
36
36
  "@awsless/json": "^0.0.10"
37
37
  },
38
38
  "dependencies": {