@based/schema 1.3.0 → 1.3.1
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 +211 -0
- package/dist/set/collections.js.map +1 -0
- package/dist/set/error.d.ts +15 -0
- package/dist/set/error.js +24 -0
- package/dist/set/error.js.map +1 -0
- package/dist/set/fields/string.d.ts.map +1 -1
- package/dist/set/fields/string.js +7 -73
- package/dist/set/fields/string.js.map +1 -1
- package/dist/set/number.d.ts +4 -0
- package/dist/set/number.js +111 -0
- package/dist/set/number.js.map +1 -0
- package/dist/set/parseDefaultAndValue.d.ts +3 -0
- package/dist/set/parseDefaultAndValue.js +33 -0
- package/dist/set/parseDefaultAndValue.js.map +1 -0
- package/dist/set/parsers.d.ts +3 -0
- package/dist/set/parsers.js +42 -0
- package/dist/set/parsers.js.map +1 -0
- 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.d.ts +5 -0
- package/dist/set/rest.js +76 -0
- package/dist/set/rest.js.map +1 -0
- package/dist/set/string.d.ts +3 -0
- package/dist/set/string.js +173 -0
- package/dist/set/string.js.map +1 -0
- package/package.json +1 -1
- package/src/set/fields/string.ts +7 -74
|
@@ -0,0 +1,211 @@
|
|
|
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
|
|
@@ -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,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,EAAE,CAAA;IAC7B,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,CAAA;IAClC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACxB,MAAM,WAAW,GAAG,EAAE,CAAA;QACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACrC,CAAC,CAAC,IAAI,CACJ,IAAA,cAAW,EAAC,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE;gBAChE,GAAG,QAAQ;gBACX,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;oBACrB,WAAW,CA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AO,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"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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;
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../src/set/fields/string.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAa,MAAM,cAAc,CAAA;AA0GrD,eAAO,MAAM,MAAM,EAAE,WAAW,CAAC,QAAQ,CAKxC,CAAA;AAID,eAAO,MAAM,IAAI,EAAE,WAAW,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../src/set/fields/string.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAa,MAAM,cAAc,CAAA;AA0GrD,eAAO,MAAM,MAAM,EAAE,WAAW,CAAC,QAAQ,CAKxC,CAAA;AAID,eAAO,MAAM,IAAI,EAAE,WAAW,CAAC,MAAM,CAqKpC,CAAA"}
|
|
@@ -150,6 +150,7 @@ const text = async (args) => {
|
|
|
150
150
|
args
|
|
151
151
|
.create({
|
|
152
152
|
key: k,
|
|
153
|
+
fieldSchema: { type: 'string' },
|
|
153
154
|
value: { $default: args.value[key][k] },
|
|
154
155
|
})
|
|
155
156
|
.collect();
|
|
@@ -170,6 +171,7 @@ const text = async (args) => {
|
|
|
170
171
|
else {
|
|
171
172
|
args
|
|
172
173
|
.create({
|
|
174
|
+
fieldSchema: { type: 'string' },
|
|
173
175
|
key: args.target.$language,
|
|
174
176
|
value: { $default: args.value[key] },
|
|
175
177
|
})
|
|
@@ -187,6 +189,7 @@ const text = async (args) => {
|
|
|
187
189
|
args
|
|
188
190
|
.create({
|
|
189
191
|
key,
|
|
192
|
+
fieldSchema: { type: 'string' },
|
|
190
193
|
value: args.value[key],
|
|
191
194
|
})
|
|
192
195
|
.collect();
|
|
@@ -199,6 +202,7 @@ const text = async (args) => {
|
|
|
199
202
|
args
|
|
200
203
|
.create({
|
|
201
204
|
key,
|
|
205
|
+
fieldSchema: { type: 'string' },
|
|
202
206
|
value: args.value[key].$value,
|
|
203
207
|
})
|
|
204
208
|
.collect();
|
|
@@ -212,6 +216,7 @@ const text = async (args) => {
|
|
|
212
216
|
args
|
|
213
217
|
.create({
|
|
214
218
|
key,
|
|
219
|
+
fieldSchema: { type: 'string' },
|
|
215
220
|
value: { $default: args.value[key].$default },
|
|
216
221
|
})
|
|
217
222
|
.collect();
|
|
@@ -233,6 +238,7 @@ const text = async (args) => {
|
|
|
233
238
|
args
|
|
234
239
|
.create({
|
|
235
240
|
key,
|
|
241
|
+
fieldSchema: { type: 'string' },
|
|
236
242
|
value: args.value[key],
|
|
237
243
|
})
|
|
238
244
|
.collect();
|
|
@@ -263,6 +269,7 @@ const text = async (args) => {
|
|
|
263
269
|
.create({
|
|
264
270
|
value,
|
|
265
271
|
key: args.target.$language,
|
|
272
|
+
fieldSchema: { type: 'string' },
|
|
266
273
|
})
|
|
267
274
|
.collect();
|
|
268
275
|
if (!args._stopObject) {
|
|
@@ -272,77 +279,4 @@ const text = async (args) => {
|
|
|
272
279
|
}
|
|
273
280
|
};
|
|
274
281
|
exports.text = text;
|
|
275
|
-
/*
|
|
276
|
-
const value = args.value
|
|
277
|
-
if (value !== null && typeof value === 'object') {
|
|
278
|
-
args.stop()
|
|
279
|
-
const result: any = {}
|
|
280
|
-
for (const key in value) {
|
|
281
|
-
if (key === '$value') {
|
|
282
|
-
const nValue = await next(args, key)
|
|
283
|
-
if (typeof nValue === 'object') {
|
|
284
|
-
deepMerge(result, nValue)
|
|
285
|
-
} else {
|
|
286
|
-
args.error(ParseError.incorrectFormat)
|
|
287
|
-
return
|
|
288
|
-
}
|
|
289
|
-
} else if (key === '$default') {
|
|
290
|
-
result.$default = await next(args, key)
|
|
291
|
-
} else if (args.schema.languages.includes(<BasedSchemaLanguage>key)) {
|
|
292
|
-
if (value[key] && typeof value[key] === 'object') {
|
|
293
|
-
for (const k in value[key]) {
|
|
294
|
-
if (k === '$value') {
|
|
295
|
-
if (!validateString(args, value[key].$value)) {
|
|
296
|
-
args.create({ key }).error(ParseError.incorrectFormat)
|
|
297
|
-
} else {
|
|
298
|
-
result[key] = value[key].$value
|
|
299
|
-
}
|
|
300
|
-
} else if (k === '$default') {
|
|
301
|
-
if (!validateString(args, value[key].$default)) {
|
|
302
|
-
args.create({ key }).error(ParseError.incorrectFormat)
|
|
303
|
-
} else {
|
|
304
|
-
setByPath(result, ['$default', key], value[key].$default)
|
|
305
|
-
}
|
|
306
|
-
} else {
|
|
307
|
-
args
|
|
308
|
-
.create({ path: [...args.path, key, k] })
|
|
309
|
-
.error(ParseError.fieldDoesNotExist)
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
} else {
|
|
313
|
-
if (!validateString(args, args.value[key])) {
|
|
314
|
-
args.error(ParseError.incorrectFormat)
|
|
315
|
-
return
|
|
316
|
-
}
|
|
317
|
-
result[key] = args.value[key]
|
|
318
|
-
}
|
|
319
|
-
} else {
|
|
320
|
-
args.create({ key }).error(ParseError.languageNotSupported)
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
args.collect(result)
|
|
324
|
-
return
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
if (typeof value !== 'string') {
|
|
328
|
-
args.error(ParseError.incorrectFormat)
|
|
329
|
-
return
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
if (!args.target.$language) {
|
|
333
|
-
args.error(ParseError.noLanguageFound)
|
|
334
|
-
return
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
if (!validateString(args, args.value)) {
|
|
338
|
-
args.error(ParseError.incorrectFormat)
|
|
339
|
-
return
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
args.value = {
|
|
343
|
-
[args.target.$language]: value,
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
args.collect()
|
|
347
|
-
*/
|
|
348
282
|
//# sourceMappingURL=string.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../../src/set/fields/string.ts"],"names":[],"mappings":";;;;;;AAKA,uCAAwC;AAExC,0DAAkC;AAKlC,MAAM,cAAc,GAGhB;IACF,KAAK,EAAE,mBAAU,CAAC,OAAO;IACzB,GAAG,EAAE,mBAAU,CAAC,KAAK;IACrB,UAAU,EAAE,mBAAU,CAAC,YAAY;IACnC,EAAE,EAAE,mBAAU,CAAC,IAAI;IACnB,OAAO,EAAE,mBAAU,CAAC,SAAS;IAC7B,IAAI,EAAE,mBAAU,CAAC,MAAM;IACvB,IAAI,EAAE,mBAAU,CAAC,MAAM;IACvB,GAAG,EAAE,mBAAU,CAAC,KAAK;IACrB,KAAK,EAAE,mBAAU,CAAC,OAAO;IACzB,YAAY,EAAE,mBAAU,CAAC,cAAc;IACvC,YAAY,EAAE,mBAAU,CAAC,cAAc;IACvC,mBAAmB,EAAE,mBAAU,CAAC,qBAAqB;IACrD,cAAc,EAAE,mBAAU,CAAC,gBAAgB;IAC3C,IAAI,EAAE,mBAAU,CAAC,MAAM;IACvB,SAAS,EAAE,mBAAU,CAAC,WAAW;IACjC,SAAS,EAAE,mBAAU,CAAC,WAAW;IACjC,KAAK,EAAE,mBAAU,CAAC,OAAO;IACzB,MAAM,EAAE,mBAAU,CAAC,QAAQ;IAC3B,aAAa,EAAE,mBAAU,CAAC,eAAe;IACzC,IAAI,EAAE,mBAAU,CAAC,MAAM;IACvB,WAAW,EAAE,mBAAU,CAAC,aAAa;IACrC,KAAK,EAAE,mBAAU,CAAC,OAAO;IACzB,QAAQ,EAAE,mBAAU,CAAC,UAAU;IAC/B,QAAQ,EAAE,mBAAU,CAAC,UAAU;IAC/B,GAAG,EAAE,mBAA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CAAC,IAAI,CAAC,WAAW,EAAE;QACrB,IAAI,CAAC,OAAO,CAAC;YACX,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,KAAK;SAC/B,CAAC,CAAA;KACH;AACH,CAAC,CAAA;AArKY,QAAA,IAAI,QAqKhB"}
|
|
@@ -0,0 +1,111 @@
|
|
|
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
|
|
@@ -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,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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,KAAK,EACL,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,EACR,SAAS,EACT,EAAE;IACF,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,WAAW,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,MAAM,UAmBlB;AAEM,MAAM,OAAO,GAAsB,KAAK,EAC7C,IAAI,EACJ,KAAK,EACL,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,EACR,SAAS,EACT,EAAE;IACF,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,WAAW,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"}
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,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CAAA;SACF;KACF;IACD,IAAI,CAAC,SAAS,EAAE;QACd,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAA;KACnE;AACH,CAAC,CAAA;AAhDY,QAAA,UAAU,cAgDtB"}
|
package/dist/set/rest.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.json = exports.enumParser = exports.boolean = exports.cardinality = void 0;
|
|
4
|
+
const utils_1 = require("@saulx/utils");
|
|
5
|
+
const hash_1 = require("@saulx/hash");
|
|
6
|
+
const error_1 = require("./error");
|
|
7
|
+
const parseDefaultAndValue_1 = require("./parseDefaultAndValue");
|
|
8
|
+
const cardinality = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
|
|
9
|
+
if (value && typeof value === 'object') {
|
|
10
|
+
if (value.$default !== undefined) {
|
|
11
|
+
(0, error_1.error)(path, error_1.ParseError.defaultNotSupported);
|
|
12
|
+
}
|
|
13
|
+
if (value.$value !== undefined) {
|
|
14
|
+
value = (0, hash_1.hashObjectIgnoreKeyOrder)(value.$value).toString(16);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
value = (0, hash_1.hashObjectIgnoreKeyOrder)(value).toString(16);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
value = (0, hash_1.hash)(value).toString(16);
|
|
22
|
+
}
|
|
23
|
+
if (!noCollect) {
|
|
24
|
+
handlers.collect({ path, value, typeSchema, fieldSchema, target });
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
exports.cardinality = cardinality;
|
|
28
|
+
const boolean = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
|
|
29
|
+
if (await (0, parseDefaultAndValue_1.parseValueAndDefault)(path, value, fieldSchema, typeSchema, target, handlers, noCollect)) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (typeof value !== 'boolean') {
|
|
33
|
+
(0, error_1.error)(path, error_1.ParseError.incorrectFormat);
|
|
34
|
+
}
|
|
35
|
+
if (!noCollect) {
|
|
36
|
+
handlers.collect({ path, value, typeSchema, fieldSchema, target });
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
exports.boolean = boolean;
|
|
40
|
+
const enumParser = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
|
|
41
|
+
const enumValues = fieldSchema.enum;
|
|
42
|
+
if (!(await (0, parseDefaultAndValue_1.parseValueAndDefault)(path, value, fieldSchema, typeSchema, target, handlers, noCollect))) {
|
|
43
|
+
for (let i = 0; i < enumValues.length; i++) {
|
|
44
|
+
if ((0, utils_1.deepEqual)(enumValues[i], value)) {
|
|
45
|
+
if (!noCollect) {
|
|
46
|
+
handlers.collect({ path, value: i, typeSchema, fieldSchema, target });
|
|
47
|
+
}
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
(0, error_1.error)(path, error_1.ParseError.incorrectFormat);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
exports.enumParser = enumParser;
|
|
55
|
+
const json = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
|
|
56
|
+
if (await (0, parseDefaultAndValue_1.parseValueAndDefault)(path, value, fieldSchema, typeSchema, target, handlers, noCollect)) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
const parsedValue = JSON.stringify(value);
|
|
61
|
+
if (!noCollect) {
|
|
62
|
+
handlers.collect({
|
|
63
|
+
path,
|
|
64
|
+
value: parsedValue,
|
|
65
|
+
typeSchema,
|
|
66
|
+
fieldSchema,
|
|
67
|
+
target,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
(0, error_1.error)(path, error_1.ParseError.incorrectFormat);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
exports.json = json;
|
|
76
|
+
//# sourceMappingURL=rest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rest.js","sourceRoot":"","sources":["../../src/set/rest.ts"],"names":[],"mappings":";;;AACA,wCAAwC;AACxC,sCAA4D;AAC5D,mCAA2C;AAC3C,iEAA6D;AAEtD,MAAM,WAAW,GAA0B,KAAK,EACrD,IAAI,EACJ,KAAK,EACL,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,EACR,SAAS,EACT,EAAE;IACF,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QACtC,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS,EAAE;YAChC,IAAA,aAAK,EAAC,IAAI,EAAE,kBAAU,CAAC,mBAAmB,CAAC,CAAA;SAC5C;QACD,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,EAAE;YAC9B,KAAK,GAAG,IAAA,+BAAwB,EAAC,KAAK,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;SAC5D;aAAM;YACL,KAAK,GAAG,IAAA,+BAAwB,EAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;SACrD;KACF;SAAM;QACL,KAAK,GAAG,IAAA,WAAI,EAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;KACjC;IACD,IAAI,CAAC,SAAS,EAAE;QACd,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAA;KACnE;AACH,CAAC,CAAA;AAxBY,QAAA,WAAW,eAwBvB;AAEM,MAAM,OAAO,GAAsB,KAAK,EAC7C,IAAI,EACJ,KAAK,EACL,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,EACR,SAAS,EACT,EAAE;IACF,IACE,MAAM,IAAA,2CAAoB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AI,EACJ,KAAK,EACL,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,EACR,SAAS,EACT,EAAE;IACF,IACE,MAAM,IAAA,2CAAoB,EACxB,IAAI,EACJ,KAAK,EACL,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,EACR,SAAS,CACV,EACD;QACA,OAAM;KACP;IAED,IAAI;QACF,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;QACzC,IAAI,CAAC,SAAS,EAAE;YACd,QAAQ,CAAC,OAAO,CAAC;gBACf,IAAI;gBACJ,KAAK,EAAE,WAAW;gBAClB,UAAU;gBACV,WAAW;gBACX,MAAM;aACP,CAAC,CAAA;SACH;KACF;IAAC,OAAO,GAAG,EAAE;QACZ,IAAA,aAAK,EAAC,IAAI,EAAE,kBAAU,CAAC,eAAe,CAAC,CAAA;KACxC;AACH,CAAC,CAAA;AArCY,QAAA,IAAI,QAqChB"}
|
|
@@ -0,0 +1,173 @@
|
|
|
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.text = exports.string = void 0;
|
|
7
|
+
const error_1 = require("./error");
|
|
8
|
+
const validator_1 = __importDefault(require("validator"));
|
|
9
|
+
const parseDefaultAndValue_1 = require("./parseDefaultAndValue");
|
|
10
|
+
const formatPatterns = {
|
|
11
|
+
email: validator_1.default.isEmail,
|
|
12
|
+
URL: validator_1.default.isURL,
|
|
13
|
+
MACAddress: validator_1.default.isMACAddress,
|
|
14
|
+
IP: validator_1.default.isIP,
|
|
15
|
+
IPRange: validator_1.default.isIPRange,
|
|
16
|
+
FQDN: validator_1.default.isFQDN,
|
|
17
|
+
IBAN: validator_1.default.isIBAN,
|
|
18
|
+
BIC: validator_1.default.isBIC,
|
|
19
|
+
alpha: validator_1.default.isAlpha,
|
|
20
|
+
alphaLocales: validator_1.default.isAlphaLocales,
|
|
21
|
+
alphanumeric: validator_1.default.isAlphanumeric,
|
|
22
|
+
alphanumericLocales: validator_1.default.isAlphanumericLocales,
|
|
23
|
+
passportNumber: validator_1.default.isPassportNumber,
|
|
24
|
+
port: validator_1.default.isPort,
|
|
25
|
+
lowercase: validator_1.default.isLowercase,
|
|
26
|
+
uppercase: validator_1.default.isUppercase,
|
|
27
|
+
ascii: validator_1.default.isAscii,
|
|
28
|
+
semVer: validator_1.default.isSemVer,
|
|
29
|
+
surrogatePair: validator_1.default.isSurrogatePair,
|
|
30
|
+
IMEI: validator_1.default.isIMEI,
|
|
31
|
+
hexadecimal: validator_1.default.isHexadecimal,
|
|
32
|
+
octal: validator_1.default.isOctal,
|
|
33
|
+
hexColor: validator_1.default.isHexColor,
|
|
34
|
+
rgbColor: validator_1.default.isRgbColor,
|
|
35
|
+
HSL: validator_1.default.isHSL,
|
|
36
|
+
ISRC: validator_1.default.isISRC,
|
|
37
|
+
MD5: validator_1.default.isMD5,
|
|
38
|
+
JWT: validator_1.default.isJWT,
|
|
39
|
+
UUID: validator_1.default.isUUID,
|
|
40
|
+
luhnNumber: validator_1.default.isLuhnNumber,
|
|
41
|
+
creditCard: validator_1.default.isCreditCard,
|
|
42
|
+
identityCard: validator_1.default.isIdentityCard,
|
|
43
|
+
EAN: validator_1.default.isEAN,
|
|
44
|
+
ISIN: validator_1.default.isISIN,
|
|
45
|
+
ISBN: validator_1.default.isISBN,
|
|
46
|
+
ISSN: validator_1.default.isISSN,
|
|
47
|
+
mobilePhone: validator_1.default.isMobilePhone,
|
|
48
|
+
mobilePhoneLocales: validator_1.default.isMobilePhoneLocales,
|
|
49
|
+
postalCode: validator_1.default.isPostalCode,
|
|
50
|
+
postalCodeLocales: validator_1.default.isPostalCodeLocales,
|
|
51
|
+
ethereumAddress: validator_1.default.isEthereumAddress,
|
|
52
|
+
currency: validator_1.default.isCurrency,
|
|
53
|
+
btcAddress: validator_1.default.isBtcAddress,
|
|
54
|
+
ISO6391: validator_1.default.isISO6391,
|
|
55
|
+
ISO8601: validator_1.default.isISO8601,
|
|
56
|
+
RFC3339: validator_1.default.isRFC3339,
|
|
57
|
+
ISO31661Alpha2: validator_1.default.isISO31661Alpha2,
|
|
58
|
+
ISO31661Alpha3: validator_1.default.isISO31661Alpha3,
|
|
59
|
+
ISO4217: validator_1.default.isISO4217,
|
|
60
|
+
base32: validator_1.default.isBase32,
|
|
61
|
+
base58: validator_1.default.isBase58,
|
|
62
|
+
base64: validator_1.default.isBase64,
|
|
63
|
+
dataURI: validator_1.default.isDataURI,
|
|
64
|
+
magnetURI: validator_1.default.isMagnetURI,
|
|
65
|
+
mimeType: validator_1.default.isMimeType,
|
|
66
|
+
latLong: validator_1.default.isLatLong,
|
|
67
|
+
slug: validator_1.default.isSlug,
|
|
68
|
+
strongPassword: validator_1.default.isStrongPassword,
|
|
69
|
+
taxID: validator_1.default.isTaxID,
|
|
70
|
+
licensePlate: validator_1.default.isLicensePlate,
|
|
71
|
+
VAT: validator_1.default.isVAT,
|
|
72
|
+
};
|
|
73
|
+
const validate = (path, value, fieldSchema) => {
|
|
74
|
+
if (typeof value !== 'string') {
|
|
75
|
+
(0, error_1.error)(path, error_1.ParseError.incorrectFormat);
|
|
76
|
+
}
|
|
77
|
+
if (fieldSchema.minLength && value.length < fieldSchema.minLength) {
|
|
78
|
+
(0, error_1.error)(path, error_1.ParseError.subceedsMinimum);
|
|
79
|
+
}
|
|
80
|
+
if (fieldSchema.maxLength && value.length > fieldSchema.maxLength) {
|
|
81
|
+
(0, error_1.error)(path, error_1.ParseError.exceedsMaximum);
|
|
82
|
+
}
|
|
83
|
+
if (fieldSchema.pattern) {
|
|
84
|
+
const re = new RegExp(fieldSchema.pattern);
|
|
85
|
+
if (!re.test(value)) {
|
|
86
|
+
(0, error_1.error)(path, error_1.ParseError.incorrectFormat);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (fieldSchema.format && !formatPatterns[fieldSchema.format](value)) {
|
|
90
|
+
(0, error_1.error)(path, error_1.ParseError.incorrectFormat);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const string = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
|
|
94
|
+
if (await (0, parseDefaultAndValue_1.parseValueAndDefault)(path, value, fieldSchema, typeSchema, target, handlers, noCollect)) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
validate(path, value, fieldSchema);
|
|
98
|
+
if (!noCollect) {
|
|
99
|
+
handlers.collect({ path, value, typeSchema, fieldSchema, target });
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
exports.string = string;
|
|
103
|
+
const text = async (path, value, fieldSchema, typeSchema, target, handlers, noCollect) => {
|
|
104
|
+
const valueType = typeof value;
|
|
105
|
+
if (target.$language && valueType === 'string') {
|
|
106
|
+
validate(path, value, fieldSchema);
|
|
107
|
+
if (!noCollect) {
|
|
108
|
+
handlers.collect({
|
|
109
|
+
path,
|
|
110
|
+
value: { [target.$language]: value },
|
|
111
|
+
typeSchema,
|
|
112
|
+
fieldSchema,
|
|
113
|
+
target,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (valueType !== 'object') {
|
|
119
|
+
(0, error_1.error)(path, error_1.ParseError.incorrectFormat);
|
|
120
|
+
}
|
|
121
|
+
if (target.$language &&
|
|
122
|
+
(await (0, parseDefaultAndValue_1.parseValueAndDefault)(path, value, fieldSchema, typeSchema, target, handlers, noCollect))) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
else if (await (0, parseDefaultAndValue_1.parseValueAndDefault)(path, value, fieldSchema, typeSchema, target, handlers, true)) {
|
|
126
|
+
if (!noCollect) {
|
|
127
|
+
handlers.collect({
|
|
128
|
+
path,
|
|
129
|
+
value,
|
|
130
|
+
typeSchema,
|
|
131
|
+
fieldSchema,
|
|
132
|
+
target,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
for (const key in value) {
|
|
138
|
+
const newPath = [...path, key];
|
|
139
|
+
// @ts-ignore
|
|
140
|
+
if (!target.schema.languages.includes(key)) {
|
|
141
|
+
(0, error_1.error)(newPath, error_1.ParseError.languageNotSupported);
|
|
142
|
+
}
|
|
143
|
+
if (typeof value[key] === 'object') {
|
|
144
|
+
if (value[key].$value) {
|
|
145
|
+
await (0, exports.text)([...newPath, '$value'], value[key].$value, fieldSchema, typeSchema, target, handlers, true);
|
|
146
|
+
}
|
|
147
|
+
if (!noCollect) {
|
|
148
|
+
handlers.collect({
|
|
149
|
+
path: newPath,
|
|
150
|
+
value: null,
|
|
151
|
+
typeSchema,
|
|
152
|
+
fieldSchema,
|
|
153
|
+
target,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (!(await (0, parseDefaultAndValue_1.parseValueAndDefault)(path, { [key]: value[key] }, fieldSchema, typeSchema, target, handlers, true))) {
|
|
159
|
+
validate(newPath, value[key], fieldSchema);
|
|
160
|
+
}
|
|
161
|
+
if (!noCollect) {
|
|
162
|
+
handlers.collect({
|
|
163
|
+
path: newPath,
|
|
164
|
+
value: value[key],
|
|
165
|
+
typeSchema,
|
|
166
|
+
fieldSchema,
|
|
167
|
+
target,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
exports.text = text;
|
|
173
|
+
//# sourceMappingURL=string.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../src/set/string.ts"],"names":[],"mappings":";;;;;;AACA,mCAA2C;AAE3C,0DAAkC;AAClC,iEAA6D;AAE7D,MAAM,cAAc,GAGhB;IACF,KAAK,EAAE,mBAAU,CAAC,OAAO;IACzB,GAAG,EAAE,mBAAU,CAAC,KAAK;IACrB,UAAU,E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,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YAC1C,IAAA,aAAK,EAAC,OAAO,EAAE,kBAAU,CAAC,oBAAoB,CAAC,CAAA;SAChD;QAED,IAAI,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE;YAClC,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE;gBACrB,MAAM,IAAA,YAAI,EACR,CAAC,GAAG,OAAO,EAAE,QAAQ,CAAC,EACtB,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,EACjB,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,EACR,IAAI,CACL,CAAA;aACF;YAED,IAAI,CAAC,SAAS,EAAE;gBACd,QAAQ,CAAC,OAAO,CAAC;oBACf,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,IAAI;oBACX,UAAU;oBACV,WAAW;oBACX,MAAM;iBACP,CAAC,CAAA;aACH;YACD,SAAQ;SACT;QAED,IACE,CAAC,CAAC,MAAM,IAAA,2CAAoB,EAC1B,IAAI,EACJ,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,EACrB,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,EACR,IAAI,CACL,CAAC,EACF;YACA,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC,CAAA;SAC3C;QAED,IAAI,CAAC,SAAS,EAAE;YACd,QAAQ,CAAC,OAAO,CAAC;gBACf,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC;gBACjB,UAAU;gBACV,WAAW;gBACX,MAAM;aACP,CAAC,CAAA;SACH;KACF;AACH,CAAC,CAAA;AAzHY,QAAA,IAAI,QAyHhB"}
|
package/package.json
CHANGED
package/src/set/fields/string.ts
CHANGED
|
@@ -164,6 +164,7 @@ export const text: FieldParser<'text'> = async (args) => {
|
|
|
164
164
|
args
|
|
165
165
|
.create({
|
|
166
166
|
key: k,
|
|
167
|
+
fieldSchema: { type: 'string' },
|
|
167
168
|
value: { $default: args.value[key][k] },
|
|
168
169
|
})
|
|
169
170
|
.collect()
|
|
@@ -180,6 +181,7 @@ export const text: FieldParser<'text'> = async (args) => {
|
|
|
180
181
|
} else {
|
|
181
182
|
args
|
|
182
183
|
.create({
|
|
184
|
+
fieldSchema: { type: 'string' },
|
|
183
185
|
key: args.target.$language,
|
|
184
186
|
value: { $default: args.value[key] },
|
|
185
187
|
})
|
|
@@ -196,6 +198,7 @@ export const text: FieldParser<'text'> = async (args) => {
|
|
|
196
198
|
args
|
|
197
199
|
.create({
|
|
198
200
|
key,
|
|
201
|
+
fieldSchema: { type: 'string' },
|
|
199
202
|
value: args.value[key],
|
|
200
203
|
})
|
|
201
204
|
.collect()
|
|
@@ -206,6 +209,7 @@ export const text: FieldParser<'text'> = async (args) => {
|
|
|
206
209
|
args
|
|
207
210
|
.create({
|
|
208
211
|
key,
|
|
212
|
+
fieldSchema: { type: 'string' },
|
|
209
213
|
value: args.value[key].$value,
|
|
210
214
|
})
|
|
211
215
|
.collect()
|
|
@@ -217,6 +221,7 @@ export const text: FieldParser<'text'> = async (args) => {
|
|
|
217
221
|
args
|
|
218
222
|
.create({
|
|
219
223
|
key,
|
|
224
|
+
fieldSchema: { type: 'string' },
|
|
220
225
|
value: { $default: args.value[key].$default },
|
|
221
226
|
})
|
|
222
227
|
.collect()
|
|
@@ -236,6 +241,7 @@ export const text: FieldParser<'text'> = async (args) => {
|
|
|
236
241
|
args
|
|
237
242
|
.create({
|
|
238
243
|
key,
|
|
244
|
+
fieldSchema: { type: 'string' },
|
|
239
245
|
value: args.value[key],
|
|
240
246
|
})
|
|
241
247
|
.collect()
|
|
@@ -269,6 +275,7 @@ export const text: FieldParser<'text'> = async (args) => {
|
|
|
269
275
|
.create({
|
|
270
276
|
value,
|
|
271
277
|
key: args.target.$language,
|
|
278
|
+
fieldSchema: { type: 'string' },
|
|
272
279
|
})
|
|
273
280
|
.collect()
|
|
274
281
|
|
|
@@ -278,77 +285,3 @@ export const text: FieldParser<'text'> = async (args) => {
|
|
|
278
285
|
})
|
|
279
286
|
}
|
|
280
287
|
}
|
|
281
|
-
|
|
282
|
-
/*
|
|
283
|
-
const value = args.value
|
|
284
|
-
if (value !== null && typeof value === 'object') {
|
|
285
|
-
args.stop()
|
|
286
|
-
const result: any = {}
|
|
287
|
-
for (const key in value) {
|
|
288
|
-
if (key === '$value') {
|
|
289
|
-
const nValue = await next(args, key)
|
|
290
|
-
if (typeof nValue === 'object') {
|
|
291
|
-
deepMerge(result, nValue)
|
|
292
|
-
} else {
|
|
293
|
-
args.error(ParseError.incorrectFormat)
|
|
294
|
-
return
|
|
295
|
-
}
|
|
296
|
-
} else if (key === '$default') {
|
|
297
|
-
result.$default = await next(args, key)
|
|
298
|
-
} else if (args.schema.languages.includes(<BasedSchemaLanguage>key)) {
|
|
299
|
-
if (value[key] && typeof value[key] === 'object') {
|
|
300
|
-
for (const k in value[key]) {
|
|
301
|
-
if (k === '$value') {
|
|
302
|
-
if (!validateString(args, value[key].$value)) {
|
|
303
|
-
args.create({ key }).error(ParseError.incorrectFormat)
|
|
304
|
-
} else {
|
|
305
|
-
result[key] = value[key].$value
|
|
306
|
-
}
|
|
307
|
-
} else if (k === '$default') {
|
|
308
|
-
if (!validateString(args, value[key].$default)) {
|
|
309
|
-
args.create({ key }).error(ParseError.incorrectFormat)
|
|
310
|
-
} else {
|
|
311
|
-
setByPath(result, ['$default', key], value[key].$default)
|
|
312
|
-
}
|
|
313
|
-
} else {
|
|
314
|
-
args
|
|
315
|
-
.create({ path: [...args.path, key, k] })
|
|
316
|
-
.error(ParseError.fieldDoesNotExist)
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
} else {
|
|
320
|
-
if (!validateString(args, args.value[key])) {
|
|
321
|
-
args.error(ParseError.incorrectFormat)
|
|
322
|
-
return
|
|
323
|
-
}
|
|
324
|
-
result[key] = args.value[key]
|
|
325
|
-
}
|
|
326
|
-
} else {
|
|
327
|
-
args.create({ key }).error(ParseError.languageNotSupported)
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
args.collect(result)
|
|
331
|
-
return
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
if (typeof value !== 'string') {
|
|
335
|
-
args.error(ParseError.incorrectFormat)
|
|
336
|
-
return
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
if (!args.target.$language) {
|
|
340
|
-
args.error(ParseError.noLanguageFound)
|
|
341
|
-
return
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
if (!validateString(args, args.value)) {
|
|
345
|
-
args.error(ParseError.incorrectFormat)
|
|
346
|
-
return
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
args.value = {
|
|
350
|
-
[args.target.$language]: value,
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
args.collect()
|
|
354
|
-
*/
|