@itwin/ecschema-metadata 5.11.0-dev.3 → 5.11.0-dev.5
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/Localization/LocalizationProvider.d.ts +31 -0
- package/lib/cjs/Localization/LocalizationProvider.d.ts.map +1 -0
- package/lib/cjs/Localization/LocalizationProvider.js +37 -0
- package/lib/cjs/Localization/LocalizationProvider.js.map +1 -0
- package/lib/cjs/Localization/LocalizationTypes.d.ts +41 -0
- package/lib/cjs/Localization/LocalizationTypes.d.ts.map +1 -0
- package/lib/cjs/Localization/LocalizationTypes.js +7 -0
- package/lib/cjs/Localization/LocalizationTypes.js.map +1 -0
- package/lib/cjs/Localization/SchemaLocalization.d.ts +94 -0
- package/lib/cjs/Localization/SchemaLocalization.d.ts.map +1 -0
- package/lib/cjs/Localization/SchemaLocalization.js +197 -0
- package/lib/cjs/Localization/SchemaLocalization.js.map +1 -0
- package/lib/cjs/ecschema-metadata.d.ts +3 -0
- package/lib/cjs/ecschema-metadata.d.ts.map +1 -1
- package/lib/cjs/ecschema-metadata.js +3 -0
- package/lib/cjs/ecschema-metadata.js.map +1 -1
- package/lib/esm/Localization/LocalizationProvider.d.ts +31 -0
- package/lib/esm/Localization/LocalizationProvider.d.ts.map +1 -0
- package/lib/esm/Localization/LocalizationProvider.js +33 -0
- package/lib/esm/Localization/LocalizationProvider.js.map +1 -0
- package/lib/esm/Localization/LocalizationTypes.d.ts +41 -0
- package/lib/esm/Localization/LocalizationTypes.d.ts.map +1 -0
- package/lib/esm/Localization/LocalizationTypes.js +6 -0
- package/lib/esm/Localization/LocalizationTypes.js.map +1 -0
- package/lib/esm/Localization/SchemaLocalization.d.ts +94 -0
- package/lib/esm/Localization/SchemaLocalization.d.ts.map +1 -0
- package/lib/esm/Localization/SchemaLocalization.js +193 -0
- package/lib/esm/Localization/SchemaLocalization.js.map +1 -0
- package/lib/esm/ecschema-metadata.d.ts +3 -0
- package/lib/esm/ecschema-metadata.d.ts.map +1 -1
- package/lib/esm/ecschema-metadata.js +3 -0
- package/lib/esm/ecschema-metadata.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
# Change Log - @itwin/ecschema-metadata
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 03 Jun 2026 20:21:39 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 5.10.0
|
|
6
|
+
Wed, 03 Jun 2026 20:19:46 GMT
|
|
7
|
+
|
|
8
|
+
### Updates
|
|
9
|
+
|
|
10
|
+
- UnitConversion, parseDefinition, and Graph now re-exported from @itwin/core-quantity. UnitConversion.from() signature uses UnitConversionSource interface (structural typing — no consumer changes needed). No public API changes.
|
|
11
|
+
- Use units schema 01.00.10
|
|
12
|
+
- Add a SchemaView layer
|
|
13
|
+
- Document the units schema update for volume-per-length conversion metadata.
|
|
4
14
|
|
|
5
15
|
## 5.9.5
|
|
6
16
|
Mon, 01 Jun 2026 17:34:00 GMT
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SchemaLocalizationJson } from "./LocalizationTypes";
|
|
2
|
+
/**
|
|
3
|
+
* Interface for providing localization JSON files for schemas.
|
|
4
|
+
* @beta
|
|
5
|
+
*/
|
|
6
|
+
export interface ILocalizationProvider {
|
|
7
|
+
/**
|
|
8
|
+
* Load localization JSON for a given schema and locale.
|
|
9
|
+
* @param schemaName The name of the schema
|
|
10
|
+
* @param locale The locale identifier (e.g., "de", "fr", "es-CO")
|
|
11
|
+
* @returns Promise resolving to the localization JSON, or undefined if not found
|
|
12
|
+
*/
|
|
13
|
+
getLocalization(schemaName: string, locale: string): Promise<SchemaLocalizationJson | undefined>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The provider to load the localization JSON files.
|
|
17
|
+
* @beta
|
|
18
|
+
*/
|
|
19
|
+
export declare class LocalizationProvider implements ILocalizationProvider {
|
|
20
|
+
private _loader;
|
|
21
|
+
/**
|
|
22
|
+
* Constructs a LocalizationProvider.
|
|
23
|
+
* @param _loader Function that loads JSON content given a schema name and locale
|
|
24
|
+
*/
|
|
25
|
+
constructor(_loader: (schemaName: string, locale: string) => Promise<SchemaLocalizationJson | undefined>);
|
|
26
|
+
/**
|
|
27
|
+
* Load localization JSON for a given schema and locale.
|
|
28
|
+
*/
|
|
29
|
+
getLocalization(schemaName: string, locale: string): Promise<SchemaLocalizationJson | undefined>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=LocalizationProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalizationProvider.d.ts","sourceRoot":"","sources":["../../../src/Localization/LocalizationProvider.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;;OAKG;IACH,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC,CAAC;CAClG;AAED;;;GAGG;AACH,qBAAa,oBAAqB,YAAW,qBAAqB;IAMpD,OAAO,CAAC,OAAO;IAJ3B;;;OAGG;gBACiB,OAAO,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC;IAGhH;;OAEG;IACU,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC;CAmB9G"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LocalizationProvider = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The provider to load the localization JSON files.
|
|
6
|
+
* @beta
|
|
7
|
+
*/
|
|
8
|
+
class LocalizationProvider {
|
|
9
|
+
_loader;
|
|
10
|
+
/**
|
|
11
|
+
* Constructs a LocalizationProvider.
|
|
12
|
+
* @param _loader Function that loads JSON content given a schema name and locale
|
|
13
|
+
*/
|
|
14
|
+
constructor(_loader) {
|
|
15
|
+
this._loader = _loader;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Load localization JSON for a given schema and locale.
|
|
19
|
+
*/
|
|
20
|
+
async getLocalization(schemaName, locale) {
|
|
21
|
+
const localizationData = await this._loader(schemaName, locale);
|
|
22
|
+
if (localizationData) {
|
|
23
|
+
if (!localizationData.name || !localizationData.locale) {
|
|
24
|
+
throw new Error(`Invalid localization JSON for ${schemaName}:${locale} - missing schema name or locale`);
|
|
25
|
+
}
|
|
26
|
+
if (localizationData.name !== schemaName) {
|
|
27
|
+
throw new Error(`Localization JSON mismatch for ${schemaName}:${locale} - expected schema name "${schemaName}" but got "${localizationData.name}"`);
|
|
28
|
+
}
|
|
29
|
+
if (localizationData.locale !== locale) {
|
|
30
|
+
throw new Error(`Localization JSON mismatch for ${schemaName}:${locale} - expected locale "${locale}" but got "${localizationData.locale}"`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return localizationData;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.LocalizationProvider = LocalizationProvider;
|
|
37
|
+
//# sourceMappingURL=LocalizationProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalizationProvider.js","sourceRoot":"","sources":["../../../src/Localization/LocalizationProvider.ts"],"names":[],"mappings":";;;AAoBA;;;GAGG;AACH,MAAa,oBAAoB;IAMX;IAJpB;;;OAGG;IACH,YAAoB,OAA4F;QAA5F,YAAO,GAAP,OAAO,CAAqF;IAChH,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,eAAe,CAAC,UAAkB,EAAE,MAAc;QAC7D,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAEhE,IAAI,gBAAgB,EAAE,CAAC;YACrB,IAAI,CAAC,gBAAgB,CAAC,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC;gBACvD,MAAM,IAAI,KAAK,CAAC,iCAAiC,UAAU,IAAI,MAAM,kCAAkC,CAAC,CAAC;YAC3G,CAAC;YAED,IAAI,gBAAgB,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;gBACzC,MAAM,IAAI,KAAK,CAAC,kCAAkC,UAAU,IAAI,MAAM,4BAA4B,UAAU,cAAc,gBAAgB,CAAC,IAAI,GAAG,CAAC,CAAC;YACtJ,CAAC;YAED,IAAI,gBAAgB,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;gBACvC,MAAM,IAAI,KAAK,CAAC,kCAAkC,UAAU,IAAI,MAAM,uBAAuB,MAAM,cAAc,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC;YAC/I,CAAC;QACH,CAAC;QAED,OAAO,gBAAgB,CAAC;IAC1B,CAAC;CACF;AA/BD,oDA+BC","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\nimport { SchemaLocalizationJson } from \"./LocalizationTypes\";\r\n\r\n/**\r\n * Interface for providing localization JSON files for schemas.\r\n * @beta\r\n */\r\nexport interface ILocalizationProvider {\r\n /**\r\n * Load localization JSON for a given schema and locale.\r\n * @param schemaName The name of the schema\r\n * @param locale The locale identifier (e.g., \"de\", \"fr\", \"es-CO\")\r\n * @returns Promise resolving to the localization JSON, or undefined if not found\r\n */\r\n getLocalization(schemaName: string, locale: string): Promise<SchemaLocalizationJson | undefined>;\r\n}\r\n\r\n/**\r\n * The provider to load the localization JSON files.\r\n * @beta\r\n */\r\nexport class LocalizationProvider implements ILocalizationProvider {\r\n\r\n /**\r\n * Constructs a LocalizationProvider.\r\n * @param _loader Function that loads JSON content given a schema name and locale\r\n */\r\n constructor(private _loader: (schemaName: string, locale: string) => Promise<SchemaLocalizationJson | undefined>) {\r\n }\r\n\r\n /**\r\n * Load localization JSON for a given schema and locale.\r\n */\r\n public async getLocalization(schemaName: string, locale: string): Promise<SchemaLocalizationJson | undefined> {\r\n const localizationData = await this._loader(schemaName, locale);\r\n\r\n if (localizationData) {\r\n if (!localizationData.name || !localizationData.locale) {\r\n throw new Error(`Invalid localization JSON for ${schemaName}:${locale} - missing schema name or locale`);\r\n }\r\n\r\n if (localizationData.name !== schemaName) {\r\n throw new Error(`Localization JSON mismatch for ${schemaName}:${locale} - expected schema name \"${schemaName}\" but got \"${localizationData.name}\"`);\r\n }\r\n\r\n if (localizationData.locale !== locale) {\r\n throw new Error(`Localization JSON mismatch for ${schemaName}:${locale} - expected locale \"${locale}\" but got \"${localizationData.locale}\"`);\r\n }\r\n }\r\n\r\n return localizationData;\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents localized label and description for a schema element.
|
|
3
|
+
* @beta
|
|
4
|
+
*/
|
|
5
|
+
export interface LocalizedText {
|
|
6
|
+
label?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Localized text for a schema item
|
|
11
|
+
* @beta
|
|
12
|
+
*/
|
|
13
|
+
export interface LocalizedItemText extends LocalizedText {
|
|
14
|
+
/** Localized members keyed by member name */
|
|
15
|
+
members?: {
|
|
16
|
+
[memberName: string]: LocalizedText;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* JSON structure for schema localization file.
|
|
21
|
+
* @beta
|
|
22
|
+
*/
|
|
23
|
+
export interface SchemaLocalizationJson {
|
|
24
|
+
/** Schema version identifier */
|
|
25
|
+
$schema: string;
|
|
26
|
+
/** Name of the schema this localization applies to */
|
|
27
|
+
name: string;
|
|
28
|
+
/** Version of the schema */
|
|
29
|
+
version: string;
|
|
30
|
+
/** Locale identifier (e.g., "de", "fr", "es-CO") */
|
|
31
|
+
locale: string;
|
|
32
|
+
/** Localized schema label */
|
|
33
|
+
label?: string;
|
|
34
|
+
/** Localized schema description */
|
|
35
|
+
description?: string;
|
|
36
|
+
/** Localized schema items, keyed by item name */
|
|
37
|
+
items?: {
|
|
38
|
+
[itemName: string]: LocalizedItemText;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=LocalizationTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalizationTypes.d.ts","sourceRoot":"","sources":["../../../src/Localization/LocalizationTypes.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAkB,SAAQ,aAAa;IACtD,6CAA6C;IAC7C,OAAO,CAAC,EAAE;QAAE,CAAC,UAAU,EAAE,MAAM,GAAG,aAAa,CAAA;KAAE,CAAC;CACnD;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,gCAAgC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iDAAiD;IACjD,KAAK,CAAC,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,CAAA;KAAE,CAAC;CACnD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
//# sourceMappingURL=LocalizationTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalizationTypes.js","sourceRoot":"","sources":["../../../src/Localization/LocalizationTypes.ts"],"names":[],"mappings":";AAAA;;;+FAG+F","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\n/**\r\n * Represents localized label and description for a schema element.\r\n * @beta\r\n */\r\nexport interface LocalizedText {\r\n label?: string;\r\n description?: string;\r\n}\r\n\r\n/**\r\n * Localized text for a schema item\r\n * @beta\r\n */\r\nexport interface LocalizedItemText extends LocalizedText {\r\n /** Localized members keyed by member name */\r\n members?: { [memberName: string]: LocalizedText };\r\n}\r\n\r\n/**\r\n * JSON structure for schema localization file.\r\n * @beta\r\n */\r\nexport interface SchemaLocalizationJson {\r\n /** Schema version identifier */\r\n $schema: string;\r\n /** Name of the schema this localization applies to */\r\n name: string;\r\n /** Version of the schema */\r\n version: string;\r\n /** Locale identifier (e.g., \"de\", \"fr\", \"es-CO\") */\r\n locale: string;\r\n /** Localized schema label */\r\n label?: string;\r\n /** Localized schema description */\r\n description?: string;\r\n /** Localized schema items, keyed by item name */\r\n items?: { [itemName: string]: LocalizedItemText };\r\n}\r\n"]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { SchemaKey } from "../SchemaKey";
|
|
2
|
+
import { SchemaView } from "../SchemaView";
|
|
3
|
+
import { Schema } from "../Metadata/Schema";
|
|
4
|
+
import { ECClass } from "../Metadata/Class";
|
|
5
|
+
import { Property } from "../Metadata/Property";
|
|
6
|
+
import { SchemaItem } from "../Metadata/SchemaItem";
|
|
7
|
+
import { ILocalizationProvider } from "./LocalizationProvider";
|
|
8
|
+
import { AnyEnumerator, Enumeration } from "../Metadata/Enumeration";
|
|
9
|
+
import { LocalizedText } from "./LocalizationTypes";
|
|
10
|
+
type SchemaViewItem = SchemaView.Class | SchemaView.Enumeration | SchemaView.KindOfQuantity | SchemaView.PropertyCategory;
|
|
11
|
+
/**
|
|
12
|
+
* Manages schema localization to provide localized labels and descriptions.
|
|
13
|
+
* @beta
|
|
14
|
+
*/
|
|
15
|
+
export declare class SchemaLocalization {
|
|
16
|
+
private _provider;
|
|
17
|
+
private _locale;
|
|
18
|
+
private _cache;
|
|
19
|
+
private constructor();
|
|
20
|
+
private get _baseLocale();
|
|
21
|
+
private cacheKey;
|
|
22
|
+
/**
|
|
23
|
+
* Create a SchemaLocalization instance and pre-load localization files for the given schemas.
|
|
24
|
+
* @param provider The localization provider to use for loading localization files
|
|
25
|
+
* @param locale The target locale (e.g., "de", "fr", "es-CO")
|
|
26
|
+
* @param schemas The schemas whose localization should be pre-loaded
|
|
27
|
+
*/
|
|
28
|
+
static create(provider: ILocalizationProvider, locale: string, schemaKeys: Iterable<SchemaKey>): Promise<SchemaLocalization>;
|
|
29
|
+
get locale(): string;
|
|
30
|
+
setLocale(locale: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* Get localization provider.
|
|
33
|
+
*/
|
|
34
|
+
get provider(): ILocalizationProvider;
|
|
35
|
+
/**
|
|
36
|
+
* Load localizations for the given schema keys.
|
|
37
|
+
* @param schemaKeys The schema keys to load localization for
|
|
38
|
+
*/
|
|
39
|
+
loadLocalizations(schemaKeys: Iterable<SchemaKey>): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Get a localized label for a schema, schema item, or member.
|
|
42
|
+
*/
|
|
43
|
+
getLabel(schemaName: string, itemName?: string, memberName?: string): string | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Get a localized description for a schema, schema item, or member.
|
|
46
|
+
*/
|
|
47
|
+
getDescription(schemaName: string, itemName?: string, memberName?: string): string | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Get localized label and description of a schema.
|
|
50
|
+
* Label fallback: localized label → base locale label → original label → schema name
|
|
51
|
+
* Description fallback: localized description → base locale description → original description
|
|
52
|
+
*/
|
|
53
|
+
getLocalizedSchema(schema: Schema | SchemaView.Schema): LocalizedText;
|
|
54
|
+
/**
|
|
55
|
+
* Get localized label and description of a schema item (class, enumeration, unit, etc.).
|
|
56
|
+
* Label fallback: localized label → base locale label → original label → item name
|
|
57
|
+
* Description fallback: localized description → base locale description → original description
|
|
58
|
+
*/
|
|
59
|
+
getLocalizedSchemaItem(item: SchemaItem | SchemaViewItem): LocalizedText;
|
|
60
|
+
/**
|
|
61
|
+
* Get localized label and description of a property.
|
|
62
|
+
* Label fallback: localized label → base locale label → original label → property name
|
|
63
|
+
* Description fallback: localized description → base locale description → original description
|
|
64
|
+
*/
|
|
65
|
+
getLocalizedProperty(ecClass: ECClass | SchemaView.Class, property: Property | SchemaView.Property): LocalizedText;
|
|
66
|
+
/**
|
|
67
|
+
* Get localized label and description of an enumerator.
|
|
68
|
+
* Label fallback: localized label → base locale label → original label → enumerator name
|
|
69
|
+
* Description fallback: localized description → base locale description → original description
|
|
70
|
+
*/
|
|
71
|
+
getLocalizedEnumerator(enumeration: Enumeration | SchemaView.Enumeration, enumerator: AnyEnumerator | SchemaView.Enumerator): LocalizedText;
|
|
72
|
+
/**
|
|
73
|
+
* Load localization information for a specific schema and locale.
|
|
74
|
+
*/
|
|
75
|
+
private loadLocalizationInfo;
|
|
76
|
+
/**
|
|
77
|
+
* Get major version from version string
|
|
78
|
+
*/
|
|
79
|
+
private getMajorVersion;
|
|
80
|
+
/**
|
|
81
|
+
* Retrieve the cached localization for a locale
|
|
82
|
+
*/
|
|
83
|
+
private getCachedLocalization;
|
|
84
|
+
/**
|
|
85
|
+
* Resolve a label from a localization object by item and optional member path.
|
|
86
|
+
*/
|
|
87
|
+
private resolveLabel;
|
|
88
|
+
/**
|
|
89
|
+
* Resolve a description from a localization object by item and optional member path.
|
|
90
|
+
*/
|
|
91
|
+
private resolveDescription;
|
|
92
|
+
}
|
|
93
|
+
export {};
|
|
94
|
+
//# sourceMappingURL=SchemaLocalization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaLocalization.d.ts","sourceRoot":"","sources":["../../../src/Localization/SchemaLocalization.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,aAAa,EAA0B,MAAM,qBAAqB,CAAC;AAI5E,KAAK,cAAc,GAAG,UAAU,CAAC,KAAK,GAAG,UAAU,CAAC,WAAW,GAAG,UAAU,CAAC,cAAc,GAAG,UAAU,CAAC,gBAAgB,CAAC;AAE1H;;;GAGG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,SAAS,CAAwB;IACzC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAA8D;IAE5E,OAAO;IAKP,OAAO,KAAK,WAAW,GAEtB;IAED,OAAO,CAAC,QAAQ;IAIhB;;;;;OAKG;WACiB,MAAM,CAAC,QAAQ,EAAE,qBA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,CAAC,kBAAkB;CAU3B"}
|
|
@@ -0,0 +1,197 @@
|
|
|
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.SchemaLocalization = void 0;
|
|
8
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
9
|
+
const loggerCategory = "SchemaLocalization";
|
|
10
|
+
/**
|
|
11
|
+
* Manages schema localization to provide localized labels and descriptions.
|
|
12
|
+
* @beta
|
|
13
|
+
*/
|
|
14
|
+
class SchemaLocalization {
|
|
15
|
+
_provider;
|
|
16
|
+
_locale;
|
|
17
|
+
_cache = new Map();
|
|
18
|
+
constructor(provider, locale) {
|
|
19
|
+
this._provider = provider;
|
|
20
|
+
this._locale = locale;
|
|
21
|
+
}
|
|
22
|
+
get _baseLocale() {
|
|
23
|
+
return this._locale.includes("-") ? this._locale.split("-")[0] : undefined;
|
|
24
|
+
}
|
|
25
|
+
cacheKey(schemaName, locale) {
|
|
26
|
+
return `${schemaName}:${locale}`;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Create a SchemaLocalization instance and pre-load localization files for the given schemas.
|
|
30
|
+
* @param provider The localization provider to use for loading localization files
|
|
31
|
+
* @param locale The target locale (e.g., "de", "fr", "es-CO")
|
|
32
|
+
* @param schemas The schemas whose localization should be pre-loaded
|
|
33
|
+
*/
|
|
34
|
+
static async create(provider, locale, schemaKeys) {
|
|
35
|
+
const localization = new SchemaLocalization(provider, locale);
|
|
36
|
+
await localization.loadLocalizations(schemaKeys);
|
|
37
|
+
return localization;
|
|
38
|
+
}
|
|
39
|
+
get locale() {
|
|
40
|
+
return this._locale;
|
|
41
|
+
}
|
|
42
|
+
setLocale(locale) {
|
|
43
|
+
this._locale = locale;
|
|
44
|
+
this._cache.clear();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get localization provider.
|
|
48
|
+
*/
|
|
49
|
+
get provider() {
|
|
50
|
+
return this._provider;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Load localizations for the given schema keys.
|
|
54
|
+
* @param schemaKeys The schema keys to load localization for
|
|
55
|
+
*/
|
|
56
|
+
async loadLocalizations(schemaKeys) {
|
|
57
|
+
const promises = [];
|
|
58
|
+
for (const key of schemaKeys) {
|
|
59
|
+
promises.push(this.loadLocalizationInfo(key.name, key.readVersion, this._locale));
|
|
60
|
+
if (this._baseLocale !== undefined)
|
|
61
|
+
promises.push(this.loadLocalizationInfo(key.name, key.readVersion, this._baseLocale));
|
|
62
|
+
}
|
|
63
|
+
await Promise.all(promises);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get a localized label for a schema, schema item, or member.
|
|
67
|
+
*/
|
|
68
|
+
getLabel(schemaName, itemName, memberName) {
|
|
69
|
+
const localization = this.getCachedLocalization(schemaName, this._locale);
|
|
70
|
+
const label = this.resolveLabel(localization, itemName, memberName);
|
|
71
|
+
if (label)
|
|
72
|
+
return label;
|
|
73
|
+
if (this._baseLocale) {
|
|
74
|
+
const baseLocalization = this.getCachedLocalization(schemaName, this._baseLocale);
|
|
75
|
+
return this.resolveLabel(baseLocalization, itemName, memberName);
|
|
76
|
+
}
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get a localized description for a schema, schema item, or member.
|
|
81
|
+
*/
|
|
82
|
+
getDescription(schemaName, itemName, memberName) {
|
|
83
|
+
const localization = this.getCachedLocalization(schemaName, this._locale);
|
|
84
|
+
const description = this.resolveDescription(localization, itemName, memberName);
|
|
85
|
+
if (description)
|
|
86
|
+
return description;
|
|
87
|
+
if (this._baseLocale) {
|
|
88
|
+
const baseLocalization = this.getCachedLocalization(schemaName, this._baseLocale);
|
|
89
|
+
return this.resolveDescription(baseLocalization, itemName, memberName);
|
|
90
|
+
}
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Get localized label and description of a schema.
|
|
95
|
+
* Label fallback: localized label → base locale label → original label → schema name
|
|
96
|
+
* Description fallback: localized description → base locale description → original description
|
|
97
|
+
*/
|
|
98
|
+
getLocalizedSchema(schema) {
|
|
99
|
+
const label = this.getLabel(schema.name) ?? (schema.label || schema.name);
|
|
100
|
+
const description = this.getDescription(schema.name) ?? schema.description;
|
|
101
|
+
return { label, description };
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Get localized label and description of a schema item (class, enumeration, unit, etc.).
|
|
105
|
+
* Label fallback: localized label → base locale label → original label → item name
|
|
106
|
+
* Description fallback: localized description → base locale description → original description
|
|
107
|
+
*/
|
|
108
|
+
getLocalizedSchemaItem(item) {
|
|
109
|
+
const label = this.getLabel(item.schema.name, item.name) ?? (item.label || item.name);
|
|
110
|
+
const description = this.getDescription(item.schema.name, item.name) ?? item.description;
|
|
111
|
+
return { label, description };
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Get localized label and description of a property.
|
|
115
|
+
* Label fallback: localized label → base locale label → original label → property name
|
|
116
|
+
* Description fallback: localized description → base locale description → original description
|
|
117
|
+
*/
|
|
118
|
+
getLocalizedProperty(ecClass, property) {
|
|
119
|
+
const label = this.getLabel(ecClass.schema.name, ecClass.name, property.name) ?? (property.label || property.name);
|
|
120
|
+
const description = this.getDescription(ecClass.schema.name, ecClass.name, property.name) ?? property.description;
|
|
121
|
+
return { label, description };
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Get localized label and description of an enumerator.
|
|
125
|
+
* Label fallback: localized label → base locale label → original label → enumerator name
|
|
126
|
+
* Description fallback: localized description → base locale description → original description
|
|
127
|
+
*/
|
|
128
|
+
getLocalizedEnumerator(enumeration, enumerator) {
|
|
129
|
+
const label = this.getLabel(enumeration.schema.name, enumeration.name, enumerator.name) ?? (enumerator.label || enumerator.name);
|
|
130
|
+
const description = this.getDescription(enumeration.schema.name, enumeration.name, enumerator.name) ?? enumerator.description;
|
|
131
|
+
return { label, description };
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Load localization information for a specific schema and locale.
|
|
135
|
+
*/
|
|
136
|
+
async loadLocalizationInfo(schemaName, readVersion, locale) {
|
|
137
|
+
const cacheKey = this.cacheKey(schemaName, locale);
|
|
138
|
+
if (this._cache.has(cacheKey))
|
|
139
|
+
return;
|
|
140
|
+
const localization = await this._provider.getLocalization(schemaName, locale);
|
|
141
|
+
if (localization?.version) {
|
|
142
|
+
const localizationMajor = this.getMajorVersion(localization.version);
|
|
143
|
+
if (localizationMajor === undefined || readVersion !== localizationMajor) {
|
|
144
|
+
core_bentley_1.Logger.logWarning(loggerCategory, `Localization version mismatch for schema "${schemaName}". Schema major version is ${readVersion.toString()}, but localization is for major version ${localizationMajor?.toString() ?? "undefined"}.`);
|
|
145
|
+
this._cache.set(cacheKey, undefined);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
this._cache.set(cacheKey, localization);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Get major version from version string
|
|
153
|
+
*/
|
|
154
|
+
getMajorVersion(version) {
|
|
155
|
+
const rawVersion = version.split(".");
|
|
156
|
+
if (rawVersion.length > 0) {
|
|
157
|
+
const majorVersion = parseInt(rawVersion[0], 10);
|
|
158
|
+
return isNaN(majorVersion) ? undefined : majorVersion;
|
|
159
|
+
}
|
|
160
|
+
return undefined;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Retrieve the cached localization for a locale
|
|
164
|
+
*/
|
|
165
|
+
getCachedLocalization(schemaName, locale) {
|
|
166
|
+
const cacheKey = this.cacheKey(schemaName, locale);
|
|
167
|
+
return this._cache.get(cacheKey);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Resolve a label from a localization object by item and optional member path.
|
|
171
|
+
*/
|
|
172
|
+
resolveLabel(localization, itemName, memberName) {
|
|
173
|
+
if (!localization)
|
|
174
|
+
return undefined;
|
|
175
|
+
if (!itemName)
|
|
176
|
+
return localization.label;
|
|
177
|
+
const item = localization.items?.[itemName];
|
|
178
|
+
if (!memberName)
|
|
179
|
+
return item?.label;
|
|
180
|
+
return item?.members?.[memberName]?.label;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Resolve a description from a localization object by item and optional member path.
|
|
184
|
+
*/
|
|
185
|
+
resolveDescription(localization, itemName, memberName) {
|
|
186
|
+
if (!localization)
|
|
187
|
+
return undefined;
|
|
188
|
+
if (!itemName)
|
|
189
|
+
return localization.description;
|
|
190
|
+
const item = localization.items?.[itemName];
|
|
191
|
+
if (!memberName)
|
|
192
|
+
return item?.description;
|
|
193
|
+
return item?.members?.[memberName]?.description;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
exports.SchemaLocalization = SchemaLocalization;
|
|
197
|
+
//# sourceMappingURL=SchemaLocalization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaLocalization.js","sourceRoot":"","sources":["../../../src/Localization/SchemaLocalization.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAM/F,sDAA6C;AAO7C,MAAM,cAAc,GAAG,oBAAoB,CAAC;AAI5C;;;GAGG;AACH,MAAa,kBAAkB;IACrB,SAAS,CAAwB;IACjC,OAAO,CAAS;IAChB,MAAM,GAAoD,IAAI,GAAG,EAAE,CAAC;IAE5E,YAAoB,QAA+B,EAAE,MAAc;QACjE,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,IAAY,WAAW;QACrB,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,C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AAY,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,CAAC;QAC5C,IAAI,CAAC,UAAU;YACb,OAAO,IAAI,EAAE,WAAW,CAAC;QAC3B,OAAO,IAAI,EAAE,OAAO,EAAE,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC;IAClD,CAAC;CACF;AA9MD,gDA8MC","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 { SchemaKey } from \"../SchemaKey\";\r\nimport { SchemaView } from \"../SchemaView\";\r\nimport { Schema } from \"../Metadata/Schema\";\r\nimport { ECClass } from \"../Metadata/Class\";\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport { Property } from \"../Metadata/Property\";\r\nimport { SchemaItem } from \"../Metadata/SchemaItem\";\r\nimport { ILocalizationProvider } from \"./LocalizationProvider\";\r\nimport { AnyEnumerator, Enumeration } from \"../Metadata/Enumeration\";\r\nimport { LocalizedText, SchemaLocalizationJson } from \"./LocalizationTypes\";\r\n\r\nconst loggerCategory = \"SchemaLocalization\";\r\n\r\ntype SchemaViewItem = SchemaView.Class | SchemaView.Enumeration | SchemaView.KindOfQuantity | SchemaView.PropertyCategory;\r\n\r\n/**\r\n * Manages schema localization to provide localized labels and descriptions.\r\n * @beta\r\n */\r\nexport class SchemaLocalization {\r\n private _provider: ILocalizationProvider;\r\n private _locale: string;\r\n private _cache: Map<string, SchemaLocalizationJson | undefined> = new Map();\r\n\r\n private constructor(provider: ILocalizationProvider, locale: string) {\r\n this._provider = provider;\r\n this._locale = locale;\r\n }\r\n\r\n private get _baseLocale(): string | undefined {\r\n return this._locale.includes(\"-\") ? this._locale.split(\"-\")[0] : undefined;\r\n }\r\n\r\n private cacheKey(schemaName: string, locale: string): string {\r\n return `${schemaName}:${locale}`;\r\n }\r\n\r\n /**\r\n * Create a SchemaLocalization instance and pre-load localization files for the given schemas.\r\n * @param provider The localization provider to use for loading localization files\r\n * @param locale The target locale (e.g., \"de\", \"fr\", \"es-CO\")\r\n * @param schemas The schemas whose localization should be pre-loaded\r\n */\r\n public static async create(provider: ILocalizationProvider, locale: string, schemaKeys: Iterable<SchemaKey>): Promise<SchemaLocalization> {\r\n const localization = new SchemaLocalization(provider, locale);\r\n await localization.loadLocalizations(schemaKeys);\r\n return localization;\r\n }\r\n\r\n public get locale(): string {\r\n return this._locale;\r\n }\r\n\r\n public setLocale(locale: string): void {\r\n this._locale = locale;\r\n this._cache.clear();\r\n }\r\n\r\n /**\r\n * Get localization provider.\r\n */\r\n public get provider(): ILocalizationProvider {\r\n return this._provider;\r\n }\r\n\r\n /**\r\n * Load localizations for the given schema keys.\r\n * @param schemaKeys The schema keys to load localization for\r\n */\r\n public async loadLocalizations(schemaKeys: Iterable<SchemaKey>): Promise<void> {\r\n const promises: Promise<void>[] = [];\r\n for (const key of schemaKeys) {\r\n promises.push(this.loadLocalizationInfo(key.name, key.readVersion, this._locale));\r\n if (this._baseLocale !== undefined)\r\n promises.push(this.loadLocalizationInfo(key.name, key.readVersion, this._baseLocale));\r\n }\r\n await Promise.all(promises);\r\n }\r\n\r\n /**\r\n * Get a localized label for a schema, schema item, or member.\r\n */\r\n public getLabel(schemaName: string, itemName?: string, memberName?: string): string | undefined {\r\n const localization = this.getCachedLocalization(schemaName, this._locale);\r\n const label = this.resolveLabel(localization, itemName, memberName);\r\n if (label)\r\n return label;\r\n\r\n if (this._baseLocale) {\r\n const baseLocalization = this.getCachedLocalization(schemaName, this._baseLocale);\r\n return this.resolveLabel(baseLocalization, itemName, memberName);\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Get a localized description for a schema, schema item, or member.\r\n */\r\n public getDescription(schemaName: string, itemName?: string, memberName?: string): string | undefined {\r\n const localization = this.getCachedLocalization(schemaName, this._locale);\r\n const description = this.resolveDescription(localization, itemName, memberName);\r\n if (description)\r\n return description;\r\n\r\n if (this._baseLocale) {\r\n const baseLocalization = this.getCachedLocalization(schemaName, this._baseLocale);\r\n return this.resolveDescription(baseLocalization, itemName, memberName);\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Get localized label and description of a schema.\r\n * Label fallback: localized label → base locale label → original label → schema name\r\n * Description fallback: localized description → base locale description → original description\r\n */\r\n public getLocalizedSchema(schema: Schema | SchemaView.Schema): LocalizedText {\r\n const label = this.getLabel(schema.name) ?? (schema.label || schema.name);\r\n const description = this.getDescription(schema.name) ?? schema.description;\r\n return { label, description };\r\n }\r\n\r\n /**\r\n * Get localized label and description of a schema item (class, enumeration, unit, etc.).\r\n * Label fallback: localized label → base locale label → original label → item name\r\n * Description fallback: localized description → base locale description → original description\r\n */\r\n public getLocalizedSchemaItem(item: SchemaItem | SchemaViewItem): LocalizedText {\r\n const label = this.getLabel(item.schema.name, item.name) ?? (item.label || item.name);\r\n const description = this.getDescription(item.schema.name, item.name) ?? item.description;\r\n return { label, description };\r\n }\r\n\r\n /**\r\n * Get localized label and description of a property.\r\n * Label fallback: localized label → base locale label → original label → property name\r\n * Description fallback: localized description → base locale description → original description\r\n */\r\n public getLocalizedProperty(ecClass: ECClass | SchemaView.Class, property: Property | SchemaView.Property): LocalizedText {\r\n const label = this.getLabel(ecClass.schema.name, ecClass.name, property.name) ?? (property.label || property.name);\r\n const description = this.getDescription(ecClass.schema.name, ecClass.name, property.name) ?? property.description;\r\n return { label, description };\r\n }\r\n\r\n /**\r\n * Get localized label and description of an enumerator.\r\n * Label fallback: localized label → base locale label → original label → enumerator name\r\n * Description fallback: localized description → base locale description → original description\r\n */\r\n public getLocalizedEnumerator(enumeration: Enumeration | SchemaView.Enumeration, enumerator: AnyEnumerator | SchemaView.Enumerator): LocalizedText {\r\n const label = this.getLabel(enumeration.schema.name, enumeration.name, enumerator.name) ?? (enumerator.label || enumerator.name);\r\n const description = this.getDescription(enumeration.schema.name, enumeration.name, enumerator.name) ?? enumerator.description;\r\n return { label, description };\r\n }\r\n\r\n /**\r\n * Load localization information for a specific schema and locale.\r\n */\r\n private async loadLocalizationInfo(schemaName: string, readVersion: number, locale: string): Promise<void> {\r\n const cacheKey = this.cacheKey(schemaName, locale);\r\n if (this._cache.has(cacheKey))\r\n return;\r\n\r\n const localization = await this._provider.getLocalization(schemaName, locale);\r\n if (localization?.version) {\r\n const localizationMajor = this.getMajorVersion(localization.version);\r\n if (localizationMajor === undefined || readVersion !== localizationMajor) {\r\n Logger.logWarning(loggerCategory, `Localization version mismatch for schema \"${schemaName}\". Schema major version is ${readVersion.toString()}, but localization is for major version ${localizationMajor?.toString() ?? \"undefined\"}.`);\r\n this._cache.set(cacheKey, undefined);\r\n return;\r\n }\r\n }\r\n\r\n this._cache.set(cacheKey, localization);\r\n }\r\n\r\n /**\r\n * Get major version from version string\r\n */\r\n private getMajorVersion(version: string): number | undefined {\r\n const rawVersion = version.split(\".\");\r\n if (rawVersion.length > 0) {\r\n const majorVersion = parseInt(rawVersion[0], 10);\r\n return isNaN(majorVersion) ? undefined : majorVersion;\r\n }\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Retrieve the cached localization for a locale\r\n */\r\n private getCachedLocalization(schemaName: string, locale: string): SchemaLocalizationJson | undefined {\r\n const cacheKey = this.cacheKey(schemaName, locale);\r\n return this._cache.get(cacheKey);\r\n }\r\n\r\n /**\r\n * Resolve a label from a localization object by item and optional member path.\r\n */\r\n private resolveLabel(localization: SchemaLocalizationJson | undefined, itemName?: string, memberName?: string): string | undefined {\r\n if (!localization)\r\n return undefined;\r\n if (!itemName)\r\n return localization.label;\r\n const item = localization.items?.[itemName];\r\n if (!memberName)\r\n return item?.label;\r\n return item?.members?.[memberName]?.label;\r\n }\r\n\r\n /**\r\n * Resolve a description from a localization object by item and optional member path.\r\n */\r\n private resolveDescription(localization: SchemaLocalizationJson | undefined, itemName?: string, memberName?: string): string | undefined {\r\n if (!localization)\r\n return undefined;\r\n if (!itemName)\r\n return localization.description;\r\n const item = localization.items?.[itemName];\r\n if (!memberName)\r\n return item?.description;\r\n return item?.members?.[memberName]?.description;\r\n }\r\n}\r\n"]}
|
|
@@ -44,6 +44,9 @@ export { SchemaGraph } from "./utils/SchemaGraph";
|
|
|
44
44
|
export * from "./SchemaViewBinaryReader";
|
|
45
45
|
export * from "./SchemaView";
|
|
46
46
|
export * from "./SchemaViewInterfaces";
|
|
47
|
+
export * from "./Localization/LocalizationTypes";
|
|
48
|
+
export * from "./Localization/LocalizationProvider";
|
|
49
|
+
export * from "./Localization/SchemaLocalization";
|
|
47
50
|
/** @docs-package-description
|
|
48
51
|
* The ecschema-metadata package contains classes for working with ECSchemas that can be used in both [frontend]($docs/learning/frontend/index.md) and [backend]($docs/learning/backend/index.md).
|
|
49
52
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ecschema-metadata.d.ts","sourceRoot":"","sources":["../../src/ecschema-metadata.ts"],"names":[],"mappings":"AAKA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,YAA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ACjG,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACnH,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mCAAmC,CAAC;AAClD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oCAAoC,CAAC;AACnD,cAAc,uCAAuC,CAAC;AACtD,cAAc,yCAAyC,CAAC;AACxD,cAAc,+CAA+C,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAC5F,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,cAAc,0BAA0B,CAAC;AACzC,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AACjD,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAElD;;GAEG;AACH;;;GAGG;AACH;;;GAGG"}
|
|
@@ -93,6 +93,9 @@ Object.defineProperty(exports, "SchemaGraph", { enumerable: true, get: function
|
|
|
93
93
|
__exportStar(require("./SchemaViewBinaryReader"), exports);
|
|
94
94
|
__exportStar(require("./SchemaView"), exports);
|
|
95
95
|
__exportStar(require("./SchemaViewInterfaces"), exports);
|
|
96
|
+
__exportStar(require("./Localization/LocalizationTypes"), exports);
|
|
97
|
+
__exportStar(require("./Localization/LocalizationProvider"), exports);
|
|
98
|
+
__exportStar(require("./Localization/SchemaLocalization"), exports);
|
|
96
99
|
/** @docs-package-description
|
|
97
100
|
* The ecschema-metadata package contains classes for working with ECSchemas that can be used in both [frontend]($docs/learning/frontend/index.md) and [backend]($docs/learning/backend/index.md).
|
|
98
101
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ecschema-metadata.js","sourceRoot":"","sources":["../../src/ecschema-metadata.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;;;;;;;;;;;;;;AAE/F,8CAA4B;AAC5B,4CAA0B;AAC1B,mDAAiC;AACjC,oEAAkD;AAClD,8DAA4C;AAC5C,2DAAyC;AACzC,8DAA4C;AAC5C,2CAAyB;AACzB,8CAA4B;AAC5B,8CAA4B;AAC5B,+CAA6B;AAC7B,0CAAwD;AAA/C,gGAAA,OAAO,OAAA;AAAE,oGAAA,WAAW,OAAA;AAC7B,gDAA+C;AAAtC,oGAAA,QAAQ,OAAA;AACjB,wEAAuE;AAA9D,4HAAA,oBAAoB,OAAA;AAC7B,sDAAqD;AAA5C,0GAAA,WAAW,OAAA;AACpB,sDAAgF;AAAxD,0GAAA,WAAW,OAAA;AACnC,4CAA2C;AAAlC,gGAAA,MAAM,OAAA;AACf,wDAAuD;AAA9C,4GAAA,YAAY,OAAA;AACrB,4DAA2D;AAAlD,gHAAA,cAAc,OAAA;AACvB,0CAAyC;AAAhC,8FAAA,KAAK,OAAA;AACd,4DAA0C;AAC1C,oDAAmD;AAA1C,wGAAA,UAAU,OAAA;AACnB,gDAI6B;AAH3B,oGAAA,QAAQ,OAAA;AAAE,6GAAA,iBAAiB,OAAA;AAAE,kHAAA,sBAAsB,OAAA;AAAE,+GAAA,mBAAmB,OAAA;AAAE,0GAAA,cAAc,OAAA;AACxF,+GAAA,mBAAmB,OAAA;AAAE,oHAAA,wBAAwB,OAAA;AAAE,8GAAA,kBAAkB,OAAA;AACX,yGAAA,aAAa,OAAA;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yC;AAAhC,8FAAA,KAAK,OAAA;AACd,4DAA0C;AAC1C,oDAAmD;AAA1C,wGAAA,UAAU,OAAA;AACnB,gDAI6B;AAH3B,oGAAA,QAAQ,OAAA;AAAE,6GAAA,iBAAiB,OAAA;AAAE,kHAAA,sBAAsB,OAAA;AAAE,+GAAA,mBAAmB,OAAA;AAAE,0GAAA,cAAc,OAAA;AACxF,+GAAA,mBAAmB,OAAA;AAAE,oHAAA,wBAAwB,OAAA;AAAE,8GAAA,kBAAkB,OAAA;AACX,yGAAA,aAAa,OAAA;AAAE,uHAAA,2BAA2B,OAAA;AAElG,gEAA+D;AAAtD,oHAAA,gBAAgB,OAAA;AACzB,kEAAmH;AAA1G,sHAAA,iBAAiB,OAAA;AAAE,2HAAA,sBAAsB,OAAA;AAAE,6HAAA,wBAAwB,OAAA;AAC5E,4CAA2C;AAAlC,gGAAA,MAAM,OAAA;AACf,wDAAsC;AACtC,wCAAuC;AAA9B,4FAAA,IAAI,OAAA;AACb,oDAAmD;AAA1C,wGAAA,UAAU,OAAA;AACnB,kDAAgC;AAChC,sDAAoC;AACpC,8CAA4B;AAC5B,iDAA+B;AAC/B,iEAA+C;AAC/C,oEAAkD;AAClD,4DAA0C;AAC1C,8DAA4C;AAC5C,qEAAmD;AACnD,wEAAsD;AACtD,0EAAwD;AACxD,gFAA8D;AAE9D,mDAAkD;AAAzC,0GAAA,WAAW,OAAA;AACpB,2DAAyC;AACzC,+CAA6B;AAC7B,yDAAuC;AACvC,mEAAiD;AACjD,sEAAoD;AACpD,oEAAkD;AAElD;;GAEG;AACH;;;GAGG;AACH;;;GAGG","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\nexport * from \"./Constants\";\r\nexport * from \"./Context\";\r\nexport * from \"./DelayedPromise\";\r\nexport * from \"./Deserialization/SchemaGraphUtil\";\r\nexport * from \"./Deserialization/JsonProps\";\r\nexport * from \"./Deserialization/Helper\";\r\nexport * from \"./Deserialization/XmlParser\";\r\nexport * from \"./ECName\";\r\nexport * from \"./ECObjects\";\r\nexport * from \"./Exception\";\r\nexport * from \"./Interfaces\";\r\nexport { ECClass, StructClass } from \"./Metadata/Class\";\r\nexport { Constant } from \"./Metadata/Constant\";\r\nexport { CustomAttributeClass } from \"./Metadata/CustomAttributeClass\";\r\nexport { EntityClass } from \"./Metadata/EntityClass\";\r\nexport { AnyEnumerator, Enumeration, Enumerator } from \"./Metadata/Enumeration\";\r\nexport { Format } from \"./Metadata/Format\";\r\nexport { InvertedUnit } from \"./Metadata/InvertedUnit\";\r\nexport { KindOfQuantity } from \"./Metadata/KindOfQuantity\";\r\nexport { Mixin } from \"./Metadata/Mixin\";\r\nexport * from \"./Metadata/OverrideFormat\";\r\nexport { Phenomenon } from \"./Metadata/Phenomenon\";\r\nexport {\r\n Property, PrimitiveProperty, PrimitiveArrayProperty, EnumerationProperty, StructProperty,\r\n StructArrayProperty, EnumerationArrayProperty, NavigationProperty, AnyArrayProperty, AnyEnumerationProperty,\r\n AnyPrimitiveProperty, AnyProperty, AnyStructProperty, ArrayProperty, PrimitiveOrEnumPropertyBase,\r\n} from \"./Metadata/Property\";\r\nexport { PropertyCategory } from \"./Metadata/PropertyCategory\";\r\nexport { RelationshipClass, RelationshipConstraint, RelationshipMultiplicity } from \"./Metadata/RelationshipClass\";\r\nexport { Schema } from \"./Metadata/Schema\";\r\nexport * from \"./Metadata/SchemaItem\";\r\nexport { Unit } from \"./Metadata/Unit\";\r\nexport { UnitSystem } from \"./Metadata/UnitSystem\";\r\nexport * from \"./PropertyTypes\";\r\nexport * from \"./SchemaJsonLocater\";\r\nexport * from \"./SchemaKey\";\r\nexport * from \"./SchemaLoader\";\r\nexport * from \"./UnitConversion/UnitConverter\";\r\nexport * from \"./UnitProvider/SchemaUnitProvider\";\r\nexport * from \"./Validation/SchemaWalker\";\r\nexport * from \"./SchemaPartVisitorDelegate\";\r\nexport * from \"./Formatting/SchemaFormatsProvider\";\r\nexport * from \"./Formatting/FormatSetFormatsProvider\";\r\nexport * from \"./IncrementalLoading/ECSqlSchemaLocater\";\r\nexport * from \"./IncrementalLoading/IncrementalSchemaLocater\";\r\nexport { CustomAttribute, CustomAttributeContainerProps } from \"./Metadata/CustomAttribute\";\r\nexport { SchemaGraph } from \"./utils/SchemaGraph\";\r\nexport * from \"./SchemaViewBinaryReader\";\r\nexport * from \"./SchemaView\";\r\nexport * from \"./SchemaViewInterfaces\";\r\nexport * from \"./Localization/LocalizationTypes\";\r\nexport * from \"./Localization/LocalizationProvider\";\r\nexport * from \"./Localization/SchemaLocalization\";\r\n\r\n/** @docs-package-description\r\n * The ecschema-metadata package contains classes for working with ECSchemas that can be used in both [frontend]($docs/learning/frontend/index.md) and [backend]($docs/learning/backend/index.md).\r\n */\r\n/**\r\n * @docs-group-description Metadata\r\n * Definitions of classes and interfaces that represent all [EC elements]($docs/bis/ec/index.md).\r\n */\r\n/**\r\n * @docs-group-description Utils\r\n * A set of utility classes used throughout the package.\r\n */\r\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SchemaLocalizationJson } from "./LocalizationTypes";
|
|
2
|
+
/**
|
|
3
|
+
* Interface for providing localization JSON files for schemas.
|
|
4
|
+
* @beta
|
|
5
|
+
*/
|
|
6
|
+
export interface ILocalizationProvider {
|
|
7
|
+
/**
|
|
8
|
+
* Load localization JSON for a given schema and locale.
|
|
9
|
+
* @param schemaName The name of the schema
|
|
10
|
+
* @param locale The locale identifier (e.g., "de", "fr", "es-CO")
|
|
11
|
+
* @returns Promise resolving to the localization JSON, or undefined if not found
|
|
12
|
+
*/
|
|
13
|
+
getLocalization(schemaName: string, locale: string): Promise<SchemaLocalizationJson | undefined>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The provider to load the localization JSON files.
|
|
17
|
+
* @beta
|
|
18
|
+
*/
|
|
19
|
+
export declare class LocalizationProvider implements ILocalizationProvider {
|
|
20
|
+
private _loader;
|
|
21
|
+
/**
|
|
22
|
+
* Constructs a LocalizationProvider.
|
|
23
|
+
* @param _loader Function that loads JSON content given a schema name and locale
|
|
24
|
+
*/
|
|
25
|
+
constructor(_loader: (schemaName: string, locale: string) => Promise<SchemaLocalizationJson | undefined>);
|
|
26
|
+
/**
|
|
27
|
+
* Load localization JSON for a given schema and locale.
|
|
28
|
+
*/
|
|
29
|
+
getLocalization(schemaName: string, locale: string): Promise<SchemaLocalizationJson | undefined>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=LocalizationProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalizationProvider.d.ts","sourceRoot":"","sources":["../../../src/Localization/LocalizationProvider.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;;OAKG;IACH,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC,CAAC;CAClG;AAED;;;GAGG;AACH,qBAAa,oBAAqB,YAAW,qBAAqB;IAMpD,OAAO,CAAC,OAAO;IAJ3B;;;OAGG;gBACiB,OAAO,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC;IAGhH;;OAEG;IACU,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC;CAmB9G"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The provider to load the localization JSON files.
|
|
3
|
+
* @beta
|
|
4
|
+
*/
|
|
5
|
+
export class LocalizationProvider {
|
|
6
|
+
_loader;
|
|
7
|
+
/**
|
|
8
|
+
* Constructs a LocalizationProvider.
|
|
9
|
+
* @param _loader Function that loads JSON content given a schema name and locale
|
|
10
|
+
*/
|
|
11
|
+
constructor(_loader) {
|
|
12
|
+
this._loader = _loader;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Load localization JSON for a given schema and locale.
|
|
16
|
+
*/
|
|
17
|
+
async getLocalization(schemaName, locale) {
|
|
18
|
+
const localizationData = await this._loader(schemaName, locale);
|
|
19
|
+
if (localizationData) {
|
|
20
|
+
if (!localizationData.name || !localizationData.locale) {
|
|
21
|
+
throw new Error(`Invalid localization JSON for ${schemaName}:${locale} - missing schema name or locale`);
|
|
22
|
+
}
|
|
23
|
+
if (localizationData.name !== schemaName) {
|
|
24
|
+
throw new Error(`Localization JSON mismatch for ${schemaName}:${locale} - expected schema name "${schemaName}" but got "${localizationData.name}"`);
|
|
25
|
+
}
|
|
26
|
+
if (localizationData.locale !== locale) {
|
|
27
|
+
throw new Error(`Localization JSON mismatch for ${schemaName}:${locale} - expected locale "${locale}" but got "${localizationData.locale}"`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return localizationData;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=LocalizationProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalizationProvider.js","sourceRoot":"","sources":["../../../src/Localization/LocalizationProvider.ts"],"names":[],"mappings":"AAoBA;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IAMX;IAJpB;;;OAGG;IACH,YAAoB,OAA4F;QAA5F,YAAO,GAAP,OAAO,CAAqF;IAChH,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,eAAe,CAAC,UAAkB,EAAE,MAAc;QAC7D,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAEhE,IAAI,gBAAgB,EAAE,CAAC;YACrB,IAAI,CAAC,gBAAgB,CAAC,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC;gBACvD,MAAM,IAAI,KAAK,CAAC,iCAAiC,UAAU,IAAI,MAAM,kCAAkC,CAAC,CAAC;YAC3G,CAAC;YAED,IAAI,gBAAgB,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;gBACzC,MAAM,IAAI,KAAK,CAAC,kCAAkC,UAAU,IAAI,MAAM,4BAA4B,UAAU,cAAc,gBAAgB,CAAC,IAAI,GAAG,CAAC,CAAC;YACtJ,CAAC;YAED,IAAI,gBAAgB,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;gBACvC,MAAM,IAAI,KAAK,CAAC,kCAAkC,UAAU,IAAI,MAAM,uBAAuB,MAAM,cAAc,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC;YAC/I,CAAC;QACH,CAAC;QAED,OAAO,gBAAgB,CAAC;IAC1B,CAAC;CACF","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\nimport { SchemaLocalizationJson } from \"./LocalizationTypes\";\r\n\r\n/**\r\n * Interface for providing localization JSON files for schemas.\r\n * @beta\r\n */\r\nexport interface ILocalizationProvider {\r\n /**\r\n * Load localization JSON for a given schema and locale.\r\n * @param schemaName The name of the schema\r\n * @param locale The locale identifier (e.g., \"de\", \"fr\", \"es-CO\")\r\n * @returns Promise resolving to the localization JSON, or undefined if not found\r\n */\r\n getLocalization(schemaName: string, locale: string): Promise<SchemaLocalizationJson | undefined>;\r\n}\r\n\r\n/**\r\n * The provider to load the localization JSON files.\r\n * @beta\r\n */\r\nexport class LocalizationProvider implements ILocalizationProvider {\r\n\r\n /**\r\n * Constructs a LocalizationProvider.\r\n * @param _loader Function that loads JSON content given a schema name and locale\r\n */\r\n constructor(private _loader: (schemaName: string, locale: string) => Promise<SchemaLocalizationJson | undefined>) {\r\n }\r\n\r\n /**\r\n * Load localization JSON for a given schema and locale.\r\n */\r\n public async getLocalization(schemaName: string, locale: string): Promise<SchemaLocalizationJson | undefined> {\r\n const localizationData = await this._loader(schemaName, locale);\r\n\r\n if (localizationData) {\r\n if (!localizationData.name || !localizationData.locale) {\r\n throw new Error(`Invalid localization JSON for ${schemaName}:${locale} - missing schema name or locale`);\r\n }\r\n\r\n if (localizationData.name !== schemaName) {\r\n throw new Error(`Localization JSON mismatch for ${schemaName}:${locale} - expected schema name \"${schemaName}\" but got \"${localizationData.name}\"`);\r\n }\r\n\r\n if (localizationData.locale !== locale) {\r\n throw new Error(`Localization JSON mismatch for ${schemaName}:${locale} - expected locale \"${locale}\" but got \"${localizationData.locale}\"`);\r\n }\r\n }\r\n\r\n return localizationData;\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents localized label and description for a schema element.
|
|
3
|
+
* @beta
|
|
4
|
+
*/
|
|
5
|
+
export interface LocalizedText {
|
|
6
|
+
label?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Localized text for a schema item
|
|
11
|
+
* @beta
|
|
12
|
+
*/
|
|
13
|
+
export interface LocalizedItemText extends LocalizedText {
|
|
14
|
+
/** Localized members keyed by member name */
|
|
15
|
+
members?: {
|
|
16
|
+
[memberName: string]: LocalizedText;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* JSON structure for schema localization file.
|
|
21
|
+
* @beta
|
|
22
|
+
*/
|
|
23
|
+
export interface SchemaLocalizationJson {
|
|
24
|
+
/** Schema version identifier */
|
|
25
|
+
$schema: string;
|
|
26
|
+
/** Name of the schema this localization applies to */
|
|
27
|
+
name: string;
|
|
28
|
+
/** Version of the schema */
|
|
29
|
+
version: string;
|
|
30
|
+
/** Locale identifier (e.g., "de", "fr", "es-CO") */
|
|
31
|
+
locale: string;
|
|
32
|
+
/** Localized schema label */
|
|
33
|
+
label?: string;
|
|
34
|
+
/** Localized schema description */
|
|
35
|
+
description?: string;
|
|
36
|
+
/** Localized schema items, keyed by item name */
|
|
37
|
+
items?: {
|
|
38
|
+
[itemName: string]: LocalizedItemText;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=LocalizationTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalizationTypes.d.ts","sourceRoot":"","sources":["../../../src/Localization/LocalizationTypes.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAkB,SAAQ,aAAa;IACtD,6CAA6C;IAC7C,OAAO,CAAC,EAAE;QAAE,CAAC,UAAU,EAAE,MAAM,GAAG,aAAa,CAAA;KAAE,CAAC;CACnD;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,gCAAgC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iDAAiD;IACjD,KAAK,CAAC,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,CAAA;KAAE,CAAC;CACnD"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
export {};
|
|
6
|
+
//# sourceMappingURL=LocalizationTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalizationTypes.js","sourceRoot":"","sources":["../../../src/Localization/LocalizationTypes.ts"],"names":[],"mappings":"AAAA;;;+FAG+F","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\n/**\r\n * Represents localized label and description for a schema element.\r\n * @beta\r\n */\r\nexport interface LocalizedText {\r\n label?: string;\r\n description?: string;\r\n}\r\n\r\n/**\r\n * Localized text for a schema item\r\n * @beta\r\n */\r\nexport interface LocalizedItemText extends LocalizedText {\r\n /** Localized members keyed by member name */\r\n members?: { [memberName: string]: LocalizedText };\r\n}\r\n\r\n/**\r\n * JSON structure for schema localization file.\r\n * @beta\r\n */\r\nexport interface SchemaLocalizationJson {\r\n /** Schema version identifier */\r\n $schema: string;\r\n /** Name of the schema this localization applies to */\r\n name: string;\r\n /** Version of the schema */\r\n version: string;\r\n /** Locale identifier (e.g., \"de\", \"fr\", \"es-CO\") */\r\n locale: string;\r\n /** Localized schema label */\r\n label?: string;\r\n /** Localized schema description */\r\n description?: string;\r\n /** Localized schema items, keyed by item name */\r\n items?: { [itemName: string]: LocalizedItemText };\r\n}\r\n"]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { SchemaKey } from "../SchemaKey";
|
|
2
|
+
import { SchemaView } from "../SchemaView";
|
|
3
|
+
import { Schema } from "../Metadata/Schema";
|
|
4
|
+
import { ECClass } from "../Metadata/Class";
|
|
5
|
+
import { Property } from "../Metadata/Property";
|
|
6
|
+
import { SchemaItem } from "../Metadata/SchemaItem";
|
|
7
|
+
import { ILocalizationProvider } from "./LocalizationProvider";
|
|
8
|
+
import { AnyEnumerator, Enumeration } from "../Metadata/Enumeration";
|
|
9
|
+
import { LocalizedText } from "./LocalizationTypes";
|
|
10
|
+
type SchemaViewItem = SchemaView.Class | SchemaView.Enumeration | SchemaView.KindOfQuantity | SchemaView.PropertyCategory;
|
|
11
|
+
/**
|
|
12
|
+
* Manages schema localization to provide localized labels and descriptions.
|
|
13
|
+
* @beta
|
|
14
|
+
*/
|
|
15
|
+
export declare class SchemaLocalization {
|
|
16
|
+
private _provider;
|
|
17
|
+
private _locale;
|
|
18
|
+
private _cache;
|
|
19
|
+
private constructor();
|
|
20
|
+
private get _baseLocale();
|
|
21
|
+
private cacheKey;
|
|
22
|
+
/**
|
|
23
|
+
* Create a SchemaLocalization instance and pre-load localization files for the given schemas.
|
|
24
|
+
* @param provider The localization provider to use for loading localization files
|
|
25
|
+
* @param locale The target locale (e.g., "de", "fr", "es-CO")
|
|
26
|
+
* @param schemas The schemas whose localization should be pre-loaded
|
|
27
|
+
*/
|
|
28
|
+
static create(provider: ILocalizationProvider, locale: string, schemaKeys: Iterable<SchemaKey>): Promise<SchemaLocalization>;
|
|
29
|
+
get locale(): string;
|
|
30
|
+
setLocale(locale: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* Get localization provider.
|
|
33
|
+
*/
|
|
34
|
+
get provider(): ILocalizationProvider;
|
|
35
|
+
/**
|
|
36
|
+
* Load localizations for the given schema keys.
|
|
37
|
+
* @param schemaKeys The schema keys to load localization for
|
|
38
|
+
*/
|
|
39
|
+
loadLocalizations(schemaKeys: Iterable<SchemaKey>): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Get a localized label for a schema, schema item, or member.
|
|
42
|
+
*/
|
|
43
|
+
getLabel(schemaName: string, itemName?: string, memberName?: string): string | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Get a localized description for a schema, schema item, or member.
|
|
46
|
+
*/
|
|
47
|
+
getDescription(schemaName: string, itemName?: string, memberName?: string): string | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Get localized label and description of a schema.
|
|
50
|
+
* Label fallback: localized label → base locale label → original label → schema name
|
|
51
|
+
* Description fallback: localized description → base locale description → original description
|
|
52
|
+
*/
|
|
53
|
+
getLocalizedSchema(schema: Schema | SchemaView.Schema): LocalizedText;
|
|
54
|
+
/**
|
|
55
|
+
* Get localized label and description of a schema item (class, enumeration, unit, etc.).
|
|
56
|
+
* Label fallback: localized label → base locale label → original label → item name
|
|
57
|
+
* Description fallback: localized description → base locale description → original description
|
|
58
|
+
*/
|
|
59
|
+
getLocalizedSchemaItem(item: SchemaItem | SchemaViewItem): LocalizedText;
|
|
60
|
+
/**
|
|
61
|
+
* Get localized label and description of a property.
|
|
62
|
+
* Label fallback: localized label → base locale label → original label → property name
|
|
63
|
+
* Description fallback: localized description → base locale description → original description
|
|
64
|
+
*/
|
|
65
|
+
getLocalizedProperty(ecClass: ECClass | SchemaView.Class, property: Property | SchemaView.Property): LocalizedText;
|
|
66
|
+
/**
|
|
67
|
+
* Get localized label and description of an enumerator.
|
|
68
|
+
* Label fallback: localized label → base locale label → original label → enumerator name
|
|
69
|
+
* Description fallback: localized description → base locale description → original description
|
|
70
|
+
*/
|
|
71
|
+
getLocalizedEnumerator(enumeration: Enumeration | SchemaView.Enumeration, enumerator: AnyEnumerator | SchemaView.Enumerator): LocalizedText;
|
|
72
|
+
/**
|
|
73
|
+
* Load localization information for a specific schema and locale.
|
|
74
|
+
*/
|
|
75
|
+
private loadLocalizationInfo;
|
|
76
|
+
/**
|
|
77
|
+
* Get major version from version string
|
|
78
|
+
*/
|
|
79
|
+
private getMajorVersion;
|
|
80
|
+
/**
|
|
81
|
+
* Retrieve the cached localization for a locale
|
|
82
|
+
*/
|
|
83
|
+
private getCachedLocalization;
|
|
84
|
+
/**
|
|
85
|
+
* Resolve a label from a localization object by item and optional member path.
|
|
86
|
+
*/
|
|
87
|
+
private resolveLabel;
|
|
88
|
+
/**
|
|
89
|
+
* Resolve a description from a localization object by item and optional member path.
|
|
90
|
+
*/
|
|
91
|
+
private resolveDescription;
|
|
92
|
+
}
|
|
93
|
+
export {};
|
|
94
|
+
//# sourceMappingURL=SchemaLocalization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaLocalization.d.ts","sourceRoot":"","sources":["../../../src/Localization/SchemaLocalization.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,aAAa,EAA0B,MAAM,qBAAqB,CAAC;AAI5E,KAAK,cAAc,GAAG,UAAU,CAAC,KAAK,GAAG,UAAU,CAAC,WAAW,GAAG,UAAU,CAAC,cAAc,GAAG,UAAU,CAAC,gBAAgB,CAAC;AAE1H;;;GAGG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,SAAS,CAAwB;IACzC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAA8D;IAE5E,OAAO;IAKP,OAAO,KAAK,WAAW,GAEtB;IAED,OAAO,CAAC,QAAQ;IAIhB;;;;;OAKG;WACiB,MAAM,CAAC,QAAQ,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAMzI,IAAW,MAAM,IAAI,MAAM,CAE1B;IAEM,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAKtC;;OAEG;IACH,IAAW,QAAQ,IAAI,qBAAqB,CAE3C;IAED;;;OAGG;IACU,iBAAiB,CAAC,UAAU,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAU9E;;OAEG;IACI,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAc/F;;OAEG;IACI,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAcrG;;;;OAIG;IACI,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC,MAAM,GAAG,aAAa;IAM5E;;;;OAIG;IACI,sBAAsB,CAAC,IAAI,EAAE,UAAU,GAAG,cAAc,GAAG,aAAa;IAM/E;;;;OAIG;IACI,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,GAAG,UAAU,CAAC,QAAQ,GAAG,aAAa;IAMzH;;;;OAIG;IACI,sBAAsB,CAAC,WAAW,EAAE,WAAW,GAAG,UAAU,CAAC,WAAW,EAAE,UAAU,EAAE,aAAa,GAAG,UAAU,CAAC,UAAU,GAAG,aAAa;IAMlJ;;OAEG;YACW,oBAAoB;IAkBlC;;OAEG;IACH,OAAO,CAAC,eAAe;IASvB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAK7B;;OAEG;IACH,OAAO,CAAC,YAAY;IAWpB;;OAEG;IACH,OAAO,CAAC,kBAAkB;CAU3B"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { Logger } from "@itwin/core-bentley";
|
|
6
|
+
const loggerCategory = "SchemaLocalization";
|
|
7
|
+
/**
|
|
8
|
+
* Manages schema localization to provide localized labels and descriptions.
|
|
9
|
+
* @beta
|
|
10
|
+
*/
|
|
11
|
+
export class SchemaLocalization {
|
|
12
|
+
_provider;
|
|
13
|
+
_locale;
|
|
14
|
+
_cache = new Map();
|
|
15
|
+
constructor(provider, locale) {
|
|
16
|
+
this._provider = provider;
|
|
17
|
+
this._locale = locale;
|
|
18
|
+
}
|
|
19
|
+
get _baseLocale() {
|
|
20
|
+
return this._locale.includes("-") ? this._locale.split("-")[0] : undefined;
|
|
21
|
+
}
|
|
22
|
+
cacheKey(schemaName, locale) {
|
|
23
|
+
return `${schemaName}:${locale}`;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Create a SchemaLocalization instance and pre-load localization files for the given schemas.
|
|
27
|
+
* @param provider The localization provider to use for loading localization files
|
|
28
|
+
* @param locale The target locale (e.g., "de", "fr", "es-CO")
|
|
29
|
+
* @param schemas The schemas whose localization should be pre-loaded
|
|
30
|
+
*/
|
|
31
|
+
static async create(provider, locale, schemaKeys) {
|
|
32
|
+
const localization = new SchemaLocalization(provider, locale);
|
|
33
|
+
await localization.loadLocalizations(schemaKeys);
|
|
34
|
+
return localization;
|
|
35
|
+
}
|
|
36
|
+
get locale() {
|
|
37
|
+
return this._locale;
|
|
38
|
+
}
|
|
39
|
+
setLocale(locale) {
|
|
40
|
+
this._locale = locale;
|
|
41
|
+
this._cache.clear();
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get localization provider.
|
|
45
|
+
*/
|
|
46
|
+
get provider() {
|
|
47
|
+
return this._provider;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Load localizations for the given schema keys.
|
|
51
|
+
* @param schemaKeys The schema keys to load localization for
|
|
52
|
+
*/
|
|
53
|
+
async loadLocalizations(schemaKeys) {
|
|
54
|
+
const promises = [];
|
|
55
|
+
for (const key of schemaKeys) {
|
|
56
|
+
promises.push(this.loadLocalizationInfo(key.name, key.readVersion, this._locale));
|
|
57
|
+
if (this._baseLocale !== undefined)
|
|
58
|
+
promises.push(this.loadLocalizationInfo(key.name, key.readVersion, this._baseLocale));
|
|
59
|
+
}
|
|
60
|
+
await Promise.all(promises);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get a localized label for a schema, schema item, or member.
|
|
64
|
+
*/
|
|
65
|
+
getLabel(schemaName, itemName, memberName) {
|
|
66
|
+
const localization = this.getCachedLocalization(schemaName, this._locale);
|
|
67
|
+
const label = this.resolveLabel(localization, itemName, memberName);
|
|
68
|
+
if (label)
|
|
69
|
+
return label;
|
|
70
|
+
if (this._baseLocale) {
|
|
71
|
+
const baseLocalization = this.getCachedLocalization(schemaName, this._baseLocale);
|
|
72
|
+
return this.resolveLabel(baseLocalization, itemName, memberName);
|
|
73
|
+
}
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Get a localized description for a schema, schema item, or member.
|
|
78
|
+
*/
|
|
79
|
+
getDescription(schemaName, itemName, memberName) {
|
|
80
|
+
const localization = this.getCachedLocalization(schemaName, this._locale);
|
|
81
|
+
const description = this.resolveDescription(localization, itemName, memberName);
|
|
82
|
+
if (description)
|
|
83
|
+
return description;
|
|
84
|
+
if (this._baseLocale) {
|
|
85
|
+
const baseLocalization = this.getCachedLocalization(schemaName, this._baseLocale);
|
|
86
|
+
return this.resolveDescription(baseLocalization, itemName, memberName);
|
|
87
|
+
}
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Get localized label and description of a schema.
|
|
92
|
+
* Label fallback: localized label → base locale label → original label → schema name
|
|
93
|
+
* Description fallback: localized description → base locale description → original description
|
|
94
|
+
*/
|
|
95
|
+
getLocalizedSchema(schema) {
|
|
96
|
+
const label = this.getLabel(schema.name) ?? (schema.label || schema.name);
|
|
97
|
+
const description = this.getDescription(schema.name) ?? schema.description;
|
|
98
|
+
return { label, description };
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Get localized label and description of a schema item (class, enumeration, unit, etc.).
|
|
102
|
+
* Label fallback: localized label → base locale label → original label → item name
|
|
103
|
+
* Description fallback: localized description → base locale description → original description
|
|
104
|
+
*/
|
|
105
|
+
getLocalizedSchemaItem(item) {
|
|
106
|
+
const label = this.getLabel(item.schema.name, item.name) ?? (item.label || item.name);
|
|
107
|
+
const description = this.getDescription(item.schema.name, item.name) ?? item.description;
|
|
108
|
+
return { label, description };
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Get localized label and description of a property.
|
|
112
|
+
* Label fallback: localized label → base locale label → original label → property name
|
|
113
|
+
* Description fallback: localized description → base locale description → original description
|
|
114
|
+
*/
|
|
115
|
+
getLocalizedProperty(ecClass, property) {
|
|
116
|
+
const label = this.getLabel(ecClass.schema.name, ecClass.name, property.name) ?? (property.label || property.name);
|
|
117
|
+
const description = this.getDescription(ecClass.schema.name, ecClass.name, property.name) ?? property.description;
|
|
118
|
+
return { label, description };
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Get localized label and description of an enumerator.
|
|
122
|
+
* Label fallback: localized label → base locale label → original label → enumerator name
|
|
123
|
+
* Description fallback: localized description → base locale description → original description
|
|
124
|
+
*/
|
|
125
|
+
getLocalizedEnumerator(enumeration, enumerator) {
|
|
126
|
+
const label = this.getLabel(enumeration.schema.name, enumeration.name, enumerator.name) ?? (enumerator.label || enumerator.name);
|
|
127
|
+
const description = this.getDescription(enumeration.schema.name, enumeration.name, enumerator.name) ?? enumerator.description;
|
|
128
|
+
return { label, description };
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Load localization information for a specific schema and locale.
|
|
132
|
+
*/
|
|
133
|
+
async loadLocalizationInfo(schemaName, readVersion, locale) {
|
|
134
|
+
const cacheKey = this.cacheKey(schemaName, locale);
|
|
135
|
+
if (this._cache.has(cacheKey))
|
|
136
|
+
return;
|
|
137
|
+
const localization = await this._provider.getLocalization(schemaName, locale);
|
|
138
|
+
if (localization?.version) {
|
|
139
|
+
const localizationMajor = this.getMajorVersion(localization.version);
|
|
140
|
+
if (localizationMajor === undefined || readVersion !== localizationMajor) {
|
|
141
|
+
Logger.logWarning(loggerCategory, `Localization version mismatch for schema "${schemaName}". Schema major version is ${readVersion.toString()}, but localization is for major version ${localizationMajor?.toString() ?? "undefined"}.`);
|
|
142
|
+
this._cache.set(cacheKey, undefined);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
this._cache.set(cacheKey, localization);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Get major version from version string
|
|
150
|
+
*/
|
|
151
|
+
getMajorVersion(version) {
|
|
152
|
+
const rawVersion = version.split(".");
|
|
153
|
+
if (rawVersion.length > 0) {
|
|
154
|
+
const majorVersion = parseInt(rawVersion[0], 10);
|
|
155
|
+
return isNaN(majorVersion) ? undefined : majorVersion;
|
|
156
|
+
}
|
|
157
|
+
return undefined;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Retrieve the cached localization for a locale
|
|
161
|
+
*/
|
|
162
|
+
getCachedLocalization(schemaName, locale) {
|
|
163
|
+
const cacheKey = this.cacheKey(schemaName, locale);
|
|
164
|
+
return this._cache.get(cacheKey);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Resolve a label from a localization object by item and optional member path.
|
|
168
|
+
*/
|
|
169
|
+
resolveLabel(localization, itemName, memberName) {
|
|
170
|
+
if (!localization)
|
|
171
|
+
return undefined;
|
|
172
|
+
if (!itemName)
|
|
173
|
+
return localization.label;
|
|
174
|
+
const item = localization.items?.[itemName];
|
|
175
|
+
if (!memberName)
|
|
176
|
+
return item?.label;
|
|
177
|
+
return item?.members?.[memberName]?.label;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Resolve a description from a localization object by item and optional member path.
|
|
181
|
+
*/
|
|
182
|
+
resolveDescription(localization, itemName, memberName) {
|
|
183
|
+
if (!localization)
|
|
184
|
+
return undefined;
|
|
185
|
+
if (!itemName)
|
|
186
|
+
return localization.description;
|
|
187
|
+
const item = localization.items?.[itemName];
|
|
188
|
+
if (!memberName)
|
|
189
|
+
return item?.description;
|
|
190
|
+
return item?.members?.[memberName]?.description;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=SchemaLocalization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaLocalization.js","sourceRoot":"","sources":["../../../src/Localization/SchemaLocalization.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAM/F,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAO7C,MAAM,cAAc,GAAG,oBAAoB,CAAC;AAI5C;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IACrB,SAAS,CAAwB;IACjC,OAAO,CAAS;IAChB,MAAM,GAAoD,IAAI,GAAG,EAAE,CAAC;IAE5E,YAAoB,QAA+B,EAAE,MAAc;QACjE,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,IAAY,WAAW;QACrB,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7E,CAAC;IAEO,QAAQ,CAAC,UAAkB,EAAE,MAAc;QACjD,OAAO,GAAG,UAAU,IAAI,MAAM,EAAE,CAAC;IACnC,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,QAA+B,EAAE,MAAc,EAAE,UAA+B;QACzG,MAA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CAAC;YACjD,OAAO,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC;QACxD,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;OAEG;IACK,qBAAqB,CAAC,UAAkB,EAAE,MAAc;QAC9D,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QACnD,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED;;OAEG;IACK,YAAY,CAAC,YAAgD,EAAE,QAAiB,EAAE,UAAmB;QAC3G,IAAI,CAAC,YAAY;YACf,OAAO,SAAS,CAAC;QACnB,IAAI,CAAC,QAAQ;YACX,OAAO,YAAY,CAAC,KAAK,CAAC;QAC5B,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,CAAC;QAC5C,IAAI,CAAC,UAAU;YACb,OAAO,IAAI,EAAE,KAAK,CAAC;QACrB,OAAO,IAAI,EAAE,OAAO,EAAE,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC;IAC5C,CAAC;IAED;;OAEG;IACK,kBAAkB,CAAC,YAAgD,EAAE,QAAiB,EAAE,UAAmB;QACjH,IAAI,CAAC,YAAY;YACf,OAAO,SAAS,CAAC;QACnB,IAAI,CAAC,QAAQ;YACX,OAAO,YAAY,CAAC,WAAW,CAAC;QAClC,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,CAAC;QAC5C,IAAI,CAAC,UAAU;YACb,OAAO,IAAI,EAAE,WAAW,CAAC;QAC3B,OAAO,IAAI,EAAE,OAAO,EAAE,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC;IAClD,CAAC;CACF","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 { SchemaKey } from \"../SchemaKey\";\r\nimport { SchemaView } from \"../SchemaView\";\r\nimport { Schema } from \"../Metadata/Schema\";\r\nimport { ECClass } from \"../Metadata/Class\";\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport { Property } from \"../Metadata/Property\";\r\nimport { SchemaItem } from \"../Metadata/SchemaItem\";\r\nimport { ILocalizationProvider } from \"./LocalizationProvider\";\r\nimport { AnyEnumerator, Enumeration } from \"../Metadata/Enumeration\";\r\nimport { LocalizedText, SchemaLocalizationJson } from \"./LocalizationTypes\";\r\n\r\nconst loggerCategory = \"SchemaLocalization\";\r\n\r\ntype SchemaViewItem = SchemaView.Class | SchemaView.Enumeration | SchemaView.KindOfQuantity | SchemaView.PropertyCategory;\r\n\r\n/**\r\n * Manages schema localization to provide localized labels and descriptions.\r\n * @beta\r\n */\r\nexport class SchemaLocalization {\r\n private _provider: ILocalizationProvider;\r\n private _locale: string;\r\n private _cache: Map<string, SchemaLocalizationJson | undefined> = new Map();\r\n\r\n private constructor(provider: ILocalizationProvider, locale: string) {\r\n this._provider = provider;\r\n this._locale = locale;\r\n }\r\n\r\n private get _baseLocale(): string | undefined {\r\n return this._locale.includes(\"-\") ? this._locale.split(\"-\")[0] : undefined;\r\n }\r\n\r\n private cacheKey(schemaName: string, locale: string): string {\r\n return `${schemaName}:${locale}`;\r\n }\r\n\r\n /**\r\n * Create a SchemaLocalization instance and pre-load localization files for the given schemas.\r\n * @param provider The localization provider to use for loading localization files\r\n * @param locale The target locale (e.g., \"de\", \"fr\", \"es-CO\")\r\n * @param schemas The schemas whose localization should be pre-loaded\r\n */\r\n public static async create(provider: ILocalizationProvider, locale: string, schemaKeys: Iterable<SchemaKey>): Promise<SchemaLocalization> {\r\n const localization = new SchemaLocalization(provider, locale);\r\n await localization.loadLocalizations(schemaKeys);\r\n return localization;\r\n }\r\n\r\n public get locale(): string {\r\n return this._locale;\r\n }\r\n\r\n public setLocale(locale: string): void {\r\n this._locale = locale;\r\n this._cache.clear();\r\n }\r\n\r\n /**\r\n * Get localization provider.\r\n */\r\n public get provider(): ILocalizationProvider {\r\n return this._provider;\r\n }\r\n\r\n /**\r\n * Load localizations for the given schema keys.\r\n * @param schemaKeys The schema keys to load localization for\r\n */\r\n public async loadLocalizations(schemaKeys: Iterable<SchemaKey>): Promise<void> {\r\n const promises: Promise<void>[] = [];\r\n for (const key of schemaKeys) {\r\n promises.push(this.loadLocalizationInfo(key.name, key.readVersion, this._locale));\r\n if (this._baseLocale !== undefined)\r\n promises.push(this.loadLocalizationInfo(key.name, key.readVersion, this._baseLocale));\r\n }\r\n await Promise.all(promises);\r\n }\r\n\r\n /**\r\n * Get a localized label for a schema, schema item, or member.\r\n */\r\n public getLabel(schemaName: string, itemName?: string, memberName?: string): string | undefined {\r\n const localization = this.getCachedLocalization(schemaName, this._locale);\r\n const label = this.resolveLabel(localization, itemName, memberName);\r\n if (label)\r\n return label;\r\n\r\n if (this._baseLocale) {\r\n const baseLocalization = this.getCachedLocalization(schemaName, this._baseLocale);\r\n return this.resolveLabel(baseLocalization, itemName, memberName);\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Get a localized description for a schema, schema item, or member.\r\n */\r\n public getDescription(schemaName: string, itemName?: string, memberName?: string): string | undefined {\r\n const localization = this.getCachedLocalization(schemaName, this._locale);\r\n const description = this.resolveDescription(localization, itemName, memberName);\r\n if (description)\r\n return description;\r\n\r\n if (this._baseLocale) {\r\n const baseLocalization = this.getCachedLocalization(schemaName, this._baseLocale);\r\n return this.resolveDescription(baseLocalization, itemName, memberName);\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Get localized label and description of a schema.\r\n * Label fallback: localized label → base locale label → original label → schema name\r\n * Description fallback: localized description → base locale description → original description\r\n */\r\n public getLocalizedSchema(schema: Schema | SchemaView.Schema): LocalizedText {\r\n const label = this.getLabel(schema.name) ?? (schema.label || schema.name);\r\n const description = this.getDescription(schema.name) ?? schema.description;\r\n return { label, description };\r\n }\r\n\r\n /**\r\n * Get localized label and description of a schema item (class, enumeration, unit, etc.).\r\n * Label fallback: localized label → base locale label → original label → item name\r\n * Description fallback: localized description → base locale description → original description\r\n */\r\n public getLocalizedSchemaItem(item: SchemaItem | SchemaViewItem): LocalizedText {\r\n const label = this.getLabel(item.schema.name, item.name) ?? (item.label || item.name);\r\n const description = this.getDescription(item.schema.name, item.name) ?? item.description;\r\n return { label, description };\r\n }\r\n\r\n /**\r\n * Get localized label and description of a property.\r\n * Label fallback: localized label → base locale label → original label → property name\r\n * Description fallback: localized description → base locale description → original description\r\n */\r\n public getLocalizedProperty(ecClass: ECClass | SchemaView.Class, property: Property | SchemaView.Property): LocalizedText {\r\n const label = this.getLabel(ecClass.schema.name, ecClass.name, property.name) ?? (property.label || property.name);\r\n const description = this.getDescription(ecClass.schema.name, ecClass.name, property.name) ?? property.description;\r\n return { label, description };\r\n }\r\n\r\n /**\r\n * Get localized label and description of an enumerator.\r\n * Label fallback: localized label → base locale label → original label → enumerator name\r\n * Description fallback: localized description → base locale description → original description\r\n */\r\n public getLocalizedEnumerator(enumeration: Enumeration | SchemaView.Enumeration, enumerator: AnyEnumerator | SchemaView.Enumerator): LocalizedText {\r\n const label = this.getLabel(enumeration.schema.name, enumeration.name, enumerator.name) ?? (enumerator.label || enumerator.name);\r\n const description = this.getDescription(enumeration.schema.name, enumeration.name, enumerator.name) ?? enumerator.description;\r\n return { label, description };\r\n }\r\n\r\n /**\r\n * Load localization information for a specific schema and locale.\r\n */\r\n private async loadLocalizationInfo(schemaName: string, readVersion: number, locale: string): Promise<void> {\r\n const cacheKey = this.cacheKey(schemaName, locale);\r\n if (this._cache.has(cacheKey))\r\n return;\r\n\r\n const localization = await this._provider.getLocalization(schemaName, locale);\r\n if (localization?.version) {\r\n const localizationMajor = this.getMajorVersion(localization.version);\r\n if (localizationMajor === undefined || readVersion !== localizationMajor) {\r\n Logger.logWarning(loggerCategory, `Localization version mismatch for schema \"${schemaName}\". Schema major version is ${readVersion.toString()}, but localization is for major version ${localizationMajor?.toString() ?? \"undefined\"}.`);\r\n this._cache.set(cacheKey, undefined);\r\n return;\r\n }\r\n }\r\n\r\n this._cache.set(cacheKey, localization);\r\n }\r\n\r\n /**\r\n * Get major version from version string\r\n */\r\n private getMajorVersion(version: string): number | undefined {\r\n const rawVersion = version.split(\".\");\r\n if (rawVersion.length > 0) {\r\n const majorVersion = parseInt(rawVersion[0], 10);\r\n return isNaN(majorVersion) ? undefined : majorVersion;\r\n }\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Retrieve the cached localization for a locale\r\n */\r\n private getCachedLocalization(schemaName: string, locale: string): SchemaLocalizationJson | undefined {\r\n const cacheKey = this.cacheKey(schemaName, locale);\r\n return this._cache.get(cacheKey);\r\n }\r\n\r\n /**\r\n * Resolve a label from a localization object by item and optional member path.\r\n */\r\n private resolveLabel(localization: SchemaLocalizationJson | undefined, itemName?: string, memberName?: string): string | undefined {\r\n if (!localization)\r\n return undefined;\r\n if (!itemName)\r\n return localization.label;\r\n const item = localization.items?.[itemName];\r\n if (!memberName)\r\n return item?.label;\r\n return item?.members?.[memberName]?.label;\r\n }\r\n\r\n /**\r\n * Resolve a description from a localization object by item and optional member path.\r\n */\r\n private resolveDescription(localization: SchemaLocalizationJson | undefined, itemName?: string, memberName?: string): string | undefined {\r\n if (!localization)\r\n return undefined;\r\n if (!itemName)\r\n return localization.description;\r\n const item = localization.items?.[itemName];\r\n if (!memberName)\r\n return item?.description;\r\n return item?.members?.[memberName]?.description;\r\n }\r\n}\r\n"]}
|
|
@@ -44,6 +44,9 @@ export { SchemaGraph } from "./utils/SchemaGraph";
|
|
|
44
44
|
export * from "./SchemaViewBinaryReader";
|
|
45
45
|
export * from "./SchemaView";
|
|
46
46
|
export * from "./SchemaViewInterfaces";
|
|
47
|
+
export * from "./Localization/LocalizationTypes";
|
|
48
|
+
export * from "./Localization/LocalizationProvider";
|
|
49
|
+
export * from "./Localization/SchemaLocalization";
|
|
47
50
|
/** @docs-package-description
|
|
48
51
|
* The ecschema-metadata package contains classes for working with ECSchemas that can be used in both [frontend]($docs/learning/frontend/index.md) and [backend]($docs/learning/backend/index.md).
|
|
49
52
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ecschema-metadata.d.ts","sourceRoot":"","sources":["../../src/ecschema-metadata.ts"],"names":[],"mappings":"AAKA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EACL,QAAQ,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,cAAc,EACxF,mBAAmB,E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AAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mCAAmC,CAAC;AAClD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oCAAoC,CAAC;AACnD,cAAc,uCAAuC,CAAC;AACtD,cAAc,yCAAyC,CAAC;AACxD,cAAc,+CAA+C,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAC5F,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,cAAc,0BAA0B,CAAC;AACzC,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AACjD,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAElD;;GAEG;AACH;;;GAGG;AACH;;;GAGG"}
|
|
@@ -47,6 +47,9 @@ export { SchemaGraph } from "./utils/SchemaGraph";
|
|
|
47
47
|
export * from "./SchemaViewBinaryReader";
|
|
48
48
|
export * from "./SchemaView";
|
|
49
49
|
export * from "./SchemaViewInterfaces";
|
|
50
|
+
export * from "./Localization/LocalizationTypes";
|
|
51
|
+
export * from "./Localization/LocalizationProvider";
|
|
52
|
+
export * from "./Localization/SchemaLocalization";
|
|
50
53
|
/** @docs-package-description
|
|
51
54
|
* The ecschema-metadata package contains classes for working with ECSchemas that can be used in both [frontend]($docs/learning/frontend/index.md) and [backend]($docs/learning/backend/index.md).
|
|
52
55
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ecschema-metadata.js","sourceRoot":"","sources":["../../src/ecschema-metadata.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,cAAc,aAAa,CAAC;AAC5B,cAAc,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CAAmC,CAAC;AAElD;;GAEG;AACH;;;GAGG;AACH;;;GAGG","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\nexport * from \"./Constants\";\r\nexport * from \"./Context\";\r\nexport * from \"./DelayedPromise\";\r\nexport * from \"./Deserialization/SchemaGraphUtil\";\r\nexport * from \"./Deserialization/JsonProps\";\r\nexport * from \"./Deserialization/Helper\";\r\nexport * from \"./Deserialization/XmlParser\";\r\nexport * from \"./ECName\";\r\nexport * from \"./ECObjects\";\r\nexport * from \"./Exception\";\r\nexport * from \"./Interfaces\";\r\nexport { ECClass, StructClass } from \"./Metadata/Class\";\r\nexport { Constant } from \"./Metadata/Constant\";\r\nexport { CustomAttributeClass } from \"./Metadata/CustomAttributeClass\";\r\nexport { EntityClass } from \"./Metadata/EntityClass\";\r\nexport { AnyEnumerator, Enumeration, Enumerator } from \"./Metadata/Enumeration\";\r\nexport { Format } from \"./Metadata/Format\";\r\nexport { InvertedUnit } from \"./Metadata/InvertedUnit\";\r\nexport { KindOfQuantity } from \"./Metadata/KindOfQuantity\";\r\nexport { Mixin } from \"./Metadata/Mixin\";\r\nexport * from \"./Metadata/OverrideFormat\";\r\nexport { Phenomenon } from \"./Metadata/Phenomenon\";\r\nexport {\r\n Property, PrimitiveProperty, PrimitiveArrayProperty, EnumerationProperty, StructProperty,\r\n StructArrayProperty, EnumerationArrayProperty, NavigationProperty, AnyArrayProperty, AnyEnumerationProperty,\r\n AnyPrimitiveProperty, AnyProperty, AnyStructProperty, ArrayProperty, PrimitiveOrEnumPropertyBase,\r\n} from \"./Metadata/Property\";\r\nexport { PropertyCategory } from \"./Metadata/PropertyCategory\";\r\nexport { RelationshipClass, RelationshipConstraint, RelationshipMultiplicity } from \"./Metadata/RelationshipClass\";\r\nexport { Schema } from \"./Metadata/Schema\";\r\nexport * from \"./Metadata/SchemaItem\";\r\nexport { Unit } from \"./Metadata/Unit\";\r\nexport { UnitSystem } from \"./Metadata/UnitSystem\";\r\nexport * from \"./PropertyTypes\";\r\nexport * from \"./SchemaJsonLocater\";\r\nexport * from \"./SchemaKey\";\r\nexport * from \"./SchemaLoader\";\r\nexport * from \"./UnitConversion/UnitConverter\";\r\nexport * from \"./UnitProvider/SchemaUnitProvider\";\r\nexport * from \"./Validation/SchemaWalker\";\r\nexport * from \"./SchemaPartVisitorDelegate\";\r\nexport * from \"./Formatting/SchemaFormatsProvider\";\r\nexport * from \"./Formatting/FormatSetFormatsProvider\";\r\nexport * from \"./IncrementalLoading/ECSqlSchemaLocater\";\r\nexport * from \"./IncrementalLoading/IncrementalSchemaLocater\";\r\nexport { CustomAttribute, CustomAttributeContainerProps } from \"./Metadata/CustomAttribute\";\r\nexport { SchemaGraph } from \"./utils/SchemaGraph\";\r\nexport * from \"./SchemaViewBinaryReader\";\r\nexport * from \"./SchemaView\";\r\nexport * from \"./SchemaViewInterfaces\";\r\nexport * from \"./Localization/LocalizationTypes\";\r\nexport * from \"./Localization/LocalizationProvider\";\r\nexport * from \"./Localization/SchemaLocalization\";\r\n\r\n/** @docs-package-description\r\n * The ecschema-metadata package contains classes for working with ECSchemas that can be used in both [frontend]($docs/learning/frontend/index.md) and [backend]($docs/learning/backend/index.md).\r\n */\r\n/**\r\n * @docs-group-description Metadata\r\n * Definitions of classes and interfaces that represent all [EC elements]($docs/bis/ec/index.md).\r\n */\r\n/**\r\n * @docs-group-description Utils\r\n * A set of utility classes used throughout the package.\r\n */\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/ecschema-metadata",
|
|
3
|
-
"version": "5.11.0-dev.
|
|
3
|
+
"version": "5.11.0-dev.5",
|
|
4
4
|
"description": "ECObjects core concepts in typescript",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/cjs/ecschema-metadata.js",
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"rimraf": "^6.0.1",
|
|
42
42
|
"typescript": "~5.6.2",
|
|
43
43
|
"vitest": "^3.0.6",
|
|
44
|
-
"@itwin/build-tools": "5.11.0-dev.
|
|
45
|
-
"@itwin/core-bentley": "5.11.0-dev.
|
|
46
|
-
"@itwin/core-quantity": "5.11.0-dev.
|
|
44
|
+
"@itwin/build-tools": "5.11.0-dev.5",
|
|
45
|
+
"@itwin/core-bentley": "5.11.0-dev.5",
|
|
46
|
+
"@itwin/core-quantity": "5.11.0-dev.5"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@itwin/core-bentley": "5.11.0-dev.
|
|
50
|
-
"@itwin/core-quantity": "5.11.0-dev.
|
|
49
|
+
"@itwin/core-bentley": "5.11.0-dev.5",
|
|
50
|
+
"@itwin/core-quantity": "5.11.0-dev.5"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"build": "npm run -s build:cjs && npm run -s build:esm",
|