nesoi 3.0.19 → 3.0.21
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/lib/elements/blocks/block.builder.d.ts +10 -1
- package/lib/elements/blocks/block.builder.js +26 -0
- package/lib/elements/blocks/job/job.builder.d.ts +7 -1
- package/lib/elements/blocks/job/job.builder.js +4 -0
- package/lib/elements/entities/bucket/model/bucket_model.convert.js +1 -1
- package/lib/elements/entities/message/message.builder.js +2 -2
- package/lib/elements/entities/message/message_parser.d.ts +0 -1
- package/lib/elements/entities/message/message_parser.js +2 -46
- package/lib/elements/entities/message/template/message_template.schema.d.ts +33 -1
- package/lib/elements/entities/message/template/message_template.schema.js +20 -1
- package/lib/elements/entities/message/template/message_template_field.builder.d.ts +11 -0
- package/lib/elements/entities/message/template/message_template_field.builder.js +24 -8
- package/lib/elements/entities/message/template/message_template_parser.d.ts +2 -2
- package/lib/elements/entities/message/template/message_template_parser.js +110 -29
- package/lib/engine/data/error.d.ts +12 -11
- package/lib/engine/data/error.js +7 -7
- package/lib/engine/util/deep.d.ts +2 -0
- package/lib/engine/util/deep.js +30 -0
- package/lib/engine/util/parse.d.ts +28 -18
- package/lib/engine/util/parse.js +31 -34
- package/package.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -169,53 +169,54 @@ export declare namespace NesoiError {
|
|
|
169
169
|
module: string;
|
|
170
170
|
}): BaseError;
|
|
171
171
|
function InvalidEnumScope($: {
|
|
172
|
+
alias: string;
|
|
172
173
|
path: string;
|
|
173
|
-
name: string;
|
|
174
|
-
alias?: string;
|
|
175
174
|
value: any;
|
|
176
175
|
fieldpath: string;
|
|
177
176
|
}): BaseError;
|
|
178
177
|
function InvalidFieldEnumValue($: {
|
|
179
|
-
|
|
178
|
+
alias: string;
|
|
180
179
|
path: string;
|
|
181
180
|
value: any;
|
|
182
181
|
type: string;
|
|
183
182
|
options: string[];
|
|
184
183
|
}): BaseError;
|
|
185
184
|
function InvalidFieldType($: {
|
|
186
|
-
|
|
185
|
+
alias: string;
|
|
187
186
|
path: string;
|
|
188
187
|
value: any;
|
|
189
188
|
type: string;
|
|
190
189
|
}): BaseError;
|
|
191
190
|
function ValueDoesntMatchUnion($: {
|
|
192
|
-
|
|
191
|
+
alias: string;
|
|
193
192
|
path: string;
|
|
194
193
|
value: any;
|
|
195
|
-
unionErrors: string[];
|
|
194
|
+
unionErrors: Record<string, any>[];
|
|
196
195
|
}): BaseError;
|
|
197
196
|
function UnsanitaryValue($: {
|
|
197
|
+
alias: string;
|
|
198
|
+
path: string;
|
|
198
199
|
details: string;
|
|
199
200
|
}): BaseError;
|
|
200
201
|
function FieldIsRequired($: {
|
|
201
|
-
|
|
202
|
+
alias: string;
|
|
202
203
|
path: string;
|
|
203
204
|
value: any;
|
|
204
205
|
}): BaseError;
|
|
205
206
|
function RuleFailed($: {
|
|
207
|
+
alias: string;
|
|
208
|
+
path: string;
|
|
206
209
|
rule: $MessageTemplateRule;
|
|
207
210
|
error: string;
|
|
208
211
|
}): BaseError;
|
|
209
212
|
function FileTooBig($: {
|
|
213
|
+
alias: string;
|
|
210
214
|
path: string;
|
|
211
|
-
name: string;
|
|
212
|
-
alias?: string;
|
|
213
215
|
maxsize: number;
|
|
214
216
|
}): BaseError;
|
|
215
217
|
function FileExtNotAllowed($: {
|
|
218
|
+
alias: string;
|
|
216
219
|
path: string;
|
|
217
|
-
name: string;
|
|
218
|
-
alias?: string;
|
|
219
220
|
options: string[];
|
|
220
221
|
}): BaseError;
|
|
221
222
|
}
|
package/lib/engine/data/error.js
CHANGED
|
@@ -302,19 +302,19 @@ var NesoiError;
|
|
|
302
302
|
}
|
|
303
303
|
Message.NotSupportedByModule = NotSupportedByModule;
|
|
304
304
|
function InvalidEnumScope($) {
|
|
305
|
-
return new BaseError('Message.InvalidEnumScope', `${$.alias
|
|
305
|
+
return new BaseError('Message.InvalidEnumScope', `${$.alias} is an enum with dynamic scope, and the path '${$.fieldpath}' of the message has an invalid value '${$.value}'`, Status.BAD_REQUEST, $);
|
|
306
306
|
}
|
|
307
307
|
Message.InvalidEnumScope = InvalidEnumScope;
|
|
308
308
|
function InvalidFieldEnumValue($) {
|
|
309
|
-
return new BaseError('Message.InvalidFieldEnumValue', `Message field '${$.
|
|
309
|
+
return new BaseError('Message.InvalidFieldEnumValue', `Message field '${$.alias}' value '${$.value}' should be one of the following: ${$.options?.join(',')}`, Status.BAD_REQUEST, $);
|
|
310
310
|
}
|
|
311
311
|
Message.InvalidFieldEnumValue = InvalidFieldEnumValue;
|
|
312
312
|
function InvalidFieldType($) {
|
|
313
|
-
return new BaseError('Message.InvalidFieldType', `Message field '${$.
|
|
313
|
+
return new BaseError('Message.InvalidFieldType', `Message field '${$.alias}' value '${$.value}' is not of type '${$.type}'`, Status.BAD_REQUEST, $);
|
|
314
314
|
}
|
|
315
315
|
Message.InvalidFieldType = InvalidFieldType;
|
|
316
316
|
function ValueDoesntMatchUnion($) {
|
|
317
|
-
return new BaseError('Message.ValueDoesntMatchUnion', `Message field '${$.
|
|
317
|
+
return new BaseError('Message.ValueDoesntMatchUnion', `Message field '${$.alias}' (${$.path}) value '${$.value}' doesn't match any of the union options'`, Status.BAD_REQUEST, $);
|
|
318
318
|
}
|
|
319
319
|
Message.ValueDoesntMatchUnion = ValueDoesntMatchUnion;
|
|
320
320
|
function UnsanitaryValue($) {
|
|
@@ -322,7 +322,7 @@ var NesoiError;
|
|
|
322
322
|
}
|
|
323
323
|
Message.UnsanitaryValue = UnsanitaryValue;
|
|
324
324
|
function FieldIsRequired($) {
|
|
325
|
-
return new BaseError('Message.FieldIsRequired', `Field ${$.
|
|
325
|
+
return new BaseError('Message.FieldIsRequired', `Field ${$.alias} (${$.path}) is required`, Status.BAD_REQUEST, $);
|
|
326
326
|
}
|
|
327
327
|
Message.FieldIsRequired = FieldIsRequired;
|
|
328
328
|
function RuleFailed($) {
|
|
@@ -330,11 +330,11 @@ var NesoiError;
|
|
|
330
330
|
}
|
|
331
331
|
Message.RuleFailed = RuleFailed;
|
|
332
332
|
function FileTooBig($) {
|
|
333
|
-
return new BaseError('Message.FileTooBig', `${$.alias
|
|
333
|
+
return new BaseError('Message.FileTooBig', `${$.alias} size exceeds max (${$.maxsize})`, Status.BAD_REQUEST, $);
|
|
334
334
|
}
|
|
335
335
|
Message.FileTooBig = FileTooBig;
|
|
336
336
|
function FileExtNotAllowed($) {
|
|
337
|
-
return new BaseError('Message.FileExtNotAllowed', `${$.alias
|
|
337
|
+
return new BaseError('Message.FileExtNotAllowed', `${$.alias} extension not allowed. Options: ${$.options}`, Status.BAD_REQUEST, $);
|
|
338
338
|
}
|
|
339
339
|
Message.FileExtNotAllowed = FileExtNotAllowed;
|
|
340
340
|
})(Message = NesoiError.Message || (NesoiError.Message = {}));
|
|
@@ -8,5 +8,7 @@ export type DeepPartialNullable<T> = UndefinedToOptional<T extends object ? {
|
|
|
8
8
|
type Obj = Record<string, any>;
|
|
9
9
|
export declare class Deep {
|
|
10
10
|
static copy<T extends Obj>(obj: T): T;
|
|
11
|
+
static get(obj: Record<string, any>, path: string): any;
|
|
12
|
+
static set(obj: Record<string, any>, path: string, value: any): void;
|
|
11
13
|
}
|
|
12
14
|
export {};
|
package/lib/engine/util/deep.js
CHANGED
|
@@ -44,5 +44,35 @@ class Deep {
|
|
|
44
44
|
}
|
|
45
45
|
return copy;
|
|
46
46
|
}
|
|
47
|
+
static get(obj, path) {
|
|
48
|
+
if (!path) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
const props = path.split('.');
|
|
52
|
+
let val = obj;
|
|
53
|
+
for (const p in props) {
|
|
54
|
+
val = val[props[p]];
|
|
55
|
+
if (val === undefined) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return val;
|
|
60
|
+
}
|
|
61
|
+
static set(obj, path, value) {
|
|
62
|
+
const props = path.split('.');
|
|
63
|
+
let val = obj;
|
|
64
|
+
for (const p in props) {
|
|
65
|
+
const prop = props[p];
|
|
66
|
+
if (val[prop] === undefined) {
|
|
67
|
+
val[prop] = {};
|
|
68
|
+
}
|
|
69
|
+
if (parseInt(p) < props.length - 1) {
|
|
70
|
+
val = val[prop];
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
val[prop] = value;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
47
77
|
}
|
|
48
78
|
exports.Deep = Deep;
|
|
@@ -7,56 +7,66 @@ import { NesoiDatetime } from '../data/datetime';
|
|
|
7
7
|
import { NesoiFile } from '../data/file';
|
|
8
8
|
import { NesoiDuration } from '../data/duration';
|
|
9
9
|
export declare function parseBoolean(field: {
|
|
10
|
+
path_raw: string;
|
|
10
11
|
alias: string;
|
|
11
|
-
}, path: string, value: any): boolean;
|
|
12
|
+
}, path: string[], value: any): boolean;
|
|
12
13
|
export declare function parseDate(field: {
|
|
14
|
+
path_raw: string;
|
|
13
15
|
alias: string;
|
|
14
|
-
}, path: string, value: any): NesoiDate;
|
|
16
|
+
}, path: string[], value: any): NesoiDate;
|
|
15
17
|
export declare function parseDatetime(field: {
|
|
18
|
+
path_raw: string;
|
|
16
19
|
alias: string;
|
|
17
|
-
}, path: string, value: any): NesoiDatetime;
|
|
20
|
+
}, path: string[], value: any): NesoiDatetime;
|
|
18
21
|
export declare function parseDuration(field: {
|
|
22
|
+
path_raw: string;
|
|
19
23
|
alias: string;
|
|
20
|
-
}, path: string, value: any): NesoiDuration;
|
|
24
|
+
}, path: string[], value: any): NesoiDuration;
|
|
21
25
|
export declare function parseDecimal(field: {
|
|
26
|
+
path_raw: string;
|
|
22
27
|
alias: string;
|
|
23
|
-
}, path: string, value: any): NesoiDecimal;
|
|
28
|
+
}, path: string[], value: any): NesoiDecimal;
|
|
24
29
|
export declare function parseEnum(raw: Record<string, any>, field: {
|
|
30
|
+
path_raw: string;
|
|
25
31
|
name: string;
|
|
26
32
|
alias: string;
|
|
27
|
-
}, path: string, value: any, options: string | readonly string[] | Record<string, any>, trx: AnyTrxNode): any;
|
|
33
|
+
}, path: string[], value: any, options: string | readonly string[] | Record<string, any>, trx: AnyTrxNode): any;
|
|
28
34
|
export declare function parseFile(field: {
|
|
35
|
+
path_raw: string;
|
|
29
36
|
name: string;
|
|
30
37
|
alias: string;
|
|
31
|
-
}, path: string, value: any, options?: {
|
|
38
|
+
}, path: string[], value: any, options?: {
|
|
32
39
|
maxsize?: number;
|
|
33
40
|
extnames?: string[];
|
|
34
41
|
}): NesoiFile;
|
|
35
42
|
export declare function parseFloat_(field: {
|
|
43
|
+
path_raw: string;
|
|
36
44
|
alias: string;
|
|
37
|
-
}, path: string, value: any): number;
|
|
45
|
+
}, path: string[], value: any): number;
|
|
38
46
|
export declare function parseId<M extends $Module, Name extends BucketName<M>, View extends ViewName<M['buckets'][Name]> | undefined>(field: {
|
|
47
|
+
path_raw: string;
|
|
39
48
|
alias: string;
|
|
40
|
-
}, path: string, value: any, trx: AnyTrxNode, bucket: Name, type?: 'int' | 'string', view?: View): Promise<{
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
obj: any;
|
|
44
|
-
};
|
|
49
|
+
}, path: string[], value: any, trx: AnyTrxNode, bucket: Name, type?: 'int' | 'string', view?: View): Promise<{
|
|
50
|
+
id: string | number;
|
|
51
|
+
obj: any;
|
|
45
52
|
}>;
|
|
46
53
|
export declare function parseInt_(field: {
|
|
54
|
+
path_raw: string;
|
|
47
55
|
alias: string;
|
|
48
|
-
}, path: string, value: any): number;
|
|
56
|
+
}, path: string[], value: any): number;
|
|
49
57
|
export declare function parseString(field: {
|
|
58
|
+
path_raw: string;
|
|
50
59
|
alias: string;
|
|
51
|
-
}, path: string, value: any): string;
|
|
60
|
+
}, path: string[], value: any): string;
|
|
52
61
|
export declare function parseStringOrNumber(field: {
|
|
62
|
+
path_raw: string;
|
|
53
63
|
alias: string;
|
|
54
|
-
}, path: string, value: any): string | number;
|
|
64
|
+
}, path: string[], value: any): string | number;
|
|
55
65
|
export declare function parseDict(field: {
|
|
56
66
|
path_raw: string;
|
|
57
67
|
alias: string;
|
|
58
68
|
children?: $MessageTemplateFields;
|
|
59
|
-
}, path: string, value: any): Record<string, {
|
|
69
|
+
}, path: string[], value: any): Record<string, {
|
|
60
70
|
field: $MessageTemplateField;
|
|
61
71
|
value?: any;
|
|
62
72
|
}>;
|
|
@@ -64,7 +74,7 @@ export declare function parseObj(field: {
|
|
|
64
74
|
path_raw: string;
|
|
65
75
|
alias: string;
|
|
66
76
|
children?: $MessageTemplateFields;
|
|
67
|
-
}, path: string, value: any): Record<string, {
|
|
77
|
+
}, path: string[], value: any): Record<string, {
|
|
68
78
|
field: $MessageTemplateField;
|
|
69
79
|
value?: any;
|
|
70
80
|
}>;
|
package/lib/engine/util/parse.js
CHANGED
|
@@ -31,32 +31,32 @@ function parseBoolean(field, path, value) {
|
|
|
31
31
|
if (typeof value === 'boolean') {
|
|
32
32
|
return value;
|
|
33
33
|
}
|
|
34
|
-
throw error_1.NesoiError.Message.InvalidFieldType({
|
|
34
|
+
throw error_1.NesoiError.Message.InvalidFieldType({ alias: field.alias, path: path.join('.'), value, type: 'boolean' });
|
|
35
35
|
}
|
|
36
36
|
function parseDate(field, path, value) {
|
|
37
37
|
// TODO: limit to date
|
|
38
38
|
if (typeof value === 'string') {
|
|
39
39
|
return date_1.NesoiDate.fromISO(value);
|
|
40
40
|
}
|
|
41
|
-
throw error_1.NesoiError.Message.InvalidFieldType({
|
|
41
|
+
throw error_1.NesoiError.Message.InvalidFieldType({ alias: field.alias, path: path.join('.'), value, type: 'date' });
|
|
42
42
|
}
|
|
43
43
|
function parseDatetime(field, path, value) {
|
|
44
44
|
if (typeof value === 'string') {
|
|
45
45
|
return datetime_1.NesoiDatetime.fromISO(value);
|
|
46
46
|
}
|
|
47
|
-
throw error_1.NesoiError.Message.InvalidFieldType({
|
|
47
|
+
throw error_1.NesoiError.Message.InvalidFieldType({ alias: field.alias, path: path.join('.'), value, type: 'datetime' });
|
|
48
48
|
}
|
|
49
49
|
function parseDuration(field, path, value) {
|
|
50
50
|
if (typeof value === 'string') {
|
|
51
51
|
return duration_1.NesoiDuration.fromString(value);
|
|
52
52
|
}
|
|
53
|
-
throw error_1.NesoiError.Message.InvalidFieldType({
|
|
53
|
+
throw error_1.NesoiError.Message.InvalidFieldType({ alias: field.alias, path: path.join('.'), value, type: 'duration' });
|
|
54
54
|
}
|
|
55
55
|
function parseDecimal(field, path, value) {
|
|
56
56
|
if (typeof value === 'string') {
|
|
57
57
|
return new decimal_1.NesoiDecimal(value);
|
|
58
58
|
}
|
|
59
|
-
throw error_1.NesoiError.Message.InvalidFieldType({
|
|
59
|
+
throw error_1.NesoiError.Message.InvalidFieldType({ alias: field.alias, path: path.join('.'), value, type: 'decimal' });
|
|
60
60
|
}
|
|
61
61
|
function parseEnum(raw, field, path, value, options, trx) {
|
|
62
62
|
if (typeof value === 'string') {
|
|
@@ -71,7 +71,7 @@ function parseEnum(raw, field, path, value, options, trx) {
|
|
|
71
71
|
}
|
|
72
72
|
catch {
|
|
73
73
|
const v = tree_1.Tree.get(raw, enumPath[2]);
|
|
74
|
-
throw error_1.NesoiError.Message.InvalidEnumScope({
|
|
74
|
+
throw error_1.NesoiError.Message.InvalidEnumScope({ alias: field.alias, path: path.join('.'), value: v, fieldpath: enumPath[2] });
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
else {
|
|
@@ -82,7 +82,7 @@ function parseEnum(raw, field, path, value, options, trx) {
|
|
|
82
82
|
return value;
|
|
83
83
|
}
|
|
84
84
|
else {
|
|
85
|
-
throw error_1.NesoiError.Message.InvalidFieldEnumValue({
|
|
85
|
+
throw error_1.NesoiError.Message.InvalidFieldEnumValue({ alias: field.alias, path: path.join('.'), value, type: 'enum', options: keys });
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
else if (Array.isArray(options)) {
|
|
@@ -90,7 +90,7 @@ function parseEnum(raw, field, path, value, options, trx) {
|
|
|
90
90
|
return value;
|
|
91
91
|
}
|
|
92
92
|
else {
|
|
93
|
-
throw error_1.NesoiError.Message.InvalidFieldEnumValue({
|
|
93
|
+
throw error_1.NesoiError.Message.InvalidFieldEnumValue({ alias: field.alias, path: path.join('.'), value, type: 'enum', options });
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
else if (typeof options === 'object') {
|
|
@@ -98,29 +98,24 @@ function parseEnum(raw, field, path, value, options, trx) {
|
|
|
98
98
|
return options[value];
|
|
99
99
|
}
|
|
100
100
|
else {
|
|
101
|
-
throw error_1.NesoiError.Message.InvalidFieldEnumValue({
|
|
101
|
+
throw error_1.NesoiError.Message.InvalidFieldEnumValue({ alias: field.alias, path: path.join('.'), value, type: 'enum', options: Object.keys(options) });
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
throw error_1.NesoiError.Message.InvalidFieldType({
|
|
105
|
+
throw error_1.NesoiError.Message.InvalidFieldType({ alias: field.alias, path: path.join('.'), value, type: 'string' });
|
|
106
106
|
}
|
|
107
107
|
function parseFile(field, path, value, options) {
|
|
108
108
|
if (!(value instanceof file_1.NesoiFile)) {
|
|
109
|
-
throw error_1.NesoiError.Message.InvalidFieldType({
|
|
109
|
+
throw error_1.NesoiError.Message.InvalidFieldType({ alias: field.alias, path: path.join('.'), value, type: 'file' });
|
|
110
110
|
}
|
|
111
111
|
if (options?.maxsize) {
|
|
112
112
|
if (value.size > options?.maxsize) {
|
|
113
|
-
throw error_1.NesoiError.Message.FileTooBig({
|
|
114
|
-
path,
|
|
115
|
-
name: field.name,
|
|
116
|
-
alias: field.alias,
|
|
117
|
-
maxsize: options?.maxsize
|
|
118
|
-
});
|
|
113
|
+
throw error_1.NesoiError.Message.FileTooBig({ alias: field.alias, path: path.join('.'), maxsize: options?.maxsize });
|
|
119
114
|
}
|
|
120
115
|
}
|
|
121
116
|
if (options?.extnames) {
|
|
122
117
|
if (!options?.extnames.includes(value.extname)) {
|
|
123
|
-
throw error_1.NesoiError.Message.FileExtNotAllowed({
|
|
118
|
+
throw error_1.NesoiError.Message.FileExtNotAllowed({ alias: field.alias, path: path.join('.'), options: options?.extnames });
|
|
124
119
|
}
|
|
125
120
|
}
|
|
126
121
|
return value;
|
|
@@ -137,7 +132,7 @@ function parseFloat_(field, path, value) {
|
|
|
137
132
|
return value;
|
|
138
133
|
}
|
|
139
134
|
}
|
|
140
|
-
throw error_1.NesoiError.Message.InvalidFieldType({
|
|
135
|
+
throw error_1.NesoiError.Message.InvalidFieldType({ alias: field.alias, path: path.join('.'), value, type: 'float' });
|
|
141
136
|
}
|
|
142
137
|
async function parseId(field, path, value, trx, bucket, type, view) {
|
|
143
138
|
let val;
|
|
@@ -148,12 +143,10 @@ async function parseId(field, path, value, trx, bucket, type, view) {
|
|
|
148
143
|
val = parseInt_(field, path, value);
|
|
149
144
|
}
|
|
150
145
|
return {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
: await trx.bucket(bucket).readOneOrFail(val)
|
|
156
|
-
}
|
|
146
|
+
id: val,
|
|
147
|
+
obj: view
|
|
148
|
+
? await trx.bucket(bucket).viewOneOrFail(val, view)
|
|
149
|
+
: await trx.bucket(bucket).readOneOrFail(val)
|
|
157
150
|
};
|
|
158
151
|
}
|
|
159
152
|
function parseInt_(field, path, value) {
|
|
@@ -169,32 +162,33 @@ function parseInt_(field, path, value) {
|
|
|
169
162
|
return val;
|
|
170
163
|
}
|
|
171
164
|
}
|
|
172
|
-
throw error_1.NesoiError.Message.InvalidFieldType({
|
|
165
|
+
throw error_1.NesoiError.Message.InvalidFieldType({ alias: field.alias, path: path.join('.'), value, type: 'integer' });
|
|
173
166
|
}
|
|
174
167
|
function parseString(field, path, value) {
|
|
175
168
|
if (typeof value === 'string') {
|
|
176
169
|
return value;
|
|
177
170
|
}
|
|
178
|
-
throw error_1.NesoiError.Message.InvalidFieldType({
|
|
171
|
+
throw error_1.NesoiError.Message.InvalidFieldType({ alias: field.alias, path: path.join('.'), value, type: 'string' });
|
|
179
172
|
}
|
|
180
173
|
function parseStringOrNumber(field, path, value) {
|
|
181
174
|
if (typeof value === 'string' || typeof value === 'number') {
|
|
182
175
|
return value;
|
|
183
176
|
}
|
|
184
|
-
throw error_1.NesoiError.Message.InvalidFieldType({
|
|
177
|
+
throw error_1.NesoiError.Message.InvalidFieldType({ alias: field.alias, path: path.join('.'), value, type: 'string_or_number' });
|
|
185
178
|
}
|
|
186
179
|
function parseDict(field, path, value) {
|
|
187
180
|
if (typeof value === 'object') {
|
|
188
181
|
const children = {};
|
|
189
182
|
for (const key in value) {
|
|
183
|
+
const _field = field.children['__dict'];
|
|
190
184
|
children[key] = {
|
|
191
|
-
field:
|
|
185
|
+
field: _field,
|
|
192
186
|
value: value[key]
|
|
193
187
|
};
|
|
194
188
|
}
|
|
195
189
|
return children;
|
|
196
190
|
}
|
|
197
|
-
throw error_1.NesoiError.Message.InvalidFieldType({
|
|
191
|
+
throw error_1.NesoiError.Message.InvalidFieldType({ alias: field.alias, path: path.join('.'), value, type: 'dict' });
|
|
198
192
|
}
|
|
199
193
|
function parseObj(field, path, value) {
|
|
200
194
|
if (typeof value === 'object') {
|
|
@@ -202,12 +196,15 @@ function parseObj(field, path, value) {
|
|
|
202
196
|
return {};
|
|
203
197
|
const children = {};
|
|
204
198
|
for (const key in field.children) {
|
|
205
|
-
children[key]
|
|
206
|
-
|
|
207
|
-
|
|
199
|
+
const _field = field.children[key];
|
|
200
|
+
const key_raw = _field.path_raw.split('.')[path.length];
|
|
201
|
+
const key_parsed = _field.path_parsed.split('.')[path.length];
|
|
202
|
+
children[key_parsed] = {
|
|
203
|
+
field: _field,
|
|
204
|
+
value: value[key_raw]
|
|
208
205
|
};
|
|
209
206
|
}
|
|
210
207
|
return children;
|
|
211
208
|
}
|
|
212
|
-
throw error_1.NesoiError.Message.InvalidFieldType({
|
|
209
|
+
throw error_1.NesoiError.Message.InvalidFieldType({ alias: field.alias, path: path.join('.'), value, type: 'object' });
|
|
213
210
|
}
|