@awsless/validate 0.0.15 → 0.0.17
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/README.MD +0 -0
- package/dist/index.cjs +2 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +4 -3
- package/package.json +7 -5
package/README.MD
ADDED
|
File without changes
|
package/dist/index.cjs
CHANGED
|
@@ -40,13 +40,14 @@ module.exports = __toCommonJS(src_exports);
|
|
|
40
40
|
__reExport(src_exports, require("valibot"), module.exports);
|
|
41
41
|
|
|
42
42
|
// src/schema/json.ts
|
|
43
|
+
var import_json = require("@awsless/json");
|
|
43
44
|
var import_valibot = require("valibot");
|
|
44
45
|
var json = (schema) => {
|
|
45
46
|
return (0, import_valibot.transform)(
|
|
46
47
|
(0, import_valibot.string)(),
|
|
47
48
|
(value) => {
|
|
48
49
|
try {
|
|
49
|
-
return
|
|
50
|
+
return (0, import_json.parse)(value);
|
|
50
51
|
} catch (error) {
|
|
51
52
|
return null;
|
|
52
53
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -4,10 +4,10 @@ export * from 'valibot';
|
|
|
4
4
|
import { BigFloat } from '@awsless/big-float';
|
|
5
5
|
import { UUID } from 'crypto';
|
|
6
6
|
import { DurationFormat, Duration } from '@awsless/duration';
|
|
7
|
-
import {
|
|
7
|
+
import { AnyTable, PrimaryKey } from '@awsless/dynamodb';
|
|
8
8
|
|
|
9
9
|
type JsonSchema<T extends BaseSchema> = SchemaWithTransform<StringSchema, Output<T>>;
|
|
10
|
-
declare const json: <T extends BaseSchema
|
|
10
|
+
declare const json: <T extends BaseSchema>(schema: T) => JsonSchema<T>;
|
|
11
11
|
|
|
12
12
|
type BigFloatSchema = BaseSchema<string | number | BigFloat | {
|
|
13
13
|
exponent: number;
|
|
@@ -36,7 +36,7 @@ type SqsQueueSchema<S extends BaseSchema = UnknownSchema> = BaseSchema<Input<S>
|
|
|
36
36
|
body: string | Input<S>;
|
|
37
37
|
}[];
|
|
38
38
|
}, Output<S>[]>;
|
|
39
|
-
declare const sqsQueue: <S extends BaseSchema
|
|
39
|
+
declare const sqsQueue: <S extends BaseSchema = UnknownSchema<unknown>>(body?: S) => SqsQueueSchema<S>;
|
|
40
40
|
|
|
41
41
|
type SnsTopicSchema<S extends BaseSchema = UnknownSchema> = BaseSchema<Input<S> | Input<S>[] | {
|
|
42
42
|
Records: {
|
|
@@ -45,10 +45,10 @@ type SnsTopicSchema<S extends BaseSchema = UnknownSchema> = BaseSchema<Input<S>
|
|
|
45
45
|
};
|
|
46
46
|
}[];
|
|
47
47
|
}, Output<S>[]>;
|
|
48
|
-
declare const snsTopic: <S extends BaseSchema
|
|
48
|
+
declare const snsTopic: <S extends BaseSchema = UnknownSchema<unknown>>(body?: S) => SnsTopicSchema<S>;
|
|
49
49
|
|
|
50
50
|
type EventName = 'MODIFY' | 'INSERT' | 'REMOVE';
|
|
51
|
-
type DynamoDBStreamSchema<T extends
|
|
51
|
+
type DynamoDBStreamSchema<T extends AnyTable> = BaseSchema<{
|
|
52
52
|
Records: {
|
|
53
53
|
eventName: EventName;
|
|
54
54
|
dynamodb: {
|
|
@@ -63,7 +63,7 @@ type DynamoDBStreamSchema<T extends TableDefinition<any, any, any, any>> = BaseS
|
|
|
63
63
|
old?: T['schema']['OUTPUT'];
|
|
64
64
|
new?: T['schema']['OUTPUT'];
|
|
65
65
|
}[]>;
|
|
66
|
-
declare const dynamoDbStream: <T extends
|
|
66
|
+
declare const dynamoDbStream: <T extends AnyTable>(table: T) => DynamoDBStreamSchema<T>;
|
|
67
67
|
|
|
68
68
|
declare function positive<T extends BigFloat | number>(error?: ErrorMessage): valibot.CustomValidation<T>;
|
|
69
69
|
|
|
@@ -74,4 +74,4 @@ declare function unique<T extends any[]>(compare?: (a: T[number], b: T[number])
|
|
|
74
74
|
declare function minDuration<T extends Duration>(min: Duration, error?: ErrorMessage): valibot.CustomValidation<T>;
|
|
75
75
|
declare function maxDuration<T extends Duration>(max: Duration, error?: ErrorMessage): valibot.CustomValidation<T>;
|
|
76
76
|
|
|
77
|
-
export { BigFloatSchema, BigIntSchema, DateSchema, DurationSchema, DynamoDBStreamSchema, JsonSchema, SnsTopicSchema, SqsQueueSchema, UuidSchema, bigfloat, bigint, date, duration, dynamoDbStream, json, maxDuration, minDuration, positive, precision, snsTopic, sqsQueue, unique, uuid };
|
|
77
|
+
export { type BigFloatSchema, type BigIntSchema, type DateSchema, type DurationSchema, type DynamoDBStreamSchema, type JsonSchema, type SnsTopicSchema, type SqsQueueSchema, type UuidSchema, bigfloat, bigint, date, duration, dynamoDbStream, json, maxDuration, minDuration, positive, precision, snsTopic, sqsQueue, unique, uuid };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,10 +4,10 @@ export * from 'valibot';
|
|
|
4
4
|
import { BigFloat } from '@awsless/big-float';
|
|
5
5
|
import { UUID } from 'crypto';
|
|
6
6
|
import { DurationFormat, Duration } from '@awsless/duration';
|
|
7
|
-
import {
|
|
7
|
+
import { AnyTable, PrimaryKey } from '@awsless/dynamodb';
|
|
8
8
|
|
|
9
9
|
type JsonSchema<T extends BaseSchema> = SchemaWithTransform<StringSchema, Output<T>>;
|
|
10
|
-
declare const json: <T extends BaseSchema
|
|
10
|
+
declare const json: <T extends BaseSchema>(schema: T) => JsonSchema<T>;
|
|
11
11
|
|
|
12
12
|
type BigFloatSchema = BaseSchema<string | number | BigFloat | {
|
|
13
13
|
exponent: number;
|
|
@@ -36,7 +36,7 @@ type SqsQueueSchema<S extends BaseSchema = UnknownSchema> = BaseSchema<Input<S>
|
|
|
36
36
|
body: string | Input<S>;
|
|
37
37
|
}[];
|
|
38
38
|
}, Output<S>[]>;
|
|
39
|
-
declare const sqsQueue: <S extends BaseSchema
|
|
39
|
+
declare const sqsQueue: <S extends BaseSchema = UnknownSchema<unknown>>(body?: S) => SqsQueueSchema<S>;
|
|
40
40
|
|
|
41
41
|
type SnsTopicSchema<S extends BaseSchema = UnknownSchema> = BaseSchema<Input<S> | Input<S>[] | {
|
|
42
42
|
Records: {
|
|
@@ -45,10 +45,10 @@ type SnsTopicSchema<S extends BaseSchema = UnknownSchema> = BaseSchema<Input<S>
|
|
|
45
45
|
};
|
|
46
46
|
}[];
|
|
47
47
|
}, Output<S>[]>;
|
|
48
|
-
declare const snsTopic: <S extends BaseSchema
|
|
48
|
+
declare const snsTopic: <S extends BaseSchema = UnknownSchema<unknown>>(body?: S) => SnsTopicSchema<S>;
|
|
49
49
|
|
|
50
50
|
type EventName = 'MODIFY' | 'INSERT' | 'REMOVE';
|
|
51
|
-
type DynamoDBStreamSchema<T extends
|
|
51
|
+
type DynamoDBStreamSchema<T extends AnyTable> = BaseSchema<{
|
|
52
52
|
Records: {
|
|
53
53
|
eventName: EventName;
|
|
54
54
|
dynamodb: {
|
|
@@ -63,7 +63,7 @@ type DynamoDBStreamSchema<T extends TableDefinition<any, any, any, any>> = BaseS
|
|
|
63
63
|
old?: T['schema']['OUTPUT'];
|
|
64
64
|
new?: T['schema']['OUTPUT'];
|
|
65
65
|
}[]>;
|
|
66
|
-
declare const dynamoDbStream: <T extends
|
|
66
|
+
declare const dynamoDbStream: <T extends AnyTable>(table: T) => DynamoDBStreamSchema<T>;
|
|
67
67
|
|
|
68
68
|
declare function positive<T extends BigFloat | number>(error?: ErrorMessage): valibot.CustomValidation<T>;
|
|
69
69
|
|
|
@@ -74,4 +74,4 @@ declare function unique<T extends any[]>(compare?: (a: T[number], b: T[number])
|
|
|
74
74
|
declare function minDuration<T extends Duration>(min: Duration, error?: ErrorMessage): valibot.CustomValidation<T>;
|
|
75
75
|
declare function maxDuration<T extends Duration>(max: Duration, error?: ErrorMessage): valibot.CustomValidation<T>;
|
|
76
76
|
|
|
77
|
-
export { BigFloatSchema, BigIntSchema, DateSchema, DurationSchema, DynamoDBStreamSchema, JsonSchema, SnsTopicSchema, SqsQueueSchema, UuidSchema, bigfloat, bigint, date, duration, dynamoDbStream, json, maxDuration, minDuration, positive, precision, snsTopic, sqsQueue, unique, uuid };
|
|
77
|
+
export { type BigFloatSchema, type BigIntSchema, type DateSchema, type DurationSchema, type DynamoDBStreamSchema, type JsonSchema, type SnsTopicSchema, type SqsQueueSchema, type UuidSchema, bigfloat, bigint, date, duration, dynamoDbStream, json, maxDuration, minDuration, positive, precision, snsTopic, sqsQueue, unique, uuid };
|
package/dist/index.js
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
export * from "valibot";
|
|
3
3
|
|
|
4
4
|
// src/schema/json.ts
|
|
5
|
+
import { parse } from "@awsless/json";
|
|
5
6
|
import { string, transform } from "valibot";
|
|
6
7
|
var json = (schema) => {
|
|
7
8
|
return transform(
|
|
8
9
|
string(),
|
|
9
10
|
(value) => {
|
|
10
11
|
try {
|
|
11
|
-
return
|
|
12
|
+
return parse(value);
|
|
12
13
|
} catch (error) {
|
|
13
14
|
return null;
|
|
14
15
|
}
|
|
@@ -98,14 +99,14 @@ var uuid = (error) => {
|
|
|
98
99
|
|
|
99
100
|
// src/schema/duration.ts
|
|
100
101
|
import { defaultArgs as defaultArgs4, regex as regex2, string as string6, transform as transform6 } from "valibot";
|
|
101
|
-
import { parse } from "@awsless/duration";
|
|
102
|
+
import { parse as parse2 } from "@awsless/duration";
|
|
102
103
|
function duration(arg1, arg2) {
|
|
103
104
|
const [msg, pipe] = defaultArgs4(arg1, arg2);
|
|
104
105
|
const error = msg ?? "Invalid duration";
|
|
105
106
|
return transform6(
|
|
106
107
|
string6(error, [regex2(/^[0-9]+ (milliseconds?|seconds?|minutes?|hours?|days?)/, error)]),
|
|
107
108
|
(value) => {
|
|
108
|
-
return
|
|
109
|
+
return parse2(value);
|
|
109
110
|
},
|
|
110
111
|
pipe
|
|
111
112
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awsless/validate",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -24,14 +24,16 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@awsless/big-float": "^0.0.4",
|
|
28
27
|
"@awsless/duration": "^0.0.1",
|
|
29
|
-
"@awsless/
|
|
28
|
+
"@awsless/big-float": "^0.0.4",
|
|
29
|
+
"@awsless/json": "^0.0.6",
|
|
30
|
+
"@awsless/dynamodb": "^0.1.5"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
33
|
"@awsless/big-float": "^0.0.4",
|
|
33
|
-
"@awsless/
|
|
34
|
-
"@awsless/
|
|
34
|
+
"@awsless/duration": "^0.0.1",
|
|
35
|
+
"@awsless/dynamodb": "^0.1.5",
|
|
36
|
+
"@awsless/json": "^0.0.6"
|
|
35
37
|
},
|
|
36
38
|
"dependencies": {
|
|
37
39
|
"valibot": "^0.30.0"
|