@itwin/ecschema-locaters 4.0.0-dev.6 → 4.0.0-dev.60
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 +11 -1
- package/lib/cjs/SchemaFileLocater.d.ts +82 -82
- package/lib/cjs/SchemaFileLocater.js +212 -212
- package/lib/cjs/SchemaFileLocater.js.map +1 -1
- package/lib/cjs/SchemaFileUtility.d.ts +17 -17
- package/lib/cjs/SchemaFileUtility.js +48 -48
- package/lib/cjs/SchemaFileUtility.js.map +1 -1
- package/lib/cjs/SchemaJsonFileLocater.d.ts +33 -33
- package/lib/cjs/SchemaJsonFileLocater.js +90 -90
- package/lib/cjs/SchemaJsonFileLocater.js.map +1 -1
- package/lib/cjs/SchemaXmlFileLocater.d.ts +33 -33
- package/lib/cjs/SchemaXmlFileLocater.js +93 -93
- package/lib/cjs/SchemaXmlFileLocater.js.map +1 -1
- package/lib/cjs/StubSchemaXmlFileLocater.d.ts +69 -69
- package/lib/cjs/StubSchemaXmlFileLocater.js +177 -177
- package/lib/cjs/StubSchemaXmlFileLocater.js.map +1 -1
- package/lib/cjs/ecschema-locaters.d.ts +17 -17
- package/lib/cjs/ecschema-locaters.js +37 -33
- package/lib/cjs/ecschema-locaters.js.map +1 -1
- package/lib/cjs/test/SchemaFileUtility.test.d.ts +1 -1
- package/lib/cjs/test/SchemaFileUtility.test.js +56 -56
- package/lib/cjs/test/SchemaFileUtility.test.js.map +1 -1
- package/lib/cjs/test/SchemaJsonFileLocator.test.d.ts +1 -1
- package/lib/cjs/test/SchemaJsonFileLocator.test.js +119 -119
- package/lib/cjs/test/SchemaJsonFileLocator.test.js.map +1 -1
- package/lib/cjs/test/SchemaXmlFileLocator.test.d.ts +1 -1
- package/lib/cjs/test/SchemaXmlFileLocator.test.js +180 -180
- package/lib/cjs/test/SchemaXmlFileLocator.test.js.map +1 -1
- package/lib/cjs/test/StubSchemaXmlFileLocater.test.d.ts +1 -1
- package/lib/cjs/test/StubSchemaXmlFileLocater.test.js +170 -170
- package/lib/cjs/test/StubSchemaXmlFileLocater.test.js.map +1 -1
- package/package.json +7 -7
|
@@ -1,178 +1,178 @@
|
|
|
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.StubSchemaXmlFileLocater = void 0;
|
|
8
|
-
const path = require("path");
|
|
9
|
-
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
10
|
-
const SchemaFileLocater_1 = require("./SchemaFileLocater");
|
|
11
|
-
/** @packageDocumentation
|
|
12
|
-
* @module Locaters
|
|
13
|
-
*/
|
|
14
|
-
function isECv2Schema(schemaText) {
|
|
15
|
-
return /<ECSchema[^>]*xmlns=".*ECXML.2.0"/.test(schemaText);
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* A SchemaLocater implementation for locating XML Schema files
|
|
19
|
-
* from the file system using configurable search paths. Returns only
|
|
20
|
-
* Schemas from XML files with their keys populated.
|
|
21
|
-
* @internal
|
|
22
|
-
*/
|
|
23
|
-
class StubSchemaXmlFileLocater extends SchemaFileLocater_1.SchemaFileLocater {
|
|
24
|
-
/**
|
|
25
|
-
* Loads a Schema from an XML file on the file system.
|
|
26
|
-
* @param schemaPath The path to the Schema file.
|
|
27
|
-
* @param schemaText Optionally pass in the schema text read from the schema file. If undefined,
|
|
28
|
-
* the schema will be read from the provided schemaPath.
|
|
29
|
-
*/
|
|
30
|
-
loadSchema(schemaPath, schemaText) {
|
|
31
|
-
schemaText = schemaText || this.readUtf8FileToStringSync(schemaPath);
|
|
32
|
-
if (!schemaText)
|
|
33
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.UnableToLocateSchema, `Unable to locate schema XML file at ${schemaPath}`);
|
|
34
|
-
this.addSchemaSearchPaths([path.dirname(schemaPath)]);
|
|
35
|
-
const key = this.getSchemaKey(schemaText);
|
|
36
|
-
const alias = this.getSchemaAlias(schemaText);
|
|
37
|
-
const context = new ecschema_metadata_1.SchemaContext();
|
|
38
|
-
context.addLocater(this);
|
|
39
|
-
// Load the schema and return it
|
|
40
|
-
const schema = new ecschema_metadata_1.Schema(context, new SchemaFileLocater_1.FileSchemaKey(key, schemaPath, schemaText), alias);
|
|
41
|
-
this.addSchemaReferences(schema, context, ecschema_metadata_1.SchemaMatchType.LatestWriteCompatible);
|
|
42
|
-
return schema;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Attempts to retrieve a Schema with the given SchemaKey by using the configured search paths
|
|
46
|
-
* to locate the XML Schema file from the file system. Returns only Schemas from XML files with
|
|
47
|
-
* their keys populated.
|
|
48
|
-
* @param key The SchemaKey of the Schema to retrieve.
|
|
49
|
-
* @param matchType The SchemaMatchType.
|
|
50
|
-
* @param context The SchemaContext that will control the lifetime of the schema.
|
|
51
|
-
*/
|
|
52
|
-
async getSchema(key, matchType, context) {
|
|
53
|
-
return this.getSchemaSync(key, matchType, context);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Attempts to retrieve a Schema with the given SchemaKey by using the configured search paths
|
|
57
|
-
* to locate the XML Schema file from the file system. Returns only Schemas from XML files with
|
|
58
|
-
* their keys populated.
|
|
59
|
-
* @param key The SchemaKey of the Schema to retrieve.
|
|
60
|
-
* @param matchType The SchemaMatchType.
|
|
61
|
-
* @param context The SchemaContext that will control the lifetime of the schema.
|
|
62
|
-
*/
|
|
63
|
-
getSchemaSync(key, matchType, context) {
|
|
64
|
-
const candidates = this.findEligibleSchemaKeys(key, matchType, "xml");
|
|
65
|
-
if (!candidates || candidates.length === 0)
|
|
66
|
-
return undefined;
|
|
67
|
-
const maxCandidate = candidates.sort(this.compareSchemaKeyByVersion)[candidates.length - 1]; // eslint-disable-line @typescript-eslint/unbound-method
|
|
68
|
-
const alias = this.getSchemaAlias(maxCandidate.schemaText);
|
|
69
|
-
const schema = new ecschema_metadata_1.Schema(context, maxCandidate, alias);
|
|
70
|
-
context.addSchemaSync(schema);
|
|
71
|
-
this.addSchemaReferences(schema, context, ecschema_metadata_1.SchemaMatchType.LatestWriteCompatible);
|
|
72
|
-
return schema;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Constructs a SchemaKey based on the information in the Schema XML.
|
|
76
|
-
* @param schemaXml The Schema XML as a string.
|
|
77
|
-
*/
|
|
78
|
-
getSchemaKey(schemaXml) {
|
|
79
|
-
const matches = schemaXml.match(/<ECSchema ([^]+?)>/g);
|
|
80
|
-
if (!matches || matches.length !== 1)
|
|
81
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaXML, `Could not find '<ECSchema>' tag in the given file`);
|
|
82
|
-
const name = matches[0].match(/schemaName="(.+?)"/);
|
|
83
|
-
const version = matches[0].match(/version="(.+?)"/);
|
|
84
|
-
if (!name || name.length !== 2 || !version || version.length !== 2)
|
|
85
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaXML, `Could not find the ECSchema 'schemaName' or 'version' tag in the given file`);
|
|
86
|
-
let ecVersion;
|
|
87
|
-
if (isECv2Schema(schemaXml))
|
|
88
|
-
ecVersion = this.fromECv2String(version[1]);
|
|
89
|
-
else
|
|
90
|
-
ecVersion = ecschema_metadata_1.ECVersion.fromString(version[1]);
|
|
91
|
-
const key = new ecschema_metadata_1.SchemaKey(name[1], ecVersion);
|
|
92
|
-
return key;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Gets an array of SchemaKeys of the Schemas referenced by the given Schema.
|
|
96
|
-
* @param xmlSchemaKey The SchemaKey of the parent Schema containing the references.
|
|
97
|
-
*/
|
|
98
|
-
getSchemaReferenceKeys(schemaKey) {
|
|
99
|
-
return this._getSchemaReferenceKeys(schemaKey);
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Adds schemas to the references collection for the given Schema by locating
|
|
103
|
-
* the referenced schemas.
|
|
104
|
-
* @param schema The schema for which to add the references.
|
|
105
|
-
* @param context The SchemaContext that will control the lifetime of the schema.
|
|
106
|
-
* @param refMatchType The SchemaMatchType to use when locating schema references.
|
|
107
|
-
*/
|
|
108
|
-
addSchemaReferences(schema, context, refMatchType) {
|
|
109
|
-
const refKeys = this.getSchemaReferenceKeys(schema.schemaKey);
|
|
110
|
-
for (const key of refKeys) {
|
|
111
|
-
const refSchema = context ? context.getSchemaSync(key, refMatchType) : undefined;
|
|
112
|
-
if (!refSchema)
|
|
113
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.UnableToLocateSchema, `Unable to locate referenced schema: ${key.name}.${key.readVersion}.${key.writeVersion}.${key.minorVersion}`);
|
|
114
|
-
schema.references.push(refSchema);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Gets an array of SchemaKeys of the Schemas referenced by the given Schema.
|
|
119
|
-
* @param data The Schema XML string.
|
|
120
|
-
*/
|
|
121
|
-
_getSchemaReferenceKeys(xmlSchemaKey) {
|
|
122
|
-
const file = xmlSchemaKey.schemaText;
|
|
123
|
-
if (!file)
|
|
124
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.UnableToLocateSchema, `Could not locate the schema file, ${xmlSchemaKey.fileName}, for the schema ${xmlSchemaKey.name}`);
|
|
125
|
-
const data = file.toString().replace(/(\s*)<!--.*?-->/g, ""); // ignore any comments in the XML file when getting the array of SchemaKeys
|
|
126
|
-
const keys = [];
|
|
127
|
-
const matches = data.match(/<ECSchemaReference ([^]+?)\/>/g);
|
|
128
|
-
if (!matches)
|
|
129
|
-
return keys;
|
|
130
|
-
for (const match of matches) {
|
|
131
|
-
const name = match.match(/name="(.+?)"/);
|
|
132
|
-
const versionMatch = match.match(/version="(.+?)"/);
|
|
133
|
-
if (!name || name.length !== 2 || !versionMatch || versionMatch.length !== 2)
|
|
134
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaXML, `Invalid ECSchemaReference xml encountered in the schema file`);
|
|
135
|
-
// write version maybe missing, so insert "0"
|
|
136
|
-
let versionString = versionMatch[1];
|
|
137
|
-
const versionParts = versionString.split(".");
|
|
138
|
-
if (versionParts.length === 2)
|
|
139
|
-
versionParts.splice(1, 0, "0");
|
|
140
|
-
versionString = versionParts.join(".");
|
|
141
|
-
const key = new ecschema_metadata_1.SchemaKey(name[1], ecschema_metadata_1.ECVersion.fromString(versionString));
|
|
142
|
-
keys.push(key);
|
|
143
|
-
}
|
|
144
|
-
return keys;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Gets the Schema alias from the Schema XML.
|
|
148
|
-
* @param data The Schema XML as a string.
|
|
149
|
-
*/
|
|
150
|
-
getSchemaAlias(schemaXml) {
|
|
151
|
-
let match;
|
|
152
|
-
if (isECv2Schema(schemaXml)) {
|
|
153
|
-
match = schemaXml.match(/<ECSchema.*nameSpacePrefix="(?<alias>\w+)"/);
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
match = schemaXml.match(/<ECSchema.*alias="(?<alias>\w+)"/);
|
|
157
|
-
}
|
|
158
|
-
if (!match || !match.groups.alias) {
|
|
159
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaXML, `Could not find the ECSchema 'alias' tag in the given file.`);
|
|
160
|
-
}
|
|
161
|
-
return match.groups.alias;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Parses a valid EC 2.0 version string and returns an ECVersion object. The second digit becomes the minor version,
|
|
165
|
-
* and a zero is inserted as the 'write' digit. Example: "1.1" -> "1.0.1".
|
|
166
|
-
* @param versionString A valid EC 2.0 version string of the format, 'RR.mm'.
|
|
167
|
-
*/
|
|
168
|
-
fromECv2String(versionString) {
|
|
169
|
-
const [read, minor] = versionString.split(".");
|
|
170
|
-
if (!read)
|
|
171
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidECVersion, `The read version is missing from version string, ${versionString}`);
|
|
172
|
-
if (!minor)
|
|
173
|
-
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidECVersion, `The minor version is missing from version string, ${versionString}`);
|
|
174
|
-
return new ecschema_metadata_1.ECVersion(+read, 0, +minor);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
exports.StubSchemaXmlFileLocater = StubSchemaXmlFileLocater;
|
|
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.StubSchemaXmlFileLocater = void 0;
|
|
8
|
+
const path = require("path");
|
|
9
|
+
const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
|
|
10
|
+
const SchemaFileLocater_1 = require("./SchemaFileLocater");
|
|
11
|
+
/** @packageDocumentation
|
|
12
|
+
* @module Locaters
|
|
13
|
+
*/
|
|
14
|
+
function isECv2Schema(schemaText) {
|
|
15
|
+
return /<ECSchema[^>]*xmlns=".*ECXML.2.0"/.test(schemaText);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A SchemaLocater implementation for locating XML Schema files
|
|
19
|
+
* from the file system using configurable search paths. Returns only
|
|
20
|
+
* Schemas from XML files with their keys populated.
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
class StubSchemaXmlFileLocater extends SchemaFileLocater_1.SchemaFileLocater {
|
|
24
|
+
/**
|
|
25
|
+
* Loads a Schema from an XML file on the file system.
|
|
26
|
+
* @param schemaPath The path to the Schema file.
|
|
27
|
+
* @param schemaText Optionally pass in the schema text read from the schema file. If undefined,
|
|
28
|
+
* the schema will be read from the provided schemaPath.
|
|
29
|
+
*/
|
|
30
|
+
loadSchema(schemaPath, schemaText) {
|
|
31
|
+
schemaText = schemaText || this.readUtf8FileToStringSync(schemaPath);
|
|
32
|
+
if (!schemaText)
|
|
33
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.UnableToLocateSchema, `Unable to locate schema XML file at ${schemaPath}`);
|
|
34
|
+
this.addSchemaSearchPaths([path.dirname(schemaPath)]);
|
|
35
|
+
const key = this.getSchemaKey(schemaText);
|
|
36
|
+
const alias = this.getSchemaAlias(schemaText);
|
|
37
|
+
const context = new ecschema_metadata_1.SchemaContext();
|
|
38
|
+
context.addLocater(this);
|
|
39
|
+
// Load the schema and return it
|
|
40
|
+
const schema = new ecschema_metadata_1.Schema(context, new SchemaFileLocater_1.FileSchemaKey(key, schemaPath, schemaText), alias);
|
|
41
|
+
this.addSchemaReferences(schema, context, ecschema_metadata_1.SchemaMatchType.LatestWriteCompatible);
|
|
42
|
+
return schema;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Attempts to retrieve a Schema with the given SchemaKey by using the configured search paths
|
|
46
|
+
* to locate the XML Schema file from the file system. Returns only Schemas from XML files with
|
|
47
|
+
* their keys populated.
|
|
48
|
+
* @param key The SchemaKey of the Schema to retrieve.
|
|
49
|
+
* @param matchType The SchemaMatchType.
|
|
50
|
+
* @param context The SchemaContext that will control the lifetime of the schema.
|
|
51
|
+
*/
|
|
52
|
+
async getSchema(key, matchType, context) {
|
|
53
|
+
return this.getSchemaSync(key, matchType, context);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Attempts to retrieve a Schema with the given SchemaKey by using the configured search paths
|
|
57
|
+
* to locate the XML Schema file from the file system. Returns only Schemas from XML files with
|
|
58
|
+
* their keys populated.
|
|
59
|
+
* @param key The SchemaKey of the Schema to retrieve.
|
|
60
|
+
* @param matchType The SchemaMatchType.
|
|
61
|
+
* @param context The SchemaContext that will control the lifetime of the schema.
|
|
62
|
+
*/
|
|
63
|
+
getSchemaSync(key, matchType, context) {
|
|
64
|
+
const candidates = this.findEligibleSchemaKeys(key, matchType, "xml");
|
|
65
|
+
if (!candidates || candidates.length === 0)
|
|
66
|
+
return undefined;
|
|
67
|
+
const maxCandidate = candidates.sort(this.compareSchemaKeyByVersion)[candidates.length - 1]; // eslint-disable-line @typescript-eslint/unbound-method
|
|
68
|
+
const alias = this.getSchemaAlias(maxCandidate.schemaText);
|
|
69
|
+
const schema = new ecschema_metadata_1.Schema(context, maxCandidate, alias);
|
|
70
|
+
context.addSchemaSync(schema);
|
|
71
|
+
this.addSchemaReferences(schema, context, ecschema_metadata_1.SchemaMatchType.LatestWriteCompatible);
|
|
72
|
+
return schema;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Constructs a SchemaKey based on the information in the Schema XML.
|
|
76
|
+
* @param schemaXml The Schema XML as a string.
|
|
77
|
+
*/
|
|
78
|
+
getSchemaKey(schemaXml) {
|
|
79
|
+
const matches = schemaXml.match(/<ECSchema ([^]+?)>/g);
|
|
80
|
+
if (!matches || matches.length !== 1)
|
|
81
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaXML, `Could not find '<ECSchema>' tag in the given file`);
|
|
82
|
+
const name = matches[0].match(/schemaName="(.+?)"/);
|
|
83
|
+
const version = matches[0].match(/version="(.+?)"/);
|
|
84
|
+
if (!name || name.length !== 2 || !version || version.length !== 2)
|
|
85
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaXML, `Could not find the ECSchema 'schemaName' or 'version' tag in the given file`);
|
|
86
|
+
let ecVersion;
|
|
87
|
+
if (isECv2Schema(schemaXml))
|
|
88
|
+
ecVersion = this.fromECv2String(version[1]);
|
|
89
|
+
else
|
|
90
|
+
ecVersion = ecschema_metadata_1.ECVersion.fromString(version[1]);
|
|
91
|
+
const key = new ecschema_metadata_1.SchemaKey(name[1], ecVersion);
|
|
92
|
+
return key;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Gets an array of SchemaKeys of the Schemas referenced by the given Schema.
|
|
96
|
+
* @param xmlSchemaKey The SchemaKey of the parent Schema containing the references.
|
|
97
|
+
*/
|
|
98
|
+
getSchemaReferenceKeys(schemaKey) {
|
|
99
|
+
return this._getSchemaReferenceKeys(schemaKey);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Adds schemas to the references collection for the given Schema by locating
|
|
103
|
+
* the referenced schemas.
|
|
104
|
+
* @param schema The schema for which to add the references.
|
|
105
|
+
* @param context The SchemaContext that will control the lifetime of the schema.
|
|
106
|
+
* @param refMatchType The SchemaMatchType to use when locating schema references.
|
|
107
|
+
*/
|
|
108
|
+
addSchemaReferences(schema, context, refMatchType) {
|
|
109
|
+
const refKeys = this.getSchemaReferenceKeys(schema.schemaKey);
|
|
110
|
+
for (const key of refKeys) {
|
|
111
|
+
const refSchema = context ? context.getSchemaSync(key, refMatchType) : undefined;
|
|
112
|
+
if (!refSchema)
|
|
113
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.UnableToLocateSchema, `Unable to locate referenced schema: ${key.name}.${key.readVersion}.${key.writeVersion}.${key.minorVersion}`);
|
|
114
|
+
schema.references.push(refSchema);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Gets an array of SchemaKeys of the Schemas referenced by the given Schema.
|
|
119
|
+
* @param data The Schema XML string.
|
|
120
|
+
*/
|
|
121
|
+
_getSchemaReferenceKeys(xmlSchemaKey) {
|
|
122
|
+
const file = xmlSchemaKey.schemaText;
|
|
123
|
+
if (!file)
|
|
124
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.UnableToLocateSchema, `Could not locate the schema file, ${xmlSchemaKey.fileName}, for the schema ${xmlSchemaKey.name}`);
|
|
125
|
+
const data = file.toString().replace(/(\s*)<!--.*?-->/g, ""); // ignore any comments in the XML file when getting the array of SchemaKeys
|
|
126
|
+
const keys = [];
|
|
127
|
+
const matches = data.match(/<ECSchemaReference ([^]+?)\/>/g);
|
|
128
|
+
if (!matches)
|
|
129
|
+
return keys;
|
|
130
|
+
for (const match of matches) {
|
|
131
|
+
const name = match.match(/name="(.+?)"/);
|
|
132
|
+
const versionMatch = match.match(/version="(.+?)"/);
|
|
133
|
+
if (!name || name.length !== 2 || !versionMatch || versionMatch.length !== 2)
|
|
134
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaXML, `Invalid ECSchemaReference xml encountered in the schema file`);
|
|
135
|
+
// write version maybe missing, so insert "0"
|
|
136
|
+
let versionString = versionMatch[1];
|
|
137
|
+
const versionParts = versionString.split(".");
|
|
138
|
+
if (versionParts.length === 2)
|
|
139
|
+
versionParts.splice(1, 0, "0");
|
|
140
|
+
versionString = versionParts.join(".");
|
|
141
|
+
const key = new ecschema_metadata_1.SchemaKey(name[1], ecschema_metadata_1.ECVersion.fromString(versionString));
|
|
142
|
+
keys.push(key);
|
|
143
|
+
}
|
|
144
|
+
return keys;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Gets the Schema alias from the Schema XML.
|
|
148
|
+
* @param data The Schema XML as a string.
|
|
149
|
+
*/
|
|
150
|
+
getSchemaAlias(schemaXml) {
|
|
151
|
+
let match;
|
|
152
|
+
if (isECv2Schema(schemaXml)) {
|
|
153
|
+
match = schemaXml.match(/<ECSchema.*nameSpacePrefix="(?<alias>\w+)"/);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
match = schemaXml.match(/<ECSchema.*alias="(?<alias>\w+)"/);
|
|
157
|
+
}
|
|
158
|
+
if (!match || !match.groups.alias) {
|
|
159
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidSchemaXML, `Could not find the ECSchema 'alias' tag in the given file.`);
|
|
160
|
+
}
|
|
161
|
+
return match.groups.alias;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Parses a valid EC 2.0 version string and returns an ECVersion object. The second digit becomes the minor version,
|
|
165
|
+
* and a zero is inserted as the 'write' digit. Example: "1.1" -> "1.0.1".
|
|
166
|
+
* @param versionString A valid EC 2.0 version string of the format, 'RR.mm'.
|
|
167
|
+
*/
|
|
168
|
+
fromECv2String(versionString) {
|
|
169
|
+
const [read, minor] = versionString.split(".");
|
|
170
|
+
if (!read)
|
|
171
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidECVersion, `The read version is missing from version string, ${versionString}`);
|
|
172
|
+
if (!minor)
|
|
173
|
+
throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.InvalidECVersion, `The minor version is missing from version string, ${versionString}`);
|
|
174
|
+
return new ecschema_metadata_1.ECVersion(+read, 0, +minor);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
exports.StubSchemaXmlFileLocater = StubSchemaXmlFileLocater;
|
|
178
178
|
//# sourceMappingURL=StubSchemaXmlFileLocater.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StubSchemaXmlFileLocater.js","sourceRoot":"","sources":["../../src/StubSchemaXmlFileLocater.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,6BAA6B;AAC7B,gEAEkC;AAClC,2DAAuE;AAEvE;;GAEG;AAEH,SAAS,YAAY,CAAC,UAAkB;IACtC,OAAO,mCAAmC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AAC9D,CAAC;AAED;;;;;GAKG;AACH,MAAa,wBAAyB,SAA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,CAAC,SAAS,CAAC,EAAE;YAC3B,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,4CAA4C,CAAQ,CAAC;SAC9E;aAAM;YACL,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,kCAAkC,CAAQ,CAAC;SACpE;QAED,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE;YACjC,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,gBAAgB,EAAE,4DAA4D,CAAC,CAAC;SAC1H;QAED,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACK,cAAc,CAAC,aAAqB;QAC1C,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAE/C,IAAI,CAAC,IAAI;YACP,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,gBAAgB,EAAE,oDAAoD,aAAa,EAAE,CAAC,CAAC;QAElI,IAAI,CAAC,KAAK;YACR,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,gBAAgB,EAAE,qDAAqD,aAAa,EAAE,CAAC,CAAC;QAEnI,OAAO,IAAI,6BAAS,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;CACF;AAxLD,4DAwLC","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 path from \"path\";\r\nimport {\r\n ECObjectsError, ECObjectsStatus, ECVersion, ISchemaLocater, Schema, SchemaContext, SchemaKey, SchemaMatchType,\r\n} from \"@itwin/ecschema-metadata\";\r\nimport { FileSchemaKey, SchemaFileLocater } from \"./SchemaFileLocater\";\r\n\r\n/** @packageDocumentation\r\n * @module Locaters\r\n */\r\n\r\nfunction isECv2Schema(schemaText: string): boolean {\r\n return /<ECSchema[^>]*xmlns=\".*ECXML.2.0\"/.test(schemaText);\r\n}\r\n\r\n/**\r\n * A SchemaLocater implementation for locating XML Schema files\r\n * from the file system using configurable search paths. Returns only\r\n * Schemas from XML files with their keys populated.\r\n * @internal\r\n */\r\nexport class StubSchemaXmlFileLocater extends SchemaFileLocater implements ISchemaLocater {\r\n /**\r\n * Loads a Schema from an XML file on the file system.\r\n * @param schemaPath The path to the Schema file.\r\n * @param schemaText Optionally pass in the schema text read from the schema file. If undefined,\r\n * the schema will be read from the provided schemaPath.\r\n */\r\n public loadSchema(schemaPath: string, schemaText?: string): Schema {\r\n schemaText = schemaText || this.readUtf8FileToStringSync(schemaPath);\r\n if (!schemaText)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `Unable to locate schema XML file at ${schemaPath}`);\r\n\r\n this.addSchemaSearchPaths([path.dirname(schemaPath)]);\r\n const key = this.getSchemaKey(schemaText);\r\n const alias = this.getSchemaAlias(schemaText);\r\n const context = new SchemaContext();\r\n context.addLocater(this);\r\n\r\n // Load the schema and return it\r\n const schema = new Schema(context, new FileSchemaKey(key, schemaPath, schemaText), alias);\r\n this.addSchemaReferences(schema, context, SchemaMatchType.LatestWriteCompatible);\r\n return schema;\r\n }\r\n\r\n /**\r\n * Attempts to retrieve a Schema with the given SchemaKey by using the configured search paths\r\n * to locate the XML Schema file from the file system. Returns only Schemas from XML files with\r\n * their keys populated.\r\n * @param key The SchemaKey of the Schema to retrieve.\r\n * @param matchType The SchemaMatchType.\r\n * @param context The SchemaContext that will control the lifetime of the schema.\r\n */\r\n public async getSchema<T extends Schema>(key: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<T | undefined> {\r\n return this.getSchemaSync(key, matchType, context) as T;\r\n }\r\n\r\n /**\r\n * Attempts to retrieve a Schema with the given SchemaKey by using the configured search paths\r\n * to locate the XML Schema file from the file system. Returns only Schemas from XML files with\r\n * their keys populated.\r\n * @param key The SchemaKey of the Schema to retrieve.\r\n * @param matchType The SchemaMatchType.\r\n * @param context The SchemaContext that will control the lifetime of the schema.\r\n */\r\n public getSchemaSync<T extends Schema>(key: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): T | undefined {\r\n const candidates: FileSchemaKey[] = this.findEligibleSchemaKeys(key, matchType, \"xml\");\r\n\r\n if (!candidates || candidates.length === 0)\r\n return undefined;\r\n\r\n const maxCandidate = candidates.sort(this.compareSchemaKeyByVersion)[candidates.length - 1]; // eslint-disable-line @typescript-eslint/unbound-method\r\n const alias = this.getSchemaAlias(maxCandidate.schemaText!);\r\n const schema = new Schema(context, maxCandidate, alias) as T;\r\n context.addSchemaSync(schema);\r\n\r\n this.addSchemaReferences(schema, context, SchemaMatchType.LatestWriteCompatible);\r\n return schema;\r\n }\r\n\r\n /**\r\n * Constructs a SchemaKey based on the information in the Schema XML.\r\n * @param schemaXml The Schema XML as a string.\r\n */\r\n public getSchemaKey(schemaXml: string): SchemaKey {\r\n const matches = schemaXml.match(/<ECSchema ([^]+?)>/g);\r\n if (!matches || matches.length !== 1)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaXML, `Could not find '<ECSchema>' tag in the given file`);\r\n\r\n const name = matches[0].match(/schemaName=\"(.+?)\"/);\r\n const version = matches[0].match(/version=\"(.+?)\"/);\r\n if (!name || name.length !== 2 || !version || version.length !== 2)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaXML, `Could not find the ECSchema 'schemaName' or 'version' tag in the given file`);\r\n\r\n let ecVersion: ECVersion;\r\n if (isECv2Schema(schemaXml))\r\n ecVersion = this.fromECv2String(version[1]);\r\n else\r\n ecVersion = ECVersion.fromString(version[1]);\r\n\r\n const key = new SchemaKey(name[1], ecVersion);\r\n return key;\r\n }\r\n\r\n /**\r\n * Gets an array of SchemaKeys of the Schemas referenced by the given Schema.\r\n * @param xmlSchemaKey The SchemaKey of the parent Schema containing the references.\r\n */\r\n private getSchemaReferenceKeys(schemaKey: FileSchemaKey): SchemaKey[] {\r\n return this._getSchemaReferenceKeys(schemaKey);\r\n }\r\n\r\n /**\r\n * Adds schemas to the references collection for the given Schema by locating\r\n * the referenced schemas.\r\n * @param schema The schema for which to add the references.\r\n * @param context The SchemaContext that will control the lifetime of the schema.\r\n * @param refMatchType The SchemaMatchType to use when locating schema references.\r\n */\r\n private addSchemaReferences(schema: Schema, context: SchemaContext, refMatchType: SchemaMatchType): void {\r\n const refKeys = this.getSchemaReferenceKeys(schema.schemaKey as FileSchemaKey);\r\n\r\n for (const key of refKeys) {\r\n const refSchema = context ? context.getSchemaSync(key, refMatchType) : undefined;\r\n if (!refSchema)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `Unable to locate referenced schema: ${key.name}.${key.readVersion}.${key.writeVersion}.${key.minorVersion}`);\r\n\r\n schema.references.push(refSchema);\r\n }\r\n }\r\n\r\n /**\r\n * Gets an array of SchemaKeys of the Schemas referenced by the given Schema.\r\n * @param data The Schema XML string.\r\n */\r\n private _getSchemaReferenceKeys(xmlSchemaKey: FileSchemaKey): SchemaKey[] {\r\n const file = xmlSchemaKey.schemaText;\r\n\r\n if (!file)\r\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `Could not locate the schema file, ${xmlSchemaKey.fileName}, for the schema ${xmlSchemaKey.name}`);\r\n\r\n const data = file.toString().replace(/(\\s*)<!--.*?-->/g, \"\"); // ignore any comments in the XML file when getting the array of SchemaKeys\r\n\r\n const keys: SchemaKey[] = [];\r\n const matches = data.match(/<ECSchemaReference ([^]+?)\\/>/g);\r\n if (!matches)\r\n return keys;\r\n\r\n for (const match of matches) {\r\n const name = match.match(/name=\"(.+?)\"/);\r\n const versionMatch = match.match(/version=\"(.+?)\"/);\r\n if (!name || name.length !== 2 || !versionMatch || versionMatch.length !== 2)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaXML, `Invalid ECSchemaReference xml encountered in the schema file`);\r\n\r\n // write version maybe missing, so insert \"0\"\r\n let versionString = versionMatch[1];\r\n const versionParts = versionString.split(\".\");\r\n if (versionParts.length === 2)\r\n versionParts.splice(1, 0, \"0\");\r\n\r\n versionString = versionParts.join(\".\");\r\n\r\n const key = new SchemaKey(name[1], ECVersion.fromString(versionString));\r\n keys.push(key);\r\n }\r\n\r\n return keys;\r\n }\r\n\r\n /**\r\n * Gets the Schema alias from the Schema XML.\r\n * @param data The Schema XML as a string.\r\n */\r\n private getSchemaAlias(schemaXml: string): string {\r\n let match: any;\r\n\r\n if (isECv2Schema(schemaXml)) {\r\n match = schemaXml.match(/<ECSchema.*nameSpacePrefix=\"(?<alias>\\w+)\"/) as any;\r\n } else {\r\n match = schemaXml.match(/<ECSchema.*alias=\"(?<alias>\\w+)\"/) as any;\r\n }\r\n\r\n if (!match || !match.groups.alias) {\r\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaXML, `Could not find the ECSchema 'alias' tag in the given file.`);\r\n }\r\n\r\n return match.groups.alias;\r\n }\r\n\r\n /**\r\n * Parses a valid EC 2.0 version string and returns an ECVersion object. The second digit becomes the minor version,\r\n * and a zero is inserted as the 'write' digit. Example: \"1.1\" -> \"1.0.1\".\r\n * @param versionString A valid EC 2.0 version string of the format, 'RR.mm'.\r\n */\r\n private fromECv2String(versionString: string): ECVersion {\r\n const [read, minor] = versionString.split(\".\");\r\n\r\n if (!read)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECVersion, `The read version is missing from version string, ${versionString}`);\r\n\r\n if (!minor)\r\n throw new ECObjectsError(ECObjectsStatus.InvalidECVersion, `The minor version is missing from version string, ${versionString}`);\r\n\r\n return new ECVersion(+read, 0, +minor);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"StubSchemaXmlFileLocater.js","sourceRoot":"","sources":["../../src/StubSchemaXmlFileLocater.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,6BAA6B;AAC7B,gEAEkC;AAClC,2DAAuE;AAEvE;;GAEG;AAEH,S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G,CAAC,CAAC;SAChB;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACK,cAAc,CAAC,SAAiB;QACtC,IAAI,KAAU,CAAC;QAEf,IAAI,YAAY,CAAC,SAAS,CAAC,EAAE;YAC3B,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,4CAA4C,CAAQ,CAAC;SAC9E;aAAM;YACL,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,kCAAkC,CAAQ,CAAC;SACpE;QAED,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE;YACjC,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,gBAAgB,EAAE,4DAA4D,CAAC,CAAC;SAC1H;QAED,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACK,cAAc,CAAC,aAAqB;QAC1C,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAE/C,IAAI,CAAC,IAAI;YACP,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,gBAAgB,EAAE,oDAAoD,aAAa,EAAE,CAAC,CAAC;QAElI,IAAI,CAAC,KAAK;YACR,MAAM,IAAI,kCAAc,CAAC,mCAAe,CAAC,gBAAgB,EAAE,qDAAqD,aAAa,EAAE,CAAC,CAAC;QAEnI,OAAO,IAAI,6BAAS,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;CACF;AAxLD,4DAwLC","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 path from \"path\";\nimport {\n ECObjectsError, ECObjectsStatus, ECVersion, ISchemaLocater, Schema, SchemaContext, SchemaKey, SchemaMatchType,\n} from \"@itwin/ecschema-metadata\";\nimport { FileSchemaKey, SchemaFileLocater } from \"./SchemaFileLocater\";\n\n/** @packageDocumentation\n * @module Locaters\n */\n\nfunction isECv2Schema(schemaText: string): boolean {\n return /<ECSchema[^>]*xmlns=\".*ECXML.2.0\"/.test(schemaText);\n}\n\n/**\n * A SchemaLocater implementation for locating XML Schema files\n * from the file system using configurable search paths. Returns only\n * Schemas from XML files with their keys populated.\n * @internal\n */\nexport class StubSchemaXmlFileLocater extends SchemaFileLocater implements ISchemaLocater {\n /**\n * Loads a Schema from an XML file on the file system.\n * @param schemaPath The path to the Schema file.\n * @param schemaText Optionally pass in the schema text read from the schema file. If undefined,\n * the schema will be read from the provided schemaPath.\n */\n public loadSchema(schemaPath: string, schemaText?: string): Schema {\n schemaText = schemaText || this.readUtf8FileToStringSync(schemaPath);\n if (!schemaText)\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `Unable to locate schema XML file at ${schemaPath}`);\n\n this.addSchemaSearchPaths([path.dirname(schemaPath)]);\n const key = this.getSchemaKey(schemaText);\n const alias = this.getSchemaAlias(schemaText);\n const context = new SchemaContext();\n context.addLocater(this);\n\n // Load the schema and return it\n const schema = new Schema(context, new FileSchemaKey(key, schemaPath, schemaText), alias);\n this.addSchemaReferences(schema, context, SchemaMatchType.LatestWriteCompatible);\n return schema;\n }\n\n /**\n * Attempts to retrieve a Schema with the given SchemaKey by using the configured search paths\n * to locate the XML Schema file from the file system. Returns only Schemas from XML files with\n * their keys populated.\n * @param key The SchemaKey of the Schema to retrieve.\n * @param matchType The SchemaMatchType.\n * @param context The SchemaContext that will control the lifetime of the schema.\n */\n public async getSchema<T extends Schema>(key: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<T | undefined> {\n return this.getSchemaSync(key, matchType, context) as T;\n }\n\n /**\n * Attempts to retrieve a Schema with the given SchemaKey by using the configured search paths\n * to locate the XML Schema file from the file system. Returns only Schemas from XML files with\n * their keys populated.\n * @param key The SchemaKey of the Schema to retrieve.\n * @param matchType The SchemaMatchType.\n * @param context The SchemaContext that will control the lifetime of the schema.\n */\n public getSchemaSync<T extends Schema>(key: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): T | 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]; // eslint-disable-line @typescript-eslint/unbound-method\n const alias = this.getSchemaAlias(maxCandidate.schemaText!);\n const schema = new Schema(context, maxCandidate, alias) as T;\n context.addSchemaSync(schema);\n\n this.addSchemaReferences(schema, context, SchemaMatchType.LatestWriteCompatible);\n return schema;\n }\n\n /**\n * Constructs a SchemaKey based on the information in the Schema XML.\n * @param schemaXml The Schema XML as a string.\n */\n public getSchemaKey(schemaXml: string): SchemaKey {\n const matches = schemaXml.match(/<ECSchema ([^]+?)>/g);\n if (!matches || matches.length !== 1)\n throw new 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 let ecVersion: ECVersion;\n if (isECv2Schema(schemaXml))\n ecVersion = this.fromECv2String(version[1]);\n else\n ecVersion = ECVersion.fromString(version[1]);\n\n const key = new SchemaKey(name[1], ecVersion);\n return key;\n }\n\n /**\n * Gets an array of SchemaKeys of the Schemas referenced by the given Schema.\n * @param xmlSchemaKey The SchemaKey of the parent Schema containing the references.\n */\n private getSchemaReferenceKeys(schemaKey: FileSchemaKey): SchemaKey[] {\n return this._getSchemaReferenceKeys(schemaKey);\n }\n\n /**\n * Adds schemas to the references collection for the given Schema by locating\n * the referenced schemas.\n * @param schema The schema for which to add the references.\n * @param context The SchemaContext that will control the lifetime of the schema.\n * @param refMatchType The SchemaMatchType to use when locating schema references.\n */\n private addSchemaReferences(schema: Schema, context: SchemaContext, refMatchType: SchemaMatchType): void {\n const refKeys = this.getSchemaReferenceKeys(schema.schemaKey as FileSchemaKey);\n\n for (const key of refKeys) {\n const refSchema = context ? context.getSchemaSync(key, refMatchType) : undefined;\n if (!refSchema)\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `Unable to locate referenced schema: ${key.name}.${key.readVersion}.${key.writeVersion}.${key.minorVersion}`);\n\n schema.references.push(refSchema);\n }\n }\n\n /**\n * Gets an array of SchemaKeys of the Schemas referenced by the given Schema.\n * @param data The Schema XML string.\n */\n private _getSchemaReferenceKeys(xmlSchemaKey: FileSchemaKey): SchemaKey[] {\n const file = xmlSchemaKey.schemaText;\n\n if (!file)\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema, `Could not locate the schema file, ${xmlSchemaKey.fileName}, for the schema ${xmlSchemaKey.name}`);\n\n const data = file.toString().replace(/(\\s*)<!--.*?-->/g, \"\"); // ignore any comments in the XML file when getting the array of SchemaKeys\n\n const keys: SchemaKey[] = [];\n const matches = data.match(/<ECSchemaReference ([^]+?)\\/>/g);\n if (!matches)\n return keys;\n\n for (const match of matches) {\n const name = match.match(/name=\"(.+?)\"/);\n const versionMatch = match.match(/version=\"(.+?)\"/);\n if (!name || name.length !== 2 || !versionMatch || versionMatch.length !== 2)\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaXML, `Invalid ECSchemaReference xml encountered in the schema file`);\n\n // write version maybe missing, so insert \"0\"\n let versionString = versionMatch[1];\n const versionParts = versionString.split(\".\");\n if (versionParts.length === 2)\n versionParts.splice(1, 0, \"0\");\n\n versionString = versionParts.join(\".\");\n\n const key = new SchemaKey(name[1], ECVersion.fromString(versionString));\n keys.push(key);\n }\n\n return keys;\n }\n\n /**\n * Gets the Schema alias from the Schema XML.\n * @param data The Schema XML as a string.\n */\n private getSchemaAlias(schemaXml: string): string {\n let match: any;\n\n if (isECv2Schema(schemaXml)) {\n match = schemaXml.match(/<ECSchema.*nameSpacePrefix=\"(?<alias>\\w+)\"/) as any;\n } else {\n match = schemaXml.match(/<ECSchema.*alias=\"(?<alias>\\w+)\"/) as any;\n }\n\n if (!match || !match.groups.alias) {\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaXML, `Could not find the ECSchema 'alias' tag in the given file.`);\n }\n\n return match.groups.alias;\n }\n\n /**\n * Parses a valid EC 2.0 version string and returns an ECVersion object. The second digit becomes the minor version,\n * and a zero is inserted as the 'write' digit. Example: \"1.1\" -> \"1.0.1\".\n * @param versionString A valid EC 2.0 version string of the format, 'RR.mm'.\n */\n private fromECv2String(versionString: string): ECVersion {\n const [read, minor] = versionString.split(\".\");\n\n if (!read)\n throw new ECObjectsError(ECObjectsStatus.InvalidECVersion, `The read version is missing from version string, ${versionString}`);\n\n if (!minor)\n throw new ECObjectsError(ECObjectsStatus.InvalidECVersion, `The minor version is missing from version string, ${versionString}`);\n\n return new ECVersion(+read, 0, +minor);\n }\n}\n"]}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export * from "./SchemaFileLocater";
|
|
2
|
-
export * from "./SchemaJsonFileLocater";
|
|
3
|
-
export * from "./SchemaXmlFileLocater";
|
|
4
|
-
export * from "./StubSchemaXmlFileLocater";
|
|
5
|
-
/** @docs-package-description
|
|
6
|
-
* The ecschema-locaters package contains classes for locating ECSchemas within a given
|
|
7
|
-
* [SchemaContext](https://www.itwinjs.org/reference/ecschema-metadata/context/schemacontext). Each locater
|
|
8
|
-
* implements the [ISchemaLocater interface](https://www.itwinjs.org/reference/ecschema-metadata/context/ischemalocater/).
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* @docs-group-description Locaters
|
|
12
|
-
* ISchemaLocater implementations used to locate schemas in a given [SchemaContext](https://www.itwinjs.org/reference/ecschema-metadata/context/schemacontext).
|
|
13
|
-
*/
|
|
14
|
-
/**
|
|
15
|
-
* @docs-group-description Utils
|
|
16
|
-
* A set of utility classes used throughout the package.
|
|
17
|
-
*/
|
|
1
|
+
export * from "./SchemaFileLocater";
|
|
2
|
+
export * from "./SchemaJsonFileLocater";
|
|
3
|
+
export * from "./SchemaXmlFileLocater";
|
|
4
|
+
export * from "./StubSchemaXmlFileLocater";
|
|
5
|
+
/** @docs-package-description
|
|
6
|
+
* The ecschema-locaters package contains classes for locating ECSchemas within a given
|
|
7
|
+
* [SchemaContext](https://www.itwinjs.org/reference/ecschema-metadata/context/schemacontext). Each locater
|
|
8
|
+
* implements the [ISchemaLocater interface](https://www.itwinjs.org/reference/ecschema-metadata/context/ischemalocater/).
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* @docs-group-description Locaters
|
|
12
|
+
* ISchemaLocater implementations used to locate schemas in a given [SchemaContext](https://www.itwinjs.org/reference/ecschema-metadata/context/schemacontext).
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* @docs-group-description Utils
|
|
16
|
+
* A set of utility classes used throughout the package.
|
|
17
|
+
*/
|
|
18
18
|
//# sourceMappingURL=ecschema-locaters.d.ts.map
|
|
@@ -1,34 +1,38 @@
|
|
|
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
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
-
if (k2 === undefined) k2 = k;
|
|
8
|
-
Object.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
__exportStar(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*/
|
|
30
|
-
/**
|
|
31
|
-
* @docs-group-description
|
|
32
|
-
*
|
|
33
|
-
*/
|
|
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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
18
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
__exportStar(require("./SchemaFileLocater"), exports);
|
|
22
|
+
__exportStar(require("./SchemaJsonFileLocater"), exports);
|
|
23
|
+
__exportStar(require("./SchemaXmlFileLocater"), exports);
|
|
24
|
+
__exportStar(require("./StubSchemaXmlFileLocater"), exports);
|
|
25
|
+
/** @docs-package-description
|
|
26
|
+
* The ecschema-locaters package contains classes for locating ECSchemas within a given
|
|
27
|
+
* [SchemaContext](https://www.itwinjs.org/reference/ecschema-metadata/context/schemacontext). Each locater
|
|
28
|
+
* implements the [ISchemaLocater interface](https://www.itwinjs.org/reference/ecschema-metadata/context/ischemalocater/).
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* @docs-group-description Locaters
|
|
32
|
+
* ISchemaLocater implementations used to locate schemas in a given [SchemaContext](https://www.itwinjs.org/reference/ecschema-metadata/context/schemacontext).
|
|
33
|
+
*/
|
|
34
|
+
/**
|
|
35
|
+
* @docs-group-description Utils
|
|
36
|
+
* A set of utility classes used throughout the package.
|
|
37
|
+
*/
|
|
34
38
|
//# sourceMappingURL=ecschema-locaters.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ecschema-locaters.js","sourceRoot":"","sources":["../../src/ecschema-locaters.ts"],"names":[],"mappings":";AAAA;;;+FAG+F
|
|
1
|
+
{"version":3,"file":"ecschema-locaters.js","sourceRoot":"","sources":["../../src/ecschema-locaters.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;;;;;AAE/F,sDAAoC;AACpC,0DAAwC;AACxC,yDAAuC;AACvC,6DAA2C;AAE3C;;;;GAIG;AACH;;;GAGG;AACH;;;GAGG","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nexport * from \"./SchemaFileLocater\";\nexport * from \"./SchemaJsonFileLocater\";\nexport * from \"./SchemaXmlFileLocater\";\nexport * from \"./StubSchemaXmlFileLocater\";\n\n/** @docs-package-description\n * The ecschema-locaters package contains classes for locating ECSchemas within a given\n * [SchemaContext](https://www.itwinjs.org/reference/ecschema-metadata/context/schemacontext). Each locater\n * implements the [ISchemaLocater interface](https://www.itwinjs.org/reference/ecschema-metadata/context/ischemalocater/).\n */\n/**\n * @docs-group-description Locaters\n * ISchemaLocater implementations used to locate schemas in a given [SchemaContext](https://www.itwinjs.org/reference/ecschema-metadata/context/schemacontext).\n */\n/**\n * @docs-group-description Utils\n * A set of utility classes used throughout the package.\n */\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=SchemaFileUtility.test.d.ts.map
|