@fluid-experimental/property-changeset 2.0.0-internal.2.2.0 → 2.0.0-internal.2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/templateValidator.d.ts +0 -5
- package/dist/templateValidator.d.ts.map +1 -1
- package/dist/templateValidator.js +5 -6
- package/dist/templateValidator.js.map +1 -1
- package/dist/test/array.spec.js +1 -2
- package/dist/test/array.spec.js.map +1 -1
- package/dist/test/tsconfig.tsbuildinfo +1 -1
- package/dist/test/validator/templateValidator.spec.js +1 -3
- package/dist/test/validator/templateValidator.spec.js.map +1 -1
- package/dist/test/validator/typeidHelper.spec.js +1 -4
- package/dist/test/validator/typeidHelper.spec.js.map +1 -1
- package/lib/templateValidator.js +0 -1
- package/lib/templateValidator.js.map +1 -1
- package/package.json +3 -3
|
@@ -2,11 +2,6 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
/**
|
|
6
|
-
* @fileoverview
|
|
7
|
-
* @description The TemplateValidator can examine consecutive versions of a given template to detect semantic
|
|
8
|
-
* versioning (semver) errors and warn about incorrect versioning practices.
|
|
9
|
-
*/
|
|
10
5
|
import { SchemaValidationResult } from "./validationResultBuilder";
|
|
11
6
|
declare type ValuesType = {
|
|
12
7
|
[key: string]: ValuesType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templateValidator.d.ts","sourceRoot":"","sources":["../src/templateValidator.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"templateValidator.d.ts","sourceRoot":"","sources":["../src/templateValidator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAiCH,OAAO,EAAE,sBAAsB,EAA2B,MAAM,2BAA2B,CAAC;AAc5F,aAAK,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC;CAAE,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AM,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,wBAAmE;IAe9F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqCG;IACC,QAAQ,CAAC,WAAW,EAAE,cAAc,EAAE,mBAAmB,CAAC,EAAE,cAAc,GAAG,sBAAsB;IAiFnG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqCG;IACG,aAAa,CAAC,WAAW,EAAE,cAAc,EAAE,mBAAmB,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAcvH;;;;;;;;OAQG;YACW,gCAAgC;CAwCjD"}
|
|
@@ -3,17 +3,16 @@
|
|
|
3
3
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
/**
|
|
7
|
-
* @fileoverview
|
|
8
|
-
* @description The TemplateValidator can examine consecutive versions of a given template to detect semantic
|
|
9
|
-
* versioning (semver) errors and warn about incorrect versioning practices.
|
|
10
|
-
*/
|
|
11
|
-
/* eslint-disable no-use-before-define */
|
|
12
6
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
7
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
8
|
};
|
|
15
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
10
|
exports.TemplateValidator = void 0;
|
|
11
|
+
/**
|
|
12
|
+
* @fileoverview
|
|
13
|
+
* @description The TemplateValidator can examine consecutive versions of a given template to detect semantic
|
|
14
|
+
* versioning (semver) errors and warn about incorrect versioning practices.
|
|
15
|
+
*/
|
|
17
16
|
const ajv_1 = __importDefault(require("ajv"));
|
|
18
17
|
const ajv_keywords_1 = __importDefault(require("ajv-keywords"));
|
|
19
18
|
const each_1 = __importDefault(require("lodash/each"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templateValidator.js","sourceRoot":"","sources":["../src/templateValidator.ts"],"names":[],"mappings":";AAAA;;;GAGG;AACH;;;;GAIG;AACH,yCAAyC;;;;;;AAEzC,8CAAsB;AACtB,gEAAuC;AAEvC,uDAA+B;AAC/B,6DAAqC;AACrC,yDAAiC;AACjC,+DAAuC;AACvC,+DAAuC;AACvC,mEAA2C;AAC3C,qDAA6B;AAC7B,iEAAyC;AACzC,+DAAuC;AACvC,qDAA6B;AAC7B,uDAA+B;AAC/B,6DAAqC;AACrC,yDAAsD;AAEtD,mCAAyD;AACzD,wDAAgC;AAChC,iCAA8B;AAE9B,aAAa;AACb,yEAA8E;AAC9E,qDAAkD;AAClD,yDAAsD;AACtD,uEAA4F;AAE5F,MAAM,EAAE,GAAG,EAAE,GAAG,2BAAS,CAAC;AAE1B,MAAM,UAAU,GAAG,IAAI,aAAG,CAAC;IACvB,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,IAAI;CAChB,CAAC,CAAC;AAEH,IAAA,sBAAW,EAAC,UAAU,EAAE,YAAY,CAAC,CAAC;AACtC,IAAA,sBAAW,EAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AAElC,MAAM,gBAAgB,GAAG,UAAU,CAAC,OAAO,CAAC,+BAAc,CAAC,CAAC;AAyB5D;;;;;;GAMG;AACH,MAAM,YAAY,GAAG;IACjB,KAAK,EAAE,CAAC;IACR,KAAK,EAAE,CA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AClE;YAED,IAAI,IAAI,CAAC,WAAW,IAAI,mBAAmB,EAAE;gBACzC,mBAAmB,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,mBAAmB,CAAC,CAAC;aACpE;YAED,MAAM,OAAO,GAAG,qBAAqB,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;YAC9D,MAAM,eAAe,GAAG,mBAAmB,CAAC,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YAE3G,4CAA4C;YAC5C,QAAQ,IAAA,gBAAO,EAAC,OAAO,EAAE,eAAe,CAAC,EAAE;gBACvC,KAAK,CAAC;oBACF,oBAAoB,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,mBAAmB,CAAC,CAAC;oBAClE,MAAM;gBACV,KAAK,CAAC;oBACF,wBAAwB;oBACxB,0BAA0B,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,mBAAmB,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;oBAClG,MAAM;gBACV,QAAQ;gBACR,KAAK,CAAC,CAAC;oBACH,gDAAgD;oBAChD,IAAI,CAAC,cAAc,CAAC,QAAQ,CACxB,IAAI,KAAK,CAAC,GAAG,CAAC,oBAAoB,GAAG,IAAI,CAAC,SAAS,CAAC;wBAChD,OAAO,EAAE,OAAO;wBAChB,QAAQ,EAAE,eAAe;qBAC5B,CAAC,CAAC,CACN,CAAC;oBACF,MAAM;aACb;YAED,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC;QACtC,CAAC,CAAC,CAAC;IACP,CAAC;;AAnPL,8CAoPC;AAnPU,uBAAK,GAAG,KAAK,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/**\n * @fileoverview\n * @description The TemplateValidator can examine consecutive versions of a given template to detect semantic\n * versioning (semver) errors and warn about incorrect versioning practices.\n */\n/* eslint-disable no-use-before-define */\n\nimport Ajv from \"ajv\";\nimport ajvKeywords from \"ajv-keywords\";\n\nimport each from \"lodash/each\";\nimport isEqual from \"lodash/isEqual\";\nimport every from \"lodash/every\";\nimport isString from \"lodash/isString\";\nimport isObject from \"lodash/isObject\";\nimport difference from \"lodash/difference\";\nimport has from \"lodash/has\";\nimport mapValues from \"lodash/mapValues\";\nimport includes from \"lodash/includes\";\nimport map from \"lodash/map\";\nimport find from \"lodash/find\";\nimport isEmpty from \"lodash/isEmpty\";\nimport { copy as cloneDeep } from \"fastest-json-copy\";\n\nimport { gt, diff, major, valid, compare } from \"semver\";\nimport traverse from \"traverse\";\nimport { queue } from \"async\";\n\n// @ts-ignore\nimport { constants, ConsoleUtils } from \"@fluid-experimental/property-common\";\nimport { TemplateSchema } from \"./templateSchema\";\nimport { TypeIdHelper } from \"./helpers/typeidHelper\";\nimport { SchemaValidationResult, ValidationResultBuilder } from \"./validationResultBuilder\";\n\nconst { MSG } = constants;\n\nconst ajvFactory = new Ajv({\n allErrors: true,\n verbose: true,\n});\n\najvKeywords(ajvFactory, \"prohibited\");\najvKeywords(ajvFactory, \"typeof\");\n\nconst _syntaxValidator = ajvFactory.compile(TemplateSchema);\n\ntype ValuesType = { [key: string]: ValuesType; };\n\ntype PropertyType = {\n id: string;\n context: string;\n typeid: string;\n values: ValuesType;\n};\n\ntype PropertiesType = PropertyType[];\n\nexport interface PropertySchema {\n constants?: any[];\n context: string;\n inherits?: string[];\n annotation?: { [key: string]: string; };\n properties: PropertiesType;\n typeid: string;\n values: ValuesType;\n}\n\ntype SchemaEntityType = PropertySchema | string[] | PropertiesType;\n\n/**\n * A weighted enumeration of semver change types. Higher values are more important.\n * PATCH: Annotation and comment changes.\n * MINOR: Added properties.\n * MAJOR: Everything else, including deleting properties.\n * @ignore\n */\nconst CHANGE_LEVEL = {\n patch: 0, // '1.0.0' -> '1.0.1'\n minor: 1, // '1.0.0' -> '1.1.0'\n major: 2, // '1.5.2' -> '2.0.0'\n\n prerelease: 0, // '1.0.0-alpha.1' -> '1.0.0'\n prepatch: 0, // '1.0.0-alpha.1' -> '1.0.1'\n preminor: 1, // '1.0.0-alpha.1' -> '1.1.0'\n premajor: 2, // '1.0.0-alpha.1' -> '2.0.0'\n};\n\nconst VALID_CONTEXTS = [\"single\", \"array\", \"map\", \"set\", \"enum\"];\n\nconst _extractTypeid = function(typeidOrReference: string) {\n // Take Reference<strong-type-id> and return strong-type-id\n if (!isString(typeidOrReference)) {\n throw new Error(MSG.TYPEID_MUST_BE_STRING + typeidOrReference);\n }\n const reference = \"Reference<\";\n let result = typeidOrReference || \"\";\n const isReference = result.indexOf(reference) === 0;\n if (isReference) {\n result = typeidOrReference.substring(reference.length, typeidOrReference.length - 1);\n }\n return result;\n};\n\n/**\n * Given a typeid string, fetches the semver 'x.y.z' version string.\n * @param in_typeid - A PropertySet typeid. For example: 'TeamLeoValidation2:ColorID-1.0.0'.\n * @returns The semver 'x.y.z' version string, or null if in_typeid is not a valid PropertySet typeid.\n */\nconst _getSemverFromTypeId = function(in_typeid: string): string | null {\n const semverRegex = /.*-(.*)$/g;\n const match = semverRegex.exec(in_typeid);\n return match ? match[1] : null;\n};\n\n/**\n * Fetches the type name of a javascript entity.\n * @param in_obj - A javascript entity.\n * @returns The type name for in_obj.\n */\nconst _getType = (in_obj: any): string => Object.prototype.toString.call(in_obj).slice(8, -1);\n\ntype PathEqualityInfo = {\n isEqual: boolean;\n path: string;\n};\n\nfunction isPropertyArray(source: SchemaEntityType): source is PropertiesType {\n return every(source, (entry: PropertyType) => isObject(entry) && entry.id !== undefined);\n}\n\n// function isSchemaTemplate(source: SchemaEntityType): source is PropertySchema {\n// return isObject(source) && !Array.isArray(source);\n// }\n\n/**\n * An object deep compare with special handling for pset property arrays.\n * pset property arrays are allowed to be out of order as long as elements can be matched with\n * their id.\n * @param in_source - The source entity to test for deep equality.\n * @param in_target - The target entity to test for deep equality.\n * @returns {isEqual: false, path: 'foo.properties[1].x'}\n *\n * - isEqual: true if in_source and in_target property sets are equal, even if the individual property arrays\n * differ but contain the same out of order elements.\n *\n * - path: path to the property that is not equal.\n */\nconst _psetDeepEquals = function(in_source: SchemaEntityType, in_target: SchemaEntityType): PathEqualityInfo {\n const idPath = [];\n if (!Array.isArray(in_source) && in_source.typeid) {\n idPath.push(`<${in_source.typeid}>`);\n }\n\n /**\n * Create the _psetDeepEquals result.\n * @param isEqual - Whether or not a PropertySet result is being constructed for\n * PropertySets that are deeply equal.\n * @returns {{isEqual: boolean, path: string}} An object that indicates whether or not the source\n * and target PropertySets are deeply equal. If they're not, it also contains a path to the\n * property that is not equal.\n */\n const _getPSetDeepEqualsResult = (isEqual: boolean): PathEqualityInfo => ({\n isEqual,\n path: isEqual ? undefined : idPath.join(\"\"),\n });\n\n /**\n * Performs a recursive, depth first deep equal test against two PropertySets.\n * @param source - The source entity to test for deep equality.\n * @param target - The target entity to test for deep equality.\n * @param id - The current path element being compared.\n * @return The result of _getPSetDeepEqualsResult\n */\n let _depthFirstDeepEquals = function(source: SchemaEntityType, target: SchemaEntityType, id?: string): PathEqualityInfo {\n let result = _getPSetDeepEqualsResult(true);\n\n if (id) {\n if (typeof id === \"number\") {\n idPath.push(`[${id}]`);\n } else {\n idPath.push(`.${id}`);\n }\n }\n\n if (Array.isArray(source)) {\n if (!Array.isArray(target)) {\n return _getPSetDeepEqualsResult(false);\n }\n\n if (source.length !== target.length) {\n return _getPSetDeepEqualsResult(false);\n }\n\n if (source.length === 0) {\n return _getPSetDeepEqualsResult(true);\n }\n\n // See if we're comparing arrays of objects (like properties) or simple arrays of strings\n // like inheritance lists.\n if (isPropertyArray(source)) {\n const targetMap = {};\n each(target, function(element: PropertyType) {\n targetMap[element.id] = element;\n });\n\n for (let i = 0; i < source.length && result.isEqual; i++) {\n const sourceId = source[i].id;\n result = _depthFirstDeepEquals.call(this, source[i], targetMap[sourceId], sourceId);\n idPath.pop();\n }\n } else {\n // Element order matters\n for (let i = 0; i < source.length && result.isEqual; i++) {\n result = _depthFirstDeepEquals.call(this, source[i], target[i], i);\n idPath.pop();\n }\n }\n } else if (isObject(source)) {\n if (!isObject(target)) {\n return _getPSetDeepEqualsResult(false);\n }\n\n const keysSource = Object.keys(source);\n const keysTarget = Object.keys(target);\n if (keysSource.length !== keysTarget.length) {\n // A template with abstract properties must equal one with an empty properties array\n // We check the difference in keys between the source and target and if the only difference is the\n // properties array we check if it's empty. Then we reverse the condition so it work both ways.\n if (\n (isEqual(difference(keysTarget, keysSource), [\"properties\"]) && !(target as any).properties.length) ||\n (isEqual(difference(keysSource, keysTarget), [\"properties\"]) && !source.properties.length)\n ) {\n return _getPSetDeepEqualsResult(true);\n }\n\n return _getPSetDeepEqualsResult(false);\n }\n\n for (let i = 0; i < keysSource.length && result.isEqual; i++) {\n const keyName = keysSource[i];\n let id = keyName === \"properties\" ? undefined : keyName;\n result = _depthFirstDeepEquals.call(this, source[keyName], target[keyName], id);\n if (id) {\n idPath.pop();\n }\n }\n } else {\n result = _getPSetDeepEqualsResult(\n _getType.call(this, source) === _getType.call(this, target) && source === target,\n );\n }\n\n return result;\n };\n\n return _depthFirstDeepEquals.call(this, in_source, in_target);\n};\n\n/**\n * Fetches the non semver part of a typeid string.\n * @param in_typeid - A PropertySet typeid. For example: 'TeamLeoValidation2:ColorID-1.0.0'.\n * @returns The typeid, without a semver.\n */\nconst _stripSemverFromTypeId = function(in_typeid: string): string | null {\n const semverRegex = /(.*)-.*$/g;\n const match = semverRegex.exec(in_typeid);\n return match ? match[1] : null;\n};\n\nconst _unresolvedTypes = function(in_template: PropertySchema) {\n let first = true;\n const that = this;\n const accSet = traverse(in_template).reduce(function(acc: { [x: string]: string; }, x: PropertySchema) {\n if (first) {\n acc = {};\n first = false;\n }\n if (isObject(x) && has(x, \"typeid\")) {\n const extractedTypeid = _extractTypeid.call(that, x.typeid);\n\n if (!TypeIdHelper.isPrimitiveType(extractedTypeid)) {\n acc[extractedTypeid] = \"\";\n }\n }\n return acc;\n });\n\n return Object.keys(accSet);\n};\n\n/**\n * Performs basic template validation.\n * @param in_template - The template object to validate.\n */\nconst _validateBasic = function(in_template: PropertySchema) {\n if (!in_template) {\n this._resultBuilder.addError(new Error(MSG.NO_TEMPLATE));\n } else if (!in_template.typeid) {\n this._resultBuilder.addError(new Error(MSG.MISSING_TYPE_ID + JSON.stringify(in_template)));\n }\n};\n\n/**\n * Validations performed when the version increases between consecutive templates.\n *\n * @remarks\n * For example: 1.1.3 -> 2.0.0\n * This function checks the change level (PATCH, MINOR, MAJOR) and analyses the template content\n * to emit warnings if the change level should be higher, given the content that changed.\n * This function assumes that: in_versionPrevious < in_version.\n *\n * @param in_template - The latest template object.\n * @param in_templatePrevious - The previous template object.\n * @param in_version - The latest template version. Ex.: '2.0.0'.\n * @param in_versionPrevious - The previous template version. Ex.: '1.1.3'.\n */\nconst _validatePositiveIncrement = function(in_template: PropertySchema, in_templatePrevious: PropertySchema, in_version: string, in_versionPrevious: string) {\n ConsoleUtils.assert(\n gt(in_version, in_versionPrevious),\n \"property-changeset.TemplateValidator._validatePositiveIncrement called on non incremental \" +\n \"template versions\",\n );\n\n const versionDiff = diff(in_version, in_versionPrevious);\n\n if (CHANGE_LEVEL[versionDiff] >= CHANGE_LEVEL.major) {\n // No need to warn about change levels since they're already declared to be major.\n return;\n }\n\n if (major(in_version) === 0) {\n // Unstable version doesn't produce any warning.\n return;\n }\n\n const idPath = [`<${in_template.typeid}>`];\n\n let _depthFirstCompare = function(id: string, sourceObj: SchemaEntityType, targetObj: SchemaEntityType) {\n if (id === \"annotation\") {\n // Here, we know that the version has increased (patch, prepatch or prerelease), so\n // there's no need to check inside comments for changes.\n return;\n }\n\n if (id) {\n idPath.push(id);\n }\n\n if ((sourceObj === undefined) !== (targetObj === undefined)) {\n let minimumLevel: string;\n let mutation: string;\n\n if (targetObj === undefined) {\n // An element has been deleted.\n minimumLevel = \"major\";\n mutation = \"delete\";\n } else {\n // An element has been added\n minimumLevel = \"minor\";\n mutation = \"add\";\n }\n\n if (CHANGE_LEVEL[versionDiff] < CHANGE_LEVEL[minimumLevel]) {\n // Violates rule 6 (warning).\n this._resultBuilder.addWarning(\n MSG.CHANGE_LEVEL_TOO_LOW_1 + JSON.stringify({\n mutation,\n id: idPath.join(\".\"),\n level: {\n expected: minimumLevel,\n actual: versionDiff,\n },\n version: {\n current: in_version,\n previous: in_versionPrevious,\n },\n }),\n );\n }\n } else {\n const sourceObjType = _getType.call(this, sourceObj);\n const targetObjType = _getType.call(this, targetObj);\n if (sourceObjType !== targetObjType) {\n this._resultBuilder.addWarning(\n MSG.CHANGE_LEVEL_TOO_LOW_1 + JSON.stringify({\n mutation: \"change\",\n id: idPath.join(\".\"),\n type: {\n current: targetObjType,\n previous: sourceObjType,\n },\n level: {\n expected: \"major\",\n actual: versionDiff,\n },\n version: {\n current: in_version,\n previous: in_versionPrevious,\n },\n }),\n );\n }\n\n if (Array.isArray(sourceObj)) {\n let targetMap = {};\n each(targetObj, function(element: any) {\n targetMap[element.id] = element;\n });\n\n for (let i = 0; i < sourceObj.length; i++) {\n const element = sourceObj[i] as any;\n _depthFirstCompare.call(this, element.id, element, targetMap[element.id]);\n delete targetMap[element.id];\n }\n\n if (!isEmpty(targetMap)) {\n // Added array element.\n let minimumLevel = \"minor\";\n if (CHANGE_LEVEL[versionDiff] < CHANGE_LEVEL[minimumLevel]) {\n // Violates rule 5 (warning)\n idPath.push(Object.keys(targetMap)[0]);\n this._resultBuilder.addWarning(\n MSG.CHANGE_LEVEL_TOO_LOW_1 + JSON.stringify({\n mutation: \"add\",\n id: idPath.join(\".\"),\n level: {\n expected: minimumLevel,\n actual: versionDiff,\n },\n version: {\n current: in_version,\n previous: in_versionPrevious,\n },\n }),\n );\n idPath.pop();\n }\n }\n } else if (isObject(sourceObj)) {\n const keysSource = Object.keys(sourceObj);\n let targetMap = {};\n mapValues(targetObj, function(val, key) {\n targetMap[key] = val;\n });\n\n for (let i = 0; i < keysSource.length; i++) {\n let valueSource = sourceObj[keysSource[i]];\n let valueTarget = targetObj[keysSource[i]];\n _depthFirstCompare.call(\n this,\n keysSource[i] === \"properties\" ? undefined : keysSource[i],\n valueSource,\n valueTarget,\n );\n delete targetMap[keysSource[i]];\n }\n\n const remainingKeys = Object.keys(targetMap);\n if (!isEmpty(remainingKeys)) {\n // Added new keys to the target. This is a MINOR change, unless they new key is a\n // comment, in which case this is a PATCH level change.\n let minimumLevel = remainingKeys.length === 1 && remainingKeys[0] === \"annotation\" ? \"patch\" : \"minor\";\n if (CHANGE_LEVEL[versionDiff] < CHANGE_LEVEL[minimumLevel]) {\n // Violates rule 5 (warning)\n idPath.push(remainingKeys[0]);\n this._resultBuilder.addWarning(\n MSG.CHANGE_LEVEL_TOO_LOW_1 + JSON.stringify({\n mutation: \"add\",\n id: idPath.join(\".\"),\n level: {\n expected: minimumLevel,\n actual: versionDiff,\n },\n version: {\n current: in_version,\n previous: in_versionPrevious,\n },\n }),\n );\n idPath.pop();\n }\n }\n } else {\n if (idPath.length === 2 && id === \"typeid\") {\n // This is the root property typeid. Ignore the version component.\n sourceObj = _stripSemverFromTypeId.call(this);\n targetObj = _stripSemverFromTypeId.call(this);\n }\n\n if (sourceObj !== targetObj) {\n let minimumLevel = id === \"value\" ? \"minor\" : \"major\";\n if (CHANGE_LEVEL[versionDiff] < CHANGE_LEVEL[minimumLevel]) {\n this._resultBuilder.addWarning(\n MSG.CHANGE_LEVEL_TOO_LOW_1 + JSON.stringify({\n mutation: \"change\",\n id: idPath.join(\".\"),\n level: {\n expected: minimumLevel,\n actual: versionDiff,\n },\n value: {\n current: targetObj,\n previous: sourceObj,\n },\n version: {\n current: in_version,\n previous: in_versionPrevious,\n },\n }),\n );\n }\n }\n }\n }\n\n if (id) {\n idPath.pop();\n }\n };\n // console.assert(has(in_templatePrevious, 'id')); // TODO: Revisit this line after running the tests.\n _depthFirstCompare.call(this, (in_templatePrevious as any).id, in_templatePrevious, in_template);\n};\n\n/**\n * Validations performed when the version between consecutive templates doesn't change.\n * For example: 1.1.3 -> 1.1.3.\n * Templates whose version didn't change should have identical content.\n * @param in_template - The latest template object.\n * @param in_templatePrevious - The previous template object.\n */\nconst _validateSameVersion = function(in_template: PropertySchema, in_templatePrevious: PropertySchema) {\n const result = _psetDeepEquals.call(this, in_templatePrevious, in_template);\n if (!result.isEqual) {\n // Violates rule 3a.\n this._resultBuilder.addError(new Error(MSG.MODIFIED_TEMPLATE_SAME_VERSION_1 + result.path));\n }\n};\n\n/**\n * Validate a template\n * Check that the template is syntactically correct as well as semantically correct.\n * @param in_template - The template to check against.\n * Produces an {object|undefined} map of key-value pairs where the path of the invalid property is the key and the\n * value is the error message.\n *\n * i.e.\n *\n * ```\n * <pre>\n * {\n * 'isValid': true or false,\n * 'typeid': 'The typeid of the object being parsed',\n * 'unresolvedTypes': [ 'An array', 'of strong typeids', 'that were found',\n * 'in the document', 'but not resolved from the local cache' ],\n * 'resolvedTypes': [ 'Array of', 'strong types resolved', 'during template parsing'],\n * 'errors': [ 'Array of', 'objects describing', 'syntax errors in the template' ]\n * ...\n * }\n * </pre>\n * ```\n * @throws if context validation fails\n */\nconst _validateSemanticAndSyntax = function(in_template: PropertySchema) {\n _validateSyntax.call(this, in_template);\n _validateConstants.call(this, in_template);\n // TODO: _validateSemantic\n};\n\n/**\n * Validate a template\n * Check that the template is syntactically correct as well as semantically correct.\n * @param in_template - The template to check against\n * @return {Promise} a promise that resolved to nothing\n * @ignore\n */\nconst _validateSemanticAndSyntaxAsync = async function(in_template: PropertySchema): Promise<any> {\n return _validateSyntaxAsync.call(this, in_template);\n};\n\n/**\n * Validates that the semver part of a template's typeid is valid.\n * @param {Object} in_template - The template object to validate.\n * @return {string} The semver string. For example: '1.0.0'.\n * @private\n * @this TemplateValidator\n * @ignore\n */\nconst _validateSemverFormat = function(in_template) {\n const templateVersion = _getSemverFromTypeId.call(this, in_template.typeid);\n if (!templateVersion) {\n this._resultBuilder.addError(new Error(MSG.MISSING_VERSION + in_template.typeid));\n } else if (valid(templateVersion) !== templateVersion) {\n this._resultBuilder.addError(new Error(MSG.INVALID_VERSION_1 + templateVersion));\n }\n\n return templateVersion;\n};\n\n/**\n * Skip semver validation. Verify that the content is the same for both templates, while ignoring\n * the root 'typeid' property.\n * @param {Object} in_template - The latest template object.\n * @param {Object} in_templatePrevious - The previous template object.\n * @private\n * @this TemplateValidator\n */\nconst _validateSkipSemver = function(in_template, in_templatePrevious) {\n // Skipping the semver validation. Ignore the root typeid field.\n const result = _psetDeepEquals.call(this, in_template, in_templatePrevious);\n if (!result.isEqual) {\n // Violates rule 3a.\n this._resultBuilder.addError(new Error(MSG.MODIFIED_TEMPLATE_1 + result.path));\n }\n};\n\n/**\n * Checks if an invalid context error should be signified\n *\n * @param {String} in_context - The latest template object.\n * @return {Error|undefined} If exists returns the InvalidContext error\n * @private\n * @this TemplateValidator\n */\nconst getInvalidContextError = function(in_context) {\n if (in_context && !includes(VALID_CONTEXTS, in_context)) {\n return new Error(`${MSG.NOT_A_VALID_CONTEXT} ${in_context}`);\n }\n\n return undefined;\n};\n\n/**\n * Validate that the context is valid\n * Validate that only Named Properties are in sets\n * @param {object} in_template - The template to check against\n * @ignore\n * @throws if the context is invalid.\n */\nconst _validateContext = function(in_template) {\n const context = in_template.context;\n\n const error = getInvalidContextError(context);\n if (error) {\n throw error;\n }\n if (context === \"map\" && in_template.contextKeyType === \"typeid\") {\n throw new Error(MSG.INVALID_OPTION_NONE_CONSTANTS);\n }\n};\n\n/**\n * Validate just the syntax of a template\n * Check that the template is well-formed, according to the schema.\n * @param {object} in_template - The template to check against\n *\n * Context validation makes sure that elements of sets eventually inherit from NamedProperty.\n * If this is not the case, a promise rejection will occur with the appropriate error.\n * @return {Promise} promise that returns without any value and rejects in case of validation error\n * @ignore\n */\nconst _validateContextAsync = async function(in_template) {\n const that = this;\n const context = in_template.context;\n\n const error = getInvalidContextError(context);\n if (error) {\n return Promise.reject(error);\n }\n if (context === \"map\" && in_template.contextKeyType === \"typeid\") {\n return Promise.reject(new Error(MSG.INVALID_OPTION_NONE_CONSTANTS));\n }\n // If context is not 'set' validation doesn't apply\n if (context !== \"set\") {\n return Promise.resolve();\n }\n\n let typedValuePromises = [Promise.resolve()];\n if (in_template.typedValue) {\n typedValuePromises = map(in_template.typedValue, (tv) => that.inheritsFrom(tv.typeid, \"NamedProperty\"));\n } else {\n // Since context is 'set' the template must eventually inherit from NamedProperty\n if (in_template.inherits === undefined) {\n return Promise.reject(new Error(MSG.SET_ONLY_NAMED_PROPS));\n }\n\n // Since context is 'set' the template must eventually inherit from NamedProperty (same as above)\n if (includes(in_template.inherits, \"NamedProperty\") || in_template.inherits === \"NamedProperty\") {\n return Promise.resolve();\n }\n }\n const typedValuePromise = Promise.all(typedValuePromises);\n\n let parents = [];\n if (in_template.inherits) {\n parents = Array.isArray(in_template.inherits) ? in_template.inherits : [in_template.inherits];\n }\n const inheritsPromises = parents.map((typeid) => this._inheritsFromAsync(typeid, \"NamedProperty\"));\n\n // Combine results from inheritsPromises and typedValuePromise\n inheritsPromises.push(typedValuePromise);\n return Promise.all(inheritsPromises).then(function(results) {\n const foundNamedPropertyDescendant = find(results, (res) => res);\n if (!foundNamedPropertyDescendant) {\n return Promise.reject(Error(MSG.SET_ONLY_NAMED_PROPS));\n }\n\n return that._hasSchemaAsync(in_template.typeid);\n }).then(function(hasIt) {\n if (!hasIt) {\n return Promise.reject(new Error(MSG.SET_ONLY_NAMED_PROPS));\n }\n\n return that._inheritsFromAsync(in_template.typeid, \"NamedProperty\");\n }).then(async function(res) {\n if (res) {\n return undefined;\n }\n\n return Promise.reject(new Error(MSG.SET_ONLY_NAMED_PROPS));\n });\n};\n\n/**\n * Validate that the context is valid\n * Validate that only Named Properties are in sets\n * @param {object} in_template - The template to check against\n * @ignore\n * @throws if the context is invalid.\n */\nlet _validateConstants = function(in_template) {\n const that = this;\n if (in_template.constants && Array.isArray(in_template.constants)) {\n for (let i = 0; i < in_template.constants.length; i++) {\n const constant = in_template.constants[i];\n const context = constant.context;\n\n if (context === \"map\" && constant.contextKeyType === \"typeid\") {\n each(constant.value, function(value, key) {\n if (!TypeIdHelper.isTemplateTypeid(key)) {\n that._resultBuilder.addError(new Error(MSG.KEY_MUST_BE_TYPEID + key));\n }\n });\n }\n }\n }\n};\n\n/**\n * Analyze output of the syntax validation and build error messages\n *\n * @param in_template - The template that was analyzed\n */\nconst _processValidationResults = function(in_template: PropertySchema) {\n let that = this;\n let result = this._resultBuilder.result;\n\n result.isValid = _syntaxValidator(in_template);\n if (!result.isValid) {\n ConsoleUtils.assert(!isEmpty(_syntaxValidator.errors), \"template validation failed but produced no error\");\n }\n\n if (_syntaxValidator.errors) {\n each(_syntaxValidator.errors, function(error) {\n const regexTypeId = /typeid/;\n switch (error.keyword) {\n case \"pattern\":\n if (error.dataPath === \".typeid\") {\n error.message = `typeid should have a pattern like: my.example:point-1.0.0 ${error.data\n } does not match that pattern`;\n } else if (\"pattern\" && regexTypeId.test(error.dataPath)) {\n error.message = error.schemaPath === \"#/definitions/typed-reference-typeid/pattern\"\n ? \"\"\n : `${error.dataPath} should follow this pattern: <namespace>:<typeid>-<version> ` +\n `(for example: Sample:Rectangle-1.0.0) or match one of the Primitive Types (Float32, Float64, ` +\n `Int8, Uint8, Int16, Uint16, Int32, Uint32, Bool, String, Reference, Enum, Int64, Uint64) or ` +\n `Reserved Types (BaseProperty, NamedProperty, NodeProperty, NamedNodeProperty, ` +\n `RelationshipProperty). '${error.data}' is not valid`;\n }\n break;\n\n case \"enum\":\n error.message = regexTypeId.test(error.dataPath)\n ? \"\"\n : `${error.dataPath} should match one of the following: ${error.schema}`;\n break;\n\n case \"type\":\n error.message = `${error.dataPath} should be a ${error.schema}`;\n break;\n\n case \"not\":\n if (error.schemaPath === \"#/switch/1/then/anyOf/0/properties/typeid/not\") {\n // remove .typeid at the end of the dataPath\n error.message = `For ${error.dataPath.slice(0, -7)\n }: Properties should have either a typeid or an array of child properties, but not both.`;\n } else if (error.schemaPath === \"#/switch/1/then/anyOf/1/properties/properties/not\") {\n // remove .properties at the end of the dataPath\n error.message = `For ${error.dataPath.slice(0, -11)\n }: Properties should have either a typeid or an array of child properties, but not both.`;\n }\n break;\n\n // these errors do not add any information. All necessary information is in the 'enum' errors\n // empty errors will be filtered out before logging.\n case \"oneOf\":\n case \"anyOf\":\n error.message = \"\";\n break;\n\n // for minItems, required and any other error - add dataPath to indicate which part of the\n // template the error refers to.\n default:\n error.message = `${error.dataPath} ${error.message}`;\n break;\n }\n // Deep-copy for thread-safety.\n that._resultBuilder.addError(cloneDeep(error));\n });\n }\n\n result.unresolvedTypes = _unresolvedTypes.call(this, in_template);\n};\n\n/**\n * Validate just the syntax of a template\n * Check that the template is well-formed, according to the schema.\n * @param in_template - The template to check against\n * @throws if a property with context set is not an instance of NamedProperties\n * @ignore\n */\nlet _validateSyntax = function(in_template: PropertySchema) {\n const that = this;\n // recursively test all properties for context\n let recursiveContextCheck = function(template) {\n _validateContext.call(that, template);\n if (template.properties) {\n template.properties.forEach(function(property) {\n recursiveContextCheck(property);\n });\n }\n };\n\n recursiveContextCheck(in_template);\n\n _processValidationResults.call(this, in_template);\n\n const result = this._resultBuilder.result;\n result.unresolvedTypes = _unresolvedTypes.call(this, in_template);\n};\n\nconst createContextCheckAsyncQueue = function() {\n const that = this;\n const contextCheckWorker = function(in_task, in_callback) {\n const property = in_task.property;\n _validateContextAsync.call(that, property).then(function(response) {\n in_callback();\n }).catch(function(error) {\n in_callback({ error });\n });\n };\n // Async queue for schema context check tasks\n return queue(contextCheckWorker, 5);\n};\n\n/**\n * Validate just the syntax of a template\n * Check that the template is well-formed, according to the schema.\n *\n * @param in_template - The template to check against\n * Mainly checks context. See _validateContextAsync\n * @returns Promise that resolves without any result\n * @ignore\n */\nlet _validateSyntaxAsync = async function(in_template: PropertySchema): Promise<SchemaValidationResult> {\n const that = this;\n\n return new Promise(function(resolve, reject) {\n if (that.asyncValidationInProgress === true) {\n reject(new Error(MSG.CONTEXT_VALIDATION_IN_PROGRESS));\n return;\n }\n\n that.asyncValidationInProgress = true;\n\n const contextCheckAsyncQueue = createContextCheckAsyncQueue.call(that);\n\n // recursively test all properties for context\n let recursiveContextCheck = function(template) {\n // Does the call to _validateContextAsync\n contextCheckAsyncQueue.push({ property: template }, function(error) {\n if (error !== undefined) {\n reject(new Error(error));\n return;\n }\n });\n if (template.properties) {\n template.properties.forEach(function(property) {\n recursiveContextCheck(property);\n });\n }\n };\n recursiveContextCheck(in_template);\n\n contextCheckAsyncQueue.drain(\n function() {\n const result = that._resultBuilder.result;\n _processValidationResults.call(that, in_template);\n result.unresolvedTypes = _unresolvedTypes.call(that, in_template);\n\n that.asyncValidationInProgress = false;\n resolve(result);\n },\n );\n });\n};\n\nexport interface TemplateValidatorOptions {\n /**\n * When set to true, {@link #validate} only checks the supplied templates' content\n * and fails the validation if they're not identical. Defaults to false.\n */\n skipSemver?: boolean;\n /**\n * When set to true, the typeid of any schema can have '-draft' as a version. Defaults to false.\n */\n allowDraft?: boolean;\n /**\n * Function that checks if a template inherits from another.\n */\n inheritsFrom?: (source: PropertySchema, target: PropertySchema) => boolean;\n /**\n * Function that checks if we have a template matching a typeid.\n */\n hasSchema?: (schema: PropertySchema, typeid: string) => boolean;\n /**\n * Function that checks if a template inherits from another asynchronously.\n */\n inheritsFromAsync?: (source: PropertySchema, target: PropertySchema) => Promise<boolean>;\n /**\n * Function that checks if we have a template matching a typeid asynchronously.\n */\n hasSchemaAsync?: (schema: PropertySchema, typeid: string) => Promise<boolean>;\n\n}\n\nconst Utils = {\n psetDeepEquals(in_source: PropertySchema, in_target: PropertySchema) {\n return _psetDeepEquals.call(this, in_source, in_target).isEqual;\n },\n};\n\n/**\n * Instantiates a new TemplateValidator. Must be provided with a set of inheritsFrom and hasSchema\n * function or inheritsFromAsync and hasSchemaAsync, but not both.\n */\nexport class TemplateValidator {\n static Utils = Utils;\n private _resultBuilder: ValidationResultBuilder;\n public _inheritsFrom: (source: PropertySchema, target: PropertySchema) => boolean;\n public _hasSchema: (schema: PropertySchema, typeid: string) => boolean;\n public _inheritsFromAsync: (source: PropertySchema, target: PropertySchema) => Promise<boolean>;\n public _hasSchemaAsync: (schema: PropertySchema, typeid: string) => Promise<boolean>;\n private readonly _allowDraft: boolean;\n private readonly _skipSemver: boolean;\n constructor(in_params: TemplateValidatorOptions = { skipSemver: false, allowDraft: false }) {\n this._skipSemver = in_params ? !!in_params.skipSemver : false;\n this._allowDraft = in_params ? !!in_params.allowDraft : false;\n // Used by validate()\n if (in_params && in_params.inheritsFrom !== undefined && in_params.hasSchema !== undefined) {\n this._inheritsFrom = in_params.inheritsFrom;\n this._hasSchema = in_params.hasSchema;\n } else if (in_params && in_params.inheritsFromAsync !== undefined && in_params.hasSchemaAsync !== undefined) {\n this._inheritsFromAsync = in_params.inheritsFromAsync;\n this._hasSchemaAsync = in_params.hasSchemaAsync;\n } else {\n throw new Error(MSG.MISSING_INHERITSFROM_OR_HASSCHEMA);\n }\n }\n\n/**\n * Validates that all templates conform to the following mandatory rules:\n *\n * 1. Must have a typeid attribute.\n *\n * 2. typeid must end in a valid semver string.\n *\n * 3. When both in_template (B) and in_templatePrevious (A) are supplied:\n *\n * - 3a. Semver is identical only if content is identical.\n *\n * - 3b. B's semver >= A's semver\n *\n * Additionally, the following soft rules will produce warnings when violated:\n *\n * 3.5. Elements of sets must eventually inherit from 'NamedProperty'\n *\n * 4. PATCH revision should be increased when _only_ the template description changes.\n *\n * 5. Adding one or more template attributes is a MINOR change.\n *\n * 6. Removing one or more template attributes is a MAJOR change.\n *\n * @param in_template - The latest template version, as a JSON object.\n * @param in_templatePrevious - The previous template version, as a JSON object. Optional.\n * @returns The validation results. Example:\n *\n * ```json\n * {\n * isValid: false,\n * errors: ['Something went wrong. Validation failed.'],\n * warnings: ['A non-fatal warning'],\n * typeid: 'SomeNamespace:PointID-1.0.0'\n * }\n * ```\n *\n * It's possible for 'isValid' to be true while 'warnings' contains one or more messages.\n */\n validate(in_template: PropertySchema, in_templatePrevious?: PropertySchema): SchemaValidationResult {\n this._resultBuilder = new ValidationResultBuilder(in_template ? in_template.typeid : \"\");\n\n let isDraft = false;\n if (in_template && in_template.typeid &&\n TypeIdHelper.extractVersion(in_template.typeid).version === \"draft\") {\n if (this._allowDraft) {\n isDraft = true;\n } else {\n this._resultBuilder.addError(\n new Error(MSG.DRAFT_AS_VERSION_TYPEID),\n );\n }\n }\n\n _validateBasic.call(this, in_template);\n if (in_templatePrevious) {\n _validateBasic.call(this, in_templatePrevious);\n }\n\n // Basic validation (such as input params) must pass before the real validation can begin.\n if (!this._resultBuilder.isValid()) {\n return this._resultBuilder.result;\n }\n\n _validateSemanticAndSyntax.call(this, in_template);\n if (!this._resultBuilder.isValid() || isDraft) {\n return this._resultBuilder.result;\n }\n\n if (in_templatePrevious) {\n _validateSemanticAndSyntax.call(this, in_templatePrevious);\n if (!this._resultBuilder.isValid()) {\n // Here the previous template is not valid. Make sure the typeid in the returned info is\n // the root of the template that failed validation.\n this._resultBuilder.result.typeid = in_templatePrevious.typeid;\n return this._resultBuilder.result;\n }\n }\n\n if (this._skipSemver && in_templatePrevious) {\n _validateSkipSemver.call(this, in_template, in_templatePrevious);\n return this._resultBuilder.result;\n }\n\n // semver format validation\n const version = _validateSemverFormat.call(this, in_template);\n const versionPrevious =\n in_templatePrevious ? _validateSemverFormat.call(this, in_templatePrevious) : null;\n\n // semver format validation must pass.\n if (!this._resultBuilder.isValid()) {\n return this._resultBuilder.result;\n }\n\n if (in_templatePrevious) {\n // Validate that the semver change is valid.\n switch (compare(version, versionPrevious)) {\n case 0:\n _validateSameVersion.call(this, in_template, in_templatePrevious);\n break;\n case 1:\n // newVersion is greater\n _validatePositiveIncrement.call(this, in_template, in_templatePrevious, version, versionPrevious);\n break;\n default:\n case -1:\n // previousVersion is greater. Violates rule 3b.\n this._resultBuilder.addError(\n new Error(MSG.VERSION_REGRESSION_1 + JSON.stringify({\n current: version,\n previous: versionPrevious,\n })),\n );\n break;\n }\n }\n\n return this._resultBuilder.result;\n }\n\n /**\n * Validates that all templates conform to the following mandatory rules:\n *\n * 1. Must have a typeid attribute.\n *\n * 2. typeid must end in a valid semver string.\n *\n * 3. When both in_template (B) and in_templatePrevious (A) are supplied:\n *\n * - 3a. Semver is identical only if content is identical.\n *\n * - 3b. B's semver >= A's semver\n *\n * Additionally, the following soft rules will produce warnings when violated:\n *\n * 3.5. Elements of sets must eventually inherit from 'NamedProperty'\n *\n * 4. PATCH revision should be increased when _only_ the template description changes.\n *\n * 5. Adding one or more template attributes is a MINOR change.\n *\n * 6. Removing one or more template attributes is a MAJOR change.\n *\n * @param in_template - The latest template version, as a JSON object.\n * @param in_templatePrevious - The previous template version, as a JSON object. Optional.\n * @returns A promise that resolves to the validation results as an object. Example:\n *\n * ```json\n * {\n * isValid: false,\n * errors: ['Something went wrong. Validation failed.'],\n * warnings: ['A non-fatal warning'],\n * typeid: 'SomeNamespace:PointID-1.0.0'\n * }\n * ```\n *\n * It's possible for 'isValid' to be true while 'warnings' contains one or more messages.\n */\n async validateAsync(in_template: PropertySchema, in_templatePrevious?: PropertySchema): Promise<SchemaValidationResult> {\n this._resultBuilder = new ValidationResultBuilder(in_template ? in_template.typeid : \"\");\n _validateBasic.call(this, in_template);\n if (in_templatePrevious) {\n _validateBasic.call(this, in_templatePrevious);\n }\n if (!this._resultBuilder.isValid()) {\n return Promise.resolve(this._resultBuilder.result);\n }\n return (in_templatePrevious) ?\n this._validateAsyncWithPreviousSchema(in_template, in_templatePrevious) :\n _validateSemanticAndSyntaxAsync.call(this, in_template);\n }\n\n /**\n * Called by validateAsync if a previous schema is passed in argument\n *\n * @param in_template - The latest template version, as a JSON object.\n * @param in_templatePrevious - The previous template version, as a JSON object. Optional.\n *\n * @returns promise that resolves to the validation results as an objet. See validateAsync\n * @ignore\n */\n private async _validateAsyncWithPreviousSchema(in_template: PropertySchema, in_templatePrevious: PropertySchema): Promise<SchemaValidationResult> {\n const that = this;\n return _validateSemanticAndSyntaxAsync.call(that, in_template).then(() => _validateSemanticAndSyntaxAsync.call(that, in_templatePrevious)).then(function() {\n if (!that._resultBuilder.isValid()) {\n // Here the previous template is not valid. Make sure the typeid in the returned info is\n // the root of the template that failed validation.\n that._resultBuilder.result.typeid = in_templatePrevious.typeid;\n }\n\n if (that._skipSemver && in_templatePrevious) {\n _validateSkipSemver.call(that, in_template, in_templatePrevious);\n }\n\n const version = _validateSemverFormat.call(that, in_template);\n const versionPrevious = in_templatePrevious ? _validateSemverFormat.call(that, in_templatePrevious) : null;\n\n // Validate that the semver change is valid.\n switch (compare(version, versionPrevious)) {\n case 0:\n _validateSameVersion.call(that, in_template, in_templatePrevious);\n break;\n case 1:\n // newVersion is greater\n _validatePositiveIncrement.call(that, in_template, in_templatePrevious, version, versionPrevious);\n break;\n default:\n case -1:\n // previousVersion is greater. Violates rule 3b.\n that._resultBuilder.addError(\n new Error(MSG.VERSION_REGRESSION_1 + JSON.stringify({\n current: version,\n previous: versionPrevious,\n })),\n );\n break;\n }\n\n return that._resultBuilder.result;\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"templateValidator.js","sourceRoot":"","sources":["../src/templateValidator.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH;;;;GAIG;AAEH,8CAAsB;AACtB,gEAAuC;AAEvC,uDAA+B;AAC/B,6DAAqC;AACrC,yDAAiC;AACjC,+DAAuC;AACvC,+DAAuC;AACvC,mEAA2C;AAC3C,qDAA6B;AAC7B,iEAAyC;AACzC,+DAAuC;AACvC,qDAA6B;AAC7B,uDAA+B;AAC/B,6DAAqC;AACrC,yDAAsD;AAEtD,mCAAyD;AACzD,wDAAgC;AAChC,iCAA8B;AAE9B,aAAa;AACb,yEAA8E;AAC9E,qDAAkD;AAClD,yDAAsD;AACtD,uEAA4F;AAE5F,MAAM,EAAE,GAAG,EAAE,GAAG,2BAAS,CAAC;AAE1B,MAAM,UAAU,GAAG,IAAI,aAAG,CAAC;IACvB,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,IAAI;CAChB,CAAC,CAAC;AA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AAI,CAAC,cAAc,CAAC,MAAM,CAAC;QACtC,CAAC,CAAC,CAAC;IACP,CAAC;;AAnPL,8CAoPC;AAnPU,uBAAK,GAAG,KAAK,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * @fileoverview\n * @description The TemplateValidator can examine consecutive versions of a given template to detect semantic\n * versioning (semver) errors and warn about incorrect versioning practices.\n */\n\nimport Ajv from \"ajv\";\nimport ajvKeywords from \"ajv-keywords\";\n\nimport each from \"lodash/each\";\nimport isEqual from \"lodash/isEqual\";\nimport every from \"lodash/every\";\nimport isString from \"lodash/isString\";\nimport isObject from \"lodash/isObject\";\nimport difference from \"lodash/difference\";\nimport has from \"lodash/has\";\nimport mapValues from \"lodash/mapValues\";\nimport includes from \"lodash/includes\";\nimport map from \"lodash/map\";\nimport find from \"lodash/find\";\nimport isEmpty from \"lodash/isEmpty\";\nimport { copy as cloneDeep } from \"fastest-json-copy\";\n\nimport { gt, diff, major, valid, compare } from \"semver\";\nimport traverse from \"traverse\";\nimport { queue } from \"async\";\n\n// @ts-ignore\nimport { constants, ConsoleUtils } from \"@fluid-experimental/property-common\";\nimport { TemplateSchema } from \"./templateSchema\";\nimport { TypeIdHelper } from \"./helpers/typeidHelper\";\nimport { SchemaValidationResult, ValidationResultBuilder } from \"./validationResultBuilder\";\n\nconst { MSG } = constants;\n\nconst ajvFactory = new Ajv({\n allErrors: true,\n verbose: true,\n});\n\najvKeywords(ajvFactory, \"prohibited\");\najvKeywords(ajvFactory, \"typeof\");\n\nconst _syntaxValidator = ajvFactory.compile(TemplateSchema);\n\ntype ValuesType = { [key: string]: ValuesType; };\n\ntype PropertyType = {\n id: string;\n context: string;\n typeid: string;\n values: ValuesType;\n};\n\ntype PropertiesType = PropertyType[];\n\nexport interface PropertySchema {\n constants?: any[];\n context: string;\n inherits?: string[];\n annotation?: { [key: string]: string; };\n properties: PropertiesType;\n typeid: string;\n values: ValuesType;\n}\n\ntype SchemaEntityType = PropertySchema | string[] | PropertiesType;\n\n/**\n * A weighted enumeration of semver change types. Higher values are more important.\n * PATCH: Annotation and comment changes.\n * MINOR: Added properties.\n * MAJOR: Everything else, including deleting properties.\n * @ignore\n */\nconst CHANGE_LEVEL = {\n patch: 0, // '1.0.0' -> '1.0.1'\n minor: 1, // '1.0.0' -> '1.1.0'\n major: 2, // '1.5.2' -> '2.0.0'\n\n prerelease: 0, // '1.0.0-alpha.1' -> '1.0.0'\n prepatch: 0, // '1.0.0-alpha.1' -> '1.0.1'\n preminor: 1, // '1.0.0-alpha.1' -> '1.1.0'\n premajor: 2, // '1.0.0-alpha.1' -> '2.0.0'\n};\n\nconst VALID_CONTEXTS = [\"single\", \"array\", \"map\", \"set\", \"enum\"];\n\nconst _extractTypeid = function(typeidOrReference: string) {\n // Take Reference<strong-type-id> and return strong-type-id\n if (!isString(typeidOrReference)) {\n throw new Error(MSG.TYPEID_MUST_BE_STRING + typeidOrReference);\n }\n const reference = \"Reference<\";\n let result = typeidOrReference || \"\";\n const isReference = result.indexOf(reference) === 0;\n if (isReference) {\n result = typeidOrReference.substring(reference.length, typeidOrReference.length - 1);\n }\n return result;\n};\n\n/**\n * Given a typeid string, fetches the semver 'x.y.z' version string.\n * @param in_typeid - A PropertySet typeid. For example: 'TeamLeoValidation2:ColorID-1.0.0'.\n * @returns The semver 'x.y.z' version string, or null if in_typeid is not a valid PropertySet typeid.\n */\nconst _getSemverFromTypeId = function(in_typeid: string): string | null {\n const semverRegex = /.*-(.*)$/g;\n const match = semverRegex.exec(in_typeid);\n return match ? match[1] : null;\n};\n\n/**\n * Fetches the type name of a javascript entity.\n * @param in_obj - A javascript entity.\n * @returns The type name for in_obj.\n */\nconst _getType = (in_obj: any): string => Object.prototype.toString.call(in_obj).slice(8, -1);\n\ntype PathEqualityInfo = {\n isEqual: boolean;\n path: string;\n};\n\nfunction isPropertyArray(source: SchemaEntityType): source is PropertiesType {\n return every(source, (entry: PropertyType) => isObject(entry) && entry.id !== undefined);\n}\n\n// function isSchemaTemplate(source: SchemaEntityType): source is PropertySchema {\n// return isObject(source) && !Array.isArray(source);\n// }\n\n/**\n * An object deep compare with special handling for pset property arrays.\n * pset property arrays are allowed to be out of order as long as elements can be matched with\n * their id.\n * @param in_source - The source entity to test for deep equality.\n * @param in_target - The target entity to test for deep equality.\n * @returns {isEqual: false, path: 'foo.properties[1].x'}\n *\n * - isEqual: true if in_source and in_target property sets are equal, even if the individual property arrays\n * differ but contain the same out of order elements.\n *\n * - path: path to the property that is not equal.\n */\nconst _psetDeepEquals = function(in_source: SchemaEntityType, in_target: SchemaEntityType): PathEqualityInfo {\n const idPath = [];\n if (!Array.isArray(in_source) && in_source.typeid) {\n idPath.push(`<${in_source.typeid}>`);\n }\n\n /**\n * Create the _psetDeepEquals result.\n * @param isEqual - Whether or not a PropertySet result is being constructed for\n * PropertySets that are deeply equal.\n * @returns {{isEqual: boolean, path: string}} An object that indicates whether or not the source\n * and target PropertySets are deeply equal. If they're not, it also contains a path to the\n * property that is not equal.\n */\n const _getPSetDeepEqualsResult = (isEqual: boolean): PathEqualityInfo => ({\n isEqual,\n path: isEqual ? undefined : idPath.join(\"\"),\n });\n\n /**\n * Performs a recursive, depth first deep equal test against two PropertySets.\n * @param source - The source entity to test for deep equality.\n * @param target - The target entity to test for deep equality.\n * @param id - The current path element being compared.\n * @return The result of _getPSetDeepEqualsResult\n */\n let _depthFirstDeepEquals = function(source: SchemaEntityType, target: SchemaEntityType, id?: string): PathEqualityInfo {\n let result = _getPSetDeepEqualsResult(true);\n\n if (id) {\n if (typeof id === \"number\") {\n idPath.push(`[${id}]`);\n } else {\n idPath.push(`.${id}`);\n }\n }\n\n if (Array.isArray(source)) {\n if (!Array.isArray(target)) {\n return _getPSetDeepEqualsResult(false);\n }\n\n if (source.length !== target.length) {\n return _getPSetDeepEqualsResult(false);\n }\n\n if (source.length === 0) {\n return _getPSetDeepEqualsResult(true);\n }\n\n // See if we're comparing arrays of objects (like properties) or simple arrays of strings\n // like inheritance lists.\n if (isPropertyArray(source)) {\n const targetMap = {};\n each(target, function(element: PropertyType) {\n targetMap[element.id] = element;\n });\n\n for (let i = 0; i < source.length && result.isEqual; i++) {\n const sourceId = source[i].id;\n result = _depthFirstDeepEquals.call(this, source[i], targetMap[sourceId], sourceId);\n idPath.pop();\n }\n } else {\n // Element order matters\n for (let i = 0; i < source.length && result.isEqual; i++) {\n result = _depthFirstDeepEquals.call(this, source[i], target[i], i);\n idPath.pop();\n }\n }\n } else if (isObject(source)) {\n if (!isObject(target)) {\n return _getPSetDeepEqualsResult(false);\n }\n\n const keysSource = Object.keys(source);\n const keysTarget = Object.keys(target);\n if (keysSource.length !== keysTarget.length) {\n // A template with abstract properties must equal one with an empty properties array\n // We check the difference in keys between the source and target and if the only difference is the\n // properties array we check if it's empty. Then we reverse the condition so it work both ways.\n if (\n (isEqual(difference(keysTarget, keysSource), [\"properties\"]) && !(target as any).properties.length) ||\n (isEqual(difference(keysSource, keysTarget), [\"properties\"]) && !source.properties.length)\n ) {\n return _getPSetDeepEqualsResult(true);\n }\n\n return _getPSetDeepEqualsResult(false);\n }\n\n for (let i = 0; i < keysSource.length && result.isEqual; i++) {\n const keyName = keysSource[i];\n let id = keyName === \"properties\" ? undefined : keyName;\n result = _depthFirstDeepEquals.call(this, source[keyName], target[keyName], id);\n if (id) {\n idPath.pop();\n }\n }\n } else {\n result = _getPSetDeepEqualsResult(\n _getType.call(this, source) === _getType.call(this, target) && source === target,\n );\n }\n\n return result;\n };\n\n return _depthFirstDeepEquals.call(this, in_source, in_target);\n};\n\n/**\n * Fetches the non semver part of a typeid string.\n * @param in_typeid - A PropertySet typeid. For example: 'TeamLeoValidation2:ColorID-1.0.0'.\n * @returns The typeid, without a semver.\n */\nconst _stripSemverFromTypeId = function(in_typeid: string): string | null {\n const semverRegex = /(.*)-.*$/g;\n const match = semverRegex.exec(in_typeid);\n return match ? match[1] : null;\n};\n\nconst _unresolvedTypes = function(in_template: PropertySchema) {\n let first = true;\n const that = this;\n const accSet = traverse(in_template).reduce(function(acc: { [x: string]: string; }, x: PropertySchema) {\n if (first) {\n acc = {};\n first = false;\n }\n if (isObject(x) && has(x, \"typeid\")) {\n const extractedTypeid = _extractTypeid.call(that, x.typeid);\n\n if (!TypeIdHelper.isPrimitiveType(extractedTypeid)) {\n acc[extractedTypeid] = \"\";\n }\n }\n return acc;\n });\n\n return Object.keys(accSet);\n};\n\n/**\n * Performs basic template validation.\n * @param in_template - The template object to validate.\n */\nconst _validateBasic = function(in_template: PropertySchema) {\n if (!in_template) {\n this._resultBuilder.addError(new Error(MSG.NO_TEMPLATE));\n } else if (!in_template.typeid) {\n this._resultBuilder.addError(new Error(MSG.MISSING_TYPE_ID + JSON.stringify(in_template)));\n }\n};\n\n/**\n * Validations performed when the version increases between consecutive templates.\n *\n * @remarks\n * For example: 1.1.3 -> 2.0.0\n * This function checks the change level (PATCH, MINOR, MAJOR) and analyses the template content\n * to emit warnings if the change level should be higher, given the content that changed.\n * This function assumes that: in_versionPrevious < in_version.\n *\n * @param in_template - The latest template object.\n * @param in_templatePrevious - The previous template object.\n * @param in_version - The latest template version. Ex.: '2.0.0'.\n * @param in_versionPrevious - The previous template version. Ex.: '1.1.3'.\n */\nconst _validatePositiveIncrement = function(in_template: PropertySchema, in_templatePrevious: PropertySchema, in_version: string, in_versionPrevious: string) {\n ConsoleUtils.assert(\n gt(in_version, in_versionPrevious),\n \"property-changeset.TemplateValidator._validatePositiveIncrement called on non incremental \" +\n \"template versions\",\n );\n\n const versionDiff = diff(in_version, in_versionPrevious);\n\n if (CHANGE_LEVEL[versionDiff] >= CHANGE_LEVEL.major) {\n // No need to warn about change levels since they're already declared to be major.\n return;\n }\n\n if (major(in_version) === 0) {\n // Unstable version doesn't produce any warning.\n return;\n }\n\n const idPath = [`<${in_template.typeid}>`];\n\n let _depthFirstCompare = function(id: string, sourceObj: SchemaEntityType, targetObj: SchemaEntityType) {\n if (id === \"annotation\") {\n // Here, we know that the version has increased (patch, prepatch or prerelease), so\n // there's no need to check inside comments for changes.\n return;\n }\n\n if (id) {\n idPath.push(id);\n }\n\n if ((sourceObj === undefined) !== (targetObj === undefined)) {\n let minimumLevel: string;\n let mutation: string;\n\n if (targetObj === undefined) {\n // An element has been deleted.\n minimumLevel = \"major\";\n mutation = \"delete\";\n } else {\n // An element has been added\n minimumLevel = \"minor\";\n mutation = \"add\";\n }\n\n if (CHANGE_LEVEL[versionDiff] < CHANGE_LEVEL[minimumLevel]) {\n // Violates rule 6 (warning).\n this._resultBuilder.addWarning(\n MSG.CHANGE_LEVEL_TOO_LOW_1 + JSON.stringify({\n mutation,\n id: idPath.join(\".\"),\n level: {\n expected: minimumLevel,\n actual: versionDiff,\n },\n version: {\n current: in_version,\n previous: in_versionPrevious,\n },\n }),\n );\n }\n } else {\n const sourceObjType = _getType.call(this, sourceObj);\n const targetObjType = _getType.call(this, targetObj);\n if (sourceObjType !== targetObjType) {\n this._resultBuilder.addWarning(\n MSG.CHANGE_LEVEL_TOO_LOW_1 + JSON.stringify({\n mutation: \"change\",\n id: idPath.join(\".\"),\n type: {\n current: targetObjType,\n previous: sourceObjType,\n },\n level: {\n expected: \"major\",\n actual: versionDiff,\n },\n version: {\n current: in_version,\n previous: in_versionPrevious,\n },\n }),\n );\n }\n\n if (Array.isArray(sourceObj)) {\n let targetMap = {};\n each(targetObj, function(element: any) {\n targetMap[element.id] = element;\n });\n\n for (let i = 0; i < sourceObj.length; i++) {\n const element = sourceObj[i] as any;\n _depthFirstCompare.call(this, element.id, element, targetMap[element.id]);\n delete targetMap[element.id];\n }\n\n if (!isEmpty(targetMap)) {\n // Added array element.\n let minimumLevel = \"minor\";\n if (CHANGE_LEVEL[versionDiff] < CHANGE_LEVEL[minimumLevel]) {\n // Violates rule 5 (warning)\n idPath.push(Object.keys(targetMap)[0]);\n this._resultBuilder.addWarning(\n MSG.CHANGE_LEVEL_TOO_LOW_1 + JSON.stringify({\n mutation: \"add\",\n id: idPath.join(\".\"),\n level: {\n expected: minimumLevel,\n actual: versionDiff,\n },\n version: {\n current: in_version,\n previous: in_versionPrevious,\n },\n }),\n );\n idPath.pop();\n }\n }\n } else if (isObject(sourceObj)) {\n const keysSource = Object.keys(sourceObj);\n let targetMap = {};\n mapValues(targetObj, function(val, key) {\n targetMap[key] = val;\n });\n\n for (let i = 0; i < keysSource.length; i++) {\n let valueSource = sourceObj[keysSource[i]];\n let valueTarget = targetObj[keysSource[i]];\n _depthFirstCompare.call(\n this,\n keysSource[i] === \"properties\" ? undefined : keysSource[i],\n valueSource,\n valueTarget,\n );\n delete targetMap[keysSource[i]];\n }\n\n const remainingKeys = Object.keys(targetMap);\n if (!isEmpty(remainingKeys)) {\n // Added new keys to the target. This is a MINOR change, unless they new key is a\n // comment, in which case this is a PATCH level change.\n let minimumLevel = remainingKeys.length === 1 && remainingKeys[0] === \"annotation\" ? \"patch\" : \"minor\";\n if (CHANGE_LEVEL[versionDiff] < CHANGE_LEVEL[minimumLevel]) {\n // Violates rule 5 (warning)\n idPath.push(remainingKeys[0]);\n this._resultBuilder.addWarning(\n MSG.CHANGE_LEVEL_TOO_LOW_1 + JSON.stringify({\n mutation: \"add\",\n id: idPath.join(\".\"),\n level: {\n expected: minimumLevel,\n actual: versionDiff,\n },\n version: {\n current: in_version,\n previous: in_versionPrevious,\n },\n }),\n );\n idPath.pop();\n }\n }\n } else {\n if (idPath.length === 2 && id === \"typeid\") {\n // This is the root property typeid. Ignore the version component.\n sourceObj = _stripSemverFromTypeId.call(this);\n targetObj = _stripSemverFromTypeId.call(this);\n }\n\n if (sourceObj !== targetObj) {\n let minimumLevel = id === \"value\" ? \"minor\" : \"major\";\n if (CHANGE_LEVEL[versionDiff] < CHANGE_LEVEL[minimumLevel]) {\n this._resultBuilder.addWarning(\n MSG.CHANGE_LEVEL_TOO_LOW_1 + JSON.stringify({\n mutation: \"change\",\n id: idPath.join(\".\"),\n level: {\n expected: minimumLevel,\n actual: versionDiff,\n },\n value: {\n current: targetObj,\n previous: sourceObj,\n },\n version: {\n current: in_version,\n previous: in_versionPrevious,\n },\n }),\n );\n }\n }\n }\n }\n\n if (id) {\n idPath.pop();\n }\n };\n // console.assert(has(in_templatePrevious, 'id')); // TODO: Revisit this line after running the tests.\n _depthFirstCompare.call(this, (in_templatePrevious as any).id, in_templatePrevious, in_template);\n};\n\n/**\n * Validations performed when the version between consecutive templates doesn't change.\n * For example: 1.1.3 -> 1.1.3.\n * Templates whose version didn't change should have identical content.\n * @param in_template - The latest template object.\n * @param in_templatePrevious - The previous template object.\n */\nconst _validateSameVersion = function(in_template: PropertySchema, in_templatePrevious: PropertySchema) {\n const result = _psetDeepEquals.call(this, in_templatePrevious, in_template);\n if (!result.isEqual) {\n // Violates rule 3a.\n this._resultBuilder.addError(new Error(MSG.MODIFIED_TEMPLATE_SAME_VERSION_1 + result.path));\n }\n};\n\n/**\n * Validate a template\n * Check that the template is syntactically correct as well as semantically correct.\n * @param in_template - The template to check against.\n * Produces an {object|undefined} map of key-value pairs where the path of the invalid property is the key and the\n * value is the error message.\n *\n * i.e.\n *\n * ```\n * <pre>\n * {\n * 'isValid': true or false,\n * 'typeid': 'The typeid of the object being parsed',\n * 'unresolvedTypes': [ 'An array', 'of strong typeids', 'that were found',\n * 'in the document', 'but not resolved from the local cache' ],\n * 'resolvedTypes': [ 'Array of', 'strong types resolved', 'during template parsing'],\n * 'errors': [ 'Array of', 'objects describing', 'syntax errors in the template' ]\n * ...\n * }\n * </pre>\n * ```\n * @throws if context validation fails\n */\nconst _validateSemanticAndSyntax = function(in_template: PropertySchema) {\n _validateSyntax.call(this, in_template);\n _validateConstants.call(this, in_template);\n // TODO: _validateSemantic\n};\n\n/**\n * Validate a template\n * Check that the template is syntactically correct as well as semantically correct.\n * @param in_template - The template to check against\n * @return {Promise} a promise that resolved to nothing\n * @ignore\n */\nconst _validateSemanticAndSyntaxAsync = async function(in_template: PropertySchema): Promise<any> {\n return _validateSyntaxAsync.call(this, in_template);\n};\n\n/**\n * Validates that the semver part of a template's typeid is valid.\n * @param {Object} in_template - The template object to validate.\n * @return {string} The semver string. For example: '1.0.0'.\n * @private\n * @this TemplateValidator\n * @ignore\n */\nconst _validateSemverFormat = function(in_template) {\n const templateVersion = _getSemverFromTypeId.call(this, in_template.typeid);\n if (!templateVersion) {\n this._resultBuilder.addError(new Error(MSG.MISSING_VERSION + in_template.typeid));\n } else if (valid(templateVersion) !== templateVersion) {\n this._resultBuilder.addError(new Error(MSG.INVALID_VERSION_1 + templateVersion));\n }\n\n return templateVersion;\n};\n\n/**\n * Skip semver validation. Verify that the content is the same for both templates, while ignoring\n * the root 'typeid' property.\n * @param {Object} in_template - The latest template object.\n * @param {Object} in_templatePrevious - The previous template object.\n * @private\n * @this TemplateValidator\n */\nconst _validateSkipSemver = function(in_template, in_templatePrevious) {\n // Skipping the semver validation. Ignore the root typeid field.\n const result = _psetDeepEquals.call(this, in_template, in_templatePrevious);\n if (!result.isEqual) {\n // Violates rule 3a.\n this._resultBuilder.addError(new Error(MSG.MODIFIED_TEMPLATE_1 + result.path));\n }\n};\n\n/**\n * Checks if an invalid context error should be signified\n *\n * @param {String} in_context - The latest template object.\n * @return {Error|undefined} If exists returns the InvalidContext error\n * @private\n * @this TemplateValidator\n */\nconst getInvalidContextError = function(in_context) {\n if (in_context && !includes(VALID_CONTEXTS, in_context)) {\n return new Error(`${MSG.NOT_A_VALID_CONTEXT} ${in_context}`);\n }\n\n return undefined;\n};\n\n/**\n * Validate that the context is valid\n * Validate that only Named Properties are in sets\n * @param {object} in_template - The template to check against\n * @ignore\n * @throws if the context is invalid.\n */\nconst _validateContext = function(in_template) {\n const context = in_template.context;\n\n const error = getInvalidContextError(context);\n if (error) {\n throw error;\n }\n if (context === \"map\" && in_template.contextKeyType === \"typeid\") {\n throw new Error(MSG.INVALID_OPTION_NONE_CONSTANTS);\n }\n};\n\n/**\n * Validate just the syntax of a template\n * Check that the template is well-formed, according to the schema.\n * @param {object} in_template - The template to check against\n *\n * Context validation makes sure that elements of sets eventually inherit from NamedProperty.\n * If this is not the case, a promise rejection will occur with the appropriate error.\n * @return {Promise} promise that returns without any value and rejects in case of validation error\n * @ignore\n */\nconst _validateContextAsync = async function(in_template) {\n const that = this;\n const context = in_template.context;\n\n const error = getInvalidContextError(context);\n if (error) {\n return Promise.reject(error);\n }\n if (context === \"map\" && in_template.contextKeyType === \"typeid\") {\n return Promise.reject(new Error(MSG.INVALID_OPTION_NONE_CONSTANTS));\n }\n // If context is not 'set' validation doesn't apply\n if (context !== \"set\") {\n return Promise.resolve();\n }\n\n let typedValuePromises = [Promise.resolve()];\n if (in_template.typedValue) {\n typedValuePromises = map(in_template.typedValue, (tv) => that.inheritsFrom(tv.typeid, \"NamedProperty\"));\n } else {\n // Since context is 'set' the template must eventually inherit from NamedProperty\n if (in_template.inherits === undefined) {\n return Promise.reject(new Error(MSG.SET_ONLY_NAMED_PROPS));\n }\n\n // Since context is 'set' the template must eventually inherit from NamedProperty (same as above)\n if (includes(in_template.inherits, \"NamedProperty\") || in_template.inherits === \"NamedProperty\") {\n return Promise.resolve();\n }\n }\n const typedValuePromise = Promise.all(typedValuePromises);\n\n let parents = [];\n if (in_template.inherits) {\n parents = Array.isArray(in_template.inherits) ? in_template.inherits : [in_template.inherits];\n }\n const inheritsPromises = parents.map((typeid) => this._inheritsFromAsync(typeid, \"NamedProperty\"));\n\n // Combine results from inheritsPromises and typedValuePromise\n inheritsPromises.push(typedValuePromise);\n return Promise.all(inheritsPromises).then(function(results) {\n const foundNamedPropertyDescendant = find(results, (res) => res);\n if (!foundNamedPropertyDescendant) {\n return Promise.reject(Error(MSG.SET_ONLY_NAMED_PROPS));\n }\n\n return that._hasSchemaAsync(in_template.typeid);\n }).then(function(hasIt) {\n if (!hasIt) {\n return Promise.reject(new Error(MSG.SET_ONLY_NAMED_PROPS));\n }\n\n return that._inheritsFromAsync(in_template.typeid, \"NamedProperty\");\n }).then(async function(res) {\n if (res) {\n return undefined;\n }\n\n return Promise.reject(new Error(MSG.SET_ONLY_NAMED_PROPS));\n });\n};\n\n/**\n * Validate that the context is valid\n * Validate that only Named Properties are in sets\n * @param {object} in_template - The template to check against\n * @ignore\n * @throws if the context is invalid.\n */\nlet _validateConstants = function(in_template) {\n const that = this;\n if (in_template.constants && Array.isArray(in_template.constants)) {\n for (let i = 0; i < in_template.constants.length; i++) {\n const constant = in_template.constants[i];\n const context = constant.context;\n\n if (context === \"map\" && constant.contextKeyType === \"typeid\") {\n each(constant.value, function(value, key) {\n if (!TypeIdHelper.isTemplateTypeid(key)) {\n that._resultBuilder.addError(new Error(MSG.KEY_MUST_BE_TYPEID + key));\n }\n });\n }\n }\n }\n};\n\n/**\n * Analyze output of the syntax validation and build error messages\n *\n * @param in_template - The template that was analyzed\n */\nconst _processValidationResults = function(in_template: PropertySchema) {\n let that = this;\n let result = this._resultBuilder.result;\n\n result.isValid = _syntaxValidator(in_template);\n if (!result.isValid) {\n ConsoleUtils.assert(!isEmpty(_syntaxValidator.errors), \"template validation failed but produced no error\");\n }\n\n if (_syntaxValidator.errors) {\n each(_syntaxValidator.errors, function(error) {\n const regexTypeId = /typeid/;\n switch (error.keyword) {\n case \"pattern\":\n if (error.dataPath === \".typeid\") {\n error.message = `typeid should have a pattern like: my.example:point-1.0.0 ${error.data\n } does not match that pattern`;\n } else if (\"pattern\" && regexTypeId.test(error.dataPath)) {\n error.message = error.schemaPath === \"#/definitions/typed-reference-typeid/pattern\"\n ? \"\"\n : `${error.dataPath} should follow this pattern: <namespace>:<typeid>-<version> ` +\n `(for example: Sample:Rectangle-1.0.0) or match one of the Primitive Types (Float32, Float64, ` +\n `Int8, Uint8, Int16, Uint16, Int32, Uint32, Bool, String, Reference, Enum, Int64, Uint64) or ` +\n `Reserved Types (BaseProperty, NamedProperty, NodeProperty, NamedNodeProperty, ` +\n `RelationshipProperty). '${error.data}' is not valid`;\n }\n break;\n\n case \"enum\":\n error.message = regexTypeId.test(error.dataPath)\n ? \"\"\n : `${error.dataPath} should match one of the following: ${error.schema}`;\n break;\n\n case \"type\":\n error.message = `${error.dataPath} should be a ${error.schema}`;\n break;\n\n case \"not\":\n if (error.schemaPath === \"#/switch/1/then/anyOf/0/properties/typeid/not\") {\n // remove .typeid at the end of the dataPath\n error.message = `For ${error.dataPath.slice(0, -7)\n }: Properties should have either a typeid or an array of child properties, but not both.`;\n } else if (error.schemaPath === \"#/switch/1/then/anyOf/1/properties/properties/not\") {\n // remove .properties at the end of the dataPath\n error.message = `For ${error.dataPath.slice(0, -11)\n }: Properties should have either a typeid or an array of child properties, but not both.`;\n }\n break;\n\n // these errors do not add any information. All necessary information is in the 'enum' errors\n // empty errors will be filtered out before logging.\n case \"oneOf\":\n case \"anyOf\":\n error.message = \"\";\n break;\n\n // for minItems, required and any other error - add dataPath to indicate which part of the\n // template the error refers to.\n default:\n error.message = `${error.dataPath} ${error.message}`;\n break;\n }\n // Deep-copy for thread-safety.\n that._resultBuilder.addError(cloneDeep(error));\n });\n }\n\n result.unresolvedTypes = _unresolvedTypes.call(this, in_template);\n};\n\n/**\n * Validate just the syntax of a template\n * Check that the template is well-formed, according to the schema.\n * @param in_template - The template to check against\n * @throws if a property with context set is not an instance of NamedProperties\n * @ignore\n */\nlet _validateSyntax = function(in_template: PropertySchema) {\n const that = this;\n // recursively test all properties for context\n let recursiveContextCheck = function(template) {\n _validateContext.call(that, template);\n if (template.properties) {\n template.properties.forEach(function(property) {\n recursiveContextCheck(property);\n });\n }\n };\n\n recursiveContextCheck(in_template);\n\n _processValidationResults.call(this, in_template);\n\n const result = this._resultBuilder.result;\n result.unresolvedTypes = _unresolvedTypes.call(this, in_template);\n};\n\nconst createContextCheckAsyncQueue = function() {\n const that = this;\n const contextCheckWorker = function(in_task, in_callback) {\n const property = in_task.property;\n _validateContextAsync.call(that, property).then(function(response) {\n in_callback();\n }).catch(function(error) {\n in_callback({ error });\n });\n };\n // Async queue for schema context check tasks\n return queue(contextCheckWorker, 5);\n};\n\n/**\n * Validate just the syntax of a template\n * Check that the template is well-formed, according to the schema.\n *\n * @param in_template - The template to check against\n * Mainly checks context. See _validateContextAsync\n * @returns Promise that resolves without any result\n * @ignore\n */\nlet _validateSyntaxAsync = async function(in_template: PropertySchema): Promise<SchemaValidationResult> {\n const that = this;\n\n return new Promise(function(resolve, reject) {\n if (that.asyncValidationInProgress === true) {\n reject(new Error(MSG.CONTEXT_VALIDATION_IN_PROGRESS));\n return;\n }\n\n that.asyncValidationInProgress = true;\n\n const contextCheckAsyncQueue = createContextCheckAsyncQueue.call(that);\n\n // recursively test all properties for context\n let recursiveContextCheck = function(template) {\n // Does the call to _validateContextAsync\n contextCheckAsyncQueue.push({ property: template }, function(error) {\n if (error !== undefined) {\n reject(new Error(error));\n return;\n }\n });\n if (template.properties) {\n template.properties.forEach(function(property) {\n recursiveContextCheck(property);\n });\n }\n };\n recursiveContextCheck(in_template);\n\n contextCheckAsyncQueue.drain(\n function() {\n const result = that._resultBuilder.result;\n _processValidationResults.call(that, in_template);\n result.unresolvedTypes = _unresolvedTypes.call(that, in_template);\n\n that.asyncValidationInProgress = false;\n resolve(result);\n },\n );\n });\n};\n\nexport interface TemplateValidatorOptions {\n /**\n * When set to true, {@link #validate} only checks the supplied templates' content\n * and fails the validation if they're not identical. Defaults to false.\n */\n skipSemver?: boolean;\n /**\n * When set to true, the typeid of any schema can have '-draft' as a version. Defaults to false.\n */\n allowDraft?: boolean;\n /**\n * Function that checks if a template inherits from another.\n */\n inheritsFrom?: (source: PropertySchema, target: PropertySchema) => boolean;\n /**\n * Function that checks if we have a template matching a typeid.\n */\n hasSchema?: (schema: PropertySchema, typeid: string) => boolean;\n /**\n * Function that checks if a template inherits from another asynchronously.\n */\n inheritsFromAsync?: (source: PropertySchema, target: PropertySchema) => Promise<boolean>;\n /**\n * Function that checks if we have a template matching a typeid asynchronously.\n */\n hasSchemaAsync?: (schema: PropertySchema, typeid: string) => Promise<boolean>;\n\n}\n\nconst Utils = {\n psetDeepEquals(in_source: PropertySchema, in_target: PropertySchema) {\n return _psetDeepEquals.call(this, in_source, in_target).isEqual;\n },\n};\n\n/**\n * Instantiates a new TemplateValidator. Must be provided with a set of inheritsFrom and hasSchema\n * function or inheritsFromAsync and hasSchemaAsync, but not both.\n */\nexport class TemplateValidator {\n static Utils = Utils;\n private _resultBuilder: ValidationResultBuilder;\n public _inheritsFrom: (source: PropertySchema, target: PropertySchema) => boolean;\n public _hasSchema: (schema: PropertySchema, typeid: string) => boolean;\n public _inheritsFromAsync: (source: PropertySchema, target: PropertySchema) => Promise<boolean>;\n public _hasSchemaAsync: (schema: PropertySchema, typeid: string) => Promise<boolean>;\n private readonly _allowDraft: boolean;\n private readonly _skipSemver: boolean;\n constructor(in_params: TemplateValidatorOptions = { skipSemver: false, allowDraft: false }) {\n this._skipSemver = in_params ? !!in_params.skipSemver : false;\n this._allowDraft = in_params ? !!in_params.allowDraft : false;\n // Used by validate()\n if (in_params && in_params.inheritsFrom !== undefined && in_params.hasSchema !== undefined) {\n this._inheritsFrom = in_params.inheritsFrom;\n this._hasSchema = in_params.hasSchema;\n } else if (in_params && in_params.inheritsFromAsync !== undefined && in_params.hasSchemaAsync !== undefined) {\n this._inheritsFromAsync = in_params.inheritsFromAsync;\n this._hasSchemaAsync = in_params.hasSchemaAsync;\n } else {\n throw new Error(MSG.MISSING_INHERITSFROM_OR_HASSCHEMA);\n }\n }\n\n/**\n * Validates that all templates conform to the following mandatory rules:\n *\n * 1. Must have a typeid attribute.\n *\n * 2. typeid must end in a valid semver string.\n *\n * 3. When both in_template (B) and in_templatePrevious (A) are supplied:\n *\n * - 3a. Semver is identical only if content is identical.\n *\n * - 3b. B's semver >= A's semver\n *\n * Additionally, the following soft rules will produce warnings when violated:\n *\n * 3.5. Elements of sets must eventually inherit from 'NamedProperty'\n *\n * 4. PATCH revision should be increased when _only_ the template description changes.\n *\n * 5. Adding one or more template attributes is a MINOR change.\n *\n * 6. Removing one or more template attributes is a MAJOR change.\n *\n * @param in_template - The latest template version, as a JSON object.\n * @param in_templatePrevious - The previous template version, as a JSON object. Optional.\n * @returns The validation results. Example:\n *\n * ```json\n * {\n * isValid: false,\n * errors: ['Something went wrong. Validation failed.'],\n * warnings: ['A non-fatal warning'],\n * typeid: 'SomeNamespace:PointID-1.0.0'\n * }\n * ```\n *\n * It's possible for 'isValid' to be true while 'warnings' contains one or more messages.\n */\n validate(in_template: PropertySchema, in_templatePrevious?: PropertySchema): SchemaValidationResult {\n this._resultBuilder = new ValidationResultBuilder(in_template ? in_template.typeid : \"\");\n\n let isDraft = false;\n if (in_template && in_template.typeid &&\n TypeIdHelper.extractVersion(in_template.typeid).version === \"draft\") {\n if (this._allowDraft) {\n isDraft = true;\n } else {\n this._resultBuilder.addError(\n new Error(MSG.DRAFT_AS_VERSION_TYPEID),\n );\n }\n }\n\n _validateBasic.call(this, in_template);\n if (in_templatePrevious) {\n _validateBasic.call(this, in_templatePrevious);\n }\n\n // Basic validation (such as input params) must pass before the real validation can begin.\n if (!this._resultBuilder.isValid()) {\n return this._resultBuilder.result;\n }\n\n _validateSemanticAndSyntax.call(this, in_template);\n if (!this._resultBuilder.isValid() || isDraft) {\n return this._resultBuilder.result;\n }\n\n if (in_templatePrevious) {\n _validateSemanticAndSyntax.call(this, in_templatePrevious);\n if (!this._resultBuilder.isValid()) {\n // Here the previous template is not valid. Make sure the typeid in the returned info is\n // the root of the template that failed validation.\n this._resultBuilder.result.typeid = in_templatePrevious.typeid;\n return this._resultBuilder.result;\n }\n }\n\n if (this._skipSemver && in_templatePrevious) {\n _validateSkipSemver.call(this, in_template, in_templatePrevious);\n return this._resultBuilder.result;\n }\n\n // semver format validation\n const version = _validateSemverFormat.call(this, in_template);\n const versionPrevious =\n in_templatePrevious ? _validateSemverFormat.call(this, in_templatePrevious) : null;\n\n // semver format validation must pass.\n if (!this._resultBuilder.isValid()) {\n return this._resultBuilder.result;\n }\n\n if (in_templatePrevious) {\n // Validate that the semver change is valid.\n switch (compare(version, versionPrevious)) {\n case 0:\n _validateSameVersion.call(this, in_template, in_templatePrevious);\n break;\n case 1:\n // newVersion is greater\n _validatePositiveIncrement.call(this, in_template, in_templatePrevious, version, versionPrevious);\n break;\n default:\n case -1:\n // previousVersion is greater. Violates rule 3b.\n this._resultBuilder.addError(\n new Error(MSG.VERSION_REGRESSION_1 + JSON.stringify({\n current: version,\n previous: versionPrevious,\n })),\n );\n break;\n }\n }\n\n return this._resultBuilder.result;\n }\n\n /**\n * Validates that all templates conform to the following mandatory rules:\n *\n * 1. Must have a typeid attribute.\n *\n * 2. typeid must end in a valid semver string.\n *\n * 3. When both in_template (B) and in_templatePrevious (A) are supplied:\n *\n * - 3a. Semver is identical only if content is identical.\n *\n * - 3b. B's semver >= A's semver\n *\n * Additionally, the following soft rules will produce warnings when violated:\n *\n * 3.5. Elements of sets must eventually inherit from 'NamedProperty'\n *\n * 4. PATCH revision should be increased when _only_ the template description changes.\n *\n * 5. Adding one or more template attributes is a MINOR change.\n *\n * 6. Removing one or more template attributes is a MAJOR change.\n *\n * @param in_template - The latest template version, as a JSON object.\n * @param in_templatePrevious - The previous template version, as a JSON object. Optional.\n * @returns A promise that resolves to the validation results as an object. Example:\n *\n * ```json\n * {\n * isValid: false,\n * errors: ['Something went wrong. Validation failed.'],\n * warnings: ['A non-fatal warning'],\n * typeid: 'SomeNamespace:PointID-1.0.0'\n * }\n * ```\n *\n * It's possible for 'isValid' to be true while 'warnings' contains one or more messages.\n */\n async validateAsync(in_template: PropertySchema, in_templatePrevious?: PropertySchema): Promise<SchemaValidationResult> {\n this._resultBuilder = new ValidationResultBuilder(in_template ? in_template.typeid : \"\");\n _validateBasic.call(this, in_template);\n if (in_templatePrevious) {\n _validateBasic.call(this, in_templatePrevious);\n }\n if (!this._resultBuilder.isValid()) {\n return Promise.resolve(this._resultBuilder.result);\n }\n return (in_templatePrevious) ?\n this._validateAsyncWithPreviousSchema(in_template, in_templatePrevious) :\n _validateSemanticAndSyntaxAsync.call(this, in_template);\n }\n\n /**\n * Called by validateAsync if a previous schema is passed in argument\n *\n * @param in_template - The latest template version, as a JSON object.\n * @param in_templatePrevious - The previous template version, as a JSON object. Optional.\n *\n * @returns promise that resolves to the validation results as an objet. See validateAsync\n * @ignore\n */\n private async _validateAsyncWithPreviousSchema(in_template: PropertySchema, in_templatePrevious: PropertySchema): Promise<SchemaValidationResult> {\n const that = this;\n return _validateSemanticAndSyntaxAsync.call(that, in_template).then(() => _validateSemanticAndSyntaxAsync.call(that, in_templatePrevious)).then(function() {\n if (!that._resultBuilder.isValid()) {\n // Here the previous template is not valid. Make sure the typeid in the returned info is\n // the root of the template that failed validation.\n that._resultBuilder.result.typeid = in_templatePrevious.typeid;\n }\n\n if (that._skipSemver && in_templatePrevious) {\n _validateSkipSemver.call(that, in_template, in_templatePrevious);\n }\n\n const version = _validateSemverFormat.call(that, in_template);\n const versionPrevious = in_templatePrevious ? _validateSemverFormat.call(that, in_templatePrevious) : null;\n\n // Validate that the semver change is valid.\n switch (compare(version, versionPrevious)) {\n case 0:\n _validateSameVersion.call(that, in_template, in_templatePrevious);\n break;\n case 1:\n // newVersion is greater\n _validatePositiveIncrement.call(that, in_template, in_templatePrevious, version, versionPrevious);\n break;\n default:\n case -1:\n // previousVersion is greater. Violates rule 3b.\n that._resultBuilder.addError(\n new Error(MSG.VERSION_REGRESSION_1 + JSON.stringify({\n current: version,\n previous: versionPrevious,\n })),\n );\n break;\n }\n\n return that._resultBuilder.result;\n });\n }\n}\n"]}
|
package/dist/test/array.spec.js
CHANGED
|
@@ -7,7 +7,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
7
7
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
8
|
};
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
/* eslint-disable no-unused-expressions */
|
|
11
10
|
/**
|
|
12
11
|
* @fileoverview Tests for the array changeset operations
|
|
13
12
|
*/
|
|
@@ -666,7 +665,7 @@ describe("Array Operations", function () {
|
|
|
666
665
|
for (const additionalInserts of ["", " with insert at the beginning", " with insert at the end"]) {
|
|
667
666
|
const offset = additionalInserts === " with insert at the beginning" ? 2 : 0;
|
|
668
667
|
for (const i of (0, range_1.default)(1, 9)) {
|
|
669
|
-
it(`at
|
|
668
|
+
it(`at position ${i + offset}${additionalInserts}`, () => {
|
|
670
669
|
const initial = createArrayCS({
|
|
671
670
|
insert: [
|
|
672
671
|
[0, generateNamedEntities(10, undefined, "number")],
|