@web-ts-toolkit/access-router 0.51.0 → 0.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1744 -118
- package/advanced.d.mts +1 -4
- package/advanced.d.ts +1 -4
- package/advanced.js +774 -307
- package/advanced.mjs +722 -255
- package/index.d.mts +88 -2
- package/index.d.ts +88 -2
- package/index.js +11011 -7572
- package/index.mjs +11043 -7606
- package/llms.txt +39 -314
- package/package.json +3 -3
- package/{parsers-DhUuvj9B.d.mts → parsers-ZSrF7SNu.d.mts} +2661 -1929
- package/{parsers-DhUuvj9B.d.ts → parsers-ZSrF7SNu.d.ts} +2661 -1929
- package/processors.js +86 -47
- package/processors.mjs +49 -10
package/processors.js
CHANGED
|
@@ -27,7 +27,46 @@ __export(processors_exports, {
|
|
|
27
27
|
sliceArrays: () => sliceArrays
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(processors_exports);
|
|
30
|
+
var import_utils2 = require("@web-ts-toolkit/utils");
|
|
31
|
+
|
|
32
|
+
// src/output/permissions-alias.ts
|
|
30
33
|
var import_utils = require("@web-ts-toolkit/utils");
|
|
34
|
+
var aliases = /* @__PURE__ */ new WeakMap();
|
|
35
|
+
function attachPermissionsAlias(output, field) {
|
|
36
|
+
if ("permissions" in output) return;
|
|
37
|
+
const metadata = (0, import_utils.get)(output, field);
|
|
38
|
+
if (metadata === void 0) return;
|
|
39
|
+
Object.defineProperty(output, "permissions", {
|
|
40
|
+
value: metadata,
|
|
41
|
+
enumerable: false,
|
|
42
|
+
writable: true,
|
|
43
|
+
configurable: true
|
|
44
|
+
});
|
|
45
|
+
aliases.set(output, field);
|
|
46
|
+
}
|
|
47
|
+
function copyPermissionsAlias(source, target) {
|
|
48
|
+
if (source && typeof source === "object" && target && typeof target === "object") {
|
|
49
|
+
const field = aliases.get(source);
|
|
50
|
+
if (field && Object.getOwnPropertyDescriptor(source, "permissions")?.value === (0, import_utils.get)(source, field))
|
|
51
|
+
attachPermissionsAlias(target, field);
|
|
52
|
+
}
|
|
53
|
+
return target;
|
|
54
|
+
}
|
|
55
|
+
function copyPermissionsAliasGraph(source, target, seen = /* @__PURE__ */ new WeakSet()) {
|
|
56
|
+
if (!source || !target || typeof source !== "object" || typeof target !== "object" || seen.has(target)) return;
|
|
57
|
+
seen.add(target);
|
|
58
|
+
copyPermissionsAlias(source, target);
|
|
59
|
+
for (const key of Object.keys(target)) {
|
|
60
|
+
copyPermissionsAliasGraph(source[key], target[key], seen);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// src/processors.ts
|
|
65
|
+
function cloneProcessorValue(value) {
|
|
66
|
+
const copy = (0, import_utils2.cloneDeep)(value);
|
|
67
|
+
copyPermissionsAliasGraph(value, copy);
|
|
68
|
+
return copy;
|
|
69
|
+
}
|
|
31
70
|
var UNSAFE_PATH_KEYS = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
32
71
|
var DEFAULT_MAX_SLICE = 1e3;
|
|
33
72
|
var DEFAULT_MASK_REPLACEMENT = "***";
|
|
@@ -62,10 +101,10 @@ function resolveLeafParents(obj, src) {
|
|
|
62
101
|
for (let ind = 0; ind < segs.length - 1; ind += 1) {
|
|
63
102
|
const seg = segs[ind];
|
|
64
103
|
targets = targets.reduce((ret, target) => {
|
|
65
|
-
if (!(0,
|
|
104
|
+
if (!(0, import_utils2.isPlainObject)(target)) return ret;
|
|
66
105
|
const targetObject = target;
|
|
67
106
|
const next = targetObject[seg];
|
|
68
|
-
if ((0,
|
|
107
|
+
if ((0, import_utils2.isArray)(next)) {
|
|
69
108
|
for (const item of next) {
|
|
70
109
|
ret.push(item);
|
|
71
110
|
}
|
|
@@ -75,8 +114,8 @@ function resolveLeafParents(obj, src) {
|
|
|
75
114
|
}
|
|
76
115
|
const leaf = segs[segs.length - 1];
|
|
77
116
|
const pairs = [];
|
|
78
|
-
(0,
|
|
79
|
-
if (!(0,
|
|
117
|
+
(0, import_utils2.forEach)(targets, (target) => {
|
|
118
|
+
if (!(0, import_utils2.isPlainObject)(target)) return;
|
|
80
119
|
pairs.push({ parent: target, leaf });
|
|
81
120
|
});
|
|
82
121
|
return pairs;
|
|
@@ -84,8 +123,8 @@ function resolveLeafParents(obj, src) {
|
|
|
84
123
|
var copyAndDepopulate = (docObject, operations, options = { mutable: true, idField: "_id" }) => {
|
|
85
124
|
const mutable = options.mutable !== false;
|
|
86
125
|
const idField = options.idField ?? "_id";
|
|
87
|
-
const obj = mutable ? docObject : (
|
|
88
|
-
(0,
|
|
126
|
+
const obj = mutable ? docObject : cloneProcessorValue(docObject);
|
|
127
|
+
(0, import_utils2.forEach)(Array.isArray(operations) ? operations : [], (op) => {
|
|
89
128
|
if (!op || typeof op.src !== "string" || typeof op.dest !== "string") return;
|
|
90
129
|
const src = op.src;
|
|
91
130
|
const dest = op.dest;
|
|
@@ -94,19 +133,19 @@ var copyAndDepopulate = (docObject, operations, options = { mutable: true, idFie
|
|
|
94
133
|
assertSafePath(dest);
|
|
95
134
|
let targets = [obj];
|
|
96
135
|
const segs = src.split(".");
|
|
97
|
-
(0,
|
|
136
|
+
(0, import_utils2.forEach)(segs, (seg, ind) => {
|
|
98
137
|
if (segs.length === ind + 1) {
|
|
99
|
-
(0,
|
|
100
|
-
if (!(0,
|
|
138
|
+
(0, import_utils2.forEach)(targets, (target) => {
|
|
139
|
+
if (!(0, import_utils2.isPlainObject)(target)) return;
|
|
101
140
|
const targetObject = target;
|
|
102
141
|
const leaf = targetObject[seg];
|
|
103
142
|
const sourceForDest = leaf;
|
|
104
143
|
let depopulated;
|
|
105
|
-
if ((0,
|
|
144
|
+
if ((0, import_utils2.isArray)(leaf)) {
|
|
106
145
|
if (leaf.length === 0) {
|
|
107
146
|
depopulated = [];
|
|
108
|
-
} else if (leaf.every((item) => (0,
|
|
109
|
-
depopulated = (0,
|
|
147
|
+
} else if (leaf.every((item) => (0, import_utils2.isPlainObject)(item))) {
|
|
148
|
+
depopulated = (0, import_utils2.map)(leaf, idField).map((id, i) => {
|
|
110
149
|
if (id === void 0) {
|
|
111
150
|
failMissingId(`${src}[${i}]`);
|
|
112
151
|
}
|
|
@@ -115,8 +154,8 @@ var copyAndDepopulate = (docObject, operations, options = { mutable: true, idFie
|
|
|
115
154
|
} else {
|
|
116
155
|
return;
|
|
117
156
|
}
|
|
118
|
-
} else if ((0,
|
|
119
|
-
const id = (0,
|
|
157
|
+
} else if ((0, import_utils2.isPlainObject)(leaf)) {
|
|
158
|
+
const id = (0, import_utils2.get)(leaf, idField);
|
|
120
159
|
if (id === void 0) {
|
|
121
160
|
failMissingId(src);
|
|
122
161
|
}
|
|
@@ -124,15 +163,15 @@ var copyAndDepopulate = (docObject, operations, options = { mutable: true, idFie
|
|
|
124
163
|
} else {
|
|
125
164
|
return;
|
|
126
165
|
}
|
|
127
|
-
(0,
|
|
128
|
-
(0,
|
|
166
|
+
(0, import_utils2.set)(targetObject, dest, sourceForDest);
|
|
167
|
+
(0, import_utils2.set)(targetObject, seg, depopulated);
|
|
129
168
|
});
|
|
130
169
|
} else {
|
|
131
170
|
targets = targets.reduce((ret, target) => {
|
|
132
|
-
if (!(0,
|
|
171
|
+
if (!(0, import_utils2.isPlainObject)(target)) return ret;
|
|
133
172
|
const targetObject = target;
|
|
134
173
|
const next = targetObject[seg];
|
|
135
|
-
if ((0,
|
|
174
|
+
if ((0, import_utils2.isArray)(next)) {
|
|
136
175
|
for (const item of next) {
|
|
137
176
|
ret.push(item);
|
|
138
177
|
}
|
|
@@ -146,8 +185,8 @@ var copyAndDepopulate = (docObject, operations, options = { mutable: true, idFie
|
|
|
146
185
|
};
|
|
147
186
|
var copyPaths = (docObject, operations, options = { mutable: true }) => {
|
|
148
187
|
const mutable = options.mutable !== false;
|
|
149
|
-
const obj = mutable ? docObject : (
|
|
150
|
-
(0,
|
|
188
|
+
const obj = mutable ? docObject : cloneProcessorValue(docObject);
|
|
189
|
+
(0, import_utils2.forEach)(Array.isArray(operations) ? operations : [], (op) => {
|
|
151
190
|
if (!op || typeof op.src !== "string" || typeof op.dest !== "string") return;
|
|
152
191
|
const src = op.src;
|
|
153
192
|
const dest = op.dest;
|
|
@@ -155,17 +194,17 @@ var copyPaths = (docObject, operations, options = { mutable: true }) => {
|
|
|
155
194
|
assertSafePath(src, "copyPaths");
|
|
156
195
|
assertSafePath(dest, "copyPaths");
|
|
157
196
|
if (src === dest) return;
|
|
158
|
-
(0,
|
|
159
|
-
if (!(0,
|
|
160
|
-
(0,
|
|
197
|
+
(0, import_utils2.forEach)(resolveLeafParents(obj, src), ({ parent, leaf }) => {
|
|
198
|
+
if (!(0, import_utils2.hasOwn)(parent, leaf)) return;
|
|
199
|
+
(0, import_utils2.set)(parent, dest, cloneProcessorValue(parent[leaf]));
|
|
161
200
|
});
|
|
162
201
|
});
|
|
163
202
|
return obj;
|
|
164
203
|
};
|
|
165
204
|
var movePaths = (docObject, operations, options = { mutable: true }) => {
|
|
166
205
|
const mutable = options.mutable !== false;
|
|
167
|
-
const obj = mutable ? docObject : (
|
|
168
|
-
(0,
|
|
206
|
+
const obj = mutable ? docObject : cloneProcessorValue(docObject);
|
|
207
|
+
(0, import_utils2.forEach)(Array.isArray(operations) ? operations : [], (op) => {
|
|
169
208
|
if (!op || typeof op.src !== "string" || typeof op.dest !== "string") return;
|
|
170
209
|
const src = op.src;
|
|
171
210
|
const dest = op.dest;
|
|
@@ -173,10 +212,10 @@ var movePaths = (docObject, operations, options = { mutable: true }) => {
|
|
|
173
212
|
assertSafePath(src, "movePaths");
|
|
174
213
|
assertSafePath(dest, "movePaths");
|
|
175
214
|
if (src === dest) return;
|
|
176
|
-
(0,
|
|
177
|
-
if (!(0,
|
|
178
|
-
const value = (
|
|
179
|
-
(0,
|
|
215
|
+
(0, import_utils2.forEach)(resolveLeafParents(obj, src), ({ parent, leaf }) => {
|
|
216
|
+
if (!(0, import_utils2.hasOwn)(parent, leaf)) return;
|
|
217
|
+
const value = cloneProcessorValue(parent[leaf]);
|
|
218
|
+
(0, import_utils2.set)(parent, dest, value);
|
|
180
219
|
if (dest === leaf || dest.startsWith(`${leaf}.`)) return;
|
|
181
220
|
delete parent[leaf];
|
|
182
221
|
});
|
|
@@ -187,8 +226,8 @@ var sliceArrays = (docObject, operations, options = { mutable: true, maxSlice: D
|
|
|
187
226
|
const mutable = options.mutable !== false;
|
|
188
227
|
const maxSlice = options.maxSlice ?? DEFAULT_MAX_SLICE;
|
|
189
228
|
assertNonNegativeSafeInteger(maxSlice, "maxSlice", "sliceArrays");
|
|
190
|
-
const obj = mutable ? docObject : (
|
|
191
|
-
(0,
|
|
229
|
+
const obj = mutable ? docObject : cloneProcessorValue(docObject);
|
|
230
|
+
(0, import_utils2.forEach)(Array.isArray(operations) ? operations : [], (op) => {
|
|
192
231
|
if (!op || typeof op.src !== "string") return;
|
|
193
232
|
const src = op.src;
|
|
194
233
|
if (src.length === 0) return;
|
|
@@ -205,15 +244,15 @@ var sliceArrays = (docObject, operations, options = { mutable: true, maxSlice: D
|
|
|
205
244
|
assertNonNegativeSafeInteger(op.limit, "limit", "sliceArrays");
|
|
206
245
|
limit = Math.min(op.limit, maxSlice);
|
|
207
246
|
}
|
|
208
|
-
(0,
|
|
247
|
+
(0, import_utils2.forEach)(resolveLeafParents(obj, src), ({ parent, leaf }) => {
|
|
209
248
|
const leafValue = parent[leaf];
|
|
210
|
-
if (!(0,
|
|
249
|
+
if (!(0, import_utils2.isArray)(leafValue)) return;
|
|
211
250
|
const end = typeof limit === "undefined" ? void 0 : skip + limit;
|
|
212
251
|
const window = leafValue.slice(skip, end);
|
|
213
252
|
if (typeof rawDest === "undefined") {
|
|
214
|
-
(0,
|
|
253
|
+
(0, import_utils2.set)(parent, leaf, window);
|
|
215
254
|
} else {
|
|
216
|
-
(0,
|
|
255
|
+
(0, import_utils2.set)(parent, rawDest, window);
|
|
217
256
|
}
|
|
218
257
|
});
|
|
219
258
|
});
|
|
@@ -221,44 +260,44 @@ var sliceArrays = (docObject, operations, options = { mutable: true, maxSlice: D
|
|
|
221
260
|
};
|
|
222
261
|
var countPaths = (docObject, operations, options = { mutable: true }) => {
|
|
223
262
|
const mutable = options.mutable !== false;
|
|
224
|
-
const obj = mutable ? docObject : (
|
|
225
|
-
(0,
|
|
263
|
+
const obj = mutable ? docObject : cloneProcessorValue(docObject);
|
|
264
|
+
(0, import_utils2.forEach)(Array.isArray(operations) ? operations : [], (op) => {
|
|
226
265
|
if (!op || typeof op.src !== "string" || typeof op.dest !== "string") return;
|
|
227
266
|
const src = op.src;
|
|
228
267
|
const dest = op.dest;
|
|
229
268
|
if (src.length === 0 || dest.length === 0) return;
|
|
230
269
|
assertSafePath(src, "countPaths");
|
|
231
270
|
assertSafePath(dest, "countPaths");
|
|
232
|
-
(0,
|
|
233
|
-
if (!(0,
|
|
271
|
+
(0, import_utils2.forEach)(resolveLeafParents(obj, src), ({ parent, leaf }) => {
|
|
272
|
+
if (!(0, import_utils2.hasOwn)(parent, leaf)) return;
|
|
234
273
|
const leafValue = parent[leaf];
|
|
235
274
|
let count;
|
|
236
|
-
if ((0,
|
|
275
|
+
if ((0, import_utils2.isArray)(leafValue)) {
|
|
237
276
|
count = leafValue.length;
|
|
238
|
-
} else if ((0,
|
|
277
|
+
} else if ((0, import_utils2.isPlainObject)(leafValue)) {
|
|
239
278
|
count = Object.keys(leafValue).length;
|
|
240
279
|
} else if (leafValue === null || typeof leafValue === "undefined") {
|
|
241
280
|
count = 0;
|
|
242
281
|
} else {
|
|
243
282
|
count = 1;
|
|
244
283
|
}
|
|
245
|
-
(0,
|
|
284
|
+
(0, import_utils2.set)(parent, dest, count);
|
|
246
285
|
});
|
|
247
286
|
});
|
|
248
287
|
return obj;
|
|
249
288
|
};
|
|
250
289
|
var maskPaths = (docObject, operations, options = { mutable: true }) => {
|
|
251
290
|
const mutable = options.mutable !== false;
|
|
252
|
-
const obj = mutable ? docObject : (
|
|
253
|
-
(0,
|
|
291
|
+
const obj = mutable ? docObject : cloneProcessorValue(docObject);
|
|
292
|
+
(0, import_utils2.forEach)(Array.isArray(operations) ? operations : [], (op) => {
|
|
254
293
|
if (!op || typeof op.src !== "string") return;
|
|
255
294
|
const src = op.src;
|
|
256
295
|
if (src.length === 0) return;
|
|
257
296
|
assertSafePath(src, "maskPaths");
|
|
258
297
|
const replacement = Object.prototype.hasOwnProperty.call(op, "replacement") ? op.replacement : DEFAULT_MASK_REPLACEMENT;
|
|
259
|
-
(0,
|
|
260
|
-
if (!(0,
|
|
261
|
-
(0,
|
|
298
|
+
(0, import_utils2.forEach)(resolveLeafParents(obj, src), ({ parent, leaf }) => {
|
|
299
|
+
if (!(0, import_utils2.hasOwn)(parent, leaf)) return;
|
|
300
|
+
(0, import_utils2.set)(parent, leaf, replacement);
|
|
262
301
|
});
|
|
263
302
|
});
|
|
264
303
|
return obj;
|
package/processors.mjs
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
// src/processors.ts
|
|
2
|
-
import { cloneDeep, forEach, get, hasOwn, isArray, isPlainObject, map, set } from "@web-ts-toolkit/utils";
|
|
2
|
+
import { cloneDeep, forEach, get as get2, hasOwn, isArray, isPlainObject, map, set } from "@web-ts-toolkit/utils";
|
|
3
|
+
|
|
4
|
+
// src/output/permissions-alias.ts
|
|
5
|
+
import { get } from "@web-ts-toolkit/utils";
|
|
6
|
+
var aliases = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
function attachPermissionsAlias(output, field) {
|
|
8
|
+
if ("permissions" in output) return;
|
|
9
|
+
const metadata = get(output, field);
|
|
10
|
+
if (metadata === void 0) return;
|
|
11
|
+
Object.defineProperty(output, "permissions", {
|
|
12
|
+
value: metadata,
|
|
13
|
+
enumerable: false,
|
|
14
|
+
writable: true,
|
|
15
|
+
configurable: true
|
|
16
|
+
});
|
|
17
|
+
aliases.set(output, field);
|
|
18
|
+
}
|
|
19
|
+
function copyPermissionsAlias(source, target) {
|
|
20
|
+
if (source && typeof source === "object" && target && typeof target === "object") {
|
|
21
|
+
const field = aliases.get(source);
|
|
22
|
+
if (field && Object.getOwnPropertyDescriptor(source, "permissions")?.value === get(source, field))
|
|
23
|
+
attachPermissionsAlias(target, field);
|
|
24
|
+
}
|
|
25
|
+
return target;
|
|
26
|
+
}
|
|
27
|
+
function copyPermissionsAliasGraph(source, target, seen = /* @__PURE__ */ new WeakSet()) {
|
|
28
|
+
if (!source || !target || typeof source !== "object" || typeof target !== "object" || seen.has(target)) return;
|
|
29
|
+
seen.add(target);
|
|
30
|
+
copyPermissionsAlias(source, target);
|
|
31
|
+
for (const key of Object.keys(target)) {
|
|
32
|
+
copyPermissionsAliasGraph(source[key], target[key], seen);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/processors.ts
|
|
37
|
+
function cloneProcessorValue(value) {
|
|
38
|
+
const copy = cloneDeep(value);
|
|
39
|
+
copyPermissionsAliasGraph(value, copy);
|
|
40
|
+
return copy;
|
|
41
|
+
}
|
|
3
42
|
var UNSAFE_PATH_KEYS = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
4
43
|
var DEFAULT_MAX_SLICE = 1e3;
|
|
5
44
|
var DEFAULT_MASK_REPLACEMENT = "***";
|
|
@@ -56,7 +95,7 @@ function resolveLeafParents(obj, src) {
|
|
|
56
95
|
var copyAndDepopulate = (docObject, operations, options = { mutable: true, idField: "_id" }) => {
|
|
57
96
|
const mutable = options.mutable !== false;
|
|
58
97
|
const idField = options.idField ?? "_id";
|
|
59
|
-
const obj = mutable ? docObject :
|
|
98
|
+
const obj = mutable ? docObject : cloneProcessorValue(docObject);
|
|
60
99
|
forEach(Array.isArray(operations) ? operations : [], (op) => {
|
|
61
100
|
if (!op || typeof op.src !== "string" || typeof op.dest !== "string") return;
|
|
62
101
|
const src = op.src;
|
|
@@ -88,7 +127,7 @@ var copyAndDepopulate = (docObject, operations, options = { mutable: true, idFie
|
|
|
88
127
|
return;
|
|
89
128
|
}
|
|
90
129
|
} else if (isPlainObject(leaf)) {
|
|
91
|
-
const id =
|
|
130
|
+
const id = get2(leaf, idField);
|
|
92
131
|
if (id === void 0) {
|
|
93
132
|
failMissingId(src);
|
|
94
133
|
}
|
|
@@ -118,7 +157,7 @@ var copyAndDepopulate = (docObject, operations, options = { mutable: true, idFie
|
|
|
118
157
|
};
|
|
119
158
|
var copyPaths = (docObject, operations, options = { mutable: true }) => {
|
|
120
159
|
const mutable = options.mutable !== false;
|
|
121
|
-
const obj = mutable ? docObject :
|
|
160
|
+
const obj = mutable ? docObject : cloneProcessorValue(docObject);
|
|
122
161
|
forEach(Array.isArray(operations) ? operations : [], (op) => {
|
|
123
162
|
if (!op || typeof op.src !== "string" || typeof op.dest !== "string") return;
|
|
124
163
|
const src = op.src;
|
|
@@ -129,14 +168,14 @@ var copyPaths = (docObject, operations, options = { mutable: true }) => {
|
|
|
129
168
|
if (src === dest) return;
|
|
130
169
|
forEach(resolveLeafParents(obj, src), ({ parent, leaf }) => {
|
|
131
170
|
if (!hasOwn(parent, leaf)) return;
|
|
132
|
-
set(parent, dest,
|
|
171
|
+
set(parent, dest, cloneProcessorValue(parent[leaf]));
|
|
133
172
|
});
|
|
134
173
|
});
|
|
135
174
|
return obj;
|
|
136
175
|
};
|
|
137
176
|
var movePaths = (docObject, operations, options = { mutable: true }) => {
|
|
138
177
|
const mutable = options.mutable !== false;
|
|
139
|
-
const obj = mutable ? docObject :
|
|
178
|
+
const obj = mutable ? docObject : cloneProcessorValue(docObject);
|
|
140
179
|
forEach(Array.isArray(operations) ? operations : [], (op) => {
|
|
141
180
|
if (!op || typeof op.src !== "string" || typeof op.dest !== "string") return;
|
|
142
181
|
const src = op.src;
|
|
@@ -147,7 +186,7 @@ var movePaths = (docObject, operations, options = { mutable: true }) => {
|
|
|
147
186
|
if (src === dest) return;
|
|
148
187
|
forEach(resolveLeafParents(obj, src), ({ parent, leaf }) => {
|
|
149
188
|
if (!hasOwn(parent, leaf)) return;
|
|
150
|
-
const value =
|
|
189
|
+
const value = cloneProcessorValue(parent[leaf]);
|
|
151
190
|
set(parent, dest, value);
|
|
152
191
|
if (dest === leaf || dest.startsWith(`${leaf}.`)) return;
|
|
153
192
|
delete parent[leaf];
|
|
@@ -159,7 +198,7 @@ var sliceArrays = (docObject, operations, options = { mutable: true, maxSlice: D
|
|
|
159
198
|
const mutable = options.mutable !== false;
|
|
160
199
|
const maxSlice = options.maxSlice ?? DEFAULT_MAX_SLICE;
|
|
161
200
|
assertNonNegativeSafeInteger(maxSlice, "maxSlice", "sliceArrays");
|
|
162
|
-
const obj = mutable ? docObject :
|
|
201
|
+
const obj = mutable ? docObject : cloneProcessorValue(docObject);
|
|
163
202
|
forEach(Array.isArray(operations) ? operations : [], (op) => {
|
|
164
203
|
if (!op || typeof op.src !== "string") return;
|
|
165
204
|
const src = op.src;
|
|
@@ -193,7 +232,7 @@ var sliceArrays = (docObject, operations, options = { mutable: true, maxSlice: D
|
|
|
193
232
|
};
|
|
194
233
|
var countPaths = (docObject, operations, options = { mutable: true }) => {
|
|
195
234
|
const mutable = options.mutable !== false;
|
|
196
|
-
const obj = mutable ? docObject :
|
|
235
|
+
const obj = mutable ? docObject : cloneProcessorValue(docObject);
|
|
197
236
|
forEach(Array.isArray(operations) ? operations : [], (op) => {
|
|
198
237
|
if (!op || typeof op.src !== "string" || typeof op.dest !== "string") return;
|
|
199
238
|
const src = op.src;
|
|
@@ -221,7 +260,7 @@ var countPaths = (docObject, operations, options = { mutable: true }) => {
|
|
|
221
260
|
};
|
|
222
261
|
var maskPaths = (docObject, operations, options = { mutable: true }) => {
|
|
223
262
|
const mutable = options.mutable !== false;
|
|
224
|
-
const obj = mutable ? docObject :
|
|
263
|
+
const obj = mutable ? docObject : cloneProcessorValue(docObject);
|
|
225
264
|
forEach(Array.isArray(operations) ? operations : [], (op) => {
|
|
226
265
|
if (!op || typeof op.src !== "string") return;
|
|
227
266
|
const src = op.src;
|