nesoi 3.0.18 → 3.0.20
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/compiler/elements/bucket.element.d.ts +1 -1
- package/lib/compiler/elements/bucket.element.js +25 -27
- package/lib/compiler/elements/message.element.js +50 -20
- 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 +11 -9
- package/lib/elements/entities/bucket/model/bucket_model_field.builder.d.ts +1 -1
- package/lib/elements/entities/bucket/model/bucket_model_field.builder.js +11 -8
- package/lib/elements/entities/bucket/view/bucket_view.js +2 -2
- package/lib/elements/entities/message/message_parser.d.ts +0 -4
- package/lib/elements/entities/message/message_parser.js +41 -75
- package/lib/elements/entities/message/template/message_template.schema.d.ts +25 -2
- package/lib/elements/entities/message/template/message_template.schema.js +16 -2
- package/lib/elements/entities/message/template/message_template_field.builder.d.ts +2 -2
- package/lib/elements/entities/message/template/message_template_field.builder.js +12 -10
- package/lib/elements/entities/message/template/message_template_parser.d.ts +6 -2
- package/lib/elements/entities/message/template/message_template_parser.js +121 -76
- package/lib/engine/data/error.d.ts +11 -0
- package/lib/engine/data/error.js +4 -0
- package/lib/engine/util/deep.d.ts +2 -0
- package/lib/engine/util/deep.js +30 -0
- package/lib/engine/util/parse.d.ts +39 -28
- package/lib/engine/util/parse.js +159 -188
- package/package.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -236,8 +236,8 @@ Nullable extends [null | never, null | never] = [never, never]> {
|
|
|
236
236
|
rule(rule: MessageTemplateRuleDef<DefinedOutput[keyof DefinedOutput], Message['#raw']>): this;
|
|
237
237
|
get array(): MessageTemplateFieldBuilder<Module, Message, { [K in keyof DefinedInput]: DefinedInput[K][]; }, { [K in keyof DefinedOutput]: DefinedOutput[K][]; }, Children, Optional, Nullable>;
|
|
238
238
|
or<Def extends AnyMessageTemplateFieldBuilder>(def: Def): MessageTemplateFieldBuilder<Module, Message, { [K in keyof DefinedInput]: DefinedInput[K] | (Def extends MessageTemplateFieldBuilder<any, any, infer X, any, any, [never, never], [never, never]> ? X : never)[keyof (Def extends MessageTemplateFieldBuilder<any, any, infer X, any, any, [never, never], [never, never]> ? X : never)]; }, { [K in keyof DefinedOutput]: DefinedOutput[K] | (Def extends MessageTemplateFieldBuilder<any, any, any, infer X, any, [never, never], [never, never]> ? X : never)[keyof (Def extends MessageTemplateFieldBuilder<any, any, any, infer X, any, [never, never], [never, never]> ? X : never)]; }, Children, Optional, Nullable>;
|
|
239
|
-
static build(builder: AnyMessageTemplateFieldBuilder, name: string, tree: ModuleTree, module: $Module,
|
|
240
|
-
static buildChildren(fields: MessageTemplateFieldBuilders, tree: ModuleTree, module: $Module,
|
|
239
|
+
static build(builder: AnyMessageTemplateFieldBuilder, name: string, tree: ModuleTree, module: $Module, basePathRaw: string, basePathParsed: string): $MessageTemplateField;
|
|
240
|
+
static buildChildren(fields: MessageTemplateFieldBuilders, tree: ModuleTree, module: $Module, basePathRaw?: string, basePathParsed?: string): $MessageTemplateFields;
|
|
241
241
|
}
|
|
242
242
|
export type MessageTemplateFieldBuilders = {
|
|
243
243
|
[x: string]: AnyMessageTemplateFieldBuilder;
|
|
@@ -157,21 +157,23 @@ class MessageTemplateFieldBuilder {
|
|
|
157
157
|
return this;
|
|
158
158
|
}
|
|
159
159
|
// Build
|
|
160
|
-
static build(builder, name, tree, module,
|
|
160
|
+
static build(builder, name, tree, module, basePathRaw, basePathParsed) {
|
|
161
161
|
const or = builder._or
|
|
162
|
-
? this.build(builder._or, name, tree, module,
|
|
163
|
-
: undefined;
|
|
164
|
-
const path = basePath + name + (builder.type === 'id' ? '_id' : '') + '.';
|
|
165
|
-
const childrenBasePath = builder.children
|
|
166
|
-
? path + (builder._array ? '*.' : '')
|
|
162
|
+
? this.build(builder._or, name, tree, module, basePathRaw, basePathParsed)
|
|
167
163
|
: undefined;
|
|
164
|
+
const pathParsed = basePathParsed + name;
|
|
165
|
+
const pathRaw = basePathParsed + (builder.type === 'id'
|
|
166
|
+
? builder._array ? `${name}_ids` : `${name}_id`
|
|
167
|
+
: name);
|
|
168
|
+
const childrenBasePathRaw = pathRaw + (builder._array ? '.#.' : '.');
|
|
169
|
+
const childrenBasePathParsed = pathParsed + (builder._array ? '.#.' : '.');
|
|
168
170
|
if (builder.value.id) {
|
|
169
171
|
const bucket = tree.getSchema(builder.value.id.bucket);
|
|
170
172
|
builder.value.id.type = bucket.model.fields.id.type;
|
|
171
173
|
}
|
|
172
|
-
return new message_template_schema_1.$MessageTemplateField(builder.type, name, builder.alias || name,
|
|
174
|
+
return new message_template_schema_1.$MessageTemplateField(builder.type, name, builder.alias || name, pathRaw, pathParsed, builder._array, builder._required, builder._defaultValue, builder._nullable, builder._rules, builder.value, builder.children ? MessageTemplateFieldBuilder.buildChildren(builder.children, tree, module, childrenBasePathRaw, childrenBasePathParsed) : undefined, or);
|
|
173
175
|
}
|
|
174
|
-
static buildChildren(fields, tree, module,
|
|
176
|
+
static buildChildren(fields, tree, module, basePathRaw = '', basePathParsed = '') {
|
|
175
177
|
const schema = {};
|
|
176
178
|
for (const c in fields) {
|
|
177
179
|
const child = fields[c];
|
|
@@ -197,13 +199,13 @@ class MessageTemplateFieldBuilder {
|
|
|
197
199
|
builder._nullable = child._nullable;
|
|
198
200
|
builder._rules = child._rules.slice(0, -1);
|
|
199
201
|
builder.children = child.children;
|
|
200
|
-
schema[param] = MessageTemplateFieldBuilder.build(builder, c, tree, module,
|
|
202
|
+
schema[param] = MessageTemplateFieldBuilder.build(builder, c, tree, module, basePathRaw, basePathParsed);
|
|
201
203
|
schema[param].children = schema[param].children || {};
|
|
202
204
|
Object.assign(schema[param].children, $msg.template.fields);
|
|
203
205
|
continue;
|
|
204
206
|
}
|
|
205
207
|
// All other parameters are built directly
|
|
206
|
-
schema[param] = MessageTemplateFieldBuilder.build(child, c, tree, module,
|
|
208
|
+
schema[param] = MessageTemplateFieldBuilder.build(child, c, tree, module, basePathRaw, basePathParsed);
|
|
207
209
|
}
|
|
208
210
|
return schema;
|
|
209
211
|
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import { $MessageTemplateField
|
|
1
|
+
import { $MessageTemplateField } from './message_template.schema';
|
|
2
2
|
import { AnyTrxNode } from "../../../../engine/transaction/trx_node";
|
|
3
|
-
export declare function MessageTemplateFieldParser(raw: Record<string, any>, trx: AnyTrxNode, field: $MessageTemplateField, value: any
|
|
3
|
+
export declare function MessageTemplateFieldParser(raw: Record<string, any>, trx: AnyTrxNode, field: $MessageTemplateField, value: any): Promise<any>;
|
|
4
|
+
/**
|
|
5
|
+
* Empty values: `{}`, `[]`, `''`, `null`, `undefined`
|
|
6
|
+
*/
|
|
7
|
+
export declare function isEmpty(value: any): boolean;
|
|
@@ -1,96 +1,141 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MessageTemplateFieldParser = MessageTemplateFieldParser;
|
|
4
|
+
exports.isEmpty = isEmpty;
|
|
4
5
|
const parse_1 = require("../../../../engine/util/parse");
|
|
5
6
|
const error_1 = require("../../../../engine/data/error");
|
|
6
|
-
async function MessageTemplateFieldParser(raw, trx, field, value
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
async function MessageTemplateFieldParser(raw, trx, field, value) {
|
|
8
|
+
return parseFieldValue(trx, field, raw, value, 0);
|
|
9
|
+
}
|
|
10
|
+
// Attempt to parse a field value
|
|
11
|
+
// - If field is an array, this method is run for each value, sequentially
|
|
12
|
+
// - If not, it's run for the original value, once
|
|
13
|
+
//
|
|
14
|
+
// - This method stacks with the .or options
|
|
15
|
+
//
|
|
16
|
+
async function parseFieldValue(trx, field, raw, value, path_idx) {
|
|
17
|
+
if (isEmpty(value)) {
|
|
18
|
+
if (field.required) {
|
|
19
|
+
throw error_1.NesoiError.Message.FieldIsRequired({ field: field.alias, path: field.path_raw, value });
|
|
20
|
+
}
|
|
21
|
+
else if (field.defaultValue !== undefined) {
|
|
22
|
+
return field.defaultValue;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
16
27
|
}
|
|
17
|
-
if (field.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
28
|
+
if (field.array) {
|
|
29
|
+
if (!Array.isArray(value)) {
|
|
30
|
+
throw error_1.NesoiError.Message.InvalidFieldType({ field: field.alias, path: field.path_raw, value, type: 'list' });
|
|
31
|
+
}
|
|
32
|
+
if (field.required && !value.length) {
|
|
33
|
+
throw error_1.NesoiError.Message.FieldIsRequired({ field: field.alias, path: field.path_raw, value });
|
|
34
|
+
}
|
|
35
|
+
const parsedValue = [];
|
|
36
|
+
for (let i = 0; i < value.length; i++) {
|
|
37
|
+
const v = value[i];
|
|
38
|
+
const parsed = await _attemptUnion(trx, field, raw, v, path_idx + 1);
|
|
39
|
+
parsedValue.push(parsed);
|
|
40
|
+
}
|
|
41
|
+
return parsedValue;
|
|
21
42
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
43
|
+
return _attemptUnion(trx, field, raw, value, path_idx);
|
|
44
|
+
}
|
|
45
|
+
async function _attemptUnion(trx, field, raw, value, path_idx, unionErrors = []) {
|
|
46
|
+
try {
|
|
47
|
+
return await _runParseMethod(trx, field, raw, value, path_idx);
|
|
26
48
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
49
|
+
catch (e) {
|
|
50
|
+
// If failed and there's a second option, atempt it
|
|
51
|
+
if (field.or) {
|
|
52
|
+
return await _attemptUnion(trx, field.or, raw, value, path_idx, [...unionErrors, e]);
|
|
53
|
+
}
|
|
54
|
+
// If this error was not the first attempt, and we have no other option
|
|
55
|
+
// we throw a specific error
|
|
56
|
+
// This avoid confusion for the client when parsing unions
|
|
57
|
+
if (unionErrors.length) {
|
|
58
|
+
throw error_1.NesoiError.Message.ValueDoesntMatchUnion({ field: field.alias, path: field.path_raw, value, unionErrors: [...unionErrors, e] });
|
|
59
|
+
}
|
|
60
|
+
throw e;
|
|
31
61
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
62
|
+
}
|
|
63
|
+
async function _runParseMethod(trx, field, raw, value, path_idx) {
|
|
64
|
+
switch (field.type) {
|
|
65
|
+
case 'obj':
|
|
66
|
+
case 'dict':
|
|
67
|
+
return await parseParentField(trx, field, raw, value, path_idx);
|
|
68
|
+
case 'unknown':
|
|
69
|
+
return value;
|
|
70
|
+
case 'boolean':
|
|
71
|
+
return (0, parse_1.parseBoolean)(field, value);
|
|
72
|
+
case 'date':
|
|
73
|
+
return (0, parse_1.parseDate)(field, value);
|
|
74
|
+
case 'datetime':
|
|
75
|
+
return (0, parse_1.parseDatetime)(field, value);
|
|
76
|
+
case 'duration':
|
|
77
|
+
return (0, parse_1.parseDuration)(field, value);
|
|
78
|
+
case 'decimal':
|
|
79
|
+
return (0, parse_1.parseDecimal)(field, value);
|
|
80
|
+
case 'enum':
|
|
81
|
+
return (0, parse_1.parseEnum)(raw, field, value, field.meta.enum.options, trx);
|
|
82
|
+
case 'file':
|
|
83
|
+
return (0, parse_1.parseFile)(field, value, field.meta.file);
|
|
84
|
+
case 'float':
|
|
85
|
+
return (0, parse_1.parseFloat_)(field, value);
|
|
86
|
+
case 'int':
|
|
87
|
+
return (0, parse_1.parseInt_)(field, value);
|
|
88
|
+
case 'string':
|
|
89
|
+
return (0, parse_1.parseString)(field, value);
|
|
90
|
+
case 'string_or_number':
|
|
91
|
+
return (0, parse_1.parseStringOrNumber)(field, value);
|
|
92
|
+
case 'id':
|
|
93
|
+
return await parseIdField(trx, field, value);
|
|
36
94
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
95
|
+
throw error_1.NesoiError.Builder.Message.UnknownTemplateFieldType(field.type);
|
|
96
|
+
}
|
|
97
|
+
async function parseParentField(trx, field, raw, value, path_idx) {
|
|
98
|
+
let children;
|
|
99
|
+
if (field.type === 'obj') {
|
|
100
|
+
children = (0, parse_1.parseObj)(field, value, path_idx);
|
|
42
101
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
'': await (0, parse_1.parseFile)(field, value, field.array, config)
|
|
47
|
-
};
|
|
102
|
+
else {
|
|
103
|
+
children = (0, parse_1.parseDict)(field, value);
|
|
48
104
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
105
|
+
const parsed = {};
|
|
106
|
+
for (const key in children) {
|
|
107
|
+
const child = children[key];
|
|
108
|
+
parsed[key] = await parseFieldValue(trx, child.field, raw, child.value, path_idx + 1);
|
|
53
109
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
return {
|
|
66
|
-
'': parsed.obj
|
|
67
|
-
};
|
|
68
|
-
}
|
|
110
|
+
return parsed;
|
|
111
|
+
}
|
|
112
|
+
async function parseIdField(trx, field, value) {
|
|
113
|
+
const bucket = field.meta.id.bucket;
|
|
114
|
+
const type = field.meta.id.type;
|
|
115
|
+
const view = field.meta.id.view;
|
|
116
|
+
const parsed = await (0, parse_1.parseId)(field, value, trx, bucket.refName, type, view);
|
|
117
|
+
if (field.array) {
|
|
118
|
+
return parsed.map((p) => p.obj);
|
|
69
119
|
}
|
|
70
|
-
|
|
71
|
-
return
|
|
72
|
-
'': await (0, parse_1.parseInt_)(field, value, field.array)
|
|
73
|
-
};
|
|
120
|
+
else {
|
|
121
|
+
return parsed.obj;
|
|
74
122
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Empty values: `{}`, `[]`, `''`, `null`, `undefined`
|
|
126
|
+
*/
|
|
127
|
+
function isEmpty(value) {
|
|
128
|
+
if (value === null || value === undefined) {
|
|
129
|
+
return true;
|
|
79
130
|
}
|
|
80
|
-
if (
|
|
81
|
-
return
|
|
82
|
-
'': await (0, parse_1.parseStringOrNumber)(field, value, field.array)
|
|
83
|
-
};
|
|
131
|
+
if (Array.isArray(value)) {
|
|
132
|
+
return value.length === 0;
|
|
84
133
|
}
|
|
85
|
-
if (
|
|
86
|
-
return
|
|
87
|
-
'': await (0, parse_1.parseObj)(field, value, field.array, trx, parseFields)
|
|
88
|
-
};
|
|
134
|
+
if (typeof value === 'object') {
|
|
135
|
+
return Object.keys(value).length === 0;
|
|
89
136
|
}
|
|
90
|
-
if (
|
|
91
|
-
return
|
|
92
|
-
'': await (0, parse_1.parseDict)(field, value, field.array, trx, parseFields)
|
|
93
|
-
};
|
|
137
|
+
if (typeof value === 'string') {
|
|
138
|
+
return value.length === 0;
|
|
94
139
|
}
|
|
95
|
-
|
|
140
|
+
return false;
|
|
96
141
|
}
|
|
@@ -169,6 +169,7 @@ export declare namespace NesoiError {
|
|
|
169
169
|
module: string;
|
|
170
170
|
}): BaseError;
|
|
171
171
|
function InvalidEnumScope($: {
|
|
172
|
+
path: string;
|
|
172
173
|
name: string;
|
|
173
174
|
alias?: string;
|
|
174
175
|
value: any;
|
|
@@ -176,15 +177,23 @@ export declare namespace NesoiError {
|
|
|
176
177
|
}): BaseError;
|
|
177
178
|
function InvalidFieldEnumValue($: {
|
|
178
179
|
field: string;
|
|
180
|
+
path: string;
|
|
179
181
|
value: any;
|
|
180
182
|
type: string;
|
|
181
183
|
options: string[];
|
|
182
184
|
}): BaseError;
|
|
183
185
|
function InvalidFieldType($: {
|
|
184
186
|
field: string;
|
|
187
|
+
path: string;
|
|
185
188
|
value: any;
|
|
186
189
|
type: string;
|
|
187
190
|
}): BaseError;
|
|
191
|
+
function ValueDoesntMatchUnion($: {
|
|
192
|
+
field: string;
|
|
193
|
+
path: string;
|
|
194
|
+
value: any;
|
|
195
|
+
unionErrors: string[];
|
|
196
|
+
}): BaseError;
|
|
188
197
|
function UnsanitaryValue($: {
|
|
189
198
|
details: string;
|
|
190
199
|
}): BaseError;
|
|
@@ -198,11 +207,13 @@ export declare namespace NesoiError {
|
|
|
198
207
|
error: string;
|
|
199
208
|
}): BaseError;
|
|
200
209
|
function FileTooBig($: {
|
|
210
|
+
path: string;
|
|
201
211
|
name: string;
|
|
202
212
|
alias?: string;
|
|
203
213
|
maxsize: number;
|
|
204
214
|
}): BaseError;
|
|
205
215
|
function FileExtNotAllowed($: {
|
|
216
|
+
path: string;
|
|
206
217
|
name: string;
|
|
207
218
|
alias?: string;
|
|
208
219
|
options: string[];
|
package/lib/engine/data/error.js
CHANGED
|
@@ -313,6 +313,10 @@ var NesoiError;
|
|
|
313
313
|
return new BaseError('Message.InvalidFieldType', `Message field '${$.field}' value '${$.value}' is not of type '${$.type}'`, Status.BAD_REQUEST, $);
|
|
314
314
|
}
|
|
315
315
|
Message.InvalidFieldType = InvalidFieldType;
|
|
316
|
+
function ValueDoesntMatchUnion($) {
|
|
317
|
+
return new BaseError('Message.ValueDoesntMatchUnion', `Message field '${$.field}' (${$.path}) value '${$.value}' doesn't match any of the union options'`, Status.BAD_REQUEST, $);
|
|
318
|
+
}
|
|
319
|
+
Message.ValueDoesntMatchUnion = ValueDoesntMatchUnion;
|
|
316
320
|
function UnsanitaryValue($) {
|
|
317
321
|
return new BaseError('Message.UnsanitaryValue', $.details, Status.BAD_REQUEST, $);
|
|
318
322
|
}
|
|
@@ -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;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NesoiDate } from '../data/date';
|
|
2
|
-
import { $MessageTemplateFields } from '../../elements/entities/message/template/message_template.schema';
|
|
2
|
+
import { $MessageTemplateField, $MessageTemplateFields } from '../../elements/entities/message/template/message_template.schema';
|
|
3
3
|
import { $Module, BucketName, ViewName } from "../../schema";
|
|
4
4
|
import { AnyTrxNode } from '../transaction/trx_node';
|
|
5
5
|
import { NesoiDecimal } from '../data/decimal';
|
|
@@ -7,63 +7,74 @@ 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
|
-
|
|
10
|
+
path_raw: string;
|
|
11
11
|
alias: string;
|
|
12
|
-
}, value: any
|
|
12
|
+
}, value: any): boolean;
|
|
13
13
|
export declare function parseDate(field: {
|
|
14
|
-
|
|
14
|
+
path_raw: string;
|
|
15
15
|
alias: string;
|
|
16
|
-
}, value: any
|
|
16
|
+
}, value: any): NesoiDate;
|
|
17
17
|
export declare function parseDatetime(field: {
|
|
18
|
-
|
|
18
|
+
path_raw: string;
|
|
19
19
|
alias: string;
|
|
20
|
-
}, value: any
|
|
20
|
+
}, value: any): NesoiDatetime;
|
|
21
21
|
export declare function parseDuration(field: {
|
|
22
|
-
|
|
22
|
+
path_raw: string;
|
|
23
23
|
alias: string;
|
|
24
|
-
}, value: any
|
|
24
|
+
}, value: any): NesoiDuration;
|
|
25
25
|
export declare function parseDecimal(field: {
|
|
26
|
-
|
|
26
|
+
path_raw: string;
|
|
27
27
|
alias: string;
|
|
28
|
-
}, value: any
|
|
28
|
+
}, value: any): NesoiDecimal;
|
|
29
29
|
export declare function parseEnum(raw: Record<string, any>, field: {
|
|
30
|
+
path_raw: string;
|
|
30
31
|
name: string;
|
|
31
32
|
alias: string;
|
|
32
|
-
}, value: any,
|
|
33
|
+
}, value: any, options: string | readonly string[] | Record<string, any>, trx: AnyTrxNode): any;
|
|
33
34
|
export declare function parseFile(field: {
|
|
35
|
+
path_raw: string;
|
|
34
36
|
name: string;
|
|
35
37
|
alias: string;
|
|
36
|
-
}, value: any,
|
|
38
|
+
}, value: any, options?: {
|
|
37
39
|
maxsize?: number;
|
|
38
40
|
extnames?: string[];
|
|
39
|
-
}):
|
|
41
|
+
}): NesoiFile;
|
|
40
42
|
export declare function parseFloat_(field: {
|
|
41
|
-
|
|
43
|
+
path_raw: string;
|
|
42
44
|
alias: string;
|
|
43
|
-
}, value: any
|
|
45
|
+
}, value: any): number;
|
|
44
46
|
export declare function parseId<M extends $Module, Name extends BucketName<M>, View extends ViewName<M['buckets'][Name]> | undefined>(field: {
|
|
45
|
-
|
|
47
|
+
path_raw: string;
|
|
46
48
|
alias: string;
|
|
47
|
-
}, value: any,
|
|
49
|
+
}, value: any, trx: AnyTrxNode, bucket: Name, type?: 'int' | 'string', view?: View): Promise<{
|
|
50
|
+
id: string | number;
|
|
51
|
+
obj: any;
|
|
52
|
+
}>;
|
|
48
53
|
export declare function parseInt_(field: {
|
|
49
|
-
|
|
54
|
+
path_raw: string;
|
|
50
55
|
alias: string;
|
|
51
|
-
}, value: any
|
|
56
|
+
}, value: any): number;
|
|
52
57
|
export declare function parseString(field: {
|
|
53
|
-
|
|
58
|
+
path_raw: string;
|
|
54
59
|
alias: string;
|
|
55
|
-
}, value: any
|
|
60
|
+
}, value: any): string;
|
|
56
61
|
export declare function parseStringOrNumber(field: {
|
|
57
|
-
|
|
62
|
+
path_raw: string;
|
|
58
63
|
alias: string;
|
|
59
|
-
}, value: any
|
|
64
|
+
}, value: any): string | number;
|
|
60
65
|
export declare function parseDict(field: {
|
|
61
|
-
|
|
66
|
+
path_raw: string;
|
|
62
67
|
alias: string;
|
|
63
68
|
children?: $MessageTemplateFields;
|
|
64
|
-
}, value: any
|
|
69
|
+
}, value: any): Record<string, {
|
|
70
|
+
field: $MessageTemplateField;
|
|
71
|
+
value?: any;
|
|
72
|
+
}>;
|
|
65
73
|
export declare function parseObj(field: {
|
|
66
|
-
|
|
74
|
+
path_raw: string;
|
|
67
75
|
alias: string;
|
|
68
76
|
children?: $MessageTemplateFields;
|
|
69
|
-
}, value: any,
|
|
77
|
+
}, value: any, path_idx: number): Record<string, {
|
|
78
|
+
field: $MessageTemplateField;
|
|
79
|
+
value?: any;
|
|
80
|
+
}>;
|