@itwin/ecschema-locaters 5.0.0-dev.98 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -1
- package/lib/cjs/SchemaFileLocater.d.ts +13 -6
- package/lib/cjs/SchemaFileLocater.d.ts.map +1 -1
- package/lib/cjs/SchemaFileLocater.js +9 -2
- package/lib/cjs/SchemaFileLocater.js.map +1 -1
- package/lib/cjs/SchemaJsonFileLocater.d.ts +2 -1
- 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/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 +2 -2
- package/lib/cjs/SchemaXmlFileLocater.d.ts.map +1 -1
- package/lib/cjs/SchemaXmlFileLocater.js +4 -4
- package/lib/cjs/SchemaXmlFileLocater.js.map +1 -1
- 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.map +1 -1
- package/lib/cjs/StubSchemaXmlFileLocater.js +9 -9
- package/lib/cjs/StubSchemaXmlFileLocater.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/SchemaXmlFileLocator.test.js +9 -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 +13 -6
- package/lib/esm/SchemaFileLocater.d.ts.map +1 -1
- package/lib/esm/SchemaFileLocater.js +9 -2
- package/lib/esm/SchemaFileLocater.js.map +1 -1
- package/lib/esm/SchemaJsonFileLocater.d.ts +2 -1
- package/lib/esm/SchemaJsonFileLocater.d.ts.map +1 -1
- package/lib/esm/SchemaJsonFileLocater.js +5 -4
- package/lib/esm/SchemaJsonFileLocater.js.map +1 -1
- package/lib/esm/SchemaXml.d.ts +1 -1
- package/lib/esm/SchemaXml.js +1 -1
- package/lib/esm/SchemaXml.js.map +1 -1
- package/lib/esm/SchemaXmlFileLocater.d.ts +2 -2
- package/lib/esm/SchemaXmlFileLocater.d.ts.map +1 -1
- package/lib/esm/SchemaXmlFileLocater.js +5 -5
- package/lib/esm/SchemaXmlFileLocater.js.map +1 -1
- package/lib/esm/SchemaXmlStringLocater.d.ts.map +1 -1
- package/lib/esm/SchemaXmlStringLocater.js +5 -5
- package/lib/esm/SchemaXmlStringLocater.js.map +1 -1
- package/lib/esm/StubSchemaXmlFileLocater.d.ts.map +1 -1
- package/lib/esm/StubSchemaXmlFileLocater.js +10 -10
- package/lib/esm/StubSchemaXmlFileLocater.js.map +1 -1
- package/lib/esm/test/SchemaJsonFileLocator.test.js +2 -2
- package/lib/esm/test/SchemaJsonFileLocator.test.js.map +1 -1
- package/lib/esm/test/SchemaXmlFileLocator.test.js +10 -10
- package/lib/esm/test/SchemaXmlFileLocator.test.js.map +1 -1
- package/lib/esm/test/SchemaXmlStringLocater.test.js +10 -10
- package/lib/esm/test/SchemaXmlStringLocater.test.js.map +1 -1
- package/lib/esm/test/StubSchemaXmlFileLocater.test.js +9 -8
- package/lib/esm/test/StubSchemaXmlFileLocater.test.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,51 @@
|
|
|
1
1
|
# Change Log - @itwin/ecschema-locaters
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Fri, 13 Jun 2025 20:25:38 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 5.0.0
|
|
6
|
+
Fri, 13 Jun 2025 20:25:38 GMT
|
|
7
|
+
|
|
8
|
+
### Updates
|
|
9
|
+
|
|
10
|
+
- Added ESM support
|
|
11
|
+
- Implemented new schema locater PublishedSchemaXmlFileLocater that will locate/load schemas from published schema xml files.
|
|
12
|
+
- applied changes in ecschema-metadatas SchemaLocater interface
|
|
13
|
+
- Change core peer dependencies to strict version.
|
|
14
|
+
|
|
15
|
+
## 4.11.5
|
|
16
|
+
Fri, 06 Jun 2025 13:41:18 GMT
|
|
17
|
+
|
|
18
|
+
_Version update only_
|
|
19
|
+
|
|
20
|
+
## 4.11.4
|
|
21
|
+
Tue, 03 Jun 2025 16:15:19 GMT
|
|
22
|
+
|
|
23
|
+
_Version update only_
|
|
24
|
+
|
|
25
|
+
## 4.11.3
|
|
26
|
+
Wed, 28 May 2025 13:56:23 GMT
|
|
27
|
+
|
|
28
|
+
_Version update only_
|
|
29
|
+
|
|
30
|
+
## 4.11.2
|
|
31
|
+
Tue, 20 May 2025 20:14:46 GMT
|
|
32
|
+
|
|
33
|
+
_Version update only_
|
|
34
|
+
|
|
35
|
+
## 4.11.1
|
|
36
|
+
Wed, 30 Apr 2025 13:13:21 GMT
|
|
37
|
+
|
|
38
|
+
_Version update only_
|
|
39
|
+
|
|
40
|
+
## 4.11.0
|
|
41
|
+
Wed, 16 Apr 2025 15:50:28 GMT
|
|
42
|
+
|
|
43
|
+
_Version update only_
|
|
44
|
+
|
|
45
|
+
## 4.10.13
|
|
46
|
+
Thu, 10 Apr 2025 17:47:21 GMT
|
|
47
|
+
|
|
48
|
+
_Version update only_
|
|
4
49
|
|
|
5
50
|
## 4.10.12
|
|
6
51
|
Wed, 02 Apr 2025 19:35:47 GMT
|
|
@@ -7,7 +7,7 @@ import { Schema, SchemaContext, SchemaKey, SchemaMatchType } from "@itwin/ecsche
|
|
|
7
7
|
* addition of two properties: fileName and schemaText. The fileName contains the
|
|
8
8
|
* full path to the file on disk and schemaText is the full string representation
|
|
9
9
|
* of the Schema.
|
|
10
|
-
* @
|
|
10
|
+
* @internal
|
|
11
11
|
*/
|
|
12
12
|
export declare class FileSchemaKey extends SchemaKey {
|
|
13
13
|
fileName: string;
|
|
@@ -23,15 +23,20 @@ export declare class FileSchemaKey extends SchemaKey {
|
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* Abstract class to hold common/overlapping functionality between SchemaJsonFileLocater and SchemaXmlFileLocater
|
|
26
|
-
* @
|
|
26
|
+
* @public @preview
|
|
27
27
|
*/
|
|
28
28
|
export declare abstract class SchemaFileLocater {
|
|
29
|
+
/** @internal */
|
|
29
30
|
searchPaths: string[];
|
|
30
31
|
constructor();
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
/** @internal */
|
|
33
|
+
protected readUtf8FileToString(filePath: string): Promise<string | undefined>;
|
|
34
|
+
/** @internal */
|
|
35
|
+
protected readUtf8FileToStringSync(filePath: string): string | undefined;
|
|
36
|
+
/** @internal */
|
|
37
|
+
protected fileExists(filePath: string): Promise<boolean | undefined>;
|
|
38
|
+
/** @internal */
|
|
39
|
+
protected fileExistsSync(filePath: string): boolean | undefined;
|
|
35
40
|
/**
|
|
36
41
|
* Adds more search paths used by this locator to find the
|
|
37
42
|
* Schema files.
|
|
@@ -72,6 +77,7 @@ export declare abstract class SchemaFileLocater {
|
|
|
72
77
|
* @param desiredKey The SchemaKey to match.
|
|
73
78
|
* @param matchType The SchemaMatchType.
|
|
74
79
|
* @param format The type of file that the schema key refers to. json or xml
|
|
80
|
+
* @internal
|
|
75
81
|
*/
|
|
76
82
|
protected findEligibleSchemaKeys(desiredKey: SchemaKey, matchType: SchemaMatchType, format: string): FileSchemaKey[];
|
|
77
83
|
/**
|
|
@@ -88,6 +94,7 @@ export declare abstract class SchemaFileLocater {
|
|
|
88
94
|
* left-hand version is less, -1 us returned. If the versions are an exact match, 0 is returned.
|
|
89
95
|
* @param lhs The 'left-hand' FileSchemaKey.
|
|
90
96
|
* @param rhs The 'right-hand' FileSchemaKey.
|
|
97
|
+
* @internal
|
|
91
98
|
*/
|
|
92
99
|
compareSchemaKeyByVersion: (lhs: FileSchemaKey, rhs: FileSchemaKey) => number;
|
|
93
100
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaFileLocater.d.ts","sourceRoot":"","sources":["../../src/SchemaFileLocater.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAwB7F;;;;;;GAMG;AACH,qBAAa,aAAc,SAAQ,SAAS;IAEnC,QAAQ,EAAE,MAAM,CAAC;IAEjB,UAAU,CAAC,EAAE,MAAM,CAAC;IAE3B;;;;;;OAMG;gBACS,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;CAKlE;AAED;;;GAGG;AACH,8BAAsB,iBAAiB;
|
|
1
|
+
{"version":3,"file":"SchemaFileLocater.d.ts","sourceRoot":"","sources":["../../src/SchemaFileLocater.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAwB7F;;;;;;GAMG;AACH,qBAAa,aAAc,SAAQ,SAAS;IAEnC,QAAQ,EAAE,MAAM,CAAC;IAEjB,UAAU,CAAC,EAAE,MAAM,CAAC;IAE3B;;;;;;OAMG;gBACS,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;CAKlE;AAED;;;GAGG;AACH,8BAAsB,iBAAiB;IACrC,gBAAgB;IACT,WAAW,EAAE,MAAM,EAAE,CAAC;;IAM7B,gBAAgB;cACA,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAWnF,gBAAgB;IAChB,SAAS,CAAC,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIxE,gBAAgB;cACA,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IAQ1E,gBAAgB;IAChB,SAAS,CAAC,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAI/D;;;;OAIG;IACI,oBAAoB,CAAC,WAAW,EAAE,MAAM,EAAE;IAMjD;;;;OAIG;IACI,mBAAmB,CAAC,UAAU,EAAE,MAAM;IAM7C,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS;IAExD;;;;;;;;;OASG;IACH,OAAO,CAAC,0BAA0B;IAoBlC;;;;;;;;OAQG;IACH,OAAO,CAAC,sBAAsB;IAwB9B;;;;;;;OAOG;IACH,SAAS,CAAC,sBAAsB,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,GAAG,aAAa,EAAE;IAmCpH;;;;;;;OAOG;aACa,SAAS,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAE1H;;;;;;OAMG;IACI,yBAAyB,QAAS,aAAa,OAAO,aAAa,KAAG,MAAM,CAEjF;CACH"}
|
|
@@ -38,7 +38,7 @@ const padStartEx = (str, targetLength, padString) => {
|
|
|
38
38
|
* addition of two properties: fileName and schemaText. The fileName contains the
|
|
39
39
|
* full path to the file on disk and schemaText is the full string representation
|
|
40
40
|
* of the Schema.
|
|
41
|
-
* @
|
|
41
|
+
* @internal
|
|
42
42
|
*/
|
|
43
43
|
class FileSchemaKey extends ecschema_metadata_1.SchemaKey {
|
|
44
44
|
// The schema file associated with the SchemaKey
|
|
@@ -61,13 +61,15 @@ class FileSchemaKey extends ecschema_metadata_1.SchemaKey {
|
|
|
61
61
|
exports.FileSchemaKey = FileSchemaKey;
|
|
62
62
|
/**
|
|
63
63
|
* Abstract class to hold common/overlapping functionality between SchemaJsonFileLocater and SchemaXmlFileLocater
|
|
64
|
-
* @
|
|
64
|
+
* @public @preview
|
|
65
65
|
*/
|
|
66
66
|
class SchemaFileLocater {
|
|
67
|
+
/** @internal */
|
|
67
68
|
searchPaths;
|
|
68
69
|
constructor() {
|
|
69
70
|
this.searchPaths = [];
|
|
70
71
|
}
|
|
72
|
+
/** @internal */
|
|
71
73
|
async readUtf8FileToString(filePath) {
|
|
72
74
|
return new Promise((resolve, reject) => {
|
|
73
75
|
fs.readFile(filePath, "utf-8", (err, data) => {
|
|
@@ -78,9 +80,11 @@ class SchemaFileLocater {
|
|
|
78
80
|
});
|
|
79
81
|
});
|
|
80
82
|
}
|
|
83
|
+
/** @internal */
|
|
81
84
|
readUtf8FileToStringSync(filePath) {
|
|
82
85
|
return fs.readFileSync(filePath, "utf-8");
|
|
83
86
|
}
|
|
87
|
+
/** @internal */
|
|
84
88
|
async fileExists(filePath) {
|
|
85
89
|
return new Promise((resolve) => {
|
|
86
90
|
fs.access(filePath, fs.constants.F_OK, (err) => {
|
|
@@ -88,6 +92,7 @@ class SchemaFileLocater {
|
|
|
88
92
|
});
|
|
89
93
|
});
|
|
90
94
|
}
|
|
95
|
+
/** @internal */
|
|
91
96
|
fileExistsSync(filePath) {
|
|
92
97
|
return fs.existsSync(filePath);
|
|
93
98
|
}
|
|
@@ -171,6 +176,7 @@ class SchemaFileLocater {
|
|
|
171
176
|
* @param desiredKey The SchemaKey to match.
|
|
172
177
|
* @param matchType The SchemaMatchType.
|
|
173
178
|
* @param format The type of file that the schema key refers to. json or xml
|
|
179
|
+
* @internal
|
|
174
180
|
*/
|
|
175
181
|
findEligibleSchemaKeys(desiredKey, matchType, format) {
|
|
176
182
|
const foundFiles = new Array();
|
|
@@ -209,6 +215,7 @@ class SchemaFileLocater {
|
|
|
209
215
|
* left-hand version is less, -1 us returned. If the versions are an exact match, 0 is returned.
|
|
210
216
|
* @param lhs The 'left-hand' FileSchemaKey.
|
|
211
217
|
* @param rhs The 'right-hand' FileSchemaKey.
|
|
218
|
+
* @internal
|
|
212
219
|
*/
|
|
213
220
|
compareSchemaKeyByVersion = (lhs, rhs) => {
|
|
214
221
|
return lhs.compareByVersion(rhs);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaFileLocater.js","sourceRoot":"","sources":["../../src/SchemaFileLocater.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,yBAAyB;AACzB,+BAAgC;AAChC,6BAA6B;AAC7B,gEAA6F;AAE7F,MAAM,YAAY,GAAG,CAAC,MAAc,EAAE,GAAG,IAAc,EAAE,EAAE;IACzD,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE;QACrD,OAAO,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,WAAW;YAC3C,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;YACjB,CAAC,CAAC,KAAK,CAAC;IACZ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,YAAoB,EAAE,SAAiB,EAAE,EAAE;IAC1E,YAAY,GAAG,YAAY,IAAI,CAAC,CAAC,CAAC,iDAAiD;IACnF,SAAS,GAAG,MAAM,CAAC,CAAC,OAAO,SAAS,KAAK,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACzE,IAAI,GAAG,CAAC,MAAM,GAAG,YAAY,EAAE,CAAC;QAC9B,OAAO,MAAM,CAAC,GA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AAE,SAAS,EAAE,MAAM,CAAC,CAAC;QAC7G,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;IAYD;;;;;OAKG;IACI,yBAAyB,GAAG,CAAC,GAAkB,EAAE,GAAkB,EAAU,EAAE;QACpF,OAAO,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC,CAAC;CACH;AAtLD,8CAsLC","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 fs from \"fs\";\nimport { globSync } from \"glob\";\nimport * as path from \"path\";\nimport { Schema, SchemaContext, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\n\nconst formatString = (format: string, ...args: string[]) => {\n return format.replace(/{(\\d+)}/g, (match, theNumber) => {\n return typeof args[theNumber] !== \"undefined\"\n ? args[theNumber]\n : match;\n });\n};\n\nconst padStartEx = (str: string, targetLength: number, padString: string) => {\n targetLength = targetLength >> 0; // truncate if number or convert non-number to 0;\n padString = String((typeof padString !== \"undefined\" ? padString : \" \"));\n if (str.length > targetLength) {\n return String(str);\n } else {\n targetLength = targetLength - str.length;\n if (targetLength > padString.length) {\n padString += padString.repeat(targetLength / padString.length); // append to original to ensure we are longer than needed\n }\n return padString.slice(0, targetLength) + str;\n }\n};\n\n/**\n * A SchemaKey implementation that aids in identifying Schema files via the\n * addition of two properties: fileName and schemaText. The fileName contains the\n * full path to the file on disk and schemaText is the full string representation\n * of the Schema.\n * @beta\n */\nexport class FileSchemaKey extends SchemaKey {\n // The schema file associated with the SchemaKey\n public fileName: string;\n // The JSON text for the schema loaded\n public schemaText?: string;\n\n /**\n * Initializes a new FileSchemaKey object.\n * @param key The EC SchemaKey identifying the Schema.\n * @param fileName The full path to the Schema file.\n * @param schemaText The string representation of the Schema\n * loaded from disk. Optional.\n */\n constructor(key: SchemaKey, fileName: string, schemaJson?: string) {\n super(key.name, key.version);\n this.fileName = fileName;\n this.schemaText = schemaJson;\n }\n}\n\n/**\n * Abstract class to hold common/overlapping functionality between SchemaJsonFileLocater and SchemaXmlFileLocater\n * @beta - Needs further testing and possibly moved to a separate package.\n */\nexport abstract class SchemaFileLocater {\n public searchPaths: string[];\n\n constructor() {\n this.searchPaths = [];\n }\n\n public async readUtf8FileToString(filePath: string): Promise<string | undefined> {\n return new Promise<string | undefined>((resolve, reject) => {\n fs.readFile(filePath, \"utf-8\", (err, data) => {\n if (err)\n reject(err);\n else\n resolve(data);\n });\n });\n }\n\n public readUtf8FileToStringSync(filePath: string): string | undefined {\n return fs.readFileSync(filePath, \"utf-8\");\n }\n\n public async fileExists(filePath: string): Promise<boolean | undefined> {\n return new Promise<boolean | undefined>((resolve) => {\n fs.access(filePath, fs.constants.F_OK, (err) => {\n resolve(err ? false : true);\n });\n });\n }\n\n public fileExistsSync(filePath: string): boolean | undefined {\n return fs.existsSync(filePath);\n }\n\n /**\n * Adds more search paths used by this locator to find the\n * Schema files.\n * @param schemaPaths An array of search paths to add\n */\n public addSchemaSearchPaths(schemaPaths: string[]) {\n // If the path is not in the schemaPaths array, add it\n for (const schemaPath of schemaPaths)\n this.addSchemaSearchPath(schemaPath);\n }\n\n /**\n * Add one search path used by this locator to find the\n * Schema files.\n * @param schemaPath A search path to add\n */\n public addSchemaSearchPath(schemaPath: string) {\n // If the path is not in the schemaPaths array, add it\n if (!this.searchPaths.find((entry) => entry === schemaPath))\n this.searchPaths.push(schemaPath);\n }\n\n protected abstract getSchemaKey(data: string): SchemaKey;\n\n /**\n * Adds SchemaKeys to the provided foundFiles collection that match the desired SchemaKey. This method\n * only attempts to find schema files that have no version in the file name.\n * @param foundFiles The collection of SchemaKeys found in the given directory.\n * @param schemaPath The directory in which to search for the Schemas.\n * @param schemaName The short name of the Schema (without version).\n * @param desiredKey The SchemaKey used to find matching Schema files.\n * @param matchType The SchemaMatchType to use when comparing the desiredKey and the keys found during the search.\n * @param format The type of file that the schema key refers to. json or xml\n */\n private addCandidateNoExtSchemaKey(foundFiles: FileSchemaKey[], schemaPath: string, schemaName: string, desiredKey: SchemaKey, matchType: SchemaMatchType, format: string) {\n const fullPath = path.join(schemaPath, `${schemaName}.ecschema.${format}`);\n\n // If the file does not exist, end\n if (!fs.existsSync(fullPath))\n return;\n\n // Read the file\n const file = fs.readFileSync(fullPath);\n if (!file)\n return;\n\n // Get the schema key\n const key = this.getSchemaKey(file.toString());\n\n // If the key matches, put it in foundFiles\n if (key.matches(desiredKey, matchType))\n foundFiles.push(new FileSchemaKey(key, fullPath, file.toString()));\n }\n\n /**\n * Adds SchemaKeys to the provided foundFiles collection that match the desired SchemaKey\n * @param foundFiles The collection of SchemaKeys found in the given directory\n * @param schemaPath The directory in which to search for the Schemas\n * @param fileFilter The file filter, potentially with wildcards, used to locate the Schema files.\n * @param desiredKey The schemaKey used to find matching Schema files\n * @param matchType The SchemaMatchType to use when comparing the desired Key and the keys found during the search.\n * @param format The type of file that the schema key refers to. json or xml\n */\n private addCandidateSchemaKeys(foundFiles: FileSchemaKey[], schemaPath: string, fileFilter: string, desiredKey: SchemaKey, matchType: SchemaMatchType, format: string) {\n const fullPath = path.join(schemaPath, fileFilter);\n\n const result = globSync(fullPath, { windowsPathsNoEscape: true });\n for (const match of result) {\n let fileName = path.basename(match, (`.ecschema.${format}`));\n // TODO: should this be moved or handled elsewhere?\n // Handles two version file names - SchemaKey.parseString supports only 3 version names.\n if (/[^\\d]\\.\\d?\\d\\.\\d?\\d$/.test(fileName)) {\n const parts = fileName.split(\".\");\n parts.splice(2, 0, \"00\");\n fileName = parts.join(\".\");\n }\n\n const file = fs.readFileSync(match);\n if (!file)\n continue;\n\n const schemaKey = SchemaKey.parseString(fileName);\n if (schemaKey.matches(desiredKey, matchType))\n foundFiles.push(new FileSchemaKey(schemaKey, match, file.toString()));\n }\n }\n\n /**\n * Attempts to find all Schema files in the configurable search paths that match\n * the desired SchemaKey.\n * @param desiredKey The SchemaKey to match.\n * @param matchType The SchemaMatchType.\n * @param format The type of file that the schema key refers to. json or xml\n */\n protected findEligibleSchemaKeys(desiredKey: SchemaKey, matchType: SchemaMatchType, format: string): FileSchemaKey[] {\n const foundFiles = new Array<FileSchemaKey>();\n\n let twoVersionSuffix: string;\n let threeVersionSuffix: string;\n const readVersion = desiredKey.readVersion.toString();\n const writeVersion = desiredKey.writeVersion.toString();\n const minorVersion = desiredKey.minorVersion.toString();\n\n if (matchType === SchemaMatchType.Latest) {\n twoVersionSuffix = (`.*.*.ecschema.${format}`);\n threeVersionSuffix = (`.*.*.*.ecschema.${format}`);\n } else if (matchType === SchemaMatchType.LatestWriteCompatible) {\n twoVersionSuffix = formatString(`.{0}.*.ecschema.${format}`, padStartEx(readVersion, 2, \"0\"));\n threeVersionSuffix = formatString(`.{0}.{1}.*.ecschema.${format}`, padStartEx(readVersion, 2, \"0\"), padStartEx(writeVersion, 2, \"0\"));\n } else if (matchType === SchemaMatchType.LatestReadCompatible) {\n twoVersionSuffix = formatString(`.{0}.*.ecschema.${format}`, padStartEx(readVersion, 2, \"0\"));\n threeVersionSuffix = formatString(`.{0}.*.*.ecschema.${format}`, padStartEx(readVersion, 2, \"0\"));\n } else {\n twoVersionSuffix = formatString(`.{0}.{1}.ecschema.${format}`, padStartEx(readVersion, 2, \"0\"), padStartEx(writeVersion, 2, \"0\"));\n threeVersionSuffix = formatString(`.{0}.{1}.{2}.ecschema.${format}`, padStartEx(readVersion, 2, \"0\"), padStartEx(writeVersion, 2, \"0\"), padStartEx(minorVersion, 2, \"0\"));\n }\n\n const twoVersionExpression = desiredKey.name + twoVersionSuffix;\n const threeVersionExpression = desiredKey.name + threeVersionSuffix;\n\n for (const searchPath of this.searchPaths) {\n this.addCandidateNoExtSchemaKey(foundFiles, searchPath, desiredKey.name, desiredKey, matchType, format);\n this.addCandidateSchemaKeys(foundFiles, searchPath, twoVersionExpression, desiredKey, matchType, format);\n this.addCandidateSchemaKeys(foundFiles, searchPath, threeVersionExpression, desiredKey, matchType, format);\n }\n\n return foundFiles;\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 abstract getSchema(key: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<Schema | undefined>;\n\n /**\n * Compares two Schema versions. If the left-hand version is greater, 1 is returned. If the\n * left-hand version is less, -1 us returned. If the versions are an exact match, 0 is returned.\n * @param lhs The 'left-hand' FileSchemaKey.\n * @param rhs The 'right-hand' FileSchemaKey.\n */\n public compareSchemaKeyByVersion = (lhs: FileSchemaKey, rhs: FileSchemaKey): number => {\n return lhs.compareByVersion(rhs);\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SchemaFileLocater.js","sourceRoot":"","sources":["../../src/SchemaFileLocater.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,yBAAyB;AACzB,+BAAgC;AAChC,6BAA6B;AAC7B,gEAA6F;AAE7F,MAAM,YAAY,GAAG,CAAC,MAAc,EAAE,GAAG,IAAc,EAAE,EAAE;IACzD,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE;QACrD,OAAO,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,WAAW;YAC3C,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;YACjB,CAAC,CAAC,KAAK,CAAC;IACZ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,YAAoB,EAAE,SAAiB,EAAE,EAAE;IAC1E,YAAY,GAAG,YAAY,IAAI,CAAC,CAAC,CAAC,iDAAiD;IACnF,SAAS,GAAG,MAAM,CAAC,CAAC,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AAU,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;YACxG,IAAI,CAAC,sBAAsB,CAAC,UAAU,EAAE,UAAU,EAAE,oBAAoB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;YACzG,IAAI,CAAC,sBAAsB,CAAC,UAAU,EAAE,UAAU,EAAE,sBAAsB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QAC7G,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;IAYD;;;;;;OAMG;IACI,yBAAyB,GAAG,CAAC,GAAkB,EAAE,GAAkB,EAAU,EAAE;QACpF,OAAO,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC,CAAC;CACH;AA7LD,8CA6LC","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 fs from \"fs\";\nimport { globSync } from \"glob\";\nimport * as path from \"path\";\nimport { Schema, SchemaContext, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\n\nconst formatString = (format: string, ...args: string[]) => {\n return format.replace(/{(\\d+)}/g, (match, theNumber) => {\n return typeof args[theNumber] !== \"undefined\"\n ? args[theNumber]\n : match;\n });\n};\n\nconst padStartEx = (str: string, targetLength: number, padString: string) => {\n targetLength = targetLength >> 0; // truncate if number or convert non-number to 0;\n padString = String((typeof padString !== \"undefined\" ? padString : \" \"));\n if (str.length > targetLength) {\n return String(str);\n } else {\n targetLength = targetLength - str.length;\n if (targetLength > padString.length) {\n padString += padString.repeat(targetLength / padString.length); // append to original to ensure we are longer than needed\n }\n return padString.slice(0, targetLength) + str;\n }\n};\n\n/**\n * A SchemaKey implementation that aids in identifying Schema files via the\n * addition of two properties: fileName and schemaText. The fileName contains the\n * full path to the file on disk and schemaText is the full string representation\n * of the Schema.\n * @internal\n */\nexport class FileSchemaKey extends SchemaKey {\n // The schema file associated with the SchemaKey\n public fileName: string;\n // The JSON text for the schema loaded\n public schemaText?: string;\n\n /**\n * Initializes a new FileSchemaKey object.\n * @param key The EC SchemaKey identifying the Schema.\n * @param fileName The full path to the Schema file.\n * @param schemaText The string representation of the Schema\n * loaded from disk. Optional.\n */\n constructor(key: SchemaKey, fileName: string, schemaJson?: string) {\n super(key.name, key.version);\n this.fileName = fileName;\n this.schemaText = schemaJson;\n }\n}\n\n/**\n * Abstract class to hold common/overlapping functionality between SchemaJsonFileLocater and SchemaXmlFileLocater\n * @public @preview\n */\nexport abstract class SchemaFileLocater {\n /** @internal */\n public searchPaths: string[];\n\n constructor() {\n this.searchPaths = [];\n }\n\n /** @internal */\n protected async readUtf8FileToString(filePath: string): Promise<string | undefined> {\n return new Promise<string | undefined>((resolve, reject) => {\n fs.readFile(filePath, \"utf-8\", (err, data) => {\n if (err)\n reject(err);\n else\n resolve(data);\n });\n });\n }\n\n /** @internal */\n protected readUtf8FileToStringSync(filePath: string): string | undefined {\n return fs.readFileSync(filePath, \"utf-8\");\n }\n\n /** @internal */\n protected async fileExists(filePath: string): Promise<boolean | undefined> {\n return new Promise<boolean | undefined>((resolve) => {\n fs.access(filePath, fs.constants.F_OK, (err) => {\n resolve(err ? false : true);\n });\n });\n }\n\n /** @internal */\n protected fileExistsSync(filePath: string): boolean | undefined {\n return fs.existsSync(filePath);\n }\n\n /**\n * Adds more search paths used by this locator to find the\n * Schema files.\n * @param schemaPaths An array of search paths to add\n */\n public addSchemaSearchPaths(schemaPaths: string[]) {\n // If the path is not in the schemaPaths array, add it\n for (const schemaPath of schemaPaths)\n this.addSchemaSearchPath(schemaPath);\n }\n\n /**\n * Add one search path used by this locator to find the\n * Schema files.\n * @param schemaPath A search path to add\n */\n public addSchemaSearchPath(schemaPath: string) {\n // If the path is not in the schemaPaths array, add it\n if (!this.searchPaths.find((entry) => entry === schemaPath))\n this.searchPaths.push(schemaPath);\n }\n\n protected abstract getSchemaKey(data: string): SchemaKey;\n\n /**\n * Adds SchemaKeys to the provided foundFiles collection that match the desired SchemaKey. This method\n * only attempts to find schema files that have no version in the file name.\n * @param foundFiles The collection of SchemaKeys found in the given directory.\n * @param schemaPath The directory in which to search for the Schemas.\n * @param schemaName The short name of the Schema (without version).\n * @param desiredKey The SchemaKey used to find matching Schema files.\n * @param matchType The SchemaMatchType to use when comparing the desiredKey and the keys found during the search.\n * @param format The type of file that the schema key refers to. json or xml\n */\n private addCandidateNoExtSchemaKey(foundFiles: FileSchemaKey[], schemaPath: string, schemaName: string, desiredKey: SchemaKey, matchType: SchemaMatchType, format: string) {\n const fullPath = path.join(schemaPath, `${schemaName}.ecschema.${format}`);\n\n // If the file does not exist, end\n if (!fs.existsSync(fullPath))\n return;\n\n // Read the file\n const file = fs.readFileSync(fullPath);\n if (!file)\n return;\n\n // Get the schema key\n const key = this.getSchemaKey(file.toString());\n\n // If the key matches, put it in foundFiles\n if (key.matches(desiredKey, matchType))\n foundFiles.push(new FileSchemaKey(key, fullPath, file.toString()));\n }\n\n /**\n * Adds SchemaKeys to the provided foundFiles collection that match the desired SchemaKey\n * @param foundFiles The collection of SchemaKeys found in the given directory\n * @param schemaPath The directory in which to search for the Schemas\n * @param fileFilter The file filter, potentially with wildcards, used to locate the Schema files.\n * @param desiredKey The schemaKey used to find matching Schema files\n * @param matchType The SchemaMatchType to use when comparing the desired Key and the keys found during the search.\n * @param format The type of file that the schema key refers to. json or xml\n */\n private addCandidateSchemaKeys(foundFiles: FileSchemaKey[], schemaPath: string, fileFilter: string, desiredKey: SchemaKey, matchType: SchemaMatchType, format: string) {\n const fullPath = path.join(schemaPath, fileFilter);\n\n const result = globSync(fullPath, { windowsPathsNoEscape: true });\n for (const match of result) {\n let fileName = path.basename(match, (`.ecschema.${format}`));\n // TODO: should this be moved or handled elsewhere?\n // Handles two version file names - SchemaKey.parseString supports only 3 version names.\n if (/[^\\d]\\.\\d?\\d\\.\\d?\\d$/.test(fileName)) {\n const parts = fileName.split(\".\");\n parts.splice(2, 0, \"00\");\n fileName = parts.join(\".\");\n }\n\n const file = fs.readFileSync(match);\n if (!file)\n continue;\n\n const schemaKey = SchemaKey.parseString(fileName);\n if (schemaKey.matches(desiredKey, matchType))\n foundFiles.push(new FileSchemaKey(schemaKey, match, file.toString()));\n }\n }\n\n /**\n * Attempts to find all Schema files in the configurable search paths that match\n * the desired SchemaKey.\n * @param desiredKey The SchemaKey to match.\n * @param matchType The SchemaMatchType.\n * @param format The type of file that the schema key refers to. json or xml\n * @internal\n */\n protected findEligibleSchemaKeys(desiredKey: SchemaKey, matchType: SchemaMatchType, format: string): FileSchemaKey[] {\n const foundFiles = new Array<FileSchemaKey>();\n\n let twoVersionSuffix: string;\n let threeVersionSuffix: string;\n const readVersion = desiredKey.readVersion.toString();\n const writeVersion = desiredKey.writeVersion.toString();\n const minorVersion = desiredKey.minorVersion.toString();\n\n if (matchType === SchemaMatchType.Latest) {\n twoVersionSuffix = (`.*.*.ecschema.${format}`);\n threeVersionSuffix = (`.*.*.*.ecschema.${format}`);\n } else if (matchType === SchemaMatchType.LatestWriteCompatible) {\n twoVersionSuffix = formatString(`.{0}.*.ecschema.${format}`, padStartEx(readVersion, 2, \"0\"));\n threeVersionSuffix = formatString(`.{0}.{1}.*.ecschema.${format}`, padStartEx(readVersion, 2, \"0\"), padStartEx(writeVersion, 2, \"0\"));\n } else if (matchType === SchemaMatchType.LatestReadCompatible) {\n twoVersionSuffix = formatString(`.{0}.*.ecschema.${format}`, padStartEx(readVersion, 2, \"0\"));\n threeVersionSuffix = formatString(`.{0}.*.*.ecschema.${format}`, padStartEx(readVersion, 2, \"0\"));\n } else {\n twoVersionSuffix = formatString(`.{0}.{1}.ecschema.${format}`, padStartEx(readVersion, 2, \"0\"), padStartEx(writeVersion, 2, \"0\"));\n threeVersionSuffix = formatString(`.{0}.{1}.{2}.ecschema.${format}`, padStartEx(readVersion, 2, \"0\"), padStartEx(writeVersion, 2, \"0\"), padStartEx(minorVersion, 2, \"0\"));\n }\n\n const twoVersionExpression = desiredKey.name + twoVersionSuffix;\n const threeVersionExpression = desiredKey.name + threeVersionSuffix;\n\n for (const searchPath of this.searchPaths) {\n this.addCandidateNoExtSchemaKey(foundFiles, searchPath, desiredKey.name, desiredKey, matchType, format);\n this.addCandidateSchemaKeys(foundFiles, searchPath, twoVersionExpression, desiredKey, matchType, format);\n this.addCandidateSchemaKeys(foundFiles, searchPath, threeVersionExpression, desiredKey, matchType, format);\n }\n\n return foundFiles;\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 abstract getSchema(key: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<Schema | undefined>;\n\n /**\n * Compares two Schema versions. If the left-hand version is greater, 1 is returned. If the\n * left-hand version is less, -1 us returned. If the versions are an exact match, 0 is returned.\n * @param lhs The 'left-hand' FileSchemaKey.\n * @param rhs The 'right-hand' FileSchemaKey.\n * @internal\n */\n public compareSchemaKeyByVersion = (lhs: FileSchemaKey, rhs: FileSchemaKey): number => {\n return lhs.compareByVersion(rhs);\n };\n}\n"]}
|
|
@@ -6,12 +6,13 @@ import { SchemaFileLocater } from "./SchemaFileLocater";
|
|
|
6
6
|
/**
|
|
7
7
|
* A SchemaLocator implementation for locating JSON Schema files
|
|
8
8
|
* from the file system using configurable search paths.
|
|
9
|
-
* @
|
|
9
|
+
* @public @preview
|
|
10
10
|
*/
|
|
11
11
|
export declare class SchemaJsonFileLocater extends SchemaFileLocater implements ISchemaLocater {
|
|
12
12
|
/**
|
|
13
13
|
* Constructs a SchemaKey based on the information in the Schema JSON
|
|
14
14
|
* @param data The Schema JSON as a string
|
|
15
|
+
* @internal
|
|
15
16
|
*/
|
|
16
17
|
protected getSchemaKey(data: string): SchemaKey;
|
|
17
18
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaJsonFileLocater.d.ts","sourceRoot":"","sources":["../../src/SchemaJsonFileLocater.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,
|
|
1
|
+
{"version":3,"file":"SchemaJsonFileLocater.d.ts","sourceRoot":"","sources":["../../src/SchemaJsonFileLocater.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,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;AAEvE;;;;GAIG;AACH,qBAAa,qBAAsB,SAAQ,iBAAkB,YAAW,cAAc;IAEpF;;;;OAIG;IACH,SAAS,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS;IAmB/C;;;;;;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;IAsBrI;;;;;;OAMG;IACI,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS;CAsBnH"}
|
|
@@ -15,21 +15,22 @@ const SchemaFileLocater_1 = require("./SchemaFileLocater");
|
|
|
15
15
|
/**
|
|
16
16
|
* A SchemaLocator implementation for locating JSON Schema files
|
|
17
17
|
* from the file system using configurable search paths.
|
|
18
|
-
* @
|
|
18
|
+
* @public @preview
|
|
19
19
|
*/
|
|
20
20
|
class SchemaJsonFileLocater extends SchemaFileLocater_1.SchemaFileLocater {
|
|
21
21
|
/**
|
|
22
22
|
* Constructs a SchemaKey based on the information in the Schema JSON
|
|
23
23
|
* @param data The Schema JSON as a string
|
|
24
|
+
* @internal
|
|
24
25
|
*/
|
|
25
26
|
getSchemaKey(data) {
|
|
26
27
|
const dataJson = JSON.parse(data);
|
|
27
28
|
// Check if the name is present
|
|
28
29
|
if (!(dataJson.name))
|
|
29
|
-
throw new ecschema_metadata_1.
|
|
30
|
+
throw new ecschema_metadata_1.ECSchemaError(ecschema_metadata_1.ECSchemaStatus.InvalidECJson, `Could not retrieve the ECSchema name in the given file.`);
|
|
30
31
|
// Check if versions is present
|
|
31
32
|
if (!(dataJson.version))
|
|
32
|
-
throw new ecschema_metadata_1.
|
|
33
|
+
throw new ecschema_metadata_1.ECSchemaError(ecschema_metadata_1.ECSchemaStatus.InvalidECJson, `Could not parse the ECSchema version in the given file.`);
|
|
33
34
|
// Get the name and version from the JSON
|
|
34
35
|
const schemaName = dataJson.name;
|
|
35
36
|
const schemaVersion = dataJson.version;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaJsonFileLocater.js","sourceRoot":"","sources":["../../src/SchemaJsonFileLocater.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,yBAAyB;AACzB,6BAA6B;AAC7B,gEAEkC;AAClC,2DAAuE;AAEvE;;;;GAIG;AACH,MAAa,qBAAsB,SAAQ,qCAAiB;IAE1D
|
|
1
|
+
{"version":3,"file":"SchemaJsonFileLocater.js","sourceRoot":"","sources":["../../src/SchemaJsonFileLocater.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,yBAAyB;AACzB,6BAA6B;AAC7B,gEAEkC;AAClC,2DAAuE;AAEvE;;;;GAIG;AACH,MAAa,qBAAsB,SAAQ,qCAAiB;IAE1D;;;;OAIG;IACO,YAAY,CAAC,IAAY;Q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,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAEtD,MAAM,MAAM,GAAG,0BAAM,CAAC,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QACxD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAlGD,sDAkGC","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 fs from \"fs\";\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\n/**\n * A SchemaLocator implementation for locating JSON Schema files\n * from the file system using configurable search paths.\n * @public @preview\n */\nexport class SchemaJsonFileLocater extends SchemaFileLocater implements ISchemaLocater {\n\n /**\n * Constructs a SchemaKey based on the information in the Schema JSON\n * @param data The Schema JSON as a string\n * @internal\n */\n protected getSchemaKey(data: string): SchemaKey {\n const dataJson = JSON.parse(data);\n\n // Check if the name is present\n if (!(dataJson.name))\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Could not retrieve the ECSchema name in the given file.`);\n\n // Check if versions is present\n if (!(dataJson.version))\n throw new ECSchemaError(ECSchemaStatus.InvalidECJson, `Could not parse the ECSchema version in the given file.`);\n\n // Get the name and version from the JSON\n const schemaName = dataJson.name;\n const schemaVersion = dataJson.version;\n\n const key = new SchemaKey(schemaName.toString(), ECVersion.fromString(schemaVersion.toString()));\n return key;\n }\n\n /**\n * Attempts to retrieve a Schema with the given SchemaKey by using the configured\n * search paths to locate the JSON 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 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;\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 files that match the schema key\n const candidates: FileSchemaKey[] = this.findEligibleSchemaKeys(schemaKey, matchType, \"json\");\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 (!await this.fileExists(schemaPath))\n return undefined;\n\n const schemaText = await this.readUtf8FileToString(schemaPath);\n if (!schemaText)\n return undefined;\n\n this.addSchemaSearchPaths([path.dirname(schemaPath)]);\n\n return Schema.startLoadingFromJson(schemaText, context);\n }\n\n /**\n * Attempts to retrieve a Schema with the given SchemaKey by using the configured\n * search paths to locate the JSON 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(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Schema | undefined {\n // Grab all schema files that match the schema key\n const candidates: FileSchemaKey[] = this.findEligibleSchemaKeys(schemaKey, matchType, \"json\");\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 (!fs.existsSync(schemaPath))\n return undefined;\n\n const schemaText = fs.readFileSync(schemaPath, \"utf-8\");\n if (!schemaText)\n return undefined;\n\n this.addSchemaSearchPaths([path.dirname(schemaPath)]);\n\n const schema = Schema.fromJsonSync(schemaText, context);\n return schema;\n }\n}\n"]}
|
package/lib/cjs/SchemaXml.d.ts
CHANGED
package/lib/cjs/SchemaXml.js
CHANGED
package/lib/cjs/SchemaXml.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaXml.js","sourceRoot":"","sources":["../../src/SchemaXml.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,+BAA+B;AAC/B,6BAA6B;AAC7B,2CAA0D;AAG1D;;;GAGG;AACH,IAAiB,SAAS,CAyCzB;AAzCD,WAAiB,SAAS;IAExB;;;;OAIG;IACI,KAAK,UAAU,SAAS,CAAC,MAAc,EAAE,UAAkB;QAChE,MAAM,GAAG,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC,CAAC;QAEtC,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QACnD,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QACpC,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,MAAM,GAAG,GAAG,sCAAsC,QAAQ,MAAM,GAAG,CAAC,OAAO,EAAE,CAAC;YAC9E,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAVqB,mBAAS,YAU9B,CAAA;IAED;;;OAGG;IACI,KAAK,UAAU,WAAW,CAAC,MAAc;QAC9C,IAAI,MAAM,GAAG,IAAI,kBAAS,EAAE,CAAC,eAAe,CAAC,wCAAwC,EAAE,iBAAiB,CAAC,CAAC;QAE1G,MAAM,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACpC,MAAM,UAAU,GAAG,IAAI,sBAAa,EAAE,CAAC;QACvC,OAAO,UAAU,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC;IANqB,qBAAW,cAMhC,CAAA;IAED,SAAS,aAAa,CAAC,MAAc,EAAE,UAAkB;QACvD,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QAC3C,MAAM,IAAI,GAAG,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,GAAG,GAAG,yBAAyB,OAAO,mBAAmB,CAAC;YAChE,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;QACvB,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,IAAI,eAAe,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC,EAzCgB,SAAS,yBAAT,SAAS,QAyCzB","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 Utils\n */\n\nimport * as fs from \"fs-extra\";\nimport * as path from \"path\";\nimport { DOMParser, XMLSerializer } from \"@xmldom/xmldom\";\nimport { Schema } from \"@itwin/ecschema-metadata\";\n\n/**\n * Utility class to assist in creating serialized EC Schemas on the file system.\n * @
|
|
1
|
+
{"version":3,"file":"SchemaXml.js","sourceRoot":"","sources":["../../src/SchemaXml.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,+BAA+B;AAC/B,6BAA6B;AAC7B,2CAA0D;AAG1D;;;GAGG;AACH,IAAiB,SAAS,CAyCzB;AAzCD,WAAiB,SAAS;IAExB;;;;OAIG;IACI,KAAK,UAAU,SAAS,CAAC,MAAc,EAAE,UAAkB;QAChE,MAAM,GAAG,GAA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,QAyCzB","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 Utils\n */\n\nimport * as fs from \"fs-extra\";\nimport * as path from \"path\";\nimport { DOMParser, XMLSerializer } from \"@xmldom/xmldom\";\nimport { Schema } from \"@itwin/ecschema-metadata\";\n\n/**\n * Utility class to assist in creating serialized EC Schemas on the file system.\n * @internal\n */\nexport namespace SchemaXml {\n\n /**\n * Writes a Schema to an xml file to the specified output path.\n * @param schema The Schema to serialize.\n * @param outputPath The directory in which to create the file.\n */\n export async function writeFile(schema: Schema, outputPath: string) {\n const xml = await writeString(schema);\n\n const baseFile = getSchemaPath(schema, outputPath);\n try {\n await fs.writeFile(baseFile, xml);\n } catch (err: any) {\n const msg = `An error occurred writing to file '${baseFile}': ${err.message}`;\n throw new Error(msg);\n }\n }\n\n /**\n * Writes a Schema to an xml string.\n * @param schema The Schema to serialize.\n */\n export async function writeString(schema: Schema): Promise<string> {\n let xmlDoc = new DOMParser().parseFromString(`<?xml version=\"1.0\" encoding=\"UTF-8\"?>`, \"application/xml\");\n\n xmlDoc = await schema.toXml(xmlDoc);\n const serializer = new XMLSerializer();\n return serializer.serializeToString(xmlDoc);\n }\n\n function getSchemaPath(schema: Schema, outputPath: string): string {\n const realDir = path.normalize(outputPath);\n const test = fs.pathExistsSync(realDir);\n if (!test) {\n const msg = `The output directory '${realDir}' does not exist.`;\n throw new Error(msg);\n }\n\n return path.resolve(realDir, `${schema.name}.ecschema.xml`);\n }\n}\n"]}
|
|
@@ -6,7 +6,7 @@ import { SchemaFileLocater } from "./SchemaFileLocater";
|
|
|
6
6
|
/**
|
|
7
7
|
* A SchemaLocater implementation for locating XML Schema files
|
|
8
8
|
* from the file system using configurable search paths.
|
|
9
|
-
* @
|
|
9
|
+
* @public @preview This is a workaround the current lack of a full xml parser.
|
|
10
10
|
*/
|
|
11
11
|
export declare class SchemaXmlFileLocater extends SchemaFileLocater implements ISchemaLocater {
|
|
12
12
|
/**
|
|
@@ -46,7 +46,7 @@ export declare class SchemaXmlFileLocater extends SchemaFileLocater implements I
|
|
|
46
46
|
*
|
|
47
47
|
* @note This locater is read-only and does not allow adding new schema search paths.
|
|
48
48
|
* @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.
|
|
49
|
-
* @
|
|
49
|
+
* @public @preview This is a workaround due to the current lack of a full xml parser.
|
|
50
50
|
*/
|
|
51
51
|
export declare class PublishedSchemaXmlFileLocater extends SchemaXmlFileLocater implements ISchemaLocater {
|
|
52
52
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaXmlFileLocater.d.ts","sourceRoot":"","sources":["../../src/SchemaXmlFileLocater.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,
|
|
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"}
|
|
@@ -17,7 +17,7 @@ const glob_1 = require("glob");
|
|
|
17
17
|
/**
|
|
18
18
|
* A SchemaLocater implementation for locating XML Schema files
|
|
19
19
|
* from the file system using configurable search paths.
|
|
20
|
-
* @
|
|
20
|
+
* @public @preview This is a workaround the current lack of a full xml parser.
|
|
21
21
|
*/
|
|
22
22
|
class SchemaXmlFileLocater extends SchemaFileLocater_1.SchemaFileLocater {
|
|
23
23
|
/**
|
|
@@ -92,11 +92,11 @@ class SchemaXmlFileLocater extends SchemaFileLocater_1.SchemaFileLocater {
|
|
|
92
92
|
getSchemaKey(data) {
|
|
93
93
|
const matches = data.match(/<ECSchema ([^]+?)>/g);
|
|
94
94
|
if (!matches || matches.length !== 1)
|
|
95
|
-
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`);
|
|
96
96
|
const name = matches[0].match(/schemaName="(.+?)"/);
|
|
97
97
|
const version = matches[0].match(/version="(.+?)"/);
|
|
98
98
|
if (!name || name.length !== 2 || !version || version.length !== 2)
|
|
99
|
-
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`);
|
|
100
100
|
const key = new ecschema_metadata_1.SchemaKey(name[1], ecschema_metadata_1.ECVersion.fromString(version[1]));
|
|
101
101
|
return key;
|
|
102
102
|
}
|
|
@@ -109,7 +109,7 @@ exports.SchemaXmlFileLocater = SchemaXmlFileLocater;
|
|
|
109
109
|
*
|
|
110
110
|
* @note This locater is read-only and does not allow adding new schema search paths.
|
|
111
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
|
-
* @
|
|
112
|
+
* @public @preview This is a workaround due to the current lack of a full xml parser.
|
|
113
113
|
*/
|
|
114
114
|
class PublishedSchemaXmlFileLocater extends SchemaXmlFileLocater {
|
|
115
115
|
/**
|
|
@@ -1 +1 @@
|
|
|
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,MAAa,oBAAqB,SAAQ,qCAAiB;IACzD;;;;;;OAMG;IACI,KAAK,CAAC,SAAS,CAAC,GAAc,EAAE,SAA0B,EAAE,OAAsB;QACvF,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,MAAM,CAAC;IAChB,CAAC;IAED;;;;;;QAMI;IACG,KAAK,CAAC,aAAa,CAAC,SAAoB,EAAE,SAA0B,EAAE,OAAsB;QACjG,MAAM,UAAU,GAAoB,IAAI,CAAC,sBAAsB,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;Q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AAM,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;AAED;;;;;;;;GAQG;AACH,MAAa,6BAA8B,SAAQ,oBAAoB;IACrE;;;OAGG;IACH,YAAmB,qBAA6B;QAC9C,KAAK,EAAE,CAAC;QAER,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC;QAClE,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,iBAAiB,WAAW,8CAA8C,CAAC,CAAC;QAE9F,kDAAkD;QAClD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,IAAA,eAAQ,EAAC,IAAI,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 ECObjectsError, ECObjectsStatus, 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 * @beta 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 ECObjectsError(ECObjectsStatus.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 ECObjectsError(ECObjectsStatus.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 * @beta 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"]}
|
|
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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C,IAAI,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"]}
|
|
@@ -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;YAClC,MAAM,IAAI,
|
|
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;YAClC,MAAM,IAAI,iCAAa,CAAC,kCAAc,CAAC,gBAAgB,EAAE,qDAAqD,CAAC,CAAC;QAElH,MAAM,IAAI,GAAG,OAAO,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;Y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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"]}
|
|
@@ -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"}
|