@itwin/ecschema-locaters 3.4.0-dev.9 → 3.5.0-dev.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGELOG.md +24 -1
  2. package/lib/cjs/SchemaFileLocater.d.ts +82 -82
  3. package/lib/cjs/SchemaFileLocater.d.ts.map +1 -1
  4. package/lib/cjs/SchemaFileLocater.js +212 -209
  5. package/lib/cjs/SchemaFileLocater.js.map +1 -1
  6. package/lib/cjs/SchemaFileUtility.d.ts +17 -14
  7. package/lib/cjs/SchemaFileUtility.d.ts.map +1 -1
  8. package/lib/cjs/SchemaFileUtility.js +48 -45
  9. package/lib/cjs/SchemaFileUtility.js.map +1 -1
  10. package/lib/cjs/SchemaJsonFileLocater.d.ts +33 -30
  11. package/lib/cjs/SchemaJsonFileLocater.d.ts.map +1 -1
  12. package/lib/cjs/SchemaJsonFileLocater.js +90 -87
  13. package/lib/cjs/SchemaJsonFileLocater.js.map +1 -1
  14. package/lib/cjs/SchemaXmlFileLocater.d.ts +33 -30
  15. package/lib/cjs/SchemaXmlFileLocater.d.ts.map +1 -1
  16. package/lib/cjs/SchemaXmlFileLocater.js +93 -90
  17. package/lib/cjs/SchemaXmlFileLocater.js.map +1 -1
  18. package/lib/cjs/StubSchemaXmlFileLocater.d.ts +69 -69
  19. package/lib/cjs/StubSchemaXmlFileLocater.d.ts.map +1 -1
  20. package/lib/cjs/StubSchemaXmlFileLocater.js +177 -174
  21. package/lib/cjs/StubSchemaXmlFileLocater.js.map +1 -1
  22. package/lib/cjs/ecschema-locaters.d.ts +17 -4
  23. package/lib/cjs/ecschema-locaters.d.ts.map +1 -1
  24. package/lib/cjs/ecschema-locaters.js +33 -20
  25. package/lib/cjs/ecschema-locaters.js.map +1 -1
  26. package/lib/cjs/test/SchemaFileUtility.test.d.ts +1 -1
  27. package/lib/cjs/test/SchemaFileUtility.test.js +56 -56
  28. package/lib/cjs/test/SchemaFileUtility.test.js.map +1 -1
  29. package/lib/cjs/test/SchemaJsonFileLocator.test.d.ts +1 -1
  30. package/lib/cjs/test/SchemaJsonFileLocator.test.js +119 -119
  31. package/lib/cjs/test/SchemaJsonFileLocator.test.js.map +1 -1
  32. package/lib/cjs/test/SchemaXmlFileLocator.test.d.ts +1 -1
  33. package/lib/cjs/test/SchemaXmlFileLocator.test.js +180 -180
  34. package/lib/cjs/test/SchemaXmlFileLocator.test.js.map +1 -1
  35. package/lib/cjs/test/StubSchemaXmlFileLocater.test.d.ts +1 -1
  36. package/lib/cjs/test/StubSchemaXmlFileLocater.test.js +170 -170
  37. package/lib/cjs/test/StubSchemaXmlFileLocater.test.js.map +1 -1
  38. package/package.json +6 -6
@@ -1,210 +1,213 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.SchemaFileLocater = exports.FileSchemaKey = void 0;
8
- const fs = require("fs");
9
- const glob = require("glob");
10
- const path = require("path");
11
- const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
12
- const formatString = (format, ...args) => {
13
- return format.replace(/{(\d+)}/g, (match, theNumber) => {
14
- return typeof args[theNumber] !== "undefined"
15
- ? args[theNumber]
16
- : match;
17
- });
18
- };
19
- const padStartEx = (str, targetLength, padString) => {
20
- targetLength = targetLength >> 0; // truncate if number or convert non-number to 0;
21
- padString = String((typeof padString !== "undefined" ? padString : " "));
22
- if (str.length > targetLength) {
23
- return String(str);
24
- }
25
- else {
26
- targetLength = targetLength - str.length;
27
- if (targetLength > padString.length) {
28
- padString += padString.repeat(targetLength / padString.length); // append to original to ensure we are longer than needed
29
- }
30
- return padString.slice(0, targetLength) + str;
31
- }
32
- };
33
- /**
34
- * A SchemaKey implementation that aids in identifying Schema files via the
35
- * addition of two properties: fileName and schemaText. The fileName contains the
36
- * full path to the file on disk and schemaText is the full string representation
37
- * of the Schema.
38
- * @beta
39
- */
40
- class FileSchemaKey extends ecschema_metadata_1.SchemaKey {
41
- /**
42
- * Initializes a new FileSchemaKey object.
43
- * @param key The EC SchemaKey identifying the Schema.
44
- * @param fileName The full path to the Schema file.
45
- * @param schemaText The string representation of the Schema
46
- * loaded from disk. Optional.
47
- */
48
- constructor(key, fileName, schemaJson) {
49
- super(key.name, key.version);
50
- this.fileName = fileName;
51
- this.schemaText = schemaJson;
52
- }
53
- }
54
- exports.FileSchemaKey = FileSchemaKey;
55
- /**
56
- * Abstract class to hold common/overlapping functionality between SchemaJsonFileLocater and SchemaXmlFileLocater
57
- * @beta - Needs further testing and possibly moved to a separate package.
58
- */
59
- class SchemaFileLocater {
60
- constructor() {
61
- /**
62
- * Compares two Schema versions. If the left-hand version is greater, 1 is returned. If the
63
- * left-hand version is less, -1 us returned. If the versions are an exact match, 0 is returned.
64
- * @param lhs The 'left-hand' FileSchemaKey.
65
- * @param rhs The 'right-hand' FileSchemaKey.
66
- */
67
- this.compareSchemaKeyByVersion = (lhs, rhs) => {
68
- return lhs.compareByVersion(rhs);
69
- };
70
- this.searchPaths = [];
71
- }
72
- async readUtf8FileToString(filePath) {
73
- return new Promise((resolve, reject) => {
74
- fs.readFile(filePath, "utf-8", (err, data) => {
75
- if (err)
76
- reject(err);
77
- else
78
- resolve(data);
79
- });
80
- });
81
- }
82
- readUtf8FileToStringSync(filePath) {
83
- return fs.readFileSync(filePath, "utf-8");
84
- }
85
- async fileExists(filePath) {
86
- return new Promise((resolve) => {
87
- fs.access(filePath, fs.constants.F_OK, (err) => {
88
- resolve(err ? false : true);
89
- });
90
- });
91
- }
92
- fileExistsSync(filePath) {
93
- return fs.existsSync(filePath);
94
- }
95
- /**
96
- * Adds more search paths used by this locator to find the
97
- * Schema files.
98
- * @param schemaPaths An array of search paths to add
99
- */
100
- addSchemaSearchPaths(schemaPaths) {
101
- // If the path is not in the schemaPaths array, add it
102
- for (const schemaPath of schemaPaths)
103
- this.addSchemaSearchPath(schemaPath);
104
- }
105
- /**
106
- * Add one search path used by this locator to find the
107
- * Schema files.
108
- * @param schemaPath A search path to add
109
- */
110
- addSchemaSearchPath(schemaPath) {
111
- // If the path is not in the schemaPaths array, add it
112
- if (!this.searchPaths.find((entry) => entry === schemaPath))
113
- this.searchPaths.push(schemaPath);
114
- }
115
- /**
116
- * Adds SchemaKeys to the provided foundFiles collection that match the desired SchemaKey. This method
117
- * only attempts to find schema files that have no version in the file name.
118
- * @param foundFiles The collection of SchemaKeys found in the given directory.
119
- * @param schemaPath The directory in which to search for the Schemas.
120
- * @param schemaName The short name of the Schema (without version).
121
- * @param desiredKey The SchemaKey used to find matching Schema files.
122
- * @param matchType The SchemaMatchType to use when comparing the desiredKey and the keys found during the search.
123
- * @param format The type of file that the schema key refers to. json or xml
124
- */
125
- addCandidateNoExtSchemaKey(foundFiles, schemaPath, schemaName, desiredKey, matchType, format) {
126
- const fullPath = path.join(schemaPath, `${schemaName}.ecschema.${format}`);
127
- // If the file does not exist, end
128
- if (!fs.existsSync(fullPath))
129
- return;
130
- // Read the file
131
- const file = fs.readFileSync(fullPath);
132
- if (!file)
133
- return;
134
- // Get the schema key
135
- const key = this.getSchemaKey(file.toString());
136
- // If the key matches, put it in foundFiles
137
- if (key.matches(desiredKey, matchType))
138
- foundFiles.push(new FileSchemaKey(key, fullPath, file.toString()));
139
- }
140
- /**
141
- * Adds SchemaKeys to the provided foundFiles collection that match the desired SchemaKey
142
- * @param foundFiles The collection of SchemaKeys found in the given directory
143
- * @param schemaPath The directory in which to search for the Schemas
144
- * @param fileFilter The file filter, potentially with wildcards, used to locate the Schema files.
145
- * @param desiredKey The schemaKey used to find matching Schema files
146
- * @param matchType The SchemaMatchType to use when comparing the desired Key and the keys found during the search.
147
- * @param format The type of file that the schema key refers to. json or xml
148
- */
149
- addCandidateSchemaKeys(foundFiles, schemaPath, fileFilter, desiredKey, matchType, format) {
150
- const fullPath = path.join(schemaPath, fileFilter);
151
- const result = new glob.GlobSync(fullPath, { sync: true });
152
- for (const match of result.found) {
153
- let fileName = path.basename(match, (`.ecschema.${format}`));
154
- // TODO: should this be moved or handled elsewhere?
155
- // Handles two version file names - SchemaKey.parseString supports only 3 version names.
156
- if (/[^\d]\.\d?\d\.\d?\d$/.test(fileName)) {
157
- const parts = fileName.split(".");
158
- parts.splice(2, 0, "00");
159
- fileName = parts.join(".");
160
- }
161
- const file = fs.readFileSync(match);
162
- if (!file)
163
- continue;
164
- const schemaKey = ecschema_metadata_1.SchemaKey.parseString(fileName);
165
- if (schemaKey.matches(desiredKey, matchType))
166
- foundFiles.push(new FileSchemaKey(schemaKey, match, file.toString()));
167
- }
168
- }
169
- /**
170
- * Attempts to find all Schema files in the configurable search paths that match
171
- * the desired SchemaKey.
172
- * @param desiredKey The SchemaKey to match.
173
- * @param matchType The SchemaMatchType.
174
- * @param format The type of file that the schema key refers to. json or xml
175
- */
176
- findEligibleSchemaKeys(desiredKey, matchType, format) {
177
- const foundFiles = new Array();
178
- let twoVersionSuffix;
179
- let threeVersionSuffix;
180
- const readVersion = desiredKey.readVersion.toString();
181
- const writeVersion = desiredKey.writeVersion.toString();
182
- const minorVersion = desiredKey.minorVersion.toString();
183
- if (matchType === ecschema_metadata_1.SchemaMatchType.Latest) {
184
- twoVersionSuffix = (`.*.*.ecschema.${format}`);
185
- threeVersionSuffix = (`.*.*.*.ecschema.${format}`);
186
- }
187
- else if (matchType === ecschema_metadata_1.SchemaMatchType.LatestWriteCompatible) {
188
- twoVersionSuffix = formatString(`.{0}.*.ecschema.${format}`, padStartEx(readVersion, 2, "0"));
189
- threeVersionSuffix = formatString(`.{0}.{1}.*.ecschema.${format}`, padStartEx(readVersion, 2, "0"), padStartEx(writeVersion, 2, "0"));
190
- }
191
- else if (matchType === ecschema_metadata_1.SchemaMatchType.LatestReadCompatible) {
192
- twoVersionSuffix = formatString(`.{0}.*.ecschema.${format}`, padStartEx(readVersion, 2, "0"));
193
- threeVersionSuffix = formatString(`.{0}.*.*.ecschema.${format}`, padStartEx(readVersion, 2, "0"));
194
- }
195
- else {
196
- twoVersionSuffix = formatString(`.{0}.{1}.ecschema.${format}`, padStartEx(readVersion, 2, "0"), padStartEx(writeVersion, 2, "0"));
197
- threeVersionSuffix = formatString(`.{0}.{1}.{2}.ecschema.${format}`, padStartEx(readVersion, 2, "0"), padStartEx(writeVersion, 2, "0"), padStartEx(minorVersion, 2, "0"));
198
- }
199
- const twoVersionExpression = desiredKey.name + twoVersionSuffix;
200
- const threeVersionExpression = desiredKey.name + threeVersionSuffix;
201
- for (const searchPath of this.searchPaths) {
202
- this.addCandidateNoExtSchemaKey(foundFiles, searchPath, desiredKey.name, desiredKey, matchType, format);
203
- this.addCandidateSchemaKeys(foundFiles, searchPath, twoVersionExpression, desiredKey, matchType, format);
204
- this.addCandidateSchemaKeys(foundFiles, searchPath, threeVersionExpression, desiredKey, matchType, format);
205
- }
206
- return foundFiles;
207
- }
208
- }
209
- exports.SchemaFileLocater = SchemaFileLocater;
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.SchemaFileLocater = exports.FileSchemaKey = void 0;
8
+ const fs = require("fs");
9
+ const glob = require("glob");
10
+ const path = require("path");
11
+ const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
12
+ /** @packageDocumentation
13
+ * @module Locaters
14
+ */
15
+ const formatString = (format, ...args) => {
16
+ return format.replace(/{(\d+)}/g, (match, theNumber) => {
17
+ return typeof args[theNumber] !== "undefined"
18
+ ? args[theNumber]
19
+ : match;
20
+ });
21
+ };
22
+ const padStartEx = (str, targetLength, padString) => {
23
+ targetLength = targetLength >> 0; // truncate if number or convert non-number to 0;
24
+ padString = String((typeof padString !== "undefined" ? padString : " "));
25
+ if (str.length > targetLength) {
26
+ return String(str);
27
+ }
28
+ else {
29
+ targetLength = targetLength - str.length;
30
+ if (targetLength > padString.length) {
31
+ padString += padString.repeat(targetLength / padString.length); // append to original to ensure we are longer than needed
32
+ }
33
+ return padString.slice(0, targetLength) + str;
34
+ }
35
+ };
36
+ /**
37
+ * A SchemaKey implementation that aids in identifying Schema files via the
38
+ * addition of two properties: fileName and schemaText. The fileName contains the
39
+ * full path to the file on disk and schemaText is the full string representation
40
+ * of the Schema.
41
+ * @beta
42
+ */
43
+ class FileSchemaKey extends ecschema_metadata_1.SchemaKey {
44
+ /**
45
+ * Initializes a new FileSchemaKey object.
46
+ * @param key The EC SchemaKey identifying the Schema.
47
+ * @param fileName The full path to the Schema file.
48
+ * @param schemaText The string representation of the Schema
49
+ * loaded from disk. Optional.
50
+ */
51
+ constructor(key, fileName, schemaJson) {
52
+ super(key.name, key.version);
53
+ this.fileName = fileName;
54
+ this.schemaText = schemaJson;
55
+ }
56
+ }
57
+ exports.FileSchemaKey = FileSchemaKey;
58
+ /**
59
+ * Abstract class to hold common/overlapping functionality between SchemaJsonFileLocater and SchemaXmlFileLocater
60
+ * @beta - Needs further testing and possibly moved to a separate package.
61
+ */
62
+ class SchemaFileLocater {
63
+ constructor() {
64
+ /**
65
+ * Compares two Schema versions. If the left-hand version is greater, 1 is returned. If the
66
+ * left-hand version is less, -1 us returned. If the versions are an exact match, 0 is returned.
67
+ * @param lhs The 'left-hand' FileSchemaKey.
68
+ * @param rhs The 'right-hand' FileSchemaKey.
69
+ */
70
+ this.compareSchemaKeyByVersion = (lhs, rhs) => {
71
+ return lhs.compareByVersion(rhs);
72
+ };
73
+ this.searchPaths = [];
74
+ }
75
+ async readUtf8FileToString(filePath) {
76
+ return new Promise((resolve, reject) => {
77
+ fs.readFile(filePath, "utf-8", (err, data) => {
78
+ if (err)
79
+ reject(err);
80
+ else
81
+ resolve(data);
82
+ });
83
+ });
84
+ }
85
+ readUtf8FileToStringSync(filePath) {
86
+ return fs.readFileSync(filePath, "utf-8");
87
+ }
88
+ async fileExists(filePath) {
89
+ return new Promise((resolve) => {
90
+ fs.access(filePath, fs.constants.F_OK, (err) => {
91
+ resolve(err ? false : true);
92
+ });
93
+ });
94
+ }
95
+ fileExistsSync(filePath) {
96
+ return fs.existsSync(filePath);
97
+ }
98
+ /**
99
+ * Adds more search paths used by this locator to find the
100
+ * Schema files.
101
+ * @param schemaPaths An array of search paths to add
102
+ */
103
+ addSchemaSearchPaths(schemaPaths) {
104
+ // If the path is not in the schemaPaths array, add it
105
+ for (const schemaPath of schemaPaths)
106
+ this.addSchemaSearchPath(schemaPath);
107
+ }
108
+ /**
109
+ * Add one search path used by this locator to find the
110
+ * Schema files.
111
+ * @param schemaPath A search path to add
112
+ */
113
+ addSchemaSearchPath(schemaPath) {
114
+ // If the path is not in the schemaPaths array, add it
115
+ if (!this.searchPaths.find((entry) => entry === schemaPath))
116
+ this.searchPaths.push(schemaPath);
117
+ }
118
+ /**
119
+ * Adds SchemaKeys to the provided foundFiles collection that match the desired SchemaKey. This method
120
+ * only attempts to find schema files that have no version in the file name.
121
+ * @param foundFiles The collection of SchemaKeys found in the given directory.
122
+ * @param schemaPath The directory in which to search for the Schemas.
123
+ * @param schemaName The short name of the Schema (without version).
124
+ * @param desiredKey The SchemaKey used to find matching Schema files.
125
+ * @param matchType The SchemaMatchType to use when comparing the desiredKey and the keys found during the search.
126
+ * @param format The type of file that the schema key refers to. json or xml
127
+ */
128
+ addCandidateNoExtSchemaKey(foundFiles, schemaPath, schemaName, desiredKey, matchType, format) {
129
+ const fullPath = path.join(schemaPath, `${schemaName}.ecschema.${format}`);
130
+ // If the file does not exist, end
131
+ if (!fs.existsSync(fullPath))
132
+ return;
133
+ // Read the file
134
+ const file = fs.readFileSync(fullPath);
135
+ if (!file)
136
+ return;
137
+ // Get the schema key
138
+ const key = this.getSchemaKey(file.toString());
139
+ // If the key matches, put it in foundFiles
140
+ if (key.matches(desiredKey, matchType))
141
+ foundFiles.push(new FileSchemaKey(key, fullPath, file.toString()));
142
+ }
143
+ /**
144
+ * Adds SchemaKeys to the provided foundFiles collection that match the desired SchemaKey
145
+ * @param foundFiles The collection of SchemaKeys found in the given directory
146
+ * @param schemaPath The directory in which to search for the Schemas
147
+ * @param fileFilter The file filter, potentially with wildcards, used to locate the Schema files.
148
+ * @param desiredKey The schemaKey used to find matching Schema files
149
+ * @param matchType The SchemaMatchType to use when comparing the desired Key and the keys found during the search.
150
+ * @param format The type of file that the schema key refers to. json or xml
151
+ */
152
+ addCandidateSchemaKeys(foundFiles, schemaPath, fileFilter, desiredKey, matchType, format) {
153
+ const fullPath = path.join(schemaPath, fileFilter);
154
+ const result = new glob.GlobSync(fullPath, { sync: true });
155
+ for (const match of result.found) {
156
+ let fileName = path.basename(match, (`.ecschema.${format}`));
157
+ // TODO: should this be moved or handled elsewhere?
158
+ // Handles two version file names - SchemaKey.parseString supports only 3 version names.
159
+ if (/[^\d]\.\d?\d\.\d?\d$/.test(fileName)) {
160
+ const parts = fileName.split(".");
161
+ parts.splice(2, 0, "00");
162
+ fileName = parts.join(".");
163
+ }
164
+ const file = fs.readFileSync(match);
165
+ if (!file)
166
+ continue;
167
+ const schemaKey = ecschema_metadata_1.SchemaKey.parseString(fileName);
168
+ if (schemaKey.matches(desiredKey, matchType))
169
+ foundFiles.push(new FileSchemaKey(schemaKey, match, file.toString()));
170
+ }
171
+ }
172
+ /**
173
+ * Attempts to find all Schema files in the configurable search paths that match
174
+ * the desired SchemaKey.
175
+ * @param desiredKey The SchemaKey to match.
176
+ * @param matchType The SchemaMatchType.
177
+ * @param format The type of file that the schema key refers to. json or xml
178
+ */
179
+ findEligibleSchemaKeys(desiredKey, matchType, format) {
180
+ const foundFiles = new Array();
181
+ let twoVersionSuffix;
182
+ let threeVersionSuffix;
183
+ const readVersion = desiredKey.readVersion.toString();
184
+ const writeVersion = desiredKey.writeVersion.toString();
185
+ const minorVersion = desiredKey.minorVersion.toString();
186
+ if (matchType === ecschema_metadata_1.SchemaMatchType.Latest) {
187
+ twoVersionSuffix = (`.*.*.ecschema.${format}`);
188
+ threeVersionSuffix = (`.*.*.*.ecschema.${format}`);
189
+ }
190
+ else if (matchType === ecschema_metadata_1.SchemaMatchType.LatestWriteCompatible) {
191
+ twoVersionSuffix = formatString(`.{0}.*.ecschema.${format}`, padStartEx(readVersion, 2, "0"));
192
+ threeVersionSuffix = formatString(`.{0}.{1}.*.ecschema.${format}`, padStartEx(readVersion, 2, "0"), padStartEx(writeVersion, 2, "0"));
193
+ }
194
+ else if (matchType === ecschema_metadata_1.SchemaMatchType.LatestReadCompatible) {
195
+ twoVersionSuffix = formatString(`.{0}.*.ecschema.${format}`, padStartEx(readVersion, 2, "0"));
196
+ threeVersionSuffix = formatString(`.{0}.*.*.ecschema.${format}`, padStartEx(readVersion, 2, "0"));
197
+ }
198
+ else {
199
+ twoVersionSuffix = formatString(`.{0}.{1}.ecschema.${format}`, padStartEx(readVersion, 2, "0"), padStartEx(writeVersion, 2, "0"));
200
+ threeVersionSuffix = formatString(`.{0}.{1}.{2}.ecschema.${format}`, padStartEx(readVersion, 2, "0"), padStartEx(writeVersion, 2, "0"), padStartEx(minorVersion, 2, "0"));
201
+ }
202
+ const twoVersionExpression = desiredKey.name + twoVersionSuffix;
203
+ const threeVersionExpression = desiredKey.name + threeVersionSuffix;
204
+ for (const searchPath of this.searchPaths) {
205
+ this.addCandidateNoExtSchemaKey(foundFiles, searchPath, desiredKey.name, desiredKey, matchType, format);
206
+ this.addCandidateSchemaKeys(foundFiles, searchPath, twoVersionExpression, desiredKey, matchType, format);
207
+ this.addCandidateSchemaKeys(foundFiles, searchPath, threeVersionExpression, desiredKey, matchType, format);
208
+ }
209
+ return foundFiles;
210
+ }
211
+ }
212
+ exports.SchemaFileLocater = SchemaFileLocater;
210
213
  //# sourceMappingURL=SchemaFileLocater.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaFileLocater.js","sourceRoot":"","sources":["../../src/SchemaFileLocater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YAClI,kBAAkB,GAAG,YAAY,CAAC,yBAAyB,MAAM,EAAE,EAAE,UAAU,CAAC,WAAW,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,UAAU,CAAC,YAAY,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,UAAU,CAAC,YAAY,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;SAC3K;QAED,MAAM,oBAAoB,GAAG,UAAU,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAChE,MAAM,sBAAsB,GAAG,UAAU,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAEpE,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,WAAW,EAAE;YACzC,IAAI,CAAC,0BAA0B,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,IAAI,EAAE,UAAU,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;SAC5G;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;CAaF;AA5KD,8CA4KC","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 * as fs from \"fs\";\r\nimport * as glob from \"glob\";\r\nimport * as path from \"path\";\r\nimport { Schema, SchemaContext, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\r\n\r\nconst formatString = (format: string, ...args: string[]) => {\r\n return format.replace(/{(\\d+)}/g, (match, theNumber) => {\r\n return typeof args[theNumber] !== \"undefined\"\r\n ? args[theNumber]\r\n : match;\r\n });\r\n};\r\n\r\nconst padStartEx = (str: string, targetLength: number, padString: string) => {\r\n targetLength = targetLength >> 0; // truncate if number or convert non-number to 0;\r\n padString = String((typeof padString !== \"undefined\" ? padString : \" \"));\r\n if (str.length > targetLength) {\r\n return String(str);\r\n } else {\r\n targetLength = targetLength - str.length;\r\n if (targetLength > padString.length) {\r\n padString += padString.repeat(targetLength / padString.length); // append to original to ensure we are longer than needed\r\n }\r\n return padString.slice(0, targetLength) + str;\r\n }\r\n};\r\n\r\n/**\r\n * A SchemaKey implementation that aids in identifying Schema files via the\r\n * addition of two properties: fileName and schemaText. The fileName contains the\r\n * full path to the file on disk and schemaText is the full string representation\r\n * of the Schema.\r\n * @beta\r\n */\r\nexport class FileSchemaKey extends SchemaKey {\r\n // The schema file associated with the SchemaKey\r\n public fileName: string;\r\n // The JSON text for the schema loaded\r\n public schemaText?: string;\r\n\r\n /**\r\n * Initializes a new FileSchemaKey object.\r\n * @param key The EC SchemaKey identifying the Schema.\r\n * @param fileName The full path to the Schema file.\r\n * @param schemaText The string representation of the Schema\r\n * loaded from disk. Optional.\r\n */\r\n constructor(key: SchemaKey, fileName: string, schemaJson?: string) {\r\n super(key.name, key.version);\r\n this.fileName = fileName;\r\n this.schemaText = schemaJson;\r\n }\r\n}\r\n\r\n/**\r\n * Abstract class to hold common/overlapping functionality between SchemaJsonFileLocater and SchemaXmlFileLocater\r\n * @beta - Needs further testing and possibly moved to a separate package.\r\n */\r\nexport abstract class SchemaFileLocater {\r\n public searchPaths: string[];\r\n\r\n constructor() {\r\n this.searchPaths = [];\r\n }\r\n\r\n public async readUtf8FileToString(filePath: string): Promise<string | undefined> {\r\n return new Promise<string | undefined>((resolve, reject) => {\r\n fs.readFile(filePath, \"utf-8\", (err, data) => {\r\n if (err)\r\n reject(err);\r\n else\r\n resolve(data);\r\n });\r\n });\r\n }\r\n\r\n public readUtf8FileToStringSync(filePath: string): string | undefined {\r\n return fs.readFileSync(filePath, \"utf-8\");\r\n }\r\n\r\n public async fileExists(filePath: string): Promise<boolean | undefined> {\r\n return new Promise<boolean | undefined>((resolve) => {\r\n fs.access(filePath, fs.constants.F_OK, (err) => {\r\n resolve(err ? false : true);\r\n });\r\n });\r\n }\r\n\r\n public fileExistsSync(filePath: string): boolean | undefined {\r\n return fs.existsSync(filePath);\r\n }\r\n\r\n /**\r\n * Adds more search paths used by this locator to find the\r\n * Schema files.\r\n * @param schemaPaths An array of search paths to add\r\n */\r\n public addSchemaSearchPaths(schemaPaths: string[]) {\r\n // If the path is not in the schemaPaths array, add it\r\n for (const schemaPath of schemaPaths)\r\n this.addSchemaSearchPath(schemaPath);\r\n }\r\n\r\n /**\r\n * Add one search path used by this locator to find the\r\n * Schema files.\r\n * @param schemaPath A search path to add\r\n */\r\n public addSchemaSearchPath(schemaPath: string) {\r\n // If the path is not in the schemaPaths array, add it\r\n if (!this.searchPaths.find((entry) => entry === schemaPath))\r\n this.searchPaths.push(schemaPath);\r\n }\r\n\r\n protected abstract getSchemaKey(data: string): SchemaKey;\r\n\r\n /**\r\n * Adds SchemaKeys to the provided foundFiles collection that match the desired SchemaKey. This method\r\n * only attempts to find schema files that have no version in the file name.\r\n * @param foundFiles The collection of SchemaKeys found in the given directory.\r\n * @param schemaPath The directory in which to search for the Schemas.\r\n * @param schemaName The short name of the Schema (without version).\r\n * @param desiredKey The SchemaKey used to find matching Schema files.\r\n * @param matchType The SchemaMatchType to use when comparing the desiredKey and the keys found during the search.\r\n * @param format The type of file that the schema key refers to. json or xml\r\n */\r\n private addCandidateNoExtSchemaKey(foundFiles: FileSchemaKey[], schemaPath: string, schemaName: string, desiredKey: SchemaKey, matchType: SchemaMatchType, format: string) {\r\n const fullPath = path.join(schemaPath, `${schemaName}.ecschema.${format}`);\r\n\r\n // If the file does not exist, end\r\n if (!fs.existsSync(fullPath)) return;\r\n\r\n // Read the file\r\n const file = fs.readFileSync(fullPath);\r\n if (!file) return;\r\n\r\n // Get the schema key\r\n const key = this.getSchemaKey(file.toString());\r\n\r\n // If the key matches, put it in foundFiles\r\n if (key.matches(desiredKey, matchType))\r\n foundFiles.push(new FileSchemaKey(key, fullPath, file.toString()));\r\n }\r\n\r\n /**\r\n * Adds SchemaKeys to the provided foundFiles collection that match the desired SchemaKey\r\n * @param foundFiles The collection of SchemaKeys found in the given directory\r\n * @param schemaPath The directory in which to search for the Schemas\r\n * @param fileFilter The file filter, potentially with wildcards, used to locate the Schema files.\r\n * @param desiredKey The schemaKey used to find matching Schema files\r\n * @param matchType The SchemaMatchType to use when comparing the desired Key and the keys found during the search.\r\n * @param format The type of file that the schema key refers to. json or xml\r\n */\r\n private addCandidateSchemaKeys(foundFiles: FileSchemaKey[], schemaPath: string, fileFilter: string, desiredKey: SchemaKey, matchType: SchemaMatchType, format: string) {\r\n const fullPath = path.join(schemaPath, fileFilter);\r\n\r\n const result = new glob.GlobSync(fullPath, { sync: true });\r\n for (const match of result.found) {\r\n let fileName = path.basename(match, (`.ecschema.${format}`));\r\n // TODO: should this be moved or handled elsewhere?\r\n // Handles two version file names - SchemaKey.parseString supports only 3 version names.\r\n if (/[^\\d]\\.\\d?\\d\\.\\d?\\d$/.test(fileName)) {\r\n const parts = fileName.split(\".\");\r\n parts.splice(2, 0, \"00\");\r\n fileName = parts.join(\".\");\r\n }\r\n\r\n const file = fs.readFileSync(match);\r\n if (!file)\r\n continue;\r\n\r\n const schemaKey = SchemaKey.parseString(fileName);\r\n if (schemaKey.matches(desiredKey, matchType))\r\n foundFiles.push(new FileSchemaKey(schemaKey, match, file.toString()));\r\n }\r\n }\r\n\r\n /**\r\n * Attempts to find all Schema files in the configurable search paths that match\r\n * the desired SchemaKey.\r\n * @param desiredKey The SchemaKey to match.\r\n * @param matchType The SchemaMatchType.\r\n * @param format The type of file that the schema key refers to. json or xml\r\n */\r\n protected findEligibleSchemaKeys(desiredKey: SchemaKey, matchType: SchemaMatchType, format: string): FileSchemaKey[] {\r\n const foundFiles = new Array<FileSchemaKey>();\r\n\r\n let twoVersionSuffix: string;\r\n let threeVersionSuffix: string;\r\n const readVersion = desiredKey.readVersion.toString();\r\n const writeVersion = desiredKey.writeVersion.toString();\r\n const minorVersion = desiredKey.minorVersion.toString();\r\n\r\n if (matchType === SchemaMatchType.Latest) {\r\n twoVersionSuffix = (`.*.*.ecschema.${format}`);\r\n threeVersionSuffix = (`.*.*.*.ecschema.${format}`);\r\n } else if (matchType === SchemaMatchType.LatestWriteCompatible) {\r\n twoVersionSuffix = formatString(`.{0}.*.ecschema.${format}`, padStartEx(readVersion, 2, \"0\"));\r\n threeVersionSuffix = formatString(`.{0}.{1}.*.ecschema.${format}`, padStartEx(readVersion, 2, \"0\"), padStartEx(writeVersion, 2, \"0\"));\r\n } else if (matchType === SchemaMatchType.LatestReadCompatible) {\r\n twoVersionSuffix = formatString(`.{0}.*.ecschema.${format}`, padStartEx(readVersion, 2, \"0\"));\r\n threeVersionSuffix = formatString(`.{0}.*.*.ecschema.${format}`, padStartEx(readVersion, 2, \"0\"));\r\n } else {\r\n twoVersionSuffix = formatString(`.{0}.{1}.ecschema.${format}`, padStartEx(readVersion, 2, \"0\"), padStartEx(writeVersion, 2, \"0\"));\r\n threeVersionSuffix = formatString(`.{0}.{1}.{2}.ecschema.${format}`, padStartEx(readVersion, 2, \"0\"), padStartEx(writeVersion, 2, \"0\"), padStartEx(minorVersion, 2, \"0\"));\r\n }\r\n\r\n const twoVersionExpression = desiredKey.name + twoVersionSuffix;\r\n const threeVersionExpression = desiredKey.name + threeVersionSuffix;\r\n\r\n for (const searchPath of this.searchPaths) {\r\n this.addCandidateNoExtSchemaKey(foundFiles, searchPath, desiredKey.name, desiredKey, matchType, format);\r\n this.addCandidateSchemaKeys(foundFiles, searchPath, twoVersionExpression, desiredKey, matchType, format);\r\n this.addCandidateSchemaKeys(foundFiles, searchPath, threeVersionExpression, desiredKey, matchType, format);\r\n }\r\n\r\n return foundFiles;\r\n }\r\n\r\n public abstract getSchema<T extends Schema>(key: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<T | undefined>;\r\n\r\n /**\r\n * Compares two Schema versions. If the left-hand version is greater, 1 is returned. If the\r\n * left-hand version is less, -1 us returned. If the versions are an exact match, 0 is returned.\r\n * @param lhs The 'left-hand' FileSchemaKey.\r\n * @param rhs The 'right-hand' FileSchemaKey.\r\n */\r\n public compareSchemaKeyByVersion = (lhs: FileSchemaKey, rhs: FileSchemaKey): number => {\r\n return lhs.compareByVersion(rhs);\r\n };\r\n}\r\n"]}
1
+ {"version":3,"file":"SchemaFileLocater.js","sourceRoot":"","sources":["../../src/SchemaFileLocater.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,yBAAyB;AACzB,6BAA6B;AAC7B,6BAA6B;AAC7B,gEAA6F;AAE7F;;GAEG;AAEH,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;QAC7B,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;KACpB;SAAM;QACL,YAAY,GAAG,YAAY,GAAG,GAAG,CAAC,MAAM,CAAC;QACzC,IAAI,YAAY,GAAG,SAAS,CAAC,MAAM,EAAE;YAC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AE,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;YAC9F,kBAAkB,GAAG,YAAY,CAAC,qBAAqB,MAAM,EAAE,EAAE,UAAU,CAAC,WAAW,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;SACnG;aAAM;YACL,gBAAgB,GAAG,YAAY,CAAC,qBAAqB,MAAM,EAAE,EAAE,UAAU,CAAC,WAAW,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,UAAU,CAAC,YAAY,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;YAClI,kBAAkB,GAAG,YAAY,CAAC,yBAAyB,MAAM,EAAE,EAAE,UAAU,CAAC,WAAW,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,UAAU,CAAC,YAAY,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,UAAU,CAAC,YAAY,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;SAC3K;QAED,MAAM,oBAAoB,GAAG,UAAU,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAChE,MAAM,sBAAsB,GAAG,UAAU,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAEpE,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,WAAW,EAAE;YACzC,IAAI,CAAC,0BAA0B,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,IAAI,EAAE,UAAU,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;SAC5G;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;CAaF;AA9KD,8CA8KC","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 * as fs from \"fs\";\nimport * as glob from \"glob\";\nimport * as path from \"path\";\nimport { Schema, SchemaContext, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\n\n/** @packageDocumentation\n * @module Locaters\n */\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 = new glob.GlobSync(fullPath, { sync: true });\n for (const match of result.found) {\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 public abstract getSchema<T extends Schema>(key: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<T | 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,15 +1,18 @@
1
- import { Schema } from "@itwin/ecschema-metadata";
2
- /**
3
- * Utility class to assist in creating serialized EC Schemas on the file system.
4
- * @beta
5
- */
6
- export declare class SchemaFileUtility {
7
- /**
8
- * Writes a Schema to an xml file to the specified output path.
9
- * @param schema The Schema to serialize.
10
- * @param outputPath The directory in which to create the file.
11
- */
12
- static writeSchemaXmlFile(schema: Schema, outputPath: string): Promise<void>;
13
- private static getSchemaPath;
14
- }
1
+ import { Schema } from "@itwin/ecschema-metadata";
2
+ /** @packageDocumentation
3
+ * @module Utils
4
+ */
5
+ /**
6
+ * Utility class to assist in creating serialized EC Schemas on the file system.
7
+ * @beta
8
+ */
9
+ export declare class SchemaFileUtility {
10
+ /**
11
+ * Writes a Schema to an xml file to the specified output path.
12
+ * @param schema The Schema to serialize.
13
+ * @param outputPath The directory in which to create the file.
14
+ */
15
+ static writeSchemaXmlFile(schema: Schema, outputPath: string): Promise<void>;
16
+ private static getSchemaPath;
17
+ }
15
18
  //# sourceMappingURL=SchemaFileUtility.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaFileUtility.d.ts","sourceRoot":"","sources":["../../src/SchemaFileUtility.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD;;;GAGG;AACH,qBAAa,iBAAiB;IAE5B;;;;OAIG;WACiB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAgBzE,OAAO,CAAC,MAAM,CAAC,aAAa;CAU7B"}
1
+ {"version":3,"file":"SchemaFileUtility.d.ts","sourceRoot":"","sources":["../../src/SchemaFileUtility.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD;;GAEG;AAEH;;;GAGG;AACH,qBAAa,iBAAiB;IAE5B;;;;OAIG;WACiB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAgBzE,OAAO,CAAC,MAAM,CAAC,aAAa;CAU7B"}