@based/schema 0.0.5 → 0.0.7
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/set/collections.d.ts +5 -0
- package/dist/set/collections.js +123 -0
- package/dist/set/collections.js.map +1 -0
- package/dist/set/error.d.ts +10 -0
- package/dist/set/error.js +19 -0
- package/dist/set/error.js.map +1 -0
- package/dist/set/index.d.ts +1 -1
- package/dist/set/index.js +13 -17
- package/dist/set/index.js.map +1 -1
- package/dist/set/number copy.d.ts +4 -0
- package/dist/set/number copy.js +57 -0
- package/dist/set/number copy.js.map +1 -0
- package/dist/set/number.d.ts +4 -0
- package/dist/set/number.js +98 -0
- package/dist/set/number.js.map +1 -0
- package/dist/set/parsers.d.ts +2 -5
- package/dist/set/parsers.js +35 -357
- package/dist/set/parsers.js.map +1 -1
- package/dist/set/references.d.ts +3 -0
- package/dist/set/references.js +77 -0
- package/dist/set/references.js.map +1 -0
- package/dist/set/rest copy.d.ts +5 -0
- package/dist/set/rest copy.js +53 -0
- package/dist/set/rest copy.js.map +1 -0
- package/dist/set/rest.d.ts +5 -0
- package/dist/set/rest.js +57 -0
- package/dist/set/rest.js.map +1 -0
- package/dist/set/string.d.ts +3 -0
- package/dist/set/string.js +149 -0
- package/dist/set/string.js.map +1 -0
- package/dist/set/types.d.ts +5 -0
- package/dist/set/types.js +3 -0
- package/dist/set/types.js.map +1 -0
- package/dist/types.d.ts +36 -17
- package/dist/types.js.map +1 -1
- package/package.json +3 -1
- package/src/set/collections.ts +215 -0
- package/src/set/error.ts +17 -0
- package/src/set/index.ts +14 -21
- package/src/set/number.ts +136 -0
- package/src/set/parsers.ts +17 -553
- package/src/set/references.ts +107 -0
- package/src/set/rest.ts +83 -0
- package/src/set/string.ts +184 -0
- package/src/set/types.ts +20 -0
- package/src/types.ts +105 -20
- package/test/setWalker.ts +23 -7
- package/src/set/handleError.ts +0 -15
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.record = exports.array = exports.object = exports.set = void 0;
|
|
4
|
+
const error_1 = require("./error");
|
|
5
|
+
const _1 = require(".");
|
|
6
|
+
const set = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
|
|
7
|
+
const q = [];
|
|
8
|
+
const fieldDef = fieldSchema.items;
|
|
9
|
+
if (Array.isArray(value)) {
|
|
10
|
+
const parsedArray = [];
|
|
11
|
+
for (let i = 0; i < value.length; i++) {
|
|
12
|
+
q.push((0, _1.fieldWalker)([...path, i], value[i], fieldDef, typeSchema, target, {
|
|
13
|
+
...handlers,
|
|
14
|
+
collect: ({ value }) => {
|
|
15
|
+
parsedArray.push(value);
|
|
16
|
+
},
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
await Promise.all(q);
|
|
20
|
+
if (!noCollect) {
|
|
21
|
+
handlers.collect({
|
|
22
|
+
path,
|
|
23
|
+
value: { $value: parsedArray },
|
|
24
|
+
typeSchema,
|
|
25
|
+
fieldSchema,
|
|
26
|
+
target,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
if (value.$add) {
|
|
32
|
+
for (let i = 0; i < value.$add.length; i++) {
|
|
33
|
+
q.push((0, _1.fieldWalker)([...path, '$add', i], value.$add[i], fieldDef, typeSchema, target, handlers, true));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (value.$delete) {
|
|
37
|
+
for (let i = 0; i < value.$add.length; i++) {
|
|
38
|
+
q.push((0, _1.fieldWalker)([...path, '$delete', i], value.$delete[i], fieldDef, typeSchema, target, handlers, true));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
await Promise.all(q);
|
|
42
|
+
if (!noCollect) {
|
|
43
|
+
handlers.collect({ path, value, typeSchema, fieldSchema, target });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
exports.set = set;
|
|
48
|
+
const object = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
|
|
49
|
+
if (typeof value !== 'object') {
|
|
50
|
+
(0, error_1.error)(path, error_1.ParseError.incorrectFormat);
|
|
51
|
+
}
|
|
52
|
+
const isArray = Array.isArray(value);
|
|
53
|
+
if (isArray) {
|
|
54
|
+
(0, error_1.error)(path, error_1.ParseError.incorrectFormat);
|
|
55
|
+
}
|
|
56
|
+
const q = [];
|
|
57
|
+
for (const key in value) {
|
|
58
|
+
const propDef = fieldSchema.properties[key];
|
|
59
|
+
if (!propDef) {
|
|
60
|
+
(0, error_1.error)([...path, key], error_1.ParseError.fieldDoesNotExist);
|
|
61
|
+
}
|
|
62
|
+
q.push((0, _1.fieldWalker)([...path, key], value[key], propDef, typeSchema, target, handlers, noCollect));
|
|
63
|
+
}
|
|
64
|
+
await Promise.all(q);
|
|
65
|
+
};
|
|
66
|
+
exports.object = object;
|
|
67
|
+
const array = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
|
|
68
|
+
const isArray = Array.isArray(value);
|
|
69
|
+
if (typeof value === 'object' && !isArray) {
|
|
70
|
+
if (value.$insert) {
|
|
71
|
+
if (typeof value.$insert !== 'object' ||
|
|
72
|
+
value.$insert.$idx === undefined) {
|
|
73
|
+
(0, error_1.error)([...path, '$insert'], error_1.ParseError.incorrectFormat);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
const insert = Array.isArray(value.$insert.$value)
|
|
77
|
+
? value.$insert.$value
|
|
78
|
+
: [value.$insert.$value];
|
|
79
|
+
const q = [];
|
|
80
|
+
for (let i = 0; i < insert.length; i++) {
|
|
81
|
+
q.push((0, _1.fieldWalker)([...path, 'insert', i], insert[i], fieldSchema.values, typeSchema, target, handlers, true));
|
|
82
|
+
}
|
|
83
|
+
await Promise.all(q);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (value.$remove && value.$remove.$idx === undefined) {
|
|
87
|
+
(0, error_1.error)([...path, '$remove'], error_1.ParseError.incorrectFormat);
|
|
88
|
+
}
|
|
89
|
+
if (value.$push) {
|
|
90
|
+
const q = [];
|
|
91
|
+
const push = Array.isArray(value.$push) ? value.$push : [value.$push];
|
|
92
|
+
for (let i = 0; i < push.length; i++) {
|
|
93
|
+
q.push((0, _1.fieldWalker)([...path, i], push[i], fieldSchema.values, typeSchema, target, handlers, true));
|
|
94
|
+
}
|
|
95
|
+
await Promise.all(q);
|
|
96
|
+
}
|
|
97
|
+
if (value.$assign) {
|
|
98
|
+
if (typeof value.$assign !== 'object' ||
|
|
99
|
+
value.$assign.$idx === undefined) {
|
|
100
|
+
(0, error_1.error)([...path, '$assign'], error_1.ParseError.incorrectFormat);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
await (0, _1.fieldWalker)([...path, '$assign', '$value'], value.$assign.$value, fieldSchema.values, typeSchema, target, handlers, true);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (!noCollect) {
|
|
107
|
+
handlers.collect({ path, value, typeSchema, fieldSchema, target });
|
|
108
|
+
}
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (!isArray) {
|
|
112
|
+
(0, error_1.error)(path, error_1.ParseError.incorrectFieldType);
|
|
113
|
+
}
|
|
114
|
+
const q = [];
|
|
115
|
+
for (let i = 0; i < value.length; i++) {
|
|
116
|
+
q.push((0, _1.fieldWalker)([...path, i], value[i], fieldSchema.values, typeSchema, target, handlers, noCollect));
|
|
117
|
+
}
|
|
118
|
+
await Promise.all(q);
|
|
119
|
+
};
|
|
120
|
+
exports.array = array;
|
|
121
|
+
const record = async (path, value, fieldSchema) => { };
|
|
122
|
+
exports.record = record;
|
|
123
|
+
//# sourceMappingURL=collections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections.js","sourceRoot":"","sources":["../../src/set/collections.ts"],"names":[],"mappings":";;;AACA,mCAA2C;AAC3C,wBAA+B;AAExB,MAAM,GAAG,GAAk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eType' = 1,
|
|
4
|
+
'exceedsMaximum' = 2,
|
|
5
|
+
'subceedsMinimum' = 3,
|
|
6
|
+
'fieldDoesNotExist' = 4,
|
|
7
|
+
'incorrectFormat' = 5,
|
|
8
|
+
'referenceIsIncorrectType' = 6
|
|
9
|
+
}
|
|
10
|
+
export declare const error: (path: (number | string)[], error: ParseError, type?: string) => never;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.error = exports.ParseError = void 0;
|
|
4
|
+
var ParseError;
|
|
5
|
+
(function (ParseError) {
|
|
6
|
+
ParseError[ParseError["incorrectFieldType"] = 0] = "incorrectFieldType";
|
|
7
|
+
ParseError[ParseError["incorrectNodeType"] = 1] = "incorrectNodeType";
|
|
8
|
+
ParseError[ParseError["exceedsMaximum"] = 2] = "exceedsMaximum";
|
|
9
|
+
ParseError[ParseError["subceedsMinimum"] = 3] = "subceedsMinimum";
|
|
10
|
+
ParseError[ParseError["fieldDoesNotExist"] = 4] = "fieldDoesNotExist";
|
|
11
|
+
ParseError[ParseError["incorrectFormat"] = 5] = "incorrectFormat";
|
|
12
|
+
ParseError[ParseError["referenceIsIncorrectType"] = 6] = "referenceIsIncorrectType";
|
|
13
|
+
})(ParseError = exports.ParseError || (exports.ParseError = {}));
|
|
14
|
+
const error = (path, error, type // nice to give as option
|
|
15
|
+
) => {
|
|
16
|
+
throw new Error(`Field: "${path.join('.')}" ${ParseError[error]}`);
|
|
17
|
+
};
|
|
18
|
+
exports.error = error;
|
|
19
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/set/error.ts"],"names":[],"mappings":";;;AAAA,IAAY,UAQX;AARD,WAAY,UAAU;IACpB,uEAAoB,CAAA;IACpB,qEAAmB,CAAA;IACnB,+DAAgB,CAAA;IAChB,iEAAiB,CAAA;IACjB,qEAAmB,CAAA;IACnB,iEAAiB,CAAA;IACjB,mFAA0B,CAAA;AAC5B,CAAC,EARW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAQrB;AAEM,MAAM,KAAK,GAAG,CACnB,IAAyB,EACzB,KAAiB,EACjB,IAAa,CAAC,yBAAyB;EACvC,EAAE;IACF,MAAM,IAAI,KAAK,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;AACpE,CAAC,CAAA;AANY,QAAA,KAAK,SAMjB"}
|
package/dist/set/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BasedSchemaField, BasedSchemaType, BasedSetHandlers, BasedSchema, BasedSetTarget } from '../types';
|
|
2
|
-
export declare const fieldWalker: (path: (string | number)[], value: any, fieldSchema: BasedSchemaField, typeSchema: BasedSchemaType, target: BasedSetTarget, handlers: BasedSetHandlers) => Promise<void>;
|
|
2
|
+
export declare const fieldWalker: (path: (string | number)[], value: any, fieldSchema: BasedSchemaField, typeSchema: BasedSchemaType, target: BasedSetTarget, handlers: BasedSetHandlers, noCollect?: boolean) => Promise<void>;
|
|
3
3
|
export declare const setWalker: (schema: BasedSchema, value: {
|
|
4
4
|
[key: string]: any;
|
|
5
5
|
}, handlers: BasedSetHandlers) => Promise<BasedSetTarget>;
|
package/dist/set/index.js
CHANGED
|
@@ -4,12 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.setWalker = exports.fieldWalker = void 0;
|
|
7
|
-
const
|
|
7
|
+
const error_1 = require("./error");
|
|
8
8
|
const parsers_1 = __importDefault(require("./parsers"));
|
|
9
|
-
|
|
10
|
-
// also make collect async
|
|
11
|
-
// add extra function for loading required
|
|
12
|
-
const fieldWalker = async (path, value, fieldSchema, typeSchema, target, handlers) => {
|
|
9
|
+
const fieldWalker = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
|
|
13
10
|
if ('$ref' in fieldSchema) {
|
|
14
11
|
// TODO: when we have this it has to get it from the schema and redo the parsing with the correct fieldSchema
|
|
15
12
|
return;
|
|
@@ -17,21 +14,23 @@ const fieldWalker = async (path, value, fieldSchema, typeSchema, target, handler
|
|
|
17
14
|
const valueType = typeof value;
|
|
18
15
|
const valueIsObject = value && valueType === 'object';
|
|
19
16
|
if (valueIsObject && value.$delete === true) {
|
|
20
|
-
|
|
17
|
+
if (!noCollect) {
|
|
18
|
+
handlers.collect({ path, value, typeSchema, fieldSchema, target });
|
|
19
|
+
}
|
|
21
20
|
return;
|
|
22
21
|
}
|
|
23
22
|
const typeDef = fieldSchema.type ?? ('enum' in fieldSchema ? 'enum' : '');
|
|
24
23
|
if (!typeDef) {
|
|
25
|
-
|
|
24
|
+
(0, error_1.error)(path, error_1.ParseError.fieldDoesNotExist);
|
|
26
25
|
}
|
|
27
26
|
if ('customValidator' in fieldSchema) {
|
|
28
27
|
const customValidator = fieldSchema.customValidator;
|
|
29
28
|
if (!(await customValidator(value, path, target))) {
|
|
30
|
-
|
|
29
|
+
(0, error_1.error)(path, error_1.ParseError.incorrectFormat);
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
const parse = parsers_1.default[typeDef];
|
|
34
|
-
await parse(path, value, fieldSchema, typeSchema, target, handlers);
|
|
33
|
+
await parse(path, value, fieldSchema, typeSchema, target, handlers, noCollect);
|
|
35
34
|
return;
|
|
36
35
|
};
|
|
37
36
|
exports.fieldWalker = fieldWalker;
|
|
@@ -40,18 +39,18 @@ const setWalker = async (schema, value, handlers) => {
|
|
|
40
39
|
if (value.$id) {
|
|
41
40
|
type = schema.prefixToTypeMapping[value.$id.slice(0, 2)];
|
|
42
41
|
if (!type) {
|
|
43
|
-
|
|
42
|
+
(0, error_1.error)([value.$id], error_1.ParseError.incorrectNodeType);
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
45
|
if (value.type) {
|
|
47
46
|
if (type && value.type !== type) {
|
|
48
|
-
|
|
47
|
+
(0, error_1.error)([value.$id, value.type], error_1.ParseError.incorrectNodeType);
|
|
49
48
|
}
|
|
50
49
|
type = value.type;
|
|
51
50
|
}
|
|
52
51
|
const schemaType = schema.types[type];
|
|
53
52
|
if (!schemaType) {
|
|
54
|
-
|
|
53
|
+
(0, error_1.error)([type], error_1.ParseError.incorrectNodeType);
|
|
55
54
|
}
|
|
56
55
|
const target = {
|
|
57
56
|
type,
|
|
@@ -65,13 +64,10 @@ const setWalker = async (schema, value, handlers) => {
|
|
|
65
64
|
}
|
|
66
65
|
const q = [];
|
|
67
66
|
for (const key in value) {
|
|
68
|
-
if (key[0]
|
|
69
|
-
console.info('key is operator', key);
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
67
|
+
if (key[0] !== '$') {
|
|
72
68
|
const fieldSchema = schemaType.fields[key];
|
|
73
69
|
if (!fieldSchema) {
|
|
74
|
-
|
|
70
|
+
(0, error_1.error)([key], error_1.ParseError.fieldDoesNotExist);
|
|
75
71
|
}
|
|
76
72
|
else {
|
|
77
73
|
q.push((0, exports.fieldWalker)([key], value[key], fieldSchema, schemaType, target, handlers));
|
package/dist/set/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/set/index.ts"],"names":[],"mappings":";;;;;;AAOA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/set/index.ts"],"names":[],"mappings":";;;;;;AAOA,mCAA2C;AAC3C,wDAA+B;AAExB,MAAM,WAAW,GAAG,KAAK,EAC9B,IAAyB,EACzB,KAAU,EACV,WAA6B,EAC7B,UAA2B,EAC3B,MAAsB,EACtB,QAA0B,EAC1B,SAAmB,EACJ,EAAE;IACjB,IAAI,MAAM,IAAI,WAAW,EAAE;QACzB,6GAA6G;QAC7G,OAAM;KACP;IACD,MAAM,SAAS,GAAG,OAAO,KAAK,C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,IAAA,mBAAW,EACT,CAAC,GAAG,CAAC,EACL,KAAK,CAAC,GAAG,CAAC,EACV,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,CACT,CACF,CAAA;aACF;SACF;KACF;IAED,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IAEpB,kCAAkC;IAClC,+DAA+D;IAC/D,iDAAiD;IACjD,MAAM;IAEN,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AApEY,QAAA,SAAS,aAoErB"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.integer = exports.number = exports.timestamp = void 0;
|
|
4
|
+
const error_1 = require("./error");
|
|
5
|
+
const timestamp = async (path, value, fieldSchema, typeSchema, target, handlers) => {
|
|
6
|
+
if (typeof value === 'string') {
|
|
7
|
+
if (value === 'now') {
|
|
8
|
+
value = Date.now();
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
const d = new Date(value);
|
|
12
|
+
value = d.valueOf();
|
|
13
|
+
if (isNaN(value)) {
|
|
14
|
+
throw (0, error_1.error)(path, error_1.ParseError.incorrectFormat);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
// // smaller then / larger then steps
|
|
19
|
+
// if (typeof value !== 'number') {
|
|
20
|
+
// throw createError(path, target.type, 'timestamp', value)
|
|
21
|
+
// }
|
|
22
|
+
// if (fieldSchema.maximum) {
|
|
23
|
+
// if (fieldSchema.exclusiveMaximum && value > value) {
|
|
24
|
+
// throw createError(path, target.type, 'timestamp', value)
|
|
25
|
+
// } else if (value >= value) {
|
|
26
|
+
// throw createError(path, target.type, 'timestamp', value)
|
|
27
|
+
// }
|
|
28
|
+
// }
|
|
29
|
+
// if (fieldSchema.minimum) {
|
|
30
|
+
// if (fieldSchema.exclusiveMinimum && value < value) {
|
|
31
|
+
// throw createError(path, target.type, 'timestamp', value)
|
|
32
|
+
// } else if (value <= value) {
|
|
33
|
+
// throw createError(path, target.type, 'timestamp', value)
|
|
34
|
+
// }
|
|
35
|
+
// }
|
|
36
|
+
handlers.collect({ path, value, typeSchema, fieldSchema, target });
|
|
37
|
+
};
|
|
38
|
+
exports.timestamp = timestamp;
|
|
39
|
+
const number = async (path, value, fieldSchema, typeSchema, target, handlers) => {
|
|
40
|
+
// value .default
|
|
41
|
+
// $increment / $decrement
|
|
42
|
+
if (typeof value !== 'number') {
|
|
43
|
+
(0, error_1.error)(path, error_1.ParseError.incorrectFormat);
|
|
44
|
+
}
|
|
45
|
+
handlers.collect({ path, value, typeSchema, fieldSchema, target });
|
|
46
|
+
};
|
|
47
|
+
exports.number = number;
|
|
48
|
+
const integer = async (path, value, fieldSchema, typeSchema, target, handlers) => {
|
|
49
|
+
// value .default
|
|
50
|
+
// $increment / $decrement
|
|
51
|
+
if (typeof value !== 'number' || value - Math.floor(value) !== 0) {
|
|
52
|
+
(0, error_1.error)(path, error_1.ParseError.incorrectFormat);
|
|
53
|
+
}
|
|
54
|
+
handlers.collect({ path, value, typeSchema, fieldSchema, target });
|
|
55
|
+
};
|
|
56
|
+
exports.integer = integer;
|
|
57
|
+
//# sourceMappingURL=number%20copy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number copy.js","sourceRoot":"","sources":["../../src/set/number copy.ts"],"names":[],"mappings":";;;AACA,mCAA2C;AAEpC,MAAM,SAAS,GAAwB,KAAK,EACjD,IAAI,EACJ,KAAK,EACL,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,EACR,EAAE;IACF,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,IAAI,KAAK,KAAK,KAAK,EAAE;YACnB,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;SACnB;aAAM;YACL,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAA;YACzB,KAAK,GAAG,CAAC,CAAC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IAAA,aAAK,EAAC,IAAI,EAAE,kBAAU,CAAC,eAAe,CAAC,CAAA;KACxC;IACD,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAA;AACpE,CAAC,CAAA;AAdY,QAAA,OAAO,WAcnB"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.integer = exports.number = exports.timestamp = void 0;
|
|
4
|
+
const error_1 = require("./error");
|
|
5
|
+
const validate = (path, value, fieldSchema) => {
|
|
6
|
+
if (typeof value !== 'number') {
|
|
7
|
+
(0, error_1.error)(path, error_1.ParseError.incorrectFormat);
|
|
8
|
+
}
|
|
9
|
+
if (fieldSchema.maximum) {
|
|
10
|
+
if (fieldSchema.exclusiveMaximum && value > value) {
|
|
11
|
+
(0, error_1.error)(path, error_1.ParseError.exceedsMaximum);
|
|
12
|
+
}
|
|
13
|
+
else if (value >= value) {
|
|
14
|
+
(0, error_1.error)(path, error_1.ParseError.exceedsMaximum);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
if (fieldSchema.minimum) {
|
|
18
|
+
if (fieldSchema.exclusiveMinimum && value < value) {
|
|
19
|
+
(0, error_1.error)(path, error_1.ParseError.subceedsMinimum);
|
|
20
|
+
}
|
|
21
|
+
else if (value <= value) {
|
|
22
|
+
(0, error_1.error)(path, error_1.ParseError.subceedsMinimum);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return value;
|
|
26
|
+
};
|
|
27
|
+
const shared = (path, value, fieldSchema) => {
|
|
28
|
+
if (typeof value === 'object') {
|
|
29
|
+
if (value.$increment) {
|
|
30
|
+
validate([...path, '$increment'], value.$increment, fieldSchema);
|
|
31
|
+
}
|
|
32
|
+
if (value.$decrement) {
|
|
33
|
+
validate([...path, '$decrement'], value.$decrement, fieldSchema);
|
|
34
|
+
}
|
|
35
|
+
if (value.$value) {
|
|
36
|
+
validate([...path], value.$value, fieldSchema);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
validate(path, value, fieldSchema);
|
|
41
|
+
}
|
|
42
|
+
return value;
|
|
43
|
+
};
|
|
44
|
+
const timestamp = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
|
|
45
|
+
if (typeof value === 'string') {
|
|
46
|
+
if (value === 'now') {
|
|
47
|
+
value = Date.now();
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
const d = new Date(value);
|
|
51
|
+
value = d.valueOf();
|
|
52
|
+
if (isNaN(value)) {
|
|
53
|
+
throw (0, error_1.error)(path, error_1.ParseError.incorrectFormat);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const parsedValue = shared(path, value, fieldSchema);
|
|
58
|
+
if (!noCollect) {
|
|
59
|
+
handlers.collect({
|
|
60
|
+
path,
|
|
61
|
+
value: parsedValue,
|
|
62
|
+
typeSchema,
|
|
63
|
+
fieldSchema,
|
|
64
|
+
target,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
exports.timestamp = timestamp;
|
|
69
|
+
const number = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
|
|
70
|
+
const parsedValue = shared(path, value, fieldSchema);
|
|
71
|
+
if (!noCollect) {
|
|
72
|
+
handlers.collect({
|
|
73
|
+
path,
|
|
74
|
+
value: parsedValue,
|
|
75
|
+
typeSchema,
|
|
76
|
+
fieldSchema,
|
|
77
|
+
target,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
exports.number = number;
|
|
82
|
+
const integer = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
|
|
83
|
+
if (typeof value === 'number' && value - Math.floor(value) !== 0) {
|
|
84
|
+
(0, error_1.error)(path, error_1.ParseError.incorrectFormat);
|
|
85
|
+
}
|
|
86
|
+
const parsedValue = shared(path, value, fieldSchema);
|
|
87
|
+
if (!noCollect) {
|
|
88
|
+
handlers.collect({
|
|
89
|
+
path,
|
|
90
|
+
value: parsedValue,
|
|
91
|
+
typeSchema,
|
|
92
|
+
fieldSchema,
|
|
93
|
+
target,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
exports.integer = integer;
|
|
98
|
+
//# sourceMappingURL=number.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number.js","sourceRoot":"","sources":["../../src/set/number.ts"],"names":[],"mappings":";;;AACA,mCAA2C;AAO3C,MAAM,QAAQ,GAAG,CACf,IAAyB,EACzB,KAAU,EACV,WAG6B,EACrB,EAAE;IACV,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,IAAA,aAAK,EAAC,IAAI,EAAE,kBAAU,CAAC,eAAe,CAAC,CAAA;KACxC;IACD,IAAI,WAAW,CAAC,OAAO,EAAE;QACvB,IAAI,WAAW,CAAC,gBAAgB,IAAI,KAAK,GAAG,KAAK,EAAE;YACjD,IAAA,aAAK,EAAC,IAAI,EAAE,kBAAU,CAAC,cAAc,CAAC,CAAA;SACvC;aAAM,IAAI,KAAK,IAAI,KAAK,EAAE;YACzB,IAAA,aAAK,EAAC,IAAI,EAAE,kBAAU,CAAC,cAAc,CAAC,CAAA;SACvC;KACF;IACD,IAAI,WAAW,CAAC,OAAO,EAAE;QACvB,IAAI,WAAW,CAAC,gBAAgB,IAAI,KAAK,GAAG,KAAK,EAAE;YACjD,IAAA,aAAK,EAAC,IAAI,EAAE,kBAAU,CAAC,eAAe,CAAC,CAAA;SACxC;aAAM,IAAI,KAAK,IAAI,KAAK,EAAE;YACzB,IAAA,aAAK,EAAC,IAAI,EAAE,kBAAU,CAAC,eAAe,CAAC,CAAA;SACxC;KACF;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAED,MAAM,MAAM,GAAG,CACb,IAAyB,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sers: {
|
|
4
|
-
[key: string]: Parser;
|
|
5
|
-
};
|
|
1
|
+
import { Parsers } from './types';
|
|
2
|
+
declare const parsers: Parsers;
|
|
6
3
|
export default parsers;
|