@itwin/ecschema-locaters 5.0.0-dev.11 → 5.0.0-dev.111
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/CHANGELOG.md +71 -1
- package/lib/cjs/SchemaFileLocater.d.ts +23 -8
- package/lib/cjs/SchemaFileLocater.d.ts.map +1 -1
- package/lib/cjs/SchemaFileLocater.js +23 -11
- package/lib/cjs/SchemaFileLocater.js.map +1 -1
- package/lib/cjs/SchemaJsonFileLocater.d.ts +4 -3
- package/lib/cjs/SchemaJsonFileLocater.d.ts.map +1 -1
- package/lib/cjs/SchemaJsonFileLocater.js +4 -3
- package/lib/cjs/SchemaJsonFileLocater.js.map +1 -1
- package/lib/cjs/SchemaStringLocater.d.ts +2 -2
- package/lib/cjs/SchemaStringLocater.d.ts.map +1 -1
- package/lib/cjs/SchemaStringLocater.js +12 -9
- package/lib/cjs/SchemaStringLocater.js.map +1 -1
- package/lib/cjs/SchemaXml.d.ts +1 -1
- package/lib/cjs/SchemaXml.js +1 -1
- package/lib/cjs/SchemaXml.js.map +1 -1
- package/lib/cjs/SchemaXmlFileLocater.d.ts +31 -3
- package/lib/cjs/SchemaXmlFileLocater.d.ts.map +1 -1
- package/lib/cjs/SchemaXmlFileLocater.js +46 -4
- package/lib/cjs/SchemaXmlFileLocater.js.map +1 -1
- package/lib/cjs/SchemaXmlStringLocater.d.ts +2 -2
- package/lib/cjs/SchemaXmlStringLocater.d.ts.map +1 -1
- package/lib/cjs/SchemaXmlStringLocater.js +4 -4
- package/lib/cjs/SchemaXmlStringLocater.js.map +1 -1
- package/lib/cjs/StubSchemaXmlFileLocater.d.ts +2 -2
- package/lib/cjs/StubSchemaXmlFileLocater.d.ts.map +1 -1
- package/lib/cjs/StubSchemaXmlFileLocater.js +9 -9
- package/lib/cjs/StubSchemaXmlFileLocater.js.map +1 -1
- package/lib/cjs/ecschema-locaters.js.map +1 -1
- package/lib/cjs/test/ConcurrentGetSchemaJson.test.js.map +1 -1
- package/lib/cjs/test/ConcurrentGetSchemaXml.test.js.map +1 -1
- package/lib/cjs/test/SchemaJsonFileLocator.test.js +2 -2
- package/lib/cjs/test/SchemaJsonFileLocator.test.js.map +1 -1
- package/lib/cjs/test/SchemaXml.test.js.map +1 -1
- package/lib/cjs/test/SchemaXmlFileLocator.test.js +12 -9
- package/lib/cjs/test/SchemaXmlFileLocator.test.js.map +1 -1
- package/lib/cjs/test/SchemaXmlStringLocater.test.js +9 -9
- package/lib/cjs/test/SchemaXmlStringLocater.test.js.map +1 -1
- package/lib/cjs/test/StubSchemaXmlFileLocater.test.js +9 -8
- package/lib/cjs/test/StubSchemaXmlFileLocater.test.js.map +1 -1
- package/lib/esm/SchemaFileLocater.d.ts +101 -0
- package/lib/esm/SchemaFileLocater.d.ts.map +1 -0
- package/lib/esm/SchemaFileLocater.js +220 -0
- package/lib/esm/SchemaFileLocater.js.map +1 -0
- package/lib/esm/SchemaJsonFileLocater.d.ts +43 -0
- package/lib/esm/SchemaJsonFileLocater.d.ts.map +1 -0
- package/lib/esm/SchemaJsonFileLocater.js +97 -0
- package/lib/esm/SchemaJsonFileLocater.js.map +1 -0
- package/lib/esm/SchemaStringLocater.d.ts +54 -0
- package/lib/esm/SchemaStringLocater.d.ts.map +1 -0
- package/lib/esm/SchemaStringLocater.js +83 -0
- package/lib/esm/SchemaStringLocater.js.map +1 -0
- package/lib/esm/SchemaXml.d.ts +22 -0
- package/lib/esm/SchemaXml.d.ts.map +1 -0
- package/lib/esm/SchemaXml.js +55 -0
- package/lib/esm/SchemaXml.js.map +1 -0
- package/lib/esm/SchemaXmlFileLocater.d.ts +70 -0
- package/lib/esm/SchemaXmlFileLocater.d.ts.map +1 -0
- package/lib/esm/SchemaXmlFileLocater.js +140 -0
- package/lib/esm/SchemaXmlFileLocater.js.map +1 -0
- package/lib/esm/SchemaXmlStringLocater.d.ts +48 -0
- package/lib/esm/SchemaXmlStringLocater.d.ts.map +1 -0
- package/lib/esm/SchemaXmlStringLocater.js +100 -0
- package/lib/esm/SchemaXmlStringLocater.js.map +1 -0
- package/lib/esm/StubSchemaXmlFileLocater.d.ts +81 -0
- package/lib/esm/StubSchemaXmlFileLocater.d.ts.map +1 -0
- package/lib/esm/StubSchemaXmlFileLocater.js +184 -0
- package/lib/esm/StubSchemaXmlFileLocater.js.map +1 -0
- package/lib/esm/ecschema-locaters.d.ts +20 -0
- package/lib/esm/ecschema-locaters.d.ts.map +1 -0
- package/lib/esm/ecschema-locaters.js +24 -0
- package/lib/esm/ecschema-locaters.js.map +1 -0
- package/lib/esm/test/ConcurrentGetSchemaJson.test.d.ts +2 -0
- package/lib/esm/test/ConcurrentGetSchemaJson.test.d.ts.map +1 -0
- package/lib/esm/test/ConcurrentGetSchemaJson.test.js +249 -0
- package/lib/esm/test/ConcurrentGetSchemaJson.test.js.map +1 -0
- package/lib/esm/test/ConcurrentGetSchemaXml.test.d.ts +2 -0
- package/lib/esm/test/ConcurrentGetSchemaXml.test.d.ts.map +1 -0
- package/lib/esm/test/ConcurrentGetSchemaXml.test.js +186 -0
- package/lib/esm/test/ConcurrentGetSchemaXml.test.js.map +1 -0
- package/lib/esm/test/SchemaJsonFileLocator.test.d.ts +2 -0
- package/lib/esm/test/SchemaJsonFileLocator.test.d.ts.map +1 -0
- package/lib/esm/test/SchemaJsonFileLocator.test.js +118 -0
- package/lib/esm/test/SchemaJsonFileLocator.test.js.map +1 -0
- package/lib/esm/test/SchemaXml.test.d.ts +2 -0
- package/lib/esm/test/SchemaXml.test.d.ts.map +1 -0
- package/lib/esm/test/SchemaXml.test.js +55 -0
- package/lib/esm/test/SchemaXml.test.js.map +1 -0
- package/lib/esm/test/SchemaXmlFileLocator.test.d.ts +2 -0
- package/lib/esm/test/SchemaXmlFileLocator.test.d.ts.map +1 -0
- package/lib/esm/test/SchemaXmlFileLocator.test.js +182 -0
- package/lib/esm/test/SchemaXmlFileLocator.test.js.map +1 -0
- package/lib/esm/test/SchemaXmlStringLocater.test.d.ts +2 -0
- package/lib/esm/test/SchemaXmlStringLocater.test.d.ts.map +1 -0
- package/lib/esm/test/SchemaXmlStringLocater.test.js +219 -0
- package/lib/esm/test/SchemaXmlStringLocater.test.js.map +1 -0
- package/lib/esm/test/StubSchemaXmlFileLocater.test.d.ts +2 -0
- package/lib/esm/test/StubSchemaXmlFileLocater.test.d.ts.map +1 -0
- package/lib/esm/test/StubSchemaXmlFileLocater.test.js +170 -0
- package/lib/esm/test/StubSchemaXmlFileLocater.test.js.map +1 -0
- package/package.json +14 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaXmlFileLocater.d.ts","sourceRoot":"","sources":["../../src/SchemaXmlFileLocater.ts"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"SchemaXmlFileLocater.d.ts","sourceRoot":"","sources":["../../src/SchemaXmlFileLocater.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EACqC,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,eAAe,EACxH,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAiB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGvE;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,iBAAkB,YAAW,cAAc;IACnF;;;;;;OAMG;IACU,SAAS,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAOvH;;;;;;QAMI;IACS,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IA2BrI;;;;;;OAMG;IACI,aAAa,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS;IA4B5G;;;OAGG;IACI,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS;CAa7C;AAED;;;;;;;;GAQG;AACH,qBAAa,6BAA8B,SAAQ,oBAAqB,YAAW,cAAc;IAC/F;;;OAGG;gBACgB,qBAAqB,EAAE,MAAM;IAWhD;;;;OAIG;IACa,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAI9D;;;;OAIG;IACa,oBAAoB,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,IAAI;CAGnE"}
|
|
@@ -7,15 +7,17 @@
|
|
|
7
7
|
* @module Locaters
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.SchemaXmlFileLocater = void 0;
|
|
10
|
+
exports.PublishedSchemaXmlFileLocater = exports.SchemaXmlFileLocater = void 0;
|
|
11
11
|
const path = require("path");
|
|
12
|
+
const fs = require("fs");
|
|
12
13
|
const xmldom_1 = require("@xmldom/xmldom");
|
|
13
14
|
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
14
15
|
const SchemaFileLocater_1 = require("./SchemaFileLocater");
|
|
16
|
+
const glob_1 = require("glob");
|
|
15
17
|
/**
|
|
16
18
|
* A SchemaLocater implementation for locating XML Schema files
|
|
17
19
|
* from the file system using configurable search paths.
|
|
18
|
-
* @
|
|
20
|
+
* @public @preview This is a workaround the current lack of a full xml parser.
|
|
19
21
|
*/
|
|
20
22
|
class SchemaXmlFileLocater extends SchemaFileLocater_1.SchemaFileLocater {
|
|
21
23
|
/**
|
|
@@ -90,14 +92,54 @@ class SchemaXmlFileLocater extends SchemaFileLocater_1.SchemaFileLocater {
|
|
|
90
92
|
getSchemaKey(data) {
|
|
91
93
|
const matches = data.match(/<ECSchema ([^]+?)>/g);
|
|
92
94
|
if (!matches || matches.length !== 1)
|
|
93
|
-
throw new ecschema_metadata_1.
|
|
95
|
+
throw new ecschema_metadata_1.ECSchemaError(ecschema_metadata_1.ECSchemaStatus.InvalidSchemaXML, `Could not find '<ECSchema>' tag in the given file`);
|
|
94
96
|
const name = matches[0].match(/schemaName="(.+?)"/);
|
|
95
97
|
const version = matches[0].match(/version="(.+?)"/);
|
|
96
98
|
if (!name || name.length !== 2 || !version || version.length !== 2)
|
|
97
|
-
throw new ecschema_metadata_1.
|
|
99
|
+
throw new ecschema_metadata_1.ECSchemaError(ecschema_metadata_1.ECSchemaStatus.InvalidSchemaXML, `Could not find the ECSchema 'schemaName' or 'version' tag in the given file`);
|
|
98
100
|
const key = new ecschema_metadata_1.SchemaKey(name[1], ecschema_metadata_1.ECVersion.fromString(version[1]));
|
|
99
101
|
return key;
|
|
100
102
|
}
|
|
101
103
|
}
|
|
102
104
|
exports.SchemaXmlFileLocater = SchemaXmlFileLocater;
|
|
105
|
+
/**
|
|
106
|
+
* This locater is responsible for locating standard schema files that are released by the core-backend package.
|
|
107
|
+
* The locater needs an argument to the known backend assets directory where the core-backend package is installed.
|
|
108
|
+
* This can be accessed by the KnownLocations.nativeAssetsDir getter provided by core-backend.
|
|
109
|
+
*
|
|
110
|
+
* @note This locater is read-only and does not allow adding new schema search paths.
|
|
111
|
+
* @note This locater should be used as a fallback/last chance locater in the schema context as any user defined schema should have higher precedence over the standard schema.
|
|
112
|
+
* @public @preview This is a workaround due to the current lack of a full xml parser.
|
|
113
|
+
*/
|
|
114
|
+
class PublishedSchemaXmlFileLocater extends SchemaXmlFileLocater {
|
|
115
|
+
/**
|
|
116
|
+
* Constructs a new PublishedSchemaXmlFileLocater
|
|
117
|
+
* @param knownBackendAssetsDir The assets directory where the core-backend package is installed. Can be accessed by the KnownLocations.nativeAssetsDir getter provided by core-backend.
|
|
118
|
+
*/
|
|
119
|
+
constructor(knownBackendAssetsDir) {
|
|
120
|
+
super();
|
|
121
|
+
const ecSchemaDir = path.join(knownBackendAssetsDir, "ECSchemas");
|
|
122
|
+
if (!fs.existsSync(ecSchemaDir))
|
|
123
|
+
throw new Error(`The directory ${ecSchemaDir} containing standard schemas does not exist.`);
|
|
124
|
+
// Pre-defined set of standard schema search paths
|
|
125
|
+
this.searchPaths.push(...(0, glob_1.globSync)(path.join(ecSchemaDir, "*/"), { windowsPathsNoEscape: true }).filter(fs.existsSync));
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Overrides the addSchemaSearchPath method to prevent adding new schema search paths.
|
|
129
|
+
*
|
|
130
|
+
* @param _schemaPath - The schema path to add (ignored).
|
|
131
|
+
*/
|
|
132
|
+
addSchemaSearchPath(_schemaPath) {
|
|
133
|
+
return; // Do nothing, this is a read-only locator
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Overrides the addSchemaSearchPaths method to prevent adding new schema search paths.
|
|
137
|
+
*
|
|
138
|
+
* @param _schemaPaths - The schema paths to add (ignored).
|
|
139
|
+
*/
|
|
140
|
+
addSchemaSearchPaths(_schemaPaths) {
|
|
141
|
+
return; // Do nothing, this is a read-only locator
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
exports.PublishedSchemaXmlFileLocater = PublishedSchemaXmlFileLocater;
|
|
103
145
|
//# sourceMappingURL=SchemaXmlFileLocater.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaXmlFileLocater.js","sourceRoot":"","sources":["../../src/SchemaXmlFileLocater.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,6BAA6B;AAC7B,2CAA2C;AAC3C,gEAEkC;AAClC,2DAAuE;AAEvE;;;;GAIG;AACH,MAAa,oBAAqB,SAAQ,qCAAiB;IACzD;;;;;;OAMG;IACI,KAAK,CAAC,SAAS,CAAmB,GAAc,EAAE,SAA0B,EAAE,OAAsB;QACzG,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QAElD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,eAAe,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QAC7D,OAAO,MAAW,CAAC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O,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACpD,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAChE,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,gBAAgB,EAAE,6EAA6E,CAAC,CAAC;QAE5I,MAAM,GAAG,GAAG,IAAI,6BAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,6BAAS,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACrE,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AArGD,oDAqGC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Locaters\r\n */\r\n\r\nimport * as path from \"path\";\r\nimport { DOMParser } from \"@xmldom/xmldom\";\r\nimport {\r\n ECObjectsError, ECObjectsStatus, ECVersion, ISchemaLocater, Schema, SchemaContext, SchemaInfo, SchemaKey, SchemaMatchType, SchemaReadHelper, XmlParser,\r\n} from \"@itwin/ecschema-metadata\";\r\nimport { FileSchemaKey, SchemaFileLocater } from \"./SchemaFileLocater\";\r\n\r\n/**\r\n * A SchemaLocater implementation for locating XML Schema files\r\n * from the file system using configurable search paths.\r\n * @beta This is a workaround the current lack of a full xml parser.\r\n */\r\nexport class SchemaXmlFileLocater extends SchemaFileLocater implements ISchemaLocater {\r\n /**\r\n * Attempts to retrieve a Schema with the given SchemaKey by using the configured search paths\r\n * to locate the XML Schema file from the file system.\r\n * @param key The SchemaKey of the Schema to retrieve.\r\n * @param matchType The SchemaMatchType.\r\n * @param context The SchemaContext that will control the lifetime of the schema.\r\n */\r\n public async getSchema<T extends Schema>(key: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<T | undefined> {\r\n await this.getSchemaInfo(key, matchType, context);\r\n\r\n const schema = await context.getCachedSchema(key, matchType);\r\n return schema as T;\r\n }\r\n\r\n /**\r\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\r\n * The fully loaded schema can be gotten later from the context using the getCachedSchema method.\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n * @param context The SchemaContext that will control the lifetime of the schema and holds the schema's references, if they exist.\r\n */\r\n public async getSchemaInfo(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined> {\r\n const candidates: FileSchemaKey[] = this.findEligibleSchemaKeys(schemaKey, matchType, \"xml\");\r\n\r\n if (0 === candidates.length)\r\n return undefined;\r\n\r\n const maxCandidate = candidates.sort(this.compareSchemaKeyByVersion)[candidates.length - 1];\r\n const schemaPath = maxCandidate.fileName;\r\n\r\n // Load the file\r\n if (undefined === await this.fileExists(schemaPath))\r\n return undefined;\r\n\r\n const schemaText = await this.readUtf8FileToString(schemaPath);\r\n if (undefined === schemaText)\r\n return undefined;\r\n\r\n const parser = new DOMParser();\r\n const document = parser.parseFromString(schemaText);\r\n\r\n this.addSchemaSearchPaths([path.dirname(schemaPath)]);\r\n const reader = new SchemaReadHelper(XmlParser, context);\r\n const schema = new Schema(context);\r\n\r\n return reader.readSchemaInfo(schema, document);\r\n }\r\n\r\n /**\r\n * Attempts to retrieve a Schema with the given SchemaKey by using the configured search paths\r\n * to locate the XML Schema file from the file system.\r\n * @param key The SchemaKey of the Schema to retrieve.\r\n * @param matchType The SchemaMatchType.\r\n * @param context The SchemaContext that will control the lifetime of the schema.\r\n */\r\n public getSchemaSync<T extends Schema>(key: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): T | undefined {\r\n const candidates: FileSchemaKey[] = this.findEligibleSchemaKeys(key, matchType, \"xml\");\r\n\r\n if (!candidates || candidates.length === 0)\r\n return undefined;\r\n\r\n const maxCandidate = candidates.sort(this.compareSchemaKeyByVersion)[candidates.length - 1];\r\n const schemaPath = maxCandidate.fileName;\r\n\r\n // Load the file\r\n if (!this.fileExistsSync(schemaPath))\r\n return undefined;\r\n\r\n const schemaText = this.readUtf8FileToStringSync(schemaPath);\r\n if (!schemaText)\r\n return undefined;\r\n\r\n const parser = new DOMParser();\r\n const document = parser.parseFromString(schemaText);\r\n\r\n this.addSchemaSearchPaths([path.dirname(schemaPath)]);\r\n const reader = new SchemaReadHelper(XmlParser, context);\r\n let schema: Schema = new Schema(context);\r\n schema = reader.readSchemaSync(schema, document);\r\n\r\n return schema as T;\r\n }\r\n\r\n /**\r\n * Constructs a SchemaKey based on the information in the Schema XML.\r\n * @param data The Schema XML as a string.\r\n */\r\n public getSchemaKey(data: string): SchemaKey {\r\n const matches = data.match(/<ECSchema ([^]+?)>/g);\r\n if (!matches || matches.length !== 1)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaXML, `Could not find '<ECSchema>' tag in the given file`);\r\n\r\n const name = matches[0].match(/schemaName=\"(.+?)\"/);\r\n const version = matches[0].match(/version=\"(.+?)\"/);\r\n if (!name || name.length !== 2 || !version || version.length !== 2)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaXML, `Could not find the ECSchema 'schemaName' or 'version' tag in the given file`);\r\n\r\n const key = new SchemaKey(name[1], ECVersion.fromString(version[1]));\r\n return key;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"SchemaXmlFileLocater.js","sourceRoot":"","sources":["../../src/SchemaXmlFileLocater.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,6BAA6B;AAC7B,yBAAyB;AACzB,2CAA2C;AAC3C,gEAEkC;AAClC,2DAAuE;AACvE,+BAAgC;AAEhC;;;;GAIG;AACH,M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,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IACzH,CAAC;IAED;;;;OAIG;IACa,mBAAmB,CAAC,WAAmB;QACrD,OAAO,CAAC,0CAA0C;IACpD,CAAC;IAED;;;;OAIG;IACa,oBAAoB,CAAC,YAAsB;QACzD,OAAO,CAAC,0CAA0C;IACpD,CAAC;CACF;AAjCD,sEAiCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Locaters\n */\n\nimport * as path from \"path\";\nimport * as fs from \"fs\";\nimport { DOMParser } from \"@xmldom/xmldom\";\nimport {\n ECSchemaError, ECSchemaStatus, ECVersion, ISchemaLocater, Schema, SchemaContext, SchemaInfo, SchemaKey, SchemaMatchType, SchemaReadHelper, XmlParser,\n} from \"@itwin/ecschema-metadata\";\nimport { FileSchemaKey, SchemaFileLocater } from \"./SchemaFileLocater\";\nimport { globSync } from \"glob\";\n\n/**\n * A SchemaLocater implementation for locating XML Schema files\n * from the file system using configurable search paths.\n * @public @preview This is a workaround the current lack of a full xml parser.\n */\nexport class SchemaXmlFileLocater extends SchemaFileLocater implements ISchemaLocater {\n /**\n * Attempts to retrieve a Schema with the given SchemaKey by using the configured search paths\n * to locate the XML Schema file from the file system.\n * @param key The SchemaKey of the Schema to retrieve.\n * @param matchType The SchemaMatchType.\n * @param context The SchemaContext that will control the lifetime of the schema.\n */\n public async getSchema(key: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<Schema | undefined> {\n await this.getSchemaInfo(key, matchType, context);\n\n const schema = await context.getCachedSchema(key, matchType);\n return schema;\n }\n\n /**\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\n * The fully loaded schema can be gotten later from the context using the getCachedSchema method.\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\n * @param matchType The match type to use when locating the schema\n * @param context The SchemaContext that will control the lifetime of the schema and holds the schema's references, if they exist.\n */\n public async getSchemaInfo(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined> {\n const candidates: FileSchemaKey[] = this.findEligibleSchemaKeys(schemaKey, matchType, \"xml\");\n\n if (0 === candidates.length)\n return undefined;\n\n const maxCandidate = candidates.sort(this.compareSchemaKeyByVersion)[candidates.length - 1];\n const schemaPath = maxCandidate.fileName;\n\n // Load the file\n if (undefined === await this.fileExists(schemaPath))\n return undefined;\n\n const schemaText = await this.readUtf8FileToString(schemaPath);\n if (undefined === schemaText)\n return undefined;\n\n const parser = new DOMParser();\n const document = parser.parseFromString(schemaText);\n\n this.addSchemaSearchPaths([path.dirname(schemaPath)]);\n const reader = new SchemaReadHelper(XmlParser, context);\n const schema = new Schema(context);\n\n return reader.readSchemaInfo(schema, document);\n }\n\n /**\n * Attempts to retrieve a Schema with the given SchemaKey by using the configured search paths\n * to locate the XML Schema file from the file system.\n * @param key The SchemaKey of the Schema to retrieve.\n * @param matchType The SchemaMatchType.\n * @param context The SchemaContext that will control the lifetime of the schema.\n */\n public getSchemaSync(key: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Schema | undefined {\n const candidates: FileSchemaKey[] = this.findEligibleSchemaKeys(key, matchType, \"xml\");\n\n if (!candidates || candidates.length === 0)\n return undefined;\n\n const maxCandidate = candidates.sort(this.compareSchemaKeyByVersion)[candidates.length - 1];\n const schemaPath = maxCandidate.fileName;\n\n // Load the file\n if (!this.fileExistsSync(schemaPath))\n return undefined;\n\n const schemaText = this.readUtf8FileToStringSync(schemaPath);\n if (!schemaText)\n return undefined;\n\n const parser = new DOMParser();\n const document = parser.parseFromString(schemaText);\n\n this.addSchemaSearchPaths([path.dirname(schemaPath)]);\n const reader = new SchemaReadHelper(XmlParser, context);\n let schema: Schema = new Schema(context);\n schema = reader.readSchemaSync(schema, document);\n\n return schema;\n }\n\n /**\n * Constructs a SchemaKey based on the information in the Schema XML.\n * @param data The Schema XML as a string.\n */\n public getSchemaKey(data: string): SchemaKey {\n const matches = data.match(/<ECSchema ([^]+?)>/g);\n if (!matches || matches.length !== 1)\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Could not find '<ECSchema>' tag in the given file`);\n\n const name = matches[0].match(/schemaName=\"(.+?)\"/);\n const version = matches[0].match(/version=\"(.+?)\"/);\n if (!name || name.length !== 2 || !version || version.length !== 2)\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Could not find the ECSchema 'schemaName' or 'version' tag in the given file`);\n\n const key = new SchemaKey(name[1], ECVersion.fromString(version[1]));\n return key;\n }\n}\n\n/**\n * This locater is responsible for locating standard schema files that are released by the core-backend package.\n * The locater needs an argument to the known backend assets directory where the core-backend package is installed.\n * This can be accessed by the KnownLocations.nativeAssetsDir getter provided by core-backend.\n *\n * @note This locater is read-only and does not allow adding new schema search paths.\n * @note This locater should be used as a fallback/last chance locater in the schema context as any user defined schema should have higher precedence over the standard schema.\n * @public @preview This is a workaround due to the current lack of a full xml parser.\n */\nexport class PublishedSchemaXmlFileLocater extends SchemaXmlFileLocater implements ISchemaLocater {\n /**\n * Constructs a new PublishedSchemaXmlFileLocater\n * @param knownBackendAssetsDir The assets directory where the core-backend package is installed. Can be accessed by the KnownLocations.nativeAssetsDir getter provided by core-backend.\n */\n public constructor(knownBackendAssetsDir: string) {\n super();\n\n const ecSchemaDir = path.join(knownBackendAssetsDir, \"ECSchemas\");\n if (!fs.existsSync(ecSchemaDir))\n throw new Error(`The directory ${ecSchemaDir} containing standard schemas does not exist.`);\n\n // Pre-defined set of standard schema search paths\n this.searchPaths.push(...globSync(path.join(ecSchemaDir, \"*/\"), { windowsPathsNoEscape: true }).filter(fs.existsSync));\n }\n\n /**\n * Overrides the addSchemaSearchPath method to prevent adding new schema search paths.\n *\n * @param _schemaPath - The schema path to add (ignored).\n */\n public override addSchemaSearchPath(_schemaPath: string): void {\n return; // Do nothing, this is a read-only locator\n }\n\n /**\n * Overrides the addSchemaSearchPaths method to prevent adding new schema search paths.\n *\n * @param _schemaPaths - The schema paths to add (ignored).\n */\n public override addSchemaSearchPaths(_schemaPaths: string[]): void {\n return; // Do nothing, this is a read-only locator\n }\n}\n"]}
|
|
@@ -21,7 +21,7 @@ export declare class SchemaXmlStringLocater extends SchemaStringLocater implemen
|
|
|
21
21
|
* @param matchType The SchemaMatchType.
|
|
22
22
|
* @param context The SchemaContext that will control the lifetime of the schema and holds the schema's references, if they exist.
|
|
23
23
|
*/
|
|
24
|
-
getSchema
|
|
24
|
+
getSchema(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<Schema | undefined>;
|
|
25
25
|
/**
|
|
26
26
|
* Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.
|
|
27
27
|
* The fully loaded schema can be gotten later from the context using the getCachedSchema method.
|
|
@@ -37,7 +37,7 @@ export declare class SchemaXmlStringLocater extends SchemaStringLocater implemen
|
|
|
37
37
|
* @param matchType The SchemaMatchType.
|
|
38
38
|
* @param context The SchemaContext that will control the lifetime of the schema and holds the schema's references, if they exist.
|
|
39
39
|
*/
|
|
40
|
-
getSchemaSync
|
|
40
|
+
getSchemaSync(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Schema | undefined;
|
|
41
41
|
/**
|
|
42
42
|
* Parses a valid EC 2.0 version string and returns an ECVersion object. The second digit becomes the minor version,
|
|
43
43
|
* and a zero is inserted as the 'write' digit. Example: "1.1" -> "1.0.1".
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaXmlStringLocater.d.ts","sourceRoot":"","sources":["../../src/SchemaXmlStringLocater.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"SchemaXmlStringLocater.d.ts","sourceRoot":"","sources":["../../src/SchemaXmlStringLocater.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EACqC,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,eAAe,EACxH,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAmB,MAAM,uBAAuB,CAAC;AAE7E;;;;GAIG;AACH,qBAAa,sBAAuB,SAAQ,mBAAoB,YAAW,cAAc;IAEvF;;;OAGG;IACI,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS;IAejD;;;;;;OAMG;IACU,SAAS,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAO7H;;;;;;QAMI;IACS,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAkBrI;;;;;;OAMG;IACI,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS;IAmBlH;;;;OAIG;IACH,OAAO,CAAC,cAAc;CAYvB"}
|
|
@@ -24,11 +24,11 @@ class SchemaXmlStringLocater extends SchemaStringLocater_1.SchemaStringLocater {
|
|
|
24
24
|
getSchemaKey(schemaXml) {
|
|
25
25
|
const matches = schemaXml.match(/<ECSchema ([^]+?)>/g);
|
|
26
26
|
if (!matches || matches.length !== 1)
|
|
27
|
-
throw new ecschema_metadata_1.
|
|
27
|
+
throw new ecschema_metadata_1.ECSchemaError(ecschema_metadata_1.ECSchemaStatus.InvalidSchemaXML, `Could not find '<ECSchema>' tag in the given string`);
|
|
28
28
|
const name = matches[0].match(/schemaName="(.+?)"/);
|
|
29
29
|
const version = matches[0].match(/version="(.+?)"/);
|
|
30
30
|
if (!name || name.length !== 2 || !version || version.length !== 2)
|
|
31
|
-
throw new ecschema_metadata_1.
|
|
31
|
+
throw new ecschema_metadata_1.ECSchemaError(ecschema_metadata_1.ECSchemaStatus.InvalidSchemaXML, `Could not find the ECSchema 'schemaName' or 'version' tag in the given string`);
|
|
32
32
|
const ecVersion = ecschema_metadata_1.ECVersion.fromString(version[1]);
|
|
33
33
|
const key = new ecschema_metadata_1.SchemaKey(name[1], ecVersion);
|
|
34
34
|
return key;
|
|
@@ -94,9 +94,9 @@ class SchemaXmlStringLocater extends SchemaStringLocater_1.SchemaStringLocater {
|
|
|
94
94
|
fromECv2String(versionString) {
|
|
95
95
|
const [read, minor] = versionString.split(".");
|
|
96
96
|
if (!read)
|
|
97
|
-
throw new ecschema_metadata_1.
|
|
97
|
+
throw new ecschema_metadata_1.ECSchemaError(ecschema_metadata_1.ECSchemaStatus.InvalidECVersion, `The read version is missing from version string, ${versionString}`);
|
|
98
98
|
if (!minor)
|
|
99
|
-
throw new ecschema_metadata_1.
|
|
99
|
+
throw new ecschema_metadata_1.ECSchemaError(ecschema_metadata_1.ECSchemaStatus.InvalidECVersion, `The minor version is missing from version string, ${versionString}`);
|
|
100
100
|
return new ecschema_metadata_1.ECVersion(+read, 0, +minor);
|
|
101
101
|
}
|
|
102
102
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaXmlStringLocater.js","sourceRoot":"","sources":["../../src/SchemaXmlStringLocater.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,2CAA2C;AAC3C,gEAEkC;AAClC,+DAA6E;AAE7E;;;;GAIG;AACH,MAAa,sBAAuB,SAAQ,yCAAmB;IAE7D;;;OAGG;IACI,YAAY,CAAC,SAAiB;QACnC,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;QACvD,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YA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AC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC5F,MAAM,UAAU,GAAG,YAAY,CAAC,UAAU,CAAC;QAE3C,MAAM,MAAM,GAAG,IAAI,kBAAS,EAAE,CAAC;QAC/B,MAAM,QAAQ,GAAG,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;QAEpD,MAAM,MAAM,GAAG,IAAI,oCAAgB,CAAC,6BAAS,EAAE,OAAO,CAAC,CAAC;QACxD,IAAI,MAAM,GAAW,IAAI,0BAAM,CAAC,OAAO,CAAC,CAAC;QACzC,MAAM,GAAG,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAEjD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACK,cAAc,CAAC,aAAqB;QAC1C,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAE/C,IAAI,CAAC,IAAI;YACP,MAAM,IAAI,iCAAa,CAAC,kCAAc,CAAC,gBAAgB,EAAE,oDAAoD,aAAa,EAAE,CAAC,CAAC;QAEhI,IAAI,CAAC,KAAK;YACR,MAAM,IAAI,iCAAa,CAAC,kCAAc,CAAC,gBAAgB,EAAE,qDAAqD,aAAa,EAAE,CAAC,CAAC;QAEjI,OAAO,IAAI,6BAAS,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;CAEF;AAvGD,wDAuGC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Locaters\n */\n\nimport { DOMParser } from \"@xmldom/xmldom\";\nimport {\n ECSchemaError, ECSchemaStatus, ECVersion, ISchemaLocater, Schema, SchemaContext, SchemaInfo, SchemaKey, SchemaMatchType, SchemaReadHelper, XmlParser,\n} from \"@itwin/ecschema-metadata\";\nimport { SchemaStringLocater, StringSchemaKey } from \"./SchemaStringLocater\";\n\n/**\n * A SchemaLocator implementation for locating and deserializing EC Schemas from XML strings\n * loaded in memory.\n * @beta\n */\nexport class SchemaXmlStringLocater extends SchemaStringLocater implements ISchemaLocater {\n\n /**\n * Constructs a SchemaKey based on the information in the Schema XML.\n * @param schemaXml The Schema XML as a string.\n */\n public getSchemaKey(schemaXml: string): SchemaKey {\n const matches = schemaXml.match(/<ECSchema ([^]+?)>/g);\n if (!matches || matches.length !== 1)\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Could not find '<ECSchema>' tag in the given string`);\n\n const name = matches[0].match(/schemaName=\"(.+?)\"/);\n const version = matches[0].match(/version=\"(.+?)\"/);\n if (!name || name.length !== 2 || !version || version.length !== 2)\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Could not find the ECSchema 'schemaName' or 'version' tag in the given string`);\n\n const ecVersion = ECVersion.fromString(version[1]);\n const key = new SchemaKey(name[1], ecVersion);\n return key;\n }\n\n /**\n * Attempts to retrieve a Schema with the given SchemaKey by searching the configured\n * Schema strings.\n * @param key The SchemaKey of the Schema to retrieve.\n * @param matchType The SchemaMatchType.\n * @param context The SchemaContext that will control the lifetime of the schema and holds the schema's references, if they exist.\n */\n public async getSchema(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<Schema | undefined> {\n await this.getSchemaInfo(schemaKey, matchType, context);\n\n const schema = await context.getCachedSchema(schemaKey, matchType);\n return schema as Schema;\n }\n\n /**\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\n * The fully loaded schema can be gotten later from the context using the getCachedSchema method.\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\n * @param matchType The match type to use when locating the schema\n * @param context The SchemaContext that will control the lifetime of the schema and holds the schema's references, if they exist.\n */\n public async getSchemaInfo(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined> {\n // Grab all schema strings that match the schema key\n const candidates: StringSchemaKey[] = this.findEligibleSchemaKeys(schemaKey, matchType);\n if (!candidates || candidates.length === 0)\n return undefined;\n\n const maxCandidate = candidates.sort(this.compareSchemaKeyByVersion)[candidates.length - 1];\n const schemaText = maxCandidate.schemaText;\n\n const parser = new DOMParser();\n const document = parser.parseFromString(schemaText);\n\n const reader = new SchemaReadHelper(XmlParser, context);\n const schema = new Schema(context);\n\n return reader.readSchemaInfo(schema, document);\n }\n\n /**\n * Attempts to retrieve a Schema with the given SchemaKey by searching the configured\n * Schema strings.\n * @param key The SchemaKey of the Schema to retrieve.\n * @param matchType The SchemaMatchType.\n * @param context The SchemaContext that will control the lifetime of the schema and holds the schema's references, if they exist.\n */\n public getSchemaSync(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Schema | undefined {\n // Grab all schema strings that match the schema key\n const candidates: StringSchemaKey[] = this.findEligibleSchemaKeys(schemaKey, matchType);\n if (!candidates || candidates.length === 0)\n return undefined;\n\n const maxCandidate = candidates.sort(this.compareSchemaKeyByVersion)[candidates.length - 1];\n const schemaText = maxCandidate.schemaText;\n\n const parser = new DOMParser();\n const document = parser.parseFromString(schemaText);\n\n const reader = new SchemaReadHelper(XmlParser, context);\n let schema: Schema = new Schema(context);\n schema = reader.readSchemaSync(schema, document);\n\n return schema;\n }\n\n /**\n * Parses a valid EC 2.0 version string and returns an ECVersion object. The second digit becomes the minor version,\n * and a zero is inserted as the 'write' digit. Example: \"1.1\" -> \"1.0.1\".\n * @param versionString A valid EC 2.0 version string of the format, 'RR.mm'.\n */\n private fromECv2String(versionString: string): ECVersion {\n const [read, minor] = versionString.split(\".\");\n\n if (!read)\n throw new ECSchemaError(ECSchemaStatus.InvalidECVersion, `The read version is missing from version string, ${versionString}`);\n\n if (!minor)\n throw new ECSchemaError(ECSchemaStatus.InvalidECVersion, `The minor version is missing from version string, ${versionString}`);\n\n return new ECVersion(+read, 0, +minor);\n }\n\n}\n"]}
|
|
@@ -25,7 +25,7 @@ export declare class StubSchemaXmlFileLocater extends SchemaFileLocater implemen
|
|
|
25
25
|
* @param matchType The SchemaMatchType.
|
|
26
26
|
* @param context The SchemaContext that will control the lifetime of the schema.
|
|
27
27
|
*/
|
|
28
|
-
getSchema
|
|
28
|
+
getSchema(key: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<Schema | undefined>;
|
|
29
29
|
/**
|
|
30
30
|
* Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.
|
|
31
31
|
* The fully loaded schema can be gotten later from the context using the getCachedSchema method.
|
|
@@ -42,7 +42,7 @@ export declare class StubSchemaXmlFileLocater extends SchemaFileLocater implemen
|
|
|
42
42
|
* @param matchType The SchemaMatchType.
|
|
43
43
|
* @param context The SchemaContext that will control the lifetime of the schema.
|
|
44
44
|
*/
|
|
45
|
-
getSchemaSync
|
|
45
|
+
getSchemaSync(key: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Schema | undefined;
|
|
46
46
|
/**
|
|
47
47
|
* Constructs a SchemaKey based on the information in the Schema XML.
|
|
48
48
|
* @param schemaXml The Schema XML as a string.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StubSchemaXmlFileLocater.d.ts","sourceRoot":"","sources":["../../src/StubSchemaXmlFileLocater.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"StubSchemaXmlFileLocater.d.ts","sourceRoot":"","sources":["../../src/StubSchemaXmlFileLocater.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EACqC,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,eAAe,EACxH,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAiB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAMvE;;;;;GAKG;AACH,qBAAa,wBAAyB,SAAQ,iBAAkB,YAAW,cAAc;IACvF;;;;;OAKG;IACI,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM;IAiBlE;;;;;;;OAOG;IACU,SAAS,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAIvH;;;;;;QAMI;IACS,aAAa,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAI/H;;;;;;;OAOG;IACI,aAAa,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS;IAe5G;;;OAGG;IACI,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS;IAoBjD;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAI9B;;;;;;OAMG;IACH,OAAO,CAAC,mBAAmB;IAY3B;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAkC/B;;;OAGG;IACH,OAAO,CAAC,cAAc;IAgBtB;;;;OAIG;IACH,OAAO,CAAC,cAAc;CAWvB"}
|
|
@@ -30,7 +30,7 @@ class StubSchemaXmlFileLocater extends SchemaFileLocater_1.SchemaFileLocater {
|
|
|
30
30
|
loadSchema(schemaPath, schemaText) {
|
|
31
31
|
schemaText = schemaText || this.readUtf8FileToStringSync(schemaPath);
|
|
32
32
|
if (!schemaText)
|
|
33
|
-
throw new ecschema_metadata_1.
|
|
33
|
+
throw new ecschema_metadata_1.ECSchemaError(ecschema_metadata_1.ECSchemaStatus.UnableToLocateSchema, `Unable to locate schema XML file at ${schemaPath}`);
|
|
34
34
|
this.addSchemaSearchPaths([path.dirname(schemaPath)]);
|
|
35
35
|
const key = this.getSchemaKey(schemaText);
|
|
36
36
|
const alias = this.getSchemaAlias(schemaText);
|
|
@@ -88,11 +88,11 @@ class StubSchemaXmlFileLocater extends SchemaFileLocater_1.SchemaFileLocater {
|
|
|
88
88
|
getSchemaKey(schemaXml) {
|
|
89
89
|
const matches = schemaXml.match(/<ECSchema ([^]+?)>/g);
|
|
90
90
|
if (!matches || matches.length !== 1)
|
|
91
|
-
throw new ecschema_metadata_1.
|
|
91
|
+
throw new ecschema_metadata_1.ECSchemaError(ecschema_metadata_1.ECSchemaStatus.InvalidSchemaXML, `Could not find '<ECSchema>' tag in the given file`);
|
|
92
92
|
const name = matches[0].match(/schemaName="(.+?)"/);
|
|
93
93
|
const version = matches[0].match(/version="(.+?)"/);
|
|
94
94
|
if (!name || name.length !== 2 || !version || version.length !== 2)
|
|
95
|
-
throw new ecschema_metadata_1.
|
|
95
|
+
throw new ecschema_metadata_1.ECSchemaError(ecschema_metadata_1.ECSchemaStatus.InvalidSchemaXML, `Could not find the ECSchema 'schemaName' or 'version' tag in the given file`);
|
|
96
96
|
let ecVersion;
|
|
97
97
|
if (isECv2Schema(schemaXml))
|
|
98
98
|
ecVersion = this.fromECv2String(version[1]);
|
|
@@ -120,7 +120,7 @@ class StubSchemaXmlFileLocater extends SchemaFileLocater_1.SchemaFileLocater {
|
|
|
120
120
|
for (const key of refKeys) {
|
|
121
121
|
const refSchema = context ? context.getSchemaSync(key, refMatchType) : undefined;
|
|
122
122
|
if (!refSchema)
|
|
123
|
-
throw new ecschema_metadata_1.
|
|
123
|
+
throw new ecschema_metadata_1.ECSchemaError(ecschema_metadata_1.ECSchemaStatus.UnableToLocateSchema, `Unable to locate referenced schema: ${key.name}.${key.readVersion}.${key.writeVersion}.${key.minorVersion}`);
|
|
124
124
|
schema.references.push(refSchema);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
@@ -131,7 +131,7 @@ class StubSchemaXmlFileLocater extends SchemaFileLocater_1.SchemaFileLocater {
|
|
|
131
131
|
_getSchemaReferenceKeys(xmlSchemaKey) {
|
|
132
132
|
const file = xmlSchemaKey.schemaText;
|
|
133
133
|
if (!file)
|
|
134
|
-
throw new ecschema_metadata_1.
|
|
134
|
+
throw new ecschema_metadata_1.ECSchemaError(ecschema_metadata_1.ECSchemaStatus.UnableToLocateSchema, `Could not locate the schema file, ${xmlSchemaKey.fileName}, for the schema ${xmlSchemaKey.name}`);
|
|
135
135
|
const data = file.toString().replace(/(\s*)<!--[\s\S]*?--!?>/g, ""); // ignore any comments in the XML file when getting the array of SchemaKeys
|
|
136
136
|
const keys = [];
|
|
137
137
|
const matches = data.match(/<ECSchemaReference ([^]+?)\/>/g);
|
|
@@ -141,7 +141,7 @@ class StubSchemaXmlFileLocater extends SchemaFileLocater_1.SchemaFileLocater {
|
|
|
141
141
|
const name = match.match(/name="(.+?)"/);
|
|
142
142
|
const versionMatch = match.match(/version="(.+?)"/);
|
|
143
143
|
if (!name || name.length !== 2 || !versionMatch || versionMatch.length !== 2)
|
|
144
|
-
throw new ecschema_metadata_1.
|
|
144
|
+
throw new ecschema_metadata_1.ECSchemaError(ecschema_metadata_1.ECSchemaStatus.InvalidSchemaXML, `Invalid ECSchemaReference xml encountered in the schema file`);
|
|
145
145
|
// write version maybe missing, so insert "0"
|
|
146
146
|
let versionString = versionMatch[1];
|
|
147
147
|
const versionParts = versionString.split(".");
|
|
@@ -166,7 +166,7 @@ class StubSchemaXmlFileLocater extends SchemaFileLocater_1.SchemaFileLocater {
|
|
|
166
166
|
match = schemaXml.match(/<ECSchema.*alias="(?<alias>\w+)"/);
|
|
167
167
|
}
|
|
168
168
|
if (!match || !match.groups.alias) {
|
|
169
|
-
throw new ecschema_metadata_1.
|
|
169
|
+
throw new ecschema_metadata_1.ECSchemaError(ecschema_metadata_1.ECSchemaStatus.InvalidSchemaXML, `Could not find the ECSchema 'alias' tag in the given file.`);
|
|
170
170
|
}
|
|
171
171
|
return match.groups.alias;
|
|
172
172
|
}
|
|
@@ -178,9 +178,9 @@ class StubSchemaXmlFileLocater extends SchemaFileLocater_1.SchemaFileLocater {
|
|
|
178
178
|
fromECv2String(versionString) {
|
|
179
179
|
const [read, minor] = versionString.split(".");
|
|
180
180
|
if (!read)
|
|
181
|
-
throw new ecschema_metadata_1.
|
|
181
|
+
throw new ecschema_metadata_1.ECSchemaError(ecschema_metadata_1.ECSchemaStatus.InvalidECVersion, `The read version is missing from version string, ${versionString}`);
|
|
182
182
|
if (!minor)
|
|
183
|
-
throw new ecschema_metadata_1.
|
|
183
|
+
throw new ecschema_metadata_1.ECSchemaError(ecschema_metadata_1.ECSchemaStatus.InvalidECVersion, `The minor version is missing from version string, ${versionString}`);
|
|
184
184
|
return new ecschema_metadata_1.ECVersion(+read, 0, +minor);
|
|
185
185
|
}
|
|
186
186
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StubSchemaXmlFileLocater.js","sourceRoot":"","sources":["../../src/StubSchemaXmlFileLocater.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,6BAA6B;AAC7B,gEAEkC;AAClC,2DAAuE;AAEvE,SAAS,YAAY,CAAC,UAAkB;IACtC,OAAO,mCAAmC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AAC9D,CAAC;AAED;;;;;GAKG;AACH,MAAa,wBAAyB,SAAQ,qCAAiB;IAC7D;;;;;OAKG;IACI,UAAU,CAAC,UAAkB,EAAE,UAAmB;QACvD,UAAU,GAAG,UAAU,IAAI,IAAI,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAC;QACrE,IAAI,CAAC,UAAU;YACb,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,oBAAoB,EAAE,uCAAuC,UAAU,EAAE,CAAC,CAAC;QAEtH,IAAI,CAAC,oBAAoB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACtD,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QAC1C,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,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c,CAAC,mCAAe,CAAC,gBAAgB,EAAE,4DAA4D,CAAC,CAAC;QAC3H,CAAC;QAED,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACK,cAAc,CAAC,aAAqB;QAC1C,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAE/C,IAAI,CAAC,IAAI;YACP,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,gBAAgB,EAAE,oDAAoD,aAAa,EAAE,CAAC,CAAC;QAElI,IAAI,CAAC,KAAK;YACR,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,gBAAgB,EAAE,qDAAqD,aAAa,EAAE,CAAC,CAAC;QAEnI,OAAO,IAAI,6BAAS,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;CACF;AAnMD,4DAmMC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Locaters\r\n */\r\n\r\nimport * as path from \"path\";\r\nimport {\r\n ECObjectsError, ECObjectsStatus, ECVersion, ISchemaLocater, Schema, SchemaContext, SchemaInfo, SchemaKey, SchemaMatchType,\r\n} from \"@itwin/ecschema-metadata\";\r\nimport { FileSchemaKey, SchemaFileLocater } from \"./SchemaFileLocater\";\r\n\r\nfunction isECv2Schema(schemaText: string): boolean {\r\n return /<ECSchema[^>]*xmlns=\".*ECXML.2.0\"/.test(schemaText);\r\n}\r\n\r\n/**\r\n * A SchemaLocater implementation for locating XML Schema files\r\n * from the file system using configurable search paths. Returns only\r\n * Schemas from XML files with their keys populated.\r\n * @internal\r\n */\r\nexport class StubSchemaXmlFileLocater extends SchemaFileLocater implements ISchemaLocater {\r\n /**\r\n * Loads a Schema from an XML file on the file system.\r\n * @param schemaPath The path to the Schema file.\r\n * @param schemaText Optionally pass in the schema text read from the schema file. If undefined,\r\n * the schema will be read from the provided schemaPath.\r\n */\r\n public loadSchema(schemaPath: string, schemaText?: string): Schema {\r\n schemaText = schemaText || this.readUtf8FileToStringSync(schemaPath);\r\n if (!schemaText)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `Unable to locate schema XML file at ${schemaPath}`);\r\n\r\n this.addSchemaSearchPaths([path.dirname(schemaPath)]);\r\n const key = this.getSchemaKey(schemaText);\r\n const alias = this.getSchemaAlias(schemaText);\r\n const context = new SchemaContext();\r\n context.addLocater(this);\r\n\r\n // Load the schema and return it\r\n const schema = new Schema(context, new FileSchemaKey(key, schemaPath, schemaText), alias);\r\n this.addSchemaReferences(schema, context, SchemaMatchType.LatestWriteCompatible);\r\n return schema;\r\n }\r\n\r\n /**\r\n * Attempts to retrieve a Schema with the given SchemaKey by using the configured search paths\r\n * to locate the XML Schema file from the file system. Returns only Schemas from XML files with\r\n * their keys populated.\r\n * @param key The SchemaKey of the Schema to retrieve.\r\n * @param matchType The SchemaMatchType.\r\n * @param context The SchemaContext that will control the lifetime of the schema.\r\n */\r\n public async getSchema<T extends Schema>(key: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<T | undefined> {\r\n return this.getSchemaSync(key, matchType, context) as T;\r\n }\r\n\r\n /**\r\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\r\n * The fully loaded schema can be gotten later from the context using the getCachedSchema method.\r\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\r\n * @param matchType The match type to use when locating the schema\r\n * @param context The SchemaContext that will control the lifetime of the schema and holds the schema's references, if they exist.\r\n */\r\n public async getSchemaInfo(key: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined> {\r\n return this.getSchemaSync(key, matchType, context) as SchemaInfo;\r\n }\r\n\r\n /**\r\n * Attempts to retrieve a Schema with the given SchemaKey by using the configured search paths\r\n * to locate the XML Schema file from the file system. Returns only Schemas from XML files with\r\n * their keys populated.\r\n * @param key The SchemaKey of the Schema to retrieve.\r\n * @param matchType The SchemaMatchType.\r\n * @param context The SchemaContext that will control the lifetime of the schema.\r\n */\r\n public getSchemaSync<T extends Schema>(key: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): T | undefined {\r\n const candidates: FileSchemaKey[] = this.findEligibleSchemaKeys(key, matchType, \"xml\");\r\n\r\n if (!candidates || candidates.length === 0)\r\n return undefined;\r\n\r\n const maxCandidate = candidates.sort(this.compareSchemaKeyByVersion)[candidates.length - 1];\r\n const alias = this.getSchemaAlias(maxCandidate.schemaText!);\r\n const schema = new Schema(context, maxCandidate, alias) as T;\r\n context.addSchemaSync(schema);\r\n\r\n this.addSchemaReferences(schema, context, SchemaMatchType.LatestWriteCompatible);\r\n return schema;\r\n }\r\n\r\n /**\r\n * Constructs a SchemaKey based on the information in the Schema XML.\r\n * @param schemaXml The Schema XML as a string.\r\n */\r\n public getSchemaKey(schemaXml: string): SchemaKey {\r\n const matches = schemaXml.match(/<ECSchema ([^]+?)>/g);\r\n if (!matches || matches.length !== 1)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaXML, `Could not find '<ECSchema>' tag in the given file`);\r\n\r\n const name = matches[0].match(/schemaName=\"(.+?)\"/);\r\n const version = matches[0].match(/version=\"(.+?)\"/);\r\n if (!name || name.length !== 2 || !version || version.length !== 2)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaXML, `Could not find the ECSchema 'schemaName' or 'version' tag in the given file`);\r\n\r\n let ecVersion: ECVersion;\r\n if (isECv2Schema(schemaXml))\r\n ecVersion = this.fromECv2String(version[1]);\r\n else\r\n ecVersion = ECVersion.fromString(version[1]);\r\n\r\n const key = new SchemaKey(name[1], ecVersion);\r\n return key;\r\n }\r\n\r\n /**\r\n * Gets an array of SchemaKeys of the Schemas referenced by the given Schema.\r\n * @param xmlSchemaKey The SchemaKey of the parent Schema containing the references.\r\n */\r\n private getSchemaReferenceKeys(schemaKey: FileSchemaKey): SchemaKey[] {\r\n return this._getSchemaReferenceKeys(schemaKey);\r\n }\r\n\r\n /**\r\n * Adds schemas to the references collection for the given Schema by locating\r\n * the referenced schemas.\r\n * @param schema The schema for which to add the references.\r\n * @param context The SchemaContext that will control the lifetime of the schema.\r\n * @param refMatchType The SchemaMatchType to use when locating schema references.\r\n */\r\n private addSchemaReferences(schema: Schema, context: SchemaContext, refMatchType: SchemaMatchType): void {\r\n const refKeys = this.getSchemaReferenceKeys(schema.schemaKey as FileSchemaKey);\r\n\r\n for (const key of refKeys) {\r\n const refSchema = context ? context.getSchemaSync(key, refMatchType) : undefined;\r\n if (!refSchema)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `Unable to locate referenced schema: ${key.name}.${key.readVersion}.${key.writeVersion}.${key.minorVersion}`);\r\n\r\n schema.references.push(refSchema);\r\n }\r\n }\r\n\r\n /**\r\n * Gets an array of SchemaKeys of the Schemas referenced by the given Schema.\r\n * @param data The Schema XML string.\r\n */\r\n private _getSchemaReferenceKeys(xmlSchemaKey: FileSchemaKey): SchemaKey[] {\r\n const file = xmlSchemaKey.schemaText;\r\n\r\n if (!file)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `Could not locate the schema file, ${xmlSchemaKey.fileName}, for the schema ${xmlSchemaKey.name}`);\r\n\r\n const data = file.toString().replace(/(\\s*)<!--[\\s\\S]*?--!?>/g, \"\"); // ignore any comments in the XML file when getting the array of SchemaKeys\r\n\r\n const keys: SchemaKey[] = [];\r\n const matches = data.match(/<ECSchemaReference ([^]+?)\\/>/g);\r\n if (!matches)\r\n return keys;\r\n\r\n for (const match of matches) {\r\n const name = match.match(/name=\"(.+?)\"/);\r\n const versionMatch = match.match(/version=\"(.+?)\"/);\r\n if (!name || name.length !== 2 || !versionMatch || versionMatch.length !== 2)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaXML, `Invalid ECSchemaReference xml encountered in the schema file`);\r\n\r\n // write version maybe missing, so insert \"0\"\r\n let versionString = versionMatch[1];\r\n const versionParts = versionString.split(\".\");\r\n if (versionParts.length === 2)\r\n versionParts.splice(1, 0, \"0\");\r\n\r\n versionString = versionParts.join(\".\");\r\n\r\n const key = new SchemaKey(name[1], ECVersion.fromString(versionString));\r\n keys.push(key);\r\n }\r\n\r\n return keys;\r\n }\r\n\r\n /**\r\n * Gets the Schema alias from the Schema XML.\r\n * @param data The Schema XML as a string.\r\n */\r\n private getSchemaAlias(schemaXml: string): string {\r\n let match: any;\r\n\r\n if (isECv2Schema(schemaXml)) {\r\n match = schemaXml.match(/<ECSchema.*nameSpacePrefix=\"(?<alias>\\w+)\"/) as any;\r\n } else {\r\n match = schemaXml.match(/<ECSchema.*alias=\"(?<alias>\\w+)\"/) as any;\r\n }\r\n\r\n if (!match || !match.groups.alias) {\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaXML, `Could not find the ECSchema 'alias' tag in the given file.`);\r\n }\r\n\r\n return match.groups.alias;\r\n }\r\n\r\n /**\r\n * Parses a valid EC 2.0 version string and returns an ECVersion object. The second digit becomes the minor version,\r\n * and a zero is inserted as the 'write' digit. Example: \"1.1\" -> \"1.0.1\".\r\n * @param versionString A valid EC 2.0 version string of the format, 'RR.mm'.\r\n */\r\n private fromECv2String(versionString: string): ECVersion {\r\n const [read, minor] = versionString.split(\".\");\r\n\r\n if (!read)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECVersion, `The read version is missing from version string, ${versionString}`);\r\n\r\n if (!minor)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECVersion, `The minor version is missing from version string, ${versionString}`);\r\n\r\n return new ECVersion(+read, 0, +minor);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"StubSchemaXmlFileLocater.js","sourceRoot":"","sources":["../../src/StubSchemaXmlFileLocater.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;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,KAAK,CAAC,CAAC;IACzC,CAAC;CACF;AAnMD,4DAmMC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Locaters\n */\n\nimport * as path from \"path\";\nimport {\n ECSchemaError, ECSchemaStatus, ECVersion, ISchemaLocater, Schema, SchemaContext, SchemaInfo, SchemaKey, SchemaMatchType,\n} from \"@itwin/ecschema-metadata\";\nimport { FileSchemaKey, SchemaFileLocater } from \"./SchemaFileLocater\";\n\nfunction isECv2Schema(schemaText: string): boolean {\n return /<ECSchema[^>]*xmlns=\".*ECXML.2.0\"/.test(schemaText);\n}\n\n/**\n * A SchemaLocater implementation for locating XML Schema files\n * from the file system using configurable search paths. Returns only\n * Schemas from XML files with their keys populated.\n * @internal\n */\nexport class StubSchemaXmlFileLocater extends SchemaFileLocater implements ISchemaLocater {\n /**\n * Loads a Schema from an XML file on the file system.\n * @param schemaPath The path to the Schema file.\n * @param schemaText Optionally pass in the schema text read from the schema file. If undefined,\n * the schema will be read from the provided schemaPath.\n */\n public loadSchema(schemaPath: string, schemaText?: string): Schema {\n schemaText = schemaText || this.readUtf8FileToStringSync(schemaPath);\n if (!schemaText)\n throw new ECSchemaError(ECSchemaStatus.UnableToLocateSchema, `Unable to locate schema XML file at ${schemaPath}`);\n\n this.addSchemaSearchPaths([path.dirname(schemaPath)]);\n const key = this.getSchemaKey(schemaText);\n const alias = this.getSchemaAlias(schemaText);\n const context = new SchemaContext();\n context.addLocater(this);\n\n // Load the schema and return it\n const schema = new Schema(context, new FileSchemaKey(key, schemaPath, schemaText), alias);\n this.addSchemaReferences(schema, context, SchemaMatchType.LatestWriteCompatible);\n return schema;\n }\n\n /**\n * Attempts to retrieve a Schema with the given SchemaKey by using the configured search paths\n * to locate the XML Schema file from the file system. Returns only Schemas from XML files with\n * their keys populated.\n * @param key The SchemaKey of the Schema to retrieve.\n * @param matchType The SchemaMatchType.\n * @param context The SchemaContext that will control the lifetime of the schema.\n */\n public async getSchema(key: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<Schema | undefined> {\n return this.getSchemaSync(key, matchType, context);\n }\n\n /**\n * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.\n * The fully loaded schema can be gotten later from the context using the getCachedSchema method.\n * @param schemaKey The SchemaKey describing the schema to get from the cache.\n * @param matchType The match type to use when locating the schema\n * @param context The SchemaContext that will control the lifetime of the schema and holds the schema's references, if they exist.\n */\n public async getSchemaInfo(key: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined> {\n return this.getSchemaSync(key, matchType, context) as SchemaInfo;\n }\n\n /**\n * Attempts to retrieve a Schema with the given SchemaKey by using the configured search paths\n * to locate the XML Schema file from the file system. Returns only Schemas from XML files with\n * their keys populated.\n * @param key The SchemaKey of the Schema to retrieve.\n * @param matchType The SchemaMatchType.\n * @param context The SchemaContext that will control the lifetime of the schema.\n */\n public getSchemaSync(key: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Schema | undefined {\n const candidates: FileSchemaKey[] = this.findEligibleSchemaKeys(key, matchType, \"xml\");\n\n if (!candidates || candidates.length === 0)\n return undefined;\n\n const maxCandidate = candidates.sort(this.compareSchemaKeyByVersion)[candidates.length - 1];\n const alias = this.getSchemaAlias(maxCandidate.schemaText!);\n const schema = new Schema(context, maxCandidate, alias);\n context.addSchemaSync(schema);\n\n this.addSchemaReferences(schema, context, SchemaMatchType.LatestWriteCompatible);\n return schema;\n }\n\n /**\n * Constructs a SchemaKey based on the information in the Schema XML.\n * @param schemaXml The Schema XML as a string.\n */\n public getSchemaKey(schemaXml: string): SchemaKey {\n const matches = schemaXml.match(/<ECSchema ([^]+?)>/g);\n if (!matches || matches.length !== 1)\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Could not find '<ECSchema>' tag in the given file`);\n\n const name = matches[0].match(/schemaName=\"(.+?)\"/);\n const version = matches[0].match(/version=\"(.+?)\"/);\n if (!name || name.length !== 2 || !version || version.length !== 2)\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Could not find the ECSchema 'schemaName' or 'version' tag in the given file`);\n\n let ecVersion: ECVersion;\n if (isECv2Schema(schemaXml))\n ecVersion = this.fromECv2String(version[1]);\n else\n ecVersion = ECVersion.fromString(version[1]);\n\n const key = new SchemaKey(name[1], ecVersion);\n return key;\n }\n\n /**\n * Gets an array of SchemaKeys of the Schemas referenced by the given Schema.\n * @param xmlSchemaKey The SchemaKey of the parent Schema containing the references.\n */\n private getSchemaReferenceKeys(schemaKey: FileSchemaKey): SchemaKey[] {\n return this._getSchemaReferenceKeys(schemaKey);\n }\n\n /**\n * Adds schemas to the references collection for the given Schema by locating\n * the referenced schemas.\n * @param schema The schema for which to add the references.\n * @param context The SchemaContext that will control the lifetime of the schema.\n * @param refMatchType The SchemaMatchType to use when locating schema references.\n */\n private addSchemaReferences(schema: Schema, context: SchemaContext, refMatchType: SchemaMatchType): void {\n const refKeys = this.getSchemaReferenceKeys(schema.schemaKey as FileSchemaKey);\n\n for (const key of refKeys) {\n const refSchema = context ? context.getSchemaSync(key, refMatchType) : undefined;\n if (!refSchema)\n throw new ECSchemaError(ECSchemaStatus.UnableToLocateSchema, `Unable to locate referenced schema: ${key.name}.${key.readVersion}.${key.writeVersion}.${key.minorVersion}`);\n\n schema.references.push(refSchema);\n }\n }\n\n /**\n * Gets an array of SchemaKeys of the Schemas referenced by the given Schema.\n * @param data The Schema XML string.\n */\n private _getSchemaReferenceKeys(xmlSchemaKey: FileSchemaKey): SchemaKey[] {\n const file = xmlSchemaKey.schemaText;\n\n if (!file)\n throw new ECSchemaError(ECSchemaStatus.UnableToLocateSchema, `Could not locate the schema file, ${xmlSchemaKey.fileName}, for the schema ${xmlSchemaKey.name}`);\n\n const data = file.toString().replace(/(\\s*)<!--[\\s\\S]*?--!?>/g, \"\"); // ignore any comments in the XML file when getting the array of SchemaKeys\n\n const keys: SchemaKey[] = [];\n const matches = data.match(/<ECSchemaReference ([^]+?)\\/>/g);\n if (!matches)\n return keys;\n\n for (const match of matches) {\n const name = match.match(/name=\"(.+?)\"/);\n const versionMatch = match.match(/version=\"(.+?)\"/);\n if (!name || name.length !== 2 || !versionMatch || versionMatch.length !== 2)\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Invalid ECSchemaReference xml encountered in the schema file`);\n\n // write version maybe missing, so insert \"0\"\n let versionString = versionMatch[1];\n const versionParts = versionString.split(\".\");\n if (versionParts.length === 2)\n versionParts.splice(1, 0, \"0\");\n\n versionString = versionParts.join(\".\");\n\n const key = new SchemaKey(name[1], ECVersion.fromString(versionString));\n keys.push(key);\n }\n\n return keys;\n }\n\n /**\n * Gets the Schema alias from the Schema XML.\n * @param data The Schema XML as a string.\n */\n private getSchemaAlias(schemaXml: string): string {\n let match: any;\n\n if (isECv2Schema(schemaXml)) {\n match = schemaXml.match(/<ECSchema.*nameSpacePrefix=\"(?<alias>\\w+)\"/) as any;\n } else {\n match = schemaXml.match(/<ECSchema.*alias=\"(?<alias>\\w+)\"/) as any;\n }\n\n if (!match || !match.groups.alias) {\n throw new ECSchemaError(ECSchemaStatus.InvalidSchemaXML, `Could not find the ECSchema 'alias' tag in the given file.`);\n }\n\n return match.groups.alias;\n }\n\n /**\n * Parses a valid EC 2.0 version string and returns an ECVersion object. The second digit becomes the minor version,\n * and a zero is inserted as the 'write' digit. Example: \"1.1\" -> \"1.0.1\".\n * @param versionString A valid EC 2.0 version string of the format, 'RR.mm'.\n */\n private fromECv2String(versionString: string): ECVersion {\n const [read, minor] = versionString.split(\".\");\n\n if (!read)\n throw new ECSchemaError(ECSchemaStatus.InvalidECVersion, `The read version is missing from version string, ${versionString}`);\n\n if (!minor)\n throw new ECSchemaError(ECSchemaStatus.InvalidECVersion, `The minor version is missing from version string, ${versionString}`);\n\n return new ECVersion(+read, 0, +minor);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ecschema-locaters.js","sourceRoot":"","sources":["../../src/ecschema-locaters.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;;;;;AAE/F,sDAAoC;AACpC,8CAA4B;AAC5B,0DAAwC;AACxC,yDAAuC;AACvC,6DAA2C;AAC3C,2DAAyC;AAEzC;;;;GAIG;AACH;;;GAGG;AACH;;;GAGG","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"ecschema-locaters.js","sourceRoot":"","sources":["../../src/ecschema-locaters.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;;;;;AAE/F,sDAAoC;AACpC,8CAA4B;AAC5B,0DAAwC;AACxC,yDAAuC;AACvC,6DAA2C;AAC3C,2DAAyC;AAEzC;;;;GAIG;AACH;;;GAGG;AACH;;;GAGG","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nexport * from \"./SchemaFileLocater\";\nexport * from \"./SchemaXml\";\nexport * from \"./SchemaJsonFileLocater\";\nexport * from \"./SchemaXmlFileLocater\";\nexport * from \"./StubSchemaXmlFileLocater\";\nexport * from \"./SchemaXmlStringLocater\";\n\n/** @docs-package-description\n * The ecschema-locaters package contains classes for locating ECSchemas within a given\n * [SchemaContext](https://www.itwinjs.org/reference/ecschema-metadata/context/schemacontext). Each locater\n * implements the [ISchemaLocater interface](https://www.itwinjs.org/reference/ecschema-metadata/context/ischemalocater/).\n */\n/**\n * @docs-group-description Locaters\n * ISchemaLocater implementations used to locate schemas in a given [SchemaContext](https://www.itwinjs.org/reference/ecschema-metadata/context/schemacontext).\n */\n/**\n * @docs-group-description Utils\n * A set of utility classes used throughout the package.\n */\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"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,GAAG,CAAC,CAAC;QACxB,MAAM,WAAW,GAAG,IAAI,CAAC;QACzB,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAC/B,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE;YAC5C,IAAI,eAAe,KAAK,CAAC,EAAE,CAAC;gBAC1B,eAAe,GAAG,CAAC,CAAC;gBACpB,OAAO,aAAa,CAAC,SAAS,CAAC,IAAI,6BAAS,CAAC,SAAS,CAAC,CAAC,CAAC;YAC3D,CAAC;YACD,OAAO,aAAa,CAAC,SAAS,CAAC,IAAI,6BAAS,CAAC,sBAAsB,CAAC,CAAC,CAAC;QACxE,CAAC,CAAC,CACH,CAAC;QACF,IAAA,aAAM,EAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAC7C,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YACzB,IAAA,aAAM,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC;QACrC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { assert, expect } from \"chai\";\r\nimport * as fs from \"fs\";\r\nimport * as path from \"path\";\r\nimport { ECVersion, Schema, SchemaContext, SchemaJsonLocater, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\r\nimport { SchemaJsonFileLocater } from \"../SchemaJsonFileLocater\";\r\n\r\ndescribe(\"Concurrent schema JSON deserialization\", () => {\r\n const assetDir: string = path.join(__dirname, \"assets\");\r\n const schemaFolder = path.join(__dirname, \"assets\", \"json\");\r\n\r\n const schemaKeys: SchemaKey[] = [];\r\n let context: SchemaContext;\r\n let contextSync: SchemaContext;\r\n let syncSchemas: Array<Schema | undefined> = [];\r\n\r\n const locater = new SchemaJsonFileLocater();\r\n\r\n before(() => {\r\n if (!fs.existsSync(assetDir))\r\n fs.mkdirSync(assetDir);\r\n if (!fs.existsSync(schemaFolder))\r\n fs.mkdirSync(schemaFolder);\r\n\r\n copySchemasToAssetsDir();\r\n\r\n // Deserialize schemas synchronously/serially as standard to compare to\r\n contextSync = new SchemaContext();\r\n locater.addSchemaSearchPath(schemaFolder);\r\n contextSync.addLocater(locater);\r\n\r\n const schemaFiles = fs.readdirSync(schemaFolder);\r\n schemaFiles.forEach((fileName) => {\r\n const schemaFile = path.join(schemaFolder, fileName);\r\n const schemaJson = JSON.parse(fs.readFileSync(schemaFile, \"utf-8\"));\r\n const schemaName = schemaJson.name;\r\n const schemaVersion = schemaJson.version;\r\n\r\n const key = new SchemaKey(schemaName.toString(), ECVersion.fromString(schemaVersion.toString()));\r\n schemaKeys.push(key);\r\n });\r\n\r\n syncSchemas = schemaKeys.map((key): Schema | undefined => {\r\n if (!key)\r\n return undefined;\r\n\r\n const schema = contextSync.getSchemaSync(key, SchemaMatchType.Latest);\r\n return schema;\r\n });\r\n });\r\n\r\n beforeEach(() => {\r\n context = new SchemaContext();\r\n context.addLocater(locater);\r\n });\r\n\r\n function getSchemaPathFromPackage(packageName: string, schemaFileName: string): string {\r\n const schemaFile = path.join(__dirname, \"..\", \"..\", \"..\", \"node_modules\", \"@bentley\", packageName, schemaFileName);\r\n return schemaFile;\r\n }\r\n\r\n function copySchemasToAssetsDir() {\r\n // Copy Schemas that we need for testing\r\n fs.copyFileSync(getSchemaPathFromPackage(\"aec-units-schema\", \"AecUnits.ecschema.json\"), path.join(schemaFolder, \"AecUnits.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"architectural-physical-schema\", \"ArchitecturalPhysical.ecschema.json\"), path.join(schemaFolder, \"ArchitecturalPhysical.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"bis-core-schema\", \"BisCore.ecschema.json\"), path.join(schemaFolder, \"BisCore.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"bis-custom-attributes-schema\", \"BisCustomAttributes.ecschema.json\"), path.join(schemaFolder, \"BisCustomAttributes.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"construction-schema\", \"Construction.ecschema.json\"), path.join(schemaFolder, \"Construction.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"core-custom-attributes-schema\", \"CoreCustomAttributes.ecschema.json\"), path.join(schemaFolder, \"CoreCustomAttributes.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"ecdb-map-schema\", \"ECDbMap.ecschema.json\"), path.join(schemaFolder, \"ECDbMap.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"ecdb-schema-policies-schema\", \"ECDbSchemaPolicies.ecschema.json\"), path.join(schemaFolder, \"ECDbSchemaPolicies.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"formats-schema\", \"Formats.ecschema.json\"), path.join(schemaFolder, \"Formats.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"linear-referencing-schema\", \"LinearReferencing.ecschema.json\"), path.join(schemaFolder, \"LinearReferencing.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"physical-material-schema\", \"PhysicalMaterial.ecschema.json\"), path.join(schemaFolder, \"PhysicalMaterial.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"plant-custom-attributes-schema\", \"PlantCustomAttributes.ecschema.json\"), path.join(schemaFolder, \"PlantCustomAttributes.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"quantity-takeoffs-aspects-schema\", \"QuantityTakeoffsAspects.ecschema.json\"), path.join(schemaFolder, \"QuantityTakeoffsAspects.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"spatial-composition-schema\", \"SpatialComposition.ecschema.json\"), path.join(schemaFolder, \"SpatialComposition.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"structural-physical-schema\", \"StructuralPhysical.ecschema.json\"), path.join(schemaFolder, \"StructuralPhysical.ecschema.json\"));\r\n fs.copyFileSync(getSchemaPathFromPackage(\"units-schema\", \"Units.ecschema.json\"), path.join(schemaFolder, \"Units.ecschema.json\"));\r\n }\r\n\r\n it(\"should match schemas deserialized concurrently with schemas deserialized serially\", async () => {\r\n const schemaPromises = schemaKeys.map(async (key): Promise<Schema | undefined> => {\r\n if (!key)\r\n return undefined;\r\n\r\n const schema = await context.getSchema(key, SchemaMatchType.Latest);\r\n return schema;\r\n });\r\n const asyncSchemas = await Promise.all(schemaPromises);\r\n\r\n for (let i = 0; i < schemaKeys.length; i++) {\r\n const syncSchema = syncSchemas[i];\r\n expect(syncSchema).not.to.be.undefined;\r\n const syncJSON = syncSchema!.toJSON();\r\n\r\n const asyncSchema = asyncSchemas[i];\r\n expect(asyncSchema).not.to.be.undefined;\r\n const asyncJSON = asyncSchema!.toJSON();\r\n expect(asyncJSON).to.deep.equal(syncJSON);\r\n }\r\n });\r\n\r\n it(\"should be able to mix getSchema and getSchemaSync\", async () => {\r\n const schemaPromises = schemaKeys.map(async (key, index): Promise<Schema | undefined> => {\r\n if (index % 2 === 0) {\r\n // Use getSchema() for even indices\r\n if (!key)\r\n return undefined;\r\n\r\n const schema = await context.getSchema(key, SchemaMatchType.Latest);\r\n return schema;\r\n } else {\r\n // Use getSchemaSync() for odd indices\r\n if (!key)\r\n return undefined;\r\n\r\n const schema = context.getSchemaSync(key, SchemaMatchType.Latest);\r\n return schema;\r\n }\r\n });\r\n const schemas = await Promise.all(schemaPromises);\r\n\r\n for (let i = 0; i < schemaKeys.length; i++) {\r\n const syncSchema = syncSchemas[i];\r\n expect(syncSchema).not.to.be.undefined;\r\n const syncJSON = syncSchema!.toJSON();\r\n\r\n const schema = schemas[i];\r\n expect(schema).not.to.be.undefined;\r\n const schemaJSON = schema!.toJSON();\r\n expect(schemaJSON).to.deep.equal(syncJSON);\r\n }\r\n });\r\n\r\n /* Run these tests below one at a time. Running them together doesn't get accurate performance likely bc of disk access caching */\r\n it.skip(\"should measure regular deserialization performance\", async () => {\r\n const schemaPromises = schemaKeys.map(async (key): Promise<Schema | undefined> => {\r\n if (!key)\r\n return undefined;\r\n\r\n const schema = await context.getSchema(key, SchemaMatchType.Latest);\r\n return schema;\r\n });\r\n\r\n for (const promise of schemaPromises) {\r\n await promise;\r\n }\r\n\r\n expect(schemaPromises.length).to.equal(schemaKeys.length);\r\n });\r\n\r\n it.skip(\"should measure concurrent deserialization performance\", async () => {\r\n const schemaPromises = schemaKeys.map(async (key): Promise<Schema | undefined> => {\r\n if (!key)\r\n return undefined;\r\n\r\n const schema = await context.getSchema(key, SchemaMatchType.Latest);\r\n return schema;\r\n });\r\n const asyncSchemas = await Promise.all(schemaPromises);\r\n\r\n expect(asyncSchemas.length).to.equal(schemaKeys.length);\r\n });\r\n\r\n it(\"Concurrently get BisCore with SchemaJsonFileLocater\", async () => {\r\n const schemaContext = new SchemaContext();\r\n const jsonFileLocater = new SchemaJsonFileLocater();\r\n jsonFileLocater.addSchemaSearchPath(schemaFolder);\r\n schemaContext.addLocater(jsonFileLocater);\r\n\r\n const schemas = await Promise.all(\r\n [...Array(100).keys()].map(async () => {\r\n return schemaContext.getSchema(new SchemaKey(\"BisCore\"));\r\n }),\r\n );\r\n expect(schemas.length).to.equal(100);\r\n schemas.forEach((schema) => {\r\n assert(schema !== undefined);\r\n expect(schema.fullName).to.equal(\"BisCore\");\r\n });\r\n });\r\n\r\n it(\"Concurrently get a schema and it's referenced schema with SchemaJsonFileLocater\", async () => {\r\n const schemaContext = new SchemaContext();\r\n const jsonFileLocater = new SchemaJsonFileLocater();\r\n jsonFileLocater.addSchemaSearchPath(schemaFolder);\r\n schemaContext.addLocater(jsonFileLocater);\r\n\r\n let getBisCoreFirst = 0;\r\n const schemas = await Promise.all(\r\n [...Array(2).keys()].map(async () => {\r\n if (getBisCoreFirst === 0) {\r\n getBisCoreFirst = 1;\r\n return schemaContext.getSchema(new SchemaKey(\"BisCore\"));\r\n }\r\n return schemaContext.getSchema(new SchemaKey(\"CoreCustomAttributes\"));\r\n }),\r\n );\r\n expect(schemas.length).to.equal(2);\r\n schemas.forEach((schema) => {\r\n expect(schema).to.not.be.undefined;\r\n });\r\n });\r\n\r\n const getSchemaProps = (schemaName: string) => {\r\n if (schemaName === \"BisCore\") {\r\n return {\r\n $schema: \"https://dev.bentley.com/json_schemas/ec/32/ecschema\",\r\n alias: \"bis\",\r\n description: \"The BIS core schema contains classes that all other domain schemas extend.\",\r\n label: \"BIS Core\",\r\n name: \"BisCore\",\r\n version: \"01.00.15\",\r\n references:[{name:\"CoreCustomAttributes\", version:\"01.00.04\"},{name:\"ECDbMap\", version:\"02.00.00\"},{name:\"ECDbSchemaPolicies\", version:\"01.00.00\"}],\r\n };\r\n }\r\n if (schemaName === \"CoreCustomAttributes\") {\r\n return {\r\n $schema: \"https://dev.bentley.com/json_schemas/ec/32/ecschema\",\r\n alias: \"CoreCA\",\r\n description: \"Custom attributes to indicate core EC concepts, may include struct classes intended for use in core custom attributes.\",\r\n label: \"Core Custom Attributes\",\r\n name: \"CoreCustomAttributes\",\r\n version: \"01.00.04\",\r\n };\r\n }\r\n if (schemaName === \"ECDbMap\") {\r\n return {\r\n $schema: \"https://dev.bentley.com/json_schemas/ec/32/ecschema\",\r\n alias: \"ECDbMap\",\r\n description: \"ECDbMap Desc\",\r\n label: \"ECDbMap\",\r\n name: \"ECDbMap\",\r\n version: \"02.00.00\",\r\n };\r\n }\r\n if (schemaName === \"ECDbSchemaPolicies\") {\r\n return {\r\n $schema: \"https://dev.bentley.com/json_schemas/ec/32/ecschema\",\r\n alias: \"ECDbSchemaPolicies\",\r\n description: \"ECDbSchemaPolicies Desc\",\r\n label: \"ECDbSchemaPolicies\",\r\n name: \"ECDbSchemaPolicies\",\r\n version: \"01.00.00\",\r\n };\r\n }\r\n\r\n return undefined;\r\n };\r\n\r\n it(\"Concurrently get BisCore with SchemaJsonLocater\", async () => {\r\n const schemaContext = new SchemaContext();\r\n const jsonLocater = new SchemaJsonLocater(getSchemaProps);\r\n schemaContext.addLocater(jsonLocater);\r\n\r\n const schemaCount = 1000;\r\n const schemas = await Promise.all(\r\n [...Array(schemaCount).keys()].map(async () => {\r\n return schemaContext.getSchema(new SchemaKey(\"BisCore\"));\r\n }),\r\n );\r\n expect(schemas.length).to.equal(schemaCount);\r\n schemas.forEach((schema) => {\r\n assert(schema !== undefined);\r\n expect(schema.fullName).to.equal(\"BisCore\");\r\n });\r\n });\r\n\r\n it(\"Concurrently get a schema and it's referenced schema with SchemaJsonLocater\", async () => {\r\n const schemaContext = new SchemaContext();\r\n const jsonLocater = new SchemaJsonLocater(getSchemaProps);\r\n schemaContext.addLocater(jsonLocater);\r\n\r\n let getBisCoreFirst = 0;\r\n const schemaCount = 1000;\r\n const schemas = await Promise.all(\r\n [...Array(schemaCount).keys()].map(async () => {\r\n if (getBisCoreFirst === 0) {\r\n getBisCoreFirst = 1;\r\n return schemaContext.getSchema(new SchemaKey(\"BisCore\"));\r\n }\r\n return schemaContext.getSchema(new SchemaKey(\"CoreCustomAttributes\"));\r\n }),\r\n );\r\n expect(schemas.length).to.equal(schemaCount);\r\n schemas.forEach((schema) => {\r\n expect(schema).to.not.be.undefined;\r\n });\r\n });\r\n});\r\n"]}
|
|
1
|
+
{"version":3,"file":"ConcurrentGetSchemaJson.test.js","sourceRoot":"","sources":["../../../src/test/ConcurrentGetSchemaJson.test.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;AAE/F,+BAAsC;AACtC,yBAAyB;AACzB,6BAA6B;AAC7B,gEAA2H;AAC3H,oEAAiE;AAEjE,QAAQ,CAAC,wCAAwC,EAAE,GAAG,EAAE;IACtD,MAAM,QAAQ,GAAW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;gBAC1B,eAAe,GAAG,CAAC,CAAC;gBACpB,OAAO,aAAa,CAAC,SAAS,CAAC,IAAI,6BAAS,CAAC,SAAS,CAAC,CAAC,CAAC;YAC3D,CAAC;YACD,OAAO,aAAa,CAAC,SAAS,CAAC,IAAI,6BAAS,CAAC,sBAAsB,CAAC,CAAC,CAAC;QACxE,CAAC,CAAC,CACH,CAAC;QACF,IAAA,aAAM,EAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAC7C,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YACzB,IAAA,aAAM,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC;QACrC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { assert, expect } from \"chai\";\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport { ECVersion, Schema, SchemaContext, SchemaJsonLocater, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\nimport { SchemaJsonFileLocater } from \"../SchemaJsonFileLocater\";\n\ndescribe(\"Concurrent schema JSON deserialization\", () => {\n const assetDir: string = path.join(__dirname, \"assets\");\n const schemaFolder = path.join(__dirname, \"assets\", \"json\");\n\n const schemaKeys: SchemaKey[] = [];\n let context: SchemaContext;\n let contextSync: SchemaContext;\n let syncSchemas: Array<Schema | undefined> = [];\n\n const locater = new SchemaJsonFileLocater();\n\n before(() => {\n if (!fs.existsSync(assetDir))\n fs.mkdirSync(assetDir);\n if (!fs.existsSync(schemaFolder))\n fs.mkdirSync(schemaFolder);\n\n copySchemasToAssetsDir();\n\n // Deserialize schemas synchronously/serially as standard to compare to\n contextSync = new SchemaContext();\n locater.addSchemaSearchPath(schemaFolder);\n contextSync.addLocater(locater);\n\n const schemaFiles = fs.readdirSync(schemaFolder);\n schemaFiles.forEach((fileName) => {\n const schemaFile = path.join(schemaFolder, fileName);\n const schemaJson = JSON.parse(fs.readFileSync(schemaFile, \"utf-8\"));\n const schemaName = schemaJson.name;\n const schemaVersion = schemaJson.version;\n\n const key = new SchemaKey(schemaName.toString(), ECVersion.fromString(schemaVersion.toString()));\n schemaKeys.push(key);\n });\n\n syncSchemas = schemaKeys.map((key): Schema | undefined => {\n if (!key)\n return undefined;\n\n const schema = contextSync.getSchemaSync(key, SchemaMatchType.Latest);\n return schema;\n });\n });\n\n beforeEach(() => {\n context = new SchemaContext();\n context.addLocater(locater);\n });\n\n function getSchemaPathFromPackage(packageName: string, schemaFileName: string): string {\n const schemaFile = path.join(__dirname, \"..\", \"..\", \"..\", \"node_modules\", \"@bentley\", packageName, schemaFileName);\n return schemaFile;\n }\n\n function copySchemasToAssetsDir() {\n // Copy Schemas that we need for testing\n fs.copyFileSync(getSchemaPathFromPackage(\"aec-units-schema\", \"AecUnits.ecschema.json\"), path.join(schemaFolder, \"AecUnits.ecschema.json\"));\n fs.copyFileSync(getSchemaPathFromPackage(\"architectural-physical-schema\", \"ArchitecturalPhysical.ecschema.json\"), path.join(schemaFolder, \"ArchitecturalPhysical.ecschema.json\"));\n fs.copyFileSync(getSchemaPathFromPackage(\"bis-core-schema\", \"BisCore.ecschema.json\"), path.join(schemaFolder, \"BisCore.ecschema.json\"));\n fs.copyFileSync(getSchemaPathFromPackage(\"bis-custom-attributes-schema\", \"BisCustomAttributes.ecschema.json\"), path.join(schemaFolder, \"BisCustomAttributes.ecschema.json\"));\n fs.copyFileSync(getSchemaPathFromPackage(\"construction-schema\", \"Construction.ecschema.json\"), path.join(schemaFolder, \"Construction.ecschema.json\"));\n fs.copyFileSync(getSchemaPathFromPackage(\"core-custom-attributes-schema\", \"CoreCustomAttributes.ecschema.json\"), path.join(schemaFolder, \"CoreCustomAttributes.ecschema.json\"));\n fs.copyFileSync(getSchemaPathFromPackage(\"ecdb-map-schema\", \"ECDbMap.ecschema.json\"), path.join(schemaFolder, \"ECDbMap.ecschema.json\"));\n fs.copyFileSync(getSchemaPathFromPackage(\"ecdb-schema-policies-schema\", \"ECDbSchemaPolicies.ecschema.json\"), path.join(schemaFolder, \"ECDbSchemaPolicies.ecschema.json\"));\n fs.copyFileSync(getSchemaPathFromPackage(\"formats-schema\", \"Formats.ecschema.json\"), path.join(schemaFolder, \"Formats.ecschema.json\"));\n fs.copyFileSync(getSchemaPathFromPackage(\"linear-referencing-schema\", \"LinearReferencing.ecschema.json\"), path.join(schemaFolder, \"LinearReferencing.ecschema.json\"));\n fs.copyFileSync(getSchemaPathFromPackage(\"physical-material-schema\", \"PhysicalMaterial.ecschema.json\"), path.join(schemaFolder, \"PhysicalMaterial.ecschema.json\"));\n fs.copyFileSync(getSchemaPathFromPackage(\"plant-custom-attributes-schema\", \"PlantCustomAttributes.ecschema.json\"), path.join(schemaFolder, \"PlantCustomAttributes.ecschema.json\"));\n fs.copyFileSync(getSchemaPathFromPackage(\"quantity-takeoffs-aspects-schema\", \"QuantityTakeoffsAspects.ecschema.json\"), path.join(schemaFolder, \"QuantityTakeoffsAspects.ecschema.json\"));\n fs.copyFileSync(getSchemaPathFromPackage(\"spatial-composition-schema\", \"SpatialComposition.ecschema.json\"), path.join(schemaFolder, \"SpatialComposition.ecschema.json\"));\n fs.copyFileSync(getSchemaPathFromPackage(\"structural-physical-schema\", \"StructuralPhysical.ecschema.json\"), path.join(schemaFolder, \"StructuralPhysical.ecschema.json\"));\n fs.copyFileSync(getSchemaPathFromPackage(\"units-schema\", \"Units.ecschema.json\"), path.join(schemaFolder, \"Units.ecschema.json\"));\n }\n\n it(\"should match schemas deserialized concurrently with schemas deserialized serially\", async () => {\n const schemaPromises = schemaKeys.map(async (key): Promise<Schema | undefined> => {\n if (!key)\n return undefined;\n\n const schema = await context.getSchema(key, SchemaMatchType.Latest);\n return schema;\n });\n const asyncSchemas = await Promise.all(schemaPromises);\n\n for (let i = 0; i < schemaKeys.length; i++) {\n const syncSchema = syncSchemas[i];\n expect(syncSchema).not.to.be.undefined;\n const syncJSON = syncSchema!.toJSON();\n\n const asyncSchema = asyncSchemas[i];\n expect(asyncSchema).not.to.be.undefined;\n const asyncJSON = asyncSchema!.toJSON();\n expect(asyncJSON).to.deep.equal(syncJSON);\n }\n });\n\n it(\"should be able to mix getSchema and getSchemaSync\", async () => {\n const schemaPromises = schemaKeys.map(async (key, index): Promise<Schema | undefined> => {\n if (index % 2 === 0) {\n // Use getSchema() for even indices\n if (!key)\n return undefined;\n\n const schema = await context.getSchema(key, SchemaMatchType.Latest);\n return schema;\n } else {\n // Use getSchemaSync() for odd indices\n if (!key)\n return undefined;\n\n const schema = context.getSchemaSync(key, SchemaMatchType.Latest);\n return schema;\n }\n });\n const schemas = await Promise.all(schemaPromises);\n\n for (let i = 0; i < schemaKeys.length; i++) {\n const syncSchema = syncSchemas[i];\n expect(syncSchema).not.to.be.undefined;\n const syncJSON = syncSchema!.toJSON();\n\n const schema = schemas[i];\n expect(schema).not.to.be.undefined;\n const schemaJSON = schema!.toJSON();\n expect(schemaJSON).to.deep.equal(syncJSON);\n }\n });\n\n /* Run these tests below one at a time. Running them together doesn't get accurate performance likely bc of disk access caching */\n it.skip(\"should measure regular deserialization performance\", async () => {\n const schemaPromises = schemaKeys.map(async (key): Promise<Schema | undefined> => {\n if (!key)\n return undefined;\n\n const schema = await context.getSchema(key, SchemaMatchType.Latest);\n return schema;\n });\n\n for (const promise of schemaPromises) {\n await promise;\n }\n\n expect(schemaPromises.length).to.equal(schemaKeys.length);\n });\n\n it.skip(\"should measure concurrent deserialization performance\", async () => {\n const schemaPromises = schemaKeys.map(async (key): Promise<Schema | undefined> => {\n if (!key)\n return undefined;\n\n const schema = await context.getSchema(key, SchemaMatchType.Latest);\n return schema;\n });\n const asyncSchemas = await Promise.all(schemaPromises);\n\n expect(asyncSchemas.length).to.equal(schemaKeys.length);\n });\n\n it(\"Concurrently get BisCore with SchemaJsonFileLocater\", async () => {\n const schemaContext = new SchemaContext();\n const jsonFileLocater = new SchemaJsonFileLocater();\n jsonFileLocater.addSchemaSearchPath(schemaFolder);\n schemaContext.addLocater(jsonFileLocater);\n\n const schemas = await Promise.all(\n [...Array(100).keys()].map(async () => {\n return schemaContext.getSchema(new SchemaKey(\"BisCore\"));\n }),\n );\n expect(schemas.length).to.equal(100);\n schemas.forEach((schema) => {\n assert(schema !== undefined);\n expect(schema.fullName).to.equal(\"BisCore\");\n });\n });\n\n it(\"Concurrently get a schema and it's referenced schema with SchemaJsonFileLocater\", async () => {\n const schemaContext = new SchemaContext();\n const jsonFileLocater = new SchemaJsonFileLocater();\n jsonFileLocater.addSchemaSearchPath(schemaFolder);\n schemaContext.addLocater(jsonFileLocater);\n\n let getBisCoreFirst = 0;\n const schemas = await Promise.all(\n [...Array(2).keys()].map(async () => {\n if (getBisCoreFirst === 0) {\n getBisCoreFirst = 1;\n return schemaContext.getSchema(new SchemaKey(\"BisCore\"));\n }\n return schemaContext.getSchema(new SchemaKey(\"CoreCustomAttributes\"));\n }),\n );\n expect(schemas.length).to.equal(2);\n schemas.forEach((schema) => {\n expect(schema).to.not.be.undefined;\n });\n });\n\n const getSchemaProps = (schemaName: string) => {\n if (schemaName === \"BisCore\") {\n return {\n $schema: \"https://dev.bentley.com/json_schemas/ec/32/ecschema\",\n alias: \"bis\",\n description: \"The BIS core schema contains classes that all other domain schemas extend.\",\n label: \"BIS Core\",\n name: \"BisCore\",\n version: \"01.00.15\",\n references:[{name:\"CoreCustomAttributes\", version:\"01.00.04\"},{name:\"ECDbMap\", version:\"02.00.00\"},{name:\"ECDbSchemaPolicies\", version:\"01.00.00\"}],\n };\n }\n if (schemaName === \"CoreCustomAttributes\") {\n return {\n $schema: \"https://dev.bentley.com/json_schemas/ec/32/ecschema\",\n alias: \"CoreCA\",\n description: \"Custom attributes to indicate core EC concepts, may include struct classes intended for use in core custom attributes.\",\n label: \"Core Custom Attributes\",\n name: \"CoreCustomAttributes\",\n version: \"01.00.04\",\n };\n }\n if (schemaName === \"ECDbMap\") {\n return {\n $schema: \"https://dev.bentley.com/json_schemas/ec/32/ecschema\",\n alias: \"ECDbMap\",\n description: \"ECDbMap Desc\",\n label: \"ECDbMap\",\n name: \"ECDbMap\",\n version: \"02.00.00\",\n };\n }\n if (schemaName === \"ECDbSchemaPolicies\") {\n return {\n $schema: \"https://dev.bentley.com/json_schemas/ec/32/ecschema\",\n alias: \"ECDbSchemaPolicies\",\n description: \"ECDbSchemaPolicies Desc\",\n label: \"ECDbSchemaPolicies\",\n name: \"ECDbSchemaPolicies\",\n version: \"01.00.00\",\n };\n }\n\n return undefined;\n };\n\n it(\"Concurrently get BisCore with SchemaJsonLocater\", async () => {\n const schemaContext = new SchemaContext();\n const jsonLocater = new SchemaJsonLocater(getSchemaProps);\n schemaContext.addLocater(jsonLocater);\n\n const schemaCount = 1000;\n const schemas = await Promise.all(\n [...Array(schemaCount).keys()].map(async () => {\n return schemaContext.getSchema(new SchemaKey(\"BisCore\"));\n }),\n );\n expect(schemas.length).to.equal(schemaCount);\n schemas.forEach((schema) => {\n assert(schema !== undefined);\n expect(schema.fullName).to.equal(\"BisCore\");\n });\n });\n\n it(\"Concurrently get a schema and it's referenced schema with SchemaJsonLocater\", async () => {\n const schemaContext = new SchemaContext();\n const jsonLocater = new SchemaJsonLocater(getSchemaProps);\n schemaContext.addLocater(jsonLocater);\n\n let getBisCoreFirst = 0;\n const schemaCount = 1000;\n const schemas = await Promise.all(\n [...Array(schemaCount).keys()].map(async () => {\n if (getBisCoreFirst === 0) {\n getBisCoreFirst = 1;\n return schemaContext.getSchema(new SchemaKey(\"BisCore\"));\n }\n return schemaContext.getSchema(new SchemaKey(\"CoreCustomAttributes\"));\n }),\n );\n expect(schemas.length).to.equal(schemaCount);\n schemas.forEach((schema) => {\n expect(schema).to.not.be.undefined;\n });\n });\n});\n"]}
|