@nocobase/plugin-workflow-javascript 2.1.0-alpha.12 → 2.1.0-alpha.14

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.
Files changed (145) hide show
  1. package/dist/client/index.js +1 -1
  2. package/dist/externalVersion.js +4 -4
  3. package/dist/node_modules/isolated-vm/.clang-tidy +13 -0
  4. package/dist/node_modules/isolated-vm/.dockerignore +9 -0
  5. package/dist/node_modules/isolated-vm/Dockerfile.alpine +9 -0
  6. package/dist/node_modules/isolated-vm/Dockerfile.debian +12 -0
  7. package/dist/node_modules/isolated-vm/LICENSE +13 -0
  8. package/dist/node_modules/isolated-vm/binding.gyp +120 -0
  9. package/dist/node_modules/isolated-vm/include.js +3 -0
  10. package/dist/node_modules/isolated-vm/inspector-example.js +59 -0
  11. package/dist/node_modules/isolated-vm/isolated-vm.d.ts +820 -0
  12. package/dist/node_modules/isolated-vm/isolated-vm.js +1 -0
  13. package/dist/node_modules/isolated-vm/native-example/binding.gyp +23 -0
  14. package/dist/node_modules/isolated-vm/native-example/example.cc +61 -0
  15. package/dist/node_modules/isolated-vm/native-example/package.json +13 -0
  16. package/dist/node_modules/isolated-vm/native-example/usage.js +35 -0
  17. package/dist/node_modules/isolated-vm/out/isolated_vm.node +0 -0
  18. package/dist/node_modules/isolated-vm/package.json +1 -0
  19. package/dist/node_modules/isolated-vm/src/external_copy/error.h +33 -0
  20. package/dist/node_modules/isolated-vm/src/external_copy/external_copy.cc +509 -0
  21. package/dist/node_modules/isolated-vm/src/external_copy/external_copy.h +117 -0
  22. package/dist/node_modules/isolated-vm/src/external_copy/serializer.cc +85 -0
  23. package/dist/node_modules/isolated-vm/src/external_copy/serializer.h +136 -0
  24. package/dist/node_modules/isolated-vm/src/external_copy/serializer_nortti.cc +73 -0
  25. package/dist/node_modules/isolated-vm/src/external_copy/string.cc +124 -0
  26. package/dist/node_modules/isolated-vm/src/external_copy/string.h +28 -0
  27. package/dist/node_modules/isolated-vm/src/isolate/allocator.h +32 -0
  28. package/dist/node_modules/isolated-vm/src/isolate/allocator_nortti.cc +142 -0
  29. package/dist/node_modules/isolated-vm/src/isolate/class_handle.h +334 -0
  30. package/dist/node_modules/isolated-vm/src/isolate/cpu_profile_manager.cc +220 -0
  31. package/dist/node_modules/isolated-vm/src/isolate/cpu_profile_manager.h +100 -0
  32. package/dist/node_modules/isolated-vm/src/isolate/environment.cc +626 -0
  33. package/dist/node_modules/isolated-vm/src/isolate/environment.h +381 -0
  34. package/dist/node_modules/isolated-vm/src/isolate/executor.cc +198 -0
  35. package/dist/node_modules/isolated-vm/src/isolate/executor.h +183 -0
  36. package/dist/node_modules/isolated-vm/src/isolate/external.h +64 -0
  37. package/dist/node_modules/isolated-vm/src/isolate/functor_runners.h +97 -0
  38. package/dist/node_modules/isolated-vm/src/isolate/generic/array.h +145 -0
  39. package/dist/node_modules/isolated-vm/src/isolate/generic/callbacks.h +272 -0
  40. package/dist/node_modules/isolated-vm/src/isolate/generic/error.h +140 -0
  41. package/dist/node_modules/isolated-vm/src/isolate/generic/extract_params.h +145 -0
  42. package/dist/node_modules/isolated-vm/src/isolate/generic/handle_cast.h +257 -0
  43. package/dist/node_modules/isolated-vm/src/isolate/generic/read_option.h +47 -0
  44. package/dist/node_modules/isolated-vm/src/isolate/holder.cc +88 -0
  45. package/dist/node_modules/isolated-vm/src/isolate/holder.h +63 -0
  46. package/dist/node_modules/isolated-vm/src/isolate/inspector.cc +200 -0
  47. package/dist/node_modules/isolated-vm/src/isolate/inspector.h +70 -0
  48. package/dist/node_modules/isolated-vm/src/isolate/node_wrapper.h +15 -0
  49. package/dist/node_modules/isolated-vm/src/isolate/platform_delegate.cc +22 -0
  50. package/dist/node_modules/isolated-vm/src/isolate/platform_delegate.h +46 -0
  51. package/dist/node_modules/isolated-vm/src/isolate/remote_handle.h +164 -0
  52. package/dist/node_modules/isolated-vm/src/isolate/run_with_timeout.h +171 -0
  53. package/dist/node_modules/isolated-vm/src/isolate/runnable.h +29 -0
  54. package/dist/node_modules/isolated-vm/src/isolate/scheduler.cc +191 -0
  55. package/dist/node_modules/isolated-vm/src/isolate/scheduler.h +165 -0
  56. package/dist/node_modules/isolated-vm/src/isolate/specific.h +35 -0
  57. package/dist/node_modules/isolated-vm/src/isolate/stack_trace.cc +219 -0
  58. package/dist/node_modules/isolated-vm/src/isolate/stack_trace.h +24 -0
  59. package/dist/node_modules/isolated-vm/src/isolate/strings.h +127 -0
  60. package/dist/node_modules/isolated-vm/src/isolate/three_phase_task.cc +385 -0
  61. package/dist/node_modules/isolated-vm/src/isolate/three_phase_task.h +136 -0
  62. package/dist/node_modules/isolated-vm/src/isolate/transferable.h +15 -0
  63. package/dist/node_modules/isolated-vm/src/isolate/util.h +45 -0
  64. package/dist/node_modules/isolated-vm/src/isolate/v8_inspector_wrapper.h +12 -0
  65. package/dist/node_modules/isolated-vm/src/isolate/v8_version.h +12 -0
  66. package/dist/node_modules/isolated-vm/src/isolated_vm.h +71 -0
  67. package/dist/node_modules/isolated-vm/src/lib/covariant.h +50 -0
  68. package/dist/node_modules/isolated-vm/src/lib/lockable.h +178 -0
  69. package/dist/node_modules/isolated-vm/src/lib/suspend.h +106 -0
  70. package/dist/node_modules/isolated-vm/src/lib/thread_pool.cc +98 -0
  71. package/dist/node_modules/isolated-vm/src/lib/thread_pool.h +45 -0
  72. package/dist/node_modules/isolated-vm/src/lib/timer.cc +233 -0
  73. package/dist/node_modules/isolated-vm/src/lib/timer.h +36 -0
  74. package/dist/node_modules/isolated-vm/src/module/callback.cc +151 -0
  75. package/dist/node_modules/isolated-vm/src/module/callback.h +64 -0
  76. package/dist/node_modules/isolated-vm/src/module/context_handle.cc +241 -0
  77. package/dist/node_modules/isolated-vm/src/module/context_handle.h +35 -0
  78. package/dist/node_modules/isolated-vm/src/module/evaluation.cc +109 -0
  79. package/dist/node_modules/isolated-vm/src/module/evaluation.h +99 -0
  80. package/dist/node_modules/isolated-vm/src/module/external_copy_handle.cc +119 -0
  81. package/dist/node_modules/isolated-vm/src/module/external_copy_handle.h +64 -0
  82. package/dist/node_modules/isolated-vm/src/module/isolate.cc +136 -0
  83. package/dist/node_modules/isolated-vm/src/module/isolate_handle.cc +611 -0
  84. package/dist/node_modules/isolated-vm/src/module/isolate_handle.h +47 -0
  85. package/dist/node_modules/isolated-vm/src/module/lib_handle.cc +77 -0
  86. package/dist/node_modules/isolated-vm/src/module/lib_handle.h +28 -0
  87. package/dist/node_modules/isolated-vm/src/module/module_handle.cc +475 -0
  88. package/dist/node_modules/isolated-vm/src/module/module_handle.h +68 -0
  89. package/dist/node_modules/isolated-vm/src/module/native_module_handle.cc +104 -0
  90. package/dist/node_modules/isolated-vm/src/module/native_module_handle.h +49 -0
  91. package/dist/node_modules/isolated-vm/src/module/reference_handle.cc +636 -0
  92. package/dist/node_modules/isolated-vm/src/module/reference_handle.h +106 -0
  93. package/dist/node_modules/isolated-vm/src/module/script_handle.cc +107 -0
  94. package/dist/node_modules/isolated-vm/src/module/script_handle.h +37 -0
  95. package/dist/node_modules/isolated-vm/src/module/session_handle.cc +173 -0
  96. package/dist/node_modules/isolated-vm/src/module/session_handle.h +31 -0
  97. package/dist/node_modules/isolated-vm/src/module/transferable.cc +268 -0
  98. package/dist/node_modules/isolated-vm/src/module/transferable.h +42 -0
  99. package/dist/node_modules/isolated-vm/vendor/v8_inspector/nodejs_v18.0.0.h +360 -0
  100. package/dist/node_modules/isolated-vm/vendor/v8_inspector/nodejs_v18.3.0.h +376 -0
  101. package/dist/node_modules/isolated-vm/vendor/v8_inspector/nodejs_v20.0.0.h +397 -0
  102. package/dist/node_modules/isolated-vm/vendor/v8_inspector/nodejs_v22.0.0.h +419 -0
  103. package/dist/node_modules/joi/dist/joi-browser.min.js +1 -0
  104. package/dist/node_modules/joi/lib/annotate.js +175 -0
  105. package/dist/node_modules/joi/lib/base.js +1069 -0
  106. package/dist/node_modules/joi/lib/cache.js +143 -0
  107. package/dist/node_modules/joi/lib/common.js +216 -0
  108. package/dist/node_modules/joi/lib/compile.js +283 -0
  109. package/dist/node_modules/joi/lib/errors.js +271 -0
  110. package/dist/node_modules/joi/lib/extend.js +312 -0
  111. package/dist/node_modules/joi/lib/index.d.ts +2365 -0
  112. package/dist/node_modules/joi/lib/index.js +1 -0
  113. package/dist/node_modules/joi/lib/manifest.js +476 -0
  114. package/dist/node_modules/joi/lib/messages.js +178 -0
  115. package/dist/node_modules/joi/lib/modify.js +267 -0
  116. package/dist/node_modules/joi/lib/ref.js +414 -0
  117. package/dist/node_modules/joi/lib/schemas.js +302 -0
  118. package/dist/node_modules/joi/lib/state.js +166 -0
  119. package/dist/node_modules/joi/lib/template.js +463 -0
  120. package/dist/node_modules/joi/lib/trace.js +346 -0
  121. package/dist/node_modules/joi/lib/types/alternatives.js +364 -0
  122. package/dist/node_modules/joi/lib/types/any.js +174 -0
  123. package/dist/node_modules/joi/lib/types/array.js +809 -0
  124. package/dist/node_modules/joi/lib/types/binary.js +100 -0
  125. package/dist/node_modules/joi/lib/types/boolean.js +150 -0
  126. package/dist/node_modules/joi/lib/types/date.js +233 -0
  127. package/dist/node_modules/joi/lib/types/function.js +93 -0
  128. package/dist/node_modules/joi/lib/types/keys.js +1067 -0
  129. package/dist/node_modules/joi/lib/types/link.js +168 -0
  130. package/dist/node_modules/joi/lib/types/number.js +363 -0
  131. package/dist/node_modules/joi/lib/types/object.js +22 -0
  132. package/dist/node_modules/joi/lib/types/string.js +850 -0
  133. package/dist/node_modules/joi/lib/types/symbol.js +102 -0
  134. package/dist/node_modules/joi/lib/validator.js +750 -0
  135. package/dist/node_modules/joi/lib/values.js +263 -0
  136. package/dist/node_modules/joi/node_modules/@hapi/topo/lib/index.d.ts +60 -0
  137. package/dist/node_modules/joi/node_modules/@hapi/topo/lib/index.js +225 -0
  138. package/dist/node_modules/joi/node_modules/@hapi/topo/package.json +30 -0
  139. package/dist/node_modules/joi/package.json +1 -0
  140. package/dist/node_modules/winston-transport/package.json +1 -1
  141. package/dist/server/IsolatedVm.js +75 -0
  142. package/dist/server/ScriptInstruction.d.ts +8 -0
  143. package/dist/server/ScriptInstruction.js +23 -1
  144. package/dist/server/Vm.js +42 -27
  145. package/package.json +4 -2
@@ -0,0 +1,463 @@
1
+ 'use strict';
2
+
3
+ const Assert = require('@hapi/hoek/lib/assert');
4
+ const Clone = require('@hapi/hoek/lib/clone');
5
+ const EscapeHtml = require('@hapi/hoek/lib/escapeHtml');
6
+ const Formula = require('@sideway/formula');
7
+
8
+ const Common = require('./common');
9
+ const Errors = require('./errors');
10
+ const Ref = require('./ref');
11
+
12
+
13
+ const internals = {
14
+ symbol: Symbol('template'),
15
+
16
+ opens: new Array(1000).join('\u0000'),
17
+ closes: new Array(1000).join('\u0001'),
18
+
19
+ dateFormat: {
20
+ date: Date.prototype.toDateString,
21
+ iso: Date.prototype.toISOString,
22
+ string: Date.prototype.toString,
23
+ time: Date.prototype.toTimeString,
24
+ utc: Date.prototype.toUTCString
25
+ }
26
+ };
27
+
28
+
29
+ module.exports = exports = internals.Template = class {
30
+
31
+ constructor(source, options) {
32
+
33
+ Assert(typeof source === 'string', 'Template source must be a string');
34
+ Assert(!source.includes('\u0000') && !source.includes('\u0001'), 'Template source cannot contain reserved control characters');
35
+
36
+ this.source = source;
37
+ this.rendered = source;
38
+
39
+ this._template = null;
40
+
41
+ if (options) {
42
+ const { functions, ...opts } = options;
43
+ this._settings = Object.keys(opts).length ? Clone(opts) : undefined;
44
+ this._functions = functions;
45
+ if (this._functions) {
46
+ Assert(Object.keys(this._functions).every((key) => typeof key === 'string'), 'Functions keys must be strings');
47
+ Assert(Object.values(this._functions).every((key) => typeof key === 'function'), 'Functions values must be functions');
48
+ }
49
+ }
50
+ else {
51
+ this._settings = undefined;
52
+ this._functions = undefined;
53
+ }
54
+
55
+ this._parse();
56
+ }
57
+
58
+ _parse() {
59
+
60
+ // 'text {raw} {{ref}} \\{{ignore}} {{ignore\\}} {{ignore {{ignore}'
61
+
62
+ if (!this.source.includes('{')) {
63
+ return;
64
+ }
65
+
66
+ // Encode escaped \\{{{{{
67
+
68
+ const encoded = internals.encode(this.source);
69
+
70
+ // Split on first { in each set
71
+
72
+ const parts = internals.split(encoded);
73
+
74
+ // Process parts
75
+
76
+ let refs = false;
77
+ const processed = [];
78
+ const head = parts.shift();
79
+ if (head) {
80
+ processed.push(head);
81
+ }
82
+
83
+ for (const part of parts) {
84
+ const raw = part[0] !== '{';
85
+ const ender = raw ? '}' : '}}';
86
+ const end = part.indexOf(ender);
87
+ if (end === -1 || // Ignore non-matching closing
88
+ part[1] === '{') { // Ignore more than two {
89
+
90
+ processed.push(`{${internals.decode(part)}`);
91
+ continue;
92
+ }
93
+
94
+ let variable = part.slice(raw ? 0 : 1, end);
95
+ const wrapped = variable[0] === ':';
96
+ if (wrapped) {
97
+ variable = variable.slice(1);
98
+ }
99
+
100
+ const dynamic = this._ref(internals.decode(variable), { raw, wrapped });
101
+ processed.push(dynamic);
102
+ if (typeof dynamic !== 'string') {
103
+ refs = true;
104
+ }
105
+
106
+ const rest = part.slice(end + ender.length);
107
+ if (rest) {
108
+ processed.push(internals.decode(rest));
109
+ }
110
+ }
111
+
112
+ if (!refs) {
113
+ this.rendered = processed.join('');
114
+ return;
115
+ }
116
+
117
+ this._template = processed;
118
+ }
119
+
120
+ static date(date, prefs) {
121
+
122
+ return internals.dateFormat[prefs.dateFormat].call(date);
123
+ }
124
+
125
+ describe(options = {}) {
126
+
127
+ if (!this._settings &&
128
+ options.compact) {
129
+
130
+ return this.source;
131
+ }
132
+
133
+ const desc = { template: this.source };
134
+ if (this._settings) {
135
+ desc.options = this._settings;
136
+ }
137
+
138
+ if (this._functions) {
139
+ desc.functions = this._functions;
140
+ }
141
+
142
+ return desc;
143
+ }
144
+
145
+ static build(desc) {
146
+
147
+ return new internals.Template(desc.template, desc.options || desc.functions ? { ...desc.options, functions: desc.functions } : undefined);
148
+ }
149
+
150
+ isDynamic() {
151
+
152
+ return !!this._template;
153
+ }
154
+
155
+ static isTemplate(template) {
156
+
157
+ return template ? !!template[Common.symbols.template] : false;
158
+ }
159
+
160
+ refs() {
161
+
162
+ if (!this._template) {
163
+ return;
164
+ }
165
+
166
+ const refs = [];
167
+ for (const part of this._template) {
168
+ if (typeof part !== 'string') {
169
+ refs.push(...part.refs);
170
+ }
171
+ }
172
+
173
+ return refs;
174
+ }
175
+
176
+ resolve(value, state, prefs, local) {
177
+
178
+ if (this._template &&
179
+ this._template.length === 1) {
180
+
181
+ return this._part(this._template[0], /* context -> [*/ value, state, prefs, local, {} /*] */);
182
+ }
183
+
184
+ return this.render(value, state, prefs, local);
185
+ }
186
+
187
+ _part(part, ...args) {
188
+
189
+ if (part.ref) {
190
+ return part.ref.resolve(...args);
191
+ }
192
+
193
+ return part.formula.evaluate(args);
194
+ }
195
+
196
+ render(value, state, prefs, local, options = {}) {
197
+
198
+ if (!this.isDynamic()) {
199
+ return this.rendered;
200
+ }
201
+
202
+ const parts = [];
203
+ for (const part of this._template) {
204
+ if (typeof part === 'string') {
205
+ parts.push(part);
206
+ }
207
+ else {
208
+ const rendered = this._part(part, /* context -> [*/ value, state, prefs, local, options /*] */);
209
+ const string = internals.stringify(rendered, value, state, prefs, local, options);
210
+ if (string !== undefined) {
211
+ const result = part.raw || (options.errors && options.errors.escapeHtml) === false ? string : EscapeHtml(string);
212
+ parts.push(internals.wrap(result, part.wrapped && prefs.errors.wrap.label));
213
+ }
214
+ }
215
+ }
216
+
217
+ return parts.join('');
218
+ }
219
+
220
+ _ref(content, { raw, wrapped }) {
221
+
222
+ const refs = [];
223
+ const reference = (variable) => {
224
+
225
+ const ref = Ref.create(variable, this._settings);
226
+ refs.push(ref);
227
+ return (context) => {
228
+
229
+ const resolved = ref.resolve(...context);
230
+ return resolved !== undefined ? resolved : null;
231
+ };
232
+ };
233
+
234
+ try {
235
+ const functions = this._functions ? { ...internals.functions, ...this._functions } : internals.functions;
236
+ var formula = new Formula.Parser(content, { reference, functions, constants: internals.constants });
237
+ }
238
+ catch (err) {
239
+ err.message = `Invalid template variable "${content}" fails due to: ${err.message}`;
240
+ throw err;
241
+ }
242
+
243
+ if (formula.single) {
244
+ if (formula.single.type === 'reference') {
245
+ const ref = refs[0];
246
+ return { ref, raw, refs, wrapped: wrapped || ref.type === 'local' && ref.key === 'label' };
247
+ }
248
+
249
+ return internals.stringify(formula.single.value);
250
+ }
251
+
252
+ return { formula, raw, refs };
253
+ }
254
+
255
+ toString() {
256
+
257
+ return this.source;
258
+ }
259
+ };
260
+
261
+
262
+ internals.Template.prototype[Common.symbols.template] = true;
263
+ internals.Template.prototype.isImmutable = true; // Prevents Hoek from deep cloning schema objects
264
+
265
+
266
+ internals.encode = function (string) {
267
+
268
+ return string
269
+ .replace(/\\(\{+)/g, ($0, $1) => {
270
+
271
+ return internals.opens.slice(0, $1.length);
272
+ })
273
+ .replace(/\\(\}+)/g, ($0, $1) => {
274
+
275
+ return internals.closes.slice(0, $1.length);
276
+ });
277
+ };
278
+
279
+
280
+ internals.decode = function (string) {
281
+
282
+ return string
283
+ .replace(/\u0000/g, '{')
284
+ .replace(/\u0001/g, '}');
285
+ };
286
+
287
+
288
+ internals.split = function (string) {
289
+
290
+ const parts = [];
291
+ let current = '';
292
+
293
+ for (let i = 0; i < string.length; ++i) {
294
+ const char = string[i];
295
+
296
+ if (char === '{') {
297
+ let next = '';
298
+ while (i + 1 < string.length &&
299
+ string[i + 1] === '{') {
300
+
301
+ next += '{';
302
+ ++i;
303
+ }
304
+
305
+ parts.push(current);
306
+ current = next;
307
+ }
308
+ else {
309
+ current += char;
310
+ }
311
+ }
312
+
313
+ parts.push(current);
314
+ return parts;
315
+ };
316
+
317
+
318
+ internals.wrap = function (value, ends) {
319
+
320
+ if (!ends) {
321
+ return value;
322
+ }
323
+
324
+ if (ends.length === 1) {
325
+ return `${ends}${value}${ends}`;
326
+ }
327
+
328
+ return `${ends[0]}${value}${ends[1]}`;
329
+ };
330
+
331
+
332
+ internals.stringify = function (value, original, state, prefs, local, options = {}) {
333
+
334
+ const type = typeof value;
335
+ const wrap = prefs && prefs.errors && prefs.errors.wrap || {};
336
+
337
+ let skipWrap = false;
338
+ if (Ref.isRef(value) &&
339
+ value.render) {
340
+
341
+ skipWrap = value.in;
342
+ value = value.resolve(original, state, prefs, local, { in: value.in, ...options });
343
+ }
344
+
345
+ if (value === null) {
346
+ return 'null';
347
+ }
348
+
349
+ if (type === 'string') {
350
+ return internals.wrap(value, options.arrayItems && wrap.string);
351
+ }
352
+
353
+ if (type === 'number' ||
354
+ type === 'function' ||
355
+ type === 'symbol') {
356
+
357
+ return value.toString();
358
+ }
359
+
360
+ if (type !== 'object') {
361
+ return JSON.stringify(value);
362
+ }
363
+
364
+ if (value instanceof Date) {
365
+ return internals.Template.date(value, prefs);
366
+ }
367
+
368
+ if (value instanceof Map) {
369
+ const pairs = [];
370
+ for (const [key, sym] of value.entries()) {
371
+ pairs.push(`${key.toString()} -> ${sym.toString()}`);
372
+ }
373
+
374
+ value = pairs;
375
+ }
376
+
377
+ if (!Array.isArray(value)) {
378
+ return value.toString();
379
+ }
380
+
381
+ const values = [];
382
+ for (const item of value) {
383
+ values.push(internals.stringify(item, original, state, prefs, local, { arrayItems: true, ...options }));
384
+ }
385
+
386
+ return internals.wrap(values.join(', '), !skipWrap && wrap.array);
387
+ };
388
+
389
+
390
+ internals.constants = {
391
+
392
+ true: true,
393
+ false: false,
394
+ null: null,
395
+
396
+ second: 1000,
397
+ minute: 60 * 1000,
398
+ hour: 60 * 60 * 1000,
399
+ day: 24 * 60 * 60 * 1000
400
+ };
401
+
402
+
403
+ internals.functions = {
404
+
405
+ if(condition, then, otherwise) {
406
+
407
+ return condition ? then : otherwise;
408
+ },
409
+
410
+ length(item) {
411
+
412
+ if (typeof item === 'string') {
413
+ return item.length;
414
+ }
415
+
416
+ if (!item || typeof item !== 'object') {
417
+ return null;
418
+ }
419
+
420
+ if (Array.isArray(item)) {
421
+ return item.length;
422
+ }
423
+
424
+ return Object.keys(item).length;
425
+ },
426
+
427
+ msg(code) {
428
+
429
+ const [value, state, prefs, local, options] = this;
430
+ const messages = options.messages;
431
+ if (!messages) {
432
+ return '';
433
+ }
434
+
435
+ const template = Errors.template(value, messages[0], code, state, prefs) || Errors.template(value, messages[1], code, state, prefs);
436
+ if (!template) {
437
+ return '';
438
+ }
439
+
440
+ return template.render(value, state, prefs, local, options);
441
+ },
442
+
443
+ number(value) {
444
+
445
+ if (typeof value === 'number') {
446
+ return value;
447
+ }
448
+
449
+ if (typeof value === 'string') {
450
+ return parseFloat(value);
451
+ }
452
+
453
+ if (typeof value === 'boolean') {
454
+ return value ? 1 : 0;
455
+ }
456
+
457
+ if (value instanceof Date) {
458
+ return value.getTime();
459
+ }
460
+
461
+ return null;
462
+ }
463
+ };