@furo/open-models 0.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +27 -0
  3. package/dist/CustomPrototypes.d.ts +6 -0
  4. package/dist/CustomPrototypes.js +4 -0
  5. package/dist/CustomPrototypes.js.map +1 -0
  6. package/dist/FDM_OPTIONS.d.ts +16 -0
  7. package/dist/FDM_OPTIONS.js +8 -0
  8. package/dist/FDM_OPTIONS.js.map +1 -0
  9. package/dist/FieldConstraints.d.ts +15 -0
  10. package/dist/FieldConstraints.js +3 -0
  11. package/dist/FieldConstraints.js.map +1 -0
  12. package/dist/FieldNode.d.ts +339 -0
  13. package/dist/FieldNode.js +835 -0
  14. package/dist/FieldNode.js.map +1 -0
  15. package/dist/OM_OPTIONS.d.ts +16 -0
  16. package/dist/OM_OPTIONS.js +8 -0
  17. package/dist/OM_OPTIONS.js.map +1 -0
  18. package/dist/OPEN_MODELS_OPTIONS.d.ts +16 -0
  19. package/dist/OPEN_MODELS_OPTIONS.js +8 -0
  20. package/dist/OPEN_MODELS_OPTIONS.js.map +1 -0
  21. package/dist/OPTIONS.d.ts +16 -0
  22. package/dist/OPTIONS.js +8 -0
  23. package/dist/OPTIONS.js.map +1 -0
  24. package/dist/Registry.d.ts +17 -0
  25. package/dist/Registry.js +29 -0
  26. package/dist/Registry.js.map +1 -0
  27. package/dist/Validator.d.ts +7 -0
  28. package/dist/Validator.js +3 -0
  29. package/dist/Validator.js.map +1 -0
  30. package/dist/ValueState.d.ts +37 -0
  31. package/dist/ValueState.js +39 -0
  32. package/dist/ValueState.js.map +1 -0
  33. package/dist/index.d.ts +21 -0
  34. package/dist/index.js +19 -0
  35. package/dist/index.js.map +1 -0
  36. package/dist/primitives/BOOLEAN.d.ts +14 -0
  37. package/dist/primitives/BOOLEAN.js +56 -0
  38. package/dist/primitives/BOOLEAN.js.map +1 -0
  39. package/dist/primitives/ENUM.d.ts +17 -0
  40. package/dist/primitives/ENUM.js +76 -0
  41. package/dist/primitives/ENUM.js.map +1 -0
  42. package/dist/primitives/INT32.d.ts +18 -0
  43. package/dist/primitives/INT32.js +98 -0
  44. package/dist/primitives/INT32.js.map +1 -0
  45. package/dist/primitives/STRING.d.ts +16 -0
  46. package/dist/primitives/STRING.js +99 -0
  47. package/dist/primitives/STRING.js.map +1 -0
  48. package/dist/proxies/ARRAY.d.ts +165 -0
  49. package/dist/proxies/ARRAY.js +398 -0
  50. package/dist/proxies/ARRAY.js.map +1 -0
  51. package/dist/proxies/MAP.d.ts +101 -0
  52. package/dist/proxies/MAP.js +225 -0
  53. package/dist/proxies/MAP.js.map +1 -0
  54. package/dist/proxies/RECURSION.d.ts +13 -0
  55. package/dist/proxies/RECURSION.js +51 -0
  56. package/dist/proxies/RECURSION.js.map +1 -0
  57. package/dist/well_known/ANY.d.ts +20 -0
  58. package/dist/well_known/ANY.js +91 -0
  59. package/dist/well_known/ANY.js.map +1 -0
  60. package/dist/well_known/Int32Value.d.ts +17 -0
  61. package/dist/well_known/Int32Value.js +115 -0
  62. package/dist/well_known/Int32Value.js.map +1 -0
  63. package/dist/well_known/Int64Value.d.ts +16 -0
  64. package/dist/well_known/Int64Value.js +105 -0
  65. package/dist/well_known/Int64Value.js.map +1 -0
  66. package/package.json +83 -0
@@ -0,0 +1,398 @@
1
+ import { FieldNode } from '../FieldNode.js';
2
+ export class ARRAY extends FieldNode {
3
+ constructor(initData, parent, parentATributeName) {
4
+ super(undefined, parent, parentATributeName);
5
+ this._value = [];
6
+ this.___Constructor = undefined;
7
+ this.__isPrimitive = true;
8
+ if (initData !== undefined) {
9
+ // eslint-disable-next-line no-console
10
+ console.error('Use the ARRAY.Builder()');
11
+ }
12
+ this.__meta.typeName = `primitives.ARRAY<>`;
13
+ }
14
+ /**
15
+ * Creates an element of type T and adds it to the beginning or end (default) of the ARRAY
16
+ * @param initData
17
+ * @param before
18
+ */
19
+ add(initData, before) {
20
+ const Constructor = this.__getConstructor();
21
+ const fn = new Constructor();
22
+ if (initData) {
23
+ fn.__updateWithLiteral(initData);
24
+ }
25
+ const n = before ? 0 : this.length;
26
+ fn.__parentNode = this;
27
+ fn.__meta.fieldName = `[${n}]`;
28
+ fn.__meta.index = n;
29
+ fn.__meta.isArrayNode = true;
30
+ fn.__rootNode = this.__rootNode;
31
+ if (before) {
32
+ this._value.unshift(fn);
33
+ }
34
+ else {
35
+ this._value.push(fn);
36
+ }
37
+ this.__isEmpty = false;
38
+ this.__notifyArrayChanges(true);
39
+ return fn;
40
+ }
41
+ /**
42
+ *
43
+ * @param initData
44
+ */
45
+ initFromLiteral(Constructor, initData) {
46
+ this.__clear();
47
+ this.__meta.initialValue = initData;
48
+ this.__pushWithoutNotifications(initData);
49
+ this.__notifyArrayChanges(false);
50
+ }
51
+ /**
52
+ * creates a literal type from a json type
53
+ *
54
+ */
55
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
+ __mapJsonToLiteral(data) {
57
+ const literal = [];
58
+ // create a dummy object
59
+ const Constructor = this.__getConstructor();
60
+ const fn = new Constructor();
61
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
62
+ data.forEach((row) => {
63
+ literal.push(fn.__mapJsonToLiteral(row));
64
+ });
65
+ return literal;
66
+ }
67
+ __updateWithLiteral(initData) {
68
+ if (this.__parentNode !== undefined) {
69
+ this.initFromLiteral(this.__getConstructor(), initData);
70
+ }
71
+ }
72
+ __getFieldNodeByPath(deepPath = '') {
73
+ const path = deepPath
74
+ .replaceAll(/[[\]]/g, '.')
75
+ .split('.')
76
+ .filter(p => p !== '');
77
+ if (path.length > 0 && path[0] !== '') {
78
+ // eslint-disable-next-line no-param-reassign
79
+ deepPath = path.slice(1).join('.');
80
+ if (deepPath === '') {
81
+ if (this.value[parseInt(path[0], 10)]) {
82
+ return this.value[parseInt(path[0], 10)];
83
+ }
84
+ }
85
+ else if (this.value[parseInt(path[0], 10)]) {
86
+ return this.value[parseInt(path[0], 10)].__getFieldNodeByPath(deepPath);
87
+ }
88
+ return undefined;
89
+ }
90
+ return undefined;
91
+ }
92
+ __notifyArrayChanges(bubbles) {
93
+ this.__dispatchEvent(new CustomEvent('this-array-changed', {
94
+ detail: this,
95
+ bubbles: false,
96
+ }));
97
+ this.__dispatchEvent(new CustomEvent('this-field-value-changed', {
98
+ detail: this,
99
+ bubbles: false,
100
+ }));
101
+ if (bubbles) {
102
+ this.__dispatchEvent(new CustomEvent('array-changed', {
103
+ detail: this,
104
+ bubbles: true,
105
+ }));
106
+ this.__dispatchEvent(new CustomEvent('field-value-changed', {
107
+ detail: this,
108
+ bubbles: true,
109
+ }));
110
+ }
111
+ else {
112
+ this.__dispatchEvent(new CustomEvent('array-changed', {
113
+ detail: this,
114
+ bubbles: false,
115
+ }));
116
+ this.__dispatchEvent(new CustomEvent('field-value-changed', {
117
+ detail: this,
118
+ bubbles: false,
119
+ }));
120
+ }
121
+ }
122
+ // used by broadcast
123
+ get __childNodes() {
124
+ return this._value;
125
+ }
126
+ __getConstructor() {
127
+ if (this.___Constructor !== undefined) {
128
+ return this.___Constructor;
129
+ }
130
+ // the __parentNode defines the type of the ARRAY<T,I>
131
+ const fieldDescriptor = this.__parentNode.__meta.nodeFields.find(f => f.fieldName === this.__meta.fieldName);
132
+ return fieldDescriptor?.FieldConstructor;
133
+ }
134
+ /**
135
+ * @function
136
+ * @template T FieldNode
137
+ * @template I Json like interface type
138
+ * @param {T} Constructor - Const
139
+ * @param {I[]} initData - Initial open-models
140
+ * @returns {ARRAY<T, I>}
141
+ */
142
+ static Builder(Constructor, initData) {
143
+ const a = new ARRAY();
144
+ a.___Constructor = Constructor;
145
+ a.initFromLiteral(Constructor, initData);
146
+ return a;
147
+ }
148
+ toString() {
149
+ // resolve parent
150
+ const innerType = this.__parentNode?.__meta.nodeFields.find(f => f.fieldName === this.__meta.fieldName);
151
+ return `[object ARRAY<${innerType?.FieldConstructor.name}>]`;
152
+ }
153
+ // only used by direct invocation of the type
154
+ __stringify() {
155
+ return JSON.stringify(this.__toJson());
156
+ }
157
+ // only used by direct invocation of the type
158
+ __toJson() {
159
+ return this.value.map((v) => v.__toJson());
160
+ }
161
+ // only used by direct invocation of the type
162
+ __toLiteral() {
163
+ return this.value.map((v) => v.__toLiteral());
164
+ }
165
+ __clear() {
166
+ this._value.length = 0;
167
+ this.__isEmpty = true;
168
+ this.__notifyArrayChanges(false);
169
+ }
170
+ delete(index) {
171
+ const removed = this._value.splice(index, 1);
172
+ this._rebuildIndexAndFieldName();
173
+ this.__notifyArrayChanges(true);
174
+ return removed[0].__toLiteral();
175
+ }
176
+ deleteT(index) {
177
+ const removed = this._value.splice(index, 1);
178
+ this._rebuildIndexAndFieldName();
179
+ this.__notifyArrayChanges(true);
180
+ return removed[0];
181
+ }
182
+ get value() {
183
+ return this._value;
184
+ }
185
+ /**
186
+ * NOT needed any more, because we use the __TypeSetter instead of the __PrimitivesSetter
187
+ set value(arr: T[]) {
188
+ // assigning the new array will destroy any reference to it
189
+ // __clear the array
190
+ this.__clear();
191
+ // (this as any)[`_${fieldName}`].length = 0;
192
+ // refill the array
193
+ arr.forEach((e, i) => {
194
+ e.__parentNode = this;
195
+ e.__meta.fieldName = `${i}`;
196
+ e.__meta.index = i;
197
+ e.__meta.isArrayNode = true;
198
+ this._value.push(e);
199
+ });
200
+ this.__notifyArrayChanges(true);
201
+ }
202
+ */
203
+ get length() {
204
+ return this._value.length;
205
+ }
206
+ /**
207
+ * The at() method of Array instances takes an integer value and returns the item at that index, allowing for positive and negative integers. Negative integers count back from the last item in the array.
208
+ *
209
+ * This method returns the Interface type.
210
+ *
211
+ * @param {I} index - Zero-based index of the array element to be returned, converted to an integer . Negative index counts back from the end of the array — if index < 0, index + array. length is accessed.
212
+ */
213
+ at(index) {
214
+ return this._value.at(index);
215
+ }
216
+ /**
217
+ * The at() method of Array instances takes an integer value and returns the item at that index, allowing for positive and negative integers. Negative integers count back from the last item in the array.
218
+ *
219
+ * This method returns the FieldNode type.
220
+ *
221
+ * @param {T} index - Zero-based index of the array element to be returned, converted to an integer . Negative index counts back from the end of the array — if index < 0, index + array. length is accessed.
222
+ */
223
+ atT(index) {
224
+ return this._value.at(index);
225
+ }
226
+ /**
227
+ * The entries() method of Array instances returns a new array iterator object that contains the key/ value pairs for each index in the array.
228
+ */
229
+ entries() {
230
+ return this._value.map(t => t.__toLiteral()).entries();
231
+ }
232
+ /**
233
+ * The entries() method of Array instances returns a new array iterator object that contains the key/ value pairs for each index in the array.
234
+ */
235
+ entriesT() {
236
+ return this._value.entries();
237
+ }
238
+ /**
239
+ * Map with interface type as value.
240
+ *
241
+ * The map() method of Array instances creates a new array populated with the results of calling a provided function on every element in the calling array.
242
+ */
243
+ mapI(callbackfn, thisArg) {
244
+ return this._value.map(t => t.__toLiteral()).map(callbackfn, thisArg);
245
+ }
246
+ /**
247
+ * The map() method of Array instances creates a new array populated with the results of calling a provided function on every element in the calling array.
248
+ */
249
+ map(callbackfn, thisArg) {
250
+ return this._value.map(callbackfn, thisArg);
251
+ }
252
+ forEach(callbackfn, thisArg) {
253
+ return this._value.forEach(callbackfn, thisArg);
254
+ }
255
+ /**
256
+ * ...
257
+ * This method requires a FieldNode, not the interface type
258
+ * @param searchElement
259
+ * @param fromIndex
260
+ */
261
+ includes(searchElement, fromIndex) {
262
+ return this._value.includes(searchElement, fromIndex);
263
+ }
264
+ /**
265
+ * ...
266
+ * Alternatively you can use the T.__meta.index to get the index of an element.
267
+ * This method requires a FieldNode, not the interface type.
268
+ * @param searchElement
269
+ * @param fromIndex
270
+ */
271
+ indexOf(searchElement, fromIndex) {
272
+ // if searchElement is a FieldNode return __meta.index
273
+ return this._value.indexOf(searchElement, fromIndex);
274
+ }
275
+ keys() {
276
+ return this._value.keys();
277
+ }
278
+ lastIndexOf(searchElement, fromIndex) {
279
+ return this._value.lastIndexOf(searchElement, fromIndex);
280
+ }
281
+ pop() {
282
+ const ret = this._value.pop();
283
+ this.__notifyArrayChanges(true);
284
+ return ret;
285
+ }
286
+ /**
287
+ * The push() method of Array instances adds the specified elements to the end of an array and returns the new length of the array.
288
+ * Params:
289
+ * element1 … elementN – The element(s) to add to the end of the array.
290
+ * Returns:
291
+ * The new length property of the object upon which the method was called
292
+ * @param items
293
+ */
294
+ push(...items) {
295
+ const n = this.__pushWithoutNotifications(items);
296
+ this.__notifyArrayChanges(true);
297
+ return n;
298
+ }
299
+ __pushWithoutNotifications(items) {
300
+ let n = 0;
301
+ const Constructor = this.__getConstructor();
302
+ items.forEach((literal) => {
303
+ const fn = new Constructor();
304
+ fn.__updateWithLiteral(literal);
305
+ n = this._value.push(fn);
306
+ fn.__rootNode = this.__rootNode;
307
+ fn.__parentNode = this;
308
+ fn.__meta.fieldName = `[${n - 1}]`;
309
+ fn.__meta.index = n - 1;
310
+ fn.__meta.isArrayNode = true;
311
+ });
312
+ this.__isEmpty = false;
313
+ return n;
314
+ }
315
+ reverse() {
316
+ const ret = this._value.reverse();
317
+ this.__notifyArrayChanges(true);
318
+ return ret;
319
+ }
320
+ /**
321
+ * The shift() method of Array instances removes the first element from an array and returns that removed element.
322
+ *
323
+ * This method changes the length of the array.
324
+ */
325
+ shift() {
326
+ const t = this._value.shift();
327
+ this.__notifyArrayChanges(true);
328
+ return t?.__toLiteral();
329
+ }
330
+ /**
331
+ * The slice() method of Array instances returns a shallow copy of a portion of an array into a new array object selected from start to end (end not included) where start and end represent the index of items in that array. The original array will not be modified.
332
+ * #### Params:
333
+ * start – Zero-based index at which to start extraction, converted to an integer .
334
+ * Negative index counts back from the end of the array — if start < 0, start + array. length is used.
335
+ * If start < -array. length or start is omitted, 0 is used.
336
+ * If start >= array. length, nothing is extracted.
337
+ *
338
+ * end – Zero-based index at which to end extraction, converted to an integer . slice() extracts up to but not including end.
339
+ * Negative index counts back from the end of the array — if end < 0, end + array. length is used.
340
+ * If end < -array. length, 0 is used.
341
+ * If end >= array. length or end is omitted, array. length is used, causing all elements until the end to be extracted.
342
+ * If end is positioned before or at start after normalization, nothing is extracted.
343
+ *
344
+ */
345
+ slice(start, end) {
346
+ const tar = this._value.slice(start, end);
347
+ const ret = tar.map(t => t.__toLiteral());
348
+ this.__notifyArrayChanges(true);
349
+ return ret;
350
+ }
351
+ splice(start, deleteCount, ...items) {
352
+ if (deleteCount) {
353
+ const Constructor = this.__getConstructor();
354
+ const i = this._value
355
+ .splice(start, deleteCount, ...items.map((literal) => {
356
+ const fn = new Constructor();
357
+ fn.__updateWithLiteral(literal);
358
+ fn.__rootNode = this.__rootNode;
359
+ fn.__parentNode = this;
360
+ fn.__meta.isArrayNode = true;
361
+ return fn;
362
+ }))
363
+ .map(item => item.__toLiteral());
364
+ this._rebuildIndexAndFieldName();
365
+ this.__notifyArrayChanges(true);
366
+ return i;
367
+ }
368
+ const ret = this._value.splice(start).map(item => item.__toLiteral());
369
+ this.__notifyArrayChanges(true);
370
+ return ret;
371
+ }
372
+ /**
373
+ * The unshift() method of Array instances adds the specified elements to the beginning of an array and returns the new length of the array.
374
+ * #### Params:
375
+ * - **element1 … elementN** The elements to add to the front of the arr.
376
+ *
377
+ * #### Returns:
378
+ * The new length property of the object upon which the method was called.
379
+ *
380
+ */
381
+ unshift(...items) {
382
+ const ret = this._value.unshift(...items);
383
+ this.__notifyArrayChanges(true);
384
+ return ret;
385
+ }
386
+ values() {
387
+ return this._value.values();
388
+ }
389
+ _rebuildIndexAndFieldName() {
390
+ this._value.forEach((fn, i) => {
391
+ // eslint-disable-next-line no-param-reassign
392
+ fn.__meta.fieldName = `[${i}]`;
393
+ // eslint-disable-next-line no-param-reassign
394
+ fn.__meta.index = i;
395
+ });
396
+ }
397
+ }
398
+ //# sourceMappingURL=ARRAY.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ARRAY.js","sourceRoot":"","sources":["../../src/proxies/ARRAY.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,OAAO,KAA8B,SAAQ,SAAS;IAK1D,YAAY,QA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C,EAAE,EAAE;YAC/B,6CAA6C;YAC7C,EAAE,CAAC,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC;YAC/B,6CAA6C;YAC7C,EAAE,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;QACtB,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { FieldNode } from '../FieldNode';\n\nexport class ARRAY<T extends FieldNode, I> extends FieldNode {\n private _value: T[] = [];\n\n private ___Constructor: (new () => T) | undefined = undefined;\n\n constructor(initData?: I[], parent?: FieldNode, parentATributeName?: string) {\n super(undefined, parent, parentATributeName);\n this.__isPrimitive = true;\n if (initData !== undefined) {\n // eslint-disable-next-line no-console\n console.error('Use the ARRAY.Builder()');\n }\n this.__meta.typeName = `primitives.ARRAY<>`;\n }\n\n /**\n * Creates an element of type T and adds it to the beginning or end (default) of the ARRAY\n * @param initData\n * @param before\n */\n public add(initData?: I, before?: boolean): T {\n const Constructor: new () => T = this.__getConstructor();\n\n const fn = new Constructor();\n if (initData) {\n fn.__updateWithLiteral(initData);\n }\n const n = before ? 0 : this.length;\n fn.__parentNode = this;\n fn.__meta.fieldName = `[${n}]`;\n fn.__meta.index = n;\n fn.__meta.isArrayNode = true;\n fn.__rootNode = this.__rootNode;\n if (before) {\n this._value.unshift(fn);\n } else {\n this._value.push(fn);\n }\n\n this.__isEmpty = false;\n this.__notifyArrayChanges(true);\n return fn;\n }\n\n /**\n *\n * @param initData\n */\n initFromLiteral(Constructor: { new (): T }, initData: I[]) {\n this.__clear();\n this.__meta.initialValue = initData;\n this.__pushWithoutNotifications(initData);\n this.__notifyArrayChanges(false);\n }\n\n /**\n * creates a literal type from a json type\n *\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n __mapJsonToLiteral(data: any): any {\n const literal: I[] = [];\n // create a dummy object\n const Constructor = this.__getConstructor();\n const fn = new Constructor();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data.forEach((row: any) => {\n literal.push(fn.__mapJsonToLiteral(row));\n });\n return literal;\n }\n\n __updateWithLiteral(initData: I[]) {\n if (this.__parentNode !== undefined) {\n this.initFromLiteral(this.__getConstructor(), initData);\n }\n }\n\n __getFieldNodeByPath(deepPath: string = ''): FieldNode | undefined {\n const path = deepPath\n .replaceAll(/[[\\]]/g, '.')\n .split('.')\n .filter(p => p !== '');\n\n if (path.length > 0 && path[0] !== '') {\n // eslint-disable-next-line no-param-reassign\n deepPath = path.slice(1).join('.');\n if (deepPath === '') {\n if (this.value[parseInt(path[0], 10)]) {\n return this.value[parseInt(path[0], 10)] as FieldNode;\n }\n } else if (this.value[parseInt(path[0], 10)]) {\n return (\n this.value[parseInt(path[0], 10)] as FieldNode\n ).__getFieldNodeByPath(deepPath);\n }\n return undefined;\n }\n return undefined;\n }\n\n private __notifyArrayChanges(bubbles?: boolean) {\n this.__dispatchEvent(\n new CustomEvent('this-array-changed', {\n detail: this,\n bubbles: false,\n }),\n );\n this.__dispatchEvent(\n new CustomEvent('this-field-value-changed', {\n detail: this,\n bubbles: false,\n }),\n );\n if (bubbles) {\n this.__dispatchEvent(\n new CustomEvent('array-changed', {\n detail: this,\n bubbles: true,\n }),\n );\n this.__dispatchEvent(\n new CustomEvent('field-value-changed', {\n detail: this,\n bubbles: true,\n }),\n );\n } else {\n this.__dispatchEvent(\n new CustomEvent('array-changed', {\n detail: this,\n bubbles: false,\n }),\n );\n this.__dispatchEvent(\n new CustomEvent('field-value-changed', {\n detail: this,\n bubbles: false,\n }),\n );\n }\n }\n\n // used by broadcast\n public get __childNodes(): T[] {\n return this._value;\n }\n\n private __getConstructor(): new () => T {\n if (this.___Constructor !== undefined) {\n return this.___Constructor;\n }\n // the __parentNode defines the type of the ARRAY<T,I>\n const fieldDescriptor = this.__parentNode!.__meta.nodeFields.find(\n f => f.fieldName === this.__meta.fieldName,\n );\n return fieldDescriptor?.FieldConstructor as new () => T;\n }\n\n /**\n * @function\n * @template T FieldNode\n * @template I Json like interface type\n * @param {T} Constructor - Const\n * @param {I[]} initData - Initial open-models\n * @returns {ARRAY<T, I>}\n */\n static Builder<T extends FieldNode, I>(\n Constructor: new () => T,\n initData: I[],\n ): ARRAY<T, I> {\n const a: ARRAY<T, I> = new ARRAY<T, I>();\n a.___Constructor = Constructor;\n a.initFromLiteral(Constructor, initData);\n return a;\n }\n\n toString(): string {\n // resolve parent\n const innerType = this.__parentNode?.__meta.nodeFields.find(\n f => f.fieldName === this.__meta.fieldName,\n );\n return `[object ARRAY<${innerType?.FieldConstructor.name}>]`;\n }\n\n // only used by direct invocation of the type\n __stringify(): string {\n return JSON.stringify(this.__toJson());\n }\n\n // only used by direct invocation of the type\n __toJson(): T[] {\n return this.value.map((v: FieldNode) => v.__toJson());\n }\n\n // only used by direct invocation of the type\n __toLiteral(): T[] {\n return this.value.map((v: FieldNode) => v.__toLiteral());\n }\n\n __clear() {\n this._value.length = 0;\n this.__isEmpty = true;\n this.__notifyArrayChanges(false);\n }\n\n delete(index: number): I {\n const removed = this._value.splice(index, 1);\n this._rebuildIndexAndFieldName();\n this.__notifyArrayChanges(true);\n return removed[0].__toLiteral();\n }\n\n deleteT(index: number): T {\n const removed = this._value.splice(index, 1);\n this._rebuildIndexAndFieldName();\n this.__notifyArrayChanges(true);\n return removed[0];\n }\n\n get value(): T[] {\n return this._value;\n }\n\n /**\n * NOT needed any more, because we use the __TypeSetter instead of the __PrimitivesSetter\n set value(arr: T[]) {\n // assigning the new array will destroy any reference to it\n // __clear the array\n this.__clear();\n // (this as any)[`_${fieldName}`].length = 0;\n // refill the array\n arr.forEach((e, i) => {\n e.__parentNode = this;\n e.__meta.fieldName = `${i}`;\n e.__meta.index = i;\n e.__meta.isArrayNode = true;\n this._value.push(e);\n });\n this.__notifyArrayChanges(true);\n }\n */\n\n get length(): number {\n return this._value.length;\n }\n\n /**\n * The at() method of Array instances takes an integer value and returns the item at that index, allowing for positive and negative integers. Negative integers count back from the last item in the array.\n *\n * This method returns the Interface type.\n *\n * @param {I} index - Zero-based index of the array element to be returned, converted to an integer . Negative index counts back from the end of the array — if index < 0, index + array. length is accessed.\n */\n at(index: number): T | undefined {\n return this._value.at(index);\n }\n\n /**\n * The at() method of Array instances takes an integer value and returns the item at that index, allowing for positive and negative integers. Negative integers count back from the last item in the array.\n *\n * This method returns the FieldNode type.\n *\n * @param {T} index - Zero-based index of the array element to be returned, converted to an integer . Negative index counts back from the end of the array — if index < 0, index + array. length is accessed.\n */\n atT(index: number): T | undefined {\n return this._value.at(index);\n }\n\n /**\n * The entries() method of Array instances returns a new array iterator object that contains the key/ value pairs for each index in the array.\n */\n entries(): IterableIterator<[number, I]> {\n return this._value.map(t => t.__toLiteral()).entries();\n }\n\n /**\n * The entries() method of Array instances returns a new array iterator object that contains the key/ value pairs for each index in the array.\n */\n entriesT(): IterableIterator<[number, T]> {\n return this._value.entries();\n }\n\n /**\n * Map with interface type as value.\n *\n * The map() method of Array instances creates a new array populated with the results of calling a provided function on every element in the calling array.\n */\n mapI<U>(\n callbackfn: (value: I, index: number, array: I[]) => U,\n thisArg?: unknown,\n ): U[] {\n return this._value.map(t => t.__toLiteral()).map(callbackfn, thisArg);\n }\n\n /**\n * The map() method of Array instances creates a new array populated with the results of calling a provided function on every element in the calling array.\n */\n map<U>(\n callbackfn: (value: T, index: number, array: T[]) => U,\n thisArg?: unknown,\n ): U[] {\n return this._value.map(callbackfn, thisArg);\n }\n\n forEach(\n callbackfn: (value: T, index: number, array: T[]) => void,\n thisArg?: unknown,\n ): void {\n return this._value.forEach(callbackfn, thisArg);\n }\n\n /**\n * ...\n * This method requires a FieldNode, not the interface type\n * @param searchElement\n * @param fromIndex\n */\n includes(searchElement: T, fromIndex?: number): boolean {\n return this._value.includes(searchElement, fromIndex);\n }\n\n /**\n * ...\n * Alternatively you can use the T.__meta.index to get the index of an element.\n * This method requires a FieldNode, not the interface type.\n * @param searchElement\n * @param fromIndex\n */\n indexOf(searchElement: T, fromIndex?: number): number {\n // if searchElement is a FieldNode return __meta.index\n return this._value.indexOf(searchElement, fromIndex);\n }\n\n keys(): IterableIterator<number> {\n return this._value.keys();\n }\n\n lastIndexOf(searchElement: T, fromIndex?: number): number {\n return this._value.lastIndexOf(searchElement, fromIndex);\n }\n\n pop(): T | undefined {\n const ret = this._value.pop();\n this.__notifyArrayChanges(true);\n return ret;\n }\n\n /**\n * The push() method of Array instances adds the specified elements to the end of an array and returns the new length of the array.\n * Params:\n * element1 … elementN – The element(s) to add to the end of the array.\n * Returns:\n * The new length property of the object upon which the method was called\n * @param items\n */\n push(...items: I[]): number {\n const n = this.__pushWithoutNotifications(items);\n this.__notifyArrayChanges(true);\n return n;\n }\n\n private __pushWithoutNotifications(items: I[]) {\n let n: number = 0;\n const Constructor: new () => T = this.__getConstructor();\n items.forEach((literal: I) => {\n const fn = new Constructor();\n fn.__updateWithLiteral(literal);\n n = this._value.push(fn);\n fn.__rootNode = this.__rootNode;\n fn.__parentNode = this;\n fn.__meta.fieldName = `[${n - 1}]`;\n fn.__meta.index = n - 1;\n fn.__meta.isArrayNode = true;\n });\n\n this.__isEmpty = false;\n return n;\n }\n\n reverse(): T[] {\n const ret = this._value.reverse();\n this.__notifyArrayChanges(true);\n return ret;\n }\n\n /**\n * The shift() method of Array instances removes the first element from an array and returns that removed element.\n *\n * This method changes the length of the array.\n */\n shift(): I | undefined {\n const t = this._value.shift();\n this.__notifyArrayChanges(true);\n return t?.__toLiteral();\n }\n\n /**\n * The slice() method of Array instances returns a shallow copy of a portion of an array into a new array object selected from start to end (end not included) where start and end represent the index of items in that array. The original array will not be modified.\n * #### Params:\n * start – Zero-based index at which to start extraction, converted to an integer .\n * Negative index counts back from the end of the array — if start < 0, start + array. length is used.\n * If start < -array. length or start is omitted, 0 is used.\n * If start >= array. length, nothing is extracted.\n *\n * end – Zero-based index at which to end extraction, converted to an integer . slice() extracts up to but not including end.\n * Negative index counts back from the end of the array — if end < 0, end + array. length is used.\n * If end < -array. length, 0 is used.\n * If end >= array. length or end is omitted, array. length is used, causing all elements until the end to be extracted.\n * If end is positioned before or at start after normalization, nothing is extracted.\n *\n */\n slice(start?: number, end?: number): I[] {\n const tar = this._value.slice(start, end);\n const ret = tar.map(t => t.__toLiteral());\n this.__notifyArrayChanges(true);\n return ret;\n }\n\n splice(start: number, deleteCount?: number): I[];\n\n splice(start: number, deleteCount: number, ...items: I[]): I[];\n\n splice(start: number, deleteCount?: number, ...items: I[]): I[] {\n if (deleteCount) {\n const Constructor: new () => T = this.__getConstructor();\n const i: I[] = this._value\n .splice(\n start,\n deleteCount,\n ...items.map((literal: I) => {\n const fn = new Constructor();\n fn.__updateWithLiteral(literal);\n fn.__rootNode = this.__rootNode;\n fn.__parentNode = this;\n fn.__meta.isArrayNode = true;\n return fn;\n }),\n )\n .map(item => item.__toLiteral());\n this._rebuildIndexAndFieldName();\n this.__notifyArrayChanges(true);\n return i;\n }\n const ret = this._value.splice(start).map(item => item.__toLiteral());\n this.__notifyArrayChanges(true);\n return ret;\n }\n\n /**\n * The unshift() method of Array instances adds the specified elements to the beginning of an array and returns the new length of the array.\n * #### Params:\n * - **element1 … elementN** The elements to add to the front of the arr.\n *\n * #### Returns:\n * The new length property of the object upon which the method was called.\n *\n */\n unshift(...items: T[]): number {\n const ret = this._value.unshift(...items);\n this.__notifyArrayChanges(true);\n return ret;\n }\n\n values(): IterableIterator<T> {\n return this._value.values();\n }\n\n private _rebuildIndexAndFieldName() {\n this._value.forEach((fn: T, i) => {\n // eslint-disable-next-line no-param-reassign\n fn.__meta.fieldName = `[${i}]`;\n // eslint-disable-next-line no-param-reassign\n fn.__meta.index = i;\n });\n }\n}\n"]}
@@ -0,0 +1,101 @@
1
+ import { FieldNode } from '../FieldNode.js';
2
+ /**
3
+ * K can only be a 'string' or 'number' because in JSON UseProtoNames you can only set a string or a number.
4
+ *
5
+ * Even https://protobuf.dev/programming-guides/proto3/#maps defines another structure,
6
+ * we use https://protobuf.dev/programming-guides/proto3/#json
7
+ */
8
+ export declare class MAP<K extends string | number, T extends FieldNode, I> extends FieldNode {
9
+ value: Map<K, T>;
10
+ constructor(initData?: {
11
+ [key: string | number]: I;
12
+ }, parent?: FieldNode, parentAttributeName?: string);
13
+ static Builder<K extends string | number, T extends FieldNode, I>(TConstructor: new () => T, initData: {
14
+ [key: string | number]: I;
15
+ }): MAP<K, T, I>;
16
+ toString(): string;
17
+ /**
18
+ *
19
+ * @param Constructor - type constructor for T
20
+ * @param {{ [key: string | number]: I }} initData - initial map interface type
21
+ */
22
+ initFromLiteral(Constructor: {
23
+ new (): T;
24
+ }, initData: {
25
+ [key: string | number]: I;
26
+ }): void;
27
+ __getFieldNodeByPath(deepPath?: string): FieldNode | undefined;
28
+ get __childNodes(): T[];
29
+ private __notifyMapChanges;
30
+ /**
31
+ *
32
+ * @param initData
33
+ */
34
+ __updateWithLiteral(initData: {
35
+ [key: string | number]: I;
36
+ }): void;
37
+ __mapJsonToLiteral(data: any): any;
38
+ __toJson(): {
39
+ [key: string | number]: I;
40
+ };
41
+ __toLiteral(): {
42
+ [key: string | number]: I;
43
+ };
44
+ /**
45
+ * Adds a new element with a specified key and value to the Map. If an element with the same key already exists, the element will be updated.
46
+ *
47
+ * The set() method adds or updates an entry in a Map object with a specified key and a value.
48
+ *
49
+ * #### Params:
50
+ * - **key:** The key of the element to add to the Map object. The key may be any JavaScript typeName (any primitive value or any typeName of JavaScript object ).
51
+ * - **value:** The value of the element to add to the Map object. The value may be any JavaScript typeName (any primitive value or any typeName of JavaScript object ).
52
+ *
53
+ * #### Returns:
54
+ * The Map object.
55
+ */
56
+ set(key: K, value: T): Map<K, T>;
57
+ clear(): void;
58
+ /**
59
+ * The __clear() method of Map instances removes all elements from this map.
60
+ * @public
61
+ */
62
+ __clear(): void;
63
+ /**
64
+ * @returns true if an element in the Map existed and has been removed, or false if the element does not exist.
65
+ */
66
+ delete(key: K): boolean;
67
+ /**
68
+ * Executes a provided function once per each key/value pair in the Map, in insertion order.
69
+ *
70
+ * #### Params:
71
+ * - **callbackFn:** A function to execute for each entry in the map. The function is called with the following arguments:
72
+ * - **value:** Value of each iteration.
73
+ * - **key:** Key of each iteration.
74
+ * - **map:** The map being iterated.
75
+ * - **thisArg:** A value to use as this when executing callbackFn.
76
+ */
77
+ forEach(callbackfn: (value: T, key: K, map: Map<K, T>) => void, thisArg?: unknown): void;
78
+ /**
79
+ * Returns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.
80
+ * @returns Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.
81
+ */
82
+ get(key: K): T | undefined;
83
+ /**
84
+ * @returns boolean indicating whether an element with the specified key exists or not.
85
+ */
86
+ has(key: K): boolean;
87
+ /**
88
+ * The keys() method of Map instances returns a new map iterator object that contains the keys for each element in this map in insertion order.
89
+ * Returns:
90
+ * A new iterable iterator object .
91
+ */
92
+ keys(): IterableIterator<K>;
93
+ /**
94
+ * The entries() method of Map instances returns a new map iterator object that contains the [key, value] pairs for each element in this map in insertion order.
95
+ */
96
+ entries(): IterableIterator<[K, T]>;
97
+ /**
98
+ * @returns the number of elements in the Map.
99
+ */
100
+ get size(): number;
101
+ }