@fluid-experimental/property-changeset 2.0.0-internal.1.2.0.93071 → 2.0.0-internal.1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/changeset.d.ts.map +1 -1
- package/dist/changeset.js +3 -6
- package/dist/changeset.js.map +1 -1
- package/dist/changeset_operations/array.d.ts +31 -0
- package/dist/changeset_operations/array.d.ts.map +1 -1
- package/dist/changeset_operations/array.js +52 -47
- package/dist/changeset_operations/array.js.map +1 -1
- package/dist/changeset_operations/indexedCollection.d.ts +12 -14
- package/dist/changeset_operations/indexedCollection.d.ts.map +1 -1
- package/dist/changeset_operations/indexedCollection.js +13 -14
- package/dist/changeset_operations/indexedCollection.js.map +1 -1
- package/dist/helpers/typeidHelper.d.ts +6 -6
- package/dist/helpers/typeidHelper.d.ts.map +1 -1
- package/dist/helpers/typeidHelper.js +16 -26
- package/dist/helpers/typeidHelper.js.map +1 -1
- package/dist/pathHelper.d.ts +1 -1
- package/dist/pathHelper.d.ts.map +1 -1
- package/dist/pathHelper.js +50 -52
- package/dist/pathHelper.js.map +1 -1
- package/dist/templateValidator.d.ts +58 -26
- package/dist/templateValidator.d.ts.map +1 -1
- package/dist/templateValidator.js +64 -38
- package/dist/templateValidator.js.map +1 -1
- package/dist/test/array.spec.js +3 -6
- package/dist/test/array.spec.js.map +1 -1
- package/dist/test/pathHelper.spec.js +2 -4
- package/dist/test/pathHelper.spec.js.map +1 -1
- package/dist/test/reversibleCs.spec.js +2 -4
- package/dist/test/reversibleCs.spec.js.map +1 -1
- package/dist/test/tsconfig.tsbuildinfo +1 -1
- package/dist/test/validator/templateValidator.spec.js +5 -10
- package/dist/test/validator/templateValidator.spec.js.map +1 -1
- package/dist/utils.d.ts +131 -103
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +160 -167
- package/dist/utils.js.map +1 -1
- package/dist/validationResultBuilder.d.ts +2 -4
- package/dist/validationResultBuilder.d.ts.map +1 -1
- package/dist/validationResultBuilder.js +1 -7
- package/dist/validationResultBuilder.js.map +1 -1
- package/lib/changeset.js +3 -6
- package/lib/changeset.js.map +1 -1
- package/lib/changeset_operations/array.js +52 -47
- package/lib/changeset_operations/array.js.map +1 -1
- package/lib/changeset_operations/indexedCollection.js +13 -14
- package/lib/changeset_operations/indexedCollection.js.map +1 -1
- package/lib/helpers/typeidHelper.js +16 -26
- package/lib/helpers/typeidHelper.js.map +1 -1
- package/lib/pathHelper.js +50 -52
- package/lib/pathHelper.js.map +1 -1
- package/lib/templateValidator.js +64 -38
- package/lib/templateValidator.js.map +1 -1
- package/lib/utils.js +160 -167
- package/lib/utils.js.map +1 -1
- package/lib/validationResultBuilder.js +1 -7
- package/lib/validationResultBuilder.js.map +1 -1
- package/package.json +3 -3
package/lib/utils.js
CHANGED
|
@@ -24,16 +24,17 @@ const { PROPERTY_PATH_DELIMITER, MSG } = constants;
|
|
|
24
24
|
* @alias property-changeset.Utils
|
|
25
25
|
* @class
|
|
26
26
|
*/
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
27
28
|
export var Utils;
|
|
28
29
|
(function (Utils) {
|
|
29
30
|
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
* Traverses a ChangeSet recursively and invokes the callback for each visited property.
|
|
32
|
+
*
|
|
33
|
+
* @param in_preCallback - The (pre-order) callback function that is invoked for each property
|
|
34
|
+
* @param in_postCallback - The (post-order) callback function that is invoked for each property
|
|
35
|
+
* @param in_context - The traversal context for the currently processed property
|
|
36
|
+
* @param in_levelCallback - A callback for when a node is reached
|
|
37
|
+
*/
|
|
37
38
|
function _traverseChangeSetRecursivelyAsync(in_preCallback, in_postCallback, in_context, in_levelCallback) {
|
|
38
39
|
let pathSeparator;
|
|
39
40
|
let currentPath;
|
|
@@ -106,14 +107,11 @@ export var Utils;
|
|
|
106
107
|
let nextSegmentToPushInParentStack = in_context.getLastSegment();
|
|
107
108
|
// Note: we don't quote the path string here, since the paths
|
|
108
109
|
// in a ChangeSet are already quoted, if necessary
|
|
109
|
-
|
|
110
|
+
in_context._lastSegmentString = currentTypeIdContext === "map" ||
|
|
110
111
|
currentTypeIdContext === "array" ||
|
|
111
|
-
currentTypeIdContext === "set"
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
else {
|
|
115
|
-
in_context._lastSegmentString = pathSeparator + escapedSegment;
|
|
116
|
-
}
|
|
112
|
+
currentTypeIdContext === "set"
|
|
113
|
+
? `[${escapedSegment}]`
|
|
114
|
+
: pathSeparator + escapedSegment;
|
|
117
115
|
in_context._fullPath = currentPath + in_context.getLastSegmentString();
|
|
118
116
|
// Store the typeid and nested ChangeSet
|
|
119
117
|
in_context._typeid = in_nestedTypeid;
|
|
@@ -463,14 +461,11 @@ export var Utils;
|
|
|
463
461
|
const escapedSegment = in_escape && isString(in_segment) ? PathHelper.quotePathSegmentIfNeeded(in_segment) : in_segment;
|
|
464
462
|
let nextSegmentToPushInParentStack = in_context._lastSegment;
|
|
465
463
|
// Note: we don't quote the path string here, since the paths in a ChangeSet are already quoted, if necessary
|
|
466
|
-
|
|
464
|
+
in_context._lastSegmentString = currentTypeIdContext === "map" ||
|
|
467
465
|
currentTypeIdContext === "array" ||
|
|
468
|
-
currentTypeIdContext === "set"
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
else {
|
|
472
|
-
in_context._lastSegmentString = pathSeparator + escapedSegment;
|
|
473
|
-
}
|
|
466
|
+
currentTypeIdContext === "set"
|
|
467
|
+
? `[${escapedSegment}]`
|
|
468
|
+
: pathSeparator + escapedSegment;
|
|
474
469
|
in_context._fullPath = currentPath + in_context._lastSegmentString;
|
|
475
470
|
// Store the typeid and nested ChangeSet
|
|
476
471
|
in_context._typeid = in_nestedTypeid;
|
|
@@ -753,12 +748,9 @@ export var Utils;
|
|
|
753
748
|
*/
|
|
754
749
|
getPostLastSegment() {
|
|
755
750
|
if (this._propertyContainerType === "array" && isNumber(this._lastSegment) && this._arrayIteratorOffset !== undefined) {
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
else {
|
|
760
|
-
return this._lastSegment + this._arrayIteratorOffset;
|
|
761
|
-
}
|
|
751
|
+
return this._operationType === "remove"
|
|
752
|
+
? this._lastSegment + this._arrayIteratorOffset - this._arrayLocalIndex
|
|
753
|
+
: this._lastSegment + this._arrayIteratorOffset;
|
|
762
754
|
}
|
|
763
755
|
else {
|
|
764
756
|
return this._lastSegment;
|
|
@@ -983,14 +975,7 @@ export var Utils;
|
|
|
983
975
|
}
|
|
984
976
|
else {
|
|
985
977
|
// if we're given an extra rootTypeId, use that
|
|
986
|
-
|
|
987
|
-
context._typeid = in_params.rootTypeid;
|
|
988
|
-
}
|
|
989
|
-
else {
|
|
990
|
-
// By default, we assume that a ChangeSet without a typeid affects a NodeProperty, since that is the default
|
|
991
|
-
// for a repository root
|
|
992
|
-
context._typeid = "NodeProperty";
|
|
993
|
-
}
|
|
978
|
+
context._typeid = in_params.rootTypeid ? in_params.rootTypeid : "NodeProperty";
|
|
994
979
|
}
|
|
995
980
|
context._nestedChangeSet = in_changeSet;
|
|
996
981
|
context._parentNestedChangeSet = in_changeSet;
|
|
@@ -1021,14 +1006,7 @@ export var Utils;
|
|
|
1021
1006
|
}
|
|
1022
1007
|
else {
|
|
1023
1008
|
// if we're given an extra rootTypeId, use that
|
|
1024
|
-
|
|
1025
|
-
context._typeid = in_params.rootTypeid;
|
|
1026
|
-
}
|
|
1027
|
-
else {
|
|
1028
|
-
// By default, we assume that a ChangeSet without a typeid affects a NodeProperty, since that is the default
|
|
1029
|
-
// for a repository root
|
|
1030
|
-
context._typeid = "NodeProperty";
|
|
1031
|
-
}
|
|
1009
|
+
context._typeid = in_params.rootTypeid ? in_params.rootTypeid : "NodeProperty";
|
|
1032
1010
|
}
|
|
1033
1011
|
context._nestedChangeSet = in_changeSet;
|
|
1034
1012
|
context._parentNestedChangeSet = in_changeSet;
|
|
@@ -1069,9 +1047,8 @@ export var Utils;
|
|
|
1069
1047
|
* @param in_callback - A callback that is used to emit every template
|
|
1070
1048
|
* @param in_finalizer - A callback that is called when enumeration is completed
|
|
1071
1049
|
*
|
|
1072
|
-
* @returns All templates that appear in the ChangeSet
|
|
1073
|
-
*
|
|
1074
|
-
* definition (object)
|
|
1050
|
+
* @returns All templates that appear in the ChangeSet.
|
|
1051
|
+
* The returned object has members key (string), corresponding to the type and value with the definition (object)
|
|
1075
1052
|
*/
|
|
1076
1053
|
function enumerateSchemas(in_changeSet, in_callback, in_finalizer) {
|
|
1077
1054
|
const result = [];
|
|
@@ -1111,14 +1088,10 @@ export var Utils;
|
|
|
1111
1088
|
}
|
|
1112
1089
|
return;
|
|
1113
1090
|
}
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
}
|
|
1119
|
-
else {
|
|
1120
|
-
operationScope = userData;
|
|
1121
|
-
}
|
|
1091
|
+
const operationScope = in_context.getPropertyContainerType() !== "template"
|
|
1092
|
+
? (userData[in_context.getOperationType()] = userData[in_context.getOperationType()]
|
|
1093
|
+
|| (in_context.getPropertyContainerType() === "array" ? [] : {}))
|
|
1094
|
+
: userData;
|
|
1122
1095
|
if (TypeIdHelper.isPrimitiveType(in_context.getTypeid())) {
|
|
1123
1096
|
// This is a primitive type, we store it under its name in the result
|
|
1124
1097
|
operationScope[in_context.getLastSegment()] = in_context.getNestedChangeSet();
|
|
@@ -1194,10 +1167,13 @@ export var Utils;
|
|
|
1194
1167
|
* @param in_changeSet - The ChangeSet to process
|
|
1195
1168
|
* @param in_excludetypeids - Exclude all typeids from the returned ChangeSet
|
|
1196
1169
|
* @throws if path is invalid.
|
|
1197
|
-
* @returns The changes that are applied to the given path
|
|
1170
|
+
* @returns The changes that are applied to the given path.
|
|
1171
|
+
*
|
|
1172
|
+
* ```
|
|
1198
1173
|
* <pre>
|
|
1199
1174
|
* {insert: Object|undefined, modify: Object|undefined, remove: boolean|undefined}
|
|
1200
1175
|
* </pre>
|
|
1176
|
+
* ```
|
|
1201
1177
|
*/
|
|
1202
1178
|
function getChangesByPath(in_path, in_root, in_changeSet, in_excludetypeids) {
|
|
1203
1179
|
// if we're asked for the root, just return the root (in a modify)
|
|
@@ -1269,65 +1245,78 @@ export var Utils;
|
|
|
1269
1245
|
/**
|
|
1270
1246
|
* Invoke a callback for all nested ChangeSets that correspond to a set of user supplied tokenized paths.
|
|
1271
1247
|
*
|
|
1272
|
-
* @param in_paths -
|
|
1273
|
-
*
|
|
1274
|
-
*
|
|
1275
|
-
*
|
|
1276
|
-
*
|
|
1277
|
-
*
|
|
1278
|
-
*
|
|
1248
|
+
* @param in_paths - A map or object which contains the tokenized paths as nested elements.
|
|
1249
|
+
* Common path segment are thus shared.
|
|
1250
|
+
*
|
|
1251
|
+
* NOTE: It is recommended to use Map as it provides better performance.
|
|
1252
|
+
* For example, for these three paths:
|
|
1253
|
+
*
|
|
1254
|
+
* - 'entry1'
|
|
1255
|
+
*
|
|
1256
|
+
* - 'nested.entry2'
|
|
1257
|
+
*
|
|
1258
|
+
* - 'nested.entry3'
|
|
1279
1259
|
*
|
|
1280
|
-
*
|
|
1281
|
-
* new Map([
|
|
1282
|
-
* ['entry', new Map()],
|
|
1283
|
-
* ['nested', new Map([
|
|
1284
|
-
* ['entry2', new Map()],
|
|
1285
|
-
* ['entry3', new Map()]
|
|
1286
|
-
* ])]
|
|
1287
|
-
* ])
|
|
1260
|
+
* Using a map for paths would look like this:
|
|
1288
1261
|
*
|
|
1289
|
-
*
|
|
1290
|
-
*
|
|
1291
|
-
*
|
|
1292
|
-
*
|
|
1293
|
-
*
|
|
1294
|
-
*
|
|
1295
|
-
*
|
|
1296
|
-
*
|
|
1262
|
+
* ```typescript
|
|
1263
|
+
* new Map([
|
|
1264
|
+
* ['entry', new Map()],
|
|
1265
|
+
* ['nested', new Map([
|
|
1266
|
+
* ['entry2', new Map()],
|
|
1267
|
+
* ['entry3', new Map()]
|
|
1268
|
+
* ])]
|
|
1269
|
+
* ])
|
|
1270
|
+
* ```
|
|
1297
1271
|
*
|
|
1298
|
-
*
|
|
1299
|
-
*
|
|
1300
|
-
*
|
|
1301
|
-
*
|
|
1302
|
-
*
|
|
1303
|
-
*
|
|
1304
|
-
*
|
|
1305
|
-
*
|
|
1306
|
-
*
|
|
1307
|
-
*
|
|
1308
|
-
*
|
|
1309
|
-
*
|
|
1310
|
-
*
|
|
1311
|
-
*
|
|
1312
|
-
*
|
|
1313
|
-
*
|
|
1314
|
-
*
|
|
1315
|
-
*
|
|
1316
|
-
*
|
|
1317
|
-
*
|
|
1318
|
-
*
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
* @param
|
|
1325
|
-
*
|
|
1272
|
+
* While using objects for paths would look like this:
|
|
1273
|
+
*
|
|
1274
|
+
* ```typescript
|
|
1275
|
+
* {
|
|
1276
|
+
* entry: {},
|
|
1277
|
+
* nested: {
|
|
1278
|
+
* entry2: {}
|
|
1279
|
+
* entry3: {}
|
|
1280
|
+
* }
|
|
1281
|
+
* }
|
|
1282
|
+
* ```
|
|
1283
|
+
*
|
|
1284
|
+
* The element under the path, will be provided to the callback. If you have to pass additional data
|
|
1285
|
+
* to the callback, you can add private data by prefixing it with __ and setting
|
|
1286
|
+
* in_options.escapeLeadingDoubleUnderscore to true.
|
|
1287
|
+
* In case you do that, bear in mind that paths that refer to changeSet properties that have at least
|
|
1288
|
+
* two underscores as prefix in its id, should contain an extra underscore character as prefix:
|
|
1289
|
+
*
|
|
1290
|
+
* ```
|
|
1291
|
+
* | Path in changeSet | Path in paths |
|
|
1292
|
+
* | path0 | path0 | (unescaped)
|
|
1293
|
+
* | _path1 | _path1 | (unescaoed)
|
|
1294
|
+
* | __path2 | ___path2 | (escaped with one extra leading underscore)
|
|
1295
|
+
* | ___path3 | ____path3 | (also escaped, the same applies to N underscores where N >= 2)
|
|
1296
|
+
* ```
|
|
1297
|
+
* @param in_changeSet - The ChangeSet to process
|
|
1298
|
+
* @param in_callback - The function to invoke at the registered paths (it is called both for the interior and the
|
|
1299
|
+
* leaf nodes). The callback will be called for each node with the following parameters:
|
|
1300
|
+
*
|
|
1301
|
+
* - `context`: The current TraversalContext as returned by Utils.traverseChangeSetRecursively.
|
|
1302
|
+
* Can be used for querying the current Property type, operation, etc.
|
|
1303
|
+
*
|
|
1304
|
+
* - `currentSubPaths`: A subset of the tokenized paths passed in as input to this function that still need to be
|
|
1305
|
+
* processed from the current node
|
|
1306
|
+
*
|
|
1307
|
+
* - `currentTokenizedPath`: The tokenized path leading to the current node
|
|
1308
|
+
*
|
|
1309
|
+
* - `contractedPathSegment`: True if the current node is inside a contracted path segment (e.g.
|
|
1310
|
+
* currentTokenizedPath is ['foo'], coming from the changeset segment 'foo.bar'), false otherwise. If true, the
|
|
1311
|
+
* typeid from the context parameter may not be valid at the current node. Callbacks may ignore this if they are
|
|
1312
|
+
* not concerned with the type.
|
|
1313
|
+
*
|
|
1314
|
+
* @param in_options.rootOperation - The operation that has been applied to the root of the ChangeSet
|
|
1315
|
+
* (either 'insert' or 'modify')
|
|
1326
1316
|
* @param in_options.rootTypeid - The full type of the root Property of the ChangeSet
|
|
1327
|
-
* @param in_options.escapeLeadingDoubleUnderscore -
|
|
1328
|
-
*
|
|
1329
|
-
*
|
|
1330
|
-
* application.
|
|
1317
|
+
* @param in_options.escapeLeadingDoubleUnderscore - If this is set to true, keys which start with '__' will be
|
|
1318
|
+
* escaped (by adding an additional '_') before the lookup into the paths map. This frees the keyspace with
|
|
1319
|
+
* duplicated underscores for the use by the calling application.
|
|
1331
1320
|
*/
|
|
1332
1321
|
function getChangesToTokenizedPaths(in_paths, in_changeSet, in_callback, in_options = { escapeLeadingDoubleUnderscore: false, rootOperation: 'modify' }) {
|
|
1333
1322
|
const currentTokenizedPath = [];
|
|
@@ -1375,14 +1364,11 @@ export var Utils;
|
|
|
1375
1364
|
return thisLevel;
|
|
1376
1365
|
};
|
|
1377
1366
|
const _toCallbackParam = (pathLevels) => {
|
|
1378
|
-
|
|
1367
|
+
return legacyPaths
|
|
1379
1368
|
// If a user provided objects as paths, they would expect objects in their callbacks as well.
|
|
1380
1369
|
// So, we transform the parameter to an object, which is not very performant but is backwards compatible.
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
else {
|
|
1384
|
-
return pathLevels;
|
|
1385
|
-
}
|
|
1370
|
+
? _convertMapToLevel(pathLevels)
|
|
1371
|
+
: pathLevels;
|
|
1386
1372
|
};
|
|
1387
1373
|
if (!(in_paths instanceof Map)) {
|
|
1388
1374
|
legacyPaths = true;
|
|
@@ -1478,32 +1464,37 @@ export var Utils;
|
|
|
1478
1464
|
* Given a change set, this function will filter it based on a series of paths.
|
|
1479
1465
|
* The final ChangeSet will only include the paths in question starting from the root of
|
|
1480
1466
|
* the ChangeSet.
|
|
1481
|
-
*
|
|
1482
|
-
*
|
|
1483
|
-
*
|
|
1484
|
-
*
|
|
1485
|
-
*
|
|
1486
|
-
*
|
|
1487
|
-
*
|
|
1488
|
-
*
|
|
1489
|
-
*
|
|
1490
|
-
*
|
|
1491
|
-
*
|
|
1492
|
-
*
|
|
1493
|
-
*
|
|
1494
|
-
*
|
|
1495
|
-
*
|
|
1496
|
-
*
|
|
1467
|
+
*
|
|
1468
|
+
* @example Given the following change set:
|
|
1469
|
+
*
|
|
1470
|
+
* ```json
|
|
1471
|
+
* 'insert': {
|
|
1472
|
+
* 'String': {
|
|
1473
|
+
* 'string1': 'hello',
|
|
1474
|
+
* 'string2': 'world
|
|
1475
|
+
* }
|
|
1476
|
+
* }
|
|
1477
|
+
* ```
|
|
1478
|
+
*
|
|
1479
|
+
* And the path `['string1']`, the resulting ChangeSet will be:
|
|
1480
|
+
*
|
|
1481
|
+
* ```json
|
|
1482
|
+
* 'insert': {
|
|
1483
|
+
* 'String': {
|
|
1484
|
+
* 'string1': 'hello'
|
|
1485
|
+
* }
|
|
1486
|
+
* }
|
|
1487
|
+
* ```
|
|
1497
1488
|
*
|
|
1498
1489
|
* NOTE: Paths that traverse through sets and arrays are not supported.
|
|
1499
1490
|
*
|
|
1500
|
-
* @param in_changeSet - The changeset to parse
|
|
1491
|
+
* @param in_changeSet - The changeset to parse.
|
|
1501
1492
|
* @param in_paths - List of paths to filter by. This can either be passed
|
|
1502
|
-
*
|
|
1503
|
-
*
|
|
1504
|
-
*
|
|
1493
|
+
* as a flat array of paths or as a Map with the tokenized, tree structured paths, see the
|
|
1494
|
+
* documentation of getChangesToTokenizedPaths for an example.
|
|
1495
|
+
* Note: duplicate paths will be ignored including ones that encompasse other paths.
|
|
1505
1496
|
*
|
|
1506
|
-
* @throws
|
|
1497
|
+
* @throws If a path given resolves into an array or set.
|
|
1507
1498
|
* @returns - Filtered ChangeSet
|
|
1508
1499
|
*/
|
|
1509
1500
|
function getFilteredChangeSetByPaths(in_changeSet, in_paths) {
|
|
@@ -1550,21 +1541,15 @@ export var Utils;
|
|
|
1550
1541
|
changeSetToPopulate = pathToChangeSet[parentPath] || changeSetToPopulate;
|
|
1551
1542
|
}
|
|
1552
1543
|
else if (index < tokenizedPath.length - 1) {
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
else {
|
|
1557
|
-
parentPath += `[${PathHelper.quotePathSegmentIfNeeded(segment)}]`;
|
|
1558
|
-
}
|
|
1544
|
+
parentPath += context.getContainerStack()[index] !== "set" && context.getContainerStack()[index] !== "map"
|
|
1545
|
+
? `.${PathHelper.quotePathSegmentIfNeeded(segment)}`
|
|
1546
|
+
: `[${PathHelper.quotePathSegmentIfNeeded(segment)}]`;
|
|
1559
1547
|
changeSetToPopulate = pathToChangeSet[parentPath] || changeSetToPopulate;
|
|
1560
1548
|
}
|
|
1561
1549
|
else {
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
else {
|
|
1566
|
-
parentPath += `[${PathHelper.quotePathSegmentIfNeeded(segment)}]`;
|
|
1567
|
-
}
|
|
1550
|
+
parentPath += context.getContainerStack()[index] !== "set" && context.getContainerStack()[index] !== "map"
|
|
1551
|
+
? `.${PathHelper.quotePathSegmentIfNeeded(segment)}`
|
|
1552
|
+
: `[${PathHelper.quotePathSegmentIfNeeded(segment)}]`;
|
|
1568
1553
|
fullPath = parentPath;
|
|
1569
1554
|
}
|
|
1570
1555
|
pathsToDelete.push(parentPath);
|
|
@@ -1697,7 +1682,7 @@ export var Utils;
|
|
|
1697
1682
|
*
|
|
1698
1683
|
* @param in_paths - An array with paths
|
|
1699
1684
|
* @returns {Map} A tree structured representation of the tokenized paths that can be
|
|
1700
|
-
*
|
|
1685
|
+
* passed to getChangesToTokenizedPaths and getFilteredChangeSetByPaths.
|
|
1701
1686
|
*/
|
|
1702
1687
|
function convertPathArrayToTree(in_paths) {
|
|
1703
1688
|
in_paths = Array.isArray(in_paths) ? in_paths : [in_paths];
|
|
@@ -1737,22 +1722,27 @@ export var Utils;
|
|
|
1737
1722
|
* Given a change set, this function will filter it based on a series of paths.
|
|
1738
1723
|
* The final ChangeSet will exclude the paths in question starting from the root of
|
|
1739
1724
|
* the ChangeSet.
|
|
1740
|
-
*
|
|
1741
|
-
*
|
|
1742
|
-
*
|
|
1743
|
-
*
|
|
1744
|
-
*
|
|
1745
|
-
*
|
|
1746
|
-
*
|
|
1747
|
-
*
|
|
1748
|
-
*
|
|
1749
|
-
*
|
|
1750
|
-
*
|
|
1751
|
-
*
|
|
1752
|
-
*
|
|
1753
|
-
*
|
|
1754
|
-
*
|
|
1755
|
-
*
|
|
1725
|
+
*
|
|
1726
|
+
* @example Given the following change set:
|
|
1727
|
+
*
|
|
1728
|
+
* ```json
|
|
1729
|
+
* 'insert': {
|
|
1730
|
+
* 'String': {
|
|
1731
|
+
* 'string1': 'hello',
|
|
1732
|
+
* 'string2': 'world
|
|
1733
|
+
* }
|
|
1734
|
+
* }
|
|
1735
|
+
* ```
|
|
1736
|
+
*
|
|
1737
|
+
* And the path `['string1']`, the resulting ChangeSet will be:
|
|
1738
|
+
*
|
|
1739
|
+
* ```json
|
|
1740
|
+
* 'insert': {
|
|
1741
|
+
* 'String': {
|
|
1742
|
+
* 'string2': 'world'
|
|
1743
|
+
* }
|
|
1744
|
+
* }
|
|
1745
|
+
* ```
|
|
1756
1746
|
*
|
|
1757
1747
|
* NOTE: Paths that traverse through sets and arrays are not supported.
|
|
1758
1748
|
*
|
|
@@ -1787,7 +1777,8 @@ export var Utils;
|
|
|
1787
1777
|
Utils.excludePathsFromChangeSet = excludePathsFromChangeSet;
|
|
1788
1778
|
/**
|
|
1789
1779
|
* Extract all paths from the ChangeSet in a flattened list and include the operations and typeid information.
|
|
1790
|
-
* NOTE: The paths returned also include the parent. i.e. the path 'nodeProp.subproperty' will result in
|
|
1780
|
+
* @remarks NOTE: The paths returned also include the parent. i.e. the path 'nodeProp.subproperty' will result in:
|
|
1781
|
+
* ```json
|
|
1791
1782
|
* {
|
|
1792
1783
|
* nodeProp: {
|
|
1793
1784
|
* operation: 'modify',
|
|
@@ -1798,6 +1789,8 @@ export var Utils;
|
|
|
1798
1789
|
* typeid: { typeid: 'Float32', context: 'single', isEnum: false }
|
|
1799
1790
|
* }
|
|
1800
1791
|
* }
|
|
1792
|
+
* ```
|
|
1793
|
+
*
|
|
1801
1794
|
* @param in_changeSet - The changeset to extract paths from
|
|
1802
1795
|
* @param in_options - Set of options
|
|
1803
1796
|
* @param in_options.includeOperation - Flag to include the operation
|