vestjs-runtime 1.2.0 → 1.2.2

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 (43) hide show
  1. package/dist/cjs/IsolateSerializer.development.js +100 -25
  2. package/dist/cjs/IsolateSerializer.development.js.map +1 -1
  3. package/dist/cjs/IsolateSerializer.production.js +1 -1
  4. package/dist/cjs/IsolateSerializer.production.js.map +1 -1
  5. package/dist/cjs/test-utils.development.js +16 -6
  6. package/dist/cjs/test-utils.development.js.map +1 -1
  7. package/dist/cjs/test-utils.production.js +1 -1
  8. package/dist/cjs/test-utils.production.js.map +1 -1
  9. package/dist/cjs/vestjs-runtime.development.js +99 -25
  10. package/dist/cjs/vestjs-runtime.development.js.map +1 -1
  11. package/dist/cjs/vestjs-runtime.production.js +1 -1
  12. package/dist/cjs/vestjs-runtime.production.js.map +1 -1
  13. package/dist/es/IsolateSerializer.development.js +101 -27
  14. package/dist/es/IsolateSerializer.development.js.map +1 -1
  15. package/dist/es/IsolateSerializer.production.js +1 -1
  16. package/dist/es/IsolateSerializer.production.js.map +1 -1
  17. package/dist/es/test-utils.development.js +16 -6
  18. package/dist/es/test-utils.development.js.map +1 -1
  19. package/dist/es/test-utils.production.js +1 -1
  20. package/dist/es/test-utils.production.js.map +1 -1
  21. package/dist/es/vestjs-runtime.development.js +100 -26
  22. package/dist/es/vestjs-runtime.development.js.map +1 -1
  23. package/dist/es/vestjs-runtime.production.js +1 -1
  24. package/dist/es/vestjs-runtime.production.js.map +1 -1
  25. package/dist/umd/IsolateSerializer.development.js +100 -25
  26. package/dist/umd/IsolateSerializer.development.js.map +1 -1
  27. package/dist/umd/IsolateSerializer.production.js +1 -1
  28. package/dist/umd/IsolateSerializer.production.js.map +1 -1
  29. package/dist/umd/test-utils.development.js +18 -10
  30. package/dist/umd/test-utils.development.js.map +1 -1
  31. package/dist/umd/test-utils.production.js +1 -1
  32. package/dist/umd/test-utils.production.js.map +1 -1
  33. package/dist/umd/vestjs-runtime.development.js +99 -25
  34. package/dist/umd/vestjs-runtime.development.js.map +1 -1
  35. package/dist/umd/vestjs-runtime.production.js +1 -1
  36. package/dist/umd/vestjs-runtime.production.js.map +1 -1
  37. package/package.json +3 -3
  38. package/types/IsolateSerializer.d.ts +19 -7
  39. package/types/IsolateSerializer.d.ts.map +1 -1
  40. package/types/test-utils.d.ts +2 -1
  41. package/types/test-utils.d.ts.map +1 -1
  42. package/types/vestjs-runtime.d.ts +41 -21
  43. package/types/vestjs-runtime.d.ts.map +1 -1
@@ -20,16 +20,18 @@ var IsolateKeys;
20
20
  IsolateKeys["AllowReorder"] = "allowReorder";
21
21
  IsolateKeys["Status"] = "status";
22
22
  IsolateKeys["AbortController"] = "abortController";
23
+ IsolateKeys["Children"] = "children";
23
24
  })(IsolateKeys || (IsolateKeys = {}));
24
25
  var MinifiedKeys;
25
26
  (function (MinifiedKeys) {
26
27
  MinifiedKeys["Type"] = "$";
27
- MinifiedKeys["Keys"] = "K";
28
- MinifiedKeys["Key"] = "k";
28
+ MinifiedKeys["Keys"] = "Ks";
29
+ MinifiedKeys["Key"] = "ky";
29
30
  MinifiedKeys["Parent"] = "P";
30
31
  MinifiedKeys["Data"] = "D";
31
- MinifiedKeys["AllowReorder"] = "aR";
32
+ MinifiedKeys["AllowReorder"] = "AR";
32
33
  MinifiedKeys["Status"] = "S";
34
+ MinifiedKeys["Children"] = "C";
33
35
  })(MinifiedKeys || (MinifiedKeys = {}));
34
36
  const KeyToMinified = {
35
37
  [IsolateKeys.Type]: MinifiedKeys.Type,
@@ -39,6 +41,7 @@ const KeyToMinified = {
39
41
  [IsolateKeys.Key]: MinifiedKeys.Key,
40
42
  [IsolateKeys.AllowReorder]: MinifiedKeys.AllowReorder,
41
43
  [IsolateKeys.Status]: MinifiedKeys.Status,
44
+ [IsolateKeys.Children]: MinifiedKeys.Children,
42
45
  };
43
46
  // This const is an object that looks like this:
44
47
  // {
@@ -47,13 +50,18 @@ const KeyToMinified = {
47
50
  // 'P': 'parent',
48
51
  // ...
49
52
  // }
50
- const MinifiedToKey = Object.entries(KeyToMinified).reduce((acc, [key, minified]) => Object.assign(acc, {
51
- [minified]: key,
52
- }), {});
53
+ const MinifiedToKey = invertKeyMap(KeyToMinified);
54
+ function invertKeyMap(miniMap = {}) {
55
+ return Object.entries(miniMap).reduce((acc, [key, minified]) => vestUtils.assign(acc, {
56
+ [minified]: key,
57
+ }), {});
58
+ }
53
59
  const ExcludedFromDump = [
54
60
  IsolateKeys.AbortController,
55
61
  IsolateKeys.Parent,
56
62
  IsolateKeys.Keys,
63
+ IsolateKeys.Children,
64
+ IsolateKeys.Data,
57
65
  ];
58
66
 
59
67
  class IsolateMutator {
@@ -105,8 +113,9 @@ class IsolateMutator {
105
113
  }
106
114
 
107
115
  class IsolateSerializer {
108
- // eslint-disable-next-line max-statements, complexity
109
- static deserialize(node) {
116
+ // eslint-disable-next-line max-statements, complexity, max-lines-per-function
117
+ static deserialize(node, miniMaps) {
118
+ var _a;
110
119
  // the assumption is that the tree is built correctly,
111
120
  // but the children are missing the parent property to
112
121
  // avoid circular references during serialization.
@@ -114,29 +123,52 @@ class IsolateSerializer {
114
123
  // to avoid circular references during serialization.
115
124
  // we need to rebuild the tree and add back the parent property to the children
116
125
  // and the keys property to the parents.
126
+ const inverseMinimap = deeplyInvertKeyMap(miniMaps);
127
+ // Validate the root object
117
128
  const root = vestUtils.isStringValue(node)
118
129
  ? JSON.parse(node)
119
130
  : Object.assign({}, node);
120
131
  IsolateSerializer.validateIsolate(root);
121
132
  const queue = [root];
133
+ // Iterate over the queue until it's empty
122
134
  while (queue.length) {
135
+ // Get the next item from the queue
123
136
  const current = queue.shift();
124
- const children = IsolateSerializer.getChildren(current);
137
+ // Get the children of the current item
138
+ const children = IsolateSerializer.expandChildren(current);
139
+ // Iterate over the minified keys
125
140
  for (const key in MinifiedToKey) {
141
+ // Get the value for the current key
126
142
  const value = current[key];
143
+ // If the value is not null or undefined
127
144
  if (vestUtils.isNotNullish(value)) {
128
- current[MinifiedToKey[key]] = value;
145
+ // Get the key to use
146
+ const keyToUse = MinifiedToKey[key];
147
+ // If the key is data, then we may need to transform the keys
148
+ // eslint-disable-next-line max-depth
149
+ if (keyToUse === IsolateKeys.Data) {
150
+ // Transform the keys
151
+ current[keyToUse] = transformKeys(value, (_a = inverseMinimap === null || inverseMinimap === void 0 ? void 0 : inverseMinimap.keys) === null || _a === void 0 ? void 0 : _a.data);
152
+ }
153
+ else {
154
+ // Otherwise, just set the key
155
+ current[keyToUse] = transformValueByKey(keyToUse, value, inverseMinimap);
156
+ }
157
+ // Remove the old key
129
158
  delete current[key];
130
159
  }
131
160
  }
161
+ // If there are no children, nothing to do.
132
162
  if (!children) {
133
163
  continue;
134
164
  }
165
+ // Copy the children and set their parent to the current node.
135
166
  current.children = children.map(child => {
136
167
  var _a;
137
168
  const nextChild = Object.assign({}, child);
138
169
  IsolateMutator.setParent(nextChild, current);
139
170
  queue.push(nextChild);
171
+ // If the child has a key, add it to the parent's keys.
140
172
  const key = nextChild.key;
141
173
  if (key) {
142
174
  current.keys = (_a = current.keys) !== null && _a !== void 0 ? _a : {};
@@ -147,14 +179,16 @@ class IsolateSerializer {
147
179
  }
148
180
  return root;
149
181
  }
150
- static serialize(isolate) {
182
+ static serialize(isolate, miniMaps) {
151
183
  if (vestUtils.isNullish(isolate)) {
152
184
  return '';
153
185
  }
154
- return JSON.stringify(transformIsolate(isolate));
186
+ return JSON.stringify(transformIsolate(isolate, miniMaps));
155
187
  }
156
- static getChildren(node) {
157
- return node.children ? [...node.children] : null;
188
+ static expandChildren(node) {
189
+ return node[MinifiedKeys.Children]
190
+ ? [...node[MinifiedKeys.Children]]
191
+ : null;
158
192
  }
159
193
  static validateIsolate(node) {
160
194
  vestUtils.invariant(vestUtils.hasOwnProperty(node, IsolateKeys.Type) ||
@@ -162,15 +196,20 @@ class IsolateSerializer {
162
196
  }
163
197
  }
164
198
  // eslint-disable-next-line max-statements, complexity
165
- function transformIsolate(isolate) {
199
+ function transformIsolate(isolate, miniMaps) {
200
+ var _a;
166
201
  const next = {};
167
202
  if (isolate.children) {
168
- next.children = isolate.children.map(transformIsolate);
203
+ next[MinifiedKeys.Children] = isolate.children.map(isolate => transformIsolate(isolate, miniMaps));
204
+ }
205
+ if (!vestUtils.isEmpty(isolate.data)) {
206
+ next[MinifiedKeys.Data] = transformKeys(isolate.data, (_a = miniMaps === null || miniMaps === void 0 ? void 0 : miniMaps.keys) === null || _a === void 0 ? void 0 : _a.data);
169
207
  }
170
208
  for (const key in isolate) {
171
- if (key === 'children') {
172
- continue;
173
- }
209
+ // Skip keys that should be excluded from the dump.
210
+ // While we're excluding children from the dump, they'll actually remain there
211
+ // due to the fact that we've already transformed them recursively beforehand
212
+ // thus renaming them to the minified key.
174
213
  if (isKeyExcluededFromDump(key)) {
175
214
  continue;
176
215
  }
@@ -178,18 +217,54 @@ function transformIsolate(isolate) {
178
217
  if (vestUtils.isNullish(value)) {
179
218
  continue;
180
219
  }
181
- if (vestUtils.hasOwnProperty(KeyToMinified, key)) {
182
- next[KeyToMinified[key]] = value;
183
- }
184
- else {
185
- next[key] = value;
186
- }
220
+ const keyToUse = minifyKey(key);
221
+ next[keyToUse] = transformValueByKey(key, value, miniMaps);
187
222
  }
188
223
  return next;
189
224
  }
190
225
  function isKeyExcluededFromDump(key) {
191
226
  return ExcludedFromDump.includes(key);
192
227
  }
228
+ function minifyKey(key) {
229
+ var _a;
230
+ return (_a = KeyToMinified[key]) !== null && _a !== void 0 ? _a : key;
231
+ }
232
+ function transformValueByKey(key, value, miniMaps) {
233
+ var _a, _b;
234
+ if (vestUtils.isNullish(value)) {
235
+ return value;
236
+ }
237
+ const keyMap = (_a = miniMaps === null || miniMaps === void 0 ? void 0 : miniMaps.values) === null || _a === void 0 ? void 0 : _a[key];
238
+ return keyMap ? (_b = keyMap[value]) !== null && _b !== void 0 ? _b : value : value;
239
+ }
240
+ function transformKeys(data, keyMap) {
241
+ var _a;
242
+ const next = {};
243
+ // Loop over each key in the data.
244
+ for (const key in data) {
245
+ // Find the key to use for the next object.
246
+ // If there is no key map, use the original key.
247
+ // If there is a key map, use the key map entry for the current key.
248
+ const keyToUse = (_a = (keyMap ? keyMap[key] : key)) !== null && _a !== void 0 ? _a : key;
249
+ // Add the key and value to the next object.
250
+ next[keyToUse] = data[key];
251
+ }
252
+ // Return the next object.
253
+ return next;
254
+ }
255
+ function deeplyInvertKeyMap(miniMaps = {}) {
256
+ return Object.entries(miniMaps).reduce((acc, [key, value]) => {
257
+ if (typeof value === 'object') {
258
+ return vestUtils.assign(acc, {
259
+ [key]: deeplyInvertKeyMap(value),
260
+ });
261
+ }
262
+ return vestUtils.assign(acc, {
263
+ [value]: key,
264
+ });
265
+ }, {});
266
+ }
193
267
 
194
268
  exports.IsolateSerializer = IsolateSerializer;
269
+ exports.deeplyInvertKeyMap = deeplyInvertKeyMap;
195
270
  //# sourceMappingURL=IsolateSerializer.development.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"IsolateSerializer.development.js","sources":["../../src/errors/ErrorStrings.ts","../../src/Isolate/IsolateKeys.ts","../../src/Isolate/IsolateMutator.ts","../../src/exports/IsolateSerializer.ts"],"sourcesContent":["export enum ErrorStrings {\n NO_ACTIVE_ISOLATE = 'Not within an active isolate',\n UNABLE_TO_PICK_NEXT_ISOLATE = 'Unable to pick next isolate. This is a bug, please report it to the Vest maintainers.',\n ENCOUNTERED_THE_SAME_KEY_TWICE = `Encountered the same key \"{key}\" twice. This may lead to inconsistent or overriding of results.`,\n INVALID_ISOLATE_CANNOT_PARSE = `Invalid isolate was passed to IsolateSerializer. Cannot proceed.`,\n}\n","export enum IsolateKeys {\n Type = '$type',\n Keys = 'keys',\n Key = 'key',\n Parent = 'parent',\n Data = 'data',\n AllowReorder = 'allowReorder',\n Status = 'status',\n AbortController = 'abortController',\n}\n\nenum MinifiedKeys {\n Type = '$',\n Keys = 'K',\n Key = 'k',\n Parent = 'P',\n Data = 'D',\n AllowReorder = 'aR',\n Status = 'S',\n}\n\nexport const KeyToMinified = {\n [IsolateKeys.Type]: MinifiedKeys.Type,\n [IsolateKeys.Keys]: MinifiedKeys.Keys,\n [IsolateKeys.Parent]: MinifiedKeys.Parent,\n [IsolateKeys.Data]: MinifiedKeys.Data,\n [IsolateKeys.Key]: MinifiedKeys.Key,\n [IsolateKeys.AllowReorder]: MinifiedKeys.AllowReorder,\n [IsolateKeys.Status]: MinifiedKeys.Status,\n};\n\n// This const is an object that looks like this:\n// {\n// '$': '$type',\n// 'K': 'keys',\n// 'P': 'parent',\n// ...\n// }\nexport const MinifiedToKey = Object.entries(KeyToMinified).reduce(\n (acc, [key, minified]) =>\n Object.assign(acc, {\n [minified]: key,\n }),\n {} as Record<string, IsolateKeys>\n);\n\nexport const ExcludedFromDump = [\n IsolateKeys.AbortController,\n IsolateKeys.Parent,\n IsolateKeys.Keys,\n];\n","import { Nullable, invariant, isNullish } from 'vest-utils';\n\nimport { TIsolate } from 'Isolate';\n\nexport class IsolateMutator {\n static setParent(isolate: TIsolate, parent: Nullable<TIsolate>): TIsolate {\n isolate.parent = parent;\n return isolate;\n }\n\n static saveOutput(isolate: TIsolate, output: any): TIsolate {\n isolate.output = output;\n return isolate;\n }\n\n static setKey(isolate: TIsolate, key: Nullable<string>): TIsolate {\n isolate.key = key;\n return isolate;\n }\n\n static addChild(isolate: TIsolate, child: TIsolate): void {\n invariant(isolate);\n\n isolate.children = isolate.children ?? [];\n\n isolate.children.push(child);\n IsolateMutator.setParent(child, isolate);\n }\n\n static removeChild(isolate: TIsolate, node: TIsolate): void {\n isolate.children =\n isolate.children?.filter(child => child !== node) ?? null;\n }\n\n static addChildKey(isolate: TIsolate, key: string, node: TIsolate): void {\n invariant(isolate);\n\n isolate.keys = isolate.keys ?? {};\n\n isolate.keys[key] = node;\n }\n\n static slice(isolate: TIsolate, at: number): void {\n if (isNullish(isolate.children)) {\n return;\n }\n isolate.children.length = at;\n }\n\n static setData(isolate: TIsolate, data: any): void {\n isolate.data = data;\n }\n\n static abort(isolate: TIsolate, reason?: string): void {\n if (isNullish(isolate.abortController)) {\n return;\n }\n isolate.abortController.abort(reason);\n }\n}\n","import { ErrorStrings } from 'ErrorStrings';\nimport {\n Nullable,\n hasOwnProperty,\n invariant,\n isNotNullish,\n isNullish,\n isStringValue,\n text,\n} from 'vest-utils';\n\nimport { TIsolate } from 'Isolate';\nimport {\n ExcludedFromDump,\n IsolateKeys,\n KeyToMinified,\n MinifiedToKey,\n} from 'IsolateKeys';\nimport { IsolateMutator } from 'IsolateMutator';\n\nexport class IsolateSerializer {\n // eslint-disable-next-line max-statements, complexity\n static deserialize(node: Record<string, any> | TIsolate | string): TIsolate {\n // the assumption is that the tree is built correctly,\n // but the children are missing the parent property to\n // avoid circular references during serialization.\n // in the same way, the parents are missing the `keys` property\n // to avoid circular references during serialization.\n // we need to rebuild the tree and add back the parent property to the children\n // and the keys property to the parents.\n\n const root = isStringValue(node)\n ? JSON.parse(node)\n : ({ ...node } as TIsolate);\n\n IsolateSerializer.validateIsolate(root);\n\n const queue = [root];\n\n while (queue.length) {\n const current = queue.shift();\n\n const children = IsolateSerializer.getChildren(current);\n\n for (const key in MinifiedToKey) {\n const value = current[key];\n if (isNotNullish(value)) {\n current[MinifiedToKey[key]] = value;\n delete current[key];\n }\n }\n\n if (!children) {\n continue;\n }\n\n current.children = children.map(child => {\n const nextChild = { ...child };\n\n IsolateMutator.setParent(nextChild, current);\n queue.push(nextChild);\n\n const key = nextChild.key;\n\n if (key) {\n current.keys = current.keys ?? {};\n current.keys[key] = nextChild;\n }\n\n return nextChild;\n });\n }\n\n return root as TIsolate;\n }\n\n static serialize(isolate: Nullable<TIsolate>): string {\n if (isNullish(isolate)) {\n return '';\n }\n\n return JSON.stringify(transformIsolate(isolate));\n }\n\n static getChildren(node: TIsolate): Nullable<TIsolate[]> {\n return node.children ? [...node.children] : null;\n }\n\n static validateIsolate(node: Record<string, any> | TIsolate): void {\n invariant(\n hasOwnProperty(node, IsolateKeys.Type) ||\n hasOwnProperty(node, KeyToMinified[IsolateKeys.Type]),\n text(ErrorStrings.INVALID_ISOLATE_CANNOT_PARSE)\n );\n }\n}\n\n// eslint-disable-next-line max-statements, complexity\nfunction transformIsolate(isolate: TIsolate): Record<string, any> {\n const next: Record<string, any> = {};\n\n if (isolate.children) {\n next.children = isolate.children.map(transformIsolate);\n }\n\n for (const key in isolate) {\n if (key === 'children') {\n continue;\n }\n\n if (isKeyExcluededFromDump(key)) {\n continue;\n }\n const value = isolate[key as keyof TIsolate];\n\n if (isNullish(value)) {\n continue;\n }\n\n if (hasOwnProperty(KeyToMinified, key)) {\n next[KeyToMinified[key]] = value;\n } else {\n next[key] = value;\n }\n }\n\n return next;\n}\n\nfunction isKeyExcluededFromDump(key: string): boolean {\n return ExcludedFromDump.includes(key as IsolateKeys);\n}\n"],"names":["invariant","isNullish","isStringValue","isNotNullish","hasOwnProperty","text"],"mappings":";;;;AAAA,IAAY,YAKX,CAAA;AALD,CAAA,UAAY,YAAY,EAAA;AACtB,IAAA,YAAA,CAAA,mBAAA,CAAA,GAAA,8BAAkD,CAAA;AAClD,IAAA,YAAA,CAAA,6BAAA,CAAA,GAAA,uFAAqH,CAAA;AACrH,IAAA,YAAA,CAAA,gCAAA,CAAA,GAAA,mGAAkI,CAAA;AAClI,IAAA,YAAA,CAAA,8BAAA,CAAA,GAAA,kEAAiG,CAAA;AACnG,CAAC,EALW,YAAY,KAAZ,YAAY,GAKvB,EAAA,CAAA,CAAA;;ACLD,IAAY,WASX,CAAA;AATD,CAAA,UAAY,WAAW,EAAA;AACrB,IAAA,WAAA,CAAA,MAAA,CAAA,GAAA,OAAc,CAAA;AACd,IAAA,WAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACb,IAAA,WAAA,CAAA,KAAA,CAAA,GAAA,KAAW,CAAA;AACX,IAAA,WAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,WAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAA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AAE;YAC/B,SAAS;AACV,SAAA;AACD,QAAA,MAAM,KAAK,GAAG,OAAO,CAAC,GAAqB,CAAC,CAAC;AAE7C,QAAA,IAAIJ,mBAAS,CAAC,KAAK,CAAC,EAAE;YACpB,SAAS;AACV,SAAA;AAED,QAAA,IAAIG,wBAAc,CAAC,aAAa,EAAE,GAAG,CAAC,EAAE;YACtC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;AAClC,SAAA;AAAM,aAAA;AACL,YAAA,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AACnB,SAAA;AACF,KAAA;AAED,IAAA,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,sBAAsB,CAAC,GAAW,EAAA;AACzC,IAAA,OAAO,gBAAgB,CAAC,QAAQ,CAAC,GAAkB,CAAC,CAAC;AACvD;;;;"}
1
+ {"version":3,"file":"IsolateSerializer.development.js","sources":["../../src/errors/ErrorStrings.ts","../../src/Isolate/IsolateKeys.ts","../../src/Isolate/IsolateMutator.ts","../../src/exports/IsolateSerializer.ts"],"sourcesContent":["export enum ErrorStrings {\n NO_ACTIVE_ISOLATE = 'Not within an active isolate',\n UNABLE_TO_PICK_NEXT_ISOLATE = 'Unable to pick next isolate. This is a bug, please report it to the Vest maintainers.',\n ENCOUNTERED_THE_SAME_KEY_TWICE = `Encountered the same key \"{key}\" twice. This may lead to inconsistent or overriding of results.`,\n INVALID_ISOLATE_CANNOT_PARSE = `Invalid isolate was passed to IsolateSerializer. Cannot proceed.`,\n}\n","import { assign } from 'vest-utils';\n\nexport enum IsolateKeys {\n Type = '$type',\n Keys = 'keys',\n Key = 'key',\n Parent = 'parent',\n Data = 'data',\n AllowReorder = 'allowReorder',\n Status = 'status',\n AbortController = 'abortController',\n Children = 'children',\n}\n\nexport enum MinifiedKeys {\n Type = '$',\n Keys = 'Ks',\n Key = 'ky',\n Parent = 'P',\n Data = 'D',\n AllowReorder = 'AR',\n Status = 'S',\n Children = 'C',\n}\n\nexport const KeyToMinified = {\n [IsolateKeys.Type]: MinifiedKeys.Type,\n [IsolateKeys.Keys]: MinifiedKeys.Keys,\n [IsolateKeys.Parent]: MinifiedKeys.Parent,\n [IsolateKeys.Data]: MinifiedKeys.Data,\n [IsolateKeys.Key]: MinifiedKeys.Key,\n [IsolateKeys.AllowReorder]: MinifiedKeys.AllowReorder,\n [IsolateKeys.Status]: MinifiedKeys.Status,\n [IsolateKeys.Children]: MinifiedKeys.Children,\n};\n\n// This const is an object that looks like this:\n// {\n// '$': '$type',\n// 'K': 'keys',\n// 'P': 'parent',\n// ...\n// }\nexport const MinifiedToKey = invertKeyMap(KeyToMinified);\n\nexport function invertKeyMap(miniMap: Record<string, string> = {}) {\n return Object.entries(miniMap).reduce(\n (acc, [key, minified]) =>\n assign(acc, {\n [minified]: key,\n }),\n {} as Record<string, string>\n );\n}\n\nexport const ExcludedFromDump = [\n IsolateKeys.AbortController,\n IsolateKeys.Parent,\n IsolateKeys.Keys,\n IsolateKeys.Children,\n IsolateKeys.Data,\n];\n","import { Nullable, invariant, isNullish } from 'vest-utils';\n\nimport { TIsolate } from 'Isolate';\n\nexport class IsolateMutator {\n static setParent(isolate: TIsolate, parent: Nullable<TIsolate>): TIsolate {\n isolate.parent = parent;\n return isolate;\n }\n\n static saveOutput(isolate: TIsolate, output: any): TIsolate {\n isolate.output = output;\n return isolate;\n }\n\n static setKey(isolate: TIsolate, key: Nullable<string>): TIsolate {\n isolate.key = key;\n return isolate;\n }\n\n static addChild(isolate: TIsolate, child: TIsolate): void {\n invariant(isolate);\n\n isolate.children = isolate.children ?? [];\n\n isolate.children.push(child);\n IsolateMutator.setParent(child, isolate);\n }\n\n static removeChild(isolate: TIsolate, node: TIsolate): void {\n isolate.children =\n isolate.children?.filter(child => child !== node) ?? null;\n }\n\n static addChildKey(isolate: TIsolate, key: string, node: TIsolate): void {\n invariant(isolate);\n\n isolate.keys = isolate.keys ?? {};\n\n isolate.keys[key] = node;\n }\n\n static slice(isolate: TIsolate, at: number): void {\n if (isNullish(isolate.children)) {\n return;\n }\n isolate.children.length = at;\n }\n\n static setData(isolate: TIsolate, data: any): void {\n isolate.data = data;\n }\n\n static abort(isolate: TIsolate, reason?: string): void {\n if (isNullish(isolate.abortController)) {\n return;\n }\n isolate.abortController.abort(reason);\n }\n}\n","import { ErrorStrings } from 'ErrorStrings';\nimport {\n Maybe,\n Nullable,\n assign,\n hasOwnProperty,\n invariant,\n isEmpty,\n isNotNullish,\n isNullish,\n isStringValue,\n text,\n} from 'vest-utils';\n\nimport { TIsolate } from 'Isolate';\nimport {\n ExcludedFromDump,\n IsolateKeys,\n KeyToMinified,\n MinifiedKeys,\n MinifiedToKey,\n} from 'IsolateKeys';\nimport { IsolateMutator } from 'IsolateMutator';\n\nexport class IsolateSerializer {\n // eslint-disable-next-line max-statements, complexity, max-lines-per-function\n static deserialize(\n node: Record<string, any> | TIsolate | string,\n miniMaps: Maybe<MiniMaps>\n ): TIsolate {\n // the assumption is that the tree is built correctly,\n // but the children are missing the parent property to\n // avoid circular references during serialization.\n // in the same way, the parents are missing the `keys` property\n // to avoid circular references during serialization.\n // we need to rebuild the tree and add back the parent property to the children\n // and the keys property to the parents.\n const inverseMinimap = deeplyInvertKeyMap(miniMaps);\n\n // Validate the root object\n const root = isStringValue(node)\n ? JSON.parse(node)\n : ({ ...node } as TIsolate);\n\n IsolateSerializer.validateIsolate(root);\n\n const queue = [root];\n\n // Iterate over the queue until it's empty\n while (queue.length) {\n // Get the next item from the queue\n const current = queue.shift();\n\n // Get the children of the current item\n const children = IsolateSerializer.expandChildren(current);\n\n // Iterate over the minified keys\n for (const key in MinifiedToKey) {\n // Get the value for the current key\n const value = current[key];\n\n // If the value is not null or undefined\n if (isNotNullish(value)) {\n // Get the key to use\n const keyToUse = MinifiedToKey[key];\n\n // If the key is data, then we may need to transform the keys\n // eslint-disable-next-line max-depth\n if (keyToUse === IsolateKeys.Data) {\n // Transform the keys\n current[keyToUse] = transformKeys(\n value,\n inverseMinimap?.keys?.data\n );\n } else {\n // Otherwise, just set the key\n current[keyToUse] = transformValueByKey(\n keyToUse,\n value,\n inverseMinimap\n );\n }\n\n // Remove the old key\n delete current[key];\n }\n }\n\n // If there are no children, nothing to do.\n if (!children) {\n continue;\n }\n\n // Copy the children and set their parent to the current node.\n current.children = children.map(child => {\n const nextChild = { ...child };\n\n IsolateMutator.setParent(nextChild, current);\n queue.push(nextChild);\n\n // If the child has a key, add it to the parent's keys.\n const key = nextChild.key;\n\n if (key) {\n current.keys = current.keys ?? {};\n current.keys[key] = nextChild;\n }\n\n return nextChild;\n });\n }\n\n return root as TIsolate;\n }\n\n static serialize(\n isolate: Nullable<TIsolate>,\n miniMaps: Maybe<MiniMaps>\n ): string {\n if (isNullish(isolate)) {\n return '';\n }\n\n return JSON.stringify(transformIsolate(isolate, miniMaps));\n }\n\n static expandChildren(node: Record<string, any>): Nullable<TIsolate[]> {\n return node[MinifiedKeys.Children]\n ? [...node[MinifiedKeys.Children]]\n : null;\n }\n\n static validateIsolate(node: Record<string, any> | TIsolate): void {\n invariant(\n hasOwnProperty(node, IsolateKeys.Type) ||\n hasOwnProperty(node, KeyToMinified[IsolateKeys.Type]),\n text(ErrorStrings.INVALID_ISOLATE_CANNOT_PARSE)\n );\n }\n}\n\n// eslint-disable-next-line max-statements, complexity\nfunction transformIsolate(\n isolate: TIsolate,\n miniMaps: Maybe<MiniMaps>\n): Record<string, any> {\n const next: Record<string, any> = {};\n\n if (isolate.children) {\n next[MinifiedKeys.Children] = isolate.children.map(isolate =>\n transformIsolate(isolate, miniMaps)\n );\n }\n\n if (!isEmpty(isolate.data)) {\n next[MinifiedKeys.Data] = transformKeys(isolate.data, miniMaps?.keys?.data);\n }\n\n for (const key in isolate) {\n // Skip keys that should be excluded from the dump.\n // While we're excluding children from the dump, they'll actually remain there\n // due to the fact that we've already transformed them recursively beforehand\n // thus renaming them to the minified key.\n if (isKeyExcluededFromDump(key)) {\n continue;\n }\n const value = isolate[key as keyof TIsolate];\n\n if (isNullish(value)) {\n continue;\n }\n\n const keyToUse = minifyKey(key);\n next[keyToUse] = transformValueByKey(key, value, miniMaps);\n }\n\n return next;\n}\n\nfunction isKeyExcluededFromDump(key: string): boolean {\n return ExcludedFromDump.includes(key as IsolateKeys);\n}\n\nfunction minifyKey(key: string): string {\n return KeyToMinified[key as keyof typeof KeyToMinified] ?? key;\n}\n\nfunction transformValueByKey(\n key: string,\n value: any,\n miniMaps: Maybe<MiniMaps>\n): any {\n if (isNullish(value)) {\n return value;\n }\n\n const keyMap = miniMaps?.values?.[key as keyof MiniMaps['values']];\n\n return keyMap ? keyMap[value] ?? value : value;\n}\n\nfunction transformKeys(\n data: Record<string, any>,\n keyMap: Maybe<MiniMap>\n): Record<string, any> {\n const next: Record<string, any> = {};\n\n // Loop over each key in the data.\n for (const key in data) {\n // Find the key to use for the next object.\n // If there is no key map, use the original key.\n // If there is a key map, use the key map entry for the current key.\n const keyToUse = (keyMap ? keyMap[key] : key) ?? key;\n\n // Add the key and value to the next object.\n next[keyToUse] = data[key];\n }\n\n // Return the next object.\n return next;\n}\n\ntype MiniMap = Record<string, string>;\n\ntype MiniMaps = Partial<{\n keys: Partial<{\n [IsolateKeys.Data]: MiniMap;\n }>;\n values: Partial<{\n [IsolateKeys.Status]: MiniMap;\n [IsolateKeys.Type]: MiniMap;\n }>;\n}>;\n\nexport function deeplyInvertKeyMap(miniMaps: Maybe<MiniMaps> = {}): MiniMaps {\n return Object.entries(miniMaps).reduce((acc, [key, value]) => {\n if (typeof value === 'object') {\n return assign(acc, {\n [key]: deeplyInvertKeyMap(value as MiniMaps),\n });\n }\n return assign(acc, {\n [value]: key,\n });\n }, {} as MiniMaps);\n}\n"],"names":["assign","invariant","isNullish","isStringValue","isNotNullish","hasOwnProperty","text","isEmpty"],"mappings":";;;;AAAA,IAAY,YAKX,CAAA;AALD,CAAA,UAAY,YAAY,EAAA;AACtB,IAAA,YAAA,CAAA,mBAAA,CAAA,GAAA,8BAAkD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AA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,OAAOF,gBAAM,CAAC,GAAG,EAAE;AACjB,gBAAA,CAAC,GAAG,GAAG,kBAAkB,CAAC,KAAiB,CAAC;AAC7C,aAAA,CAAC,CAAC;AACJ,SAAA;QACD,OAAOA,gBAAM,CAAC,GAAG,EAAE;YACjB,CAAC,KAAK,GAAG,GAAG;AACb,SAAA,CAAC,CAAC;KACJ,EAAE,EAAc,CAAC,CAAC;AACrB;;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";var t,e,r,i=require("vest-utils");!function(t){t.NO_ACTIVE_ISOLATE="Not within an active isolate",t.UNABLE_TO_PICK_NEXT_ISOLATE="Unable to pick next isolate. This is a bug, please report it to the Vest maintainers.",t.ENCOUNTERED_THE_SAME_KEY_TWICE='Encountered the same key "{key}" twice. This may lead to inconsistent or overriding of results.',t.INVALID_ISOLATE_CANNOT_PARSE="Invalid isolate was passed to IsolateSerializer. Cannot proceed."}(t||(t={})),function(t){t.Type="$type",t.Keys="keys",t.Key="key",t.Parent="parent",t.Data="data",t.AllowReorder="allowReorder",t.Status="status",t.AbortController="abortController"}(e||(e={})),function(t){t.Type="$",t.Keys="K",t.Key="k",t.Parent="P",t.Data="D",t.AllowReorder="aR",t.Status="S"}(r||(r={}));const s={[e.Type]:r.Type,[e.Keys]:r.Keys,[e.Parent]:r.Parent,[e.Data]:r.Data,[e.Key]:r.Key,[e.AllowReorder]:r.AllowReorder,[e.Status]:r.Status},n=Object.entries(s).reduce(((t,[e,r])=>Object.assign(t,{[r]:e})),{}),a=[e.AbortController,e.Parent,e.Keys];class l{static setParent(t,e){return t.parent=e,t}static saveOutput(t,e){return t.output=e,t}static setKey(t,e){return t.key=e,t}static addChild(t,e){var r;i.invariant(t),t.children=null!==(r=t.children)&&void 0!==r?r:[],t.children.push(e),l.setParent(e,t)}static removeChild(t,e){var r,i;t.children=null!==(i=null===(r=t.children)||void 0===r?void 0:r.filter((t=>t!==e)))&&void 0!==i?i:null}static addChildKey(t,e,r){var s;i.invariant(t),t.keys=null!==(s=t.keys)&&void 0!==s?s:{},t.keys[e]=r}static slice(t,e){i.isNullish(t.children)||(t.children.length=e)}static setData(t,e){t.data=e}static abort(t,e){i.isNullish(t.abortController)||t.abortController.abort(e)}}class o{static deserialize(t){const e=i.isStringValue(t)?JSON.parse(t):Object.assign({},t);o.validateIsolate(e);const r=[e];for(;r.length;){const t=r.shift(),e=o.getChildren(t);for(const e in n){const r=t[e];i.isNotNullish(r)&&(t[n[e]]=r,delete t[e])}e&&(t.children=e.map((e=>{var i;const s=Object.assign({},e);l.setParent(s,t),r.push(s);const n=s.key;return n&&(t.keys=null!==(i=t.keys)&&void 0!==i?i:{},t.keys[n]=s),s})))}return e}static serialize(t){return i.isNullish(t)?"":JSON.stringify(c(t))}static getChildren(t){return t.children?[...t.children]:null}static validateIsolate(r){i.invariant(i.hasOwnProperty(r,e.Type)||i.hasOwnProperty(r,s[e.Type]),i.text(t.INVALID_ISOLATE_CANNOT_PARSE))}}function c(t){const e={};t.children&&(e.children=t.children.map(c));for(const r in t){if("children"===r)continue;if(d(r))continue;const n=t[r];i.isNullish(n)||(i.hasOwnProperty(s,r)?e[s[r]]=n:e[r]=n)}return e}function d(t){return a.includes(t)}exports.IsolateSerializer=o;
1
+ "use strict";var t,e,n,i=require("vest-utils");!function(t){t.NO_ACTIVE_ISOLATE="Not within an active isolate",t.UNABLE_TO_PICK_NEXT_ISOLATE="Unable to pick next isolate. This is a bug, please report it to the Vest maintainers.",t.ENCOUNTERED_THE_SAME_KEY_TWICE='Encountered the same key "{key}" twice. This may lead to inconsistent or overriding of results.',t.INVALID_ISOLATE_CANNOT_PARSE="Invalid isolate was passed to IsolateSerializer. Cannot proceed."}(t||(t={})),function(t){t.Type="$type",t.Keys="keys",t.Key="key",t.Parent="parent",t.Data="data",t.AllowReorder="allowReorder",t.Status="status",t.AbortController="abortController",t.Children="children"}(e||(e={})),function(t){t.Type="$",t.Keys="Ks",t.Key="ky",t.Parent="P",t.Data="D",t.AllowReorder="AR",t.Status="S",t.Children="C"}(n||(n={}));const r={[e.Type]:n.Type,[e.Keys]:n.Keys,[e.Parent]:n.Parent,[e.Data]:n.Data,[e.Key]:n.Key,[e.AllowReorder]:n.AllowReorder,[e.Status]:n.Status,[e.Children]:n.Children},a=function(t={}){return Object.entries(t).reduce(((t,[e,n])=>i.assign(t,{[n]:e})),{})}(r);const s=[e.AbortController,e.Parent,e.Keys,e.Children,e.Data];class l{static setParent(t,e){return t.parent=e,t}static saveOutput(t,e){return t.output=e,t}static setKey(t,e){return t.key=e,t}static addChild(t,e){var n;i.invariant(t),t.children=null!==(n=t.children)&&void 0!==n?n:[],t.children.push(e),l.setParent(e,t)}static removeChild(t,e){var n,i;t.children=null!==(i=null===(n=t.children)||void 0===n?void 0:n.filter((t=>t!==e)))&&void 0!==i?i:null}static addChildKey(t,e,n){var r;i.invariant(t),t.keys=null!==(r=t.keys)&&void 0!==r?r:{},t.keys[e]=n}static slice(t,e){i.isNullish(t.children)||(t.children.length=e)}static setData(t,e){t.data=e}static abort(t,e){i.isNullish(t.abortController)||t.abortController.abort(e)}}class o{static deserialize(t,n){var r;const s=y(n),d=i.isStringValue(t)?JSON.parse(t):Object.assign({},t);o.validateIsolate(d);const u=[d];for(;u.length;){const t=u.shift(),n=o.expandChildren(t);for(const n in a){const l=t[n];if(i.isNotNullish(l)){const i=a[n];i===e.Data?t[i]=v(l,null===(r=null==s?void 0:s.keys)||void 0===r?void 0:r.data):t[i]=h(i,l,s),delete t[n]}}n&&(t.children=n.map((e=>{var n;const i=Object.assign({},e);l.setParent(i,t),u.push(i);const r=i.key;return r&&(t.keys=null!==(n=t.keys)&&void 0!==n?n:{},t.keys[r]=i),i})))}return d}static serialize(t,e){return i.isNullish(t)?"":JSON.stringify(d(t,e))}static expandChildren(t){return t[n.Children]?[...t[n.Children]]:null}static validateIsolate(n){i.invariant(i.hasOwnProperty(n,e.Type)||i.hasOwnProperty(n,r[e.Type]),i.text(t.INVALID_ISOLATE_CANNOT_PARSE))}}function d(t,e){var r;const a={};t.children&&(a[n.Children]=t.children.map((t=>d(t,e)))),i.isEmpty(t.data)||(a[n.Data]=v(t.data,null===(r=null==e?void 0:e.keys)||void 0===r?void 0:r.data));for(const n in t){if(u(n))continue;const r=t[n];if(i.isNullish(r))continue;a[c(n)]=h(n,r,e)}return a}function u(t){return s.includes(t)}function c(t){var e;return null!==(e=r[t])&&void 0!==e?e:t}function h(t,e,n){var r,a;if(i.isNullish(e))return e;const s=null===(r=null==n?void 0:n.values)||void 0===r?void 0:r[t];return s&&null!==(a=s[e])&&void 0!==a?a:e}function v(t,e){var n;const i={};for(const r in t){i[null!==(n=e?e[r]:r)&&void 0!==n?n:r]=t[r]}return i}function y(t={}){return Object.entries(t).reduce(((t,[e,n])=>"object"==typeof n?i.assign(t,{[e]:y(n)}):i.assign(t,{[n]:e})),{})}exports.IsolateSerializer=o,exports.deeplyInvertKeyMap=y;
2
2
  //# sourceMappingURL=IsolateSerializer.production.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"IsolateSerializer.production.js","sources":["../../src/errors/ErrorStrings.ts","../../src/Isolate/IsolateKeys.ts","../../src/Isolate/IsolateMutator.ts","../../src/exports/IsolateSerializer.ts"],"sourcesContent":["export enum ErrorStrings {\n NO_ACTIVE_ISOLATE = 'Not within an active isolate',\n UNABLE_TO_PICK_NEXT_ISOLATE = 'Unable to pick next isolate. This is a bug, please report it to the Vest maintainers.',\n ENCOUNTERED_THE_SAME_KEY_TWICE = `Encountered the same key \"{key}\" twice. This may lead to inconsistent or overriding of results.`,\n INVALID_ISOLATE_CANNOT_PARSE = `Invalid isolate was passed to IsolateSerializer. Cannot proceed.`,\n}\n","export enum IsolateKeys {\n Type = '$type',\n Keys = 'keys',\n Key = 'key',\n Parent = 'parent',\n Data = 'data',\n AllowReorder = 'allowReorder',\n Status = 'status',\n AbortController = 'abortController',\n}\n\nenum MinifiedKeys {\n Type = '$',\n Keys = 'K',\n Key = 'k',\n Parent = 'P',\n Data = 'D',\n AllowReorder = 'aR',\n Status = 'S',\n}\n\nexport const KeyToMinified = {\n [IsolateKeys.Type]: MinifiedKeys.Type,\n [IsolateKeys.Keys]: MinifiedKeys.Keys,\n [IsolateKeys.Parent]: MinifiedKeys.Parent,\n [IsolateKeys.Data]: MinifiedKeys.Data,\n [IsolateKeys.Key]: MinifiedKeys.Key,\n [IsolateKeys.AllowReorder]: MinifiedKeys.AllowReorder,\n [IsolateKeys.Status]: MinifiedKeys.Status,\n};\n\n// This const is an object that looks like this:\n// {\n// '$': '$type',\n// 'K': 'keys',\n// 'P': 'parent',\n// ...\n// }\nexport const MinifiedToKey = Object.entries(KeyToMinified).reduce(\n (acc, [key, minified]) =>\n Object.assign(acc, {\n [minified]: key,\n }),\n {} as Record<string, IsolateKeys>\n);\n\nexport const ExcludedFromDump = [\n IsolateKeys.AbortController,\n IsolateKeys.Parent,\n IsolateKeys.Keys,\n];\n","import { Nullable, invariant, isNullish } from 'vest-utils';\n\nimport { TIsolate } from 'Isolate';\n\nexport class IsolateMutator {\n static setParent(isolate: TIsolate, parent: Nullable<TIsolate>): TIsolate {\n isolate.parent = parent;\n return isolate;\n }\n\n static saveOutput(isolate: TIsolate, output: any): TIsolate {\n isolate.output = output;\n return isolate;\n }\n\n static setKey(isolate: TIsolate, key: Nullable<string>): TIsolate {\n isolate.key = key;\n return isolate;\n }\n\n static addChild(isolate: TIsolate, child: TIsolate): void {\n invariant(isolate);\n\n isolate.children = isolate.children ?? [];\n\n isolate.children.push(child);\n IsolateMutator.setParent(child, isolate);\n }\n\n static removeChild(isolate: TIsolate, node: TIsolate): void {\n isolate.children =\n isolate.children?.filter(child => child !== node) ?? null;\n }\n\n static addChildKey(isolate: TIsolate, key: string, node: TIsolate): void {\n invariant(isolate);\n\n isolate.keys = isolate.keys ?? {};\n\n isolate.keys[key] = node;\n }\n\n static slice(isolate: TIsolate, at: number): void {\n if (isNullish(isolate.children)) {\n return;\n }\n isolate.children.length = at;\n }\n\n static setData(isolate: TIsolate, data: any): void {\n isolate.data = data;\n }\n\n static abort(isolate: TIsolate, reason?: string): void {\n if (isNullish(isolate.abortController)) {\n return;\n }\n isolate.abortController.abort(reason);\n }\n}\n","import { ErrorStrings } from 'ErrorStrings';\nimport {\n Nullable,\n hasOwnProperty,\n invariant,\n isNotNullish,\n isNullish,\n isStringValue,\n text,\n} from 'vest-utils';\n\nimport { TIsolate } from 'Isolate';\nimport {\n ExcludedFromDump,\n IsolateKeys,\n KeyToMinified,\n MinifiedToKey,\n} from 'IsolateKeys';\nimport { IsolateMutator } from 'IsolateMutator';\n\nexport class IsolateSerializer {\n // eslint-disable-next-line max-statements, complexity\n static deserialize(node: Record<string, any> | TIsolate | string): TIsolate {\n // the assumption is that the tree is built correctly,\n // but the children are missing the parent property to\n // avoid circular references during serialization.\n // in the same way, the parents are missing the `keys` property\n // to avoid circular references during serialization.\n // we need to rebuild the tree and add back the parent property to the children\n // and the keys property to the parents.\n\n const root = isStringValue(node)\n ? JSON.parse(node)\n : ({ ...node } as TIsolate);\n\n IsolateSerializer.validateIsolate(root);\n\n const queue = [root];\n\n while (queue.length) {\n const current = queue.shift();\n\n const children = IsolateSerializer.getChildren(current);\n\n for (const key in MinifiedToKey) {\n const value = current[key];\n if (isNotNullish(value)) {\n current[MinifiedToKey[key]] = value;\n delete current[key];\n }\n }\n\n if (!children) {\n continue;\n }\n\n current.children = children.map(child => {\n const nextChild = { ...child };\n\n IsolateMutator.setParent(nextChild, current);\n queue.push(nextChild);\n\n const key = nextChild.key;\n\n if (key) {\n current.keys = current.keys ?? {};\n current.keys[key] = nextChild;\n }\n\n return nextChild;\n });\n }\n\n return root as TIsolate;\n }\n\n static serialize(isolate: Nullable<TIsolate>): string {\n if (isNullish(isolate)) {\n return '';\n }\n\n return JSON.stringify(transformIsolate(isolate));\n }\n\n static getChildren(node: TIsolate): Nullable<TIsolate[]> {\n return node.children ? [...node.children] : null;\n }\n\n static validateIsolate(node: Record<string, any> | TIsolate): void {\n invariant(\n hasOwnProperty(node, IsolateKeys.Type) ||\n hasOwnProperty(node, KeyToMinified[IsolateKeys.Type]),\n text(ErrorStrings.INVALID_ISOLATE_CANNOT_PARSE)\n );\n }\n}\n\n// eslint-disable-next-line max-statements, complexity\nfunction transformIsolate(isolate: TIsolate): Record<string, any> {\n const next: Record<string, any> = {};\n\n if (isolate.children) {\n next.children = isolate.children.map(transformIsolate);\n }\n\n for (const key in isolate) {\n if (key === 'children') {\n continue;\n }\n\n if (isKeyExcluededFromDump(key)) {\n continue;\n }\n const value = isolate[key as keyof TIsolate];\n\n if (isNullish(value)) {\n continue;\n }\n\n if (hasOwnProperty(KeyToMinified, key)) {\n next[KeyToMinified[key]] = value;\n } else {\n next[key] = value;\n }\n }\n\n return next;\n}\n\nfunction isKeyExcluededFromDump(key: string): boolean {\n return ExcludedFromDump.includes(key as IsolateKeys);\n}\n"],"names":["ErrorStrings","IsolateKeys","MinifiedKeys","KeyToMinified","Type","Keys","Parent","Data","Key","AllowReorder","Status","MinifiedToKey","Object","entries","reduce","acc","key","minified","assign","ExcludedFromDump","AbortController","IsolateMutator","static","isolate","parent","output","child","invariant","children","_a","push","setParent","node","_b","filter","keys","at","isNullish","length","data","reason","abortController","abort","IsolateSerializer","root","isStringValue","JSON","parse","validateIsolate","queue","current","shift","getChildren","value","isNotNullish","map","nextChild","stringify","transformIsolate","hasOwnProperty","text","INVALID_ISOLATE_CANNOT_PARSE","next","isKeyExcluededFromDump","includes"],"mappings":"iBAAYA,ECAAC,EAWPC,2BDXL,SAAYF,GACVA,EAAA,kBAAA,+BACAA,EAAA,4BAAA,wFACAA,EAAA,+BAAA,kGACAA,EAAA,6BAAA,kEACD,CALD,CAAYA,IAAAA,EAKX,CAAA,ICLD,SAAYC,GACVA,EAAA,KAAA,QACAA,EAAA,KAAA,OACAA,EAAA,IAAA,MACAA,EAAA,OAAA,SACAA,EAAA,KAAA,OACAA,EAAA,aAAA,eACAA,EAAA,OAAA,SACAA,E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,GACjB,OAAOA,EAAKJ,SAAW,IAAII,EAAKJ,UAAY,IAC7C,CAEDN,uBAAuBU,GACrBL,EAAAA,UACEgC,EAAcA,eAAC3B,EAAM/B,EAAYG,OAC/BuD,iBAAe3B,EAAM7B,EAAcF,EAAYG,OACjDwD,OAAK5D,EAAa6D,8BAErB,EAIH,SAASH,EAAiBnC,GACxB,MAAMuC,EAA4B,CAAA,EAE9BvC,EAAQK,WACVkC,EAAKlC,SAAWL,EAAQK,SAAS2B,IAAIG,IAGvC,IAAK,MAAM1C,KAAOO,EAAS,CACzB,GAAY,aAARP,EACF,SAGF,GAAI+C,EAAuB/C,GACzB,SAEF,MAAMqC,EAAQ9B,EAAQP,GAElBqB,EAAAA,UAAUgB,KAIVM,EAAcA,eAACxD,EAAea,GAChC8C,EAAK3D,EAAca,IAAQqC,EAE3BS,EAAK9C,GAAOqC,EAEf,CAED,OAAOS,CACT,CAEA,SAASC,EAAuB/C,GAC9B,OAAOG,EAAiB6C,SAAShD,EACnC"}
1
+ {"version":3,"file":"IsolateSerializer.production.js","sources":["../../src/errors/ErrorStrings.ts","../../src/Isolate/IsolateKeys.ts","../../src/Isolate/IsolateMutator.ts","../../src/exports/IsolateSerializer.ts"],"sourcesContent":["export enum ErrorStrings {\n NO_ACTIVE_ISOLATE = 'Not within an active isolate',\n UNABLE_TO_PICK_NEXT_ISOLATE = 'Unable to pick next isolate. This is a bug, please report it to the Vest maintainers.',\n ENCOUNTERED_THE_SAME_KEY_TWICE = `Encountered the same key \"{key}\" twice. This may lead to inconsistent or overriding of results.`,\n INVALID_ISOLATE_CANNOT_PARSE = `Invalid isolate was passed to IsolateSerializer. Cannot proceed.`,\n}\n","import { assign } from 'vest-utils';\n\nexport enum IsolateKeys {\n Type = '$type',\n Keys = 'keys',\n Key = 'key',\n Parent = 'parent',\n Data = 'data',\n AllowReorder = 'allowReorder',\n Status = 'status',\n AbortController = 'abortController',\n Children = 'children',\n}\n\nexport enum MinifiedKeys {\n Type = '$',\n Keys = 'Ks',\n Key = 'ky',\n Parent = 'P',\n Data = 'D',\n AllowReorder = 'AR',\n Status = 'S',\n Children = 'C',\n}\n\nexport const KeyToMinified = {\n [IsolateKeys.Type]: MinifiedKeys.Type,\n [IsolateKeys.Keys]: MinifiedKeys.Keys,\n [IsolateKeys.Parent]: MinifiedKeys.Parent,\n [IsolateKeys.Data]: MinifiedKeys.Data,\n [IsolateKeys.Key]: MinifiedKeys.Key,\n [IsolateKeys.AllowReorder]: MinifiedKeys.AllowReorder,\n [IsolateKeys.Status]: MinifiedKeys.Status,\n [IsolateKeys.Children]: MinifiedKeys.Children,\n};\n\n// This const is an object that looks like this:\n// {\n// '$': '$type',\n// 'K': 'keys',\n// 'P': 'parent',\n// ...\n// }\nexport const MinifiedToKey = invertKeyMap(KeyToMinified);\n\nexport function invertKeyMap(miniMap: Record<string, string> = {}) {\n return Object.entries(miniMap).reduce(\n (acc, [key, minified]) =>\n assign(acc, {\n [minified]: key,\n }),\n {} as Record<string, string>\n );\n}\n\nexport const ExcludedFromDump = [\n IsolateKeys.AbortController,\n IsolateKeys.Parent,\n IsolateKeys.Keys,\n IsolateKeys.Children,\n IsolateKeys.Data,\n];\n","import { Nullable, invariant, isNullish } from 'vest-utils';\n\nimport { TIsolate } from 'Isolate';\n\nexport class IsolateMutator {\n static setParent(isolate: TIsolate, parent: Nullable<TIsolate>): TIsolate {\n isolate.parent = parent;\n return isolate;\n }\n\n static saveOutput(isolate: TIsolate, output: any): TIsolate {\n isolate.output = output;\n return isolate;\n }\n\n static setKey(isolate: TIsolate, key: Nullable<string>): TIsolate {\n isolate.key = key;\n return isolate;\n }\n\n static addChild(isolate: TIsolate, child: TIsolate): void {\n invariant(isolate);\n\n isolate.children = isolate.children ?? [];\n\n isolate.children.push(child);\n IsolateMutator.setParent(child, isolate);\n }\n\n static removeChild(isolate: TIsolate, node: TIsolate): void {\n isolate.children =\n isolate.children?.filter(child => child !== node) ?? null;\n }\n\n static addChildKey(isolate: TIsolate, key: string, node: TIsolate): void {\n invariant(isolate);\n\n isolate.keys = isolate.keys ?? {};\n\n isolate.keys[key] = node;\n }\n\n static slice(isolate: TIsolate, at: number): void {\n if (isNullish(isolate.children)) {\n return;\n }\n isolate.children.length = at;\n }\n\n static setData(isolate: TIsolate, data: any): void {\n isolate.data = data;\n }\n\n static abort(isolate: TIsolate, reason?: string): void {\n if (isNullish(isolate.abortController)) {\n return;\n }\n isolate.abortController.abort(reason);\n }\n}\n","import { ErrorStrings } from 'ErrorStrings';\nimport {\n Maybe,\n Nullable,\n assign,\n hasOwnProperty,\n invariant,\n isEmpty,\n isNotNullish,\n isNullish,\n isStringValue,\n text,\n} from 'vest-utils';\n\nimport { TIsolate } from 'Isolate';\nimport {\n ExcludedFromDump,\n IsolateKeys,\n KeyToMinified,\n MinifiedKeys,\n MinifiedToKey,\n} from 'IsolateKeys';\nimport { IsolateMutator } from 'IsolateMutator';\n\nexport class IsolateSerializer {\n // eslint-disable-next-line max-statements, complexity, max-lines-per-function\n static deserialize(\n node: Record<string, any> | TIsolate | string,\n miniMaps: Maybe<MiniMaps>\n ): TIsolate {\n // the assumption is that the tree is built correctly,\n // but the children are missing the parent property to\n // avoid circular references during serialization.\n // in the same way, the parents are missing the `keys` property\n // to avoid circular references during serialization.\n // we need to rebuild the tree and add back the parent property to the children\n // and the keys property to the parents.\n const inverseMinimap = deeplyInvertKeyMap(miniMaps);\n\n // Validate the root object\n const root = isStringValue(node)\n ? JSON.parse(node)\n : ({ ...node } as TIsolate);\n\n IsolateSerializer.validateIsolate(root);\n\n const queue = [root];\n\n // Iterate over the queue until it's empty\n while (queue.length) {\n // Get the next item from the queue\n const current = queue.shift();\n\n // Get the children of the current item\n const children = IsolateSerializer.expandChildren(current);\n\n // Iterate over the minified keys\n for (const key in MinifiedToKey) {\n // Get the value for the current key\n const value = current[key];\n\n // If the value is not null or undefined\n if (isNotNullish(value)) {\n // Get the key to use\n const keyToUse = MinifiedToKey[key];\n\n // If the key is data, then we may need to transform the keys\n // eslint-disable-next-line max-depth\n if (keyToUse === IsolateKeys.Data) {\n // Transform the keys\n current[keyToUse] = transformKeys(\n value,\n inverseMinimap?.keys?.data\n );\n } else {\n // Otherwise, just set the key\n current[keyToUse] = transformValueByKey(\n keyToUse,\n value,\n inverseMinimap\n );\n }\n\n // Remove the old key\n delete current[key];\n }\n }\n\n // If there are no children, nothing to do.\n if (!children) {\n continue;\n }\n\n // Copy the children and set their parent to the current node.\n current.children = children.map(child => {\n const nextChild = { ...child };\n\n IsolateMutator.setParent(nextChild, current);\n queue.push(nextChild);\n\n // If the child has a key, add it to the parent's keys.\n const key = nextChild.key;\n\n if (key) {\n current.keys = current.keys ?? {};\n current.keys[key] = nextChild;\n }\n\n return nextChild;\n });\n }\n\n return root as TIsolate;\n }\n\n static serialize(\n isolate: Nullable<TIsolate>,\n miniMaps: Maybe<MiniMaps>\n ): string {\n if (isNullish(isolate)) {\n return '';\n }\n\n return JSON.stringify(transformIsolate(isolate, miniMaps));\n }\n\n static expandChildren(node: Record<string, any>): Nullable<TIsolate[]> {\n return node[MinifiedKeys.Children]\n ? [...node[MinifiedKeys.Children]]\n : null;\n }\n\n static validateIsolate(node: Record<string, any> | TIsolate): void {\n invariant(\n hasOwnProperty(node, IsolateKeys.Type) ||\n hasOwnProperty(node, KeyToMinified[IsolateKeys.Type]),\n text(ErrorStrings.INVALID_ISOLATE_CANNOT_PARSE)\n );\n }\n}\n\n// eslint-disable-next-line max-statements, complexity\nfunction transformIsolate(\n isolate: TIsolate,\n miniMaps: Maybe<MiniMaps>\n): Record<string, any> {\n const next: Record<string, any> = {};\n\n if (isolate.children) {\n next[MinifiedKeys.Children] = isolate.children.map(isolate =>\n transformIsolate(isolate, miniMaps)\n );\n }\n\n if (!isEmpty(isolate.data)) {\n next[MinifiedKeys.Data] = transformKeys(isolate.data, miniMaps?.keys?.data);\n }\n\n for (const key in isolate) {\n // Skip keys that should be excluded from the dump.\n // While we're excluding children from the dump, they'll actually remain there\n // due to the fact that we've already transformed them recursively beforehand\n // thus renaming them to the minified key.\n if (isKeyExcluededFromDump(key)) {\n continue;\n }\n const value = isolate[key as keyof TIsolate];\n\n if (isNullish(value)) {\n continue;\n }\n\n const keyToUse = minifyKey(key);\n next[keyToUse] = transformValueByKey(key, value, miniMaps);\n }\n\n return next;\n}\n\nfunction isKeyExcluededFromDump(key: string): boolean {\n return ExcludedFromDump.includes(key as IsolateKeys);\n}\n\nfunction minifyKey(key: string): string {\n return KeyToMinified[key as keyof typeof KeyToMinified] ?? key;\n}\n\nfunction transformValueByKey(\n key: string,\n value: any,\n miniMaps: Maybe<MiniMaps>\n): any {\n if (isNullish(value)) {\n return value;\n }\n\n const keyMap = miniMaps?.values?.[key as keyof MiniMaps['values']];\n\n return keyMap ? keyMap[value] ?? value : value;\n}\n\nfunction transformKeys(\n data: Record<string, any>,\n keyMap: Maybe<MiniMap>\n): Record<string, any> {\n const next: Record<string, any> = {};\n\n // Loop over each key in the data.\n for (const key in data) {\n // Find the key to use for the next object.\n // If there is no key map, use the original key.\n // If there is a key map, use the key map entry for the current key.\n const keyToUse = (keyMap ? keyMap[key] : key) ?? key;\n\n // Add the key and value to the next object.\n next[keyToUse] = data[key];\n }\n\n // Return the next object.\n return next;\n}\n\ntype MiniMap = Record<string, string>;\n\ntype MiniMaps = Partial<{\n keys: Partial<{\n [IsolateKeys.Data]: MiniMap;\n }>;\n values: Partial<{\n [IsolateKeys.Status]: MiniMap;\n [IsolateKeys.Type]: MiniMap;\n }>;\n}>;\n\nexport function deeplyInvertKeyMap(miniMaps: Maybe<MiniMaps> = {}): MiniMaps {\n return Object.entries(miniMaps).reduce((acc, [key, value]) => {\n if (typeof value === 'object') {\n return assign(acc, {\n [key]: deeplyInvertKeyMap(value as MiniMaps),\n });\n }\n return assign(acc, {\n [value]: key,\n });\n }, {} as MiniMaps);\n}\n"],"names":["ErrorStrings","IsolateKeys","MinifiedKeys","KeyToMinified","Type","Keys","Parent","Data","Key","AllowReorder","Status","Children","MinifiedToKey","miniMap","Object","entries","reduce","acc","key","minified","assign","invertKeyMap","ExcludedFromDump","AbortController","IsolateMutator","static","isolate","parent","output","child","invariant","children","_a","push","setParent","node","_b","filter","keys","at","isNullish","length","data","reason","abortController","abort","IsolateSerializer","miniMaps","inverseMinimap","deeplyInvertKeyMap","root","isStringValue","JSON","parse","validateIsolate","queue","current","shift","expandChildren","value","isNotNullish","keyToUse","transformKeys","transformValueByKey","map","nextChild","stringify","transformIsolate","hasOwnProperty","text","INVALID_ISOLATE_CANNOT_PARSE","next","isEmpty","isKeyExcluededFromDump","minifyKey","includes","keyMap","values"],"mappings":"iBAAYA,ECEAC,EAYAC,2BDdZ,SAAYF,GACVA,EAAA,kBAAA,+BACAA,EAAA,4BAAA,wFACAA,EAAA,+BAAA,kGACAA,EAAA,6BAAA,kEACD,CALD,CAAYA,IAAAA,EAKX,CAAA,ICHD,SAAYC,GACVA,EAAA,KAAA,QACAA,EAAA,KAAA,OACAA,EAAA,IAAA,MACAA,EAAA,OAAA,SACAA,EAAA,KAAA,OACAA,EAAA,aAAA,eACAA,EAAA,OAAA,SACAA,EAAA,gBAAA,kBACAA,EAAA,SAAA,UACD,CAVD,CAAYA,IAAAA,EAUX,CAAA,IAED,SAAYC,GACVA,EAAA,KAAA,IACAA,EAAA,KAAA,KACAA,EAAA,IAAA,KACAA,EAAA,OAAA,IACAA,EAAA,KAAA,IACAA,EAAA,aAAA,KACAA,EAAA,OAAA,IACAA,EAAA,SAAA,GACD,CATD,CAAYA,IAAAA,EASX,CAAA,IAEM,MAAMC,EAAgB,CAC3B,CAACF,EAAYG,MAAOF,EAAaE,KACjC,CAACH,EAAYI,MAAOH,EAAaG,KACjC,CAACJ,EAAYK,QAASJ,EAAaI,OACnC,CAACL,EAAYM,MAAOL,EAAaK,KACjC,CAACN,EAAYO,KAAMN,EAAaM,IAChC,CAACP,EAAYQ,cAAeP,EAAaO,aACzC,CAACR,EAAYS,QAASR,EAAaQ,OACnC,CAACT,EAAYU,UAAWT,EAAaS,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AAMC,EAAKyC,KAC5B,iBAAVA,EACFvC,EAAAA,OAAOH,EAAK,CACjBC,CAACA,GAAM+B,EAAmBU,KAGvBvC,EAAAA,OAAOH,EAAK,CACjB0C,CAACA,GAAQzC,KAEV,CAAc,EACnB"}
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ var vestUtils = require('vest-utils');
4
+
3
5
  /******************************************************************************
4
6
  Copyright (c) Microsoft Corporation.
5
7
 
@@ -44,16 +46,18 @@ var IsolateKeys;
44
46
  IsolateKeys["AllowReorder"] = "allowReorder";
45
47
  IsolateKeys["Status"] = "status";
46
48
  IsolateKeys["AbortController"] = "abortController";
49
+ IsolateKeys["Children"] = "children";
47
50
  })(IsolateKeys || (IsolateKeys = {}));
48
51
  var MinifiedKeys;
49
52
  (function (MinifiedKeys) {
50
53
  MinifiedKeys["Type"] = "$";
51
- MinifiedKeys["Keys"] = "K";
52
- MinifiedKeys["Key"] = "k";
54
+ MinifiedKeys["Keys"] = "Ks";
55
+ MinifiedKeys["Key"] = "ky";
53
56
  MinifiedKeys["Parent"] = "P";
54
57
  MinifiedKeys["Data"] = "D";
55
- MinifiedKeys["AllowReorder"] = "aR";
58
+ MinifiedKeys["AllowReorder"] = "AR";
56
59
  MinifiedKeys["Status"] = "S";
60
+ MinifiedKeys["Children"] = "C";
57
61
  })(MinifiedKeys || (MinifiedKeys = {}));
58
62
  const KeyToMinified = {
59
63
  [IsolateKeys.Type]: MinifiedKeys.Type,
@@ -63,6 +67,7 @@ const KeyToMinified = {
63
67
  [IsolateKeys.Key]: MinifiedKeys.Key,
64
68
  [IsolateKeys.AllowReorder]: MinifiedKeys.AllowReorder,
65
69
  [IsolateKeys.Status]: MinifiedKeys.Status,
70
+ [IsolateKeys.Children]: MinifiedKeys.Children,
66
71
  };
67
72
  // This const is an object that looks like this:
68
73
  // {
@@ -71,13 +76,18 @@ const KeyToMinified = {
71
76
  // 'P': 'parent',
72
77
  // ...
73
78
  // }
74
- Object.entries(KeyToMinified).reduce((acc, [key, minified]) => Object.assign(acc, {
75
- [minified]: key,
76
- }), {});
79
+ invertKeyMap(KeyToMinified);
80
+ function invertKeyMap(miniMap = {}) {
81
+ return Object.entries(miniMap).reduce((acc, [key, minified]) => vestUtils.assign(acc, {
82
+ [minified]: key,
83
+ }), {});
84
+ }
77
85
  [
78
86
  IsolateKeys.AbortController,
79
87
  IsolateKeys.Parent,
80
88
  IsolateKeys.Keys,
89
+ IsolateKeys.Children,
90
+ IsolateKeys.Data,
81
91
  ];
82
92
 
83
93
  function genTestIsolate(payload = {}) {
@@ -1 +1 @@
1
- {"version":3,"file":"test-utils.development.js","sources":["../../src/Isolate/IsolateKeys.ts","../../src/exports/test-utils.ts"],"sourcesContent":["export enum IsolateKeys {\n Type = '$type',\n Keys = 'keys',\n Key = 'key',\n Parent = 'parent',\n Data = 'data',\n AllowReorder = 'allowReorder',\n Status = 'status',\n AbortController = 'abortController',\n}\n\nenum MinifiedKeys {\n Type = '$',\n Keys = 'K',\n Key = 'k',\n Parent = 'P',\n Data = 'D',\n AllowReorder = 'aR',\n Status = 'S',\n}\n\nexport const KeyToMinified = {\n [IsolateKeys.Type]: MinifiedKeys.Type,\n [IsolateKeys.Keys]: MinifiedKeys.Keys,\n [IsolateKeys.Parent]: MinifiedKeys.Parent,\n [IsolateKeys.Data]: MinifiedKeys.Data,\n [IsolateKeys.Key]: MinifiedKeys.Key,\n [IsolateKeys.AllowReorder]: MinifiedKeys.AllowReorder,\n [IsolateKeys.Status]: MinifiedKeys.Status,\n};\n\n// This const is an object that looks like this:\n// {\n// '$': '$type',\n// 'K': 'keys',\n// 'P': 'parent',\n// ...\n// }\nexport const MinifiedToKey = Object.entries(KeyToMinified).reduce(\n (acc, [key, minified]) =>\n Object.assign(acc, {\n [minified]: key,\n }),\n {} as Record<string, IsolateKeys>\n);\n\nexport const ExcludedFromDump = [\n IsolateKeys.AbortController,\n IsolateKeys.Parent,\n IsolateKeys.Keys,\n];\n","import { TIsolate } from 'Isolate';\nimport { IsolateKeys } from 'IsolateKeys';\n\nexport function genTestIsolate(payload: Record<string, any> = {}): TIsolate {\n const { status, ...data } = payload;\n return {\n children: [],\n data,\n key: null,\n keys: {},\n output: null,\n parent: null,\n [IsolateKeys.Type]: 'UnitTest',\n ...(status && { status }),\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAY,WASX,CAAA;AATD,CAAA,UAAY,WAAW,EAAA;AACrB,IAAA,WAAA,CAAA,MAAA,CAAA,GAAA,OAAc,CAAA;AACd,IAAA,WAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACb,IAAA,WAAA,CAAA,KAAA,CAAA,GAAA,KAAW,CAAA;AACX,IAAA,WAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,WAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACb,IAAA,WAAA,CAAA,cAAA,CAAA,GAAA,cAA6B,CAAA;AAC7B,IAAA,WAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,WAAA,CAAA,iBAAA,CAAA,GAAA,iBAAmC,CAAA;AACrC,CAAC,EATW,WAAW,KAAX,WAAW,GAStB,EAAA,CAAA,CAAA,CAAA;AAED,IAAK,YAQJ,CAAA;AARD,CAAA,UAAK,YAAY,EAAA;AACf,IAAA,YAAA,CAAA,MAAA,CAAA,GAAA,GAAU,CAAA;AACV,IAAA,YAAA,CAAA,MAAA,CAAA,GAAA,GAAU,CAAA;AACV,IAAA,YAAA,CAAA,KAAA,CAAA,GAAA,GAAS,CAAA;AACT,IAAA,YAAA,CAAA,QAAA,CAAA,GAAA,GAAY,CAAA;AACZ,IAAA,YAAA,CAAA,MAAA,CAAA,GAAA,GAAU,CAAA;AACV,IAAA,YAAA,CAAA,cAAA,CAAA,GAAA,IAAmB,CAAA;AACnB,IAAA,YAAA,CAAA,QAAA,CAAA,GAAA,GAAY,CAAA;AACd,CA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CAAC,IAAI,GAAG,UAAU,EAAA,GAC1B,MAAM,IAAI,EAAE,MAAM,EAAE,EACxB,CAAA;AACJ;;;;"}
1
+ {"version":3,"file":"test-utils.development.js","sources":["../../src/Isolate/IsolateKeys.ts","../../src/exports/test-utils.ts"],"sourcesContent":["import { assign } from 'vest-utils';\n\nexport enum IsolateKeys {\n Type = '$type',\n Keys = 'keys',\n Key = 'key',\n Parent = 'parent',\n Data = 'data',\n AllowReorder = 'allowReorder',\n Status = 'status',\n AbortController = 'abortController',\n Children = 'children',\n}\n\nexport enum MinifiedKeys {\n Type = '$',\n Keys = 'Ks',\n Key = 'ky',\n Parent = 'P',\n Data = 'D',\n AllowReorder = 'AR',\n Status = 'S',\n Children = 'C',\n}\n\nexport const KeyToMinified = {\n [IsolateKeys.Type]: MinifiedKeys.Type,\n [IsolateKeys.Keys]: MinifiedKeys.Keys,\n [IsolateKeys.Parent]: MinifiedKeys.Parent,\n [IsolateKeys.Data]: MinifiedKeys.Data,\n [IsolateKeys.Key]: MinifiedKeys.Key,\n [IsolateKeys.AllowReorder]: MinifiedKeys.AllowReorder,\n [IsolateKeys.Status]: MinifiedKeys.Status,\n [IsolateKeys.Children]: MinifiedKeys.Children,\n};\n\n// This const is an object that looks like this:\n// {\n// '$': '$type',\n// 'K': 'keys',\n// 'P': 'parent',\n// ...\n// }\nexport const MinifiedToKey = invertKeyMap(KeyToMinified);\n\nexport function invertKeyMap(miniMap: Record<string, string> = {}) {\n return Object.entries(miniMap).reduce(\n (acc, [key, minified]) =>\n assign(acc, {\n [minified]: key,\n }),\n {} as Record<string, string>\n );\n}\n\nexport const ExcludedFromDump = [\n IsolateKeys.AbortController,\n IsolateKeys.Parent,\n IsolateKeys.Keys,\n IsolateKeys.Children,\n IsolateKeys.Data,\n];\n","import { TIsolate } from 'Isolate';\nimport { IsolateKeys } from 'IsolateKeys';\n\nexport function genTestIsolate(payload: Record<string, any> = {}): TIsolate {\n const { status, ...data } = payload;\n return {\n children: [],\n data,\n key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,EAA7B,CAAmB,QAAA,CAAA,CAAU,CAAC;AACpC,IAAA,OAAA,MAAA,CAAA,MAAA,CAAA,EACE,QAAQ,EAAE,EAAE,EACZ,IAAI,EACJ,GAAG,EAAE,IAAI,EACT,IAAI,EAAE,EAAE,EACR,MAAM,EAAE,IAAI,EACZ,MAAM,EAAE,IAAI,EACZ,CAAC,WAAW,CAAC,IAAI,GAAG,UAAU,EAAA,GAC1B,MAAM,IAAI,EAAE,MAAM,EAAE,EACxB,CAAA;AACJ;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";var e,t;"function"==typeof SuppressedError&&SuppressedError,function(e){e.Type="$type",e.Keys="keys",e.Key="key",e.Parent="parent",e.Data="data",e.AllowReorder="allowReorder",e.Status="status",e.AbortController="abortController"}(e||(e={})),function(e){e.Type="$",e.Keys="K",e.Key="k",e.Parent="P",e.Data="D",e.AllowReorder="aR",e.Status="S"}(t||(t={}));const r={[e.Type]:t.Type,[e.Keys]:t.Keys,[e.Parent]:t.Parent,[e.Data]:t.Data,[e.Key]:t.Key,[e.AllowReorder]:t.AllowReorder,[e.Status]:t.Status};Object.entries(r).reduce(((e,[t,r])=>Object.assign(e,{[r]:t})),{}),e.AbortController,e.Parent,e.Keys,exports.genTestIsolate=function(t={}){const{status:r}=t,o=function(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]])}return r}(t,["status"]);return Object.assign({children:[],data:o,key:null,keys:{},output:null,parent:null,[e.Type]:"UnitTest"},r&&{status:r})};
1
+ "use strict";var e,t,r=require("vest-utils");"function"==typeof SuppressedError&&SuppressedError,function(e){e.Type="$type",e.Keys="keys",e.Key="key",e.Parent="parent",e.Data="data",e.AllowReorder="allowReorder",e.Status="status",e.AbortController="abortController",e.Children="children"}(e||(e={})),function(e){e.Type="$",e.Keys="Ks",e.Key="ky",e.Parent="P",e.Data="D",e.AllowReorder="AR",e.Status="S",e.Children="C"}(t||(t={}));!function(e={}){Object.entries(e).reduce(((e,[t,n])=>r.assign(e,{[n]:t})),{})}({[e.Type]:t.Type,[e.Keys]:t.Keys,[e.Parent]:t.Parent,[e.Data]:t.Data,[e.Key]:t.Key,[e.AllowReorder]:t.AllowReorder,[e.Status]:t.Status,[e.Children]:t.Children}),e.AbortController,e.Parent,e.Keys,e.Children,e.Data,exports.genTestIsolate=function(t={}){const{status:r}=t,n=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(t,["status"]);return Object.assign({children:[],data:n,key:null,keys:{},output:null,parent:null,[e.Type]:"UnitTest"},r&&{status:r})};
2
2
  //# sourceMappingURL=test-utils.production.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"test-utils.production.js","sources":["../../src/Isolate/IsolateKeys.ts","../../src/exports/test-utils.ts"],"sourcesContent":["export enum IsolateKeys {\n Type = '$type',\n Keys = 'keys',\n Key = 'key',\n Parent = 'parent',\n Data = 'data',\n AllowReorder = 'allowReorder',\n Status = 'status',\n AbortController = 'abortController',\n}\n\nenum MinifiedKeys {\n Type = '$',\n Keys = 'K',\n Key = 'k',\n Parent = 'P',\n Data = 'D',\n AllowReorder = 'aR',\n Status = 'S',\n}\n\nexport const KeyToMinified = {\n [IsolateKeys.Type]: MinifiedKeys.Type,\n [IsolateKeys.Keys]: MinifiedKeys.Keys,\n [IsolateKeys.Parent]: MinifiedKeys.Parent,\n [IsolateKeys.Data]: MinifiedKeys.Data,\n [IsolateKeys.Key]: MinifiedKeys.Key,\n [IsolateKeys.AllowReorder]: MinifiedKeys.AllowReorder,\n [IsolateKeys.Status]: MinifiedKeys.Status,\n};\n\n// This const is an object that looks like this:\n// {\n// '$': '$type',\n// 'K': 'keys',\n// 'P': 'parent',\n// ...\n// }\nexport const MinifiedToKey = Object.entries(KeyToMinified).reduce(\n (acc, [key, minified]) =>\n Object.assign(acc, {\n [minified]: key,\n }),\n {} as Record<string, IsolateKeys>\n);\n\nexport const ExcludedFromDump = [\n IsolateKeys.AbortController,\n IsolateKeys.Parent,\n IsolateKeys.Keys,\n];\n","import { TIsolate } from 'Isolate';\nimport { IsolateKeys } from 'IsolateKeys';\n\nexport function genTestIsolate(payload: Record<string, any> = {}): TIsolate {\n const { status, ...data } = payload;\n return {\n children: [],\n data,\n key: null,\n keys: {},\n output: null,\n parent: null,\n [IsolateKeys.Type]: 'UnitTest',\n ...(status && { status }),\n };\n}\n"],"names":["IsolateKeys","MinifiedKeys","KeyToMinified","Type","Keys","Parent","Data","Key","AllowReorder","Status","Object","entries","reduce","acc","key","minified","assign","AbortController","payload","status","data","__rest","children","keys","output","parent"],"mappings":"aAAA,IAAYA,EAWPC,sDAXL,SAAYD,GACVA,EAAA,KAAA,QACAA,EAAA,KAAA,OACAA,EAAA,IAAA,MACAA,EAAA,OAAA,SACAA,EAAA,KAAA,OACAA,EAAA,aAAA,eACAA,EAAA,OAAA,SACAA,EAAA,gBAAA,iBACD,CATD,CAAYA,IAAAA,EASX,CAAA,IAED,SAAKC,GACHA,EAAA,KAAA,IACAA,EAAA,KAAA,IACAA,EAAA,IAAA,IACAA,EAAA,OAAA,IACAA,EAAA,KAAA,IACAA,EAAA,aAAA,KACAA,EAAA,OAAA,GACD,CARD,CAAKA,IAAAA,EAQJ,CAAA,IAEM,MAAMC,EAAgB,CAC3B,CAACF,EAAYG,MAAOF,EAAaE,KACjC,CAACH,EAAYI,MAAOH,EAAaG,KACjC,CAACJ,EAAYK,QAASJ,EAAaI,OACnC,CAACL,EAAYM,MAAOL,EAAaK,KACjC,CAACN,EAAYO,KAAMN,EAAaM,IAChC,CAACP,EAAYQ,cAAeP,EAAaO,aACzC,CAACR,EAAYS,QAASR,EAAaQ,QAURC,OAAOC,QAAQT,GAAeU,QACzD,CAACC,GAAMC,EAAKC,KACVL,OAAOM,OAAOH,EAAK,CACjBE,CAACA,GAAWD,KAEhB,CAAA,GAIAd,EAAYiB,gBACZjB,EAAYK,OACZL,EAAYI,4BC9CE,SAAec,EAA+B,IAC5D,MAAMC,OAAEA,GAAoBD,EAATE,2UAAIC,CAAKH,EAAtB,CAAmB,WACzB,OAAAR,OAAAM,OAAA,CACEM,SAAU,GACVF,OACAN,IAAK,KACLS,KAAM,GACNC,OAAQ,KACRC,OAAQ,KACR,CAACzB,EAAYG,MAAO,YAChBgB,GAAU,CAAEA,UAEpB"}
1
+ {"version":3,"file":"test-utils.production.js","sources":["../../src/Isolate/IsolateKeys.ts","../../src/exports/test-utils.ts"],"sourcesContent":["import { assign } from 'vest-utils';\n\nexport enum IsolateKeys {\n Type = '$type',\n Keys = 'keys',\n Key = 'key',\n Parent = 'parent',\n Data = 'data',\n AllowReorder = 'allowReorder',\n Status = 'status',\n AbortController = 'abortController',\n Children = 'children',\n}\n\nexport enum MinifiedKeys {\n Type = '$',\n Keys = 'Ks',\n Key = 'ky',\n Parent = 'P',\n Data = 'D',\n AllowReorder = 'AR',\n Status = 'S',\n Children = 'C',\n}\n\nexport const KeyToMinified = {\n [IsolateKeys.Type]: MinifiedKeys.Type,\n [IsolateKeys.Keys]: MinifiedKeys.Keys,\n [IsolateKeys.Parent]: MinifiedKeys.Parent,\n [IsolateKeys.Data]: MinifiedKeys.Data,\n [IsolateKeys.Key]: MinifiedKeys.Key,\n [IsolateKeys.AllowReorder]: MinifiedKeys.AllowReorder,\n [IsolateKeys.Status]: MinifiedKeys.Status,\n [IsolateKeys.Children]: MinifiedKeys.Children,\n};\n\n// This const is an object that looks like this:\n// {\n// '$': '$type',\n// 'K': 'keys',\n// 'P': 'parent',\n// ...\n// }\nexport const MinifiedToKey = invertKeyMap(KeyToMinified);\n\nexport function invertKeyMap(miniMap: Record<string, string> = {}) {\n return Object.entries(miniMap).reduce(\n (acc, [key, minified]) =>\n assign(acc, {\n [minified]: key,\n }),\n {} as Record<string, string>\n );\n}\n\nexport const ExcludedFromDump = [\n IsolateKeys.AbortController,\n IsolateKeys.Parent,\n IsolateKeys.Keys,\n IsolateKeys.Children,\n IsolateKeys.Data,\n];\n","import { TIsolate } from 'Isolate';\nimport { IsolateKeys } from 'IsolateKeys';\n\nexport function genTestIsolate(payload: Record<string, any> = {}): TIsolate {\n const { status, ...data } = payload;\n return {\n children: [],\n data,\n key: null,\n keys: {},\n output: null,\n parent: null,\n [IsolateKeys.Type]: 'UnitTest',\n ...(status && { status }),\n };\n}\n"],"names":["IsolateKeys","MinifiedKeys","miniMap","Object","entries","reduce","acc","key","minified","assign","invertKeyMap","Type","Keys","Parent","Data","Key","AllowReorder","Status","Children","AbortController","payload","status","data","__rest","children","keys","output","parent"],"mappings":"iBAEYA,EAYAC,8EAZZ,SAAYD,GACVA,EAAA,KAAA,QACAA,EAAA,KAAA,OACAA,EAAA,IAAA,MACAA,EAAA,OAAA,SACAA,EAAA,KAAA,OACAA,EAAA,aAAA,eACAA,EAAA,OAAA,SACAA,EAAA,gBAAA,kBACAA,EAAA,SAAA,UACD,CAVD,CAAYA,IAAAA,EAUX,CAAA,IAED,SAAYC,GACVA,EAAA,KAAA,IACAA,EAAA,KAAA,KACAA,EAAA,IAAA,KACAA,EAAA,OAAA,IACAA,EAAA,KAAA,IACAA,EAAA,aAAA,KACAA,EAAA,OAAA,IACAA,EAAA,SAAA,GACD,CATD,CAAYA,IAAAA,EASX,CAAA,KAsBe,SAAaC,EAAkC,IACtDC,OAAOC,QAAQF,GAASG,QAC7B,CAACC,GAAMC,EAAKC,KACVC,EAAAA,OAAOH,EAAK,CACVE,CAACA,GAAWD,KAEhB,CAA4B,EAEhC,CAV6BG,CAlBA,CAC3B,CAACV,EAAYW,MAAOV,EAAaU,KACjC,CAACX,EAAYY,MAAOX,EAAaW,KACjC,CAACZ,EAAYa,QAASZ,EAAaY,OACnC,CAACb,EAAYc,MAAOb,EAAaa,KACjC,CAACd,EAAYe,KAAMd,EAAac,IAChC,CAACf,EAAYgB,cAAef,EAAae,aACzC,CAAChB,EAAYiB,QAAShB,EAAagB,OACnC,CAACjB,EAAYkB,UAAWjB,EAAaiB,WAuBrClB,EAAYmB,gBACZnB,EAAYa,OACZb,EAAYY,KACZZ,EAAYkB,SACZlB,EAAYc,4BCzDE,SAAeM,EAA+B,IAC5D,MAAMC,OAAEA,GAAoBD,EAATE,2UAAIC,CAAKH,EAAtB,CAAmB,WACzB,OAAAjB,OAAAM,OAAA,CACEe,SAAU,GACVF,OACAf,IAAK,KACLkB,KAAM,GACNC,OAAQ,KACRC,OAAQ,KACR,CAAC3B,EAAYW,MAAO,YAChBU,GAAU,CAAEA,UAEpB"}