@fluid-experimental/property-changeset 2.0.0-internal.3.0.5 → 2.0.0-internal.3.1.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.
Files changed (113) hide show
  1. package/README.md +1 -0
  2. package/dist/changeset.d.ts +2 -2
  3. package/dist/changeset.d.ts.map +1 -1
  4. package/dist/changeset.js +61 -45
  5. package/dist/changeset.js.map +1 -1
  6. package/dist/changeset_operations/array.d.ts +6 -6
  7. package/dist/changeset_operations/array.d.ts.map +1 -1
  8. package/dist/changeset_operations/array.js +87 -56
  9. package/dist/changeset_operations/array.js.map +1 -1
  10. package/dist/changeset_operations/arrayChangesetIterator.d.ts.map +1 -1
  11. package/dist/changeset_operations/arrayChangesetIterator.js +43 -41
  12. package/dist/changeset_operations/arrayChangesetIterator.js.map +1 -1
  13. package/dist/changeset_operations/changesetConflictTypes.d.ts.map +1 -1
  14. package/dist/changeset_operations/changesetConflictTypes.js.map +1 -1
  15. package/dist/changeset_operations/indexedCollection.d.ts.map +1 -1
  16. package/dist/changeset_operations/indexedCollection.js +76 -44
  17. package/dist/changeset_operations/indexedCollection.js.map +1 -1
  18. package/dist/changeset_operations/isEmptyChangeset.d.ts.map +1 -1
  19. package/dist/changeset_operations/isEmptyChangeset.js +2 -1
  20. package/dist/changeset_operations/isEmptyChangeset.js.map +1 -1
  21. package/dist/changeset_operations/operationTypes.d.ts.map +1 -1
  22. package/dist/changeset_operations/operationTypes.js.map +1 -1
  23. package/dist/helpers/typeidHelper.d.ts +10 -10
  24. package/dist/helpers/typeidHelper.d.ts.map +1 -1
  25. package/dist/helpers/typeidHelper.js +19 -17
  26. package/dist/helpers/typeidHelper.js.map +1 -1
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js.map +1 -1
  29. package/dist/isReservedKeyword.d.ts.map +1 -1
  30. package/dist/isReservedKeyword.js.map +1 -1
  31. package/dist/pathHelper.d.ts.map +1 -1
  32. package/dist/pathHelper.js +16 -10
  33. package/dist/pathHelper.js.map +1 -1
  34. package/dist/rebase.d.ts.map +1 -1
  35. package/dist/rebase.js +20 -13
  36. package/dist/rebase.js.map +1 -1
  37. package/dist/templateSchema.d.ts.map +1 -1
  38. package/dist/templateSchema.js +10 -11
  39. package/dist/templateSchema.js.map +1 -1
  40. package/dist/templateValidator.d.ts.map +1 -1
  41. package/dist/templateValidator.js +135 -102
  42. package/dist/templateValidator.js.map +1 -1
  43. package/dist/test/array.spec.js +141 -343
  44. package/dist/test/array.spec.js.map +1 -1
  45. package/dist/test/pathHelper.spec.js +299 -166
  46. package/dist/test/pathHelper.spec.js.map +1 -1
  47. package/dist/test/reversibleCs.spec.js.map +1 -1
  48. package/dist/test/schemaValidator.js +3 -1
  49. package/dist/test/schemaValidator.js.map +1 -1
  50. package/dist/test/schemas/badBothPropertiesAndTypeid.js +8 -8
  51. package/dist/test/schemas/badBothPropertiesAndTypeid.js.map +1 -1
  52. package/dist/test/schemas/badInvalidSemverInTypeid.js +18 -16
  53. package/dist/test/schemas/badInvalidSemverInTypeid.js.map +1 -1
  54. package/dist/test/schemas/badMissingSemverInTypeid.js +18 -16
  55. package/dist/test/schemas/badMissingSemverInTypeid.js.map +1 -1
  56. package/dist/test/schemas/badNestedProperties.js +18 -17
  57. package/dist/test/schemas/badNestedProperties.js.map +1 -1
  58. package/dist/test/schemas/badPrimitiveTypeid.js +9 -8
  59. package/dist/test/schemas/badPrimitiveTypeid.js.map +1 -1
  60. package/dist/test/schemas/badVersionedTypeid.js +19 -17
  61. package/dist/test/schemas/badVersionedTypeid.js.map +1 -1
  62. package/dist/test/schemas/goodColorPalette.js +4 -4
  63. package/dist/test/schemas/goodColorPalette.js.map +1 -1
  64. package/dist/test/schemas/goodDraftAsVersion.js +2 -4
  65. package/dist/test/schemas/goodDraftAsVersion.js.map +1 -1
  66. package/dist/test/schemas/goodPointId.js +18 -16
  67. package/dist/test/schemas/goodPointId.js.map +1 -1
  68. package/dist/test/schemas/goodReferenceAndRegular.js +5 -5
  69. package/dist/test/schemas/goodReferenceAndRegular.js.map +1 -1
  70. package/dist/test/schemas/goodReservedTypes.js +8 -7
  71. package/dist/test/schemas/goodReservedTypes.js.map +1 -1
  72. package/dist/test/schemas/goodUIBorder.js +19 -16
  73. package/dist/test/schemas/goodUIBorder.js.map +1 -1
  74. package/dist/test/tsconfig.tsbuildinfo +1 -1
  75. package/dist/test/validator/templateSyntax.spec.js.map +1 -1
  76. package/dist/test/validator/templateValidator.spec.js +329 -306
  77. package/dist/test/validator/templateValidator.spec.js.map +1 -1
  78. package/dist/test/validator/typeidHelper.spec.js +98 -65
  79. package/dist/test/validator/typeidHelper.spec.js.map +1 -1
  80. package/dist/utils.d.ts +1 -1
  81. package/dist/utils.d.ts.map +1 -1
  82. package/dist/utils.js +149 -95
  83. package/dist/utils.js.map +1 -1
  84. package/dist/validationResultBuilder.d.ts.map +1 -1
  85. package/dist/validationResultBuilder.js.map +1 -1
  86. package/lib/changeset.js +63 -47
  87. package/lib/changeset.js.map +1 -1
  88. package/lib/changeset_operations/array.js +88 -57
  89. package/lib/changeset_operations/array.js.map +1 -1
  90. package/lib/changeset_operations/arrayChangesetIterator.js +43 -41
  91. package/lib/changeset_operations/arrayChangesetIterator.js.map +1 -1
  92. package/lib/changeset_operations/changesetConflictTypes.js.map +1 -1
  93. package/lib/changeset_operations/indexedCollection.js +76 -44
  94. package/lib/changeset_operations/indexedCollection.js.map +1 -1
  95. package/lib/changeset_operations/isEmptyChangeset.js +2 -1
  96. package/lib/changeset_operations/isEmptyChangeset.js.map +1 -1
  97. package/lib/changeset_operations/operationTypes.js.map +1 -1
  98. package/lib/helpers/typeidHelper.js +19 -17
  99. package/lib/helpers/typeidHelper.js.map +1 -1
  100. package/lib/index.js.map +1 -1
  101. package/lib/isReservedKeyword.js.map +1 -1
  102. package/lib/pathHelper.js +17 -11
  103. package/lib/pathHelper.js.map +1 -1
  104. package/lib/rebase.js +20 -13
  105. package/lib/rebase.js.map +1 -1
  106. package/lib/templateSchema.js +10 -11
  107. package/lib/templateSchema.js.map +1 -1
  108. package/lib/templateValidator.js +135 -102
  109. package/lib/templateValidator.js.map +1 -1
  110. package/lib/utils.js +149 -95
  111. package/lib/utils.js.map +1 -1
  112. package/lib/validationResultBuilder.js.map +1 -1
  113. package/package.json +100 -100
package/lib/pathHelper.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * @fileoverview Helper functions to work with path strings
7
7
  */
8
8
  // @ts-ignore
9
- import { constants } from '@fluid-experimental/property-common';
9
+ import { constants } from "@fluid-experimental/property-common";
10
10
  const { PROPERTY_PATH_DELIMITER, MSG } = constants;
11
11
  /**
12
12
  * Helper functions for string processing
@@ -41,6 +41,7 @@ export var PathHelper;
41
41
  * @returns the tokens from the path string
42
42
  */
43
43
  PathHelper.tokenizePathString = function (in_path, out_types) {
44
+ // eslint-disable-line complexity
44
45
  const tokens = [];
45
46
  let currentToken = "";
46
47
  if (out_types) {
@@ -72,7 +73,9 @@ export var PathHelper;
72
73
  }
73
74
  // Let's see if the path is simple enough to use a fast-track algorithm.
74
75
  let hackedPath = in_path.substr(path_start);
75
- if (in_path.indexOf("\\") === -1 && in_path.indexOf('"') === -1 && in_path.indexOf("*") === -1) {
76
+ if (in_path.indexOf("\\") === -1 &&
77
+ in_path.indexOf('"') === -1 &&
78
+ in_path.indexOf("*") === -1) {
76
79
  // Yes, we can do something faster than parsing each character one by one.
77
80
  let additionalTokens = [];
78
81
  const additionalTypes = [];
@@ -233,9 +236,7 @@ export var PathHelper;
233
236
  break;
234
237
  }
235
238
  default: {
236
- if (!tokenStarted &&
237
- !allowSegmentStart &&
238
- !inSquareBrackets) {
239
+ if (!tokenStarted && !allowSegmentStart && !inSquareBrackets) {
239
240
  throw new Error(MSG.MISSING_DOT_AT_SEGMENT_START + in_path);
240
241
  }
241
242
  currentToken += character;
@@ -255,7 +256,8 @@ export var PathHelper;
255
256
  // We now have to check the next character,
256
257
  // as only the combinations '][' and '].' are
257
258
  // valid
258
- if (in_path.length > i + 1) { // We only have to check this at the end of the string
259
+ if (in_path.length > i + 1) {
260
+ // We only have to check this at the end of the string
259
261
  if (in_path[i + 1] === PROPERTY_PATH_DELIMITER) {
260
262
  // We are no longer in square brackets
261
263
  inSquareBrackets = false;
@@ -337,7 +339,8 @@ export var PathHelper;
337
339
  if (typeof in_quotedPathSegment !== "string") {
338
340
  throw new TypeError(`Expecting a string as a path: ${in_quotedPathSegment}`);
339
341
  }
340
- if (in_quotedPathSegment[0] === '"' && in_quotedPathSegment[in_quotedPathSegment.length - 1] === '"') {
342
+ if (in_quotedPathSegment[0] === '"' &&
343
+ in_quotedPathSegment[in_quotedPathSegment.length - 1] === '"') {
341
344
  // We remove double quotes
342
345
  in_quotedPathSegment = in_quotedPathSegment.substr(1, in_quotedPathSegment.length - 2);
343
346
  // Then we unescape escape symbols
@@ -362,7 +365,9 @@ export var PathHelper;
362
365
  in_pathSegment.indexOf("*") !== -1 ||
363
366
  in_pathSegment.indexOf("[") !== -1 ||
364
367
  in_pathSegment.indexOf("]") !== -1 ||
365
- in_pathSegment.length === 0 ? PathHelper.quotePathSegment(in_pathSegment) : in_pathSegment;
368
+ in_pathSegment.length === 0
369
+ ? PathHelper.quotePathSegment(in_pathSegment)
370
+ : in_pathSegment;
366
371
  };
367
372
  /**
368
373
  * This function checks, whether the supplied path is a valid repository absolute path.
@@ -373,7 +378,8 @@ export var PathHelper;
373
378
  */
374
379
  PathHelper.checkValidRepositoryAbsolutePath = function (in_path) {
375
380
  if (in_path !== "" && // either an empty reference
376
- in_path[0] !== "/") { // or an absolute path starting with /
381
+ in_path[0] !== "/") {
382
+ // or an absolute path starting with /
377
383
  throw new Error(MSG.INVALID_PATH_IN_REFERENCE);
378
384
  }
379
385
  };
@@ -401,7 +407,7 @@ export var PathHelper;
401
407
  throw new Error(`Dereference ("*") is not supported in canonical paths: ${in_absolutePath}`);
402
408
  case TOKEN_TYPES.ARRAY_TOKEN:
403
409
  case TOKEN_TYPES.PATH_SEGMENT_TOKEN:
404
- path += (PROPERTY_PATH_DELIMITER + PathHelper.quotePathSegmentIfNeeded(tokens[i]));
410
+ path += PROPERTY_PATH_DELIMITER + PathHelper.quotePathSegmentIfNeeded(tokens[i]);
405
411
  break;
406
412
  default:
407
413
  break;
@@ -425,7 +431,7 @@ export var PathHelper;
425
431
  PathHelper.getChildAbsolutePathCanonical = function (in_parentAbsolutePathCanonical, in_childId) {
426
432
  const childPath = PathHelper.quotePathSegmentIfNeeded(String(in_childId));
427
433
  return in_parentAbsolutePathCanonical
428
- ? (in_parentAbsolutePathCanonical + PROPERTY_PATH_DELIMITER + childPath)
434
+ ? in_parentAbsolutePathCanonical + PROPERTY_PATH_DELIMITER + childPath
429
435
  : childPath;
430
436
  };
431
437
  let CoverageExtent;
@@ -1 +1 @@
1
- {"version":3,"file":"pathHelper.js","sourceRoot":"","sources":["../src/pathHelper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH;;GAEG;AAEH,aAAa;AACb,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAEhE,MAAM,EAAE,uBAAuB,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;AAInD;;GAEG;AACH,2DAA2D;AAC3D,MAAM,KAAW,UAAU,CA6e1B;AA7eD,WAAiB,UAAU;IAEvB,MAAM,2BAA2B,GAAG,IAAI,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAE3D;;;OAGG;IACH,IAAY,WAWX;IAXD,WAAY,WAAW;QACnB,6CAA6C;QAC7C,yEAAkB,CAAA;QAClB,+CAA+C;QAC/C,2DAAW,CAAA;QACX,uCAAuC;QACvC,mEAAe,CAAA;QACf,mDAAmD,CAAC,kBAAkB;QACtE,uEAAiB,CAAA;QACjB,2DAA2D;QAC3D,uEAAiB,CAAA;IACrB,CAAC,EAXW,WAAW,GAAX,sBAAW,KAAX,sBAAW,QAWtB;IAED;;;;;;;OAOG;IACU,6BAAkB,GAAG,UAAS,OAAe,EAAE,SAAyB;QACjF,MAAM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,CAAC;IACN,CAAC,CAAC;AACN,CAAC,EA7egB,UAAU,KAAV,UAAU,QA6e1B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/**\n * @fileoverview Helper functions to work with path strings\n */\n\n// @ts-ignore\nimport { constants } from '@fluid-experimental/property-common';\n\nconst { PROPERTY_PATH_DELIMITER, MSG } = constants;\n\nexport type PathTree = Map<String, PathTree>;\n\n/**\n * Helper functions for string processing\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace PathHelper {\n\n const RE_ALL_OPEN_SQUARE_BRACKETS = new RegExp(\"[[]\", \"g\");\n\n /**\n * Token Types\n * Type of the token in the path string\n */\n export enum TOKEN_TYPES {\n /** A normal path segment, separated via . */\n PATH_SEGMENT_TOKEN,\n /** An array path segment, separated via [ ] */\n ARRAY_TOKEN,\n /** A / at the beginning of the path */\n PATH_ROOT_TOKEN,\n /** A * that indicates a dereferencing operation */ // note: reversed!\n DEREFERENCE_TOKEN,\n /** A ../ that indicates one step above the current path */\n RAISE_LEVEL_TOKEN,\n }\n\n /**\n * Tokenizes a path string\n *\n * @param in_path - The path string to divide into tokens\n * @param out_types - The types of the tokens\n *\n * @returns the tokens from the path string\n */\n export const tokenizePathString = function(in_path: string, out_types?: TOKEN_TYPES[]): string[] { // eslint-disable-line complexity\n const tokens = [];\n let currentToken = \"\";\n\n if (out_types) {\n // Make sure out_types is empty\n out_types.splice(0, out_types.length);\n }\n\n // Handle a / at the beginning of the path by adding a special token for it\n let path_start = 0;\n if (in_path[0] === \"/\") {\n tokens.push(\"/\");\n if (out_types) {\n out_types.push(TOKEN_TYPES.PATH_ROOT_TOKEN);\n }\n path_start = 1;\n } else if (in_path.substr(0, 3) === \"../\") {\n // Handle relative paths by extracting the number steps above\n var extractLevel = function(current_path) {\n if (current_path.substr(0, 3) === \"../\") {\n if (out_types) {\n out_types.push(TOKEN_TYPES.RAISE_LEVEL_TOKEN);\n }\n tokens.push(\"../\");\n extractLevel(current_path.substr(3));\n path_start = path_start + 3;\n }\n };\n extractLevel(in_path);\n }\n\n // Let's see if the path is simple enough to use a fast-track algorithm.\n let hackedPath = in_path.substr(path_start);\n if (in_path.indexOf(\"\\\\\") === -1 && in_path.indexOf('\"') === -1 && in_path.indexOf(\"*\") === -1) {\n // Yes, we can do something faster than parsing each character one by one.\n let additionalTokens: string[] = [];\n const additionalTypes = [];\n let token: string | string[];\n let i: number;\n // Hack for simplicity, let's first replace all occurences of '[' by '.['\n hackedPath = hackedPath.replace(RE_ALL_OPEN_SQUARE_BRACKETS, \".[\");\n // Then split on '.'\n additionalTokens = hackedPath.split(\".\");\n // And validate each token.\n for (i = 0; i < additionalTokens.length; ++i) {\n token = additionalTokens[i];\n // Empty tokens are considered errors... but shouldn't '' be a valid name?\n if (token.length === 0) {\n // There's an error somewhere. Let's abort the fast-track.\n break;\n } else if (token[0] === \"[\") {\n if (token.length > 2 && token[token.length - 1] === \"]\") {\n additionalTypes.push(TOKEN_TYPES.ARRAY_TOKEN);\n additionalTokens[i] = token.substr(1, token.length - 2);\n } else {\n // There's an error somewhere. Let's abort the fast-track.\n break;\n }\n } else {\n if (token.indexOf(\"]\") !== -1) {\n // There's an error somewhere. Let's abort the fast-track.\n break;\n } else {\n // It was a simple property name.\n additionalTypes.push(TOKEN_TYPES.PATH_SEGMENT_TOKEN);\n }\n }\n }\n if (i === additionalTokens.length) {\n // Parsed everything successfully so end function here.\n if (out_types) {\n for (i = 0; i < additionalTypes.length; i++) {\n out_types.push(additionalTypes[i]);\n }\n }\n return tokens.concat(additionalTokens);\n }\n }\n\n let inSquareBrackets = false;\n let tokenStarted = false;\n let lastTokenWasQuoted = false;\n\n // We are in a context where an empty token is valid\n let atStartToken = false;\n let allowSegmentStart = true;\n\n const storeNextToken = function(tokenType) {\n // Make sure, this is not an empty token (E.g. a .. or a [] )\n if (!tokenStarted) {\n if (!atStartToken) {\n throw new Error(MSG.EMPTY_TOKEN + in_path);\n } else {\n return;\n }\n }\n\n // Store the token\n tokens.push(currentToken);\n currentToken = \"\";\n tokenStarted = false;\n atStartToken = false;\n lastTokenWasQuoted = false;\n allowSegmentStart = false;\n\n if (out_types) {\n out_types.push(tokenType);\n }\n };\n\n for (var i = path_start; i < in_path.length; i++) {\n const character = in_path[i];\n\n if (character === '\"') {\n // If we encounter a quotation mark, we start parsing the\n // quoted section\n if (!tokenStarted) {\n let endFound = false;\n\n // Read the quoted token\n for (i++; i < in_path.length; i++) {\n if (in_path[i] === '\"') {\n // We have found the end of the quoted token\n endFound = true;\n break;\n } else if (in_path[i] === \"\\\\\") {\n // Read an escaped symbol\n if (in_path.length > i + 1) {\n if (in_path[i + 1] === \"\\\\\") {\n currentToken += \"\\\\\";\n i++;\n } else if (in_path[i + 1] === '\"') {\n currentToken += '\"';\n i++;\n } else {\n throw new Error(MSG.INVALID_ESCAPE_SEQUENCE + in_path);\n }\n } else {\n throw new Error(MSG.INVALID_ESCAPE_SEQUENCE + in_path);\n }\n } else {\n // Everything else is just added to the token\n currentToken += in_path[i];\n }\n }\n\n if (!endFound) {\n throw new Error(MSG.UNCLOSED_QUOTATION_MARKS + in_path);\n }\n lastTokenWasQuoted = true;\n tokenStarted = true;\n } else {\n throw new Error(MSG.QUOTES_WITHIN_TOKEN + in_path);\n }\n } else if (!inSquareBrackets) {\n switch (character) {\n case PROPERTY_PATH_DELIMITER: {\n // A dot symbols starts a new token\n storeNextToken(TOKEN_TYPES.PATH_SEGMENT_TOKEN);\n\n allowSegmentStart = true;\n break;\n }\n case \"[\": {\n // An opening square bracket starts a new token\n if (tokenStarted) {\n storeNextToken(TOKEN_TYPES.PATH_SEGMENT_TOKEN);\n }\n\n // And sets the state to inSquareBrackets\n inSquareBrackets = true;\n break;\n }\n case \"]\": {\n throw new Error(MSG.CLOSING_BRACKET_WITHOUT_OPENING + in_path);\n }\n case \"*\": {\n // Store the last token\n if (tokenStarted) {\n storeNextToken(TOKEN_TYPES.PATH_SEGMENT_TOKEN);\n }\n\n // Create a new dereference token\n tokens.push(\"*\");\n if (out_types) {\n out_types.push(TOKEN_TYPES.DEREFERENCE_TOKEN);\n }\n\n // Reset the token started flag\n tokenStarted = false;\n atStartToken = true;\n allowSegmentStart = false;\n break;\n }\n default: {\n if (!tokenStarted &&\n !allowSegmentStart &&\n !inSquareBrackets) {\n throw new Error(MSG.MISSING_DOT_AT_SEGMENT_START + in_path);\n }\n\n currentToken += character;\n\n // We have started parsing the token\n tokenStarted = true;\n\n // When a symbols appears after a closing quotation mark, we have an error\n if (lastTokenWasQuoted) {\n throw new Error(MSG.QUOTES_WITHIN_TOKEN + in_path);\n }\n }\n }\n } else {\n if (character === \"]\") {\n // A closing square bracket starts a new token\n storeNextToken(TOKEN_TYPES.ARRAY_TOKEN);\n\n // We now have to check the next character,\n // as only the combinations '][' and '].' are\n // valid\n if (in_path.length > i + 1) { // We only have to check this at the end of the string\n if (in_path[i + 1] === PROPERTY_PATH_DELIMITER) {\n // We are no longer in square brackets\n inSquareBrackets = false;\n allowSegmentStart = true;\n i++;\n } else if (in_path[i + 1] === \"[\") {\n // We remain in square brackets\n // so inSquareBrackets remains true;\n i++;\n } else if (in_path[i + 1] === \"*\") {\n // We leave the square brackets\n inSquareBrackets = false;\n } else {\n throw new Error(MSG.INVALID_END_OF_SQUARE_BRACKETS + in_path);\n }\n } else {\n inSquareBrackets = false;\n tokenStarted = false;\n }\n } else if (character === PROPERTY_PATH_DELIMITER) {\n throw new Error(MSG.DOTS_IN_SQUARE_BRACKETS + in_path);\n } else {\n currentToken += character;\n\n // We have started parsing the token\n tokenStarted = true;\n\n // When a symbols appears after a closing quotation mark, we have an error\n if (lastTokenWasQuoted) {\n throw new Error(MSG.QUOTES_WITHIN_TOKEN + in_path);\n }\n }\n }\n }\n\n // At the end of the path we have to distinguish a few error cases\n if (inSquareBrackets) {\n // There was a un-closed bracket at the end\n throw new Error(MSG.UNCLOSED_BRACKETS + in_path);\n } else if (in_path[in_path.length - 1] === PROPERTY_PATH_DELIMITER) {\n // A path ended with a PROPERTY_PATH_DELIMITER\n throw new Error(MSG.DOT_AT_END + in_path);\n } else if (tokenStarted) {\n // There was a valid, not yet ended token\n storeNextToken(TOKEN_TYPES.PATH_SEGMENT_TOKEN);\n }\n\n return tokens;\n };\n\n /**\n * Creates a quoted string for a path seqment to make sure it parses correctly\n *\n * @param in_pathSegment - The path string to put in quotes\n *\n * @returns quoted path string\n */\n export const quotePathSegment = function(in_pathSegment: string): string {\n // WARNING: I use RegExps here, as the normal replace\n // function only replaces the first occurrence\n\n // First we escape escape symbols\n in_pathSegment = in_pathSegment.replace(/\\\\/g, \"\\\\\\\\\");\n\n // Then we escape quotes\n in_pathSegment = in_pathSegment.replace(/\"/g, '\\\\\"');\n\n // And finally, we put the string into quotation marks\n return `\"${in_pathSegment}\"`;\n };\n\n /**\n * Reverse a quoted/escaped string for a path seqment\n *\n * @param in_quotedPathSegment - The quoted/escaped path string to put in quotes\n *\n * @return unquoted path string\n */\n export const unquotePathSegment = function(in_quotedPathSegment: string): string {\n if (typeof in_quotedPathSegment !== \"string\") {\n throw new TypeError(`Expecting a string as a path: ${in_quotedPathSegment}`);\n }\n\n if (in_quotedPathSegment[0] === '\"' && in_quotedPathSegment[in_quotedPathSegment.length - 1] === '\"') {\n // We remove double quotes\n in_quotedPathSegment = in_quotedPathSegment.substr(1, in_quotedPathSegment.length - 2);\n\n // Then we unescape escape symbols\n in_quotedPathSegment = in_quotedPathSegment.replace(/\\\\\\\\/g, \"\\\\\");\n\n // Then we unescape quotes\n in_quotedPathSegment = in_quotedPathSegment.replace(/\\\\\"/g, '\"');\n }\n\n return in_quotedPathSegment;\n };\n\n /**\n * Adds quotation marks to a path string if they are needed\n *\n * @param in_pathSegment - The path string to put in quotes\n *\n * @returns quoted path string\n */\n export const quotePathSegmentIfNeeded = function(in_pathSegment: string): string {\n return in_pathSegment.indexOf(PROPERTY_PATH_DELIMITER) !== -1 ||\n in_pathSegment.indexOf('\"') !== -1 ||\n in_pathSegment.indexOf(\"\\\\\") !== -1 ||\n in_pathSegment.indexOf(\"/\") !== -1 ||\n in_pathSegment.indexOf(\"*\") !== -1 ||\n in_pathSegment.indexOf(\"[\") !== -1 ||\n in_pathSegment.indexOf(\"]\") !== -1 ||\n in_pathSegment.length === 0 ? quotePathSegment(in_pathSegment) : in_pathSegment;\n };\n\n /**\n * This function checks, whether the supplied path is a valid repository absolute path.\n *\n * It has to be either an empty string, or a path starting with a /\n *\n * @param in_path - The path to check\n */\n export const checkValidRepositoryAbsolutePath = function(in_path: string) {\n if (in_path !== \"\" && // either an empty reference\n in_path[0] !== \"/\") { // or an absolute path starting with /\n throw new Error(MSG.INVALID_PATH_IN_REFERENCE);\n }\n };\n\n /**\n * This utility function provides a canonical representation of an absolute property path.\n * It is useful to compare partial checkout paths and property paths.\n * The canonical form of paths is not suitable for ChangeSets.\n *\n * @param in_absolutePath - The absolute path to make canonical\n * @return Absolute path in canonical form\n */\n export const convertAbsolutePathToCanonical = function(in_absolutePath: string): string {\n const tokenTypes = [];\n const tokens = tokenizePathString(in_absolutePath, tokenTypes);\n let path = \"\";\n for (let i = 0; i < tokenTypes.length; i++) {\n const tokenType = tokenTypes[i];\n switch (tokenType) {\n case TOKEN_TYPES.PATH_ROOT_TOKEN:\n // Skip the leading '/'\n break;\n case TOKEN_TYPES.RAISE_LEVEL_TOKEN:\n throw new Error(`No level up (\"../\") is expected in an absolute path: ${in_absolutePath}`);\n case TOKEN_TYPES.DEREFERENCE_TOKEN:\n throw new Error(`Dereference (\"*\") is not supported in canonical paths: ${in_absolutePath}`);\n case TOKEN_TYPES.ARRAY_TOKEN:\n case TOKEN_TYPES.PATH_SEGMENT_TOKEN:\n path += (PROPERTY_PATH_DELIMITER + quotePathSegmentIfNeeded(tokens[i]));\n break;\n default:\n break;\n }\n }\n // Removes the leading PROPERTY_PATH_DELIMITER.\n if (path) {\n path = path.substring(1);\n }\n return path;\n };\n\n /**\n * This utility function provides a canonical representation of a child property path.\n * It is useful to compare partial checkout paths and property paths.\n * The canonical form of paths is not suitable for ChangeSets.\n *\n * @param in_parentAbsolutePathCanonical - The absolute path of the parent property in canonical form\n * @param in_childId - The name of the child property in its parent\n * @returns Absolute path of the child property in canonical form\n */\n export const getChildAbsolutePathCanonical = function(in_parentAbsolutePathCanonical: string, in_childId: string): string {\n const childPath = quotePathSegmentIfNeeded(String(in_childId));\n return in_parentAbsolutePathCanonical\n ? (in_parentAbsolutePathCanonical + PROPERTY_PATH_DELIMITER + childPath)\n : childPath;\n };\n\n export enum CoverageExtent {\n // The base path is not covered by any path from a given list of paths.\n // This means a property with this path and all its children would not be covered.\n UNCOVERED,\n // The base path is partially covered by at least one path from a given list of paths.\n // This means a property with this path would be covered, but some of its children could be uncovered.\n PARTLY_COVERED,\n // The base path is fully covered by at least one path from a given list of paths.\n // This means a property with this path would be covered and all of its children would be covered also.\n FULLY_COVERED,\n }\n\n interface BasePathCoverage {\n coverageExtent: CoverageExtent;\n pathList: string[];\n }\n\n /**\n * Determines if the base path is covered by the given list of paths. From that you can deduce if a\n * property with that path and all its children are covered by the given list of paths.\n *\n * This function uses the canonical representation of the property paths.\n *\n * @param in_basePath - The property's absolute path in canonical form\n * @param in_paths - The array of paths that must cover the property and its children\n * @returns The coverage of the property and its children. For a coverage of\n * 'FULLY_COVERED', only the first matching path is returned.\n */\n export const getPathCoverage = function(in_basePath: string, in_paths: string[]): BasePathCoverage {\n // First, check if the base path is entirely included in one of the paths\n for (let i = 0; i < in_paths.length; i++) {\n if (in_basePath.startsWith(in_paths[i])) {\n return {\n coverageExtent: CoverageExtent.FULLY_COVERED,\n pathList: [in_paths[i]],\n };\n }\n }\n // We did not find a path including all the children of this insertion\n // Let's check if there are paths going through it.\n const paths = [];\n for (let i = 0; i < in_paths.length; i++) {\n if (in_paths[i].startsWith(in_basePath)) {\n paths.push(in_paths[i]);\n }\n }\n if (paths.length) {\n // We found at least one path including parts of the base path.\n return {\n coverageExtent: CoverageExtent.PARTLY_COVERED,\n pathList: paths,\n };\n }\n\n // We did not find any path covering the given base path.\n return {\n coverageExtent: CoverageExtent.UNCOVERED,\n pathList: paths,\n };\n };\n}\n"]}
1
+ {"version":3,"file":"pathHelper.js","sourceRoot":"","sources":["../src/pathHelper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH;;GAEG;AAEH,aAAa;AACb,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAEhE,MAAM,EAAE,uBAAuB,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;AAInD;;GAEG;AACH,2DAA2D;AAC3D,MAAM,KAAW,UAAU,CAqgB1B;AArgBD,WAAiB,UAAU;IAC1B,MAAM,2BAA2B,GAAG,IAAI,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAE3D;;;OAGG;IACH,IAAY,WAWX;IAXD,WAAY,WAAW;QACtB,6CAA6C;QAC7C,yEAAkB,CAAA;QAClB,+CAA+C;QAC/C,2DAAW,CAAA;QACX,uCAAuC;QACvC,mEAAe,CAAA;QACf,mDAAmD,CAAC,kBAAkB;QACtE,uEAAiB,CAAA;QACjB,2DAA2D;QAC3D,uEAAiB,CAAA;IAClB,CAAC,EAXW,WAAW,GAAX,sBAAW,KAAX,sBAAW,QAWtB;IAED;;;;;;;OAOG;IACU,6BAAkB,GAAG,UACjC,OAAe,EACf,SAAyB;QAEzB,iCAAiC;QACjC,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,IAAI,YAAY,GAAG,EAAE,CAAC;QAEtB,IAAI,SAAS,EAAE;YACd,+BAA+B;YAC/B,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;SACtC;QAED,2EAA2E;QAC3E,IAAI,UAAU,GAAG,CAAC,CAAC;QACnB,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;YACvB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACjB,IAAI,SAAS,EAAE;gBACd,SAAS,CAAC,IAA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AAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACzC,IAAI,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE;gBACxC,OAAO;oBACN,cAAc,EAAE,cAAc,CAAC,aAAa;oBAC5C,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;iBACvB,CAAC;aACF;SACD;QACD,sEAAsE;QACtE,mDAAmD;QACnD,MAAM,KAAK,GAAG,EAAE,CAAC;QACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACzC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;gBACxC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;aACxB;SACD;QACD,IAAI,KAAK,CAAC,MAAM,EAAE;YACjB,+DAA+D;YAC/D,OAAO;gBACN,cAAc,EAAE,cAAc,CAAC,cAAc;gBAC7C,QAAQ,EAAE,KAAK;aACf,CAAC;SACF;QAED,yDAAyD;QACzD,OAAO;YACN,cAAc,EAAE,cAAc,CAAC,SAAS;YACxC,QAAQ,EAAE,KAAK;SACf,CAAC;IACH,CAAC,CAAC;AACH,CAAC,EArgBgB,UAAU,KAAV,UAAU,QAqgB1B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/**\n * @fileoverview Helper functions to work with path strings\n */\n\n// @ts-ignore\nimport { constants } from \"@fluid-experimental/property-common\";\n\nconst { PROPERTY_PATH_DELIMITER, MSG } = constants;\n\nexport type PathTree = Map<String, PathTree>;\n\n/**\n * Helper functions for string processing\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace PathHelper {\n\tconst RE_ALL_OPEN_SQUARE_BRACKETS = new RegExp(\"[[]\", \"g\");\n\n\t/**\n\t * Token Types\n\t * Type of the token in the path string\n\t */\n\texport enum TOKEN_TYPES {\n\t\t/** A normal path segment, separated via . */\n\t\tPATH_SEGMENT_TOKEN,\n\t\t/** An array path segment, separated via [ ] */\n\t\tARRAY_TOKEN,\n\t\t/** A / at the beginning of the path */\n\t\tPATH_ROOT_TOKEN,\n\t\t/** A * that indicates a dereferencing operation */ // note: reversed!\n\t\tDEREFERENCE_TOKEN,\n\t\t/** A ../ that indicates one step above the current path */\n\t\tRAISE_LEVEL_TOKEN,\n\t}\n\n\t/**\n\t * Tokenizes a path string\n\t *\n\t * @param in_path - The path string to divide into tokens\n\t * @param out_types - The types of the tokens\n\t *\n\t * @returns the tokens from the path string\n\t */\n\texport const tokenizePathString = function (\n\t\tin_path: string,\n\t\tout_types?: TOKEN_TYPES[],\n\t): string[] {\n\t\t// eslint-disable-line complexity\n\t\tconst tokens = [];\n\t\tlet currentToken = \"\";\n\n\t\tif (out_types) {\n\t\t\t// Make sure out_types is empty\n\t\t\tout_types.splice(0, out_types.length);\n\t\t}\n\n\t\t// Handle a / at the beginning of the path by adding a special token for it\n\t\tlet path_start = 0;\n\t\tif (in_path[0] === \"/\") {\n\t\t\ttokens.push(\"/\");\n\t\t\tif (out_types) {\n\t\t\t\tout_types.push(TOKEN_TYPES.PATH_ROOT_TOKEN);\n\t\t\t}\n\t\t\tpath_start = 1;\n\t\t} else if (in_path.substr(0, 3) === \"../\") {\n\t\t\t// Handle relative paths by extracting the number steps above\n\t\t\tvar extractLevel = function (current_path) {\n\t\t\t\tif (current_path.substr(0, 3) === \"../\") {\n\t\t\t\t\tif (out_types) {\n\t\t\t\t\t\tout_types.push(TOKEN_TYPES.RAISE_LEVEL_TOKEN);\n\t\t\t\t\t}\n\t\t\t\t\ttokens.push(\"../\");\n\t\t\t\t\textractLevel(current_path.substr(3));\n\t\t\t\t\tpath_start = path_start + 3;\n\t\t\t\t}\n\t\t\t};\n\t\t\textractLevel(in_path);\n\t\t}\n\n\t\t// Let's see if the path is simple enough to use a fast-track algorithm.\n\t\tlet hackedPath = in_path.substr(path_start);\n\t\tif (\n\t\t\tin_path.indexOf(\"\\\\\") === -1 &&\n\t\t\tin_path.indexOf('\"') === -1 &&\n\t\t\tin_path.indexOf(\"*\") === -1\n\t\t) {\n\t\t\t// Yes, we can do something faster than parsing each character one by one.\n\t\t\tlet additionalTokens: string[] = [];\n\t\t\tconst additionalTypes = [];\n\t\t\tlet token: string | string[];\n\t\t\tlet i: number;\n\t\t\t// Hack for simplicity, let's first replace all occurences of '[' by '.['\n\t\t\thackedPath = hackedPath.replace(RE_ALL_OPEN_SQUARE_BRACKETS, \".[\");\n\t\t\t// Then split on '.'\n\t\t\tadditionalTokens = hackedPath.split(\".\");\n\t\t\t// And validate each token.\n\t\t\tfor (i = 0; i < additionalTokens.length; ++i) {\n\t\t\t\ttoken = additionalTokens[i];\n\t\t\t\t// Empty tokens are considered errors... but shouldn't '' be a valid name?\n\t\t\t\tif (token.length === 0) {\n\t\t\t\t\t// There's an error somewhere. Let's abort the fast-track.\n\t\t\t\t\tbreak;\n\t\t\t\t} else if (token[0] === \"[\") {\n\t\t\t\t\tif (token.length > 2 && token[token.length - 1] === \"]\") {\n\t\t\t\t\t\tadditionalTypes.push(TOKEN_TYPES.ARRAY_TOKEN);\n\t\t\t\t\t\tadditionalTokens[i] = token.substr(1, token.length - 2);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// There's an error somewhere. Let's abort the fast-track.\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (token.indexOf(\"]\") !== -1) {\n\t\t\t\t\t\t// There's an error somewhere. Let's abort the fast-track.\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// It was a simple property name.\n\t\t\t\t\t\tadditionalTypes.push(TOKEN_TYPES.PATH_SEGMENT_TOKEN);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (i === additionalTokens.length) {\n\t\t\t\t// Parsed everything successfully so end function here.\n\t\t\t\tif (out_types) {\n\t\t\t\t\tfor (i = 0; i < additionalTypes.length; i++) {\n\t\t\t\t\t\tout_types.push(additionalTypes[i]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn tokens.concat(additionalTokens);\n\t\t\t}\n\t\t}\n\n\t\tlet inSquareBrackets = false;\n\t\tlet tokenStarted = false;\n\t\tlet lastTokenWasQuoted = false;\n\n\t\t// We are in a context where an empty token is valid\n\t\tlet atStartToken = false;\n\t\tlet allowSegmentStart = true;\n\n\t\tconst storeNextToken = function (tokenType) {\n\t\t\t// Make sure, this is not an empty token (E.g. a .. or a [] )\n\t\t\tif (!tokenStarted) {\n\t\t\t\tif (!atStartToken) {\n\t\t\t\t\tthrow new Error(MSG.EMPTY_TOKEN + in_path);\n\t\t\t\t} else {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Store the token\n\t\t\ttokens.push(currentToken);\n\t\t\tcurrentToken = \"\";\n\t\t\ttokenStarted = false;\n\t\t\tatStartToken = false;\n\t\t\tlastTokenWasQuoted = false;\n\t\t\tallowSegmentStart = false;\n\n\t\t\tif (out_types) {\n\t\t\t\tout_types.push(tokenType);\n\t\t\t}\n\t\t};\n\n\t\tfor (var i = path_start; i < in_path.length; i++) {\n\t\t\tconst character = in_path[i];\n\n\t\t\tif (character === '\"') {\n\t\t\t\t// If we encounter a quotation mark, we start parsing the\n\t\t\t\t// quoted section\n\t\t\t\tif (!tokenStarted) {\n\t\t\t\t\tlet endFound = false;\n\n\t\t\t\t\t// Read the quoted token\n\t\t\t\t\tfor (i++; i < in_path.length; i++) {\n\t\t\t\t\t\tif (in_path[i] === '\"') {\n\t\t\t\t\t\t\t// We have found the end of the quoted token\n\t\t\t\t\t\t\tendFound = true;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t} else if (in_path[i] === \"\\\\\") {\n\t\t\t\t\t\t\t// Read an escaped symbol\n\t\t\t\t\t\t\tif (in_path.length > i + 1) {\n\t\t\t\t\t\t\t\tif (in_path[i + 1] === \"\\\\\") {\n\t\t\t\t\t\t\t\t\tcurrentToken += \"\\\\\";\n\t\t\t\t\t\t\t\t\ti++;\n\t\t\t\t\t\t\t\t} else if (in_path[i + 1] === '\"') {\n\t\t\t\t\t\t\t\t\tcurrentToken += '\"';\n\t\t\t\t\t\t\t\t\ti++;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tthrow new Error(MSG.INVALID_ESCAPE_SEQUENCE + in_path);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tthrow new Error(MSG.INVALID_ESCAPE_SEQUENCE + in_path);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Everything else is just added to the token\n\t\t\t\t\t\t\tcurrentToken += in_path[i];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!endFound) {\n\t\t\t\t\t\tthrow new Error(MSG.UNCLOSED_QUOTATION_MARKS + in_path);\n\t\t\t\t\t}\n\t\t\t\t\tlastTokenWasQuoted = true;\n\t\t\t\t\ttokenStarted = true;\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(MSG.QUOTES_WITHIN_TOKEN + in_path);\n\t\t\t\t}\n\t\t\t} else if (!inSquareBrackets) {\n\t\t\t\tswitch (character) {\n\t\t\t\t\tcase PROPERTY_PATH_DELIMITER: {\n\t\t\t\t\t\t// A dot symbols starts a new token\n\t\t\t\t\t\tstoreNextToken(TOKEN_TYPES.PATH_SEGMENT_TOKEN);\n\n\t\t\t\t\t\tallowSegmentStart = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"[\": {\n\t\t\t\t\t\t// An opening square bracket starts a new token\n\t\t\t\t\t\tif (tokenStarted) {\n\t\t\t\t\t\t\tstoreNextToken(TOKEN_TYPES.PATH_SEGMENT_TOKEN);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// And sets the state to inSquareBrackets\n\t\t\t\t\t\tinSquareBrackets = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"]\": {\n\t\t\t\t\t\tthrow new Error(MSG.CLOSING_BRACKET_WITHOUT_OPENING + in_path);\n\t\t\t\t\t}\n\t\t\t\t\tcase \"*\": {\n\t\t\t\t\t\t// Store the last token\n\t\t\t\t\t\tif (tokenStarted) {\n\t\t\t\t\t\t\tstoreNextToken(TOKEN_TYPES.PATH_SEGMENT_TOKEN);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Create a new dereference token\n\t\t\t\t\t\ttokens.push(\"*\");\n\t\t\t\t\t\tif (out_types) {\n\t\t\t\t\t\t\tout_types.push(TOKEN_TYPES.DEREFERENCE_TOKEN);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Reset the token started flag\n\t\t\t\t\t\ttokenStarted = false;\n\t\t\t\t\t\tatStartToken = true;\n\t\t\t\t\t\tallowSegmentStart = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tdefault: {\n\t\t\t\t\t\tif (!tokenStarted && !allowSegmentStart && !inSquareBrackets) {\n\t\t\t\t\t\t\tthrow new Error(MSG.MISSING_DOT_AT_SEGMENT_START + in_path);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcurrentToken += character;\n\n\t\t\t\t\t\t// We have started parsing the token\n\t\t\t\t\t\ttokenStarted = true;\n\n\t\t\t\t\t\t// When a symbols appears after a closing quotation mark, we have an error\n\t\t\t\t\t\tif (lastTokenWasQuoted) {\n\t\t\t\t\t\t\tthrow new Error(MSG.QUOTES_WITHIN_TOKEN + in_path);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (character === \"]\") {\n\t\t\t\t\t// A closing square bracket starts a new token\n\t\t\t\t\tstoreNextToken(TOKEN_TYPES.ARRAY_TOKEN);\n\n\t\t\t\t\t// We now have to check the next character,\n\t\t\t\t\t// as only the combinations '][' and '].' are\n\t\t\t\t\t// valid\n\t\t\t\t\tif (in_path.length > i + 1) {\n\t\t\t\t\t\t// We only have to check this at the end of the string\n\t\t\t\t\t\tif (in_path[i + 1] === PROPERTY_PATH_DELIMITER) {\n\t\t\t\t\t\t\t// We are no longer in square brackets\n\t\t\t\t\t\t\tinSquareBrackets = false;\n\t\t\t\t\t\t\tallowSegmentStart = true;\n\t\t\t\t\t\t\ti++;\n\t\t\t\t\t\t} else if (in_path[i + 1] === \"[\") {\n\t\t\t\t\t\t\t// We remain in square brackets\n\t\t\t\t\t\t\t// so inSquareBrackets remains true;\n\t\t\t\t\t\t\ti++;\n\t\t\t\t\t\t} else if (in_path[i + 1] === \"*\") {\n\t\t\t\t\t\t\t// We leave the square brackets\n\t\t\t\t\t\t\tinSquareBrackets = false;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow new Error(MSG.INVALID_END_OF_SQUARE_BRACKETS + in_path);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tinSquareBrackets = false;\n\t\t\t\t\t\ttokenStarted = false;\n\t\t\t\t\t}\n\t\t\t\t} else if (character === PROPERTY_PATH_DELIMITER) {\n\t\t\t\t\tthrow new Error(MSG.DOTS_IN_SQUARE_BRACKETS + in_path);\n\t\t\t\t} else {\n\t\t\t\t\tcurrentToken += character;\n\n\t\t\t\t\t// We have started parsing the token\n\t\t\t\t\ttokenStarted = true;\n\n\t\t\t\t\t// When a symbols appears after a closing quotation mark, we have an error\n\t\t\t\t\tif (lastTokenWasQuoted) {\n\t\t\t\t\t\tthrow new Error(MSG.QUOTES_WITHIN_TOKEN + in_path);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// At the end of the path we have to distinguish a few error cases\n\t\tif (inSquareBrackets) {\n\t\t\t// There was a un-closed bracket at the end\n\t\t\tthrow new Error(MSG.UNCLOSED_BRACKETS + in_path);\n\t\t} else if (in_path[in_path.length - 1] === PROPERTY_PATH_DELIMITER) {\n\t\t\t// A path ended with a PROPERTY_PATH_DELIMITER\n\t\t\tthrow new Error(MSG.DOT_AT_END + in_path);\n\t\t} else if (tokenStarted) {\n\t\t\t// There was a valid, not yet ended token\n\t\t\tstoreNextToken(TOKEN_TYPES.PATH_SEGMENT_TOKEN);\n\t\t}\n\n\t\treturn tokens;\n\t};\n\n\t/**\n\t * Creates a quoted string for a path seqment to make sure it parses correctly\n\t *\n\t * @param in_pathSegment - The path string to put in quotes\n\t *\n\t * @returns quoted path string\n\t */\n\texport const quotePathSegment = function (in_pathSegment: string): string {\n\t\t// WARNING: I use RegExps here, as the normal replace\n\t\t// function only replaces the first occurrence\n\n\t\t// First we escape escape symbols\n\t\tin_pathSegment = in_pathSegment.replace(/\\\\/g, \"\\\\\\\\\");\n\n\t\t// Then we escape quotes\n\t\tin_pathSegment = in_pathSegment.replace(/\"/g, '\\\\\"');\n\n\t\t// And finally, we put the string into quotation marks\n\t\treturn `\"${in_pathSegment}\"`;\n\t};\n\n\t/**\n\t * Reverse a quoted/escaped string for a path seqment\n\t *\n\t * @param in_quotedPathSegment - The quoted/escaped path string to put in quotes\n\t *\n\t * @return unquoted path string\n\t */\n\texport const unquotePathSegment = function (in_quotedPathSegment: string): string {\n\t\tif (typeof in_quotedPathSegment !== \"string\") {\n\t\t\tthrow new TypeError(`Expecting a string as a path: ${in_quotedPathSegment}`);\n\t\t}\n\n\t\tif (\n\t\t\tin_quotedPathSegment[0] === '\"' &&\n\t\t\tin_quotedPathSegment[in_quotedPathSegment.length - 1] === '\"'\n\t\t) {\n\t\t\t// We remove double quotes\n\t\t\tin_quotedPathSegment = in_quotedPathSegment.substr(1, in_quotedPathSegment.length - 2);\n\n\t\t\t// Then we unescape escape symbols\n\t\t\tin_quotedPathSegment = in_quotedPathSegment.replace(/\\\\\\\\/g, \"\\\\\");\n\n\t\t\t// Then we unescape quotes\n\t\t\tin_quotedPathSegment = in_quotedPathSegment.replace(/\\\\\"/g, '\"');\n\t\t}\n\n\t\treturn in_quotedPathSegment;\n\t};\n\n\t/**\n\t * Adds quotation marks to a path string if they are needed\n\t *\n\t * @param in_pathSegment - The path string to put in quotes\n\t *\n\t * @returns quoted path string\n\t */\n\texport const quotePathSegmentIfNeeded = function (in_pathSegment: string): string {\n\t\treturn in_pathSegment.indexOf(PROPERTY_PATH_DELIMITER) !== -1 ||\n\t\t\tin_pathSegment.indexOf('\"') !== -1 ||\n\t\t\tin_pathSegment.indexOf(\"\\\\\") !== -1 ||\n\t\t\tin_pathSegment.indexOf(\"/\") !== -1 ||\n\t\t\tin_pathSegment.indexOf(\"*\") !== -1 ||\n\t\t\tin_pathSegment.indexOf(\"[\") !== -1 ||\n\t\t\tin_pathSegment.indexOf(\"]\") !== -1 ||\n\t\t\tin_pathSegment.length === 0\n\t\t\t? quotePathSegment(in_pathSegment)\n\t\t\t: in_pathSegment;\n\t};\n\n\t/**\n\t * This function checks, whether the supplied path is a valid repository absolute path.\n\t *\n\t * It has to be either an empty string, or a path starting with a /\n\t *\n\t * @param in_path - The path to check\n\t */\n\texport const checkValidRepositoryAbsolutePath = function (in_path: string) {\n\t\tif (\n\t\t\tin_path !== \"\" && // either an empty reference\n\t\t\tin_path[0] !== \"/\"\n\t\t) {\n\t\t\t// or an absolute path starting with /\n\t\t\tthrow new Error(MSG.INVALID_PATH_IN_REFERENCE);\n\t\t}\n\t};\n\n\t/**\n\t * This utility function provides a canonical representation of an absolute property path.\n\t * It is useful to compare partial checkout paths and property paths.\n\t * The canonical form of paths is not suitable for ChangeSets.\n\t *\n\t * @param in_absolutePath - The absolute path to make canonical\n\t * @return Absolute path in canonical form\n\t */\n\texport const convertAbsolutePathToCanonical = function (in_absolutePath: string): string {\n\t\tconst tokenTypes = [];\n\t\tconst tokens = tokenizePathString(in_absolutePath, tokenTypes);\n\t\tlet path = \"\";\n\t\tfor (let i = 0; i < tokenTypes.length; i++) {\n\t\t\tconst tokenType = tokenTypes[i];\n\t\t\tswitch (tokenType) {\n\t\t\t\tcase TOKEN_TYPES.PATH_ROOT_TOKEN:\n\t\t\t\t\t// Skip the leading '/'\n\t\t\t\t\tbreak;\n\t\t\t\tcase TOKEN_TYPES.RAISE_LEVEL_TOKEN:\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`No level up (\"../\") is expected in an absolute path: ${in_absolutePath}`,\n\t\t\t\t\t);\n\t\t\t\tcase TOKEN_TYPES.DEREFERENCE_TOKEN:\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Dereference (\"*\") is not supported in canonical paths: ${in_absolutePath}`,\n\t\t\t\t\t);\n\t\t\t\tcase TOKEN_TYPES.ARRAY_TOKEN:\n\t\t\t\tcase TOKEN_TYPES.PATH_SEGMENT_TOKEN:\n\t\t\t\t\tpath += PROPERTY_PATH_DELIMITER + quotePathSegmentIfNeeded(tokens[i]);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t// Removes the leading PROPERTY_PATH_DELIMITER.\n\t\tif (path) {\n\t\t\tpath = path.substring(1);\n\t\t}\n\t\treturn path;\n\t};\n\n\t/**\n\t * This utility function provides a canonical representation of a child property path.\n\t * It is useful to compare partial checkout paths and property paths.\n\t * The canonical form of paths is not suitable for ChangeSets.\n\t *\n\t * @param in_parentAbsolutePathCanonical - The absolute path of the parent property in canonical form\n\t * @param in_childId - The name of the child property in its parent\n\t * @returns Absolute path of the child property in canonical form\n\t */\n\texport const getChildAbsolutePathCanonical = function (\n\t\tin_parentAbsolutePathCanonical: string,\n\t\tin_childId: string,\n\t): string {\n\t\tconst childPath = quotePathSegmentIfNeeded(String(in_childId));\n\t\treturn in_parentAbsolutePathCanonical\n\t\t\t? in_parentAbsolutePathCanonical + PROPERTY_PATH_DELIMITER + childPath\n\t\t\t: childPath;\n\t};\n\n\texport enum CoverageExtent {\n\t\t// The base path is not covered by any path from a given list of paths.\n\t\t// This means a property with this path and all its children would not be covered.\n\t\tUNCOVERED,\n\t\t// The base path is partially covered by at least one path from a given list of paths.\n\t\t// This means a property with this path would be covered, but some of its children could be uncovered.\n\t\tPARTLY_COVERED,\n\t\t// The base path is fully covered by at least one path from a given list of paths.\n\t\t// This means a property with this path would be covered and all of its children would be covered also.\n\t\tFULLY_COVERED,\n\t}\n\n\tinterface BasePathCoverage {\n\t\tcoverageExtent: CoverageExtent;\n\t\tpathList: string[];\n\t}\n\n\t/**\n\t * Determines if the base path is covered by the given list of paths. From that you can deduce if a\n\t * property with that path and all its children are covered by the given list of paths.\n\t *\n\t * This function uses the canonical representation of the property paths.\n\t *\n\t * @param in_basePath - The property's absolute path in canonical form\n\t * @param in_paths - The array of paths that must cover the property and its children\n\t * @returns The coverage of the property and its children. For a coverage of\n\t * 'FULLY_COVERED', only the first matching path is returned.\n\t */\n\texport const getPathCoverage = function (\n\t\tin_basePath: string,\n\t\tin_paths: string[],\n\t): BasePathCoverage {\n\t\t// First, check if the base path is entirely included in one of the paths\n\t\tfor (let i = 0; i < in_paths.length; i++) {\n\t\t\tif (in_basePath.startsWith(in_paths[i])) {\n\t\t\t\treturn {\n\t\t\t\t\tcoverageExtent: CoverageExtent.FULLY_COVERED,\n\t\t\t\t\tpathList: [in_paths[i]],\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\t// We did not find a path including all the children of this insertion\n\t\t// Let's check if there are paths going through it.\n\t\tconst paths = [];\n\t\tfor (let i = 0; i < in_paths.length; i++) {\n\t\t\tif (in_paths[i].startsWith(in_basePath)) {\n\t\t\t\tpaths.push(in_paths[i]);\n\t\t\t}\n\t\t}\n\t\tif (paths.length) {\n\t\t\t// We found at least one path including parts of the base path.\n\t\t\treturn {\n\t\t\t\tcoverageExtent: CoverageExtent.PARTLY_COVERED,\n\t\t\t\tpathList: paths,\n\t\t\t};\n\t\t}\n\n\t\t// We did not find any path covering the given base path.\n\t\treturn {\n\t\t\tcoverageExtent: CoverageExtent.UNCOVERED,\n\t\t\tpathList: paths,\n\t\t};\n\t};\n}\n"]}
package/lib/rebase.js CHANGED
@@ -20,7 +20,9 @@ class SyncPromise {
20
20
  return this;
21
21
  }
22
22
  }
23
- const loop = (promise, fn, makePromise) => promise.then(fn).then((result) => result === null ? result : loop(makePromise(result), fn, makePromise));
23
+ const loop = (promise, fn, makePromise) => promise
24
+ .then(fn)
25
+ .then((result) => (result === null ? result : loop(makePromise(result), fn, makePromise)));
24
26
  export function rebaseToRemoteChanges(change, getUnrebasedChange, getRebasedChanges, isAsync = false) {
25
27
  const makePromise = isAsync ? Promise.resolve.bind(Promise) : (x) => new SyncPromise(x);
26
28
  let mainPromise = makePromise();
@@ -48,8 +50,7 @@ export function rebaseToRemoteChanges(change, getUnrebasedChange, getRebasedChan
48
50
  if (currentRebasedChange.remoteHeadGuid === currentRebasedChange.referenceGuid) {
49
51
  return null;
50
52
  }
51
- return makePromise(getUnrebasedChange(currentRebasedChange.referenceGuid))
52
- .then((rebaseChange) => {
53
+ return makePromise(getUnrebasedChange(currentRebasedChange.referenceGuid)).then((rebaseChange) => {
53
54
  alreadyRebasedChanges.unshift(rebaseChange);
54
55
  if (rebaseChange === undefined) {
55
56
  throw new Error("Received change that references a non-existing parent change");
@@ -62,9 +63,9 @@ export function rebaseToRemoteChanges(change, getUnrebasedChange, getRebasedChan
62
63
  mainPromise = mainPromise
63
64
  .then(() => {
64
65
  // First invert all changes on the previous local branch
65
- const startGuid = alreadyRebasedChanges.length > 0 ?
66
- alreadyRebasedChanges[0].referenceGuid :
67
- changesOnOtherLocalBranch[0].referenceGuid;
66
+ const startGuid = alreadyRebasedChanges.length > 0
67
+ ? alreadyRebasedChanges[0].referenceGuid
68
+ : changesOnOtherLocalBranch[0].referenceGuid;
68
69
  // Then apply all changes on the local remote branch
69
70
  const endGuid = change.remoteHeadGuid;
70
71
  return getRebasedChanges(startGuid, endGuid);
@@ -75,7 +76,8 @@ export function rebaseToRemoteChanges(change, getUnrebasedChange, getRebasedChan
75
76
  for (const c of relevantRemoteChanges) {
76
77
  let changeset = c.changeSet;
77
78
  let applyAfterMetaInformation;
78
- if (alreadyRebasedChanges[0] !== undefined && alreadyRebasedChanges[0].guid === c.guid) {
79
+ if (alreadyRebasedChanges[0] !== undefined &&
80
+ alreadyRebasedChanges[0].guid === c.guid) {
79
81
  const invertedChange = new ChangeSet(cloneDeep(alreadyRebasedChanges[0].changeSet));
80
82
  invertedChange.toInverseChangeSet();
81
83
  invertedChange.applyChangeSet(rebaseBaseChangeSetForAlreadyRebasedChanges);
@@ -88,7 +90,9 @@ export function rebaseToRemoteChanges(change, getUnrebasedChange, getRebasedChan
88
90
  rebaseBaseChangeSetForAlreadyRebasedChanges = invertedChange;
89
91
  alreadyRebasedChanges.shift();
90
92
  }
91
- rebaseBaseChangeSetForAlreadyRebasedChanges.applyChangeSet(changeset, { applyAfterMetaInformation });
93
+ rebaseBaseChangeSetForAlreadyRebasedChanges.applyChangeSet(changeset, {
94
+ applyAfterMetaInformation,
95
+ });
92
96
  }
93
97
  // Now we have to rebase all changes from the remote local branch with respect to this base changeset
94
98
  rebaseChangeArrays(rebaseBaseChangeSetForAlreadyRebasedChanges, changesOnOtherLocalBranch);
@@ -107,17 +111,20 @@ export function rebaseToRemoteChanges(change, getUnrebasedChange, getRebasedChan
107
111
  const conflicts = [];
108
112
  if (!isEqual(changesOnOtherLocalBranch.map((change) => change.guid), remoteChanges.map((change) => change.guid))) {
109
113
  for (const remoteChange of remoteChanges) {
110
- let applyAfterMetaInformation = commitsOnOtherLocalBranch[remoteChange.guid] !== undefined ?
111
- remoteChange.rebaseMetaInformation :
112
- undefined;
114
+ let applyAfterMetaInformation = commitsOnOtherLocalBranch[remoteChange.guid] !== undefined
115
+ ? remoteChange.rebaseMetaInformation
116
+ : undefined;
113
117
  let changeset = remoteChange.changeSet;
114
- if (changesOnOtherLocalBranch[0] !== undefined && changesOnOtherLocalBranch[0].guid === remoteChange.guid) {
118
+ if (changesOnOtherLocalBranch[0] !== undefined &&
119
+ changesOnOtherLocalBranch[0].guid === remoteChange.guid) {
115
120
  const invertedChange = new ChangeSet(cloneDeep(changesOnOtherLocalBranch[0].changeSet));
116
121
  invertedChange.toInverseChangeSet();
117
122
  invertedChange.applyChangeSet(rebaseBaseChangeSet);
118
123
  applyAfterMetaInformation = new Map();
119
124
  changeset = cloneDeep(changesOnOtherLocalBranch[0].changeSet);
120
- rebaseBaseChangeSet._rebaseChangeSet(changeset, conflicts, { applyAfterMetaInformation });
125
+ rebaseBaseChangeSet._rebaseChangeSet(changeset, conflicts, {
126
+ applyAfterMetaInformation,
127
+ });
121
128
  // This is disabled for performance reasons. Only used during debugging
122
129
  // assert(isEqual(changeset,this.remoteChanges[i].changeSet),
123
130
  // "Failed Rebase in rebaseToRemoteChanges");
package/lib/rebase.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"rebase.js","sourceRoot":"","sources":["../src/rebase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAErC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,WAAW;IAGb,YAAY,CAAkB;QAC1B,IAAI,CAAC,CAAC,IAAI,YAAY,WAAW,CAAC,EAAE;YAAE,OAAO,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;SAAE;QAClE,IAAI,CAAC,YAAY,WAAW,EAAE;YAAE,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC;SAAE;QAC9C,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACnB,CAAC;IAED,IAAI,CAAC,EAAkC;QACnC,IAAI,CAAC,KAAK,GAAG,IAAI,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;QACnD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,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,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { copy as cloneDeep } from \"fastest-json-copy\";\nimport isEqual from \"lodash/isEqual\";\n\nimport { ChangeSet } from \"./changeset\";\n\nclass SyncPromise {\n value: any;\n\n constructor(x: { value: any; }) {\n if (!(this instanceof SyncPromise)) { return new SyncPromise(x); }\n if (x instanceof SyncPromise) { x = x.value; }\n this.value = x;\n }\n\n then(fn: (arg0: any) => { value: any; }): SyncPromise {\n this.value = new SyncPromise(fn(this.value)).value;\n return this;\n }\n}\n\nconst loop = (promise: Promise<any>, fn: { (currentChange: any): any; (currentRebasedChange: any): any; }, makePromise: (arg0: any) => any) => promise.then(fn).then((result) => result === null ? result : loop(makePromise(result), fn, makePromise));\n\nexport function rebaseToRemoteChanges(\n change: any,\n getUnrebasedChange: any,\n getRebasedChanges: any,\n isAsync: boolean = false) {\n const makePromise = isAsync ? Promise.resolve.bind(Promise) : (x) => new SyncPromise(x);\n let mainPromise = makePromise();\n\n const commitsOnOtherLocalBranch = {};\n let rebaseBaseChangeSet = new ChangeSet({});\n const changesOnOtherLocalBranch = [];\n if (change.referenceGuid !== change.remoteHeadGuid) {\n // Extract all changes between the remoteHeadGuid and the referenceGuid\n let currentGuid = change.referenceGuid;\n mainPromise = loop(\n makePromise(getUnrebasedChange(currentGuid)),\n (currentChange) => {\n if (currentChange === undefined) {\n throw new Error(\"Received change that references a non-existing parent change\");\n }\n changesOnOtherLocalBranch.unshift(currentChange);\n commitsOnOtherLocalBranch[currentGuid] = currentChange;\n if (currentGuid === change.localBranchStart) {\n return null;\n }\n currentGuid = currentChange.referenceGuid;\n return getUnrebasedChange(currentGuid);\n },\n makePromise,\n );\n\n // Now we extract all changes until we arrive at a change that is relative to a remote change\n const alreadyRebasedChanges = [];\n\n mainPromise = mainPromise.then(() =>\n loop(makePromise(getUnrebasedChange(change.localBranchStart)),\n (currentRebasedChange) => {\n if (currentRebasedChange.remoteHeadGuid === currentRebasedChange.referenceGuid) {\n return null;\n }\n return makePromise(getUnrebasedChange(currentRebasedChange.referenceGuid))\n .then((rebaseChange) => {\n alreadyRebasedChanges.unshift(rebaseChange);\n if (rebaseChange === undefined) {\n throw new Error(\"Received change that references a non-existing parent change\");\n }\n return rebaseChange;\n });\n },\n makePromise,\n ),\n );\n\n // Compute the base Changeset to rebase the changes on the branch that was still the local branch\n // when the incoming change was created\n\n mainPromise = mainPromise\n .then(() => {\n // First invert all changes on the previous local branch\n const startGuid = alreadyRebasedChanges.length > 0 ?\n alreadyRebasedChanges[0].referenceGuid :\n changesOnOtherLocalBranch[0].referenceGuid;\n\n // Then apply all changes on the local remote branch\n const endGuid = change.remoteHeadGuid;\n return getRebasedChanges(startGuid, endGuid);\n })\n .then((relevantRemoteChanges) => {\n let rebaseBaseChangeSetForAlreadyRebasedChanges = new ChangeSet({});\n\n if (relevantRemoteChanges.length > 0) {\n for (const c of relevantRemoteChanges) {\n let changeset = c.changeSet;\n let applyAfterMetaInformation;\n\n if (alreadyRebasedChanges[0] !== undefined && alreadyRebasedChanges[0].guid === c.guid) {\n const invertedChange = new ChangeSet(cloneDeep(alreadyRebasedChanges[0].changeSet));\n invertedChange.toInverseChangeSet();\n invertedChange.applyChangeSet(rebaseBaseChangeSetForAlreadyRebasedChanges);\n applyAfterMetaInformation = new Map();\n const conflicts2 = [];\n changeset = cloneDeep(alreadyRebasedChanges[0].changeSet);\n rebaseBaseChangeSetForAlreadyRebasedChanges._rebaseChangeSet(changeset, conflicts2, {\n applyAfterMetaInformation,\n });\n\n rebaseBaseChangeSetForAlreadyRebasedChanges = invertedChange;\n alreadyRebasedChanges.shift();\n }\n rebaseBaseChangeSetForAlreadyRebasedChanges.applyChangeSet(changeset, { applyAfterMetaInformation });\n }\n\n // Now we have to rebase all changes from the remote local branch with respect to this base changeset\n rebaseChangeArrays(rebaseBaseChangeSetForAlreadyRebasedChanges, changesOnOtherLocalBranch);\n }\n\n // Update the reference for the rebased changes to indicate that they are now with respect to the\n // new remoteHeadGuid\n if (changesOnOtherLocalBranch.length > 0) {\n changesOnOtherLocalBranch[0].remoteHeadGuid = change.remoteHeadGuid;\n changesOnOtherLocalBranch[0].referenceGuid = change.remoteHeadGuid;\n }\n });\n }\n\n return mainPromise\n .then(() => makePromise(getRebasedChanges(change.remoteHeadGuid)))\n .then((remoteChanges) => {\n const conflicts = [];\n if (!isEqual(changesOnOtherLocalBranch.map((change) => change.guid),\n remoteChanges.map((change) => change.guid))) {\n for (const remoteChange of remoteChanges) {\n let applyAfterMetaInformation =\n commitsOnOtherLocalBranch[remoteChange.guid] !== undefined ?\n remoteChange.rebaseMetaInformation :\n undefined;\n\n let changeset = remoteChange.changeSet;\n if (changesOnOtherLocalBranch[0] !== undefined && changesOnOtherLocalBranch[0].guid === remoteChange.guid) {\n const invertedChange = new ChangeSet(cloneDeep(changesOnOtherLocalBranch[0].changeSet));\n invertedChange.toInverseChangeSet();\n invertedChange.applyChangeSet(rebaseBaseChangeSet);\n\n applyAfterMetaInformation = new Map();\n changeset = cloneDeep(changesOnOtherLocalBranch[0].changeSet);\n rebaseBaseChangeSet._rebaseChangeSet(changeset, conflicts, { applyAfterMetaInformation });\n\n // This is disabled for performance reasons. Only used during debugging\n // assert(isEqual(changeset,this.remoteChanges[i].changeSet),\n // \"Failed Rebase in rebaseToRemoteChanges\");\n rebaseBaseChangeSet = invertedChange;\n changesOnOtherLocalBranch.shift();\n }\n\n rebaseBaseChangeSet.applyChangeSet(changeset, {\n applyAfterMetaInformation,\n });\n }\n }\n\n change.rebaseMetaInformation = new Map();\n rebaseBaseChangeSet._rebaseChangeSet(change.changeSet, conflicts, {\n applyAfterMetaInformation: change.rebaseMetaInformation,\n });\n });\n}\n\nfunction rebaseChangeArrays(baseChangeSet, changesToRebase) {\n let rebaseBaseChangeSet = baseChangeSet;\n for (const change of changesToRebase) {\n const copiedChangeSet = new ChangeSet(cloneDeep(change.changeSet));\n copiedChangeSet.toInverseChangeSet();\n\n const conflicts = [];\n change.rebaseMetaInformation = new Map();\n rebaseBaseChangeSet._rebaseChangeSet(change.changeSet, conflicts, {\n applyAfterMetaInformation: change.rebaseMetaInformation,\n });\n\n copiedChangeSet.applyChangeSet(rebaseBaseChangeSet);\n copiedChangeSet.applyChangeSet(change.changeSet, {\n applyAfterMetaInformation: change.rebaseMetaInformation,\n });\n rebaseBaseChangeSet = copiedChangeSet;\n }\n}\n"]}
1
+ {"version":3,"file":"rebase.js","sourceRoot":"","sources":["../src/rebase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAErC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,WAAW;IAGhB,YAAY,CAAiB;QAC5B,IAAI,CAAC,CAAC,IAAI,YAAY,WAAW,CAAC,EAAE;YACnC,OAAO,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;SAC1B;QACD,IAAI,CAAC,YAAY,WAAW,EAAE;YAC7B,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC;SACZ;QACD,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IAChB,CAAC;IAED,IAAI,CAAC,EAAiC;QACrC,IAAI,CAAC,KAAK,GAAG,IAAI,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;QACnD,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAED,MAAM,IAAI,GAAG,CACZ,OAAqB,EACrB,EAAmE,EACnE,WAA+B,EAC9B,EAAE,CACH,OAAO;KACL,IAAI,CAAC,EAAE,CAAC;KACR,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,EAA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AS,EAAE;oBAC7C,yBAAyB;iBACzB,CAAC,CAAC;aACH;SACD;QAED,MAAM,CAAC,qBAAqB,GAAG,IAAI,GAAG,EAAE,CAAC;QACzC,mBAAmB,CAAC,gBAAgB,CAAC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE;YACjE,yBAAyB,EAAE,MAAM,CAAC,qBAAqB;SACvD,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,kBAAkB,CAAC,aAAa,EAAE,eAAe;IACzD,IAAI,mBAAmB,GAAG,aAAa,CAAC;IACxC,KAAK,MAAM,MAAM,IAAI,eAAe,EAAE;QACrC,MAAM,eAAe,GAAG,IAAI,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;QACnE,eAAe,CAAC,kBAAkB,EAAE,CAAC;QAErC,MAAM,SAAS,GAAG,EAAE,CAAC;QACrB,MAAM,CAAC,qBAAqB,GAAG,IAAI,GAAG,EAAE,CAAC;QACzC,mBAAmB,CAAC,gBAAgB,CAAC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE;YACjE,yBAAyB,EAAE,MAAM,CAAC,qBAAqB;SACvD,CAAC,CAAC;QAEH,eAAe,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC;QACpD,eAAe,CAAC,cAAc,CAAC,MAAM,CAAC,SAAS,EAAE;YAChD,yBAAyB,EAAE,MAAM,CAAC,qBAAqB;SACvD,CAAC,CAAC;QACH,mBAAmB,GAAG,eAAe,CAAC;KACtC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { copy as cloneDeep } from \"fastest-json-copy\";\nimport isEqual from \"lodash/isEqual\";\n\nimport { ChangeSet } from \"./changeset\";\n\nclass SyncPromise {\n\tvalue: any;\n\n\tconstructor(x: { value: any }) {\n\t\tif (!(this instanceof SyncPromise)) {\n\t\t\treturn new SyncPromise(x);\n\t\t}\n\t\tif (x instanceof SyncPromise) {\n\t\t\tx = x.value;\n\t\t}\n\t\tthis.value = x;\n\t}\n\n\tthen(fn: (arg0: any) => { value: any }): SyncPromise {\n\t\tthis.value = new SyncPromise(fn(this.value)).value;\n\t\treturn this;\n\t}\n}\n\nconst loop = (\n\tpromise: Promise<any>,\n\tfn: { (currentChange: any): any; (currentRebasedChange: any): any },\n\tmakePromise: (arg0: any) => any,\n) =>\n\tpromise\n\t\t.then(fn)\n\t\t.then((result) => (result === null ? result : loop(makePromise(result), fn, makePromise)));\n\nexport function rebaseToRemoteChanges(\n\tchange: any,\n\tgetUnrebasedChange: any,\n\tgetRebasedChanges: any,\n\tisAsync: boolean = false,\n) {\n\tconst makePromise = isAsync ? Promise.resolve.bind(Promise) : (x) => new SyncPromise(x);\n\tlet mainPromise = makePromise();\n\n\tconst commitsOnOtherLocalBranch = {};\n\tlet rebaseBaseChangeSet = new ChangeSet({});\n\tconst changesOnOtherLocalBranch = [];\n\tif (change.referenceGuid !== change.remoteHeadGuid) {\n\t\t// Extract all changes between the remoteHeadGuid and the referenceGuid\n\t\tlet currentGuid = change.referenceGuid;\n\t\tmainPromise = loop(\n\t\t\tmakePromise(getUnrebasedChange(currentGuid)),\n\t\t\t(currentChange) => {\n\t\t\t\tif (currentChange === undefined) {\n\t\t\t\t\tthrow new Error(\"Received change that references a non-existing parent change\");\n\t\t\t\t}\n\t\t\t\tchangesOnOtherLocalBranch.unshift(currentChange);\n\t\t\t\tcommitsOnOtherLocalBranch[currentGuid] = currentChange;\n\t\t\t\tif (currentGuid === change.localBranchStart) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\tcurrentGuid = currentChange.referenceGuid;\n\t\t\t\treturn getUnrebasedChange(currentGuid);\n\t\t\t},\n\t\t\tmakePromise,\n\t\t);\n\n\t\t// Now we extract all changes until we arrive at a change that is relative to a remote change\n\t\tconst alreadyRebasedChanges = [];\n\n\t\tmainPromise = mainPromise.then(() =>\n\t\t\tloop(\n\t\t\t\tmakePromise(getUnrebasedChange(change.localBranchStart)),\n\t\t\t\t(currentRebasedChange) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tcurrentRebasedChange.remoteHeadGuid === currentRebasedChange.referenceGuid\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\treturn makePromise(getUnrebasedChange(currentRebasedChange.referenceGuid)).then(\n\t\t\t\t\t\t(rebaseChange) => {\n\t\t\t\t\t\t\talreadyRebasedChanges.unshift(rebaseChange);\n\t\t\t\t\t\t\tif (rebaseChange === undefined) {\n\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t\"Received change that references a non-existing parent change\",\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn rebaseChange;\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tmakePromise,\n\t\t\t),\n\t\t);\n\n\t\t// Compute the base Changeset to rebase the changes on the branch that was still the local branch\n\t\t// when the incoming change was created\n\n\t\tmainPromise = mainPromise\n\t\t\t.then(() => {\n\t\t\t\t// First invert all changes on the previous local branch\n\t\t\t\tconst startGuid =\n\t\t\t\t\talreadyRebasedChanges.length > 0\n\t\t\t\t\t\t? alreadyRebasedChanges[0].referenceGuid\n\t\t\t\t\t\t: changesOnOtherLocalBranch[0].referenceGuid;\n\n\t\t\t\t// Then apply all changes on the local remote branch\n\t\t\t\tconst endGuid = change.remoteHeadGuid;\n\t\t\t\treturn getRebasedChanges(startGuid, endGuid);\n\t\t\t})\n\t\t\t.then((relevantRemoteChanges) => {\n\t\t\t\tlet rebaseBaseChangeSetForAlreadyRebasedChanges = new ChangeSet({});\n\n\t\t\t\tif (relevantRemoteChanges.length > 0) {\n\t\t\t\t\tfor (const c of relevantRemoteChanges) {\n\t\t\t\t\t\tlet changeset = c.changeSet;\n\t\t\t\t\t\tlet applyAfterMetaInformation;\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\talreadyRebasedChanges[0] !== undefined &&\n\t\t\t\t\t\t\talreadyRebasedChanges[0].guid === c.guid\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tconst invertedChange = new ChangeSet(\n\t\t\t\t\t\t\t\tcloneDeep(alreadyRebasedChanges[0].changeSet),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tinvertedChange.toInverseChangeSet();\n\t\t\t\t\t\t\tinvertedChange.applyChangeSet(\n\t\t\t\t\t\t\t\trebaseBaseChangeSetForAlreadyRebasedChanges,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tapplyAfterMetaInformation = new Map();\n\t\t\t\t\t\t\tconst conflicts2 = [];\n\t\t\t\t\t\t\tchangeset = cloneDeep(alreadyRebasedChanges[0].changeSet);\n\t\t\t\t\t\t\trebaseBaseChangeSetForAlreadyRebasedChanges._rebaseChangeSet(\n\t\t\t\t\t\t\t\tchangeset,\n\t\t\t\t\t\t\t\tconflicts2,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tapplyAfterMetaInformation,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\trebaseBaseChangeSetForAlreadyRebasedChanges = invertedChange;\n\t\t\t\t\t\t\talreadyRebasedChanges.shift();\n\t\t\t\t\t\t}\n\t\t\t\t\t\trebaseBaseChangeSetForAlreadyRebasedChanges.applyChangeSet(changeset, {\n\t\t\t\t\t\t\tapplyAfterMetaInformation,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\t// Now we have to rebase all changes from the remote local branch with respect to this base changeset\n\t\t\t\t\trebaseChangeArrays(\n\t\t\t\t\t\trebaseBaseChangeSetForAlreadyRebasedChanges,\n\t\t\t\t\t\tchangesOnOtherLocalBranch,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Update the reference for the rebased changes to indicate that they are now with respect to the\n\t\t\t\t// new remoteHeadGuid\n\t\t\t\tif (changesOnOtherLocalBranch.length > 0) {\n\t\t\t\t\tchangesOnOtherLocalBranch[0].remoteHeadGuid = change.remoteHeadGuid;\n\t\t\t\t\tchangesOnOtherLocalBranch[0].referenceGuid = change.remoteHeadGuid;\n\t\t\t\t}\n\t\t\t});\n\t}\n\n\treturn mainPromise\n\t\t.then(() => makePromise(getRebasedChanges(change.remoteHeadGuid)))\n\t\t.then((remoteChanges) => {\n\t\t\tconst conflicts = [];\n\t\t\tif (\n\t\t\t\t!isEqual(\n\t\t\t\t\tchangesOnOtherLocalBranch.map((change) => change.guid),\n\t\t\t\t\tremoteChanges.map((change) => change.guid),\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tfor (const remoteChange of remoteChanges) {\n\t\t\t\t\tlet applyAfterMetaInformation =\n\t\t\t\t\t\tcommitsOnOtherLocalBranch[remoteChange.guid] !== undefined\n\t\t\t\t\t\t\t? remoteChange.rebaseMetaInformation\n\t\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\tlet changeset = remoteChange.changeSet;\n\t\t\t\t\tif (\n\t\t\t\t\t\tchangesOnOtherLocalBranch[0] !== undefined &&\n\t\t\t\t\t\tchangesOnOtherLocalBranch[0].guid === remoteChange.guid\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst invertedChange = new ChangeSet(\n\t\t\t\t\t\t\tcloneDeep(changesOnOtherLocalBranch[0].changeSet),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tinvertedChange.toInverseChangeSet();\n\t\t\t\t\t\tinvertedChange.applyChangeSet(rebaseBaseChangeSet);\n\n\t\t\t\t\t\tapplyAfterMetaInformation = new Map();\n\t\t\t\t\t\tchangeset = cloneDeep(changesOnOtherLocalBranch[0].changeSet);\n\t\t\t\t\t\trebaseBaseChangeSet._rebaseChangeSet(changeset, conflicts, {\n\t\t\t\t\t\t\tapplyAfterMetaInformation,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\t// This is disabled for performance reasons. Only used during debugging\n\t\t\t\t\t\t// assert(isEqual(changeset,this.remoteChanges[i].changeSet),\n\t\t\t\t\t\t// \"Failed Rebase in rebaseToRemoteChanges\");\n\t\t\t\t\t\trebaseBaseChangeSet = invertedChange;\n\t\t\t\t\t\tchangesOnOtherLocalBranch.shift();\n\t\t\t\t\t}\n\n\t\t\t\t\trebaseBaseChangeSet.applyChangeSet(changeset, {\n\t\t\t\t\t\tapplyAfterMetaInformation,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tchange.rebaseMetaInformation = new Map();\n\t\t\trebaseBaseChangeSet._rebaseChangeSet(change.changeSet, conflicts, {\n\t\t\t\tapplyAfterMetaInformation: change.rebaseMetaInformation,\n\t\t\t});\n\t\t});\n}\n\nfunction rebaseChangeArrays(baseChangeSet, changesToRebase) {\n\tlet rebaseBaseChangeSet = baseChangeSet;\n\tfor (const change of changesToRebase) {\n\t\tconst copiedChangeSet = new ChangeSet(cloneDeep(change.changeSet));\n\t\tcopiedChangeSet.toInverseChangeSet();\n\n\t\tconst conflicts = [];\n\t\tchange.rebaseMetaInformation = new Map();\n\t\trebaseBaseChangeSet._rebaseChangeSet(change.changeSet, conflicts, {\n\t\t\tapplyAfterMetaInformation: change.rebaseMetaInformation,\n\t\t});\n\n\t\tcopiedChangeSet.applyChangeSet(rebaseBaseChangeSet);\n\t\tcopiedChangeSet.applyChangeSet(change.changeSet, {\n\t\t\tapplyAfterMetaInformation: change.rebaseMetaInformation,\n\t\t});\n\t\trebaseBaseChangeSet = copiedChangeSet;\n\t}\n}\n"]}
@@ -103,8 +103,10 @@ Object.keys(NativeTypes).forEach(function (key) {
103
103
  }
104
104
  });
105
105
  const requireTypeidIfNotInherits = {
106
- anyOf: [{
107
- oneOf: [{
106
+ anyOf: [
107
+ {
108
+ oneOf: [
109
+ {
108
110
  type: "object",
109
111
  properties: {
110
112
  constants: { typeof: "undefined" },
@@ -148,7 +150,8 @@ const originalSchema = {
148
150
  $ref: "#/$defs/constants",
149
151
  },
150
152
  inherits: {
151
- oneOf: [{
153
+ oneOf: [
154
+ {
152
155
  $ref: "#/$defs/typeid",
153
156
  },
154
157
  {
@@ -163,9 +166,7 @@ const originalSchema = {
163
166
  $ref: "#/$defs/annotation",
164
167
  },
165
168
  },
166
- required: [
167
- "typeid",
168
- ],
169
+ required: ["typeid"],
169
170
  };
170
171
  const TemplateSchema = {
171
172
  $schema: "http://json-schema.org/schema",
@@ -233,7 +234,8 @@ const TemplateSchema = {
233
234
  if: { properties: { typeid: { const: "Enum" } } },
234
235
  then: { properties: { properties: { type: "array" } } },
235
236
  else: {
236
- anyOf: [{
237
+ anyOf: [
238
+ {
237
239
  properties: {
238
240
  properties: { type: "array" },
239
241
  typeid: { not: { type: "string" } },
@@ -270,10 +272,7 @@ const TemplateSchema = {
270
272
  enum: ["typeid", "string"],
271
273
  },
272
274
  },
273
- allOf: [
274
- requireTypeidIfNotInherits,
275
- originalSchema,
276
- ],
275
+ allOf: [requireTypeidIfNotInherits, originalSchema],
277
276
  };
278
277
  export { TemplateSchema, NativeTypes };
279
278
  //# sourceMappingURL=templateSchema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"templateSchema.js","sourceRoot":"","sources":["../src/templateSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,GAAG;IAChB,YAAY,EAAE;QACV,QAAQ,EAAE,EAAE;QACZ,SAAS,EAAE,KAAK;KACnB;IACD,iBAAiB,EAAE;QACf,QAAQ,EAAE,CAAC,cAAc,CAAC;QAC1B,SAAS,EAAE,KAAK;KACnB;IACD,aAAa,EAAE;QACX,QAAQ,EAAE,CAAC,mBAAmB,CAAC;QAC/B,SAAS,EAAE,KAAK;KACnB;IACD,YAAY,EAAE;QACV,QAAQ,EAAE,CAAC,mBAAmB,CAAC;QAC/B,SAAS,EAAE,KAAK;KACnB;IACD,iBAAiB,EAAE;QACf,QAAQ,EAAE,CAAC,cAAc,EAAE,eAAe,CAAC;QAC3C,SAA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AAE,OAAO;YACb,QAAQ,EAAE,CAAC;YACX,KAAK,EAAE,EAAE,IAAI,EAAE,uBAAuB,EAAE;SAC3C;QACD,eAAe,EAAE;YACb,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACR,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACtB,MAAM,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE;gBAClC,KAAK,EAAE,EAAE;gBACT,UAAU,EAAE,EAAE;gBACd,OAAO,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE;gBACpC,cAAc,EAAE,EAAE,IAAI,EAAE,0BAA0B,EAAE;gBACpD,UAAU,EAAE,EAAE,IAAI,EAAE,oBAAoB,EAAE;aAC7C;YACD,QAAQ,EAAE,CAAC,IAAI,CAAC;SACnB;QACD,kBAAkB,EAAE;YAChB,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC;SAC7B;KACJ;IACD,KAAK,EAAE;QACH,0BAA0B;QAC1B,cAAc;KACjB;CACJ,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/**\n * @fileoverview\n * Declaration of the TemplateSchema module\n * The TemplateSchema is used for validating PropertySet templates that code is attempting to register\n */\n\n/**\n * Namespace containing all schema-related data for property set validation\n */\nconst NativeTypes = {\n BaseProperty: {\n inherits: [],\n primitive: false,\n },\n ContainerProperty: {\n inherits: [\"BaseProperty\"],\n primitive: false,\n },\n NamedProperty: {\n inherits: [\"ContainerProperty\"],\n primitive: false,\n },\n NodeProperty: {\n inherits: [\"ContainerProperty\"],\n primitive: false,\n },\n NamedNodeProperty: {\n inherits: [\"NodeProperty\", \"NamedProperty\"],\n primitive: false,\n },\n RelationshipProperty: {\n inherits: [\"NodeProperty\", \"NamedProperty\"],\n primitive: false,\n },\n String: {\n inherits: [\"ContainerProperty\"],\n primitive: true,\n },\n Float32: {\n inherits: [\"BaseProperty\"],\n primitive: true,\n },\n Float64: {\n inherits: [\"BaseProperty\"],\n primitive: true,\n },\n Int8: {\n inherits: [\"BaseProperty\"],\n primitive: true,\n },\n Uint8: {\n inherits: [\"BaseProperty\"],\n primitive: true,\n },\n Int16: {\n inherits: [\"BaseProperty\"],\n primitive: true,\n },\n Uint16: {\n inherits: [\"BaseProperty\"],\n primitive: true,\n },\n Int32: {\n inherits: [\"BaseProperty\"],\n primitive: true,\n },\n Uint32: {\n inherits: [\"BaseProperty\"],\n primitive: true,\n },\n Bool: {\n inherits: [\"BaseProperty\"],\n primitive: true,\n },\n Reference: {\n inherits: [\"BaseProperty\"],\n primitive: true,\n },\n Enum: {\n inherits: [\"Int32\"],\n primitive: true,\n },\n Int64: {\n inherits: [\"BaseProperty\"],\n primitive: true,\n },\n Uint64: {\n inherits: [\"BaseProperty\"],\n primitive: true,\n },\n};\n\nconst primitiveTypes = [];\nconst reservedTypes = [];\n\nObject.keys(NativeTypes).forEach(function(key) {\n if (NativeTypes[key].primitive) {\n primitiveTypes.push(key);\n } else {\n reservedTypes.push(key);\n }\n});\n\nconst requireTypeidIfNotInherits = {\n anyOf: [{\n oneOf: [{\n type: \"object\",\n properties: {\n constants: { typeof: \"undefined\" },\n },\n },\n {\n type: \"object\",\n prohibited: [\"constants\"],\n },\n ],\n },\n {\n type: \"object\",\n required: [\"inherits\"],\n },\n {\n type: \"object\",\n properties: {\n constants: {\n type: \"array\",\n items: {\n type: \"object\",\n required: [\"typeid\"],\n },\n },\n },\n },\n ],\n};\n\nconst originalSchema = {\n type: \"object\",\n minProperties: 1,\n properties: {\n typeid: {\n $ref: \"#/$defs/versioned-typeid\",\n },\n properties: {\n $ref: \"#/$defs/properties\",\n },\n constants: {\n $ref: \"#/$defs/constants\",\n },\n inherits: {\n oneOf: [{\n $ref: \"#/$defs/typeid\",\n },\n {\n type: \"array\",\n items: {\n $ref: \"#/$defs/typeid\",\n },\n },\n ],\n },\n annotation: {\n $ref: \"#/$defs/annotation\",\n },\n },\n required: [\n \"typeid\",\n ],\n};\n\nconst TemplateSchema = {\n $schema: \"http://json-schema.org/schema\",\n title: \"Property set template schema\",\n $id: \"{TEMPLATE_SCHEMA_URL}\",\n $defs: {\n \"annotation\": {\n type: \"object\",\n properties: {\n description: { type: \"string\" },\n // 'doc': { 'type': 'string', 'format': 'uri' }\n },\n },\n \"primitive-typeid\": {\n enum: primitiveTypes,\n type: \"string\",\n },\n \"versioned-typeid\": {\n type: \"string\",\n pattern: \"^[_a-zA-Z0-9\\\\.]+:[_a-zA-Z0-9\\\\.]+-(\\\\d+\\\\.\\\\d+\\\\.\\\\d+|draft)$\",\n },\n \"typed-reference-typeid\": {\n type: \"string\",\n pattern: `^Reference<([_a-zA-Z0-9\\\\.]+:[_a-zA-Z0-9\\\\.]+(-\\\\d+\\\\.\\\\d+\\\\.\\\\d+)?|${primitiveTypes.join(\"|\")}|${reservedTypes.join(\"|\")})>$`,\n },\n \"reserved-typeid\": {\n enum: reservedTypes,\n type: \"string\",\n },\n \"context\": {\n enum: [\"single\", \"array\", \"map\", \"set\"],\n },\n \"typeid\": {\n oneOf: [\n { $ref: \"#/$defs/primitive-typeid\" },\n { $ref: \"#/$defs/versioned-typeid\" },\n { $ref: \"#/$defs/typed-reference-typeid\" },\n { $ref: \"#/$defs/reserved-typeid\" },\n ],\n },\n \"properties\": {\n type: \"array\",\n items: { $ref: \"#/$defs/property-item\" },\n },\n \"property-item\": {\n type: \"object\",\n properties: {\n context: { $ref: \"#/$defs/context\" },\n typeid: { $ref: \"#/$defs/typeid\" },\n id: { type: \"string\" },\n value: {},\n typedValue: {},\n properties: { $ref: \"#/$defs/properties\" },\n annotation: { $ref: \"#/$defs/annotation\" },\n length: {\n type: \"integer\",\n multipleOf: 1.0,\n minimum: 0,\n },\n optional: {\n type: \"boolean\",\n },\n },\n required: [\"id\"],\n if: { properties: { typeid: { const: \"Enum\" } } },\n then: { properties: { properties: { type: \"array\" } } },\n else: {\n anyOf: [{\n properties: {\n properties: { type: \"array\" },\n typeid: { not: { type: \"string\" } },\n },\n },\n {\n properties: {\n typeid: { type: \"string\" },\n properties: { not: { type: \"array\" } },\n },\n },\n ],\n },\n },\n \"constants\": {\n type: \"array\",\n minItems: 1,\n items: { $ref: \"#/$defs/constant-item\" },\n },\n \"constant-item\": {\n type: \"object\",\n properties: {\n id: { type: \"string\" },\n typeid: { $ref: \"#/$defs/typeid\" },\n value: {},\n typedValue: {},\n context: { $ref: \"#/$defs/context\" },\n contextKeyType: { $ref: \"#/$defs/context-key-type\" },\n annotation: { $ref: \"#/$defs/annotation\" },\n },\n required: [\"id\"],\n },\n \"context-key-type\": {\n enum: [\"typeid\", \"string\"],\n },\n },\n allOf: [\n requireTypeidIfNotInherits,\n originalSchema,\n ],\n};\n\nexport { TemplateSchema, NativeTypes };\n"]}
1
+ {"version":3,"file":"templateSchema.js","sourceRoot":"","sources":["../src/templateSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,GAAG;IACnB,YAAY,EAAE;QACb,QAAQ,EAAE,EAAE;QACZ,SAAS,EAAE,KAAK;KAChB;IACD,iBAAiB,EAAE;QAClB,QAAQ,EAAE,CAAC,cAAc,CAAC;QAC1B,SAAS,EAAE,KAAK;KAChB;IACD,aAAa,EAAE;QACd,QAAQ,EAAE,CAAC,mBAAmB,CAAC;QAC/B,SAAS,EAAE,KAAK;KAChB;IACD,YAAY,EAAE;QACb,QAAQ,EAAE,CAAC,mBAAmB,CAAC;QAC/B,SAAS,EAAE,KAAK;KAChB;IACD,iBAAiB,EAAE;QAClB,QAAQ,EAAE,CAAC,cAAc,EAAE,eAAe,CAAC;QAC3C,SAAS,EAAE,KAAK;KAChB;IACD,oBAAoB,EAAE;QACrB,QAAQ,EAAE,CAAC,cAAc,EAAE,eAAe,CAAC;QAC3C,SAAS,EAAE,KAAK;KAChB;IACD,MAAM,EAAE;QACP,QAAQ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,MAAM,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE;gBAClC,KAAK,EAAE,EAAE;gBACT,UAAU,EAAE,EAAE;gBACd,OAAO,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE;gBACpC,cAAc,EAAE,EAAE,IAAI,EAAE,0BAA0B,EAAE;gBACpD,UAAU,EAAE,EAAE,IAAI,EAAE,oBAAoB,EAAE;aAC1C;YACD,QAAQ,EAAE,CAAC,IAAI,CAAC;SAChB;QACD,kBAAkB,EAAE;YACnB,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC;SAC1B;KACD;IACD,KAAK,EAAE,CAAC,0BAA0B,EAAE,cAAc,CAAC;CACnD,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/**\n * @fileoverview\n * Declaration of the TemplateSchema module\n * The TemplateSchema is used for validating PropertySet templates that code is attempting to register\n */\n\n/**\n * Namespace containing all schema-related data for property set validation\n */\nconst NativeTypes = {\n\tBaseProperty: {\n\t\tinherits: [],\n\t\tprimitive: false,\n\t},\n\tContainerProperty: {\n\t\tinherits: [\"BaseProperty\"],\n\t\tprimitive: false,\n\t},\n\tNamedProperty: {\n\t\tinherits: [\"ContainerProperty\"],\n\t\tprimitive: false,\n\t},\n\tNodeProperty: {\n\t\tinherits: [\"ContainerProperty\"],\n\t\tprimitive: false,\n\t},\n\tNamedNodeProperty: {\n\t\tinherits: [\"NodeProperty\", \"NamedProperty\"],\n\t\tprimitive: false,\n\t},\n\tRelationshipProperty: {\n\t\tinherits: [\"NodeProperty\", \"NamedProperty\"],\n\t\tprimitive: false,\n\t},\n\tString: {\n\t\tinherits: [\"ContainerProperty\"],\n\t\tprimitive: true,\n\t},\n\tFloat32: {\n\t\tinherits: [\"BaseProperty\"],\n\t\tprimitive: true,\n\t},\n\tFloat64: {\n\t\tinherits: [\"BaseProperty\"],\n\t\tprimitive: true,\n\t},\n\tInt8: {\n\t\tinherits: [\"BaseProperty\"],\n\t\tprimitive: true,\n\t},\n\tUint8: {\n\t\tinherits: [\"BaseProperty\"],\n\t\tprimitive: true,\n\t},\n\tInt16: {\n\t\tinherits: [\"BaseProperty\"],\n\t\tprimitive: true,\n\t},\n\tUint16: {\n\t\tinherits: [\"BaseProperty\"],\n\t\tprimitive: true,\n\t},\n\tInt32: {\n\t\tinherits: [\"BaseProperty\"],\n\t\tprimitive: true,\n\t},\n\tUint32: {\n\t\tinherits: [\"BaseProperty\"],\n\t\tprimitive: true,\n\t},\n\tBool: {\n\t\tinherits: [\"BaseProperty\"],\n\t\tprimitive: true,\n\t},\n\tReference: {\n\t\tinherits: [\"BaseProperty\"],\n\t\tprimitive: true,\n\t},\n\tEnum: {\n\t\tinherits: [\"Int32\"],\n\t\tprimitive: true,\n\t},\n\tInt64: {\n\t\tinherits: [\"BaseProperty\"],\n\t\tprimitive: true,\n\t},\n\tUint64: {\n\t\tinherits: [\"BaseProperty\"],\n\t\tprimitive: true,\n\t},\n};\n\nconst primitiveTypes = [];\nconst reservedTypes = [];\n\nObject.keys(NativeTypes).forEach(function (key) {\n\tif (NativeTypes[key].primitive) {\n\t\tprimitiveTypes.push(key);\n\t} else {\n\t\treservedTypes.push(key);\n\t}\n});\n\nconst requireTypeidIfNotInherits = {\n\tanyOf: [\n\t\t{\n\t\t\toneOf: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"object\",\n\t\t\t\t\tproperties: {\n\t\t\t\t\t\tconstants: { typeof: \"undefined\" },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttype: \"object\",\n\t\t\t\t\tprohibited: [\"constants\"],\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\t{\n\t\t\ttype: \"object\",\n\t\t\trequired: [\"inherits\"],\n\t\t},\n\t\t{\n\t\t\ttype: \"object\",\n\t\t\tproperties: {\n\t\t\t\tconstants: {\n\t\t\t\t\ttype: \"array\",\n\t\t\t\t\titems: {\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\trequired: [\"typeid\"],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t],\n};\n\nconst originalSchema = {\n\ttype: \"object\",\n\tminProperties: 1,\n\tproperties: {\n\t\ttypeid: {\n\t\t\t$ref: \"#/$defs/versioned-typeid\",\n\t\t},\n\t\tproperties: {\n\t\t\t$ref: \"#/$defs/properties\",\n\t\t},\n\t\tconstants: {\n\t\t\t$ref: \"#/$defs/constants\",\n\t\t},\n\t\tinherits: {\n\t\t\toneOf: [\n\t\t\t\t{\n\t\t\t\t\t$ref: \"#/$defs/typeid\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttype: \"array\",\n\t\t\t\t\titems: {\n\t\t\t\t\t\t$ref: \"#/$defs/typeid\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tannotation: {\n\t\t\t$ref: \"#/$defs/annotation\",\n\t\t},\n\t},\n\trequired: [\"typeid\"],\n};\n\nconst TemplateSchema = {\n\t$schema: \"http://json-schema.org/schema\",\n\ttitle: \"Property set template schema\",\n\t$id: \"{TEMPLATE_SCHEMA_URL}\",\n\t$defs: {\n\t\t\"annotation\": {\n\t\t\ttype: \"object\",\n\t\t\tproperties: {\n\t\t\t\tdescription: { type: \"string\" },\n\t\t\t\t// 'doc': { 'type': 'string', 'format': 'uri' }\n\t\t\t},\n\t\t},\n\t\t\"primitive-typeid\": {\n\t\t\tenum: primitiveTypes,\n\t\t\ttype: \"string\",\n\t\t},\n\t\t\"versioned-typeid\": {\n\t\t\ttype: \"string\",\n\t\t\tpattern: \"^[_a-zA-Z0-9\\\\.]+:[_a-zA-Z0-9\\\\.]+-(\\\\d+\\\\.\\\\d+\\\\.\\\\d+|draft)$\",\n\t\t},\n\t\t\"typed-reference-typeid\": {\n\t\t\ttype: \"string\",\n\t\t\tpattern: `^Reference<([_a-zA-Z0-9\\\\.]+:[_a-zA-Z0-9\\\\.]+(-\\\\d+\\\\.\\\\d+\\\\.\\\\d+)?|${primitiveTypes.join(\n\t\t\t\t\"|\",\n\t\t\t)}|${reservedTypes.join(\"|\")})>$`,\n\t\t},\n\t\t\"reserved-typeid\": {\n\t\t\tenum: reservedTypes,\n\t\t\ttype: \"string\",\n\t\t},\n\t\t\"context\": {\n\t\t\tenum: [\"single\", \"array\", \"map\", \"set\"],\n\t\t},\n\t\t\"typeid\": {\n\t\t\toneOf: [\n\t\t\t\t{ $ref: \"#/$defs/primitive-typeid\" },\n\t\t\t\t{ $ref: \"#/$defs/versioned-typeid\" },\n\t\t\t\t{ $ref: \"#/$defs/typed-reference-typeid\" },\n\t\t\t\t{ $ref: \"#/$defs/reserved-typeid\" },\n\t\t\t],\n\t\t},\n\t\t\"properties\": {\n\t\t\ttype: \"array\",\n\t\t\titems: { $ref: \"#/$defs/property-item\" },\n\t\t},\n\t\t\"property-item\": {\n\t\t\ttype: \"object\",\n\t\t\tproperties: {\n\t\t\t\tcontext: { $ref: \"#/$defs/context\" },\n\t\t\t\ttypeid: { $ref: \"#/$defs/typeid\" },\n\t\t\t\tid: { type: \"string\" },\n\t\t\t\tvalue: {},\n\t\t\t\ttypedValue: {},\n\t\t\t\tproperties: { $ref: \"#/$defs/properties\" },\n\t\t\t\tannotation: { $ref: \"#/$defs/annotation\" },\n\t\t\t\tlength: {\n\t\t\t\t\ttype: \"integer\",\n\t\t\t\t\tmultipleOf: 1.0,\n\t\t\t\t\tminimum: 0,\n\t\t\t\t},\n\t\t\t\toptional: {\n\t\t\t\t\ttype: \"boolean\",\n\t\t\t\t},\n\t\t\t},\n\t\t\trequired: [\"id\"],\n\t\t\tif: { properties: { typeid: { const: \"Enum\" } } },\n\t\t\tthen: { properties: { properties: { type: \"array\" } } },\n\t\t\telse: {\n\t\t\t\tanyOf: [\n\t\t\t\t\t{\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tproperties: { type: \"array\" },\n\t\t\t\t\t\t\ttypeid: { not: { type: \"string\" } },\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\ttypeid: { type: \"string\" },\n\t\t\t\t\t\t\tproperties: { not: { type: \"array\" } },\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\t\"constants\": {\n\t\t\ttype: \"array\",\n\t\t\tminItems: 1,\n\t\t\titems: { $ref: \"#/$defs/constant-item\" },\n\t\t},\n\t\t\"constant-item\": {\n\t\t\ttype: \"object\",\n\t\t\tproperties: {\n\t\t\t\tid: { type: \"string\" },\n\t\t\t\ttypeid: { $ref: \"#/$defs/typeid\" },\n\t\t\t\tvalue: {},\n\t\t\t\ttypedValue: {},\n\t\t\t\tcontext: { $ref: \"#/$defs/context\" },\n\t\t\t\tcontextKeyType: { $ref: \"#/$defs/context-key-type\" },\n\t\t\t\tannotation: { $ref: \"#/$defs/annotation\" },\n\t\t\t},\n\t\t\trequired: [\"id\"],\n\t\t},\n\t\t\"context-key-type\": {\n\t\t\tenum: [\"typeid\", \"string\"],\n\t\t},\n\t},\n\tallOf: [requireTypeidIfNotInherits, originalSchema],\n};\n\nexport { TemplateSchema, NativeTypes };\n"]}