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