vestjs-runtime 1.1.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/IsolateSerializer.development.js +114 -26
- package/dist/cjs/IsolateSerializer.development.js.map +1 -1
- package/dist/cjs/IsolateSerializer.production.js +1 -1
- package/dist/cjs/IsolateSerializer.production.js.map +1 -1
- package/dist/cjs/test-utils.development.js +22 -6
- package/dist/cjs/test-utils.development.js.map +1 -1
- package/dist/cjs/test-utils.production.js +1 -1
- package/dist/cjs/test-utils.production.js.map +1 -1
- package/dist/cjs/vestjs-runtime.development.js +114 -27
- package/dist/cjs/vestjs-runtime.development.js.map +1 -1
- package/dist/cjs/vestjs-runtime.production.js +1 -1
- package/dist/cjs/vestjs-runtime.production.js.map +1 -1
- package/dist/es/IsolateSerializer.development.js +115 -28
- package/dist/es/IsolateSerializer.development.js.map +1 -1
- package/dist/es/IsolateSerializer.production.js +1 -1
- package/dist/es/IsolateSerializer.production.js.map +1 -1
- package/dist/es/test-utils.development.js +22 -6
- package/dist/es/test-utils.development.js.map +1 -1
- package/dist/es/test-utils.production.js +1 -1
- package/dist/es/test-utils.production.js.map +1 -1
- package/dist/es/vestjs-runtime.development.js +115 -28
- package/dist/es/vestjs-runtime.development.js.map +1 -1
- package/dist/es/vestjs-runtime.production.js +1 -1
- package/dist/es/vestjs-runtime.production.js.map +1 -1
- package/dist/umd/IsolateSerializer.development.js +117 -30
- package/dist/umd/IsolateSerializer.development.js.map +1 -1
- package/dist/umd/IsolateSerializer.production.js +1 -1
- package/dist/umd/IsolateSerializer.production.js.map +1 -1
- package/dist/umd/test-utils.development.js +24 -10
- package/dist/umd/test-utils.development.js.map +1 -1
- package/dist/umd/test-utils.production.js +1 -1
- package/dist/umd/test-utils.production.js.map +1 -1
- package/dist/umd/vestjs-runtime.development.js +117 -31
- package/dist/umd/vestjs-runtime.development.js.map +1 -1
- package/dist/umd/vestjs-runtime.production.js +1 -1
- package/dist/umd/vestjs-runtime.production.js.map +1 -1
- package/package.json +3 -3
- package/types/IsolateSerializer.d.ts +22 -7
- package/types/IsolateSerializer.d.ts.map +1 -1
- package/types/test-utils.d.ts +5 -1
- package/types/test-utils.d.ts.map +1 -1
- package/types/vestjs-runtime.d.ts +51 -21
- package/types/vestjs-runtime.d.ts.map +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var vestUtils = require('vest-utils');
|
|
4
|
+
var lodash = require('lodash');
|
|
4
5
|
|
|
5
6
|
var ErrorStrings;
|
|
6
7
|
(function (ErrorStrings) {
|
|
@@ -19,16 +20,19 @@ var IsolateKeys;
|
|
|
19
20
|
IsolateKeys["Data"] = "data";
|
|
20
21
|
IsolateKeys["AllowReorder"] = "allowReorder";
|
|
21
22
|
IsolateKeys["Status"] = "status";
|
|
23
|
+
IsolateKeys["AbortController"] = "abortController";
|
|
24
|
+
IsolateKeys["Children"] = "children";
|
|
22
25
|
})(IsolateKeys || (IsolateKeys = {}));
|
|
23
26
|
var MinifiedKeys;
|
|
24
27
|
(function (MinifiedKeys) {
|
|
25
28
|
MinifiedKeys["Type"] = "$";
|
|
26
|
-
MinifiedKeys["Keys"] = "
|
|
27
|
-
MinifiedKeys["Key"] = "
|
|
29
|
+
MinifiedKeys["Keys"] = "Ks";
|
|
30
|
+
MinifiedKeys["Key"] = "ky";
|
|
28
31
|
MinifiedKeys["Parent"] = "P";
|
|
29
32
|
MinifiedKeys["Data"] = "D";
|
|
30
|
-
MinifiedKeys["AllowReorder"] = "
|
|
33
|
+
MinifiedKeys["AllowReorder"] = "AR";
|
|
31
34
|
MinifiedKeys["Status"] = "S";
|
|
35
|
+
MinifiedKeys["Children"] = "C";
|
|
32
36
|
})(MinifiedKeys || (MinifiedKeys = {}));
|
|
33
37
|
const KeyToMinified = {
|
|
34
38
|
[IsolateKeys.Type]: MinifiedKeys.Type,
|
|
@@ -38,6 +42,7 @@ const KeyToMinified = {
|
|
|
38
42
|
[IsolateKeys.Key]: MinifiedKeys.Key,
|
|
39
43
|
[IsolateKeys.AllowReorder]: MinifiedKeys.AllowReorder,
|
|
40
44
|
[IsolateKeys.Status]: MinifiedKeys.Status,
|
|
45
|
+
[IsolateKeys.Children]: MinifiedKeys.Children,
|
|
41
46
|
};
|
|
42
47
|
// This const is an object that looks like this:
|
|
43
48
|
// {
|
|
@@ -46,9 +51,19 @@ const KeyToMinified = {
|
|
|
46
51
|
// 'P': 'parent',
|
|
47
52
|
// ...
|
|
48
53
|
// }
|
|
49
|
-
const MinifiedToKey =
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
const MinifiedToKey = invertKeyMap(KeyToMinified);
|
|
55
|
+
function invertKeyMap(miniMap = {}) {
|
|
56
|
+
return Object.entries(miniMap).reduce((acc, [key, minified]) => lodash.assign(acc, {
|
|
57
|
+
[minified]: key,
|
|
58
|
+
}), {});
|
|
59
|
+
}
|
|
60
|
+
const ExcludedFromDump = [
|
|
61
|
+
IsolateKeys.AbortController,
|
|
62
|
+
IsolateKeys.Parent,
|
|
63
|
+
IsolateKeys.Keys,
|
|
64
|
+
IsolateKeys.Children,
|
|
65
|
+
IsolateKeys.Data,
|
|
66
|
+
];
|
|
52
67
|
|
|
53
68
|
class IsolateMutator {
|
|
54
69
|
static setParent(isolate, parent) {
|
|
@@ -90,11 +105,18 @@ class IsolateMutator {
|
|
|
90
105
|
static setData(isolate, data) {
|
|
91
106
|
isolate.data = data;
|
|
92
107
|
}
|
|
108
|
+
static abort(isolate, reason) {
|
|
109
|
+
if (vestUtils.isNullish(isolate.abortController)) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
isolate.abortController.abort(reason);
|
|
113
|
+
}
|
|
93
114
|
}
|
|
94
115
|
|
|
95
116
|
class IsolateSerializer {
|
|
96
|
-
// eslint-disable-next-line max-statements, complexity
|
|
97
|
-
static deserialize(node) {
|
|
117
|
+
// eslint-disable-next-line max-statements, complexity, max-lines-per-function
|
|
118
|
+
static deserialize(node, miniMaps) {
|
|
119
|
+
var _a;
|
|
98
120
|
// the assumption is that the tree is built correctly,
|
|
99
121
|
// but the children are missing the parent property to
|
|
100
122
|
// avoid circular references during serialization.
|
|
@@ -102,29 +124,52 @@ class IsolateSerializer {
|
|
|
102
124
|
// to avoid circular references during serialization.
|
|
103
125
|
// we need to rebuild the tree and add back the parent property to the children
|
|
104
126
|
// and the keys property to the parents.
|
|
127
|
+
const inverseMinimap = deeplyInvertKeyMap(miniMaps);
|
|
128
|
+
// Validate the root object
|
|
105
129
|
const root = vestUtils.isStringValue(node)
|
|
106
130
|
? JSON.parse(node)
|
|
107
131
|
: Object.assign({}, node);
|
|
108
132
|
IsolateSerializer.validateIsolate(root);
|
|
109
133
|
const queue = [root];
|
|
134
|
+
// Iterate over the queue until it's empty
|
|
110
135
|
while (queue.length) {
|
|
136
|
+
// Get the next item from the queue
|
|
111
137
|
const current = queue.shift();
|
|
112
|
-
|
|
138
|
+
// Get the children of the current item
|
|
139
|
+
const children = IsolateSerializer.expandChildren(current);
|
|
140
|
+
// Iterate over the minified keys
|
|
113
141
|
for (const key in MinifiedToKey) {
|
|
142
|
+
// Get the value for the current key
|
|
114
143
|
const value = current[key];
|
|
144
|
+
// If the value is not null or undefined
|
|
115
145
|
if (vestUtils.isNotNullish(value)) {
|
|
116
|
-
|
|
146
|
+
// Get the key to use
|
|
147
|
+
const keyToUse = MinifiedToKey[key];
|
|
148
|
+
// If the key is data, then we may need to transform the keys
|
|
149
|
+
// eslint-disable-next-line max-depth
|
|
150
|
+
if (keyToUse === IsolateKeys.Data) {
|
|
151
|
+
// Transform the keys
|
|
152
|
+
current[keyToUse] = transformKeys(value, (_a = inverseMinimap === null || inverseMinimap === void 0 ? void 0 : inverseMinimap.keys) === null || _a === void 0 ? void 0 : _a.data);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
// Otherwise, just set the key
|
|
156
|
+
current[keyToUse] = transformValueByKey(keyToUse, value, inverseMinimap);
|
|
157
|
+
}
|
|
158
|
+
// Remove the old key
|
|
117
159
|
delete current[key];
|
|
118
160
|
}
|
|
119
161
|
}
|
|
162
|
+
// If there are no children, nothing to do.
|
|
120
163
|
if (!children) {
|
|
121
164
|
continue;
|
|
122
165
|
}
|
|
166
|
+
// Copy the children and set their parent to the current node.
|
|
123
167
|
current.children = children.map(child => {
|
|
124
168
|
var _a;
|
|
125
169
|
const nextChild = Object.assign({}, child);
|
|
126
170
|
IsolateMutator.setParent(nextChild, current);
|
|
127
171
|
queue.push(nextChild);
|
|
172
|
+
// If the child has a key, add it to the parent's keys.
|
|
128
173
|
const key = nextChild.key;
|
|
129
174
|
if (key) {
|
|
130
175
|
current.keys = (_a = current.keys) !== null && _a !== void 0 ? _a : {};
|
|
@@ -135,14 +180,16 @@ class IsolateSerializer {
|
|
|
135
180
|
}
|
|
136
181
|
return root;
|
|
137
182
|
}
|
|
138
|
-
static serialize(isolate) {
|
|
183
|
+
static serialize(isolate, miniMaps) {
|
|
139
184
|
if (vestUtils.isNullish(isolate)) {
|
|
140
185
|
return '';
|
|
141
186
|
}
|
|
142
|
-
return JSON.stringify(transformIsolate(isolate));
|
|
187
|
+
return JSON.stringify(transformIsolate(isolate, miniMaps));
|
|
143
188
|
}
|
|
144
|
-
static
|
|
145
|
-
return node
|
|
189
|
+
static expandChildren(node) {
|
|
190
|
+
return node[MinifiedKeys.Children]
|
|
191
|
+
? [...node[MinifiedKeys.Children]]
|
|
192
|
+
: null;
|
|
146
193
|
}
|
|
147
194
|
static validateIsolate(node) {
|
|
148
195
|
vestUtils.invariant(vestUtils.hasOwnProperty(node, IsolateKeys.Type) ||
|
|
@@ -150,15 +197,20 @@ class IsolateSerializer {
|
|
|
150
197
|
}
|
|
151
198
|
}
|
|
152
199
|
// eslint-disable-next-line max-statements, complexity
|
|
153
|
-
function transformIsolate(isolate) {
|
|
200
|
+
function transformIsolate(isolate, miniMaps) {
|
|
201
|
+
var _a;
|
|
154
202
|
const next = {};
|
|
155
203
|
if (isolate.children) {
|
|
156
|
-
next.
|
|
204
|
+
next[MinifiedKeys.Children] = isolate.children.map(isolate => transformIsolate(isolate, miniMaps));
|
|
205
|
+
}
|
|
206
|
+
if (!vestUtils.isEmpty(isolate.data)) {
|
|
207
|
+
next[MinifiedKeys.Data] = transformKeys(isolate.data, (_a = miniMaps === null || miniMaps === void 0 ? void 0 : miniMaps.keys) === null || _a === void 0 ? void 0 : _a.data);
|
|
157
208
|
}
|
|
158
209
|
for (const key in isolate) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
210
|
+
// Skip keys that should be excluded from the dump.
|
|
211
|
+
// While we're excluding children from the dump, they'll actually remain there
|
|
212
|
+
// due to the fact that we've already transformed them recursively beforehand
|
|
213
|
+
// thus renaming them to the minified key.
|
|
162
214
|
if (isKeyExcluededFromDump(key)) {
|
|
163
215
|
continue;
|
|
164
216
|
}
|
|
@@ -166,18 +218,54 @@ function transformIsolate(isolate) {
|
|
|
166
218
|
if (vestUtils.isNullish(value)) {
|
|
167
219
|
continue;
|
|
168
220
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
next[key] = value;
|
|
174
|
-
}
|
|
221
|
+
const keyToUse = minifyKey(key);
|
|
222
|
+
next[keyToUse] = transformValueByKey(key, value, miniMaps);
|
|
175
223
|
}
|
|
176
224
|
return next;
|
|
177
225
|
}
|
|
178
226
|
function isKeyExcluededFromDump(key) {
|
|
179
|
-
return
|
|
227
|
+
return ExcludedFromDump.includes(key);
|
|
228
|
+
}
|
|
229
|
+
function minifyKey(key) {
|
|
230
|
+
var _a;
|
|
231
|
+
return (_a = KeyToMinified[key]) !== null && _a !== void 0 ? _a : key;
|
|
232
|
+
}
|
|
233
|
+
function transformValueByKey(key, value, miniMaps) {
|
|
234
|
+
var _a, _b;
|
|
235
|
+
if (vestUtils.isNullish(value)) {
|
|
236
|
+
return value;
|
|
237
|
+
}
|
|
238
|
+
const keyMap = (_a = miniMaps === null || miniMaps === void 0 ? void 0 : miniMaps.values) === null || _a === void 0 ? void 0 : _a[key];
|
|
239
|
+
return keyMap ? (_b = keyMap[value]) !== null && _b !== void 0 ? _b : value : value;
|
|
240
|
+
}
|
|
241
|
+
function transformKeys(data, keyMap) {
|
|
242
|
+
var _a;
|
|
243
|
+
const next = {};
|
|
244
|
+
// Loop over each key in the data.
|
|
245
|
+
for (const key in data) {
|
|
246
|
+
// Find the key to use for the next object.
|
|
247
|
+
// If there is no key map, use the original key.
|
|
248
|
+
// If there is a key map, use the key map entry for the current key.
|
|
249
|
+
const keyToUse = (_a = (keyMap ? keyMap[key] : key)) !== null && _a !== void 0 ? _a : key;
|
|
250
|
+
// Add the key and value to the next object.
|
|
251
|
+
next[keyToUse] = data[key];
|
|
252
|
+
}
|
|
253
|
+
// Return the next object.
|
|
254
|
+
return next;
|
|
255
|
+
}
|
|
256
|
+
function deeplyInvertKeyMap(miniMaps = {}) {
|
|
257
|
+
return Object.entries(miniMaps).reduce((acc, [key, value]) => {
|
|
258
|
+
if (typeof value === 'object') {
|
|
259
|
+
return vestUtils.assign(acc, {
|
|
260
|
+
[key]: deeplyInvertKeyMap(value),
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
return vestUtils.assign(acc, {
|
|
264
|
+
[value]: key,
|
|
265
|
+
});
|
|
266
|
+
}, {});
|
|
180
267
|
}
|
|
181
268
|
|
|
182
269
|
exports.IsolateSerializer = IsolateSerializer;
|
|
270
|
+
exports.deeplyInvertKeyMap = deeplyInvertKeyMap;
|
|
183
271
|
//# 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}\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","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","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 { IsolateKeys, KeyToMinified, MinifiedToKey } 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 [IsolateKeys.Parent, IsolateKeys.Keys].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,WAQX,CAAA;AARD,CAAA,UAAY,WAAW,EAAA;AACrB,IAAA,WAA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AAS;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,CAAC,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAkB,CAAC,CAAC;AAC7E;;;;"}
|
|
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 'lodash';\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,CAAA;AAClD,IAAA,YAAA,CAAA,6BAAA,CAAA,GAAA,uFAAqH,CAAA;AACrH,IAAA,YAAA,CAAA,gCAAA,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C,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 e,
|
|
1
|
+
"use strict";var t,e,n,i=require("vest-utils"),r=require("lodash");!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 a={[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},s=function(t={}){return Object.entries(t).reduce(((t,[e,n])=>r.assign(t,{[n]:e})),{})}(a);const l=[e.AbortController,e.Parent,e.Keys,e.Children,e.Data];class o{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),o.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 d{static deserialize(t,n){var r;const a=p(n),l=i.isStringValue(t)?JSON.parse(t):Object.assign({},t);d.validateIsolate(l);const u=[l];for(;u.length;){const t=u.shift(),n=d.expandChildren(t);for(const n in s){const l=t[n];if(i.isNotNullish(l)){const i=s[n];i===e.Data?t[i]=y(l,null===(r=null==a?void 0:a.keys)||void 0===r?void 0:r.data):t[i]=v(i,l,a),delete t[n]}}n&&(t.children=n.map((e=>{var n;const i=Object.assign({},e);o.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 l}static serialize(t,e){return i.isNullish(t)?"":JSON.stringify(u(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,a[e.Type]),i.text(t.INVALID_ISOLATE_CANNOT_PARSE))}}function u(t,e){var r;const a={};t.children&&(a[n.Children]=t.children.map((t=>u(t,e)))),i.isEmpty(t.data)||(a[n.Data]=y(t.data,null===(r=null==e?void 0:e.keys)||void 0===r?void 0:r.data));for(const n in t){if(c(n))continue;const r=t[n];if(i.isNullish(r))continue;a[h(n)]=v(n,r,e)}return a}function c(t){return l.includes(t)}function h(t){var e;return null!==(e=a[t])&&void 0!==e?e:t}function v(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 y(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 p(t={}){return Object.entries(t).reduce(((t,[e,n])=>"object"==typeof n?i.assign(t,{[e]:p(n)}):i.assign(t,{[n]:e})),{})}exports.IsolateSerializer=d,exports.deeplyInvertKeyMap=p;
|
|
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}\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","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","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 { IsolateKeys, KeyToMinified, MinifiedToKey } 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 [IsolateKeys.Parent, IsolateKeys.Keys].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","IsolateMutator","static","isolate","parent","output","child","invariant","children","_a","push","setParent","node","_b","filter","keys","at","isNullish","length","data","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,EAUPC,2BDVL,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,QACD,CARD,CAAYA,IAAAA,EAQX,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,QAUxBC,EAAgBC,OAAOC,QAAQV,GAAeW,QACzD,CAACC,GAAMC,EAAKC,KACVL,OAAOM,OAAOH,EAAK,CACjBE,CAACA,GAAWD,KAEhB,CAAA,SCtCWG,EACXC,iBAAiBC,EAAmBC,GAElC,OADAD,EAAQC,OAASA,EACVD,CACR,CAEDD,kBAAkBC,EAAmBE,GAEnC,OADAF,EAAQE,OAASA,EACV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UsB,EAAWN,GACpCD,EAAMhB,KAAKuB,GAEX,MAAMnC,EAAMmC,EAAUnC,IAOtB,OALIA,IACF6B,EAAQZ,KAAuB,QAAhBN,EAAAkB,EAAQZ,YAAQ,IAAAN,EAAAA,EAAA,CAAA,EAC/BkB,EAAQZ,KAAKjB,GAAOmC,GAGfA,CAAS,IAEnB,CAED,OAAOZ,CACR,CAEDnB,iBAAiBC,GACf,OAAIc,EAAAA,UAAUd,GACL,GAGFoB,KAAKW,UAAUC,EAAiBhC,GACxC,CAEDD,mBAAmBU,GACjB,OAAOA,EAAKJ,SAAW,IAAII,EAAKJ,UAAY,IAC7C,CAEDN,uBAAuBU,GACrBL,EAAAA,UACE6B,EAAcA,eAACxB,EAAM7B,EAAYG,OAC/BkD,iBAAexB,EAAM3B,EAAcF,EAAYG,OACjDmD,OAAKvD,EAAawD,8BAErB,EAIH,SAASH,EAAiBhC,GACxB,MAAMoC,EAA4B,CAAA,EAE9BpC,EAAQK,WACV+B,EAAK/B,SAAWL,EAAQK,SAASwB,IAAIG,IAGvC,IAAK,MAAMrC,KAAOK,EAAS,CACzB,GAAY,aAARL,EACF,SAGF,GAAI0C,EAAuB1C,GACzB,SAEF,MAAMgC,EAAQ3B,EAAQL,GAElBmB,EAAAA,UAAUa,KAIVM,EAAcA,eAACnD,EAAea,GAChCyC,EAAKtD,EAAca,IAAQgC,EAE3BS,EAAKzC,GAAOgC,EAEf,CAED,OAAOS,CACT,CAEA,SAASC,EAAuB1C,GAC9B,MAAO,CAACf,EAAYK,OAAQL,EAAYI,MAAMsD,SAAS3C,EACzD"}
|
|
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 'lodash';\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,+CDdZ,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,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OAAA,EAAAA,EAAAd,GAElC,OAAO0D,aAASA,EAAOjB,kBAAkBA,CAC3C,CAEA,SAASG,EACPpB,EACAkC,SAEA,MAAML,EAA4B,CAAA,EAGlC,IAAK,MAAMrD,KAAOwB,EAAM,CAOtB6B,EAH6C,QAA5BvC,EAAC4C,EAASA,EAAO1D,GAAOA,SAAI,IAAAc,EAAAA,EAAId,GAGhCwB,EAAKxB,EACvB,CAGD,OAAOqD,CACT,CAcgB,SAAAtB,EAAmBF,EAA4B,IAC7D,OAAOjC,OAAOC,QAAQgC,GAAU/B,QAAO,CAACC,GAAMC,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 lodash = require('lodash');
|
|
4
|
+
|
|
3
5
|
/******************************************************************************
|
|
4
6
|
Copyright (c) Microsoft Corporation.
|
|
5
7
|
|
|
@@ -43,16 +45,19 @@ var IsolateKeys;
|
|
|
43
45
|
IsolateKeys["Data"] = "data";
|
|
44
46
|
IsolateKeys["AllowReorder"] = "allowReorder";
|
|
45
47
|
IsolateKeys["Status"] = "status";
|
|
48
|
+
IsolateKeys["AbortController"] = "abortController";
|
|
49
|
+
IsolateKeys["Children"] = "children";
|
|
46
50
|
})(IsolateKeys || (IsolateKeys = {}));
|
|
47
51
|
var MinifiedKeys;
|
|
48
52
|
(function (MinifiedKeys) {
|
|
49
53
|
MinifiedKeys["Type"] = "$";
|
|
50
|
-
MinifiedKeys["Keys"] = "
|
|
51
|
-
MinifiedKeys["Key"] = "
|
|
54
|
+
MinifiedKeys["Keys"] = "Ks";
|
|
55
|
+
MinifiedKeys["Key"] = "ky";
|
|
52
56
|
MinifiedKeys["Parent"] = "P";
|
|
53
57
|
MinifiedKeys["Data"] = "D";
|
|
54
|
-
MinifiedKeys["AllowReorder"] = "
|
|
58
|
+
MinifiedKeys["AllowReorder"] = "AR";
|
|
55
59
|
MinifiedKeys["Status"] = "S";
|
|
60
|
+
MinifiedKeys["Children"] = "C";
|
|
56
61
|
})(MinifiedKeys || (MinifiedKeys = {}));
|
|
57
62
|
const KeyToMinified = {
|
|
58
63
|
[IsolateKeys.Type]: MinifiedKeys.Type,
|
|
@@ -62,6 +67,7 @@ const KeyToMinified = {
|
|
|
62
67
|
[IsolateKeys.Key]: MinifiedKeys.Key,
|
|
63
68
|
[IsolateKeys.AllowReorder]: MinifiedKeys.AllowReorder,
|
|
64
69
|
[IsolateKeys.Status]: MinifiedKeys.Status,
|
|
70
|
+
[IsolateKeys.Children]: MinifiedKeys.Children,
|
|
65
71
|
};
|
|
66
72
|
// This const is an object that looks like this:
|
|
67
73
|
// {
|
|
@@ -70,9 +76,19 @@ const KeyToMinified = {
|
|
|
70
76
|
// 'P': 'parent',
|
|
71
77
|
// ...
|
|
72
78
|
// }
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
79
|
+
invertKeyMap(KeyToMinified);
|
|
80
|
+
function invertKeyMap(miniMap = {}) {
|
|
81
|
+
return Object.entries(miniMap).reduce((acc, [key, minified]) => lodash.assign(acc, {
|
|
82
|
+
[minified]: key,
|
|
83
|
+
}), {});
|
|
84
|
+
}
|
|
85
|
+
[
|
|
86
|
+
IsolateKeys.AbortController,
|
|
87
|
+
IsolateKeys.Parent,
|
|
88
|
+
IsolateKeys.Keys,
|
|
89
|
+
IsolateKeys.Children,
|
|
90
|
+
IsolateKeys.Data,
|
|
91
|
+
];
|
|
76
92
|
|
|
77
93
|
function genTestIsolate(payload = {}) {
|
|
78
94
|
const { status } = payload, data = __rest(payload, ["status"]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-utils.development.js","sources":["../../src/Isolate/IsolateKeys.ts","../../src/exports/test-utils.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"test-utils.development.js","sources":["../../src/Isolate/IsolateKeys.ts","../../src/exports/test-utils.ts"],"sourcesContent":["import { assign } from 'lodash';\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":["assign"],"mappings":";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,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||(e={})),function(e){e.Type="$",e.Keys="
|
|
1
|
+
"use strict";var e,t,r=require("lodash");"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":["
|
|
1
|
+
{"version":3,"file":"test-utils.production.js","sources":["../../src/Isolate/IsolateKeys.ts","../../src/exports/test-utils.ts"],"sourcesContent":["import { assign } from 'lodash';\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,0EAZZ,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"}
|