@awsless/validate 0.0.17 → 0.0.18
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 +12 -9
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +28 -25
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -122,22 +122,25 @@ function date(arg1, arg2) {
|
|
|
122
122
|
// src/schema/uuid.ts
|
|
123
123
|
var import_valibot5 = require("valibot");
|
|
124
124
|
var uuid = (error) => {
|
|
125
|
-
return (0, import_valibot5.
|
|
125
|
+
return (0, import_valibot5.string)(error ?? "Invalid UUID", [(0, import_valibot5.uuid)()]);
|
|
126
126
|
};
|
|
127
127
|
|
|
128
128
|
// src/schema/duration.ts
|
|
129
|
-
var import_valibot6 = require("valibot");
|
|
130
129
|
var import_duration = require("@awsless/duration");
|
|
130
|
+
var import_valibot6 = require("valibot");
|
|
131
131
|
function duration(arg1, arg2) {
|
|
132
132
|
const [msg, pipe] = (0, import_valibot6.defaultArgs)(arg1, arg2);
|
|
133
133
|
const error = msg ?? "Invalid duration";
|
|
134
|
-
return (0, import_valibot6.
|
|
135
|
-
(0, import_valibot6.
|
|
136
|
-
(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
134
|
+
return (0, import_valibot6.union)([
|
|
135
|
+
(0, import_valibot6.instance)(import_duration.Duration, pipe),
|
|
136
|
+
(0, import_valibot6.transform)(
|
|
137
|
+
(0, import_valibot6.string)(error, [(0, import_valibot6.regex)(/^[0-9]+ (milliseconds?|seconds?|minutes?|hours?|days?|weeks?)/, error)]),
|
|
138
|
+
(value) => {
|
|
139
|
+
return (0, import_duration.parse)(value);
|
|
140
|
+
},
|
|
141
|
+
pipe
|
|
142
|
+
)
|
|
143
|
+
]);
|
|
141
144
|
}
|
|
142
145
|
|
|
143
146
|
// src/schema/aws/sqs-queue.ts
|
package/dist/index.d.cts
CHANGED
|
@@ -24,10 +24,10 @@ type DateSchema = BaseSchema<string | Date, Date>;
|
|
|
24
24
|
declare function date(pipe?: Pipe<Date>): DateSchema;
|
|
25
25
|
declare function date(error?: ErrorMessage, pipe?: Pipe<Date>): DateSchema;
|
|
26
26
|
|
|
27
|
-
type UuidSchema =
|
|
27
|
+
type UuidSchema = BaseSchema<UUID, UUID>;
|
|
28
28
|
declare const uuid: (error?: ErrorMessage) => UuidSchema;
|
|
29
29
|
|
|
30
|
-
type DurationSchema = BaseSchema<DurationFormat, Duration>;
|
|
30
|
+
type DurationSchema = BaseSchema<DurationFormat | Duration, Duration>;
|
|
31
31
|
declare function duration(pipe?: Pipe<Duration>): DurationSchema;
|
|
32
32
|
declare function duration(error?: ErrorMessage, pipe?: Pipe<Duration>): DurationSchema;
|
|
33
33
|
|
package/dist/index.d.ts
CHANGED
|
@@ -24,10 +24,10 @@ type DateSchema = BaseSchema<string | Date, Date>;
|
|
|
24
24
|
declare function date(pipe?: Pipe<Date>): DateSchema;
|
|
25
25
|
declare function date(error?: ErrorMessage, pipe?: Pipe<Date>): DateSchema;
|
|
26
26
|
|
|
27
|
-
type UuidSchema =
|
|
27
|
+
type UuidSchema = BaseSchema<UUID, UUID>;
|
|
28
28
|
declare const uuid: (error?: ErrorMessage) => UuidSchema;
|
|
29
29
|
|
|
30
|
-
type DurationSchema = BaseSchema<DurationFormat, Duration>;
|
|
30
|
+
type DurationSchema = BaseSchema<DurationFormat | Duration, Duration>;
|
|
31
31
|
declare function duration(pipe?: Pipe<Duration>): DurationSchema;
|
|
32
32
|
declare function duration(error?: ErrorMessage, pipe?: Pipe<Duration>): DurationSchema;
|
|
33
33
|
|
package/dist/index.js
CHANGED
|
@@ -22,14 +22,14 @@ var json = (schema) => {
|
|
|
22
22
|
import { BigFloat } from "@awsless/big-float";
|
|
23
23
|
import {
|
|
24
24
|
bigint,
|
|
25
|
+
custom,
|
|
25
26
|
defaultArgs,
|
|
26
27
|
instance,
|
|
27
28
|
number,
|
|
28
29
|
object,
|
|
29
30
|
string as string2,
|
|
30
31
|
transform as transform2,
|
|
31
|
-
union
|
|
32
|
-
custom
|
|
32
|
+
union
|
|
33
33
|
} from "valibot";
|
|
34
34
|
var make = (value) => new BigFloat(value);
|
|
35
35
|
function bigfloat(arg1, arg2) {
|
|
@@ -92,35 +92,38 @@ function date(arg1, arg2) {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
// src/schema/uuid.ts
|
|
95
|
-
import {
|
|
95
|
+
import { uuid as base3, string as string5 } from "valibot";
|
|
96
96
|
var uuid = (error) => {
|
|
97
|
-
return
|
|
97
|
+
return string5(error ?? "Invalid UUID", [base3()]);
|
|
98
98
|
};
|
|
99
99
|
|
|
100
100
|
// src/schema/duration.ts
|
|
101
|
-
import {
|
|
102
|
-
import {
|
|
101
|
+
import { Duration, parse as parse2 } from "@awsless/duration";
|
|
102
|
+
import { defaultArgs as defaultArgs4, instance as instance2, regex as regex2, string as string6, transform as transform5, union as union4 } from "valibot";
|
|
103
103
|
function duration(arg1, arg2) {
|
|
104
104
|
const [msg, pipe] = defaultArgs4(arg1, arg2);
|
|
105
105
|
const error = msg ?? "Invalid duration";
|
|
106
|
-
return
|
|
107
|
-
|
|
108
|
-
(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
106
|
+
return union4([
|
|
107
|
+
instance2(Duration, pipe),
|
|
108
|
+
transform5(
|
|
109
|
+
string6(error, [regex2(/^[0-9]+ (milliseconds?|seconds?|minutes?|hours?|days?|weeks?)/, error)]),
|
|
110
|
+
(value) => {
|
|
111
|
+
return parse2(value);
|
|
112
|
+
},
|
|
113
|
+
pipe
|
|
114
|
+
)
|
|
115
|
+
]);
|
|
113
116
|
}
|
|
114
117
|
|
|
115
118
|
// src/schema/aws/sqs-queue.ts
|
|
116
|
-
import { array, object as object2, transform as
|
|
119
|
+
import { array, object as object2, transform as transform6, union as union5, unknown } from "valibot";
|
|
117
120
|
var sqsQueue = (body) => {
|
|
118
121
|
const schema = body ?? unknown();
|
|
119
|
-
return
|
|
122
|
+
return union5(
|
|
120
123
|
[
|
|
121
|
-
|
|
124
|
+
transform6(schema, (input) => [input]),
|
|
122
125
|
array(schema),
|
|
123
|
-
|
|
126
|
+
transform6(
|
|
124
127
|
object2({
|
|
125
128
|
Records: array(
|
|
126
129
|
object2({
|
|
@@ -138,14 +141,14 @@ var sqsQueue = (body) => {
|
|
|
138
141
|
};
|
|
139
142
|
|
|
140
143
|
// src/schema/aws/sns-topic.ts
|
|
141
|
-
import { array as array2, object as object3, transform as
|
|
144
|
+
import { array as array2, object as object3, transform as transform7, union as union6, unknown as unknown2 } from "valibot";
|
|
142
145
|
var snsTopic = (body) => {
|
|
143
146
|
const schema = body ?? unknown2();
|
|
144
|
-
return
|
|
147
|
+
return union6(
|
|
145
148
|
[
|
|
146
|
-
|
|
149
|
+
transform7(schema, (input) => [input]),
|
|
147
150
|
array2(schema),
|
|
148
|
-
|
|
151
|
+
transform7(
|
|
149
152
|
object3({
|
|
150
153
|
Records: array2(
|
|
151
154
|
object3({
|
|
@@ -165,17 +168,17 @@ var snsTopic = (body) => {
|
|
|
165
168
|
};
|
|
166
169
|
|
|
167
170
|
// src/schema/aws/dynamodb-stream.ts
|
|
168
|
-
import { array as array3, literal, object as object4, optional, transform as
|
|
171
|
+
import { array as array3, literal, object as object4, optional, transform as transform8, union as union7, unknown as unknown3 } from "valibot";
|
|
169
172
|
var dynamoDbStream = (table) => {
|
|
170
|
-
const marshall = () =>
|
|
171
|
-
return
|
|
173
|
+
const marshall = () => transform8(unknown3(), (value) => table.unmarshall(value));
|
|
174
|
+
return transform8(
|
|
172
175
|
object4(
|
|
173
176
|
{
|
|
174
177
|
Records: array3(
|
|
175
178
|
object4({
|
|
176
179
|
// For some reason picklist fails to build.
|
|
177
180
|
// eventName: picklist(['MODIFY', 'INSERT', 'REMOVE']),
|
|
178
|
-
eventName:
|
|
181
|
+
eventName: union7([literal("MODIFY"), literal("INSERT"), literal("REMOVE")]),
|
|
179
182
|
dynamodb: object4({
|
|
180
183
|
Keys: marshall(),
|
|
181
184
|
OldImage: optional(marshall()),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awsless/validate",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -24,16 +24,16 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@awsless/duration": "^0.0.1",
|
|
28
27
|
"@awsless/big-float": "^0.0.4",
|
|
29
|
-
"@awsless/
|
|
28
|
+
"@awsless/duration": "^0.0.2",
|
|
29
|
+
"@awsless/json": "^0.0.7",
|
|
30
30
|
"@awsless/dynamodb": "^0.1.5"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@awsless/big-float": "^0.0.4",
|
|
34
|
-
"@awsless/duration": "^0.0.1",
|
|
35
34
|
"@awsless/dynamodb": "^0.1.5",
|
|
36
|
-
"@awsless/json": "^0.0.
|
|
35
|
+
"@awsless/json": "^0.0.7",
|
|
36
|
+
"@awsless/duration": "^0.0.2"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"valibot": "^0.30.0"
|