@fluid-experimental/property-changeset 0.58.1001 → 0.58.2001
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 +1 -18
- package/dist/changeset.js.map +1 -1
- package/dist/changeset_operations/array.d.ts.map +1 -1
- package/dist/changeset_operations/array.js +0 -3
- package/dist/changeset_operations/array.js.map +1 -1
- package/dist/changeset_operations/arrayChangesetIterator.d.ts +4 -4
- package/dist/changeset_operations/arrayChangesetIterator.d.ts.map +1 -1
- package/dist/changeset_operations/arrayChangesetIterator.js +1 -5
- package/dist/changeset_operations/arrayChangesetIterator.js.map +1 -1
- package/dist/changeset_operations/changesetConflictTypes.d.ts.map +1 -1
- package/dist/changeset_operations/changesetConflictTypes.js +0 -1
- package/dist/changeset_operations/changesetConflictTypes.js.map +1 -1
- package/dist/changeset_operations/indexedCollection.d.ts.map +1 -1
- package/dist/changeset_operations/indexedCollection.js +1 -3
- package/dist/changeset_operations/indexedCollection.js.map +1 -1
- package/dist/changeset_operations/isEmptyChangeset.js.map +1 -1
- package/dist/changeset_operations/operationTypes.js +0 -1
- package/dist/changeset_operations/operationTypes.js.map +1 -1
- package/dist/helpers/typeidHelper.d.ts.map +1 -1
- package/dist/helpers/typeidHelper.js +4 -5
- package/dist/helpers/typeidHelper.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/pathHelper.d.ts +2 -2
- package/dist/pathHelper.d.ts.map +1 -1
- package/dist/pathHelper.js +0 -2
- package/dist/pathHelper.js.map +1 -1
- package/dist/rebase.js +0 -1
- package/dist/rebase.js.map +1 -1
- package/dist/templateValidator.d.ts +3 -3
- package/dist/templateValidator.d.ts.map +1 -1
- package/dist/templateValidator.js +10 -12
- package/dist/templateValidator.js.map +1 -1
- package/dist/test/array.spec.js +56 -56
- package/dist/test/array.spec.js.map +1 -1
- package/dist/test/pathHelper.spec.js +14 -14
- package/dist/test/pathHelper.spec.js.map +1 -1
- package/dist/test/schemaValidator.js +2 -8
- package/dist/test/schemaValidator.js.map +1 -1
- package/dist/test/schemas/badBothPropertiesAndTypeid.js +3 -3
- package/dist/test/schemas/badBothPropertiesAndTypeid.js.map +1 -1
- package/dist/test/schemas/badInvalidSemverInTypeid.js +9 -9
- package/dist/test/schemas/badInvalidSemverInTypeid.js.map +1 -1
- package/dist/test/schemas/badMissingSemverInTypeid.js +9 -9
- package/dist/test/schemas/badMissingSemverInTypeid.js.map +1 -1
- package/dist/test/schemas/badNestedProperties.js +9 -9
- package/dist/test/schemas/badNestedProperties.js.map +1 -1
- package/dist/test/schemas/badPrimitiveTypeid.js +5 -5
- package/dist/test/schemas/badPrimitiveTypeid.js.map +1 -1
- package/dist/test/schemas/badVersionedTypeid.js +9 -9
- package/dist/test/schemas/badVersionedTypeid.js.map +1 -1
- package/dist/test/schemas/goodColorPalette.js +2 -2
- package/dist/test/schemas/goodColorPalette.js.map +1 -1
- package/dist/test/schemas/goodDraftAsVersion.js +2 -2
- package/dist/test/schemas/goodDraftAsVersion.js.map +1 -1
- package/dist/test/schemas/goodPointId.js +9 -9
- package/dist/test/schemas/goodPointId.js.map +1 -1
- package/dist/test/schemas/goodReferenceAndRegular.js +2 -2
- package/dist/test/schemas/goodReferenceAndRegular.js.map +1 -1
- package/dist/test/schemas/goodReservedTypes.js +4 -4
- package/dist/test/schemas/goodReservedTypes.js.map +1 -1
- package/dist/test/schemas/goodUIBorder.js +7 -7
- package/dist/test/schemas/goodUIBorder.js.map +1 -1
- package/dist/test/tsconfig.tsbuildinfo +23 -23
- package/dist/test/validator/templateValidator.spec.js +27 -27
- package/dist/test/validator/templateValidator.spec.js.map +1 -1
- package/dist/test/validator/typeidHelper.spec.js +2 -2
- package/dist/test/validator/typeidHelper.spec.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +2 -4
- package/dist/utils.js.map +1 -1
- package/lib/changeset.js +1 -18
- package/lib/changeset.js.map +1 -1
- package/lib/changeset_operations/array.js +0 -3
- package/lib/changeset_operations/array.js.map +1 -1
- package/lib/changeset_operations/arrayChangesetIterator.js +1 -5
- package/lib/changeset_operations/arrayChangesetIterator.js.map +1 -1
- package/lib/changeset_operations/changesetConflictTypes.js +0 -1
- package/lib/changeset_operations/changesetConflictTypes.js.map +1 -1
- package/lib/changeset_operations/indexedCollection.js +1 -3
- package/lib/changeset_operations/indexedCollection.js.map +1 -1
- package/lib/changeset_operations/isEmptyChangeset.js.map +1 -1
- package/lib/changeset_operations/operationTypes.js +0 -1
- package/lib/changeset_operations/operationTypes.js.map +1 -1
- package/lib/helpers/typeidHelper.js +4 -5
- package/lib/helpers/typeidHelper.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/pathHelper.js +0 -2
- package/lib/pathHelper.js.map +1 -1
- package/lib/rebase.js +0 -1
- package/lib/rebase.js.map +1 -1
- package/lib/templateValidator.js +10 -12
- package/lib/templateValidator.js.map +1 -1
- package/lib/utils.js +2 -4
- package/lib/utils.js.map +1 -1
- package/package.json +8 -4
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.TypeIdHelper = void 0;
|
|
11
|
-
const templateSchema_1 = require("../templateSchema");
|
|
12
11
|
// @ts-ignore
|
|
13
12
|
const property_common_1 = require("@fluid-experimental/property-common");
|
|
13
|
+
const templateSchema_1 = require("../templateSchema");
|
|
14
14
|
const { MSG } = property_common_1.constants;
|
|
15
15
|
/**
|
|
16
16
|
* Helper for Type IDs
|
|
@@ -68,7 +68,7 @@ var TypeIdHelper;
|
|
|
68
68
|
const splitTypeId = in_typeid.split("-");
|
|
69
69
|
return {
|
|
70
70
|
version: splitTypeId[1],
|
|
71
|
-
typeidWithoutVersion: splitTypeId[0]
|
|
71
|
+
typeidWithoutVersion: splitTypeId[0],
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
74
|
TypeIdHelper.extractVersion = extractVersion;
|
|
@@ -108,14 +108,14 @@ var TypeIdHelper;
|
|
|
108
108
|
return {
|
|
109
109
|
typeid,
|
|
110
110
|
context,
|
|
111
|
-
isEnum
|
|
111
|
+
isEnum,
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
114
|
else {
|
|
115
115
|
return {
|
|
116
116
|
typeid: in_typeid,
|
|
117
117
|
context: "single",
|
|
118
|
-
isEnum: false
|
|
118
|
+
isEnum: false,
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
121
|
}
|
|
@@ -267,5 +267,4 @@ var TypeIdHelper;
|
|
|
267
267
|
}
|
|
268
268
|
TypeIdHelper.getReservedTypeIds = getReservedTypeIds;
|
|
269
269
|
})(TypeIdHelper = exports.TypeIdHelper || (exports.TypeIdHelper = {}));
|
|
270
|
-
;
|
|
271
270
|
//# sourceMappingURL=typeidHelper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeidHelper.js","sourceRoot":"","sources":["../../src/helpers/typeidHelper.ts"],"names":[],"mappings":";AAAA;;;GAGG;AACH;;GAEG;;;AAEH,sDAAsF;AACtF,aAAa;AACb,yEAAgE;AAEhE,MAAM,EAAE,GAAG,EAAE,GAAG,2BAAS,CAAC;AAa1B;;;;GAIG;AACH,IAAiB,YAAY,CA+P5B;AA/PD,WAAiB,YAAY;IACzB;;;;;OAKG;IACH,SAAgB,eAAe,CAAC,SAAiB;QAC7C,MAAM,cAAc,GAAG,+BAAkB,CAAC,OAAO,CAAC,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;QAE/E,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,KAAK,EAAE,EAAE;YAC7C,OAAO,KAAK,CAAC;SAChB;QAED,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,OAAO;YACrC,SAAS,CAAC,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AC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC,EAAE;gBACpD,OAAO,IAAI,CAAC;aACf;SACJ;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;IAtCe,+BAAkB,qBAsCjC,CAAA;IAED;;;;OAIG;IACH,SAAgB,mBAAmB;QAC/B,OAAO,+BAAkB,CAAC,OAAO,CAAC,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;IACnE,CAAC;IAFe,gCAAmB,sBAElC,CAAA;IAED;;;;OAIG;IACH,SAAgB,kBAAkB;QAC9B,OAAO,+BAAkB,CAAC,OAAO,CAAC,CAAC,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;IAClE,CAAC;IAFe,+BAAkB,qBAEjC,CAAA;AACL,CAAC,EA/PgB,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QA+P5B;AAAA,CAAC","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 typeid strings\n */\n\nimport { TemplateSchema as templateSchemaJson, NativeTypes } from \"../templateSchema\";\n// @ts-ignore\nimport { constants } from \"@fluid-experimental/property-common\";\n\nconst { MSG } = constants;\n\nexport declare interface ExtractedVersion {\n version: string;\n typeidWithoutVersion: string;\n}\n\nexport declare interface ExtractedContext {\n typeid: string;\n context: string;\n isEnum: boolean;\n}\n\n/**\n * Helper for Type IDs\n * @public\n * @description Helper functions to work with typeid strings\n */\nexport namespace TypeIdHelper {\n /**\n * Checks whether the given type is a primitive type.\n *\n * @param in_typeid - The typeid we want to check\n * @returns Is this a base type?\n */\n export function isPrimitiveType(in_typeid: string): boolean {\n const primitiveTypes = templateSchemaJson[\"$defs\"][\"primitive-typeid\"][\"enum\"];\n\n if (in_typeid === undefined || in_typeid === \"\") {\n return false;\n }\n\n return in_typeid.substr(0, 5) === \"enum<\" ||\n in_typeid.substr(0, 10) === \"Reference<\" ||\n primitiveTypes.indexOf(in_typeid) >= 0;\n }\n\n /**\n * Checks whether the given type is a template typeid.\n *\n * @param in_typeid - The typeid we want to check\n * @returns Is this a base template typeid?\n */\n export function isTemplateTypeid(in_typeid: string): boolean {\n return in_typeid.indexOf(\":\") !== -1;\n }\n\n /**\n * Checks whether the given type is a reserved type.\n *\n * @param in_typeid - The typeid we want to check\n * @returns Is this a reserved type?\n */\n export function isReservedType(in_typeid: string): boolean {\n const reservedTypes = templateSchemaJson[\"$defs\"][\"reserved-typeid\"][\"enum\"];\n return reservedTypes.indexOf(in_typeid) >= 0;\n }\n\n /**\n * Extract the version number from the given typeid\n * @param in_typeid The typeid to check against\n * @returns Extracted version\n */\n export function extractVersion(in_typeid): ExtractedVersion {\n if (!in_typeid) {\n throw new Error(MSG.TYPEID_NOT_DEFINED);\n }\n const splitTypeId = in_typeid.split(\"-\");\n\n return {\n version: splitTypeId[1],\n typeidWithoutVersion: splitTypeId[0]\n };\n }\n\n /**\n * Extracts the context from a typeid\n *\n * @param in_typeid - The typeid to process\n * @returns Returns the typeid without context, the context and if we have an enum type\n */\n export function extractContext(in_typeid: string | undefined): ExtractedContext {\n const bracketIndex = in_typeid.indexOf(\"<\");\n if (bracketIndex !== -1 &&\n in_typeid[in_typeid.length - 1] === \">\") {\n let typeid = in_typeid.substr(bracketIndex + 1, in_typeid.length - bracketIndex - 2);\n let context = in_typeid.substr(0, bracketIndex);\n\n // Special case to handle collections without a typeid (e.g. \"map<>\", which should\n // be able to support all property types\n if (typeid === \"\") {\n typeid = context !== \"set\" ? \"BaseProperty\" : \"NamedProperty\";\n }\n\n // Special case to handle enums (e.g. array<enum<myType>>)\n let isEnum = false;\n if (context === \"enum\" || typeid.substr(0, 5) === \"enum<\") {\n isEnum = true;\n if (context === \"enum\") {\n context = \"single\";\n } else {\n // remove the `enum<...>` tag to get the raw typeid\n typeid = typeid.substr(5, typeid.length - 6);\n }\n }\n if (context === \"Reference\") {\n typeid = `Reference<${typeid}>`;\n context = \"single\";\n }\n\n return {\n typeid,\n context,\n isEnum\n };\n } else {\n return {\n typeid: in_typeid,\n context: \"single\",\n isEnum: false\n };\n }\n }\n\n /**\n * Creates a collection typeid string from the\n * typeid and the context.\n *\n * @param in_typeid - the typeid in the collection\n * @param in_context - the context\n * @param in_enum - set to true, if the type should get an enum tag\n *\n * @returns The combined typeid string\n */\n export function createSerializationTypeId(in_typeid: string, in_context: string, in_enum: boolean): string { // in_enum\n if (in_typeid === \"BaseProperty\") {\n // Special case for BaseProperties. These get represented as a collection\n // typeid without a child typeid. E.g. map<> instead of map<BaseProperty>\n return `${in_context}<>`;\n } else {\n if (in_enum) {\n if (in_context === \"\" || in_context === \"single\") {\n return `enum<${in_typeid}>`;\n } else {\n return `${in_context}<enum<${in_typeid}>>`;\n }\n } else {\n return `${in_context}<${in_typeid}>`;\n }\n }\n }\n\n /**\n * Checks, whether the supplied typeid is a reference property type id\n *\n * @param in_typeid - The typeid to check\n * @returns Is this a reference property typeid?\n */\n export function isReferenceTypeId(in_typeid: string | undefined ): boolean { // in_enum\n return in_typeid === \"Reference\" ||\n (in_typeid.substr(0, 10) === \"Reference<\" && in_typeid.substr(-1) === \">\");\n }\n\n /**\n * Returns the type of the properties a reference points to\n *\n * @param in_typeid - The typeid to process\n * @return The type of the referenced property\n */\n export function extractReferenceTargetTypeIdFromReference(in_typeid: string): string { // in_enum\n if (in_typeid.substr(0, 10) === \"Reference<\") {\n // Extract the type from the TypeID\n return in_typeid.substr(10, in_typeid.length - 11);\n } else {\n // This is a typeless reference, we allow all types\n return \"BaseProperty\";\n }\n }\n\n /**\n * Checks whether the given type is a template typeid.\n *\n * @param in_typeid - The typeid we want to check\n * @returns Is this a base template typeid?\n */\n export function isSchemaTypeid(in_typeid: string): boolean {\n return typeof in_typeid === \"string\" && (in_typeid.indexOf(\":\") !== -1);\n }\n\n /**\n * Extracts referenced typeid from input typeid\n *\n * @param in_typeid typeid\n *\n * @return referenced typeid or in_param if it is not a reference\n */\n export function extractTypeId(in_typeid): string {\n const matches = in_typeid.match(/\\<(.*?)\\>/);\n if (matches !== null && matches.length > 0) {\n return matches[0].replace(/[\\<\\>]/gi, \"\");\n } else {\n return in_typeid;\n }\n }\n\n\n /**\n * Check wether the in_typeid inherits from the in_baseTypeid\n *\n * Note: By default, this also returns true if in_typeid === in_baseTypeid.\n *\n * @param in_typeid - Typeid for which we want to check, whethwe in_baseTypeid is a parent\n * @param in_baseTypeid - The base typeId to check for\n * @throws if in_typeid or in_baseTypeid are not native typeid\n * @returns True if in_baseTypeid is a parent of in_typeid\n */\n export function nativeInheritsFrom(in_typeid: string, in_baseTypeid: string): boolean {\n if (!in_typeid || !in_baseTypeid) {\n throw new Error(MSG.TYPEID_NOT_DEFINED);\n }\n\n if (in_typeid.substr(0, 10) === \"Reference<\") {\n in_typeid = \"Reference\";\n }\n\n if (in_baseTypeid.substr(0, 10) === \"Reference<\") {\n in_baseTypeid = \"Reference\";\n }\n\n if (!NativeTypes[in_typeid]) {\n throw new Error(MSG.TYPEID_NOT_NATIVE + in_typeid);\n }\n\n if (!NativeTypes[in_baseTypeid]) {\n throw new Error(MSG.TYPEID_NOT_NATIVE + in_baseTypeid);\n }\n\n if (in_baseTypeid === \"BaseProperty\" || in_typeid === in_baseTypeid) {\n return true;\n }\n\n if (in_typeid === \"BaseProperty\") {\n return false;\n }\n\n let parents = NativeTypes[in_typeid][\"inherits\"];\n\n // recursively call the function for the parent of the typeid\n for (let i = 0; i < parents.length; i++) {\n if (this.nativeInheritsFrom(parents[i], in_baseTypeid)) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * return all primitive typeIds\n *\n * @returns return a list of primitiveTypeIds\n */\n export function getPrimitiveTypeIds(): string[] {\n return templateSchemaJson[\"$defs\"][\"primitive-typeid\"][\"enum\"];\n }\n\n /**\n * return all reserved typeIds\n *\n * @returns return a list of reservedTypeIds\n */\n export function getReservedTypeIds(): string[] {\n return templateSchemaJson[\"$defs\"][\"reserved-typeid\"][\"enum\"];\n }\n};\n"]}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CAAC,SAAS,CAAC,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAAC;SACtD;QAED,IAAI,CAAC,4BAAW,CAAC,aAAa,CAAC,EAAE;YAC7B,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,iBAAiB,GAAG,aAAa,CAAC,CAAC;SAC1D;QAED,IAAI,aAAa,KAAK,cAAc,IAAI,SAAS,KAAK,aAAa,EAAE;YACjE,OAAO,IAAI,CAAC;SACf;QAED,IAAI,SAAS,KAAK,cAAc,EAAE;YAC9B,OAAO,KAAK,CAAC;SAChB;QAED,IAAI,OAAO,GAAG,4BAAW,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC,CAAC;QAEjD,6DAA6D;QAC7D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACrC,IAAI,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC,EAAE;gBACpD,OAAO,IAAI,CAAC;aACf;SACJ;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;IAtCe,+BAAkB,qBAsCjC,CAAA;IAED;;;;OAIG;IACH,SAAgB,mBAAmB;QAC/B,OAAO,+BAAkB,CAAC,OAAO,CAAC,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;IACnE,CAAC;IAFe,gCAAmB,sBAElC,CAAA;IAED;;;;OAIG;IACH,SAAgB,kBAAkB;QAC9B,OAAO,+BAAkB,CAAC,OAAO,CAAC,CAAC,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;IAClE,CAAC;IAFe,+BAAkB,qBAEjC,CAAA;AACL,CAAC,EA9PgB,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QA8P5B","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 typeid strings\n */\n\n// @ts-ignore\nimport { constants } from \"@fluid-experimental/property-common\";\nimport { TemplateSchema as templateSchemaJson, NativeTypes } from \"../templateSchema\";\n\nconst { MSG } = constants;\n\nexport declare interface ExtractedVersion {\n version: string;\n typeidWithoutVersion: string;\n}\n\nexport declare interface ExtractedContext {\n typeid: string;\n context: string;\n isEnum: boolean;\n}\n\n/**\n * Helper for Type IDs\n * @public\n * @description Helper functions to work with typeid strings\n */\nexport namespace TypeIdHelper {\n /**\n * Checks whether the given type is a primitive type.\n *\n * @param in_typeid - The typeid we want to check\n * @returns Is this a base type?\n */\n export function isPrimitiveType(in_typeid: string): boolean {\n const primitiveTypes = templateSchemaJson[\"$defs\"][\"primitive-typeid\"][\"enum\"];\n\n if (in_typeid === undefined || in_typeid === \"\") {\n return false;\n }\n\n return in_typeid.substr(0, 5) === \"enum<\" ||\n in_typeid.substr(0, 10) === \"Reference<\" ||\n primitiveTypes.indexOf(in_typeid) >= 0;\n }\n\n /**\n * Checks whether the given type is a template typeid.\n *\n * @param in_typeid - The typeid we want to check\n * @returns Is this a base template typeid?\n */\n export function isTemplateTypeid(in_typeid: string): boolean {\n return in_typeid.indexOf(\":\") !== -1;\n }\n\n /**\n * Checks whether the given type is a reserved type.\n *\n * @param in_typeid - The typeid we want to check\n * @returns Is this a reserved type?\n */\n export function isReservedType(in_typeid: string): boolean {\n const reservedTypes = templateSchemaJson[\"$defs\"][\"reserved-typeid\"][\"enum\"];\n return reservedTypes.indexOf(in_typeid) >= 0;\n }\n\n /**\n * Extract the version number from the given typeid\n * @param in_typeid The typeid to check against\n * @returns Extracted version\n */\n export function extractVersion(in_typeid): ExtractedVersion {\n if (!in_typeid) {\n throw new Error(MSG.TYPEID_NOT_DEFINED);\n }\n const splitTypeId = in_typeid.split(\"-\");\n\n return {\n version: splitTypeId[1],\n typeidWithoutVersion: splitTypeId[0],\n };\n }\n\n /**\n * Extracts the context from a typeid\n *\n * @param in_typeid - The typeid to process\n * @returns Returns the typeid without context, the context and if we have an enum type\n */\n export function extractContext(in_typeid: string | undefined): ExtractedContext {\n const bracketIndex = in_typeid.indexOf(\"<\");\n if (bracketIndex !== -1 &&\n in_typeid[in_typeid.length - 1] === \">\") {\n let typeid = in_typeid.substr(bracketIndex + 1, in_typeid.length - bracketIndex - 2);\n let context = in_typeid.substr(0, bracketIndex);\n\n // Special case to handle collections without a typeid (e.g. \"map<>\", which should\n // be able to support all property types\n if (typeid === \"\") {\n typeid = context !== \"set\" ? \"BaseProperty\" : \"NamedProperty\";\n }\n\n // Special case to handle enums (e.g. array<enum<myType>>)\n let isEnum = false;\n if (context === \"enum\" || typeid.substr(0, 5) === \"enum<\") {\n isEnum = true;\n if (context === \"enum\") {\n context = \"single\";\n } else {\n // remove the `enum<...>` tag to get the raw typeid\n typeid = typeid.substr(5, typeid.length - 6);\n }\n }\n if (context === \"Reference\") {\n typeid = `Reference<${typeid}>`;\n context = \"single\";\n }\n\n return {\n typeid,\n context,\n isEnum,\n };\n } else {\n return {\n typeid: in_typeid,\n context: \"single\",\n isEnum: false,\n };\n }\n }\n\n /**\n * Creates a collection typeid string from the\n * typeid and the context.\n *\n * @param in_typeid - the typeid in the collection\n * @param in_context - the context\n * @param in_enum - set to true, if the type should get an enum tag\n *\n * @returns The combined typeid string\n */\n export function createSerializationTypeId(in_typeid: string, in_context: string, in_enum: boolean): string { // in_enum\n if (in_typeid === \"BaseProperty\") {\n // Special case for BaseProperties. These get represented as a collection\n // typeid without a child typeid. E.g. map<> instead of map<BaseProperty>\n return `${in_context}<>`;\n } else {\n if (in_enum) {\n if (in_context === \"\" || in_context === \"single\") {\n return `enum<${in_typeid}>`;\n } else {\n return `${in_context}<enum<${in_typeid}>>`;\n }\n } else {\n return `${in_context}<${in_typeid}>`;\n }\n }\n }\n\n /**\n * Checks, whether the supplied typeid is a reference property type id\n *\n * @param in_typeid - The typeid to check\n * @returns Is this a reference property typeid?\n */\n export function isReferenceTypeId(in_typeid: string | undefined): boolean { // in_enum\n return in_typeid === \"Reference\" ||\n (in_typeid.substr(0, 10) === \"Reference<\" && in_typeid.substr(-1) === \">\");\n }\n\n /**\n * Returns the type of the properties a reference points to\n *\n * @param in_typeid - The typeid to process\n * @return The type of the referenced property\n */\n export function extractReferenceTargetTypeIdFromReference(in_typeid: string): string { // in_enum\n if (in_typeid.substr(0, 10) === \"Reference<\") {\n // Extract the type from the TypeID\n return in_typeid.substr(10, in_typeid.length - 11);\n } else {\n // This is a typeless reference, we allow all types\n return \"BaseProperty\";\n }\n }\n\n /**\n * Checks whether the given type is a template typeid.\n *\n * @param in_typeid - The typeid we want to check\n * @returns Is this a base template typeid?\n */\n export function isSchemaTypeid(in_typeid: string): boolean {\n return typeof in_typeid === \"string\" && (in_typeid.indexOf(\":\") !== -1);\n }\n\n /**\n * Extracts referenced typeid from input typeid\n *\n * @param in_typeid typeid\n *\n * @return referenced typeid or in_param if it is not a reference\n */\n export function extractTypeId(in_typeid): string {\n const matches = in_typeid.match(/\\<(.*?)\\>/);\n if (matches !== null && matches.length > 0) {\n return matches[0].replace(/[\\<\\>]/gi, \"\");\n } else {\n return in_typeid;\n }\n }\n\n /**\n * Check wether the in_typeid inherits from the in_baseTypeid\n *\n * Note: By default, this also returns true if in_typeid === in_baseTypeid.\n *\n * @param in_typeid - Typeid for which we want to check, whethwe in_baseTypeid is a parent\n * @param in_baseTypeid - The base typeId to check for\n * @throws if in_typeid or in_baseTypeid are not native typeid\n * @returns True if in_baseTypeid is a parent of in_typeid\n */\n export function nativeInheritsFrom(in_typeid: string, in_baseTypeid: string): boolean {\n if (!in_typeid || !in_baseTypeid) {\n throw new Error(MSG.TYPEID_NOT_DEFINED);\n }\n\n if (in_typeid.substr(0, 10) === \"Reference<\") {\n in_typeid = \"Reference\";\n }\n\n if (in_baseTypeid.substr(0, 10) === \"Reference<\") {\n in_baseTypeid = \"Reference\";\n }\n\n if (!NativeTypes[in_typeid]) {\n throw new Error(MSG.TYPEID_NOT_NATIVE + in_typeid);\n }\n\n if (!NativeTypes[in_baseTypeid]) {\n throw new Error(MSG.TYPEID_NOT_NATIVE + in_baseTypeid);\n }\n\n if (in_baseTypeid === \"BaseProperty\" || in_typeid === in_baseTypeid) {\n return true;\n }\n\n if (in_typeid === \"BaseProperty\") {\n return false;\n }\n\n let parents = NativeTypes[in_typeid][\"inherits\"];\n\n // recursively call the function for the parent of the typeid\n for (let i = 0; i < parents.length; i++) {\n if (this.nativeInheritsFrom(parents[i], in_baseTypeid)) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * return all primitive typeIds\n *\n * @returns return a list of primitiveTypeIds\n */\n export function getPrimitiveTypeIds(): string[] {\n return templateSchemaJson[\"$defs\"][\"primitive-typeid\"][\"enum\"];\n }\n\n /**\n * return all reserved typeIds\n *\n * @returns return a list of reservedTypeIds\n */\n export function getReservedTypeIds(): string[] {\n return templateSchemaJson[\"$defs\"][\"reserved-typeid\"][\"enum\"];\n }\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -11,5 +11,5 @@ import { TemplateSchema } from "./templateSchema";
|
|
|
11
11
|
import { TemplateValidator } from "./templateValidator";
|
|
12
12
|
import { Utils } from "./utils";
|
|
13
13
|
declare const TraversalContext: typeof Utils.TraversalContext;
|
|
14
|
-
export { TemplateSchema, TemplateValidator, TypeIdHelper, ChangeSet, Utils, PathHelper, ArrayChangeSetIterator, rebaseToRemoteChanges, SerializedChangeSet, TraversalContext, ExtractedContext };
|
|
14
|
+
export { TemplateSchema, TemplateValidator, TypeIdHelper, ChangeSet, Utils, PathHelper, ArrayChangeSetIterator, rebaseToRemoteChanges, SerializedChangeSet, TraversalContext, ExtractedContext, };
|
|
15
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MA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sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,GACnB,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,2CAA6D;AAezD,0FAfK,qBAAS,OAeL;AAdb,0FAAuF;AAiBnF,uGAjBK,+CAAsB,OAiBL;AAhB1B,yDAAwE;AAYpE,6FAZuB,2BAAY,OAYvB;AAXhB,6CAA0C;AActC,2FAdK,uBAAU,OAcL;AAbd,qCAAiD;AAe7C,sGAfK,8BAAqB,OAeL;AAdzB,qDAAkD;AAO9C,+FAPK,+BAAc,OAOL;AANlB,2DAAwD;AAOpD,kGAPK,qCAAiB,OAOL;AANrB,mCAA+B;AAS3B,sFATK,aAAK,OASL;AAPT,MAAM,EAAE,gBAAgB,EAAE,GAAG,aAAK,CAAC;AAY/B,4CAAgB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { ChangeSet, SerializedChangeSet } from \"./changeset\";\nimport { ArrayChangeSetIterator } from \"./changeset_operations/arrayChangesetIterator\";\nimport { ExtractedContext, TypeIdHelper } from \"./helpers/typeidHelper\";\nimport { PathHelper } from \"./pathHelper\";\nimport { rebaseToRemoteChanges } from \"./rebase\";\nimport { TemplateSchema } from \"./templateSchema\";\nimport { TemplateValidator } from \"./templateValidator\";\nimport { Utils} from \"./utils\";\n\nconst { TraversalContext } = Utils;\n\nexport {\n TemplateSchema,\n TemplateValidator,\n TypeIdHelper,\n ChangeSet,\n Utils,\n PathHelper,\n ArrayChangeSetIterator,\n rebaseToRemoteChanges,\n SerializedChangeSet,\n TraversalContext,\n ExtractedContext
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,2CAA6D;AAezD,0FAfK,qBAAS,OAeL;AAdb,0FAAuF;AAiBnF,uGAjBK,+CAAsB,OAiBL;AAhB1B,yDAAwE;AAYpE,6FAZuB,2BAAY,OAYvB;AAXhB,6CAA0C;AActC,2FAdK,uBAAU,OAcL;AAbd,qCAAiD;AAe7C,sGAfK,8BAAqB,OAeL;AAdzB,qDAAkD;AAO9C,+FAPK,+BAAc,OAOL;AANlB,2DAAwD;AAOpD,kGAPK,qCAAiB,OAOL;AANrB,mCAA+B;AAS3B,sFATK,aAAK,OASL;AAPT,MAAM,EAAE,gBAAgB,EAAE,GAAG,aAAK,CAAC;AAY/B,4CAAgB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { ChangeSet, SerializedChangeSet } from \"./changeset\";\nimport { ArrayChangeSetIterator } from \"./changeset_operations/arrayChangesetIterator\";\nimport { ExtractedContext, TypeIdHelper } from \"./helpers/typeidHelper\";\nimport { PathHelper } from \"./pathHelper\";\nimport { rebaseToRemoteChanges } from \"./rebase\";\nimport { TemplateSchema } from \"./templateSchema\";\nimport { TemplateValidator } from \"./templateValidator\";\nimport { Utils} from \"./utils\";\n\nconst { TraversalContext } = Utils;\n\nexport {\n TemplateSchema,\n TemplateValidator,\n TypeIdHelper,\n ChangeSet,\n Utils,\n PathHelper,\n ArrayChangeSetIterator,\n rebaseToRemoteChanges,\n SerializedChangeSet,\n TraversalContext,\n ExtractedContext,\n};\n"]}
|
package/dist/pathHelper.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export declare namespace PathHelper {
|
|
|
33
33
|
*
|
|
34
34
|
* @returns the tokens from the path string
|
|
35
35
|
*/
|
|
36
|
-
export const tokenizePathString: (in_path: string, out_types?: TOKEN_TYPES[]) =>
|
|
36
|
+
export const tokenizePathString: (in_path: string, out_types?: TOKEN_TYPES[]) => string[];
|
|
37
37
|
/**
|
|
38
38
|
* Creates a quoted string for a path seqment to make sure it parses correctly
|
|
39
39
|
*
|
|
@@ -105,7 +105,7 @@ export declare namespace PathHelper {
|
|
|
105
105
|
* @returns The coverage of the property and its children. For a coverage of
|
|
106
106
|
* 'FULLY_COVERED', only the first matching path is returned.
|
|
107
107
|
*/
|
|
108
|
-
export const getPathCoverage: (in_basePath: string, in_paths:
|
|
108
|
+
export const getPathCoverage: (in_basePath: string, in_paths: string[]) => BasePathCoverage;
|
|
109
109
|
export {};
|
|
110
110
|
}
|
|
111
111
|
//# sourceMappingURL=pathHelper.d.ts.map
|
package/dist/pathHelper.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pathHelper.d.ts","sourceRoot":"","sources":["../src/pathHelper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH;;GAEG;AAOH,oBAAY,QAAQ,GAAG,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"pathHelper.d.ts","sourceRoot":"","sources":["../src/pathHelper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH;;GAEG;AAOH,oBAAY,QAAQ,GAAG,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAE7C;;GAEG;AACH,yBAAiB,UAAU,CAAC;IAIxB;;;OAGG;IACH,MAAM,MAAM,WAAW;QACnB,6CAA6C;QAC7C,kBAAkB,IAAA;QAClB,+CAA+C;QAC/C,WAAW,IAAA;QACX,uCAAuC;QACvC,eAAe,IAAA;QACf,mDAAmD,CACnD,iBAAiB,IAAA;QACjB,2DAA2D;QAC3D,iBAAiB,IAAA;KACpB;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,MAAM,kBAAkB,YAAqB,MAAM,cAAc,WAAW,EAAE,KAAG,MAAM,EAqQ7F,CAAC;IAEF;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,gBAAgB,mBAA4B,MAAM,KAAG,MAYjE,CAAC;IAEF;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,kBAAkB,yBAAkC,MAAM,KAAG,MAiBzE,CAAC;IAEF;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,wBAAwB,mBAA4B,MAAM,KAAG,MAazE,CAAC;IAEF;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,gCAAgC,YAAqB,MAAM,SAKvE,CAAC;IAEF;;;;;;;OAOG;IACH,MAAM,CAAC,MAAM,8BAA8B,oBAA6B,MAAM,KAAG,MA2BhF,CAAC;IAEF;;;;;;;;OAQG;IACH,MAAM,CAAC,MAAM,6BAA6B,mCAA4C,MAAM,cAAc,MAAM,KAAG,MAOlH,CAAC;IAEF,MAAM,MAAM,cAAc;QAGtB,SAAS,IAAA;QAGT,cAAc,IAAA;QAGd,aAAa,IAAA;KAChB;IAED,UAAU,gBAAgB;QACtB,cAAc,EAAE,cAAc,CAAC;QAC/B,QAAQ,EAAE,MAAM,EAAE,CAAC;KACtB;IAED;;;;;;;;;;OAUG;IACH,MAAM,CAAC,MAAM,eAAe,gBAAyB,MAAM,YAAY,MAAM,EAAE,KAAG,gBA+BjF,CAAC;;CACL"}
|
package/dist/pathHelper.js
CHANGED
|
@@ -34,7 +34,6 @@ var PathHelper;
|
|
|
34
34
|
/** A ../ that indicates one step above the current path */
|
|
35
35
|
TOKEN_TYPES[TOKEN_TYPES["RAISE_LEVEL_TOKEN"] = 4] = "RAISE_LEVEL_TOKEN";
|
|
36
36
|
})(TOKEN_TYPES = PathHelper.TOKEN_TYPES || (PathHelper.TOKEN_TYPES = {}));
|
|
37
|
-
;
|
|
38
37
|
/**
|
|
39
38
|
* Tokenizes a path string
|
|
40
39
|
*
|
|
@@ -446,7 +445,6 @@ var PathHelper;
|
|
|
446
445
|
// This means a property with this path would be covered and all of its children would be covered also.
|
|
447
446
|
CoverageExtent[CoverageExtent["FULLY_COVERED"] = 2] = "FULLY_COVERED";
|
|
448
447
|
})(CoverageExtent = PathHelper.CoverageExtent || (PathHelper.CoverageExtent = {}));
|
|
449
|
-
;
|
|
450
448
|
/**
|
|
451
449
|
* Determines if the base path is covered by the given list of paths. From that you can deduce if a
|
|
452
450
|
* property with that path and all its children are covered by the given list of paths.
|
package/dist/pathHelper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pathHelper.js","sourceRoot":"","sources":["../src/pathHelper.ts"],"names":[],"mappings":";AAAA;;;GAGG;AACH;;GAEG;;;AAEH,aAAa;AACb,yEAAgE;AAEhE,MAAM,EAAE,uBAAuB,EAAE,GAAG,EAAE,GAAG,2BAAS,CAAC;AAInD;;GAEG;AACH,IAAiB,UAAU,CA0e1B;AA1eD,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;IAAA,CAAC;IAEF;;;;;;;OAOG;IACU,6BAAkB,GAAG,UAAS,OAAe,EAAE,SAAyB;QACjF,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,IAAI,YAAY,GAAG,EAAE,CAAC;QAEtB,IAAI,SAAS,EAAE;YACX,+BAA+B;YAC/B,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;SACzC;QAED,2EAA2E;QAC3E,IAAI,UAAU,GAAG,CAAC,CAAC;QACnB,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;YACpB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACjB,IAAI,SAAS,EAAE;gBACX,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC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E,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACtC,IAAI,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE;gBACrC,OAAO;oBACH,cAAc,EAAE,cAAc,CAAC,aAAa;oBAC5C,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;iBAC1B,CAAC;aACL;SACJ;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;YACtC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;gBACrC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;aAC3B;SACJ;QACD,IAAI,KAAK,CAAC,MAAM,EAAE;YACd,+DAA+D;YAC/D,OAAO;gBACH,cAAc,EAAE,cAAc,CAAC,cAAc;gBAC7C,QAAQ,EAAE,KAAK;aAClB,CAAC;SACL;QAED,yDAAyD;QACzD,OAAO;YACH,cAAc,EAAE,cAAc,CAAC,SAAS;YACxC,QAAQ,EAAE,KAAK;SAClB,CAAC;IACN,CAAC,CAAC;AACN,CAAC,EA1egB,UAAU,GAAV,kBAAU,KAAV,kBAAU,QA0e1B","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 */\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[]): Array<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 if (character === PROPERTY_PATH_DELIMITER) {\n // A dot symbols starts a new token\n storeNextToken(TOKEN_TYPES.PATH_SEGMENT_TOKEN);\n\n allowSegmentStart = true;\n } else if (character === \"[\") {\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 } else if (character === \"]\") {\n throw new Error(MSG.CLOSING_BRACKET_WITHOUT_OPENING + in_path);\n } else if (character === \"*\") {\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 } else {\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 } 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 Error(`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 if (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) {\n return quotePathSegment(in_pathSegment);\n } else {\n return in_pathSegment;\n }\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 if (in_parentAbsolutePathCanonical) {\n return (in_parentAbsolutePathCanonical + PROPERTY_PATH_DELIMITER + childPath);\n } else {\n return childPath;\n }\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: Array<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,yEAAgE;AAEhE,MAAM,EAAE,uBAAuB,EAAE,GAAG,EAAE,GAAG,2BAAS,CAAC;AAInD;;GAEG;AACH,IAAiB,UAAU,CA0e1B;AA1eD,WAAiB,UAAU;IAEvB,MAAM,2BAA2B,GAAG,IAAI,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAE3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CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;gBACrC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;aAC3B;SACJ;QACD,IAAI,KAAK,CAAC,MAAM,EAAE;YACd,+DAA+D;YAC/D,OAAO;gBACH,cAAc,EAAE,cAAc,CAAC,cAAc;gBAC7C,QAAQ,EAAE,KAAK;aAClB,CAAC;SACL;QAED,yDAAyD;QACzD,OAAO;YACH,cAAc,EAAE,cAAc,CAAC,SAAS;YACxC,QAAQ,EAAE,KAAK;SAClB,CAAC;IACN,CAAC,CAAC;AACN,CAAC,EA1egB,UAAU,GAAV,kBAAU,KAAV,kBAAU,QA0e1B","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 */\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 if (character === PROPERTY_PATH_DELIMITER) {\n // A dot symbols starts a new token\n storeNextToken(TOKEN_TYPES.PATH_SEGMENT_TOKEN);\n\n allowSegmentStart = true;\n } else if (character === \"[\") {\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 } else if (character === \"]\") {\n throw new Error(MSG.CLOSING_BRACKET_WITHOUT_OPENING + in_path);\n } else if (character === \"*\") {\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 } else {\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 } 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 Error(`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 if (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) {\n return quotePathSegment(in_pathSegment);\n } else {\n return in_pathSegment;\n }\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 if (in_parentAbsolutePathCanonical) {\n return (in_parentAbsolutePathCanonical + PROPERTY_PATH_DELIMITER + childPath);\n } else {\n return childPath;\n }\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"]}
|
package/dist/rebase.js
CHANGED
|
@@ -25,7 +25,6 @@ class SyncPromise {
|
|
|
25
25
|
this.value = new SyncPromise(fn(this.value)).value;
|
|
26
26
|
return this;
|
|
27
27
|
}
|
|
28
|
-
;
|
|
29
28
|
}
|
|
30
29
|
const loop = (promise, fn, makePromise) => promise.then(fn).then((result) => result === null ? result : loop(makePromise(result), fn, makePromise));
|
|
31
30
|
function rebaseToRemoteChanges(change, getUnrebasedChange, getRebasedChanges, isAsync = false) {
|
package/dist/rebase.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rebase.js","sourceRoot":"","sources":["../src/rebase.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,yDAAoD;AACpD,6DAAqC;AAErC,2CAAwC;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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C,mBAAmB,CAAC,CAAC;QACpD,eAAe,CAAC,cAAc,CAAC,MAAM,CAAC,SAAS,EAAE;YAC7C,yBAAyB,EAAE,MAAM,CAAC,qBAAqB;SAC1D,CAAC,CAAC;QACH,mBAAmB,GAAG,eAAe,CAAC;KACzC;AACL,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,yDAAoD;AACpD,6DAAqC;AAErC,2CAAwC;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,MAAM,IAAI,GAAG,CAAC,OAAqB,EAAE,EAAoE,EAAE,WAA+B,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,IAAI,CA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cAAc,CAAC;oBACrC,yBAAyB,CAAC,KAAK,EAAE,CAAC;iBACrC;gBAED,mBAAmB,CAAC,cAAc,CAAC,SAAS,EAAE;oBAC1C,yBAAyB;iBAC5B,CAAC,CAAC;aACN;SACJ;QAED,MAAM,CAAC,qBAAqB,GAAG,IAAI,GAAG,EAAE,CAAC;QACzC,mBAAmB,CAAC,gBAAgB,CAAC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE;YAC9D,yBAAyB,EAAE,MAAM,CAAC,qBAAqB;SAC1D,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACX,CAAC;AAjJD,sDAiJC;AAED,SAAS,kBAAkB,CAAC,aAAa,EAAE,eAAe;IACtD,IAAI,mBAAmB,GAAG,aAAa,CAAC;IACxC,KAAK,MAAM,MAAM,IAAI,eAAe,EAAE;QAClC,MAAM,eAAe,GAAG,IAAI,qBAAS,CAAC,wBAAS,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;YAC9D,yBAAyB,EAAE,MAAM,CAAC,qBAAqB;SAC1D,CAAC,CAAC;QAEH,eAAe,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC;QACpD,eAAe,CAAC,cAAc,CAAC,MAAM,CAAC,SAAS,EAAE;YAC7C,yBAAyB,EAAE,MAAM,CAAC,qBAAqB;SAC1D,CAAC,CAAC;QACH,mBAAmB,GAAG,eAAe,CAAC;KACzC;AACL,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"]}
|
|
@@ -62,15 +62,15 @@ export interface TemplateValidatorOptions {
|
|
|
62
62
|
*/
|
|
63
63
|
export declare class TemplateValidator {
|
|
64
64
|
static Utils: {
|
|
65
|
-
psetDeepEquals
|
|
65
|
+
psetDeepEquals(in_source: PropertySchema, in_target: PropertySchema): any;
|
|
66
66
|
};
|
|
67
67
|
private _resultBuilder;
|
|
68
68
|
_inheritsFrom: (source: PropertySchema, target: PropertySchema) => boolean;
|
|
69
69
|
_hasSchema: (schema: PropertySchema, typeid: string) => boolean;
|
|
70
70
|
_inheritsFromAsync: (source: PropertySchema, target: PropertySchema) => Promise<boolean>;
|
|
71
71
|
_hasSchemaAsync: (schema: PropertySchema, typeid: string) => Promise<boolean>;
|
|
72
|
-
private _allowDraft;
|
|
73
|
-
private _skipSemver;
|
|
72
|
+
private readonly _allowDraft;
|
|
73
|
+
private readonly _skipSemver;
|
|
74
74
|
constructor(in_params?: TemplateValidatorOptions);
|
|
75
75
|
/**
|
|
76
76
|
* Validates that all templates conform to the following mandatory rules:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templateValidator.d.ts","sourceRoot":"","sources":["../src/templateValidator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH;;;;GAIG;AA4BH,OAAO,EAAE,sBAAsB,EAA2B,MAAM,2BAA2B,CAAC;AAc5F,aAAK,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"templateValidator.d.ts","sourceRoot":"","sources":["../src/templateValidator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH;;;;GAIG;AA4BH,OAAO,EAAE,sBAAsB,EAA2B,MAAM,2BAA2B,CAAC;AAc5F,aAAK,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,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0B;IACzC,aAAa,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,KAAK,OAAO,CAAC;IAC3E,UAAU,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;IAChE,kBAAkB,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACzF,eAAe,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACrF,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAU;IACtC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAU;gBAC1B,SAAS,GAAE,wBAAkE;IAezF;;;;;;;;;;;;;;;;;;;;;GAqBD;IACC,QAAQ,CAAC,WAAW,EAAE,cAAc,EAAE,mBAAmB,CAAC,EAAE,cAAc,GAAG,sBAAsB;IAiFnG;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,aAAa,CAAC,WAAW,EAAE,cAAc,EAAE,mBAAmB,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAcvH;;;;;;;;OAQG;YACW,gCAAgC;CAwCjD"}
|
|
@@ -32,7 +32,7 @@ const fastest_json_copy_1 = require("fastest-json-copy");
|
|
|
32
32
|
const semver_1 = require("semver");
|
|
33
33
|
const traverse_1 = __importDefault(require("traverse"));
|
|
34
34
|
const async_1 = require("async");
|
|
35
|
-
|
|
35
|
+
// @ts-ignore
|
|
36
36
|
const property_common_1 = require("@fluid-experimental/property-common");
|
|
37
37
|
const templateSchema_1 = require("./templateSchema");
|
|
38
38
|
const typeidHelper_1 = require("./helpers/typeidHelper");
|
|
@@ -40,7 +40,7 @@ const validationResultBuilder_1 = require("./validationResultBuilder");
|
|
|
40
40
|
const { MSG } = property_common_1.constants;
|
|
41
41
|
const ajvFactory = new ajv_1.default({
|
|
42
42
|
allErrors: true,
|
|
43
|
-
verbose: true
|
|
43
|
+
verbose: true,
|
|
44
44
|
});
|
|
45
45
|
ajv_keywords_1.default(ajvFactory, "prohibited");
|
|
46
46
|
ajv_keywords_1.default(ajvFactory, "typeof");
|
|
@@ -479,7 +479,7 @@ const _validateSemanticAndSyntax = function (in_template) {
|
|
|
479
479
|
* @return {Promise} a promise that resolved to nothing
|
|
480
480
|
* @ignore
|
|
481
481
|
*/
|
|
482
|
-
const _validateSemanticAndSyntaxAsync = function (in_template) {
|
|
482
|
+
const _validateSemanticAndSyntaxAsync = async function (in_template) {
|
|
483
483
|
return _validateSyntaxAsync.call(this, in_template);
|
|
484
484
|
};
|
|
485
485
|
/**
|
|
@@ -557,7 +557,7 @@ const _validateContext = function (in_template) {
|
|
|
557
557
|
* @return {Promise} promise that returns without any value and rejects in case of validation error
|
|
558
558
|
* @ignore
|
|
559
559
|
*/
|
|
560
|
-
const _validateContextAsync = function (in_template) {
|
|
560
|
+
const _validateContextAsync = async function (in_template) {
|
|
561
561
|
const that = this;
|
|
562
562
|
const context = in_template.context;
|
|
563
563
|
const error = getInvalidContextError(context);
|
|
@@ -604,7 +604,7 @@ const _validateContextAsync = function (in_template) {
|
|
|
604
604
|
return Promise.reject(new Error(MSG.SET_ONLY_NAMED_PROPS));
|
|
605
605
|
}
|
|
606
606
|
return that._inheritsFromAsync(in_template.typeid, "NamedProperty");
|
|
607
|
-
}).then(function (res) {
|
|
607
|
+
}).then(async function (res) {
|
|
608
608
|
if (res) {
|
|
609
609
|
return undefined;
|
|
610
610
|
}
|
|
@@ -751,7 +751,7 @@ const createContextCheckAsyncQueue = function () {
|
|
|
751
751
|
* @returns Promise that resolves without any result
|
|
752
752
|
* @ignore
|
|
753
753
|
*/
|
|
754
|
-
let _validateSyntaxAsync = function (in_template) {
|
|
754
|
+
let _validateSyntaxAsync = async function (in_template) {
|
|
755
755
|
const that = this;
|
|
756
756
|
return new Promise(function (resolve, reject) {
|
|
757
757
|
if (that.asyncValidationInProgress === true) {
|
|
@@ -786,9 +786,9 @@ let _validateSyntaxAsync = function (in_template) {
|
|
|
786
786
|
});
|
|
787
787
|
};
|
|
788
788
|
const Utils = {
|
|
789
|
-
psetDeepEquals
|
|
789
|
+
psetDeepEquals(in_source, in_target) {
|
|
790
790
|
return _psetDeepEquals.call(this, in_source, in_target).isEqual;
|
|
791
|
-
}
|
|
791
|
+
},
|
|
792
792
|
};
|
|
793
793
|
/**
|
|
794
794
|
* @description Instantiates a new TemplateValidator. Must be provided with a set of inheritsFrom and hasSchema
|
|
@@ -899,7 +899,6 @@ class TemplateValidator {
|
|
|
899
899
|
}
|
|
900
900
|
return this._resultBuilder.result;
|
|
901
901
|
}
|
|
902
|
-
;
|
|
903
902
|
/**
|
|
904
903
|
* Validates that all templates conform to the following mandatory rules:
|
|
905
904
|
* 1. Must have a typeid attribute.
|
|
@@ -922,7 +921,7 @@ class TemplateValidator {
|
|
|
922
921
|
* }
|
|
923
922
|
* It's possible for 'isValid' to be true while 'warnings' contains one or more messages.
|
|
924
923
|
*/
|
|
925
|
-
validateAsync(in_template, in_templatePrevious) {
|
|
924
|
+
async validateAsync(in_template, in_templatePrevious) {
|
|
926
925
|
this._resultBuilder = new validationResultBuilder_1.ValidationResultBuilder(in_template ? in_template.typeid : "");
|
|
927
926
|
_validateBasic.call(this, in_template);
|
|
928
927
|
if (in_templatePrevious) {
|
|
@@ -935,7 +934,6 @@ class TemplateValidator {
|
|
|
935
934
|
this._validateAsyncWithPreviousSchema(in_template, in_templatePrevious) :
|
|
936
935
|
_validateSemanticAndSyntaxAsync.call(this, in_template);
|
|
937
936
|
}
|
|
938
|
-
;
|
|
939
937
|
/**
|
|
940
938
|
* Called by validateAsync if a previous schema is passed in argument
|
|
941
939
|
*
|
|
@@ -945,7 +943,7 @@ class TemplateValidator {
|
|
|
945
943
|
* @returns promise that resolves to the validation results as an objet. See validateAsync
|
|
946
944
|
* @ignore
|
|
947
945
|
*/
|
|
948
|
-
_validateAsyncWithPreviousSchema(in_template, in_templatePrevious) {
|
|
946
|
+
async _validateAsyncWithPreviousSchema(in_template, in_templatePrevious) {
|
|
949
947
|
const that = this;
|
|
950
948
|
return _validateSemanticAndSyntaxAsync.call(that, in_template).then(() => _validateSemanticAndSyntaxAsync.call(that, in_templatePrevious)).then(function () {
|
|
951
949
|
if (!that._resultBuilder.isValid()) {
|