@based/schema 1.3.2 → 2.0.0
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/fields/string.d.ts.map +1 -1
- package/dist/set/fields/string.js +3 -1
- package/dist/set/fields/string.js.map +1 -1
- package/dist/set/index.d.ts.map +1 -1
- package/dist/set/index.js +3 -1
- package/dist/set/index.js.map +1 -1
- package/dist/types.d.ts +3 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/updateSchema.js +1 -1
- package/dist/updateSchema.js.map +1 -1
- package/dist/validateSchema.d.ts.map +1 -1
- package/dist/validateSchema.js +5 -2
- package/dist/validateSchema.js.map +1 -1
- package/package.json +1 -1
- package/src/set/fields/string.ts +5 -1
- package/src/set/index.ts +5 -1
- package/src/types.ts +72 -68
- package/src/updateSchema.ts +1 -1
- package/src/validateSchema.ts +6 -3
- package/test/array.ts +1 -1
- package/test/number.ts +1 -1
- package/test/reference.ts +2 -1
- package/test/rest.ts +2 -1
- package/test/set.ts +2 -1
- package/test/string.ts +1 -1
- package/test/text.ts +8 -2
- package/test/walker.ts +2 -1
- package/dist/set/collections.d.ts +0 -5
- package/dist/set/collections.js +0 -211
- package/dist/set/collections.js.map +0 -1
- package/dist/set/error.d.ts +0 -15
- package/dist/set/error.js +0 -24
- package/dist/set/error.js.map +0 -1
- package/dist/set/number.d.ts +0 -4
- package/dist/set/number.js +0 -111
- package/dist/set/number.js.map +0 -1
- package/dist/set/parseDefaultAndValue.d.ts +0 -3
- package/dist/set/parseDefaultAndValue.js +0 -33
- package/dist/set/parseDefaultAndValue.js.map +0 -1
- package/dist/set/parsers.d.ts +0 -3
- package/dist/set/parsers.js +0 -42
- package/dist/set/parsers.js.map +0 -1
- package/dist/set/references.d.ts +0 -3
- package/dist/set/references.js +0 -77
- package/dist/set/references.js.map +0 -1
- package/dist/set/rest.d.ts +0 -5
- package/dist/set/rest.js +0 -76
- package/dist/set/rest.js.map +0 -1
- package/dist/set/string.d.ts +0 -3
- package/dist/set/string.js +0 -173
- package/dist/set/string.js.map +0 -1
package/dist/set/collections.js
DELETED
|
@@ -1,211 +0,0 @@
|
|
|
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
|
-
if (value && typeof value === 'object' && value.$value) {
|
|
8
|
-
value = value.$value;
|
|
9
|
-
}
|
|
10
|
-
const q = [];
|
|
11
|
-
const fieldDef = fieldSchema.items;
|
|
12
|
-
if (Array.isArray(value)) {
|
|
13
|
-
const parsedArray = [];
|
|
14
|
-
for (let i = 0; i < value.length; i++) {
|
|
15
|
-
q.push((0, _1.fieldWalker)([...path, i], value[i], fieldDef, typeSchema, target, {
|
|
16
|
-
...handlers,
|
|
17
|
-
collect: ({ value }) => {
|
|
18
|
-
parsedArray.push(value);
|
|
19
|
-
},
|
|
20
|
-
}));
|
|
21
|
-
}
|
|
22
|
-
await Promise.all(q);
|
|
23
|
-
if (!noCollect) {
|
|
24
|
-
handlers.collect({
|
|
25
|
-
path,
|
|
26
|
-
value: { $value: parsedArray },
|
|
27
|
-
typeSchema,
|
|
28
|
-
fieldSchema,
|
|
29
|
-
target,
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
if (value.$add) {
|
|
35
|
-
for (let i = 0; i < value.$add.length; i++) {
|
|
36
|
-
q.push((0, _1.fieldWalker)(path, value.$add[i], fieldDef, typeSchema, target, handlers, true));
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
if (value.$remove) {
|
|
40
|
-
for (let i = 0; i < value.$remove.length; i++) {
|
|
41
|
-
q.push((0, _1.fieldWalker)(path, value.$remove[i], fieldDef, typeSchema, target, handlers, true));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
await Promise.all(q);
|
|
45
|
-
if (!noCollect) {
|
|
46
|
-
handlers.collect({ path, value, typeSchema, fieldSchema, target });
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
exports.set = set;
|
|
51
|
-
const object = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
|
|
52
|
-
if (typeof value !== 'object') {
|
|
53
|
-
(0, error_1.error)(path, error_1.ParseError.incorrectFormat);
|
|
54
|
-
}
|
|
55
|
-
const isArray = Array.isArray(value);
|
|
56
|
-
if (isArray) {
|
|
57
|
-
(0, error_1.error)(path, error_1.ParseError.incorrectFormat);
|
|
58
|
-
}
|
|
59
|
-
const q = [];
|
|
60
|
-
for (const key in value) {
|
|
61
|
-
const propDef = fieldSchema.properties[key];
|
|
62
|
-
if (!propDef) {
|
|
63
|
-
(0, error_1.error)([...path, key], error_1.ParseError.fieldDoesNotExist);
|
|
64
|
-
}
|
|
65
|
-
q.push((0, _1.fieldWalker)([...path, key], value[key], propDef, typeSchema, target, handlers, noCollect));
|
|
66
|
-
}
|
|
67
|
-
await Promise.all(q);
|
|
68
|
-
if (fieldSchema.required) {
|
|
69
|
-
for (const req of fieldSchema.required) {
|
|
70
|
-
if (!(req in value)) {
|
|
71
|
-
target.required.push([...path, req]);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
exports.object = object;
|
|
77
|
-
// IF REQUIRED AND PUSH OR UNSHIFT just throw here scince we dont need to parse at all...
|
|
78
|
-
const array = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
|
|
79
|
-
let isArray = Array.isArray(value);
|
|
80
|
-
let parsedValue = value;
|
|
81
|
-
let opCount = 0;
|
|
82
|
-
let has$Value = false;
|
|
83
|
-
if (typeof parsedValue === 'object' && !isArray) {
|
|
84
|
-
if (value.$value) {
|
|
85
|
-
opCount++;
|
|
86
|
-
has$Value = true;
|
|
87
|
-
parsedValue = value.$value;
|
|
88
|
-
isArray = Array.isArray(parsedValue);
|
|
89
|
-
}
|
|
90
|
-
if (value.$insert) {
|
|
91
|
-
opCount++;
|
|
92
|
-
if (opCount > 1) {
|
|
93
|
-
(0, error_1.error)(path, error_1.ParseError.multipleOperationsNotAllowed);
|
|
94
|
-
}
|
|
95
|
-
if (typeof value.$insert !== 'object' ||
|
|
96
|
-
value.$insert.$idx === undefined) {
|
|
97
|
-
(0, error_1.error)(path, error_1.ParseError.incorrectFormat);
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
const insert = Array.isArray(value.$insert.$value)
|
|
101
|
-
? value.$insert.$value
|
|
102
|
-
: [value.$insert.$value];
|
|
103
|
-
const q = [];
|
|
104
|
-
for (let i = 0; i < insert.length; i++) {
|
|
105
|
-
q.push((0, _1.fieldWalker)(path, insert[i], fieldSchema.values, typeSchema, target, handlers, true));
|
|
106
|
-
}
|
|
107
|
-
await Promise.all(q);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
if (value.$remove) {
|
|
111
|
-
opCount++;
|
|
112
|
-
if (opCount > 1) {
|
|
113
|
-
(0, error_1.error)(path, error_1.ParseError.multipleOperationsNotAllowed);
|
|
114
|
-
}
|
|
115
|
-
if (value.$remove.$idx === undefined) {
|
|
116
|
-
(0, error_1.error)(path, error_1.ParseError.incorrectFormat);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
if (value.$push) {
|
|
120
|
-
opCount++;
|
|
121
|
-
if (opCount > 1) {
|
|
122
|
-
(0, error_1.error)(path, error_1.ParseError.multipleOperationsNotAllowed);
|
|
123
|
-
}
|
|
124
|
-
// TODO: FIX PUSH PARSING
|
|
125
|
-
const q = [];
|
|
126
|
-
const push = Array.isArray(value.$push) ? value.$push : [value.$push];
|
|
127
|
-
for (let i = 0; i < push.length; i++) {
|
|
128
|
-
q.push((0, _1.fieldWalker)(
|
|
129
|
-
// exception
|
|
130
|
-
[...path, '$push', i], push[i], fieldSchema.values, typeSchema, target, handlers, true));
|
|
131
|
-
}
|
|
132
|
-
await Promise.all(q);
|
|
133
|
-
parsedValue = { $push: push };
|
|
134
|
-
}
|
|
135
|
-
if (value.$unshift) {
|
|
136
|
-
opCount++;
|
|
137
|
-
if (opCount > 1) {
|
|
138
|
-
(0, error_1.error)(path, error_1.ParseError.multipleOperationsNotAllowed);
|
|
139
|
-
}
|
|
140
|
-
const q = [];
|
|
141
|
-
const unshift = Array.isArray(value.$unshift)
|
|
142
|
-
? value.$unshift
|
|
143
|
-
: [value.$unshift];
|
|
144
|
-
// TODO: FIX UNSHIFT PARSING
|
|
145
|
-
for (let i = 0; i < unshift.length; i++) {
|
|
146
|
-
q.push((0, _1.fieldWalker)(
|
|
147
|
-
// exception
|
|
148
|
-
[...path, '$unshift', i], unshift[i], fieldSchema.values, typeSchema, target, handlers, true));
|
|
149
|
-
}
|
|
150
|
-
await Promise.all(q);
|
|
151
|
-
parsedValue = { $unshift: unshift };
|
|
152
|
-
}
|
|
153
|
-
if (value.$assign) {
|
|
154
|
-
opCount++;
|
|
155
|
-
if (opCount > 1) {
|
|
156
|
-
(0, error_1.error)(path, error_1.ParseError.multipleOperationsNotAllowed);
|
|
157
|
-
}
|
|
158
|
-
if (typeof value.$assign !== 'object' ||
|
|
159
|
-
typeof value.$assign.$idx !== 'number') {
|
|
160
|
-
(0, error_1.error)(path, error_1.ParseError.incorrectFormat);
|
|
161
|
-
}
|
|
162
|
-
await (0, _1.fieldWalker)([...path, value.$assign.$idx], value.$assign.$value, fieldSchema.values, typeSchema, target, handlers, noCollect);
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
if (!has$Value && !noCollect) {
|
|
166
|
-
handlers.collect({
|
|
167
|
-
path,
|
|
168
|
-
value: parsedValue,
|
|
169
|
-
typeSchema,
|
|
170
|
-
fieldSchema,
|
|
171
|
-
target,
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
if (!has$Value) {
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
if (!isArray) {
|
|
179
|
-
(0, error_1.error)(path, error_1.ParseError.incorrectFieldType);
|
|
180
|
-
}
|
|
181
|
-
const q = [];
|
|
182
|
-
const collector = [];
|
|
183
|
-
const nHandler = noCollect
|
|
184
|
-
? handlers
|
|
185
|
-
: {
|
|
186
|
-
...handlers,
|
|
187
|
-
collect: (collect) => {
|
|
188
|
-
collector.push(collect);
|
|
189
|
-
},
|
|
190
|
-
};
|
|
191
|
-
for (let i = 0; i < parsedValue.length; i++) {
|
|
192
|
-
q.push((0, _1.fieldWalker)([...path, i], parsedValue[i], fieldSchema.values, typeSchema, target, nHandler, noCollect));
|
|
193
|
-
}
|
|
194
|
-
await Promise.all(q);
|
|
195
|
-
if (!noCollect) {
|
|
196
|
-
handlers.collect({
|
|
197
|
-
path,
|
|
198
|
-
typeSchema,
|
|
199
|
-
fieldSchema,
|
|
200
|
-
target,
|
|
201
|
-
value: { $delete: true },
|
|
202
|
-
});
|
|
203
|
-
for (const c of collector) {
|
|
204
|
-
handlers.collect(c);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
exports.array = array;
|
|
209
|
-
const record = async (path, value, fieldSchema) => { };
|
|
210
|
-
exports.record = record;
|
|
211
|
-
//# sourceMappingURL=collections.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collections.js","sourceRoot":"","sources":["../../src/set/collections.ts"],"names":[],"mappings":";;;AACA,mCAA2C;AAC3C,wBAA+B;AAExB,MAAM,GAAG,GAAkB,KAAK,EACrC,IAAI,EACJ,KAAK,EACL,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,EACR,SAAS,EACT,EAAE;IACF,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,EAAE;QACtD,KAAK,GAAG,KAAK,CAAC,MAAM,CAAA;KACrB;IACD,MAAM,CAAC,GAAoB,EAA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G,SAAS;QACxB,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC;YACE,GAAG,QAAQ;YACX,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE;gBACnB,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YACzB,CAAC;SACF,CAAA;IACL,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC3C,CAAC,CAAC,IAAI,CACJ,IAAA,cAAW,EACT,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,EACZ,WAAW,CAAC,CAAC,CAAC,EACd,WAAW,CAAC,MAAM,EAClB,UAAU,EACV,MAAM,EACN,QAAQ,EACR,SAAS,CACV,CACF,CAAA;KACF;IACD,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IAEpB,IAAI,CAAC,SAAS,EAAE;QACd,QAAQ,CAAC,OAAO,CAAC;YACf,IAAI;YACJ,UAAU;YACV,WAAW;YACX,MAAM;YACN,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;SACzB,CAAC,CAAA;QACF,KAAK,MAAM,CAAC,IAAI,SAAS,EAAE;YACzB,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;SACpB;KACF;AACH,CAAC,CAAA;AA7LY,QAAA,KAAK,SA6LjB;AAEM,MAAM,MAAM,GAAqB,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,GAAE,CAAC,CAAA;AAAjE,QAAA,MAAM,UAA2D"}
|
package/dist/set/error.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare enum ParseError {
|
|
2
|
-
'incorrectFieldType' = 0,
|
|
3
|
-
'incorrectNodeType' = 1,
|
|
4
|
-
'exceedsMaximum' = 2,
|
|
5
|
-
'subceedsMinimum' = 3,
|
|
6
|
-
'fieldDoesNotExist' = 4,
|
|
7
|
-
'incorrectFormat' = 5,
|
|
8
|
-
'referenceIsIncorrectType' = 6,
|
|
9
|
-
'valueAndDefault' = 7,
|
|
10
|
-
'defaultNotSupported' = 8,
|
|
11
|
-
'multipleOperationsNotAllowed' = 9,
|
|
12
|
-
'requiredFieldNotDefined' = 10,
|
|
13
|
-
'languageNotSupported' = 11
|
|
14
|
-
}
|
|
15
|
-
export declare const error: (path: (number | string)[], error: ParseError, type?: string) => never;
|
package/dist/set/error.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
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[ParseError["valueAndDefault"] = 7] = "valueAndDefault";
|
|
14
|
-
ParseError[ParseError["defaultNotSupported"] = 8] = "defaultNotSupported";
|
|
15
|
-
ParseError[ParseError["multipleOperationsNotAllowed"] = 9] = "multipleOperationsNotAllowed";
|
|
16
|
-
ParseError[ParseError["requiredFieldNotDefined"] = 10] = "requiredFieldNotDefined";
|
|
17
|
-
ParseError[ParseError["languageNotSupported"] = 11] = "languageNotSupported";
|
|
18
|
-
})(ParseError = exports.ParseError || (exports.ParseError = {}));
|
|
19
|
-
const error = (path, error, type // nice to give as option
|
|
20
|
-
) => {
|
|
21
|
-
throw new Error(`Field: "${path.join('.')}" ${ParseError[error]}`);
|
|
22
|
-
};
|
|
23
|
-
exports.error = error;
|
|
24
|
-
//# sourceMappingURL=error.js.map
|
package/dist/set/error.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/set/error.ts"],"names":[],"mappings":";;;AAAA,IAAY,UAaX;AAbD,WAAY,UAAU;IACpB,uEAAoB,CAAA;IACpB,qEAAmB,CAAA;IACnB,+DAAgB,CAAA;IAChB,iEAAiB,CAAA;IACjB,qEAAmB,CAAA;IACnB,iEAAiB,CAAA;IACjB,mFAA0B,CAAA;IAC1B,iEAAiB,CAAA;IACjB,yEAAqB,CAAA;IACrB,2FAA8B,CAAA;IAC9B,kFAAyB,CAAA;IACzB,4EAAsB,CAAA;AACxB,CAAC,EAbW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAarB;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/number.d.ts
DELETED
package/dist/set/number.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
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.type === 'integer' && value - Math.floor(value) !== 0) {
|
|
10
|
-
(0, error_1.error)(path, error_1.ParseError.incorrectFormat);
|
|
11
|
-
}
|
|
12
|
-
if (fieldSchema.multipleOf &&
|
|
13
|
-
value / fieldSchema.multipleOf -
|
|
14
|
-
Math.floor(value / fieldSchema.multipleOf) !==
|
|
15
|
-
0) {
|
|
16
|
-
(0, error_1.error)(path, error_1.ParseError.incorrectFormat);
|
|
17
|
-
}
|
|
18
|
-
if (fieldSchema.maximum) {
|
|
19
|
-
if (fieldSchema.exclusiveMaximum && value > value) {
|
|
20
|
-
(0, error_1.error)(path, error_1.ParseError.exceedsMaximum);
|
|
21
|
-
}
|
|
22
|
-
else if (value >= value) {
|
|
23
|
-
(0, error_1.error)(path, error_1.ParseError.exceedsMaximum);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (fieldSchema.minimum) {
|
|
27
|
-
if (fieldSchema.exclusiveMinimum && value < value) {
|
|
28
|
-
(0, error_1.error)(path, error_1.ParseError.subceedsMinimum);
|
|
29
|
-
}
|
|
30
|
-
else if (value <= value) {
|
|
31
|
-
(0, error_1.error)(path, error_1.ParseError.subceedsMinimum);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return value;
|
|
35
|
-
};
|
|
36
|
-
const shared = (path, value, fieldSchema) => {
|
|
37
|
-
if (typeof value === 'object') {
|
|
38
|
-
if (value.$increment) {
|
|
39
|
-
validate([...path, '$increment'], value.$increment, fieldSchema);
|
|
40
|
-
}
|
|
41
|
-
if (value.$decrement) {
|
|
42
|
-
validate([...path, '$decrement'], value.$decrement, fieldSchema);
|
|
43
|
-
}
|
|
44
|
-
if (value.$value !== undefined) {
|
|
45
|
-
validate(path, value.$value, fieldSchema);
|
|
46
|
-
}
|
|
47
|
-
if (value.$default !== undefined) {
|
|
48
|
-
if (value.$value !== undefined) {
|
|
49
|
-
(0, error_1.error)(path, error_1.ParseError.valueAndDefault);
|
|
50
|
-
}
|
|
51
|
-
validate(path, value.$default, fieldSchema);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
validate(path, value, fieldSchema);
|
|
56
|
-
}
|
|
57
|
-
return value;
|
|
58
|
-
};
|
|
59
|
-
const timestamp = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
|
|
60
|
-
if (typeof value === 'string') {
|
|
61
|
-
// TODO: now + 10 and stuff
|
|
62
|
-
if (value === 'now') {
|
|
63
|
-
value = Date.now();
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
const d = new Date(value);
|
|
67
|
-
value = d.valueOf();
|
|
68
|
-
if (isNaN(value)) {
|
|
69
|
-
(0, error_1.error)(path, error_1.ParseError.incorrectFormat);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
const parsedValue = shared(path, value, fieldSchema);
|
|
74
|
-
if (!noCollect) {
|
|
75
|
-
handlers.collect({
|
|
76
|
-
path,
|
|
77
|
-
value: parsedValue,
|
|
78
|
-
typeSchema,
|
|
79
|
-
fieldSchema,
|
|
80
|
-
target,
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
exports.timestamp = timestamp;
|
|
85
|
-
const number = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
|
|
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.number = number;
|
|
98
|
-
const integer = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
|
|
99
|
-
const parsedValue = shared(path, value, fieldSchema);
|
|
100
|
-
if (!noCollect) {
|
|
101
|
-
handlers.collect({
|
|
102
|
-
path,
|
|
103
|
-
value: parsedValue,
|
|
104
|
-
typeSchema,
|
|
105
|
-
fieldSchema,
|
|
106
|
-
target,
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
exports.integer = integer;
|
|
111
|
-
//# sourceMappingURL=number.js.map
|
package/dist/set/number.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,IAAI,KAAK,SAAS,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;QACrE,IAAA,aAAK,EAAC,IAAI,EAAE,kBAAU,CAAC,eAAe,CAAC,CAAA;KACxC;IACD,IACE,WAAW,CAAC,UAAU;QACtB,KAAK,GAAG,WAAW,CAAC,UAAU;YAC5B,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,WAAW,CAAC,UAAU,CAAC;YAC1C,CAAC,EACH;QACA,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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,CAAC,CAAA;IACpD,IAAI,CAAC,SAAS,EAAE;QACd,QAAQ,CAAC,OAAO,CAAC;YACf,IAAI;YACJ,KAAK,EAAE,WAAW;YAClB,UAAU;YACV,WAAW;YACX,MAAM;SACP,CAAC,CAAA;KACH;AACH,CAAC,CAAA;AAnBY,QAAA,OAAO,WAmBnB"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.parseValueAndDefault = void 0;
|
|
7
|
-
const error_1 = require("./error");
|
|
8
|
-
const parsers_1 = __importDefault(require("./parsers"));
|
|
9
|
-
const parseValueAndDefault = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
|
|
10
|
-
let handled = false;
|
|
11
|
-
if (typeof value === 'object') {
|
|
12
|
-
const typeDef = fieldSchema.type ?? ('enum' in fieldSchema ? 'enum' : '');
|
|
13
|
-
const parse = parsers_1.default[typeDef];
|
|
14
|
-
if (value.$value !== undefined) {
|
|
15
|
-
// TODO: for errors handle path a bit smarter...
|
|
16
|
-
await parse(path, value.$value, fieldSchema, typeSchema, target, handlers, true);
|
|
17
|
-
handled = true;
|
|
18
|
-
}
|
|
19
|
-
if (value.$default !== undefined) {
|
|
20
|
-
if (value.$value !== undefined) {
|
|
21
|
-
(0, error_1.error)(path, error_1.ParseError.valueAndDefault);
|
|
22
|
-
}
|
|
23
|
-
await parse(path, value.$default, fieldSchema, typeSchema, target, handlers, true);
|
|
24
|
-
handled = true;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
if (handled && !noCollect) {
|
|
28
|
-
handlers.collect({ path, value, typeSchema, fieldSchema, target });
|
|
29
|
-
}
|
|
30
|
-
return handled;
|
|
31
|
-
};
|
|
32
|
-
exports.parseValueAndDefault = parseValueAndDefault;
|
|
33
|
-
//# sourceMappingURL=parseDefaultAndValue.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parseDefaultAndValue.js","sourceRoot":"","sources":["../../src/set/parseDefaultAndValue.ts"],"names":[],"mappings":";;;;;;AAEA,mCAA2C;AAC3C,wDAA+B;AAExB,MAAM,oBAAoB,GAAoC,KAAK,EACxE,IAAI,EACJ,KAAK,EACL,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,EACR,SAAS,EACS,EAAE;IACpB,IAAI,OAAO,GAAG,KAAK,CAAA;IACnB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,IAAI,CAAC,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;QACzE,MAAM,KAAK,GAAG,iBAAO,CAAC,OAAO,CAAC,CAAA;QAC9B,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,EAAE;YAC9B,gDAAgD;YAChD,MAAM,KAAK,CACT,IAAI,EACJ,KAAK,CAAC,MAAM,EACZ,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,EACR,IAAI,CACL,CAAA;YACD,OAAO,GAAG,IAAI,CAAA;SACf;QACD,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS,EAAE;YAChC,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,EAAE;gBAC9B,IAAA,aAAK,EAAC,IAAI,EAAE,kBAAU,CAAC,eAAe,CAAC,CAAA;aACxC;YACD,MAAM,KAAK,CACT,IAAI,EACJ,KAAK,CAAC,QAAQ,EACd,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,EACR,IAAI,CACL,CAAA;YACD,OAAO,GAAG,IAAI,CAAA;SACf;KACF;IACD,IAAI,OAAO,IAAI,CAAC,SAAS,EAAE;QACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAA;KACnE;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AA9CY,QAAA,oBAAoB,wBA8ChC"}
|
package/dist/set/parsers.d.ts
DELETED
package/dist/set/parsers.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const references = __importStar(require("./references"));
|
|
27
|
-
const collections = __importStar(require("./collections"));
|
|
28
|
-
const number = __importStar(require("./number"));
|
|
29
|
-
const string = __importStar(require("./string"));
|
|
30
|
-
const rest_1 = require("./rest");
|
|
31
|
-
const parsers = {
|
|
32
|
-
...string,
|
|
33
|
-
...references,
|
|
34
|
-
...collections,
|
|
35
|
-
...number,
|
|
36
|
-
enum: rest_1.enumParser,
|
|
37
|
-
boolean: rest_1.boolean,
|
|
38
|
-
cardinality: rest_1.cardinality,
|
|
39
|
-
json: rest_1.json,
|
|
40
|
-
};
|
|
41
|
-
exports.default = parsers;
|
|
42
|
-
//# sourceMappingURL=parsers.js.map
|
package/dist/set/parsers.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parsers.js","sourceRoot":"","sources":["../../src/set/parsers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,yDAA0C;AAC1C,2DAA4C;AAC5C,iDAAkC;AAClC,iDAAkC;AAElC,iCAA+D;AAE/D,MAAM,OAAO,GAAY;IACvB,GAAG,MAAM;IACT,GAAG,UAAU;IACb,GAAG,WAAW;IACd,GAAG,MAAM;IACT,IAAI,EAAE,iBAAU;IAChB,OAAO,EAAP,cAAO;IACP,WAAW,EAAX,kBAAW;IACX,IAAI,EAAJ,WAAI;CACL,CAAA;AAED,kBAAe,OAAO,CAAA"}
|
package/dist/set/references.d.ts
DELETED
package/dist/set/references.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.references = exports.reference = void 0;
|
|
4
|
-
const error_1 = require("./error");
|
|
5
|
-
const reference = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
|
|
6
|
-
// $no root
|
|
7
|
-
// prob pass these as options
|
|
8
|
-
// value .default
|
|
9
|
-
// $value
|
|
10
|
-
if (typeof value !== 'string') {
|
|
11
|
-
(0, error_1.error)(path, error_1.ParseError.incorrectFormat);
|
|
12
|
-
}
|
|
13
|
-
if ('allowedTypes' in fieldSchema) {
|
|
14
|
-
const prefix = value.slice(0, 2);
|
|
15
|
-
const targetType = target.schema.prefixToTypeMapping[prefix];
|
|
16
|
-
if (!targetType) {
|
|
17
|
-
(0, error_1.error)(path, error_1.ParseError.referenceIsIncorrectType);
|
|
18
|
-
}
|
|
19
|
-
let typeMatches = false;
|
|
20
|
-
for (const t of fieldSchema.allowedTypes) {
|
|
21
|
-
if (typeof t === 'string') {
|
|
22
|
-
if (t === targetType) {
|
|
23
|
-
typeMatches = true;
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
if (t.type && t.type === targetType) {
|
|
29
|
-
typeMatches = true;
|
|
30
|
-
if (t.$filter) {
|
|
31
|
-
if (!(await handlers.referenceFilterCondition(value, t.$filter))) {
|
|
32
|
-
(0, error_1.error)(path, error_1.ParseError.referenceIsIncorrectType);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
else if (!t.type && t.$filter) {
|
|
37
|
-
if (!(await handlers.referenceFilterCondition(value, t.$filter))) {
|
|
38
|
-
(0, error_1.error)(path, error_1.ParseError.referenceIsIncorrectType);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
if (typeMatches === false) {
|
|
44
|
-
(0, error_1.error)(path, error_1.ParseError.referenceIsIncorrectType);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if (!noCollect) {
|
|
48
|
-
handlers.collect({ path, value, typeSchema, fieldSchema, target });
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
exports.reference = reference;
|
|
52
|
-
const references = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
|
|
53
|
-
// default
|
|
54
|
-
// $no root
|
|
55
|
-
if (Array.isArray(value)) {
|
|
56
|
-
await Promise.all(value.map((v, i) => {
|
|
57
|
-
return (0, exports.reference)([...path, i], v,
|
|
58
|
-
// not nice slow
|
|
59
|
-
{ ...fieldSchema, type: 'reference' }, typeSchema, target, handlers, true);
|
|
60
|
-
}));
|
|
61
|
-
value = { $value: value };
|
|
62
|
-
}
|
|
63
|
-
else if (typeof value === 'object') {
|
|
64
|
-
if (value.$add) {
|
|
65
|
-
await Promise.all(value.$add.map((v, i) => {
|
|
66
|
-
return (0, exports.reference)([...path, '$add', i], v,
|
|
67
|
-
// not nice slow
|
|
68
|
-
{ ...fieldSchema, type: 'reference' }, typeSchema, target, handlers, true);
|
|
69
|
-
}));
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (!noCollect) {
|
|
73
|
-
handlers.collect({ path, value, typeSchema, fieldSchema, target });
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
exports.references = references;
|
|
77
|
-
//# sourceMappingURL=references.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"references.js","sourceRoot":"","sources":["../../src/set/references.ts"],"names":[],"mappings":";;;AACA,mCAA2C;AAEpC,MAAM,SAAS,GAAwB,KAAK,EACjD,IAAI,EACJ,KAAK,EACL,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,EACR,SAAS,EACT,EAAE;IACF,WAAW;IACX,6BAA6B;IAC7B,iBAAiB;IACjB,SAAS;IAET,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,IAAA,aAAK,EAAC,IAAI,EAAE,kBAAU,CAAC,eAAe,CAAC,CAAA;KACxC;IAED,IAAI,cAAc,IAAI,WAAW,EAAE;QACjC,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QAChC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAA;QAC5D,IAAI,CAAC,UAAU,EAAE;YACf,IAAA,aAAK,EAAC,IAAI,EAAE,kBAAU,CAAC,wBAAwB,CAAC,CAAA;SACjD;QACD,IAAI,WAAW,GAAG,KAAK,CAAA;QACvB,KAAK,MAAM,CAAC,IAAI,WAAW,CAAC,YAAY,EAAE;YACxC,IAAI,O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