@fluid-experimental/property-changeset 2.0.0-rc.2.0.2 → 2.0.0-rc.3.0.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/dist/ajvFactory.cjs +19 -0
- package/dist/ajvFactory.cjs.map +1 -0
- package/dist/ajvFactory.d.cts +7 -0
- package/dist/ajvFactory.d.cts.map +1 -0
- package/dist/changeset.d.ts +3 -6
- package/dist/changeset.d.ts.map +1 -1
- package/dist/changeset.js +75 -75
- package/dist/changeset.js.map +1 -1
- package/dist/changeset_operations/array.d.ts +6 -2
- package/dist/changeset_operations/array.d.ts.map +1 -1
- package/dist/changeset_operations/array.js +94 -96
- package/dist/changeset_operations/array.js.map +1 -1
- package/dist/changeset_operations/arrayChangesetIterator.d.ts +2 -5
- package/dist/changeset_operations/arrayChangesetIterator.d.ts.map +1 -1
- package/dist/changeset_operations/arrayChangesetIterator.js +11 -12
- package/dist/changeset_operations/arrayChangesetIterator.js.map +1 -1
- package/dist/changeset_operations/changesetConflictTypes.d.ts.map +1 -1
- package/dist/changeset_operations/changesetConflictTypes.js +2 -2
- package/dist/changeset_operations/changesetConflictTypes.js.map +1 -1
- package/dist/changeset_operations/indexedCollection.d.ts +1 -4
- package/dist/changeset_operations/indexedCollection.d.ts.map +1 -1
- package/dist/changeset_operations/indexedCollection.js +48 -49
- package/dist/changeset_operations/indexedCollection.js.map +1 -1
- package/dist/changeset_operations/isEmptyChangeset.d.ts +1 -4
- package/dist/changeset_operations/isEmptyChangeset.d.ts.map +1 -1
- package/dist/changeset_operations/isEmptyChangeset.js +9 -9
- package/dist/changeset_operations/isEmptyChangeset.js.map +1 -1
- package/dist/helpers/typeidHelper.d.ts +0 -3
- package/dist/helpers/typeidHelper.d.ts.map +1 -1
- package/dist/helpers/typeidHelper.js +10 -10
- package/dist/helpers/typeidHelper.js.map +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -19
- package/dist/index.js.map +1 -1
- package/dist/isReservedKeyword.d.ts.map +1 -1
- package/dist/isReservedKeyword.js +2 -2
- package/dist/isReservedKeyword.js.map +1 -1
- package/dist/package.json +3 -0
- package/dist/pathHelper.d.ts +0 -3
- package/dist/pathHelper.d.ts.map +1 -1
- package/dist/pathHelper.js +2 -2
- package/dist/pathHelper.js.map +1 -1
- package/dist/rebase.js +8 -8
- package/dist/rebase.js.map +1 -1
- package/dist/templateSchema.d.ts.map +1 -1
- package/dist/templateSchema.js +2 -2
- package/dist/templateSchema.js.map +1 -1
- package/dist/templateValidator.d.ts +1 -1
- package/dist/templateValidator.d.ts.map +1 -1
- package/dist/templateValidator.js +49 -54
- package/dist/templateValidator.js.map +1 -1
- package/dist/test/array.spec.js +34 -36
- package/dist/test/array.spec.js.map +1 -1
- package/dist/test/indexedCollection.spec.js +9 -6
- package/dist/test/indexedCollection.spec.js.map +1 -1
- package/dist/test/map.spec.js +4 -4
- package/dist/test/map.spec.js.map +1 -1
- package/dist/test/pathHelper.spec.js +185 -185
- package/dist/test/pathHelper.spec.js.map +1 -1
- package/dist/test/reversibleCs.spec.js +5 -5
- package/dist/test/reversibleCs.spec.js.map +1 -1
- package/dist/test/schemaValidator.js +12 -11
- package/dist/test/schemaValidator.js.map +1 -1
- package/dist/test/schemas/badBothPropertiesAndTypeid.js +18 -18
- package/dist/test/schemas/badBothPropertiesAndTypeid.js.map +1 -1
- package/dist/test/schemas/badInvalidSemverInTypeid.js +40 -40
- package/dist/test/schemas/badInvalidSemverInTypeid.js.map +1 -1
- package/dist/test/schemas/badMissingSemverInTypeid.js +40 -40
- package/dist/test/schemas/badMissingSemverInTypeid.js.map +1 -1
- package/dist/test/schemas/badNestedProperties.js +40 -40
- package/dist/test/schemas/badNestedProperties.js.map +1 -1
- package/dist/test/schemas/badPrimitiveTypeid.js +25 -25
- package/dist/test/schemas/badPrimitiveTypeid.js.map +1 -1
- package/dist/test/schemas/badVersionedTypeid.js +41 -41
- package/dist/test/schemas/badVersionedTypeid.js.map +1 -1
- package/dist/test/schemas/goodColorPalette.js +15 -15
- package/dist/test/schemas/goodColorPalette.js.map +1 -1
- package/dist/test/schemas/goodDraftAsVersion.js +12 -12
- package/dist/test/schemas/goodDraftAsVersion.js.map +1 -1
- package/dist/test/schemas/goodPointId.js +40 -40
- package/dist/test/schemas/goodPointId.js.map +1 -1
- package/dist/test/schemas/goodReferenceAndRegular.js +16 -16
- package/dist/test/schemas/goodReferenceAndRegular.js.map +1 -1
- package/dist/test/schemas/goodReservedTypes.js +22 -22
- package/dist/test/schemas/goodReservedTypes.js.map +1 -1
- package/dist/test/schemas/goodUIBorder.js +34 -34
- package/dist/test/schemas/goodUIBorder.js.map +1 -1
- package/dist/test/schemas/index.js +55 -0
- package/dist/test/schemas/index.js.map +1 -0
- package/dist/test/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/test/validator/templateSyntax.spec.js +20 -25
- package/dist/test/validator/templateSyntax.spec.js.map +1 -1
- package/dist/test/validator/templateValidator.spec.js +118 -89
- package/dist/test/validator/templateValidator.spec.js.map +1 -1
- package/dist/test/validator/typeidHelper.spec.js +42 -41
- package/dist/test/validator/typeidHelper.spec.js.map +1 -1
- package/dist/utils.d.ts +17 -13
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +79 -79
- package/dist/utils.js.map +1 -1
- package/dist/validationResultBuilder.d.ts +2 -1
- package/dist/validationResultBuilder.d.ts.map +1 -1
- package/dist/validationResultBuilder.js.map +1 -1
- package/lib/ajvFactory.cjs +19 -0
- package/lib/ajvFactory.cjs.map +1 -0
- package/lib/ajvFactory.d.cts +7 -0
- package/lib/ajvFactory.d.cts.map +1 -0
- package/lib/changeset.d.ts +3 -6
- package/lib/changeset.d.ts.map +1 -1
- package/lib/changeset.js +16 -16
- package/lib/changeset.js.map +1 -1
- package/lib/changeset_operations/array.d.ts +6 -2
- package/lib/changeset_operations/array.d.ts.map +1 -1
- package/lib/changeset_operations/array.js +7 -9
- package/lib/changeset_operations/array.js.map +1 -1
- package/lib/changeset_operations/arrayChangesetIterator.d.ts +2 -5
- package/lib/changeset_operations/arrayChangesetIterator.d.ts.map +1 -1
- package/lib/changeset_operations/arrayChangesetIterator.js +3 -4
- package/lib/changeset_operations/arrayChangesetIterator.js.map +1 -1
- package/lib/changeset_operations/changesetConflictTypes.d.ts.map +1 -1
- package/lib/changeset_operations/changesetConflictTypes.js.map +1 -1
- package/lib/changeset_operations/indexedCollection.d.ts +1 -4
- package/lib/changeset_operations/indexedCollection.d.ts.map +1 -1
- package/lib/changeset_operations/indexedCollection.js +10 -11
- package/lib/changeset_operations/indexedCollection.js.map +1 -1
- package/lib/changeset_operations/isEmptyChangeset.d.ts +1 -4
- package/lib/changeset_operations/isEmptyChangeset.d.ts.map +1 -1
- package/lib/changeset_operations/isEmptyChangeset.js +3 -3
- package/lib/changeset_operations/isEmptyChangeset.js.map +1 -1
- package/lib/helpers/typeidHelper.d.ts +0 -3
- package/lib/helpers/typeidHelper.d.ts.map +1 -1
- package/lib/helpers/typeidHelper.js +1 -1
- package/lib/helpers/typeidHelper.js.map +1 -1
- package/lib/index.d.ts +8 -8
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +8 -8
- package/lib/index.js.map +1 -1
- package/lib/isReservedKeyword.d.ts.map +1 -1
- package/lib/isReservedKeyword.js.map +1 -1
- package/lib/pathHelper.d.ts +0 -3
- package/lib/pathHelper.d.ts.map +1 -1
- package/lib/pathHelper.js.map +1 -1
- package/lib/rebase.js +2 -2
- package/lib/rebase.js.map +1 -1
- package/lib/templateSchema.d.ts.map +1 -1
- package/lib/templateSchema.js.map +1 -1
- package/lib/templateValidator.d.ts +1 -1
- package/lib/templateValidator.d.ts.map +1 -1
- package/lib/templateValidator.js +24 -29
- package/lib/templateValidator.js.map +1 -1
- package/lib/test/array.spec.js +768 -0
- package/lib/test/array.spec.js.map +1 -0
- package/lib/test/indexedCollection.spec.js +75 -0
- package/lib/test/indexedCollection.spec.js.map +1 -0
- package/lib/test/map.spec.js +17 -0
- package/lib/test/map.spec.js.map +1 -0
- package/lib/test/pathHelper.spec.js +435 -0
- package/lib/test/pathHelper.spec.js.map +1 -0
- package/lib/test/reversibleCs.spec.js +42 -0
- package/lib/test/reversibleCs.spec.js.map +1 -0
- package/lib/test/schemaValidator.js +103 -0
- package/lib/test/schemaValidator.js.map +1 -0
- package/lib/test/schemas/badBothPropertiesAndTypeid.js +24 -0
- package/lib/test/schemas/badBothPropertiesAndTypeid.js.map +1 -0
- package/lib/test/schemas/badInvalidSemverInTypeid.js +46 -0
- package/lib/test/schemas/badInvalidSemverInTypeid.js.map +1 -0
- package/lib/test/schemas/badMissingSemverInTypeid.js +46 -0
- package/lib/test/schemas/badMissingSemverInTypeid.js.map +1 -0
- package/lib/test/schemas/badNestedProperties.js +46 -0
- package/lib/test/schemas/badNestedProperties.js.map +1 -0
- package/lib/test/schemas/badPrimitiveTypeid.js +31 -0
- package/lib/test/schemas/badPrimitiveTypeid.js.map +1 -0
- package/lib/test/schemas/badVersionedTypeid.js +47 -0
- package/lib/test/schemas/badVersionedTypeid.js.map +1 -0
- package/lib/test/schemas/goodColorPalette.js +21 -0
- package/lib/test/schemas/goodColorPalette.js.map +1 -0
- package/lib/test/schemas/goodDraftAsVersion.js +18 -0
- package/lib/test/schemas/goodDraftAsVersion.js.map +1 -0
- package/lib/test/schemas/goodPointId.js +46 -0
- package/lib/test/schemas/goodPointId.js.map +1 -0
- package/lib/test/schemas/goodReferenceAndRegular.js +22 -0
- package/lib/test/schemas/goodReferenceAndRegular.js.map +1 -0
- package/lib/test/schemas/goodReservedTypes.js +29 -0
- package/lib/test/schemas/goodReservedTypes.js.map +1 -0
- package/lib/test/schemas/goodUIBorder.js +41 -0
- package/lib/test/schemas/goodUIBorder.js.map +1 -0
- package/lib/test/schemas/index.js +29 -0
- package/lib/test/schemas/index.js.map +1 -0
- package/lib/test/tsconfig.tsbuildinfo +1 -0
- package/lib/test/validator/templateSyntax.spec.js +83 -0
- package/lib/test/validator/templateSyntax.spec.js.map +1 -0
- package/lib/test/validator/templateValidator.spec.js +1022 -0
- package/lib/test/validator/templateValidator.spec.js.map +1 -0
- package/lib/test/validator/typeidHelper.spec.js +142 -0
- package/lib/test/validator/typeidHelper.spec.js.map +1 -0
- package/lib/utils.d.ts +17 -13
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +23 -23
- package/lib/utils.js.map +1 -1
- package/lib/validationResultBuilder.d.ts +2 -1
- package/lib/validationResultBuilder.d.ts.map +1 -1
- package/lib/validationResultBuilder.js.map +1 -1
- package/package.json +37 -16
- package/dist/test/tsconfig.tsbuildinfo +0 -1
package/dist/utils.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
2
6
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
7
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
8
|
};
|
|
5
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
10
|
exports.Utils = void 0;
|
|
7
|
-
/*!
|
|
8
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
9
|
-
* Licensed under the MIT License.
|
|
10
|
-
*/
|
|
11
11
|
// @ts-ignore
|
|
12
12
|
const property_common_1 = require("@fluid-experimental/property-common");
|
|
13
13
|
const async_1 = require("async");
|
|
14
14
|
const fastest_json_copy_1 = require("fastest-json-copy");
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
15
|
+
const each_js_1 = __importDefault(require("lodash/each.js"));
|
|
16
|
+
const extend_js_1 = __importDefault(require("lodash/extend.js"));
|
|
17
|
+
const find_js_1 = __importDefault(require("lodash/find.js"));
|
|
18
|
+
const isEmpty_js_1 = __importDefault(require("lodash/isEmpty.js"));
|
|
19
|
+
const isEqual_js_1 = __importDefault(require("lodash/isEqual.js"));
|
|
20
|
+
const isNumber_js_1 = __importDefault(require("lodash/isNumber.js"));
|
|
21
|
+
const isString_js_1 = __importDefault(require("lodash/isString.js"));
|
|
22
|
+
const arrayChangesetIterator_js_1 = require("./changeset_operations/arrayChangesetIterator.js");
|
|
23
|
+
const operationTypes_js_1 = require("./changeset_operations/operationTypes.js");
|
|
24
|
+
const typeidHelper_js_1 = require("./helpers/typeidHelper.js");
|
|
25
|
+
const isReservedKeyword_js_1 = require("./isReservedKeyword.js");
|
|
26
|
+
const pathHelper_js_1 = require("./pathHelper.js");
|
|
27
27
|
const { PROPERTY_PATH_DELIMITER, MSG } = property_common_1.constants;
|
|
28
28
|
/**
|
|
29
29
|
* Utils
|
|
@@ -51,7 +51,7 @@ var Utils;
|
|
|
51
51
|
// Call the callback function for this ChangeSet
|
|
52
52
|
in_context._traversalStopped = false;
|
|
53
53
|
const typeid = in_context.getTypeid();
|
|
54
|
-
let splitTypeId = typeid !== undefined ?
|
|
54
|
+
let splitTypeId = typeid !== undefined ? typeidHelper_js_1.TypeIdHelper.extractContext(typeid) : undefined;
|
|
55
55
|
in_context.setSplitTypeID(splitTypeId);
|
|
56
56
|
let currentUserData;
|
|
57
57
|
(0, async_1.series)([
|
|
@@ -72,7 +72,7 @@ var Utils;
|
|
|
72
72
|
// Call the callback function for this ChangeSet
|
|
73
73
|
in_context._traversalStopped = false;
|
|
74
74
|
splitTypeId =
|
|
75
|
-
_typeid !== undefined ?
|
|
75
|
+
_typeid !== undefined ? typeidHelper_js_1.TypeIdHelper.extractContext(_typeid) : undefined;
|
|
76
76
|
in_context.setSplitTypeID(splitTypeId);
|
|
77
77
|
if (in_postCallback !== undefined) {
|
|
78
78
|
// TODO: this duplicates the context object putting stress on the GC.
|
|
@@ -81,7 +81,7 @@ var Utils;
|
|
|
81
81
|
currentUserData = in_context.getUserData();
|
|
82
82
|
if (!in_context.isTraversing() ||
|
|
83
83
|
in_context.getOperationType() === "remove" ||
|
|
84
|
-
|
|
84
|
+
typeidHelper_js_1.TypeIdHelper.isPrimitiveType(in_context.getSplitTypeID().typeid) ||
|
|
85
85
|
in_context.getSplitTypeID().isEnum) {
|
|
86
86
|
if (in_postCallback !== undefined) {
|
|
87
87
|
in_postCallback(postOrderContext, function () {
|
|
@@ -107,8 +107,8 @@ var Utils;
|
|
|
107
107
|
try {
|
|
108
108
|
// Update the path
|
|
109
109
|
in_context._lastSegment = in_segment;
|
|
110
|
-
const escapedSegment = in_escape && (0,
|
|
111
|
-
?
|
|
110
|
+
const escapedSegment = in_escape && (0, isString_js_1.default)(in_segment)
|
|
111
|
+
? pathHelper_js_1.PathHelper.quotePathSegmentIfNeeded(in_segment)
|
|
112
112
|
: in_segment;
|
|
113
113
|
let nextSegmentToPushInParentStack = in_context.getLastSegment();
|
|
114
114
|
// Note: we don't quote the path string here, since the paths
|
|
@@ -130,7 +130,7 @@ var Utils;
|
|
|
130
130
|
in_context._arrayOperationOffset = in_arrayOperationOffset;
|
|
131
131
|
in_context._arrayIteratorOffset = in_arrayIteratorOffset;
|
|
132
132
|
if (in_arrayIteratorOffset !== undefined &&
|
|
133
|
-
(0,
|
|
133
|
+
(0, isNumber_js_1.default)(in_segment)) {
|
|
134
134
|
if (in_context._operationType === "remove") {
|
|
135
135
|
nextSegmentToPushInParentStack =
|
|
136
136
|
in_context.getLastSegment() +
|
|
@@ -190,7 +190,7 @@ var Utils;
|
|
|
190
190
|
let oldOperationType = in_context._operationType;
|
|
191
191
|
if (splitTypeId.context === "array") {
|
|
192
192
|
// Use the ArrayChangeSetIterator to process the changes in the ChangeSet in the correct order
|
|
193
|
-
const arrayIterator = new
|
|
193
|
+
const arrayIterator = new arrayChangesetIterator_js_1.ArrayChangeSetIterator(nestedChangeSet);
|
|
194
194
|
let insertCounter = 0;
|
|
195
195
|
let removeCounter = 0;
|
|
196
196
|
let modifyCounter = 0;
|
|
@@ -199,7 +199,7 @@ var Utils;
|
|
|
199
199
|
}, function (n4) {
|
|
200
200
|
let operation;
|
|
201
201
|
switch (arrayIterator.opDescription.type) {
|
|
202
|
-
case
|
|
202
|
+
case operationTypes_js_1.ArrayIteratorOperationTypes.INSERT:
|
|
203
203
|
in_context._operationType = "insert";
|
|
204
204
|
operation =
|
|
205
205
|
arrayIterator.opDescription.operation;
|
|
@@ -214,7 +214,7 @@ var Utils;
|
|
|
214
214
|
n4();
|
|
215
215
|
});
|
|
216
216
|
break;
|
|
217
|
-
case
|
|
217
|
+
case operationTypes_js_1.ArrayIteratorOperationTypes.REMOVE:
|
|
218
218
|
in_context._operationType = "remove";
|
|
219
219
|
operation =
|
|
220
220
|
arrayIterator.opDescription.operation;
|
|
@@ -229,7 +229,7 @@ var Utils;
|
|
|
229
229
|
n4();
|
|
230
230
|
});
|
|
231
231
|
break;
|
|
232
|
-
case
|
|
232
|
+
case operationTypes_js_1.ArrayIteratorOperationTypes.MODIFY:
|
|
233
233
|
operation =
|
|
234
234
|
arrayIterator.opDescription.operation;
|
|
235
235
|
in_context._operationType = "modify";
|
|
@@ -338,7 +338,7 @@ var Utils;
|
|
|
338
338
|
const typeids = Object.keys(nestedChangeSet);
|
|
339
339
|
(0, async_1.timesSeries)(typeids.length, function (i, n5) {
|
|
340
340
|
const typeid = typeids[i];
|
|
341
|
-
if (!(0,
|
|
341
|
+
if (!(0, isReservedKeyword_js_1.isReservedKeyword)(typeid)) {
|
|
342
342
|
const paths = Object.keys(nestedChangeSet[typeid]);
|
|
343
343
|
(0, async_1.timesSeries)(paths.length, function (j, n6) {
|
|
344
344
|
processChange(paths[j], nestedChangeSet[typeid][paths[j]], typeid, false, "template", undefined, undefined, undefined, undefined, n6);
|
|
@@ -409,7 +409,7 @@ var Utils;
|
|
|
409
409
|
in_objectToPopulate[in_context.getOperationType()][in_context.getTypeid()] =
|
|
410
410
|
in_objectToPopulate[in_context.getOperationType()][in_context.getTypeid()] ||
|
|
411
411
|
{};
|
|
412
|
-
if (
|
|
412
|
+
if (typeidHelper_js_1.TypeIdHelper.isPrimitiveType(in_context.getTypeid()) || in_isLeaf) {
|
|
413
413
|
in_objectToPopulate[in_context.getOperationType()][in_context.getTypeid()][in_context.getLastSegment()] = (0, fastest_json_copy_1.copy)(in_context.getNestedChangeSet());
|
|
414
414
|
}
|
|
415
415
|
else {
|
|
@@ -420,7 +420,7 @@ var Utils;
|
|
|
420
420
|
else if (in_context.getPropertyContainerType() === "template") {
|
|
421
421
|
in_objectToPopulate[in_context.getTypeid()] =
|
|
422
422
|
in_objectToPopulate[in_context.getTypeid()] || {};
|
|
423
|
-
if (
|
|
423
|
+
if (typeidHelper_js_1.TypeIdHelper.isPrimitiveType(in_context.getTypeid()) || in_isLeaf) {
|
|
424
424
|
in_objectToPopulate[in_context.getTypeid()][in_context.getLastSegment()] =
|
|
425
425
|
(0, fastest_json_copy_1.copy)(in_context.getNestedChangeSet());
|
|
426
426
|
}
|
|
@@ -454,7 +454,7 @@ var Utils;
|
|
|
454
454
|
// Call the callback function for this ChangeSet
|
|
455
455
|
in_context._traversalStopped = false;
|
|
456
456
|
const splitTypeId = in_context.getTypeid() !== undefined
|
|
457
|
-
?
|
|
457
|
+
? typeidHelper_js_1.TypeIdHelper.extractContext(in_context.getTypeid())
|
|
458
458
|
: undefined;
|
|
459
459
|
in_context._splitTypeId = splitTypeId;
|
|
460
460
|
// TODO: this duplicates the context object putting stress on the GC.
|
|
@@ -468,7 +468,7 @@ var Utils;
|
|
|
468
468
|
const currentUserData = in_context.getUserData();
|
|
469
469
|
if (!in_context.isTraversing() ||
|
|
470
470
|
in_context._operationType === "remove" ||
|
|
471
|
-
|
|
471
|
+
typeidHelper_js_1.TypeIdHelper.isPrimitiveType(in_context._splitTypeId.typeid) ||
|
|
472
472
|
in_context.getSplitTypeID().isEnum) {
|
|
473
473
|
if (in_postCallback !== undefined) {
|
|
474
474
|
in_postCallback(postOrderContext);
|
|
@@ -482,8 +482,8 @@ var Utils;
|
|
|
482
482
|
const processChange = function (in_segment, in_subChangeSet, in_nestedTypeid, in_escape, in_parentPropertyType, in_arrayOperationIndex, in_arrayLocalIndex, in_arrayOperationOffset, in_arrayIteratorOffset) {
|
|
483
483
|
// Update the path
|
|
484
484
|
in_context._lastSegment = in_segment;
|
|
485
|
-
const escapedSegment = in_escape && (0,
|
|
486
|
-
?
|
|
485
|
+
const escapedSegment = in_escape && (0, isString_js_1.default)(in_segment)
|
|
486
|
+
? pathHelper_js_1.PathHelper.quotePathSegmentIfNeeded(in_segment)
|
|
487
487
|
: in_segment;
|
|
488
488
|
let nextSegmentToPushInParentStack = in_context._lastSegment;
|
|
489
489
|
// Note: we don't quote the path string here, since the paths in a ChangeSet are already quoted, if necessary
|
|
@@ -549,13 +549,13 @@ var Utils;
|
|
|
549
549
|
let j;
|
|
550
550
|
if (splitTypeId.context === "array") {
|
|
551
551
|
// Use the ArrayChangeSetIterator to process the changes in the ChangeSet in the correct order
|
|
552
|
-
const arrayIterator = new
|
|
552
|
+
const arrayIterator = new arrayChangesetIterator_js_1.ArrayChangeSetIterator(nestedChangeSet);
|
|
553
553
|
let insertCounter = 0;
|
|
554
554
|
let removeCounter = 0;
|
|
555
555
|
let modifyCounter = 0;
|
|
556
556
|
while (!arrayIterator.atEnd()) {
|
|
557
557
|
switch (arrayIterator.opDescription.type) {
|
|
558
|
-
case
|
|
558
|
+
case operationTypes_js_1.ArrayIteratorOperationTypes.INSERT:
|
|
559
559
|
in_context._operationType = "insert";
|
|
560
560
|
for (i = 0; i < arrayIterator.opDescription.operation[1].length; ++i) {
|
|
561
561
|
// The typeid is stored inline for arrays
|
|
@@ -565,7 +565,7 @@ var Utils;
|
|
|
565
565
|
}
|
|
566
566
|
insertCounter++;
|
|
567
567
|
break;
|
|
568
|
-
case
|
|
568
|
+
case operationTypes_js_1.ArrayIteratorOperationTypes.REMOVE:
|
|
569
569
|
in_context._operationType = "remove";
|
|
570
570
|
// WARNING: 'operation[1]' is 'string | number | genericArray'. The cast to 'number'
|
|
571
571
|
// preserves the JavaScript coercion behavior, which was permitted prior to TS5.
|
|
@@ -576,7 +576,7 @@ var Utils;
|
|
|
576
576
|
}
|
|
577
577
|
removeCounter++;
|
|
578
578
|
break;
|
|
579
|
-
case
|
|
579
|
+
case operationTypes_js_1.ArrayIteratorOperationTypes.MODIFY:
|
|
580
580
|
in_context._operationType = "modify";
|
|
581
581
|
for (i = 0; i < arrayIterator.opDescription.operation[1].length; ++i) {
|
|
582
582
|
// The typeid is stored inline for arrays
|
|
@@ -653,7 +653,7 @@ var Utils;
|
|
|
653
653
|
typeids = Object.keys(nestedChangeSet);
|
|
654
654
|
for (i = 0; i < typeids.length; i++) {
|
|
655
655
|
typeid = typeids[i];
|
|
656
|
-
if (!(0,
|
|
656
|
+
if (!(0, isReservedKeyword_js_1.isReservedKeyword)(typeid)) {
|
|
657
657
|
paths = Object.keys(nestedChangeSet[typeid]);
|
|
658
658
|
for (j = 0; j < paths.length; j++) {
|
|
659
659
|
processChange(paths[j], nestedChangeSet[typeid][paths[j]], typeid, false, "template");
|
|
@@ -752,7 +752,7 @@ var Utils;
|
|
|
752
752
|
this._propertyContainerType === "map" ||
|
|
753
753
|
this._propertyContainerType === "set" ||
|
|
754
754
|
this._propertyContainerType === "root") {
|
|
755
|
-
return
|
|
755
|
+
return pathHelper_js_1.PathHelper.quotePathSegmentIfNeeded(this._lastSegment);
|
|
756
756
|
}
|
|
757
757
|
return this._lastSegment;
|
|
758
758
|
}
|
|
@@ -763,7 +763,7 @@ var Utils;
|
|
|
763
763
|
* @returns Wether the object is empty
|
|
764
764
|
*/
|
|
765
765
|
_isEmptyObject(in_context) {
|
|
766
|
-
return Object(in_context._nestedChangeSet) && (0,
|
|
766
|
+
return Object(in_context._nestedChangeSet) && (0, isEmpty_js_1.default)(in_context._nestedChangeSet);
|
|
767
767
|
}
|
|
768
768
|
/**
|
|
769
769
|
* Returns true if we're at the tip of a path
|
|
@@ -772,7 +772,7 @@ var Utils;
|
|
|
772
772
|
//
|
|
773
773
|
// @ts-ignore currently it's not needed
|
|
774
774
|
isLeafNode() {
|
|
775
|
-
return (
|
|
775
|
+
return (typeidHelper_js_1.TypeIdHelper.isPrimitiveType(this._typeid) ||
|
|
776
776
|
this._isEmptyObject(this) ||
|
|
777
777
|
this.getOperationType() === "remove");
|
|
778
778
|
}
|
|
@@ -783,7 +783,7 @@ var Utils;
|
|
|
783
783
|
*/
|
|
784
784
|
getPostLastSegment() {
|
|
785
785
|
if (this._propertyContainerType === "array" &&
|
|
786
|
-
(0,
|
|
786
|
+
(0, isNumber_js_1.default)(this._lastSegment) &&
|
|
787
787
|
this._arrayIteratorOffset !== undefined) {
|
|
788
788
|
return this._operationType === "remove"
|
|
789
789
|
? this._lastSegment + this._arrayIteratorOffset - this._arrayLocalIndex
|
|
@@ -1019,7 +1019,7 @@ var Utils;
|
|
|
1019
1019
|
}
|
|
1020
1020
|
context._nestedChangeSet = in_changeSet;
|
|
1021
1021
|
context._parentNestedChangeSet = in_changeSet;
|
|
1022
|
-
context._splitTypeId =
|
|
1022
|
+
context._splitTypeId = typeidHelper_js_1.TypeIdHelper.extractContext(context._typeid);
|
|
1023
1023
|
context._userData = in_params.userData;
|
|
1024
1024
|
if (in_params.rootOperation) {
|
|
1025
1025
|
context._operationType = in_params.rootOperation;
|
|
@@ -1050,7 +1050,7 @@ var Utils;
|
|
|
1050
1050
|
}
|
|
1051
1051
|
context._nestedChangeSet = in_changeSet;
|
|
1052
1052
|
context._parentNestedChangeSet = in_changeSet;
|
|
1053
|
-
context._splitTypeId =
|
|
1053
|
+
context._splitTypeId = typeidHelper_js_1.TypeIdHelper.extractContext(context._typeid);
|
|
1054
1054
|
context._userData = in_params.userData;
|
|
1055
1055
|
if (in_params.rootOperation) {
|
|
1056
1056
|
context._operationType = in_params.rootOperation;
|
|
@@ -1136,7 +1136,7 @@ var Utils;
|
|
|
1136
1136
|
userData[in_context.getOperationType()] ||
|
|
1137
1137
|
(in_context.getPropertyContainerType() === "array" ? [] : {}))
|
|
1138
1138
|
: userData;
|
|
1139
|
-
if (
|
|
1139
|
+
if (typeidHelper_js_1.TypeIdHelper.isPrimitiveType(in_context.getTypeid())) {
|
|
1140
1140
|
// This is a primitive type, we store it under its name in the result
|
|
1141
1141
|
operationScope[in_context.getLastSegment()] = in_context.getNestedChangeSet();
|
|
1142
1142
|
}
|
|
@@ -1166,7 +1166,7 @@ var Utils;
|
|
|
1166
1166
|
delete io_changeSet[key];
|
|
1167
1167
|
});
|
|
1168
1168
|
// Assign from the result user data
|
|
1169
|
-
(0,
|
|
1169
|
+
(0, extend_js_1.default)(io_changeSet, result);
|
|
1170
1170
|
}
|
|
1171
1171
|
Utils._stripTypeids = _stripTypeids;
|
|
1172
1172
|
/**
|
|
@@ -1234,7 +1234,7 @@ var Utils;
|
|
|
1234
1234
|
return { modify: in_changeSet };
|
|
1235
1235
|
}
|
|
1236
1236
|
// tokenize the path we are searching for
|
|
1237
|
-
const pathSegments =
|
|
1237
|
+
const pathSegments = pathHelper_js_1.PathHelper.tokenizePathString(in_path);
|
|
1238
1238
|
// Recursively traverse the ChangeSet and search for the path
|
|
1239
1239
|
const result = {};
|
|
1240
1240
|
Utils.traverseChangeSetRecursively(in_changeSet, {
|
|
@@ -1249,7 +1249,7 @@ var Utils;
|
|
|
1249
1249
|
let level = userData.currentLevel;
|
|
1250
1250
|
// We have to handle the case that a path contains nested properties. In that case we concatenate the
|
|
1251
1251
|
// properties in the path, as long as they are a prefix of the segment we are currently looking at
|
|
1252
|
-
let mergedSegment =
|
|
1252
|
+
let mergedSegment = pathHelper_js_1.PathHelper.quotePathSegmentIfNeeded(currentSegment);
|
|
1253
1253
|
while (changesetSegment.length > mergedSegment.length &&
|
|
1254
1254
|
changesetSegment.substr(0, mergedSegment.length) === mergedSegment &&
|
|
1255
1255
|
level < pathSegments.length - 1) {
|
|
@@ -1257,7 +1257,7 @@ var Utils;
|
|
|
1257
1257
|
mergedSegment =
|
|
1258
1258
|
mergedSegment +
|
|
1259
1259
|
PROPERTY_PATH_DELIMITER +
|
|
1260
|
-
|
|
1260
|
+
pathHelper_js_1.PathHelper.quotePathSegmentIfNeeded(pathSegments[level]);
|
|
1261
1261
|
}
|
|
1262
1262
|
// Have we found the right entry in the ChangeSet?
|
|
1263
1263
|
// TODO: This could be done more efficiently
|
|
@@ -1317,11 +1317,11 @@ var Utils;
|
|
|
1317
1317
|
*
|
|
1318
1318
|
* ```typescript
|
|
1319
1319
|
* new Map([
|
|
1320
|
-
*
|
|
1321
|
-
*
|
|
1322
|
-
*
|
|
1323
|
-
*
|
|
1324
|
-
*
|
|
1320
|
+
* ['entry', new Map()],
|
|
1321
|
+
* ['nested', new Map([
|
|
1322
|
+
* ['entry2', new Map()],
|
|
1323
|
+
* ['entry3', new Map()]
|
|
1324
|
+
* ])]
|
|
1325
1325
|
* ])
|
|
1326
1326
|
* ```
|
|
1327
1327
|
*
|
|
@@ -1329,11 +1329,11 @@ var Utils;
|
|
|
1329
1329
|
*
|
|
1330
1330
|
* ```typescript
|
|
1331
1331
|
* {
|
|
1332
|
-
*
|
|
1333
|
-
*
|
|
1334
|
-
*
|
|
1335
|
-
*
|
|
1336
|
-
*
|
|
1332
|
+
* entry: {},
|
|
1333
|
+
* nested: {
|
|
1334
|
+
* entry2: {}
|
|
1335
|
+
* entry3: {}
|
|
1336
|
+
* }
|
|
1337
1337
|
* }
|
|
1338
1338
|
* ```
|
|
1339
1339
|
*
|
|
@@ -1450,7 +1450,7 @@ var Utils;
|
|
|
1450
1450
|
if (changesetSegment.indexOf(".") !== -1 ||
|
|
1451
1451
|
(changesetSegment.length > 0 && changesetSegment.startsWith('"'))) {
|
|
1452
1452
|
nestedSubPath = currentSubPaths;
|
|
1453
|
-
const tokenized =
|
|
1453
|
+
const tokenized = pathHelper_js_1.PathHelper.tokenizePathString(changesetSegment);
|
|
1454
1454
|
numberOfSegments = tokenized.length;
|
|
1455
1455
|
for (let i = 0; i < tokenized.length; i++) {
|
|
1456
1456
|
let segment = tokenized[i];
|
|
@@ -1583,7 +1583,7 @@ var Utils;
|
|
|
1583
1583
|
if (tokenizedPath.length === 1) {
|
|
1584
1584
|
// first depth
|
|
1585
1585
|
changeSetToPopulate = rootChangeSet;
|
|
1586
|
-
fullPath =
|
|
1586
|
+
fullPath = pathHelper_js_1.PathHelper.quotePathSegmentIfNeeded(tokenizedPath[0]);
|
|
1587
1587
|
const pathEntry = pathsToObj.get(tokenizedPath[0]);
|
|
1588
1588
|
if (pathEntry) {
|
|
1589
1589
|
pathHasBeenFound = true;
|
|
@@ -1596,7 +1596,7 @@ var Utils;
|
|
|
1596
1596
|
const pathsToDelete = [];
|
|
1597
1597
|
tokenizedPath.forEach((segment, index) => {
|
|
1598
1598
|
if (index === 0) {
|
|
1599
|
-
parentPath +=
|
|
1599
|
+
parentPath += pathHelper_js_1.PathHelper.quotePathSegmentIfNeeded(segment);
|
|
1600
1600
|
changeSetToPopulate =
|
|
1601
1601
|
pathToChangeSet[parentPath] || changeSetToPopulate;
|
|
1602
1602
|
}
|
|
@@ -1604,8 +1604,8 @@ var Utils;
|
|
|
1604
1604
|
parentPath +=
|
|
1605
1605
|
context.getContainerStack()[index] !== "set" &&
|
|
1606
1606
|
context.getContainerStack()[index] !== "map"
|
|
1607
|
-
? `.${
|
|
1608
|
-
: `[${
|
|
1607
|
+
? `.${pathHelper_js_1.PathHelper.quotePathSegmentIfNeeded(segment)}`
|
|
1608
|
+
: `[${pathHelper_js_1.PathHelper.quotePathSegmentIfNeeded(segment)}]`;
|
|
1609
1609
|
changeSetToPopulate =
|
|
1610
1610
|
pathToChangeSet[parentPath] || changeSetToPopulate;
|
|
1611
1611
|
}
|
|
@@ -1613,8 +1613,8 @@ var Utils;
|
|
|
1613
1613
|
parentPath +=
|
|
1614
1614
|
context.getContainerStack()[index] !== "set" &&
|
|
1615
1615
|
context.getContainerStack()[index] !== "map"
|
|
1616
|
-
? `.${
|
|
1617
|
-
: `[${
|
|
1616
|
+
? `.${pathHelper_js_1.PathHelper.quotePathSegmentIfNeeded(segment)}`
|
|
1617
|
+
: `[${pathHelper_js_1.PathHelper.quotePathSegmentIfNeeded(segment)}]`;
|
|
1618
1618
|
fullPath = parentPath;
|
|
1619
1619
|
}
|
|
1620
1620
|
pathsToDelete.push(parentPath);
|
|
@@ -1690,7 +1690,7 @@ var Utils;
|
|
|
1690
1690
|
if (contractedPathSegment &&
|
|
1691
1691
|
(lastSegment.indexOf(".") !== -1 ||
|
|
1692
1692
|
(lastSegment.length > 0 && lastSegment.startsWith('"'))) &&
|
|
1693
|
-
|
|
1693
|
+
pathHelper_js_1.PathHelper.tokenizePathString(lastSegment).length > 1) {
|
|
1694
1694
|
toPurge[context.getFullPath()] = {
|
|
1695
1695
|
changeSet: changeSetToPopulate,
|
|
1696
1696
|
typeid: context.getTypeid(),
|
|
@@ -1703,9 +1703,9 @@ var Utils;
|
|
|
1703
1703
|
});
|
|
1704
1704
|
// Delete entries from the change set that we do not want.
|
|
1705
1705
|
// We can enter this case when dealing with folded paths.
|
|
1706
|
-
(0,
|
|
1706
|
+
(0, each_js_1.default)(toPurge, function (item, fullPath) {
|
|
1707
1707
|
delete item.changeSet[item.typeid][item.pathToPurge];
|
|
1708
|
-
if ((0,
|
|
1708
|
+
if ((0, isEmpty_js_1.default)(item.changeSet[item.typeid])) {
|
|
1709
1709
|
delete item.changeSet[item.typeid];
|
|
1710
1710
|
}
|
|
1711
1711
|
});
|
|
@@ -1724,10 +1724,10 @@ var Utils;
|
|
|
1724
1724
|
const operationCS = CS[operation];
|
|
1725
1725
|
let typeidCS = CS[operation][removalInformation.typeid];
|
|
1726
1726
|
delete typeidCS[removalInformation.lastSegment];
|
|
1727
|
-
if ((0,
|
|
1727
|
+
if ((0, isEmpty_js_1.default)(typeidCS)) {
|
|
1728
1728
|
delete operationCS[removalInformation.typeid];
|
|
1729
1729
|
}
|
|
1730
|
-
if ((0,
|
|
1730
|
+
if ((0, isEmpty_js_1.default)(CS[operation])) {
|
|
1731
1731
|
delete CS[operation];
|
|
1732
1732
|
}
|
|
1733
1733
|
}
|
|
@@ -1735,7 +1735,7 @@ var Utils;
|
|
|
1735
1735
|
else {
|
|
1736
1736
|
let typeidCS = CS[removalInformation.typeid];
|
|
1737
1737
|
delete typeidCS[removalInformation.lastSegment];
|
|
1738
|
-
if ((0,
|
|
1738
|
+
if ((0, isEmpty_js_1.default)(typeidCS)) {
|
|
1739
1739
|
delete CS[removalInformation.typeid];
|
|
1740
1740
|
}
|
|
1741
1741
|
}
|
|
@@ -1756,7 +1756,7 @@ var Utils;
|
|
|
1756
1756
|
in_paths = Array.isArray(in_paths) ? in_paths : [in_paths];
|
|
1757
1757
|
const pathsToProcess = new Set(in_paths);
|
|
1758
1758
|
// create an array of arrays splitting by .
|
|
1759
|
-
const tokenizedPaths = in_paths.map((path) =>
|
|
1759
|
+
const tokenizedPaths = in_paths.map((path) => pathHelper_js_1.PathHelper.tokenizePathString(path));
|
|
1760
1760
|
// Create a tree representation of the paths that are passed as an input so that
|
|
1761
1761
|
// we can leverage getChangesToTokenizedPaths and only be notified on paths
|
|
1762
1762
|
// that we care about.
|
|
@@ -1767,10 +1767,10 @@ var Utils;
|
|
|
1767
1767
|
for (let index = 0; index < tokenizedPath.length; index++) {
|
|
1768
1768
|
segment = tokenizedPath[index];
|
|
1769
1769
|
if (index === 0) {
|
|
1770
|
-
path =
|
|
1770
|
+
path = pathHelper_js_1.PathHelper.quotePathSegmentIfNeeded(segment);
|
|
1771
1771
|
}
|
|
1772
1772
|
else {
|
|
1773
|
-
path += `.${
|
|
1773
|
+
path += `.${pathHelper_js_1.PathHelper.quotePathSegmentIfNeeded(segment)}`;
|
|
1774
1774
|
}
|
|
1775
1775
|
if (pathsToProcess.has(path) && index < tokenizedPath.length - 1) {
|
|
1776
1776
|
return memo;
|
|
@@ -1824,17 +1824,17 @@ var Utils;
|
|
|
1824
1824
|
* @internal
|
|
1825
1825
|
*/
|
|
1826
1826
|
function excludePathsFromChangeSet(in_changeSet, in_paths) {
|
|
1827
|
-
if (!in_changeSet || !in_paths || (0,
|
|
1827
|
+
if (!in_changeSet || !in_paths || (0, isEmpty_js_1.default)(in_paths)) {
|
|
1828
1828
|
return in_changeSet;
|
|
1829
1829
|
}
|
|
1830
1830
|
in_paths = Array.isArray(in_paths) ? in_paths : [in_paths];
|
|
1831
1831
|
// create an array of arrays splitting by .
|
|
1832
|
-
const tokenizedPaths = in_paths.map((path) =>
|
|
1832
|
+
const tokenizedPaths = in_paths.map((path) => pathHelper_js_1.PathHelper.tokenizePathString(path));
|
|
1833
1833
|
const rootChangeSet = (0, fastest_json_copy_1.copy)(in_changeSet);
|
|
1834
1834
|
Utils.traverseChangeSetRecursively(rootChangeSet, {
|
|
1835
1835
|
preCallback: (in_context) => {
|
|
1836
|
-
const shouldExclude = (0,
|
|
1837
|
-
return (0,
|
|
1836
|
+
const shouldExclude = (0, find_js_1.default)(tokenizedPaths, (val) => {
|
|
1837
|
+
return (0, isEqual_js_1.default)(val, in_context.getParentStack());
|
|
1838
1838
|
});
|
|
1839
1839
|
if (shouldExclude) {
|
|
1840
1840
|
const operationType = in_context.getOperationType();
|