@itwin/core-backend 3.0.0-dev.84 → 3.0.0-dev.85
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 +1525 -1525
- package/README.md +11 -11
- package/lib/cjs/BisCoreSchema.js.map +1 -1
- package/lib/cjs/Category.js.map +1 -1
- package/lib/cjs/ChangedElementsDb.js.map +1 -1
- package/lib/cjs/ClassRegistry.js.map +1 -1
- package/lib/cjs/CloudStorageBackend.js.map +1 -1
- package/lib/cjs/CodeSpecs.js.map +1 -1
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/ElementAspect.js.map +1 -1
- package/lib/cjs/ElementGraphics.js.map +1 -1
- package/lib/cjs/Entity.js.map +1 -1
- package/lib/cjs/GeometrySummary.js +47 -47
- package/lib/cjs/GeometrySummary.js.map +1 -1
- package/lib/cjs/IModelJsFs.js.map +1 -1
- package/lib/cjs/LineStyle.js.map +1 -1
- package/lib/cjs/LocalhostIpcHost.js.map +1 -1
- package/lib/cjs/PromiseMemoizer.js.map +1 -1
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/RpcBackend.js.map +1 -1
- package/lib/cjs/Schema.js.map +1 -1
- package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/domains/FunctionalElements.js.map +1 -1
- package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
- package/lib/cjs/domains/GenericElements.js.map +1 -1
- package/lib/cjs/domains/GenericSchema.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
- package/package.json +22 -22
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# @itwin/core-backend
|
|
2
|
-
|
|
3
|
-
Copyright © Bentley Systems, Incorporated. All rights reserved. See LICENSE.md for license terms and full copyright notice.
|
|
4
|
-
|
|
5
|
-
## Description
|
|
6
|
-
|
|
7
|
-
The __@itwin/core-backend__ package contains classes that backend code can use to work with directly with iModels.
|
|
8
|
-
|
|
9
|
-
## Documentation
|
|
10
|
-
|
|
11
|
-
See the [iTwin.js](https://www.itwinjs.org) documentation for more information.
|
|
1
|
+
# @itwin/core-backend
|
|
2
|
+
|
|
3
|
+
Copyright © Bentley Systems, Incorporated. All rights reserved. See LICENSE.md for license terms and full copyright notice.
|
|
4
|
+
|
|
5
|
+
## Description
|
|
6
|
+
|
|
7
|
+
The __@itwin/core-backend__ package contains classes that backend code can use to work with directly with iModels.
|
|
8
|
+
|
|
9
|
+
## Documentation
|
|
10
|
+
|
|
11
|
+
See the [iTwin.js](https://www.itwinjs.org) documentation for more information.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BisCoreSchema.js","sourceRoot":"","sources":["../../src/BisCoreSchema.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,6BAA6B;AAC7B,0CAA0C;AAC1C,mDAAgD;AAChD,wCAAwC;AACxC,6CAA6C;AAC7C,sDAAsD;AACtD,6CAA8C;AAC9C,0CAA0C;AAC1C,oCAAoC;AACpC,0CAA0C;AAC1C,qCAA2C;AAC3C,wCAAwC;AACxC,4CAA4C;AAC5C,kDAAkD;AAElD;;;;;;;;;;GAUG;AACH,MAAa,aAAc,SAAQ,eAAM;IAChC,MAAM,KAAc,UAAU,KAAa,OAAO,SAAS,CAAC,CAAC,CAAC;IAC9D,MAAM,KAAK,cAAc,KAAa,OAAO,IAAI,CAAC,IAAI,CAAC,2BAAc,CAAC,eAAe,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,aAAa,CAAC,UAAU,eAAe,CAAC,CAAC,CAAC,CAAC;IAEhK,gBAAgB;IACT,MAAM,CAAC,cAAc;QAC1B,IAAI,IAAI,KAAK,gBAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,UAAU,CAAC;YACvD,OAAO;QAET,gBAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC1C,gBAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAE7B,sHAAsH;QACtH;YACE,UAAU;YACV,SAAS;YACT,QAAQ;YACR,WAAW;YACX,OAAO;YACP,OAAO;YACP,UAAU;YACV,WAAW;YACX,iBAAiB;YACjB,eAAe;SAChB,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,6BAAa,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;IACpE,CAAC;CACF;AA1BD,sCA0BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Schema\n */\n\nimport * as path from \"path\";\nimport * as categoryMod from \"./Category\";\nimport { ClassRegistry } from \"./ClassRegistry\";\nimport * as elementMod from \"./Element\";\nimport * as aspectMod from \"./ElementAspect\";\nimport * as externalSourceMod from \"./ExternalSource\";\nimport { KnownLocations } from \"./IModelHost\";\nimport * as materialMod from \"./Material\";\nimport * as modelMod from \"./Model\";\nimport * as linkMod from \"./Relationship\";\nimport { Schema, Schemas } from \"./Schema\";\nimport * as textureMod from \"./Texture\";\nimport * as viewMod from \"./ViewDefinition\";\nimport * as displayStyleMod from \"./DisplayStyle\";\n\n/**\n * The [BisCore]($docs/bis/intro/schemas-domains.md) schema is the lowest level Schema in an iModel.\n *\n * It is automatically registered when [[IModelHost.startup]] is called.\n *\n * ** Example:**\n * ``` ts\n * [[include:BisCore.registerSchemaAndGetClass]]\n * ```\n * @public\n */\nexport class BisCoreSchema extends Schema {\n public static override get schemaName(): string { return \"BisCore\"; }\n public static get schemaFilePath(): string { return path.join(KnownLocations.nativeAssetsDir, \"ECSchemas\", \"Dgn\", `${BisCoreSchema.schemaName}.ecschema.xml`); }\n\n /** @internal */\n public static registerSchema() {\n if (this === Schemas.getRegisteredSchema(this.schemaName))\n return;\n\n Schemas.unregisterSchema(this.schemaName);\n Schemas.registerSchema(this);\n\n // this list should include all backend .ts files with implementations of Entity-based classes. Order does not matter.\n [\n elementMod,\n aspectMod,\n modelMod,\n categoryMod,\n viewMod,\n linkMod,\n textureMod,\n materialMod,\n externalSourceMod,\n displayStyleMod,\n ].forEach((module) => ClassRegistry.registerModule(module, this));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BisCoreSchema.js","sourceRoot":"","sources":["../../src/BisCoreSchema.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,6BAA6B;AAC7B,0CAA0C;AAC1C,mDAAgD;AAChD,wCAAwC;AACxC,6CAA6C;AAC7C,sDAAsD;AACtD,6CAA8C;AAC9C,0CAA0C;AAC1C,oCAAoC;AACpC,0CAA0C;AAC1C,qCAA2C;AAC3C,wCAAwC;AACxC,4CAA4C;AAC5C,kDAAkD;AAElD;;;;;;;;;;GAUG;AACH,MAAa,aAAc,SAAQ,eAAM;IAChC,MAAM,KAAc,UAAU,KAAa,OAAO,SAAS,CAAC,CAAC,CAAC;IAC9D,MAAM,KAAK,cAAc,KAAa,OAAO,IAAI,CAAC,IAAI,CAAC,2BAAc,CAAC,eAAe,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,aAAa,CAAC,UAAU,eAAe,CAAC,CAAC,CAAC,CAAC;IAEhK,gBAAgB;IACT,MAAM,CAAC,cAAc;QAC1B,IAAI,IAAI,KAAK,gBAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,UAAU,CAAC;YACvD,OAAO;QAET,gBAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC1C,gBAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAE7B,sHAAsH;QACtH;YACE,UAAU;YACV,SAAS;YACT,QAAQ;YACR,WAAW;YACX,OAAO;YACP,OAAO;YACP,UAAU;YACV,WAAW;YACX,iBAAiB;YACjB,eAAe;SAChB,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,6BAAa,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;IACpE,CAAC;CACF;AA1BD,sCA0BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Schema\r\n */\r\n\r\nimport * as path from \"path\";\r\nimport * as categoryMod from \"./Category\";\r\nimport { ClassRegistry } from \"./ClassRegistry\";\r\nimport * as elementMod from \"./Element\";\r\nimport * as aspectMod from \"./ElementAspect\";\r\nimport * as externalSourceMod from \"./ExternalSource\";\r\nimport { KnownLocations } from \"./IModelHost\";\r\nimport * as materialMod from \"./Material\";\r\nimport * as modelMod from \"./Model\";\r\nimport * as linkMod from \"./Relationship\";\r\nimport { Schema, Schemas } from \"./Schema\";\r\nimport * as textureMod from \"./Texture\";\r\nimport * as viewMod from \"./ViewDefinition\";\r\nimport * as displayStyleMod from \"./DisplayStyle\";\r\n\r\n/**\r\n * The [BisCore]($docs/bis/intro/schemas-domains.md) schema is the lowest level Schema in an iModel.\r\n *\r\n * It is automatically registered when [[IModelHost.startup]] is called.\r\n *\r\n * ** Example:**\r\n * ``` ts\r\n * [[include:BisCore.registerSchemaAndGetClass]]\r\n * ```\r\n * @public\r\n */\r\nexport class BisCoreSchema extends Schema {\r\n public static override get schemaName(): string { return \"BisCore\"; }\r\n public static get schemaFilePath(): string { return path.join(KnownLocations.nativeAssetsDir, \"ECSchemas\", \"Dgn\", `${BisCoreSchema.schemaName}.ecschema.xml`); }\r\n\r\n /** @internal */\r\n public static registerSchema() {\r\n if (this === Schemas.getRegisteredSchema(this.schemaName))\r\n return;\r\n\r\n Schemas.unregisterSchema(this.schemaName);\r\n Schemas.registerSchema(this);\r\n\r\n // this list should include all backend .ts files with implementations of Entity-based classes. Order does not matter.\r\n [\r\n elementMod,\r\n aspectMod,\r\n modelMod,\r\n categoryMod,\r\n viewMod,\r\n linkMod,\r\n textureMod,\r\n materialMod,\r\n externalSourceMod,\r\n displayStyleMod,\r\n ].forEach((module) => ClassRegistry.registerModule(module, this));\r\n }\r\n}\r\n"]}
|
package/lib/cjs/Category.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Category.js","sourceRoot":"","sources":["../../src/Category.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAkE;AAClE,oDAE4B;AAC5B,uCAA8C;AAC9C,yCAAsC;AACtC,qEAAqE;AAErE;;GAEG;AACH,MAAa,WAAY,SAAQ,2BAAiB;IAQhD,gBAAgB;IAChB,YAAmB,KAAuB,EAAE,MAAgB;QAC1D,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,IAAI,mCAAqB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC9D,IAAI,CAAC,WAAW,GAAG,wBAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAC3D,CAAC;IAZD,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,aAAa,CAAC,CAAC,CAAC;IAaxE,gBAAgB;IACA,MAAM;QACpB,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,EAAsB,CAAC;QAC/C,GAAG,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;QAC1C,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC;YACjD,GAAG,CAAC,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AE,IAAI,CAAC,CAAC;QAChE,MAAM,UAAU,GAAG,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAC7D,QAAQ,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;QACjD,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AA7DD,0CA6DC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Categories\n */\n\nimport { Id64, Id64String, JsonUtils } from \"@itwin/core-bentley\";\nimport {\n BisCodeSpec, CategoryProps, Code, CodeScopeProps, CodeSpec, ElementProps, Rank, SubCategoryAppearance, SubCategoryProps,\n} from \"@itwin/core-common\";\nimport { DefinitionElement } from \"./Element\";\nimport { IModelDb } from \"./IModelDb\";\nimport { CategoryOwnsSubCategories } from \"./NavigationRelationship\";\n\n/** Defines the appearance for graphics in Geometric elements\n * @public\n */\nexport class SubCategory extends DefinitionElement {\n /** @internal */\n public static override get className(): string { return \"SubCategory\"; }\n /** The Appearance parameters for this SubCategory */\n public appearance: SubCategoryAppearance;\n /** Optional description of this SubCategory. */\n public description?: string;\n\n /** @internal */\n public constructor(props: SubCategoryProps, iModel: IModelDb) {\n super(props, iModel);\n this.appearance = new SubCategoryAppearance(props.appearance);\n this.description = JsonUtils.asString(props.description);\n }\n\n /** @internal */\n public override toJSON(): SubCategoryProps {\n const val = super.toJSON() as SubCategoryProps;\n val.appearance = this.appearance.toJSON();\n if (this.description && this.description.length > 0)\n val.description = this.description;\n return val;\n }\n\n /** Get the SubCategory's name (its Code value). */\n public getSubCategoryName(): string { return this.code.value; }\n /** Get the Id of the SubCategory. */\n public getSubCategoryId(): Id64String { return this.id; }\n /** Get the Id of this SubCategory's parent Category. */\n public getCategoryId(): Id64String { return this.parent ? this.parent.id : Id64.invalid; }\n /** Check if this is the default SubCategory of its parent Category. */\n public get isDefaultSubCategory(): boolean { return IModelDb.getDefaultSubCategoryId(this.getCategoryId()) === this.getSubCategoryId(); }\n\n /** Create a Code for a SubCategory given a name that is meant to be unique within the scope of the specified parent Category.\n * @param iModel The IModel\n * @param parentCategoryId The Id of the parent Category that owns the SubCategory and provides the scope for its name.\n * @param codeValue The name of the SubCategory\n */\n public static createCode(iModel: IModelDb, parentCategoryId: CodeScopeProps, codeValue: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.subCategory);\n return new Code({ spec: codeSpec.id, scope: parentCategoryId, value: codeValue });\n }\n\n /** Create a new SubCategory\n * @param iModelDb The iModel\n * @param parentCategoryId Create the new SubCategory as a child of this [[Category]]\n * @param name The name of the SubCategory\n * @param appearance The appearance settings to use for this SubCategory\n * @returns The newly constructed SubCategory element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(iModelDb: IModelDb, parentCategoryId: Id64String, name: string, appearance: SubCategoryAppearance.Props | SubCategoryAppearance): SubCategory {\n if (appearance instanceof SubCategoryAppearance)\n appearance = appearance.toJSON();\n\n const parentCategory = iModelDb.elements.getElement<Category>(parentCategoryId);\n const subCategoryProps: SubCategoryProps = {\n classFullName: this.classFullName,\n model: parentCategory.model,\n parent: new CategoryOwnsSubCategories(parentCategoryId),\n code: this.createCode(iModelDb, parentCategoryId, name),\n appearance,\n };\n return new SubCategory(subCategoryProps, iModelDb);\n }\n\n /** Insert a new SubCategory\n * @param iModelDb Insert into this iModel\n * @param parentCategoryId Insert the new SubCategory as a child of this Category\n * @param name The name of the SubCategory\n * @param appearance The appearance settings to use for this SubCategory\n * @returns The Id of the newly inserted SubCategory element.\n * @throws [[IModelError]] if unable to insert the element.\n */\n public static insert(iModelDb: IModelDb, parentCategoryId: Id64String, name: string, appearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\n const subCategory = this.create(iModelDb, parentCategoryId, name, appearance);\n return iModelDb.elements.insertElement(subCategory);\n }\n}\n\n/** A Category element is the target of the `category` member of [[GeometricElement]].\n * @public\n */\nexport class Category extends DefinitionElement implements CategoryProps {\n /** @internal */\n public static override get className(): string { return \"Category\"; }\n public rank: Rank = Rank.User;\n public description?: string;\n\n /** @internal */\n public constructor(props: CategoryProps, iModel: IModelDb) {\n super(props, iModel);\n this.rank = JsonUtils.asInt(props.rank);\n this.description = JsonUtils.asString(props.description);\n }\n\n /** @internal */\n public override toJSON(): CategoryProps {\n const val = super.toJSON() as CategoryProps;\n val.rank = this.rank;\n if (this.description && this.description.length > 0)\n val.description = this.description;\n return val;\n }\n\n /** Get the Id of the default SubCategory for this Category. */\n public myDefaultSubCategoryId(): Id64String { return IModelDb.getDefaultSubCategoryId(this.id); }\n\n /** Set the appearance of the default SubCategory for this Category */\n public setDefaultAppearance(props: SubCategoryAppearance.Props | SubCategoryAppearance): void {\n if (props instanceof SubCategoryAppearance)\n props = props.toJSON();\n\n const subCat = this.iModel.elements.getElement<SubCategory>(this.myDefaultSubCategoryId());\n subCat.appearance = new SubCategoryAppearance(props);\n this.iModel.elements.updateElement(subCat);\n }\n}\n\n/** Categorizes 2d GeometricElements.\n * @public\n */\nexport class DrawingCategory extends Category {\n /** @internal */\n public static override get className(): string { return \"DrawingCategory\"; }\n\n /** Construct a DrawingCategory\n * @param opts The properties of the new DrawingCategory\n * @param iModel The IModelDb where the DrawingCategory may be inserted.\n * @internal\n */\n public constructor(opts: ElementProps, iModel: IModelDb) { super(opts, iModel); }\n\n /** Get the name of the CodeSpec that is used by DrawingCategory objects. */\n public static getCodeSpecName(): string { return BisCodeSpec.drawingCategory; }\n\n /** Looks up the CategoryId of a DrawingCategory by model and name */\n public static queryCategoryIdByName(iModel: IModelDb, scopeModelId: Id64String, categoryName: string): Id64String | undefined {\n const code: Code = DrawingCategory.createCode(iModel, scopeModelId, categoryName);\n return iModel.elements.queryElementIdByCode(code);\n }\n\n /** Create a Code for a DrawingCategory given a name that is meant to be unique within the scope of the specified DefinitionModel.\n * @param iModel The IModel\n * @param scopeModelId The Id of the DefinitionModel that contains the DrawingCategory and provides the scope for its name.\n * @param codeValue The name of the category\n * @return A drawing category Code\n */\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(DrawingCategory.getCodeSpecName());\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\n }\n\n /** Create a new DrawingCategory\n * @param iModelDb The iModel\n * @param definitionModelId The [[DefinitionModel]]\n * @param name The name of the DrawingCategory\n * @returns The newly constructed DrawingCategory element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string): DrawingCategory {\n const categoryProps: CategoryProps = {\n classFullName: this.classFullName,\n model: definitionModelId,\n code: this.createCode(iModelDb, definitionModelId, name),\n isPrivate: false,\n };\n return new DrawingCategory(categoryProps, iModelDb);\n }\n\n /** Insert a new DrawingCategory\n * @param iModelDb Insert into this iModel\n * @param definitionModelId Insert the new DrawingCategory into this [[DefinitionModel]]\n * @param name The name of the DrawingCategory\n * @param defaultAppearance The appearance settings to use for the default SubCategory of this DrawingCategory\n * @returns The Id of the newly inserted DrawingCategory element.\n * @throws [[IModelError]] if unable to insert the element.\n */\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\n const category = this.create(iModelDb, definitionModelId, name);\n const elements = iModelDb.elements;\n const categoryId = elements.insertElement(category);\n category.setDefaultAppearance(defaultAppearance);\n return categoryId;\n }\n}\n\n/** Categorizes SpatialElements. See [how to create a SpatialCategory]$(docs/learning/backend/CreateElements.md#SpatialCategory).\n * @public\n */\nexport class SpatialCategory extends Category {\n /** @internal */\n public static override get className(): string { return \"SpatialCategory\"; }\n /** Construct a SpatialCategory\n * @param opts The properties of the new SpatialCategory\n * @param iModel The IModelDb where the SpatialCategory may be inserted.\n * @internal\n */\n public constructor(opts: ElementProps, iModel: IModelDb) { super(opts, iModel); }\n\n /** Get the name of the CodeSpec that is used by SpatialCategory objects. */\n public static getCodeSpecName(): string { return BisCodeSpec.spatialCategory; }\n\n /** Looks up the CategoryId of a SpatialCategory by model and name */\n public static queryCategoryIdByName(iModel: IModelDb, scopeModelId: Id64String, categoryName: string): Id64String | undefined {\n const code: Code = SpatialCategory.createCode(iModel, scopeModelId, categoryName);\n return iModel.elements.queryElementIdByCode(code);\n }\n\n /** Create a Code for a SpatialCategory given a name that is meant to be unique within the scope of the specified DefinitionModel.\n * @param iModel The IModel\n * @param scopeModelId The Id of the DefinitionModel that contains the SpatialCategory and provides the scope for its name.\n * @param codeValue The name of the category\n * @return A spatial category Code\n */\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(SpatialCategory.getCodeSpecName());\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\n }\n\n /** Create a new SpatialCategory\n * @param iModelDb The iModel\n * @param definitionModelId The [[DefinitionModel]]\n * @param name The name/CodeValue of the SpatialCategory\n * @returns The newly constructed SpatialCategory element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string): SpatialCategory {\n const categoryProps: CategoryProps = {\n classFullName: this.classFullName,\n model: definitionModelId,\n code: this.createCode(iModelDb, definitionModelId, name),\n isPrivate: false,\n };\n return new SpatialCategory(categoryProps, iModelDb);\n }\n\n /** Insert a new SpatialCategory\n * @param iModelDb Insert into this iModel\n * @param definitionModelId Insert the new SpatialCategory into this DefinitionModel\n * @param name The name of the SpatialCategory\n * @param defaultAppearance The appearance settings to use for the default SubCategory of this SpatialCategory\n * @returns The Id of the newly inserted SpatialCategory element.\n * @throws [[IModelError]] if unable to insert the element.\n */\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\n const category = this.create(iModelDb, definitionModelId, name);\n const categoryId = iModelDb.elements.insertElement(category);\n category.setDefaultAppearance(defaultAppearance);\n return categoryId;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Category.js","sourceRoot":"","sources":["../../src/Category.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAkE;AAClE,oDAE4B;AAC5B,uCAA8C;AAC9C,yCAAsC;AACtC,qEAAqE;AAErE;;GAEG;AACH,MAAa,WAAY,SAAQ,2BAAiB;IAQhD,gBAAgB;IAChB,YAAmB,KAAuB,EAAE,MAAgB;QAC1D,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,IAAI,mCAAqB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC9D,IAAI,CAAC,WAAW,GAAG,wBAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAC3D,CAAC;IAZD,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,aAAa,CAAC,CAAC,CAAC;IAaxE,gBAAgB;IACA,MAAM;QACpB,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,EAAsB,CAAC;QAC/C,GAAG,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;QAC1C,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC;YACjD,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACrC,OAAO,GAAG,CAAC;IACb,CAAC;IAED,mDAAmD;IAC5C,kBAAkB,KAAa,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/D,qCAAqC;IAC9B,gBAAgB,KAAiB,OAAO,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACzD,wDAAwD;IACjD,aAAa,KAAiB,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,C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,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,UAAU,CAAC,MAAgB,EAAE,YAA4B,EAAE,SAAiB;QACxF,MAAM,QAAQ,GAAa,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,eAAe,CAAC,eAAe,EAAE,CAAC,CAAC;QACzF,OAAO,IAAI,kBAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAChF,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CAAC,QAAkB,EAAE,iBAA6B,EAAE,IAAY;QAClF,MAAM,aAAa,GAAkB;YACnC,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,KAAK,EAAE,iBAAiB;YACxB,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,iBAAiB,EAAE,IAAI,CAAC;YACxD,SAAS,EAAE,KAAK;SACjB,CAAC;QACF,OAAO,IAAI,eAAe,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;IACtD,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,MAAM,CAAC,QAAkB,EAAE,iBAA6B,EAAE,IAAY,EAAE,iBAAsE;QAC1J,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,iBAAiB,EAAE,IAAI,CAAC,CAAC;QAChE,MAAM,UAAU,GAAG,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAC7D,QAAQ,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;QACjD,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AA7DD,0CA6DC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Categories\r\n */\r\n\r\nimport { Id64, Id64String, JsonUtils } from \"@itwin/core-bentley\";\r\nimport {\r\n BisCodeSpec, CategoryProps, Code, CodeScopeProps, CodeSpec, ElementProps, Rank, SubCategoryAppearance, SubCategoryProps,\r\n} from \"@itwin/core-common\";\r\nimport { DefinitionElement } from \"./Element\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { CategoryOwnsSubCategories } from \"./NavigationRelationship\";\r\n\r\n/** Defines the appearance for graphics in Geometric elements\r\n * @public\r\n */\r\nexport class SubCategory extends DefinitionElement {\r\n /** @internal */\r\n public static override get className(): string { return \"SubCategory\"; }\r\n /** The Appearance parameters for this SubCategory */\r\n public appearance: SubCategoryAppearance;\r\n /** Optional description of this SubCategory. */\r\n public description?: string;\r\n\r\n /** @internal */\r\n public constructor(props: SubCategoryProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.appearance = new SubCategoryAppearance(props.appearance);\r\n this.description = JsonUtils.asString(props.description);\r\n }\r\n\r\n /** @internal */\r\n public override toJSON(): SubCategoryProps {\r\n const val = super.toJSON() as SubCategoryProps;\r\n val.appearance = this.appearance.toJSON();\r\n if (this.description && this.description.length > 0)\r\n val.description = this.description;\r\n return val;\r\n }\r\n\r\n /** Get the SubCategory's name (its Code value). */\r\n public getSubCategoryName(): string { return this.code.value; }\r\n /** Get the Id of the SubCategory. */\r\n public getSubCategoryId(): Id64String { return this.id; }\r\n /** Get the Id of this SubCategory's parent Category. */\r\n public getCategoryId(): Id64String { return this.parent ? this.parent.id : Id64.invalid; }\r\n /** Check if this is the default SubCategory of its parent Category. */\r\n public get isDefaultSubCategory(): boolean { return IModelDb.getDefaultSubCategoryId(this.getCategoryId()) === this.getSubCategoryId(); }\r\n\r\n /** Create a Code for a SubCategory given a name that is meant to be unique within the scope of the specified parent Category.\r\n * @param iModel The IModel\r\n * @param parentCategoryId The Id of the parent Category that owns the SubCategory and provides the scope for its name.\r\n * @param codeValue The name of the SubCategory\r\n */\r\n public static createCode(iModel: IModelDb, parentCategoryId: CodeScopeProps, codeValue: string): Code {\r\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.subCategory);\r\n return new Code({ spec: codeSpec.id, scope: parentCategoryId, value: codeValue });\r\n }\r\n\r\n /** Create a new SubCategory\r\n * @param iModelDb The iModel\r\n * @param parentCategoryId Create the new SubCategory as a child of this [[Category]]\r\n * @param name The name of the SubCategory\r\n * @param appearance The appearance settings to use for this SubCategory\r\n * @returns The newly constructed SubCategory element.\r\n * @throws [[IModelError]] if unable to create the element.\r\n */\r\n public static create(iModelDb: IModelDb, parentCategoryId: Id64String, name: string, appearance: SubCategoryAppearance.Props | SubCategoryAppearance): SubCategory {\r\n if (appearance instanceof SubCategoryAppearance)\r\n appearance = appearance.toJSON();\r\n\r\n const parentCategory = iModelDb.elements.getElement<Category>(parentCategoryId);\r\n const subCategoryProps: SubCategoryProps = {\r\n classFullName: this.classFullName,\r\n model: parentCategory.model,\r\n parent: new CategoryOwnsSubCategories(parentCategoryId),\r\n code: this.createCode(iModelDb, parentCategoryId, name),\r\n appearance,\r\n };\r\n return new SubCategory(subCategoryProps, iModelDb);\r\n }\r\n\r\n /** Insert a new SubCategory\r\n * @param iModelDb Insert into this iModel\r\n * @param parentCategoryId Insert the new SubCategory as a child of this Category\r\n * @param name The name of the SubCategory\r\n * @param appearance The appearance settings to use for this SubCategory\r\n * @returns The Id of the newly inserted SubCategory element.\r\n * @throws [[IModelError]] if unable to insert the element.\r\n */\r\n public static insert(iModelDb: IModelDb, parentCategoryId: Id64String, name: string, appearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\r\n const subCategory = this.create(iModelDb, parentCategoryId, name, appearance);\r\n return iModelDb.elements.insertElement(subCategory);\r\n }\r\n}\r\n\r\n/** A Category element is the target of the `category` member of [[GeometricElement]].\r\n * @public\r\n */\r\nexport class Category extends DefinitionElement implements CategoryProps {\r\n /** @internal */\r\n public static override get className(): string { return \"Category\"; }\r\n public rank: Rank = Rank.User;\r\n public description?: string;\r\n\r\n /** @internal */\r\n public constructor(props: CategoryProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.rank = JsonUtils.asInt(props.rank);\r\n this.description = JsonUtils.asString(props.description);\r\n }\r\n\r\n /** @internal */\r\n public override toJSON(): CategoryProps {\r\n const val = super.toJSON() as CategoryProps;\r\n val.rank = this.rank;\r\n if (this.description && this.description.length > 0)\r\n val.description = this.description;\r\n return val;\r\n }\r\n\r\n /** Get the Id of the default SubCategory for this Category. */\r\n public myDefaultSubCategoryId(): Id64String { return IModelDb.getDefaultSubCategoryId(this.id); }\r\n\r\n /** Set the appearance of the default SubCategory for this Category */\r\n public setDefaultAppearance(props: SubCategoryAppearance.Props | SubCategoryAppearance): void {\r\n if (props instanceof SubCategoryAppearance)\r\n props = props.toJSON();\r\n\r\n const subCat = this.iModel.elements.getElement<SubCategory>(this.myDefaultSubCategoryId());\r\n subCat.appearance = new SubCategoryAppearance(props);\r\n this.iModel.elements.updateElement(subCat);\r\n }\r\n}\r\n\r\n/** Categorizes 2d GeometricElements.\r\n * @public\r\n */\r\nexport class DrawingCategory extends Category {\r\n /** @internal */\r\n public static override get className(): string { return \"DrawingCategory\"; }\r\n\r\n /** Construct a DrawingCategory\r\n * @param opts The properties of the new DrawingCategory\r\n * @param iModel The IModelDb where the DrawingCategory may be inserted.\r\n * @internal\r\n */\r\n public constructor(opts: ElementProps, iModel: IModelDb) { super(opts, iModel); }\r\n\r\n /** Get the name of the CodeSpec that is used by DrawingCategory objects. */\r\n public static getCodeSpecName(): string { return BisCodeSpec.drawingCategory; }\r\n\r\n /** Looks up the CategoryId of a DrawingCategory by model and name */\r\n public static queryCategoryIdByName(iModel: IModelDb, scopeModelId: Id64String, categoryName: string): Id64String | undefined {\r\n const code: Code = DrawingCategory.createCode(iModel, scopeModelId, categoryName);\r\n return iModel.elements.queryElementIdByCode(code);\r\n }\r\n\r\n /** Create a Code for a DrawingCategory given a name that is meant to be unique within the scope of the specified DefinitionModel.\r\n * @param iModel The IModel\r\n * @param scopeModelId The Id of the DefinitionModel that contains the DrawingCategory and provides the scope for its name.\r\n * @param codeValue The name of the category\r\n * @return A drawing category Code\r\n */\r\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {\r\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(DrawingCategory.getCodeSpecName());\r\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\r\n }\r\n\r\n /** Create a new DrawingCategory\r\n * @param iModelDb The iModel\r\n * @param definitionModelId The [[DefinitionModel]]\r\n * @param name The name of the DrawingCategory\r\n * @returns The newly constructed DrawingCategory element.\r\n * @throws [[IModelError]] if unable to create the element.\r\n */\r\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string): DrawingCategory {\r\n const categoryProps: CategoryProps = {\r\n classFullName: this.classFullName,\r\n model: definitionModelId,\r\n code: this.createCode(iModelDb, definitionModelId, name),\r\n isPrivate: false,\r\n };\r\n return new DrawingCategory(categoryProps, iModelDb);\r\n }\r\n\r\n /** Insert a new DrawingCategory\r\n * @param iModelDb Insert into this iModel\r\n * @param definitionModelId Insert the new DrawingCategory into this [[DefinitionModel]]\r\n * @param name The name of the DrawingCategory\r\n * @param defaultAppearance The appearance settings to use for the default SubCategory of this DrawingCategory\r\n * @returns The Id of the newly inserted DrawingCategory element.\r\n * @throws [[IModelError]] if unable to insert the element.\r\n */\r\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\r\n const category = this.create(iModelDb, definitionModelId, name);\r\n const elements = iModelDb.elements;\r\n const categoryId = elements.insertElement(category);\r\n category.setDefaultAppearance(defaultAppearance);\r\n return categoryId;\r\n }\r\n}\r\n\r\n/** Categorizes SpatialElements. See [how to create a SpatialCategory]$(docs/learning/backend/CreateElements.md#SpatialCategory).\r\n * @public\r\n */\r\nexport class SpatialCategory extends Category {\r\n /** @internal */\r\n public static override get className(): string { return \"SpatialCategory\"; }\r\n /** Construct a SpatialCategory\r\n * @param opts The properties of the new SpatialCategory\r\n * @param iModel The IModelDb where the SpatialCategory may be inserted.\r\n * @internal\r\n */\r\n public constructor(opts: ElementProps, iModel: IModelDb) { super(opts, iModel); }\r\n\r\n /** Get the name of the CodeSpec that is used by SpatialCategory objects. */\r\n public static getCodeSpecName(): string { return BisCodeSpec.spatialCategory; }\r\n\r\n /** Looks up the CategoryId of a SpatialCategory by model and name */\r\n public static queryCategoryIdByName(iModel: IModelDb, scopeModelId: Id64String, categoryName: string): Id64String | undefined {\r\n const code: Code = SpatialCategory.createCode(iModel, scopeModelId, categoryName);\r\n return iModel.elements.queryElementIdByCode(code);\r\n }\r\n\r\n /** Create a Code for a SpatialCategory given a name that is meant to be unique within the scope of the specified DefinitionModel.\r\n * @param iModel The IModel\r\n * @param scopeModelId The Id of the DefinitionModel that contains the SpatialCategory and provides the scope for its name.\r\n * @param codeValue The name of the category\r\n * @return A spatial category Code\r\n */\r\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {\r\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(SpatialCategory.getCodeSpecName());\r\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\r\n }\r\n\r\n /** Create a new SpatialCategory\r\n * @param iModelDb The iModel\r\n * @param definitionModelId The [[DefinitionModel]]\r\n * @param name The name/CodeValue of the SpatialCategory\r\n * @returns The newly constructed SpatialCategory element.\r\n * @throws [[IModelError]] if unable to create the element.\r\n */\r\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string): SpatialCategory {\r\n const categoryProps: CategoryProps = {\r\n classFullName: this.classFullName,\r\n model: definitionModelId,\r\n code: this.createCode(iModelDb, definitionModelId, name),\r\n isPrivate: false,\r\n };\r\n return new SpatialCategory(categoryProps, iModelDb);\r\n }\r\n\r\n /** Insert a new SpatialCategory\r\n * @param iModelDb Insert into this iModel\r\n * @param definitionModelId Insert the new SpatialCategory into this DefinitionModel\r\n * @param name The name of the SpatialCategory\r\n * @param defaultAppearance The appearance settings to use for the default SubCategory of this SpatialCategory\r\n * @returns The Id of the newly inserted SpatialCategory element.\r\n * @throws [[IModelError]] if unable to insert the element.\r\n */\r\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\r\n const category = this.create(iModelDb, definitionModelId, name);\r\n const categoryId = iModelDb.elements.insertElement(category);\r\n category.setDefaultAppearance(defaultAppearance);\r\n return categoryId;\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChangedElementsDb.js","sourceRoot":"","sources":["../../src/ChangedElementsDb.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAiG;AACjG,oDAA6F;AAE7F,yDAAsD;AACtD,iCAAsC;AAEtC,6CAA0C;AAiB1C;;GAEG;AACH,MAAa,iBAAiB;IAG5B;QACE,IAAI,CAAC,SAAS,GAAG,IAAI,uBAAU,CAAC,QAAQ,CAAC,mBAAmB,EAAE,CAAC;IACjE,CAAC;IAEM,OAAO;QACZ,IAAI,CAAC,IAAI,CAAC,SAAS;YACjB,OAAO;QAET,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACK,SAAS,CAAC,SAAmB,EAAE,QAAgB;QACrD,MAAM,MAAM,GAAa,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC9E,IAAI,MAAM,KAAK,uBAAQ,CAAC,YAAY;YAClC,MAAM,IAAI,yBAAW,CAAC,MAAM,EAAE,wBAA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sD;IACtD,IAAW,MAAM,KAAc,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAE/D,mEAAmE;IAC5D,WAAW,CAAC,WAAmB,IAAa,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAEnG;;OAEG;IACI,OAAO;QACZ,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;IAC1B,CAAC;IAEM,WAAW;QAChB,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;IAC9B,CAAC;IAED,gBAAgB;IAChB,IAAW,QAAQ;QACjB,IAAI,CAAC,IAAI,CAAC,SAAS;YACjB,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,UAAU,EAAE,qDAAqD,CAAC,CAAC;QAExG,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF;AA3LD,8CA2LC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ChangedElementsDb\n */\n\nimport { AccessToken, DbResult, IDisposable, IModelStatus, OpenMode } from \"@itwin/core-bentley\";\nimport { ChangeData, ChangedElements, ChangedModels, IModelError } from \"@itwin/core-common\";\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\nimport { BriefcaseManager } from \"./BriefcaseManager\";\nimport { ECDbOpenMode } from \"./ECDb\";\nimport { IModelDb } from \"./IModelDb\";\nimport { IModelHost } from \"./IModelHost\";\n\n/**\n * Options for processChangesets function\n * @internal\n * */\nexport interface ProcessChangesetOptions {\n startChangesetId: string;\n endChangesetId: string;\n rulesetId: string;\n filterSpatial?: boolean;\n wantParents?: boolean;\n wantPropertyChecksums?: boolean;\n rulesetDir?: string;\n tempDir?: string;\n}\n\n/** An ChangedElementsDb file\n * @internal\n */\nexport class ChangedElementsDb implements IDisposable {\n private _nativeDb: IModelJsNative.ChangedElementsECDb | undefined;\n\n constructor() {\n this._nativeDb = new IModelHost.platform.ChangedElementsECDb();\n }\n\n public dispose(): void {\n if (!this._nativeDb)\n return;\n\n this.closeDb();\n this._nativeDb.dispose();\n this._nativeDb = undefined;\n }\n\n /** Create a ChangedElementsDb\n * @param pathName The path to the ECDb file to create.\n * @throws [IModelError]($common) if the operation failed.\n */\n private _createDb(briefcase: IModelDb, pathName: string): void {\n const status: DbResult = this.nativeDb.createDb(briefcase.nativeDb, pathName);\n if (status !== DbResult.BE_SQLITE_OK)\n throw new IModelError(status, \"Failed to created ECDb\");\n }\n\n /** Open the Changed Elements Db.\n * @param pathName The path to the ECDb file to open\n * @param openMode Open mode\n * @throws [IModelError]($common) if the operation failed.\n */\n private _openDb(pathName: string, openMode: ECDbOpenMode = ECDbOpenMode.Readonly): void {\n const nativeOpenMode = openMode === ECDbOpenMode.Readonly ? OpenMode.Readonly : OpenMode.ReadWrite;\n const tryUpgrade = openMode === ECDbOpenMode.FileUpgrade;\n const status = this.nativeDb.openDb(pathName, nativeOpenMode, tryUpgrade);\n if (status !== DbResult.BE_SQLITE_OK)\n throw new IModelError(status, \"Failed to open ECDb\");\n }\n\n /** Open the Changed Elements Db.\n * @param pathName The path to the ECDb file to open\n * @param openMode Open mode\n * @returns ChangedElementsDb\n */\n public static openDb(pathName: string, openMode: ECDbOpenMode = ECDbOpenMode.Readonly): ChangedElementsDb {\n const cacheDb = new ChangedElementsDb();\n cacheDb._openDb(pathName, openMode);\n return cacheDb;\n }\n\n /** Create the changed elements cache db\n * @param briefcase IModelDb to use\n * @param pathName The path to the ECDb file to create.\n * @returns The new cache db\n */\n public static createDb(briefcase: IModelDb, pathName: string): ChangedElementsDb {\n const cacheDb = new ChangedElementsDb();\n cacheDb._createDb(briefcase, pathName);\n return cacheDb;\n }\n\n /** Processes a range of changesets and adds it to the changed elements cache\n * @param requestContext The client request context\n * @param briefcase iModel briefcase to use\n * @param options Options for processing\n */\n public async processChangesets(accessToken: AccessToken, briefcase: IModelDb, options: ProcessChangesetOptions): Promise<DbResult> {\n const iModelId = briefcase.iModelId;\n const first = (await IModelHost.hubAccess.queryChangeset({ iModelId, changeset: { id: options.startChangesetId }, accessToken })).index;\n const end = (await IModelHost.hubAccess.queryChangeset({ iModelId, changeset: { id: options.endChangesetId }, accessToken })).index;\n const changesets = await IModelHost.hubAccess.downloadChangesets({ accessToken, iModelId, range: { first, end }, targetDir: BriefcaseManager.getChangeSetsPath(iModelId) });\n\n // ChangeSets need to be processed from newest to oldest\n changesets.reverse();\n const status = this.nativeDb.processChangesets(\n briefcase.nativeDb,\n changesets,\n options.rulesetId,\n options.filterSpatial,\n options.wantParents,\n options.wantPropertyChecksums,\n options.rulesetDir,\n options.tempDir,\n );\n if (status !== DbResult.BE_SQLITE_OK)\n throw new IModelError(status, \"Failed to process changesets\");\n return status;\n }\n\n /** Processes a range of changesets and adds it to the changed elements cache\n * This call will close the IModelDb object as it is required for processing and applying changesets\n * @param requestContext The client request context\n * @param briefcase iModel briefcase to use\n * @param options options for processing\n */\n public async processChangesetsAndRoll(accessToken: AccessToken, briefcase: IModelDb, options: ProcessChangesetOptions): Promise<DbResult> {\n const iModelId = briefcase.iModelId;\n const first = (await IModelHost.hubAccess.queryChangeset({ iModelId, changeset: { id: options.startChangesetId }, accessToken })).index;\n const end = (await IModelHost.hubAccess.queryChangeset({ iModelId, changeset: { id: options.endChangesetId }, accessToken })).index;\n const changesets = await IModelHost.hubAccess.downloadChangesets({ accessToken, iModelId, range: { first, end }, targetDir: BriefcaseManager.getChangeSetsPath(iModelId) });\n\n // ChangeSets need to be processed from newest to oldest\n changesets.reverse();\n // Close briefcase before doing processing and rolling briefcase\n const dbFilename = briefcase.pathName;\n const dbGuid = briefcase.iModelId;\n briefcase.close();\n // Process changesets\n const status = this.nativeDb.processChangesetsAndRoll(\n dbFilename,\n dbGuid,\n changesets,\n options.rulesetId,\n options.filterSpatial,\n options.wantParents,\n options.wantPropertyChecksums,\n options.rulesetDir,\n options.tempDir,\n );\n if (status !== DbResult.BE_SQLITE_OK)\n throw new IModelError(status, \"Failed to process changesets\");\n return status;\n }\n\n /** Get changed elements between two changesets\n * @param startChangesetId Start Changeset Id\n * @param endChangesetId End Changeset Id\n * @returns Returns the changed elements between the changesets provided\n * @throws [IModelError]($common) if the operation failed.\n */\n public getChangedElements(startChangesetId: string, endChangesetId: string): ChangedElements | undefined {\n const result = this.nativeDb.getChangedElements(startChangesetId, endChangesetId);\n if (result.error || !result.result)\n throw new IModelError(result.error ? result.error.status : -1, result.error ? result.error.message : \"Problem getting changed elements\");\n return (result.result.changedElements) as ChangedElements;\n }\n\n /** Get changed models between two changesets\n * @param startChangesetId Start Changeset Id\n * @param endChangesetId End Changeset Id\n * @returns Returns the changed models between the changesets provided\n * @throws [IModelError]($common) if the operation failed.\n */\n public getChangedModels(startChangesetId: string, endChangesetId: string): ChangedModels | undefined {\n const result = this.nativeDb.getChangedElements(startChangesetId, endChangesetId);\n if (result.error || !result.result)\n throw new IModelError(result.error ? result.error.status : -1, result.error ? result.error.message : \"Problem getting changed models\");\n return (result.result.changedModels) as ChangedModels;\n }\n\n /** Get changed models between two changesets\n * @param startChangesetId Start Changeset Id\n * @param endChangesetId End Changeset Id\n * @returns Returns the changed models between the changesets provided\n * @throws [IModelError]($common) if the operation failed.\n */\n public getChangeData(startChangesetId: string, endChangesetId: string): ChangeData | undefined {\n const result = this.nativeDb.getChangedElements(startChangesetId, endChangesetId);\n if (result.error)\n throw new IModelError(result.error.status, result.error.message);\n return result.result as ChangeData;\n }\n\n /** Returns true if the Changed Elements Db is open */\n public get isOpen(): boolean { return this.nativeDb.isOpen(); }\n\n /** Returns true if the cache already contains this changeset Id */\n public isProcessed(changesetId: string): boolean { return this.nativeDb.isProcessed(changesetId); }\n\n /** Close the Db after saving any uncommitted changes.\n * @throws [IModelError]($common) if the database is not open.\n */\n public closeDb(): void {\n this.nativeDb.closeDb();\n }\n\n public cleanCaches(): void {\n this.nativeDb.cleanCaches();\n }\n\n /** @internal */\n public get nativeDb(): IModelJsNative.ChangedElementsECDb {\n if (!this._nativeDb)\n throw new IModelError(IModelStatus.BadRequest, \"ChangedElementsDb object has already been disposed.\");\n\n return this._nativeDb;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ChangedElementsDb.js","sourceRoot":"","sources":["../../src/ChangedElementsDb.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAiG;AACjG,oDAA6F;AAE7F,yDAAsD;AACtD,iCAAsC;AAEtC,6CAA0C;AAiB1C;;GAEG;AACH,MAAa,iBAAiB;IAG5B;QACE,IAAI,CAAC,SAAS,GAAG,IAAI,uBAAU,CAAC,QAAQ,CAAC,mBAAmB,EAAE,CAAC;IACjE,CAAC;IAEM,OAAO;QACZ,IAAI,CAAC,IAAI,CAAC,SAAS;YACjB,OAAO;QAET,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACK,SAAS,CAAC,SAAmB,EAAE,QAAgB;QACrD,MAAM,MAAM,GAAa,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC9E,IAAI,MAAM,KAAK,uBAAQ,CAAC,YAAY;YAClC,MAAM,IAAI,yBAAW,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;IAC5D,CAAC;IAED;;;;OAIG;IACK,OAAO,CAAC,QAAgB,EAAE,WAAyB,mBAAY,CAAC,QAAQ;QAC9E,MAAM,cAAc,GAAG,QAAQ,KAAK,mBAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,uBAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,uBAAQ,CAAC,SAAS,CAAC;QACnG,MAAM,UAAU,GA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C,OAAO,EAAE,CAAC;IAC1B,CAAC;IAEM,WAAW;QAChB,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;IAC9B,CAAC;IAED,gBAAgB;IAChB,IAAW,QAAQ;QACjB,IAAI,CAAC,IAAI,CAAC,SAAS;YACjB,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,UAAU,EAAE,qDAAqD,CAAC,CAAC;QAExG,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF;AA3LD,8CA2LC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module ChangedElementsDb\r\n */\r\n\r\nimport { AccessToken, DbResult, IDisposable, IModelStatus, OpenMode } from \"@itwin/core-bentley\";\r\nimport { ChangeData, ChangedElements, ChangedModels, IModelError } from \"@itwin/core-common\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { BriefcaseManager } from \"./BriefcaseManager\";\r\nimport { ECDbOpenMode } from \"./ECDb\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { IModelHost } from \"./IModelHost\";\r\n\r\n/**\r\n * Options for processChangesets function\r\n * @internal\r\n * */\r\nexport interface ProcessChangesetOptions {\r\n startChangesetId: string;\r\n endChangesetId: string;\r\n rulesetId: string;\r\n filterSpatial?: boolean;\r\n wantParents?: boolean;\r\n wantPropertyChecksums?: boolean;\r\n rulesetDir?: string;\r\n tempDir?: string;\r\n}\r\n\r\n/** An ChangedElementsDb file\r\n * @internal\r\n */\r\nexport class ChangedElementsDb implements IDisposable {\r\n private _nativeDb: IModelJsNative.ChangedElementsECDb | undefined;\r\n\r\n constructor() {\r\n this._nativeDb = new IModelHost.platform.ChangedElementsECDb();\r\n }\r\n\r\n public dispose(): void {\r\n if (!this._nativeDb)\r\n return;\r\n\r\n this.closeDb();\r\n this._nativeDb.dispose();\r\n this._nativeDb = undefined;\r\n }\r\n\r\n /** Create a ChangedElementsDb\r\n * @param pathName The path to the ECDb file to create.\r\n * @throws [IModelError]($common) if the operation failed.\r\n */\r\n private _createDb(briefcase: IModelDb, pathName: string): void {\r\n const status: DbResult = this.nativeDb.createDb(briefcase.nativeDb, pathName);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to created ECDb\");\r\n }\r\n\r\n /** Open the Changed Elements Db.\r\n * @param pathName The path to the ECDb file to open\r\n * @param openMode Open mode\r\n * @throws [IModelError]($common) if the operation failed.\r\n */\r\n private _openDb(pathName: string, openMode: ECDbOpenMode = ECDbOpenMode.Readonly): void {\r\n const nativeOpenMode = openMode === ECDbOpenMode.Readonly ? OpenMode.Readonly : OpenMode.ReadWrite;\r\n const tryUpgrade = openMode === ECDbOpenMode.FileUpgrade;\r\n const status = this.nativeDb.openDb(pathName, nativeOpenMode, tryUpgrade);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to open ECDb\");\r\n }\r\n\r\n /** Open the Changed Elements Db.\r\n * @param pathName The path to the ECDb file to open\r\n * @param openMode Open mode\r\n * @returns ChangedElementsDb\r\n */\r\n public static openDb(pathName: string, openMode: ECDbOpenMode = ECDbOpenMode.Readonly): ChangedElementsDb {\r\n const cacheDb = new ChangedElementsDb();\r\n cacheDb._openDb(pathName, openMode);\r\n return cacheDb;\r\n }\r\n\r\n /** Create the changed elements cache db\r\n * @param briefcase IModelDb to use\r\n * @param pathName The path to the ECDb file to create.\r\n * @returns The new cache db\r\n */\r\n public static createDb(briefcase: IModelDb, pathName: string): ChangedElementsDb {\r\n const cacheDb = new ChangedElementsDb();\r\n cacheDb._createDb(briefcase, pathName);\r\n return cacheDb;\r\n }\r\n\r\n /** Processes a range of changesets and adds it to the changed elements cache\r\n * @param requestContext The client request context\r\n * @param briefcase iModel briefcase to use\r\n * @param options Options for processing\r\n */\r\n public async processChangesets(accessToken: AccessToken, briefcase: IModelDb, options: ProcessChangesetOptions): Promise<DbResult> {\r\n const iModelId = briefcase.iModelId;\r\n const first = (await IModelHost.hubAccess.queryChangeset({ iModelId, changeset: { id: options.startChangesetId }, accessToken })).index;\r\n const end = (await IModelHost.hubAccess.queryChangeset({ iModelId, changeset: { id: options.endChangesetId }, accessToken })).index;\r\n const changesets = await IModelHost.hubAccess.downloadChangesets({ accessToken, iModelId, range: { first, end }, targetDir: BriefcaseManager.getChangeSetsPath(iModelId) });\r\n\r\n // ChangeSets need to be processed from newest to oldest\r\n changesets.reverse();\r\n const status = this.nativeDb.processChangesets(\r\n briefcase.nativeDb,\r\n changesets,\r\n options.rulesetId,\r\n options.filterSpatial,\r\n options.wantParents,\r\n options.wantPropertyChecksums,\r\n options.rulesetDir,\r\n options.tempDir,\r\n );\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to process changesets\");\r\n return status;\r\n }\r\n\r\n /** Processes a range of changesets and adds it to the changed elements cache\r\n * This call will close the IModelDb object as it is required for processing and applying changesets\r\n * @param requestContext The client request context\r\n * @param briefcase iModel briefcase to use\r\n * @param options options for processing\r\n */\r\n public async processChangesetsAndRoll(accessToken: AccessToken, briefcase: IModelDb, options: ProcessChangesetOptions): Promise<DbResult> {\r\n const iModelId = briefcase.iModelId;\r\n const first = (await IModelHost.hubAccess.queryChangeset({ iModelId, changeset: { id: options.startChangesetId }, accessToken })).index;\r\n const end = (await IModelHost.hubAccess.queryChangeset({ iModelId, changeset: { id: options.endChangesetId }, accessToken })).index;\r\n const changesets = await IModelHost.hubAccess.downloadChangesets({ accessToken, iModelId, range: { first, end }, targetDir: BriefcaseManager.getChangeSetsPath(iModelId) });\r\n\r\n // ChangeSets need to be processed from newest to oldest\r\n changesets.reverse();\r\n // Close briefcase before doing processing and rolling briefcase\r\n const dbFilename = briefcase.pathName;\r\n const dbGuid = briefcase.iModelId;\r\n briefcase.close();\r\n // Process changesets\r\n const status = this.nativeDb.processChangesetsAndRoll(\r\n dbFilename,\r\n dbGuid,\r\n changesets,\r\n options.rulesetId,\r\n options.filterSpatial,\r\n options.wantParents,\r\n options.wantPropertyChecksums,\r\n options.rulesetDir,\r\n options.tempDir,\r\n );\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to process changesets\");\r\n return status;\r\n }\r\n\r\n /** Get changed elements between two changesets\r\n * @param startChangesetId Start Changeset Id\r\n * @param endChangesetId End Changeset Id\r\n * @returns Returns the changed elements between the changesets provided\r\n * @throws [IModelError]($common) if the operation failed.\r\n */\r\n public getChangedElements(startChangesetId: string, endChangesetId: string): ChangedElements | undefined {\r\n const result = this.nativeDb.getChangedElements(startChangesetId, endChangesetId);\r\n if (result.error || !result.result)\r\n throw new IModelError(result.error ? result.error.status : -1, result.error ? result.error.message : \"Problem getting changed elements\");\r\n return (result.result.changedElements) as ChangedElements;\r\n }\r\n\r\n /** Get changed models between two changesets\r\n * @param startChangesetId Start Changeset Id\r\n * @param endChangesetId End Changeset Id\r\n * @returns Returns the changed models between the changesets provided\r\n * @throws [IModelError]($common) if the operation failed.\r\n */\r\n public getChangedModels(startChangesetId: string, endChangesetId: string): ChangedModels | undefined {\r\n const result = this.nativeDb.getChangedElements(startChangesetId, endChangesetId);\r\n if (result.error || !result.result)\r\n throw new IModelError(result.error ? result.error.status : -1, result.error ? result.error.message : \"Problem getting changed models\");\r\n return (result.result.changedModels) as ChangedModels;\r\n }\r\n\r\n /** Get changed models between two changesets\r\n * @param startChangesetId Start Changeset Id\r\n * @param endChangesetId End Changeset Id\r\n * @returns Returns the changed models between the changesets provided\r\n * @throws [IModelError]($common) if the operation failed.\r\n */\r\n public getChangeData(startChangesetId: string, endChangesetId: string): ChangeData | undefined {\r\n const result = this.nativeDb.getChangedElements(startChangesetId, endChangesetId);\r\n if (result.error)\r\n throw new IModelError(result.error.status, result.error.message);\r\n return result.result as ChangeData;\r\n }\r\n\r\n /** Returns true if the Changed Elements Db is open */\r\n public get isOpen(): boolean { return this.nativeDb.isOpen(); }\r\n\r\n /** Returns true if the cache already contains this changeset Id */\r\n public isProcessed(changesetId: string): boolean { return this.nativeDb.isProcessed(changesetId); }\r\n\r\n /** Close the Db after saving any uncommitted changes.\r\n * @throws [IModelError]($common) if the database is not open.\r\n */\r\n public closeDb(): void {\r\n this.nativeDb.closeDb();\r\n }\r\n\r\n public cleanCaches(): void {\r\n this.nativeDb.cleanCaches();\r\n }\r\n\r\n /** @internal */\r\n public get nativeDb(): IModelJsNative.ChangedElementsECDb {\r\n if (!this._nativeDb)\r\n throw new IModelError(IModelStatus.BadRequest, \"ChangedElementsDb object has already been disposed.\");\r\n\r\n return this._nativeDb;\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClassRegistry.js","sourceRoot":"","sources":["../../src/ClassRegistry.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA2D;AAC3D,oDAAiE;AACjE,qCAAkC;AAElC,qCAA2C;AAC3C,6DAA0D;AAE1D;;GAEG;AACH,MAAa,aAAa;IAExB,gBAAgB;IACT,MAAM,CAAC,eAAe,CAAC,GAAQ,IAAI,OAAO,CAAC,GAAG,YAAY,yBAAW,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,KAAK,2BAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC/H,gBAAgB;IACT,MAAM,CAAC,yBAAyB,CAAC,SAAiB,IAAiB,OAAO,IAAI,yBAAW,CAAC,2BAAY,CAAC,QAAQ,EAAE,0BAA0B,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;IACjK,gBAAgB;IACT,MAAM,CAAC,QAAQ,CAAC,WAA0B,EAAE,MAAqB;QACtE,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC;QAC5B,MAAM,GAAG,GAAG,CAAC,GAAG,MAAM,CAAC,UAAU,IAAI,WAAW,CAAC,SAAS,EAAE,CAAC,C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C,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACvD,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,eAAe,CAAC,aAAqB,IAAI,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC;IACnH;;;;OAIG;IACI,MAAM,CAAC,qBAAqB,CAAC,MAAqB;QACvD,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;YAC9C,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM;gBAC5B,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SAClC;IACH,CAAC;;AApIH,sCAqIC;AApIyB,uBAAS,GAAG,IAAI,GAAG,EAAyB,CAAC;AAsIvE;;;GAGG;AACH,MAAa,gBAAgB;IAA7B;QACU,cAAS,GAAgC,IAAI,GAAG,EAA0B,CAAC;IAOrF,CAAC;IALC,wCAAwC;IACjC,IAAI,CAAC,aAAqB,IAAgC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC;IAE1H,gCAAgC;IACzB,GAAG,CAAC,aAAqB,EAAE,QAAwB,IAAU,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;CACjI;AARD,4CAQC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Schema\n */\n\nimport { IModelStatus, Logger } from \"@itwin/core-bentley\";\nimport { EntityMetaData, IModelError } from \"@itwin/core-common\";\nimport { Entity } from \"./Entity\";\nimport { IModelDb } from \"./IModelDb\";\nimport { Schema, Schemas } from \"./Schema\";\nimport { IModelSchemaLoader } from \"./IModelSchemaLoader\";\n\n/** The mapping between a BIS class name (in the form \"schema:class\") and its JavaScript constructor function\n * @public\n */\nexport class ClassRegistry {\n private static readonly _classMap = new Map<string, typeof Entity>();\n /** @internal */\n public static isNotFoundError(err: any) { return (err instanceof IModelError) && (err.errorNumber === IModelStatus.NotFound); }\n /** @internal */\n public static makeMetaDataNotFoundError(className: string): IModelError { return new IModelError(IModelStatus.NotFound, `metadata not found for ${className}`); }\n /** @internal */\n public static register(entityClass: typeof Entity, schema: typeof Schema) {\n entityClass.schema = schema;\n const key = (`${schema.schemaName}:${entityClass.className}`).toLowerCase();\n if (this._classMap.has(key)) {\n const errMsg = `Class ${key} is already registered. Make sure static className member is correct on JavaScript class ${entityClass.name}`;\n Logger.logError(\"core-frontend.classRegistry\", errMsg);\n throw new Error(errMsg);\n }\n\n this._classMap.set(key, entityClass);\n }\n\n /** Generate a proxy Schema for a domain that has not been registered. */\n private static generateProxySchema(domain: string, iModel: IModelDb): typeof Schema {\n const hasBehavior = undefined !== new IModelSchemaLoader(iModel).getSchema(domain).customAttributes?.get(\"BisCore.SchemaHasBehavior\");\n const schemaClass = class extends Schema {\n public static override get schemaName() { return domain; }\n public static override get missingRequiredBehavior() { return hasBehavior; }\n };\n\n Schemas.registerSchema(schemaClass); // register the class before we return it.\n return schemaClass;\n }\n\n /** Generate a JavaScript class from Entity metadata.\n * @param entityMetaData The Entity metadata that defines the class\n */\n private static generateClassForEntity(entityMetaData: EntityMetaData, iModel: IModelDb): typeof Entity {\n const name = entityMetaData.ecclass.split(\":\");\n const domainName = name[0];\n const className = name[1];\n\n if (0 === entityMetaData.baseClasses.length) // metadata must contain a superclass\n throw new IModelError(IModelStatus.BadArg, `class ${name} has no superclass`);\n\n // make sure schema exists\n let schema = Schemas.getRegisteredSchema(domainName);\n if (undefined === schema)\n schema = this.generateProxySchema(domainName, iModel); // no schema found, create it too\n\n // this method relies on the caller having previously created/registered all superclasses\n const superclass = this._classMap.get(entityMetaData.baseClasses[0].toLowerCase());\n if (undefined === superclass)\n throw new IModelError(IModelStatus.NotFound, `cannot find superclass for class ${name}`);\n\n const generatedClass = class extends superclass { public static override get className() { return className; } };\n // the above line creates an anonymous class. For help debugging, set the \"constructor.name\" property to be the same as the bisClassName.\n Object.defineProperty(generatedClass, \"name\", { get: () => className }); // this is the (only) way to change that readonly property.\n\n // if the schema is a proxy for a domain with behavior, throw exceptions for all protected operations\n if (schema.missingRequiredBehavior) {\n const throwError = () => { throw new IModelError(IModelStatus.WrongHandler, `Schema [${domainName}] not registered, but is marked with SchemaHasBehavior`); };\n superclass.protectedOperations.forEach((operation) => (generatedClass as any)[operation] = throwError);\n }\n\n this.register(generatedClass, schema); // register it before returning\n return generatedClass;\n }\n\n /** Register all of the classes found in the given module that derive from Entity. See the example in [[Schema]]\n * @param moduleObj The module to search for subclasses of Entity\n * @param schema The schema for all found classes\n */\n public static registerModule(moduleObj: any, schema: typeof Schema) {\n for (const thisMember in moduleObj) { // eslint-disable-line guard-for-in\n const thisClass = moduleObj[thisMember];\n if (thisClass.prototype instanceof Entity)\n this.register(thisClass, schema);\n }\n }\n\n /**\n * This function fetches the specified Entity from the imodel, generates a JavaScript class for it, and registers the generated\n * class. This function also ensures that all of the base classes of the Entity exist and are registered.\n */\n private static generateClass(classFullName: string, iModel: IModelDb): typeof Entity {\n const metadata: EntityMetaData | undefined = iModel.classMetaDataRegistry.find(classFullName);\n if (metadata === undefined || metadata.ecclass === undefined)\n throw this.makeMetaDataNotFoundError(classFullName);\n\n // Make sure we have all base classes registered.\n if (metadata.baseClasses && (0 !== metadata.baseClasses.length))\n this.getClass(metadata.baseClasses[0], iModel);\n\n // Now we can generate the class from the classDef.\n return this.generateClassForEntity(metadata, iModel);\n }\n\n /** Find a registered class by classFullName.\n * @param classFullName class to find\n * @param iModel The IModel that contains the class definitions\n * @returns The Entity class or undefined\n */\n public static findRegisteredClass(classFullName: string): typeof Entity | undefined {\n return this._classMap.get(classFullName.toLowerCase());\n }\n\n /** Get the Entity class for the specified Entity className.\n * @param classFullName The full BIS class name of the Entity\n * @param iModel The IModel that contains the class definitions\n * @returns The Entity class\n */\n public static getClass(classFullName: string, iModel: IModelDb): typeof Entity {\n const key = classFullName.toLowerCase();\n const ctor = this._classMap.get(key);\n return ctor ? ctor : this.generateClass(key, iModel);\n }\n\n /** Unregister a class, by name, if one is already registered.\n * This function is not normally needed, but is useful for cases where a generated *proxy* class needs to be replaced by the *real* class.\n * @param classFullName Name of the class to unregister\n * @return true if the class was unregistered\n * @internal\n */\n public static unregisterCLass(classFullName: string) { return this._classMap.delete(classFullName.toLowerCase()); }\n /** Unregister all classes from a schema.\n * This function is not normally needed, but is useful for cases where a generated *proxy* schema needs to be replaced by the *real* schema.\n * @param schema Name of the schema to unregister\n * @internal\n */\n public static unregisterClassesFrom(schema: typeof Schema) {\n for (const entry of Array.from(this._classMap)) {\n if (entry[1].schema === schema)\n this.unregisterCLass(entry[0]);\n }\n }\n}\n\n/**\n * A cache that records the mapping between class names and class metadata\n * @internal\n */\nexport class MetaDataRegistry {\n private _registry: Map<string, EntityMetaData> = new Map<string, EntityMetaData>();\n\n /** Get the specified Entity metadata */\n public find(classFullName: string): EntityMetaData | undefined { return this._registry.get(classFullName.toLowerCase()); }\n\n /** Add metadata to the cache */\n public add(classFullName: string, metaData: EntityMetaData): void { this._registry.set(classFullName.toLowerCase(), metaData); }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ClassRegistry.js","sourceRoot":"","sources":["../../src/ClassRegistry.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA2D;AAC3D,oDAAiE;AACjE,qCAAkC;AAElC,qCAA2C;AAC3C,6DAA0D;AAE1D;;GAEG;AACH,MAAa,aAAa;IAExB,gBAAgB;IACT,MAAM,CAAC,eAAe,CAAC,GA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AAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC;IAE1H,gCAAgC;IACzB,GAAG,CAAC,aAAqB,EAAE,QAAwB,IAAU,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;CACjI;AARD,4CAQC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Schema\r\n */\r\n\r\nimport { IModelStatus, Logger } from \"@itwin/core-bentley\";\r\nimport { EntityMetaData, IModelError } from \"@itwin/core-common\";\r\nimport { Entity } from \"./Entity\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { Schema, Schemas } from \"./Schema\";\r\nimport { IModelSchemaLoader } from \"./IModelSchemaLoader\";\r\n\r\n/** The mapping between a BIS class name (in the form \"schema:class\") and its JavaScript constructor function\r\n * @public\r\n */\r\nexport class ClassRegistry {\r\n private static readonly _classMap = new Map<string, typeof Entity>();\r\n /** @internal */\r\n public static isNotFoundError(err: any) { return (err instanceof IModelError) && (err.errorNumber === IModelStatus.NotFound); }\r\n /** @internal */\r\n public static makeMetaDataNotFoundError(className: string): IModelError { return new IModelError(IModelStatus.NotFound, `metadata not found for ${className}`); }\r\n /** @internal */\r\n public static register(entityClass: typeof Entity, schema: typeof Schema) {\r\n entityClass.schema = schema;\r\n const key = (`${schema.schemaName}:${entityClass.className}`).toLowerCase();\r\n if (this._classMap.has(key)) {\r\n const errMsg = `Class ${key} is already registered. Make sure static className member is correct on JavaScript class ${entityClass.name}`;\r\n Logger.logError(\"core-frontend.classRegistry\", errMsg);\r\n throw new Error(errMsg);\r\n }\r\n\r\n this._classMap.set(key, entityClass);\r\n }\r\n\r\n /** Generate a proxy Schema for a domain that has not been registered. */\r\n private static generateProxySchema(domain: string, iModel: IModelDb): typeof Schema {\r\n const hasBehavior = undefined !== new IModelSchemaLoader(iModel).getSchema(domain).customAttributes?.get(\"BisCore.SchemaHasBehavior\");\r\n const schemaClass = class extends Schema {\r\n public static override get schemaName() { return domain; }\r\n public static override get missingRequiredBehavior() { return hasBehavior; }\r\n };\r\n\r\n Schemas.registerSchema(schemaClass); // register the class before we return it.\r\n return schemaClass;\r\n }\r\n\r\n /** Generate a JavaScript class from Entity metadata.\r\n * @param entityMetaData The Entity metadata that defines the class\r\n */\r\n private static generateClassForEntity(entityMetaData: EntityMetaData, iModel: IModelDb): typeof Entity {\r\n const name = entityMetaData.ecclass.split(\":\");\r\n const domainName = name[0];\r\n const className = name[1];\r\n\r\n if (0 === entityMetaData.baseClasses.length) // metadata must contain a superclass\r\n throw new IModelError(IModelStatus.BadArg, `class ${name} has no superclass`);\r\n\r\n // make sure schema exists\r\n let schema = Schemas.getRegisteredSchema(domainName);\r\n if (undefined === schema)\r\n schema = this.generateProxySchema(domainName, iModel); // no schema found, create it too\r\n\r\n // this method relies on the caller having previously created/registered all superclasses\r\n const superclass = this._classMap.get(entityMetaData.baseClasses[0].toLowerCase());\r\n if (undefined === superclass)\r\n throw new IModelError(IModelStatus.NotFound, `cannot find superclass for class ${name}`);\r\n\r\n const generatedClass = class extends superclass { public static override get className() { return className; } };\r\n // the above line creates an anonymous class. For help debugging, set the \"constructor.name\" property to be the same as the bisClassName.\r\n Object.defineProperty(generatedClass, \"name\", { get: () => className }); // this is the (only) way to change that readonly property.\r\n\r\n // if the schema is a proxy for a domain with behavior, throw exceptions for all protected operations\r\n if (schema.missingRequiredBehavior) {\r\n const throwError = () => { throw new IModelError(IModelStatus.WrongHandler, `Schema [${domainName}] not registered, but is marked with SchemaHasBehavior`); };\r\n superclass.protectedOperations.forEach((operation) => (generatedClass as any)[operation] = throwError);\r\n }\r\n\r\n this.register(generatedClass, schema); // register it before returning\r\n return generatedClass;\r\n }\r\n\r\n /** Register all of the classes found in the given module that derive from Entity. See the example in [[Schema]]\r\n * @param moduleObj The module to search for subclasses of Entity\r\n * @param schema The schema for all found classes\r\n */\r\n public static registerModule(moduleObj: any, schema: typeof Schema) {\r\n for (const thisMember in moduleObj) { // eslint-disable-line guard-for-in\r\n const thisClass = moduleObj[thisMember];\r\n if (thisClass.prototype instanceof Entity)\r\n this.register(thisClass, schema);\r\n }\r\n }\r\n\r\n /**\r\n * This function fetches the specified Entity from the imodel, generates a JavaScript class for it, and registers the generated\r\n * class. This function also ensures that all of the base classes of the Entity exist and are registered.\r\n */\r\n private static generateClass(classFullName: string, iModel: IModelDb): typeof Entity {\r\n const metadata: EntityMetaData | undefined = iModel.classMetaDataRegistry.find(classFullName);\r\n if (metadata === undefined || metadata.ecclass === undefined)\r\n throw this.makeMetaDataNotFoundError(classFullName);\r\n\r\n // Make sure we have all base classes registered.\r\n if (metadata.baseClasses && (0 !== metadata.baseClasses.length))\r\n this.getClass(metadata.baseClasses[0], iModel);\r\n\r\n // Now we can generate the class from the classDef.\r\n return this.generateClassForEntity(metadata, iModel);\r\n }\r\n\r\n /** Find a registered class by classFullName.\r\n * @param classFullName class to find\r\n * @param iModel The IModel that contains the class definitions\r\n * @returns The Entity class or undefined\r\n */\r\n public static findRegisteredClass(classFullName: string): typeof Entity | undefined {\r\n return this._classMap.get(classFullName.toLowerCase());\r\n }\r\n\r\n /** Get the Entity class for the specified Entity className.\r\n * @param classFullName The full BIS class name of the Entity\r\n * @param iModel The IModel that contains the class definitions\r\n * @returns The Entity class\r\n */\r\n public static getClass(classFullName: string, iModel: IModelDb): typeof Entity {\r\n const key = classFullName.toLowerCase();\r\n const ctor = this._classMap.get(key);\r\n return ctor ? ctor : this.generateClass(key, iModel);\r\n }\r\n\r\n /** Unregister a class, by name, if one is already registered.\r\n * This function is not normally needed, but is useful for cases where a generated *proxy* class needs to be replaced by the *real* class.\r\n * @param classFullName Name of the class to unregister\r\n * @return true if the class was unregistered\r\n * @internal\r\n */\r\n public static unregisterCLass(classFullName: string) { return this._classMap.delete(classFullName.toLowerCase()); }\r\n /** Unregister all classes from a schema.\r\n * This function is not normally needed, but is useful for cases where a generated *proxy* schema needs to be replaced by the *real* schema.\r\n * @param schema Name of the schema to unregister\r\n * @internal\r\n */\r\n public static unregisterClassesFrom(schema: typeof Schema) {\r\n for (const entry of Array.from(this._classMap)) {\r\n if (entry[1].schema === schema)\r\n this.unregisterCLass(entry[0]);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * A cache that records the mapping between class names and class metadata\r\n * @internal\r\n */\r\nexport class MetaDataRegistry {\r\n private _registry: Map<string, EntityMetaData> = new Map<string, EntityMetaData>();\r\n\r\n /** Get the specified Entity metadata */\r\n public find(classFullName: string): EntityMetaData | undefined { return this._registry.get(classFullName.toLowerCase()); }\r\n\r\n /** Add metadata to the cache */\r\n public add(classFullName: string, metaData: EntityMetaData): void { this._registry.set(classFullName.toLowerCase(), metaData); }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudStorageBackend.js","sourceRoot":"","sources":["../../src/CloudStorageBackend.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,mCAA+C;AAC/C,6BAA6B;AAC7B,6CAA6C;AAC7C,sDAAyD;AACzD,oDAG4B;AAC5B,mEAAgE;AAChE,6CAA0C;AAgB1C,YAAY;AACZ,MAAsB,mBAAmB;IAChC,UAAU,KAAW,CAAC;IACtB,SAAS,KAAW,CAAC;IAIrB,KAAK,CAAC,QAAQ,CAAC,KAAa,IAAmC,OAAO,SAAS,CAAC,CAAC,CAAC;IAE/E,cAAc,CAAC,EAAmC;QAC1D,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;IAC9C,CAAC;CACF;AAXD,kDAWC;AAED,YAAY;AACZ,MAAa,gBAAiB,SAAQ,mBAAmB;IAIvD,YAAmB,W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WAAW,CAAC,CAAC;IACzD,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,UAA0B,EAAE,MAAc,EAAE,SAAiB,EAAE,OAAmB,EAAE,IAAwB,EAAE,QAAiB;QACpJ,MAAM,EAAE,GAA0B,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QAE1E,MAAM,KAAK,GAAG,mCAAqB,CAAC,QAAQ,EAAE,CAAC;QAC/C,MAAM,YAAY,GAAG,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;QACjD,MAAM,WAAW,GAAG,KAAK,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;QAC/C,MAAM,GAAG,GAAG,YAAY,GAAG,WAAW,CAAC;QAEvC,IAAI,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC;YAC9B,OAAO;QAET,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;QACrF,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACtC,MAAM,OAAO,CAAC;IAChB,CAAC;CACF;AA1CD,4DA0CC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { PassThrough, Readable } from \"stream\";\nimport * as zlib from \"zlib\";\nimport * as Azure from \"@azure/storage-blob\";\nimport { Logger, PerfLogger } from \"@itwin/core-bentley\";\nimport {\n BentleyStatus, CloudStorageContainerDescriptor, CloudStorageContainerUrl, CloudStorageProvider, CloudStorageTileCache, IModelError, IModelRpcProps,\n TileContentIdentifier,\n} from \"@itwin/core-common\";\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { IModelHost } from \"./IModelHost\";\n\n/** @beta */\nexport interface CloudStorageServiceCredentials {\n service: \"azure\" | \"alicloud\" | \"external\";\n account: string;\n accessKey: string;\n}\n\n/** @beta */\nexport interface CloudStorageUploadOptions {\n type?: string;\n cacheControl?: string;\n contentEncoding?: \"gzip\";\n}\n\n/** @beta */\nexport abstract class CloudStorageService {\n public initialize(): void { }\n public terminate(): void { }\n public abstract id: CloudStorageProvider;\n public abstract obtainContainerUrl(id: CloudStorageContainerDescriptor, expiry: Date, clientIp?: string): CloudStorageContainerUrl;\n public abstract upload(container: string, name: string, data: Uint8Array, options?: CloudStorageUploadOptions, metadata?: object): Promise<string>;\n public async download(_name: string): Promise<Readable | undefined> { return undefined; }\n\n protected makeDescriptor(id: CloudStorageContainerDescriptor) {\n return { name: id.name, provider: this.id };\n }\n}\n\n/** @beta */\nexport class AzureBlobStorage extends CloudStorageService {\n private _service: Azure.BlobServiceClient;\n private _credential: Azure.StorageSharedKeyCredential;\n\n public constructor(credentials: CloudStorageServiceCredentials) {\n super();\n\n if (credentials.service !== \"azure\" || !credentials.account || !credentials.accessKey) {\n throw new IModelError(BentleyStatus.ERROR, \"Invalid credentials for Azure blob storage.\");\n }\n\n this._credential = new Azure.StorageSharedKeyCredential(credentials.account, credentials.accessKey);\n const options: Azure.StoragePipelineOptions = {};\n const pipeline = Azure.newPipeline(this._credential, options);\n this._service = new Azure.BlobServiceClient(`https://${credentials.account}.blob.core.windows.net`, pipeline);\n }\n\n public readonly id = CloudStorageProvider.Azure;\n\n public obtainContainerUrl(id: CloudStorageContainerDescriptor, expiry: Date, clientIp?: string): CloudStorageContainerUrl {\n const policy: Azure.BlobSASSignatureValues = {\n containerName: id.name,\n permissions: Azure.ContainerSASPermissions.parse(\"rl\"),\n expiresOn: expiry,\n };\n\n if (clientIp && clientIp !== \"localhost\" && clientIp !== \"127.0.0.1\" && clientIp !== \"::1\") {\n policy.ipRange = { start: clientIp };\n }\n\n const token = Azure.generateBlobSASQueryParameters(policy, this._credential);\n\n const url: CloudStorageContainerUrl = {\n descriptor: this.makeDescriptor(id),\n valid: 0,\n expires: expiry.getTime(),\n url: `https://${this._credential.accountName}.blob.core.windows.net/${id.name}?${token.toString()}`,\n };\n\n return url;\n }\n\n public async ensureContainer(name: string): Promise<void> {\n try {\n const container = this._service.getContainerClient(name);\n await container.create();\n return;\n } catch (maybeErr) {\n try {\n const err = maybeErr as Azure.RestError;\n if (err.statusCode === 409 && err.code === \"ContainerAlreadyExists\") {\n return;\n }\n } catch { }\n\n if (typeof (maybeErr) !== \"undefined\" && maybeErr) {\n throw maybeErr;\n }\n\n throw new IModelError(BentleyStatus.ERROR, `Unable to create container \"${name}\".`);\n }\n }\n\n public async upload(container: string, name: string, data: Uint8Array, options?: CloudStorageUploadOptions, metadata?: object): Promise<string> {\n try {\n await this.ensureContainer(container);\n\n const containerClient = this._service.getContainerClient(container);\n const blocks = containerClient.getBlockBlobClient(name);\n const blobHTTPHeaders = {\n blobContentType: options?.type ?? \"application/octet-stream\",\n blobCacheControl: options?.cacheControl ?? \"private, max-age=31536000, immutable\",\n };\n\n const blobOptions: Azure.BlockBlobUploadStreamOptions = metadata ?\n {\n blobHTTPHeaders,\n metadata: { ...metadata },\n } : {\n blobHTTPHeaders,\n };\n\n const dataStream = new PassThrough();\n dataStream.end(data);\n\n let source: Readable;\n\n if (options && options.contentEncoding === \"gzip\") {\n blobOptions.blobHTTPHeaders!.blobContentEncoding = options.contentEncoding;\n const compressor = zlib.createGzip();\n source = dataStream.pipe(compressor);\n } else {\n source = dataStream;\n }\n\n const blockSize = 100 * 1024 * 1024;\n const concurrency = 1;\n const result = await blocks.uploadStream(source, blockSize, concurrency, blobOptions);\n return result.etag ?? \"\";\n } catch (maybeErr) {\n if (typeof (maybeErr) !== \"undefined\" && maybeErr) {\n throw maybeErr;\n }\n\n throw new IModelError(BentleyStatus.ERROR, `Unable to upload \"${name}\".`);\n }\n }\n}\n\n/** @internal */\nexport class CloudStorageTileUploader {\n private _activeUploads: Map<string, Promise<void>> = new Map();\n\n public get activeUploads(): Iterable<Promise<void>> {\n return this._activeUploads.values();\n }\n\n private async uploadToCache(id: TileContentIdentifier, content: Uint8Array, containerKey: string, resourceKey: string, metadata?: object,) {\n await new Promise((resolve) => setTimeout(resolve));\n\n try {\n const options: CloudStorageUploadOptions = {};\n if (IModelHost.compressCachedTiles) {\n options.contentEncoding = \"gzip\";\n }\n\n const perfInfo = { ...id.tokenProps, treeId: id.treeId, contentId: id.contentId, size: content.byteLength, compress: IModelHost.compressCachedTiles };\n const perfLogger = new PerfLogger(\"Uploading tile to external tile cache\", () => perfInfo);\n await IModelHost.tileCacheService.upload(containerKey, resourceKey, content, options, metadata);\n perfLogger.dispose();\n } catch (err) {\n Logger.logError(BackendLoggerCategory.IModelTileUpload, (err instanceof Error) ? err.toString() : JSON.stringify(err));\n }\n\n this._activeUploads.delete(containerKey + resourceKey);\n }\n\n public async cacheTile(tokenProps: IModelRpcProps, treeId: string, contentId: string, content: Uint8Array, guid: string | undefined, metadata?: object): Promise<void> {\n const id: TileContentIdentifier = { tokenProps, treeId, contentId, guid };\n\n const cache = CloudStorageTileCache.getCache();\n const containerKey = cache.formContainerName(id);\n const resourceKey = cache.formResourceName(id);\n const key = containerKey + resourceKey;\n\n if (this._activeUploads.has(key))\n return;\n\n const promise = this.uploadToCache(id, content, containerKey, resourceKey, metadata);\n this._activeUploads.set(key, promise);\n await promise;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CloudStorageBackend.js","sourceRoot":"","sources":["../../src/CloudStorageBackend.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,mCAA+C;AAC/C,6BAA6B;AAC7B,6CAA6C;AAC7C,sDAAyD;AACzD,oDAG4B;AAC5B,mEAAgE;AAChE,6CAA0C;AAgB1C,YAAY;AACZ,MAAsB,mBAAmB;IAChC,UAAU,KAAW,CAAC;IACtB,SAAS,KAAW,CAAC;IAIrB,KAAK,CAAC,QAAQ,CAAC,KAAa,IAAmC,OAAO,SAAS,CAAC,CAAC,CAAC;IAE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C,gBAAgB,EAAE,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;SACxH;QAED,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,YAAY,GAAG,WAAW,CAAC,CAAC;IACzD,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,UAA0B,EAAE,MAAc,EAAE,SAAiB,EAAE,OAAmB,EAAE,IAAwB,EAAE,QAAiB;QACpJ,MAAM,EAAE,GAA0B,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QAE1E,MAAM,KAAK,GAAG,mCAAqB,CAAC,QAAQ,EAAE,CAAC;QAC/C,MAAM,YAAY,GAAG,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;QACjD,MAAM,WAAW,GAAG,KAAK,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;QAC/C,MAAM,GAAG,GAAG,YAAY,GAAG,WAAW,CAAC;QAEvC,IAAI,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC;YAC9B,OAAO;QAET,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;QACrF,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACtC,MAAM,OAAO,CAAC;IAChB,CAAC;CACF;AA1CD,4DA0CC","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 { PassThrough, Readable } from \"stream\";\r\nimport * as zlib from \"zlib\";\r\nimport * as Azure from \"@azure/storage-blob\";\r\nimport { Logger, PerfLogger } from \"@itwin/core-bentley\";\r\nimport {\r\n BentleyStatus, CloudStorageContainerDescriptor, CloudStorageContainerUrl, CloudStorageProvider, CloudStorageTileCache, IModelError, IModelRpcProps,\r\n TileContentIdentifier,\r\n} from \"@itwin/core-common\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { IModelHost } from \"./IModelHost\";\r\n\r\n/** @beta */\r\nexport interface CloudStorageServiceCredentials {\r\n service: \"azure\" | \"alicloud\" | \"external\";\r\n account: string;\r\n accessKey: string;\r\n}\r\n\r\n/** @beta */\r\nexport interface CloudStorageUploadOptions {\r\n type?: string;\r\n cacheControl?: string;\r\n contentEncoding?: \"gzip\";\r\n}\r\n\r\n/** @beta */\r\nexport abstract class CloudStorageService {\r\n public initialize(): void { }\r\n public terminate(): void { }\r\n public abstract id: CloudStorageProvider;\r\n public abstract obtainContainerUrl(id: CloudStorageContainerDescriptor, expiry: Date, clientIp?: string): CloudStorageContainerUrl;\r\n public abstract upload(container: string, name: string, data: Uint8Array, options?: CloudStorageUploadOptions, metadata?: object): Promise<string>;\r\n public async download(_name: string): Promise<Readable | undefined> { return undefined; }\r\n\r\n protected makeDescriptor(id: CloudStorageContainerDescriptor) {\r\n return { name: id.name, provider: this.id };\r\n }\r\n}\r\n\r\n/** @beta */\r\nexport class AzureBlobStorage extends CloudStorageService {\r\n private _service: Azure.BlobServiceClient;\r\n private _credential: Azure.StorageSharedKeyCredential;\r\n\r\n public constructor(credentials: CloudStorageServiceCredentials) {\r\n super();\r\n\r\n if (credentials.service !== \"azure\" || !credentials.account || !credentials.accessKey) {\r\n throw new IModelError(BentleyStatus.ERROR, \"Invalid credentials for Azure blob storage.\");\r\n }\r\n\r\n this._credential = new Azure.StorageSharedKeyCredential(credentials.account, credentials.accessKey);\r\n const options: Azure.StoragePipelineOptions = {};\r\n const pipeline = Azure.newPipeline(this._credential, options);\r\n this._service = new Azure.BlobServiceClient(`https://${credentials.account}.blob.core.windows.net`, pipeline);\r\n }\r\n\r\n public readonly id = CloudStorageProvider.Azure;\r\n\r\n public obtainContainerUrl(id: CloudStorageContainerDescriptor, expiry: Date, clientIp?: string): CloudStorageContainerUrl {\r\n const policy: Azure.BlobSASSignatureValues = {\r\n containerName: id.name,\r\n permissions: Azure.ContainerSASPermissions.parse(\"rl\"),\r\n expiresOn: expiry,\r\n };\r\n\r\n if (clientIp && clientIp !== \"localhost\" && clientIp !== \"127.0.0.1\" && clientIp !== \"::1\") {\r\n policy.ipRange = { start: clientIp };\r\n }\r\n\r\n const token = Azure.generateBlobSASQueryParameters(policy, this._credential);\r\n\r\n const url: CloudStorageContainerUrl = {\r\n descriptor: this.makeDescriptor(id),\r\n valid: 0,\r\n expires: expiry.getTime(),\r\n url: `https://${this._credential.accountName}.blob.core.windows.net/${id.name}?${token.toString()}`,\r\n };\r\n\r\n return url;\r\n }\r\n\r\n public async ensureContainer(name: string): Promise<void> {\r\n try {\r\n const container = this._service.getContainerClient(name);\r\n await container.create();\r\n return;\r\n } catch (maybeErr) {\r\n try {\r\n const err = maybeErr as Azure.RestError;\r\n if (err.statusCode === 409 && err.code === \"ContainerAlreadyExists\") {\r\n return;\r\n }\r\n } catch { }\r\n\r\n if (typeof (maybeErr) !== \"undefined\" && maybeErr) {\r\n throw maybeErr;\r\n }\r\n\r\n throw new IModelError(BentleyStatus.ERROR, `Unable to create container \"${name}\".`);\r\n }\r\n }\r\n\r\n public async upload(container: string, name: string, data: Uint8Array, options?: CloudStorageUploadOptions, metadata?: object): Promise<string> {\r\n try {\r\n await this.ensureContainer(container);\r\n\r\n const containerClient = this._service.getContainerClient(container);\r\n const blocks = containerClient.getBlockBlobClient(name);\r\n const blobHTTPHeaders = {\r\n blobContentType: options?.type ?? \"application/octet-stream\",\r\n blobCacheControl: options?.cacheControl ?? \"private, max-age=31536000, immutable\",\r\n };\r\n\r\n const blobOptions: Azure.BlockBlobUploadStreamOptions = metadata ?\r\n {\r\n blobHTTPHeaders,\r\n metadata: { ...metadata },\r\n } : {\r\n blobHTTPHeaders,\r\n };\r\n\r\n const dataStream = new PassThrough();\r\n dataStream.end(data);\r\n\r\n let source: Readable;\r\n\r\n if (options && options.contentEncoding === \"gzip\") {\r\n blobOptions.blobHTTPHeaders!.blobContentEncoding = options.contentEncoding;\r\n const compressor = zlib.createGzip();\r\n source = dataStream.pipe(compressor);\r\n } else {\r\n source = dataStream;\r\n }\r\n\r\n const blockSize = 100 * 1024 * 1024;\r\n const concurrency = 1;\r\n const result = await blocks.uploadStream(source, blockSize, concurrency, blobOptions);\r\n return result.etag ?? \"\";\r\n } catch (maybeErr) {\r\n if (typeof (maybeErr) !== \"undefined\" && maybeErr) {\r\n throw maybeErr;\r\n }\r\n\r\n throw new IModelError(BentleyStatus.ERROR, `Unable to upload \"${name}\".`);\r\n }\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class CloudStorageTileUploader {\r\n private _activeUploads: Map<string, Promise<void>> = new Map();\r\n\r\n public get activeUploads(): Iterable<Promise<void>> {\r\n return this._activeUploads.values();\r\n }\r\n\r\n private async uploadToCache(id: TileContentIdentifier, content: Uint8Array, containerKey: string, resourceKey: string, metadata?: object,) {\r\n await new Promise((resolve) => setTimeout(resolve));\r\n\r\n try {\r\n const options: CloudStorageUploadOptions = {};\r\n if (IModelHost.compressCachedTiles) {\r\n options.contentEncoding = \"gzip\";\r\n }\r\n\r\n const perfInfo = { ...id.tokenProps, treeId: id.treeId, contentId: id.contentId, size: content.byteLength, compress: IModelHost.compressCachedTiles };\r\n const perfLogger = new PerfLogger(\"Uploading tile to external tile cache\", () => perfInfo);\r\n await IModelHost.tileCacheService.upload(containerKey, resourceKey, content, options, metadata);\r\n perfLogger.dispose();\r\n } catch (err) {\r\n Logger.logError(BackendLoggerCategory.IModelTileUpload, (err instanceof Error) ? err.toString() : JSON.stringify(err));\r\n }\r\n\r\n this._activeUploads.delete(containerKey + resourceKey);\r\n }\r\n\r\n public async cacheTile(tokenProps: IModelRpcProps, treeId: string, contentId: string, content: Uint8Array, guid: string | undefined, metadata?: object): Promise<void> {\r\n const id: TileContentIdentifier = { tokenProps, treeId, contentId, guid };\r\n\r\n const cache = CloudStorageTileCache.getCache();\r\n const containerKey = cache.formContainerName(id);\r\n const resourceKey = cache.formResourceName(id);\r\n const key = containerKey + resourceKey;\r\n\r\n if (this._activeUploads.has(key))\r\n return;\r\n\r\n const promise = this.uploadToCache(id, content, containerKey, resourceKey, metadata);\r\n this._activeUploads.set(key, promise);\r\n await promise;\r\n }\r\n}\r\n"]}
|
package/lib/cjs/CodeSpecs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeSpecs.js","sourceRoot":"","sources":["../../src/CodeSpecs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA+E;AAC/E,oDAA0E;AAI1E;;GAEG;AACH,MAAa,SAAS;IAIpB,YAAY,MAAgB;QAFpB,qBAAgB,GAAe,EAAE,CAAC;QAGxC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,MAAM,CAAC,aAAa,EAAE,EAAE;YAC1B,MAAM,CAAC,kBAAkB,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;SAC/E;IACH,CAAC;IAED,8DAA8D;IACvD,OAAO,CAAC,IAAY;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,4DAA4D,EAAE,CAAC,IAAoB,EAAE,EAAE;YAC/H,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAC9B,IAAI,uBAAQ,CAAC,aAAa,KAAK,IAAI,CAAC,IAAI,EAAE;gBACxC,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,QAAQ,EAAE,oBAAoB,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;YACvF,OAAO,IAAI,CAAC,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B,IAAI,uBAAQ,CAAC,aAAa,KAAK,IAAI,CAAC,IAAI,EAAE;gBACxC,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;YAEtE,MAAM,GAAG,GAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;YAC/B,OAAO,sBAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC;QAC7F,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAxHD,8BAwHC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Codes\n */\n\nimport { DbResult, Id64, Id64String, IModelStatus } from \"@itwin/core-bentley\";\nimport { CodeScopeSpec, CodeSpec, IModelError } from \"@itwin/core-common\";\nimport { ECSqlStatement } from \"./ECSqlStatement\";\nimport { IModelDb } from \"./IModelDb\";\n\n/** Manages [CodeSpecs]($docs/BIS/intro/element-fundamentals.md#codespec) within an [[IModelDb]]\n * @public\n */\nexport class CodeSpecs {\n private _imodel: IModelDb;\n private _loadedCodeSpecs: CodeSpec[] = [];\n\n constructor(imodel: IModelDb) {\n this._imodel = imodel;\n if (imodel.isBriefcaseDb()) {\n imodel.onChangesetApplied.addListener(() => this._loadedCodeSpecs.length = 0);\n }\n }\n\n /** Look up the Id of the CodeSpec with the specified name. */\n public queryId(name: string): Id64String {\n return this._imodel.withPreparedStatement(\"SELECT ECInstanceId FROM BisCore.CodeSpec WHERE Name=:name\", (stmt: ECSqlStatement) => {\n stmt.bindString(\"name\", name);\n if (DbResult.BE_SQLITE_ROW !== stmt.step())\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\", () => ({ name }));\n return stmt.getValue(0).getId();\n });\n }\n\n /** Look up a CodeSpec by Id. The CodeSpec will be loaded from the database if necessary.\n * @param codeSpecId The Id of the CodeSpec to load\n * @returns The CodeSpec with the specified Id\n * @throws [[IModelError]] if the Id is invalid or if no CodeSpec with that Id could be found.\n */\n public getById(codeSpecId: Id64String): CodeSpec {\n if (Id64.isInvalid(codeSpecId))\n throw new IModelError(IModelStatus.InvalidId, \"Invalid codeSpecId\");\n\n // good chance it is already loaded - check there before running a query\n const found: CodeSpec | undefined = this._loadedCodeSpecs.find((codeSpec) => codeSpec.id === codeSpecId);\n if (found !== undefined)\n return found;\n\n // must load this codespec\n const loadedCodeSpec = this.load(codeSpecId);\n this._loadedCodeSpecs.push(loadedCodeSpec);\n return loadedCodeSpec;\n }\n\n /** Returns true if the IModelDb has a CodeSpec of the specified Id. */\n public hasId(codeSpecId: Id64String): boolean {\n try {\n return undefined !== this.getById(codeSpecId);\n } catch (error) {\n return false;\n }\n }\n\n /** Look up a CodeSpec by name. The CodeSpec will be loaded from the database if necessary.\n * @param name The name of the CodeSpec to load\n * @returns The CodeSpec with the specified name\n * @throws [[IModelError]] if no CodeSpec with the specified name could be found.\n */\n public getByName(name: string): CodeSpec {\n // good chance it is already loaded - check there before running a query\n const found: CodeSpec | undefined = this._loadedCodeSpecs.find((codeSpec) => codeSpec.name === name);\n if (found !== undefined)\n return found;\n const codeSpecId = this.queryId(name);\n if (codeSpecId === undefined)\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\", () => ({ name }));\n return this.getById(codeSpecId);\n }\n\n /** Returns true if the IModelDb has a CodeSpec of the specified name. */\n public hasName(name: string): boolean {\n try {\n return undefined !== this.getByName(name);\n } catch (error) {\n return false;\n }\n }\n\n /** Add a new CodeSpec to the iModel.\n * @param codeSpec The CodeSpec to insert\n * @returns The Id of the persistent CodeSpec.\n * @note If successful, this method will assign a valid CodeSpecId to the supplied CodeSpec\n * @throws IModelError if the insertion fails\n */\n public insert(codeSpec: CodeSpec): Id64String;\n /** Add a new CodeSpec to the IModelDb.\n * @param name The name for the new CodeSpec.\n * @param scopeType The scope type\n * @returns The Id of the persistent CodeSpec.\n * @throws IModelError if the insertion fails\n */\n public insert(name: string, scopeType: CodeScopeSpec.Type): Id64String;\n public insert(codeSpecOrName: CodeSpec | string, scopeType?: CodeScopeSpec.Type): Id64String {\n if (codeSpecOrName instanceof CodeSpec) {\n const codeSpec = codeSpecOrName;\n const id: Id64String = this._imodel.insertCodeSpec(codeSpec);\n codeSpec.id = id;\n return id;\n }\n if (typeof codeSpecOrName === \"string\") {\n const name = codeSpecOrName;\n if (scopeType)\n return this._imodel.insertCodeSpec(CodeSpec.create(this._imodel, name, scopeType));\n }\n throw new IModelError(IModelStatus.BadArg, \"Invalid argument\");\n }\n\n /** Load a CodeSpec from the iModel\n * @param id The persistent Id of the CodeSpec to load\n */\n public load(id: Id64String): CodeSpec {\n if (Id64.isInvalid(id))\n throw new IModelError(IModelStatus.InvalidId, \"Invalid codeSpecId\");\n\n return this._imodel.withPreparedStatement(\"SELECT name,jsonProperties FROM BisCore.CodeSpec WHERE ECInstanceId=?\", (stmt: ECSqlStatement) => {\n stmt.bindId(1, id);\n if (DbResult.BE_SQLITE_ROW !== stmt.step())\n throw new IModelError(IModelStatus.InvalidId, \"Invalid codeSpecId\");\n\n const row: any = stmt.getRow();\n return CodeSpec.createFromJson(this._imodel, id, row.name, JSON.parse(row.jsonProperties));\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CodeSpecs.js","sourceRoot":"","sources":["../../src/CodeSpecs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA+E;AAC/E,oDAA0E;AAI1E;;GAEG;AACH,MAAa,SAAS;IAIpB,YAAY,MAAgB;QAFpB,qBAAgB,GAAe,EAAE,CAAC;QAGxC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,MAAM,CAAC,aAAa,EAAE,EAAE;YAC1B,MAAM,CAAC,kB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AAC,OAAO,CAAC,cAAc,CAAC,sBAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;SACtF;QACD,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IACjE,CAAC;IAED;;OAEG;IACI,IAAI,CAAC,EAAc;QACxB,IAAI,mBAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YACpB,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;QAEtE,OAAO,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,uEAAuE,EAAE,CAAC,IAAoB,EAAE,EAAE;YAC1I,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACnB,IAAI,uBAAQ,CAAC,aAAa,KAAK,IAAI,CAAC,IAAI,EAAE;gBACxC,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;YAEtE,MAAM,GAAG,GAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;YAC/B,OAAO,sBAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC;QAC7F,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAxHD,8BAwHC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Codes\r\n */\r\n\r\nimport { DbResult, Id64, Id64String, IModelStatus } from \"@itwin/core-bentley\";\r\nimport { CodeScopeSpec, CodeSpec, IModelError } from \"@itwin/core-common\";\r\nimport { ECSqlStatement } from \"./ECSqlStatement\";\r\nimport { IModelDb } from \"./IModelDb\";\r\n\r\n/** Manages [CodeSpecs]($docs/BIS/intro/element-fundamentals.md#codespec) within an [[IModelDb]]\r\n * @public\r\n */\r\nexport class CodeSpecs {\r\n private _imodel: IModelDb;\r\n private _loadedCodeSpecs: CodeSpec[] = [];\r\n\r\n constructor(imodel: IModelDb) {\r\n this._imodel = imodel;\r\n if (imodel.isBriefcaseDb()) {\r\n imodel.onChangesetApplied.addListener(() => this._loadedCodeSpecs.length = 0);\r\n }\r\n }\r\n\r\n /** Look up the Id of the CodeSpec with the specified name. */\r\n public queryId(name: string): Id64String {\r\n return this._imodel.withPreparedStatement(\"SELECT ECInstanceId FROM BisCore.CodeSpec WHERE Name=:name\", (stmt: ECSqlStatement) => {\r\n stmt.bindString(\"name\", name);\r\n if (DbResult.BE_SQLITE_ROW !== stmt.step())\r\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\", () => ({ name }));\r\n return stmt.getValue(0).getId();\r\n });\r\n }\r\n\r\n /** Look up a CodeSpec by Id. The CodeSpec will be loaded from the database if necessary.\r\n * @param codeSpecId The Id of the CodeSpec to load\r\n * @returns The CodeSpec with the specified Id\r\n * @throws [[IModelError]] if the Id is invalid or if no CodeSpec with that Id could be found.\r\n */\r\n public getById(codeSpecId: Id64String): CodeSpec {\r\n if (Id64.isInvalid(codeSpecId))\r\n throw new IModelError(IModelStatus.InvalidId, \"Invalid codeSpecId\");\r\n\r\n // good chance it is already loaded - check there before running a query\r\n const found: CodeSpec | undefined = this._loadedCodeSpecs.find((codeSpec) => codeSpec.id === codeSpecId);\r\n if (found !== undefined)\r\n return found;\r\n\r\n // must load this codespec\r\n const loadedCodeSpec = this.load(codeSpecId);\r\n this._loadedCodeSpecs.push(loadedCodeSpec);\r\n return loadedCodeSpec;\r\n }\r\n\r\n /** Returns true if the IModelDb has a CodeSpec of the specified Id. */\r\n public hasId(codeSpecId: Id64String): boolean {\r\n try {\r\n return undefined !== this.getById(codeSpecId);\r\n } catch (error) {\r\n return false;\r\n }\r\n }\r\n\r\n /** Look up a CodeSpec by name. The CodeSpec will be loaded from the database if necessary.\r\n * @param name The name of the CodeSpec to load\r\n * @returns The CodeSpec with the specified name\r\n * @throws [[IModelError]] if no CodeSpec with the specified name could be found.\r\n */\r\n public getByName(name: string): CodeSpec {\r\n // good chance it is already loaded - check there before running a query\r\n const found: CodeSpec | undefined = this._loadedCodeSpecs.find((codeSpec) => codeSpec.name === name);\r\n if (found !== undefined)\r\n return found;\r\n const codeSpecId = this.queryId(name);\r\n if (codeSpecId === undefined)\r\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\", () => ({ name }));\r\n return this.getById(codeSpecId);\r\n }\r\n\r\n /** Returns true if the IModelDb has a CodeSpec of the specified name. */\r\n public hasName(name: string): boolean {\r\n try {\r\n return undefined !== this.getByName(name);\r\n } catch (error) {\r\n return false;\r\n }\r\n }\r\n\r\n /** Add a new CodeSpec to the iModel.\r\n * @param codeSpec The CodeSpec to insert\r\n * @returns The Id of the persistent CodeSpec.\r\n * @note If successful, this method will assign a valid CodeSpecId to the supplied CodeSpec\r\n * @throws IModelError if the insertion fails\r\n */\r\n public insert(codeSpec: CodeSpec): Id64String;\r\n /** Add a new CodeSpec to the IModelDb.\r\n * @param name The name for the new CodeSpec.\r\n * @param scopeType The scope type\r\n * @returns The Id of the persistent CodeSpec.\r\n * @throws IModelError if the insertion fails\r\n */\r\n public insert(name: string, scopeType: CodeScopeSpec.Type): Id64String;\r\n public insert(codeSpecOrName: CodeSpec | string, scopeType?: CodeScopeSpec.Type): Id64String {\r\n if (codeSpecOrName instanceof CodeSpec) {\r\n const codeSpec = codeSpecOrName;\r\n const id: Id64String = this._imodel.insertCodeSpec(codeSpec);\r\n codeSpec.id = id;\r\n return id;\r\n }\r\n if (typeof codeSpecOrName === \"string\") {\r\n const name = codeSpecOrName;\r\n if (scopeType)\r\n return this._imodel.insertCodeSpec(CodeSpec.create(this._imodel, name, scopeType));\r\n }\r\n throw new IModelError(IModelStatus.BadArg, \"Invalid argument\");\r\n }\r\n\r\n /** Load a CodeSpec from the iModel\r\n * @param id The persistent Id of the CodeSpec to load\r\n */\r\n public load(id: Id64String): CodeSpec {\r\n if (Id64.isInvalid(id))\r\n throw new IModelError(IModelStatus.InvalidId, \"Invalid codeSpecId\");\r\n\r\n return this._imodel.withPreparedStatement(\"SELECT name,jsonProperties FROM BisCore.CodeSpec WHERE ECInstanceId=?\", (stmt: ECSqlStatement) => {\r\n stmt.bindId(1, id);\r\n if (DbResult.BE_SQLITE_ROW !== stmt.step())\r\n throw new IModelError(IModelStatus.InvalidId, \"Invalid codeSpecId\");\r\n\r\n const row: any = stmt.getRow();\r\n return CodeSpec.createFromJson(this._imodel, id, row.name, JSON.parse(row.jsonProperties));\r\n });\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DisplayStyle.js","sourceRoot":"","sources":["../../src/DisplayStyle.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAmH;AACnH,oDAG4B;AAC5B,uCAA8D;AAI9D;;;;GAIG;AACH,MAAsB,YAAa,SAAQ,2BAAiB;IAC1D,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,cAAc,CAAC,CAAC,CAAC;IAGzE,gBAAgB;IAChB,YAAsB,KAAwB,EAAE,MAAgB;QAC9D,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,UAAU,CAAC,MAAgB,EAAE,YAA4B,EAAE,SAAiB;QACxF,MAAM,QAAQ,GAAa,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,yBAAW,CAAC,YAAY,CAAC,CAAC;QAChF,OAAO,IAAI,kBAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,CAA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Aa,CAAC,YAAY,CAAC,CAAC;IACvD,CAAC;CACF;AAlHD,wCAkHC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ViewDefinitions\n */\n\nimport { CompressedId64Set, Id64, Id64Array, Id64Set, Id64String, OrderedId64Iterable } from \"@itwin/core-bentley\";\nimport {\n BisCodeSpec, Code, CodeScopeProps, CodeSpec, ColorDef, DisplayStyle3dProps, DisplayStyle3dSettings, DisplayStyle3dSettingsProps,\n DisplayStyleProps, DisplayStyleSettings, PlanProjectionSettingsProps, RenderSchedule, SkyBoxImageProps, ViewFlags,\n} from \"@itwin/core-common\";\nimport { DefinitionElement, RenderTimeline } from \"./Element\";\nimport { IModelCloneContext } from \"./IModelCloneContext\";\nimport { IModelDb } from \"./IModelDb\";\n\n/** A DisplayStyle defines the parameters for 'styling' the contents of a view.\n * Internally a DisplayStyle consists of a dictionary of several named 'styles' describing specific aspects of the display style as a whole.\n * Many ViewDefinitions may share the same DisplayStyle.\n * @public\n */\nexport abstract class DisplayStyle extends DefinitionElement implements DisplayStyleProps {\n /** @internal */\n public static override get className(): string { return \"DisplayStyle\"; }\n public abstract get settings(): DisplayStyleSettings;\n\n /** @internal */\n protected constructor(props: DisplayStyleProps, iModel: IModelDb) {\n super(props, iModel);\n }\n\n /** Create a Code for a DisplayStyle given a name that is meant to be unique within the scope of the specified DefinitionModel.\n * @param iModel The IModelDb\n * @param scopeModelId The Id of the DefinitionModel that contains the DisplayStyle and provides the scope for its name.\n * @param codeValue The DisplayStyle name\n */\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.displayStyle);\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\n }\n\n /** @alpha */\n protected override collectPredecessorIds(predecessorIds: Id64Set): void {\n super.collectPredecessorIds(predecessorIds);\n for (const [id] of this.settings.subCategoryOverrides) {\n predecessorIds.add(id);\n }\n\n for (const excludedElementId of this.settings.excludedElementIds)\n predecessorIds.add(excludedElementId);\n\n if (this.settings.renderTimeline) {\n predecessorIds.add(this.settings.renderTimeline);\n } else {\n const script = this.loadScheduleScript();\n if (script)\n script.script.discloseIds(predecessorIds);\n }\n }\n\n /** @alpha */\n protected static override onCloned(context: IModelCloneContext, sourceElementProps: DisplayStyleProps, targetElementProps: DisplayStyleProps): void {\n super.onCloned(context, sourceElementProps, targetElementProps);\n\n if (!context.isBetweenIModels || !targetElementProps.jsonProperties?.styles)\n return;\n\n const settings = targetElementProps.jsonProperties.styles;\n if (settings.subCategoryOvr) {\n for (let i = 0; i < settings.subCategoryOvr.length; /* */) {\n const ovr = settings.subCategoryOvr[i];\n ovr.subCategory = context.findTargetElementId(Id64.fromJSON(ovr.subCategory));\n if (Id64.invalid === ovr.subCategory)\n settings.subCategoryOvr.splice(i, 1);\n else\n i++;\n }\n }\n\n if (settings.excludedElements) {\n const excluded: Id64Array = \"string\" === typeof settings.excludedElements ? CompressedId64Set.decompressArray(settings.excludedElements) : settings.excludedElements;\n for (let i = 0; i < excluded.length; /* */) {\n const remapped = context.findTargetElementId(excluded[i]);\n if (Id64.invalid === remapped)\n excluded.splice(i, 1);\n else\n excluded[i++] = remapped;\n }\n\n if (0 === excluded.length)\n delete settings.excludedElements;\n else\n settings.excludedElements = CompressedId64Set.compressIds(OrderedId64Iterable.sortArray(excluded));\n }\n\n // eslint-disable-next-line deprecation/deprecation\n if (settings.renderTimeline) {\n const renderTimeline = context.findTargetElementId(settings.renderTimeline);\n if (Id64.isValid(renderTimeline))\n settings.renderTimeline = renderTimeline;\n else\n delete settings.renderTimeline;\n } else if (settings.scheduleScript) { // eslint-disable-line deprecation/deprecation\n // eslint-disable-next-line deprecation/deprecation\n const scheduleScript = RenderTimeline.remapScript(context, settings.scheduleScript);\n if (scheduleScript.length > 0)\n settings.scheduleScript = scheduleScript; // eslint-disable-line deprecation/deprecation\n else\n delete settings.scheduleScript; // eslint-disable-line deprecation/deprecation\n }\n }\n\n public loadScheduleScript(): RenderSchedule.ScriptReference | undefined {\n let script;\n let sourceId;\n if (this.settings.renderTimeline) {\n const timeline = this.iModel.elements.tryGetElement<RenderTimeline>(this.settings.renderTimeline);\n if (timeline) {\n script = RenderSchedule.Script.fromJSON(timeline.scriptProps);\n sourceId = timeline.id;\n }\n } else if (this.settings.scheduleScriptProps) { // eslint-disable-line deprecation/deprecation\n // eslint-disable-next-line deprecation/deprecation\n script = RenderSchedule.Script.fromJSON(this.settings.scheduleScriptProps);\n sourceId = this.id;\n }\n\n return undefined !== sourceId && undefined !== script ? new RenderSchedule.ScriptReference(sourceId, script) : undefined;\n }\n}\n\n/** A DisplayStyle for 2d views.\n * @public\n */\nexport class DisplayStyle2d extends DisplayStyle {\n /** @internal */\n public static override get className(): string { return \"DisplayStyle2d\"; }\n private readonly _settings: DisplayStyleSettings;\n\n public get settings(): DisplayStyleSettings { return this._settings; }\n\n /** @internal */\n public constructor(props: DisplayStyleProps, iModel: IModelDb) {\n super(props, iModel);\n this._settings = new DisplayStyleSettings(this.jsonProperties);\n }\n /** Create a DisplayStyle2d for use by a ViewDefinition.\n * @param iModelDb The iModel\n * @param definitionModelId The [[DefinitionModel]]\n * @param name The name/CodeValue of the DisplayStyle2d\n * @returns The newly constructed DisplayStyle2d element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string): DisplayStyle2d {\n const displayStyleProps: DisplayStyleProps = {\n classFullName: this.classFullName,\n code: this.createCode(iModelDb, definitionModelId, name),\n model: definitionModelId,\n isPrivate: false,\n jsonProperties: {\n styles: {\n backgroundColor: 0,\n monochromeColor: ColorDef.white.toJSON(),\n viewflags: ViewFlags.defaults,\n },\n },\n };\n return new DisplayStyle2d(displayStyleProps, iModelDb);\n }\n /** Insert a DisplayStyle2d for use by a ViewDefinition.\n * @param iModelDb Insert into this iModel\n * @param definitionModelId Insert the new DisplayStyle2d into this DefinitionModel\n * @param name The name of the DisplayStyle2d\n * @returns The Id of the newly inserted DisplayStyle2d element.\n * @throws [[IModelError]] if unable to insert the element.\n */\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string): Id64String {\n const displayStyle = this.create(iModelDb, definitionModelId, name);\n return iModelDb.elements.insertElement(displayStyle);\n }\n}\n\n/** Describes initial settings for a new [[DisplayStyle3d]].\n * Most properties are inherited from [DisplayStyle3dSettingsProps]($common), but for backwards compatibility reasons, this interface is slightly awkward:\n * - It adds a `viewFlags` member that differs only in case and type from [DisplayStyleSettingsProps.viewflags]($common); and\n * - It extends the type of [DisplayStyleSettingsProps.backgroundColor]($common) to include [ColorDef]($common).\n * These idiosyncrasies will be addressed in a future version of core-backend.\n * @see [[DisplayStyle3d.create]].\n * @public\n */\nexport interface DisplayStyleCreationOptions extends Omit<DisplayStyle3dSettingsProps, \"backgroundColor\" | \"scheduleScript\"> {\n /** If supplied, the [ViewFlags]($common) applied by the display style.\n * If undefined, [DisplayStyle3dSettingsProps.viewflags]($common) will be used if present (note the difference in case); otherwise, default-constructed [ViewFlags]($common) will be used.\n */\n viewFlags?: ViewFlags;\n backgroundColor?: ColorDef | number;\n}\n\n/** A DisplayStyle for 3d views.\n * See [how to create a DisplayStyle3d]$(docs/learning/backend/CreateElements.md#DisplayStyle3d).\n * @public\n */\nexport class DisplayStyle3d extends DisplayStyle implements DisplayStyle3dProps {\n /** @internal */\n public static override get className(): string { return \"DisplayStyle3d\"; }\n private readonly _settings: DisplayStyle3dSettings;\n\n public get settings(): DisplayStyle3dSettings { return this._settings; }\n\n /** @internal */\n public constructor(props: DisplayStyle3dProps, iModel: IModelDb) {\n super(props, iModel);\n this._settings = new DisplayStyle3dSettings(this.jsonProperties);\n }\n\n /** @alpha */\n protected override collectPredecessorIds(predecessorIds: Id64Set): void {\n super.collectPredecessorIds(predecessorIds);\n const skyBoxImageProps: SkyBoxImageProps | undefined = this.settings.environment?.sky?.image;\n if (skyBoxImageProps?.texture) {\n predecessorIds.add(Id64.fromJSON(skyBoxImageProps.texture));\n }\n if (skyBoxImageProps?.textures) {\n if (skyBoxImageProps.textures.back) { predecessorIds.add(Id64.fromJSON(skyBoxImageProps.textures.back)); }\n if (skyBoxImageProps.textures.bottom) { predecessorIds.add(Id64.fromJSON(skyBoxImageProps.textures.bottom)); }\n if (skyBoxImageProps.textures.front) { predecessorIds.add(Id64.fromJSON(skyBoxImageProps.textures.front)); }\n if (skyBoxImageProps.textures.left) { predecessorIds.add(Id64.fromJSON(skyBoxImageProps.textures.left)); }\n if (skyBoxImageProps.textures.right) { predecessorIds.add(Id64.fromJSON(skyBoxImageProps.textures.right)); }\n if (skyBoxImageProps.textures.top) { predecessorIds.add(Id64.fromJSON(skyBoxImageProps.textures.top)); }\n }\n if (this.settings.planProjectionSettings) {\n for (const planProjectionSetting of this.settings.planProjectionSettings) {\n predecessorIds.add(planProjectionSetting[0]);\n }\n }\n }\n /** @alpha */\n protected static override onCloned(context: IModelCloneContext, sourceElementProps: DisplayStyle3dProps, targetElementProps: DisplayStyle3dProps): void {\n super.onCloned(context, sourceElementProps, targetElementProps);\n if (context.isBetweenIModels) {\n const skyBoxImageProps: SkyBoxImageProps | undefined = targetElementProps?.jsonProperties?.styles?.environment?.sky?.image;\n if (skyBoxImageProps?.texture) {\n const textureId: Id64String = context.findTargetElementId(Id64.fromJSON(skyBoxImageProps.texture));\n skyBoxImageProps.texture = Id64.isValidId64(textureId) ? textureId : undefined;\n }\n if (skyBoxImageProps?.textures) {\n const backTextureId: Id64String = context.findTargetElementId(Id64.fromJSON(skyBoxImageProps.textures.back));\n skyBoxImageProps.textures.back = Id64.isValidId64(backTextureId) ? backTextureId : undefined;\n const bottomTextureId: Id64String = context.findTargetElementId(Id64.fromJSON(skyBoxImageProps.textures.bottom));\n skyBoxImageProps.textures.bottom = Id64.isValidId64(bottomTextureId) ? bottomTextureId : undefined;\n const frontTextureId: Id64String = context.findTargetElementId(Id64.fromJSON(skyBoxImageProps.textures.front));\n skyBoxImageProps.textures.front = Id64.isValidId64(frontTextureId) ? frontTextureId : undefined;\n const leftTextureId: Id64String = context.findTargetElementId(Id64.fromJSON(skyBoxImageProps.textures.left));\n skyBoxImageProps.textures.left = Id64.isValidId64(leftTextureId) ? leftTextureId : undefined;\n const rightTextureId: Id64String = context.findTargetElementId(Id64.fromJSON(skyBoxImageProps.textures.right));\n skyBoxImageProps.textures.right = Id64.isValidId64(rightTextureId) ? rightTextureId : undefined;\n const topTextureId: Id64String = context.findTargetElementId(Id64.fromJSON(skyBoxImageProps.textures.top));\n skyBoxImageProps.textures.top = Id64.isValidId64(topTextureId) ? topTextureId : undefined;\n }\n if (targetElementProps?.jsonProperties?.styles?.planProjections) {\n const remappedPlanProjections: { [modelId: string]: PlanProjectionSettingsProps } = {};\n for (const entry of Object.entries(targetElementProps.jsonProperties.styles.planProjections)) {\n const remappedModelId: Id64String = context.findTargetElementId(entry[0]);\n if (Id64.isValidId64(remappedModelId)) {\n remappedPlanProjections[remappedModelId] = entry[1];\n }\n }\n targetElementProps.jsonProperties.styles.planProjections = remappedPlanProjections;\n }\n }\n }\n\n /** Create a DisplayStyle3d for use by a ViewDefinition.\n * @param iModelDb The iModel\n * @param definitionModelId The [[DefinitionModel]]\n * @param name The name/CodeValue of the DisplayStyle3d\n * @returns The newly constructed DisplayStyle3d element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string, options?: DisplayStyleCreationOptions): DisplayStyle3d {\n options = options ?? {};\n let viewflags = options.viewFlags?.toJSON();\n if (!viewflags)\n viewflags = options.viewflags ?? new ViewFlags().toJSON();\n\n const backgroundColor = options.backgroundColor instanceof ColorDef ? options.backgroundColor.toJSON() : options.backgroundColor;\n\n const settings: DisplayStyle3dSettingsProps = {\n ...options,\n viewflags,\n backgroundColor,\n };\n\n const displayStyleProps: DisplayStyle3dProps = {\n classFullName: this.classFullName,\n code: this.createCode(iModelDb, definitionModelId, name),\n model: definitionModelId,\n jsonProperties: { styles: settings },\n isPrivate: false,\n\n };\n\n return new DisplayStyle3d(displayStyleProps, iModelDb);\n }\n /**\n * Insert a DisplayStyle3d for use by a ViewDefinition.\n * @param iModelDb Insert into this iModel\n * @param definitionModelId Insert the new DisplayStyle3d into this [[DefinitionModel]]\n * @param name The name of the DisplayStyle3d\n * @returns The Id of the newly inserted DisplayStyle3d element.\n * @throws [[IModelError]] if unable to insert the element.\n */\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, options?: DisplayStyleCreationOptions): Id64String {\n const displayStyle = this.create(iModelDb, definitionModelId, name, options);\n return iModelDb.elements.insertElement(displayStyle);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DisplayStyle.js","sourceRoot":"","sources":["../../src/DisplayStyle.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAmH;AACnH,oDAG4B;AAC5B,uCAA8D;AAI9D;;;;GAIG;AACH,MAAsB,YAAa,SAAQ,2BAAiB;IAC1D,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,cAAc,CAAC,CAAC,CAAC;IAGzE,gBAAgB;IAChB,YAAsB,KAAwB,EAAE,MAAgB;QAC9D,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,UAAU,CAAC,MAAgB,EAAE,YAA4B,EAAE,SAAiB;QACxF,MAAM,QAAQ,GAAa,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,yBAAW,CAAC,YAAY,CAAC,CAAC;QAChF,OAAO,IAAI,kBAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAChF,CAAC;IAED,aAAa;IACM,qBAAqB,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AAlHD,wCAkHC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module ViewDefinitions\r\n */\r\n\r\nimport { CompressedId64Set, Id64, Id64Array, Id64Set, Id64String, OrderedId64Iterable } from \"@itwin/core-bentley\";\r\nimport {\r\n BisCodeSpec, Code, CodeScopeProps, CodeSpec, ColorDef, DisplayStyle3dProps, DisplayStyle3dSettings, DisplayStyle3dSettingsProps,\r\n DisplayStyleProps, DisplayStyleSettings, PlanProjectionSettingsProps, RenderSchedule, SkyBoxImageProps, ViewFlags,\r\n} from \"@itwin/core-common\";\r\nimport { DefinitionElement, RenderTimeline } from \"./Element\";\r\nimport { IModelCloneContext } from \"./IModelCloneContext\";\r\nimport { IModelDb } from \"./IModelDb\";\r\n\r\n/** A DisplayStyle defines the parameters for 'styling' the contents of a view.\r\n * Internally a DisplayStyle consists of a dictionary of several named 'styles' describing specific aspects of the display style as a whole.\r\n * Many ViewDefinitions may share the same DisplayStyle.\r\n * @public\r\n */\r\nexport abstract class DisplayStyle extends DefinitionElement implements DisplayStyleProps {\r\n /** @internal */\r\n public static override get className(): string { return \"DisplayStyle\"; }\r\n public abstract get settings(): DisplayStyleSettings;\r\n\r\n /** @internal */\r\n protected constructor(props: DisplayStyleProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n }\r\n\r\n /** Create a Code for a DisplayStyle given a name that is meant to be unique within the scope of the specified DefinitionModel.\r\n * @param iModel The IModelDb\r\n * @param scopeModelId The Id of the DefinitionModel that contains the DisplayStyle and provides the scope for its name.\r\n * @param codeValue The DisplayStyle name\r\n */\r\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {\r\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.displayStyle);\r\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\r\n }\r\n\r\n /** @alpha */\r\n protected override collectPredecessorIds(predecessorIds: Id64Set): void {\r\n super.collectPredecessorIds(predecessorIds);\r\n for (const [id] of this.settings.subCategoryOverrides) {\r\n predecessorIds.add(id);\r\n }\r\n\r\n for (const excludedElementId of this.settings.excludedElementIds)\r\n predecessorIds.add(excludedElementId);\r\n\r\n if (this.settings.renderTimeline) {\r\n predecessorIds.add(this.settings.renderTimeline);\r\n } else {\r\n const script = this.loadScheduleScript();\r\n if (script)\r\n script.script.discloseIds(predecessorIds);\r\n }\r\n }\r\n\r\n /** @alpha */\r\n protected static override onCloned(context: IModelCloneContext, sourceElementProps: DisplayStyleProps, targetElementProps: DisplayStyleProps): void {\r\n super.onCloned(context, sourceElementProps, targetElementProps);\r\n\r\n if (!context.isBetweenIModels || !targetElementProps.jsonProperties?.styles)\r\n return;\r\n\r\n const settings = targetElementProps.jsonProperties.styles;\r\n if (settings.subCategoryOvr) {\r\n for (let i = 0; i < settings.subCategoryOvr.length; /* */) {\r\n const ovr = settings.subCategoryOvr[i];\r\n ovr.subCategory = context.findTargetElementId(Id64.fromJSON(ovr.subCategory));\r\n if (Id64.invalid === ovr.subCategory)\r\n settings.subCategoryOvr.splice(i, 1);\r\n else\r\n i++;\r\n }\r\n }\r\n\r\n if (settings.excludedElements) {\r\n const excluded: Id64Array = \"string\" === typeof settings.excludedElements ? CompressedId64Set.decompressArray(settings.excludedElements) : settings.excludedElements;\r\n for (let i = 0; i < excluded.length; /* */) {\r\n const remapped = context.findTargetElementId(excluded[i]);\r\n if (Id64.invalid === remapped)\r\n excluded.splice(i, 1);\r\n else\r\n excluded[i++] = remapped;\r\n }\r\n\r\n if (0 === excluded.length)\r\n delete settings.excludedElements;\r\n else\r\n settings.excludedElements = CompressedId64Set.compressIds(OrderedId64Iterable.sortArray(excluded));\r\n }\r\n\r\n // eslint-disable-next-line deprecation/deprecation\r\n if (settings.renderTimeline) {\r\n const renderTimeline = context.findTargetElementId(settings.renderTimeline);\r\n if (Id64.isValid(renderTimeline))\r\n settings.renderTimeline = renderTimeline;\r\n else\r\n delete settings.renderTimeline;\r\n } else if (settings.scheduleScript) { // eslint-disable-line deprecation/deprecation\r\n // eslint-disable-next-line deprecation/deprecation\r\n const scheduleScript = RenderTimeline.remapScript(context, settings.scheduleScript);\r\n if (scheduleScript.length > 0)\r\n settings.scheduleScript = scheduleScript; // eslint-disable-line deprecation/deprecation\r\n else\r\n delete settings.scheduleScript; // eslint-disable-line deprecation/deprecation\r\n }\r\n }\r\n\r\n public loadScheduleScript(): RenderSchedule.ScriptReference | undefined {\r\n let script;\r\n let sourceId;\r\n if (this.settings.renderTimeline) {\r\n const timeline = this.iModel.elements.tryGetElement<RenderTimeline>(this.settings.renderTimeline);\r\n if (timeline) {\r\n script = RenderSchedule.Script.fromJSON(timeline.scriptProps);\r\n sourceId = timeline.id;\r\n }\r\n } else if (this.settings.scheduleScriptProps) { // eslint-disable-line deprecation/deprecation\r\n // eslint-disable-next-line deprecation/deprecation\r\n script = RenderSchedule.Script.fromJSON(this.settings.scheduleScriptProps);\r\n sourceId = this.id;\r\n }\r\n\r\n return undefined !== sourceId && undefined !== script ? new RenderSchedule.ScriptReference(sourceId, script) : undefined;\r\n }\r\n}\r\n\r\n/** A DisplayStyle for 2d views.\r\n * @public\r\n */\r\nexport class DisplayStyle2d extends DisplayStyle {\r\n /** @internal */\r\n public static override get className(): string { return \"DisplayStyle2d\"; }\r\n private readonly _settings: DisplayStyleSettings;\r\n\r\n public get settings(): DisplayStyleSettings { return this._settings; }\r\n\r\n /** @internal */\r\n public constructor(props: DisplayStyleProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this._settings = new DisplayStyleSettings(this.jsonProperties);\r\n }\r\n /** Create a DisplayStyle2d for use by a ViewDefinition.\r\n * @param iModelDb The iModel\r\n * @param definitionModelId The [[DefinitionModel]]\r\n * @param name The name/CodeValue of the DisplayStyle2d\r\n * @returns The newly constructed DisplayStyle2d element.\r\n * @throws [[IModelError]] if unable to create the element.\r\n */\r\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string): DisplayStyle2d {\r\n const displayStyleProps: DisplayStyleProps = {\r\n classFullName: this.classFullName,\r\n code: this.createCode(iModelDb, definitionModelId, name),\r\n model: definitionModelId,\r\n isPrivate: false,\r\n jsonProperties: {\r\n styles: {\r\n backgroundColor: 0,\r\n monochromeColor: ColorDef.white.toJSON(),\r\n viewflags: ViewFlags.defaults,\r\n },\r\n },\r\n };\r\n return new DisplayStyle2d(displayStyleProps, iModelDb);\r\n }\r\n /** Insert a DisplayStyle2d for use by a ViewDefinition.\r\n * @param iModelDb Insert into this iModel\r\n * @param definitionModelId Insert the new DisplayStyle2d into this DefinitionModel\r\n * @param name The name of the DisplayStyle2d\r\n * @returns The Id of the newly inserted DisplayStyle2d element.\r\n * @throws [[IModelError]] if unable to insert the element.\r\n */\r\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string): Id64String {\r\n const displayStyle = this.create(iModelDb, definitionModelId, name);\r\n return iModelDb.elements.insertElement(displayStyle);\r\n }\r\n}\r\n\r\n/** Describes initial settings for a new [[DisplayStyle3d]].\r\n * Most properties are inherited from [DisplayStyle3dSettingsProps]($common), but for backwards compatibility reasons, this interface is slightly awkward:\r\n * - It adds a `viewFlags` member that differs only in case and type from [DisplayStyleSettingsProps.viewflags]($common); and\r\n * - It extends the type of [DisplayStyleSettingsProps.backgroundColor]($common) to include [ColorDef]($common).\r\n * These idiosyncrasies will be addressed in a future version of core-backend.\r\n * @see [[DisplayStyle3d.create]].\r\n * @public\r\n */\r\nexport interface DisplayStyleCreationOptions extends Omit<DisplayStyle3dSettingsProps, \"backgroundColor\" | \"scheduleScript\"> {\r\n /** If supplied, the [ViewFlags]($common) applied by the display style.\r\n * If undefined, [DisplayStyle3dSettingsProps.viewflags]($common) will be used if present (note the difference in case); otherwise, default-constructed [ViewFlags]($common) will be used.\r\n */\r\n viewFlags?: ViewFlags;\r\n backgroundColor?: ColorDef | number;\r\n}\r\n\r\n/** A DisplayStyle for 3d views.\r\n * See [how to create a DisplayStyle3d]$(docs/learning/backend/CreateElements.md#DisplayStyle3d).\r\n * @public\r\n */\r\nexport class DisplayStyle3d extends DisplayStyle implements DisplayStyle3dProps {\r\n /** @internal */\r\n public static override get className(): string { return \"DisplayStyle3d\"; }\r\n private readonly _settings: DisplayStyle3dSettings;\r\n\r\n public get settings(): DisplayStyle3dSettings { return this._settings; }\r\n\r\n /** @internal */\r\n public constructor(props: DisplayStyle3dProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this._settings = new DisplayStyle3dSettings(this.jsonProperties);\r\n }\r\n\r\n /** @alpha */\r\n protected override collectPredecessorIds(predecessorIds: Id64Set): void {\r\n super.collectPredecessorIds(predecessorIds);\r\n const skyBoxImageProps: SkyBoxImageProps | undefined = this.settings.environment?.sky?.image;\r\n if (skyBoxImageProps?.texture) {\r\n predecessorIds.add(Id64.fromJSON(skyBoxImageProps.texture));\r\n }\r\n if (skyBoxImageProps?.textures) {\r\n if (skyBoxImageProps.textures.back) { predecessorIds.add(Id64.fromJSON(skyBoxImageProps.textures.back)); }\r\n if (skyBoxImageProps.textures.bottom) { predecessorIds.add(Id64.fromJSON(skyBoxImageProps.textures.bottom)); }\r\n if (skyBoxImageProps.textures.front) { predecessorIds.add(Id64.fromJSON(skyBoxImageProps.textures.front)); }\r\n if (skyBoxImageProps.textures.left) { predecessorIds.add(Id64.fromJSON(skyBoxImageProps.textures.left)); }\r\n if (skyBoxImageProps.textures.right) { predecessorIds.add(Id64.fromJSON(skyBoxImageProps.textures.right)); }\r\n if (skyBoxImageProps.textures.top) { predecessorIds.add(Id64.fromJSON(skyBoxImageProps.textures.top)); }\r\n }\r\n if (this.settings.planProjectionSettings) {\r\n for (const planProjectionSetting of this.settings.planProjectionSettings) {\r\n predecessorIds.add(planProjectionSetting[0]);\r\n }\r\n }\r\n }\r\n /** @alpha */\r\n protected static override onCloned(context: IModelCloneContext, sourceElementProps: DisplayStyle3dProps, targetElementProps: DisplayStyle3dProps): void {\r\n super.onCloned(context, sourceElementProps, targetElementProps);\r\n if (context.isBetweenIModels) {\r\n const skyBoxImageProps: SkyBoxImageProps | undefined = targetElementProps?.jsonProperties?.styles?.environment?.sky?.image;\r\n if (skyBoxImageProps?.texture) {\r\n const textureId: Id64String = context.findTargetElementId(Id64.fromJSON(skyBoxImageProps.texture));\r\n skyBoxImageProps.texture = Id64.isValidId64(textureId) ? textureId : undefined;\r\n }\r\n if (skyBoxImageProps?.textures) {\r\n const backTextureId: Id64String = context.findTargetElementId(Id64.fromJSON(skyBoxImageProps.textures.back));\r\n skyBoxImageProps.textures.back = Id64.isValidId64(backTextureId) ? backTextureId : undefined;\r\n const bottomTextureId: Id64String = context.findTargetElementId(Id64.fromJSON(skyBoxImageProps.textures.bottom));\r\n skyBoxImageProps.textures.bottom = Id64.isValidId64(bottomTextureId) ? bottomTextureId : undefined;\r\n const frontTextureId: Id64String = context.findTargetElementId(Id64.fromJSON(skyBoxImageProps.textures.front));\r\n skyBoxImageProps.textures.front = Id64.isValidId64(frontTextureId) ? frontTextureId : undefined;\r\n const leftTextureId: Id64String = context.findTargetElementId(Id64.fromJSON(skyBoxImageProps.textures.left));\r\n skyBoxImageProps.textures.left = Id64.isValidId64(leftTextureId) ? leftTextureId : undefined;\r\n const rightTextureId: Id64String = context.findTargetElementId(Id64.fromJSON(skyBoxImageProps.textures.right));\r\n skyBoxImageProps.textures.right = Id64.isValidId64(rightTextureId) ? rightTextureId : undefined;\r\n const topTextureId: Id64String = context.findTargetElementId(Id64.fromJSON(skyBoxImageProps.textures.top));\r\n skyBoxImageProps.textures.top = Id64.isValidId64(topTextureId) ? topTextureId : undefined;\r\n }\r\n if (targetElementProps?.jsonProperties?.styles?.planProjections) {\r\n const remappedPlanProjections: { [modelId: string]: PlanProjectionSettingsProps } = {};\r\n for (const entry of Object.entries(targetElementProps.jsonProperties.styles.planProjections)) {\r\n const remappedModelId: Id64String = context.findTargetElementId(entry[0]);\r\n if (Id64.isValidId64(remappedModelId)) {\r\n remappedPlanProjections[remappedModelId] = entry[1];\r\n }\r\n }\r\n targetElementProps.jsonProperties.styles.planProjections = remappedPlanProjections;\r\n }\r\n }\r\n }\r\n\r\n /** Create a DisplayStyle3d for use by a ViewDefinition.\r\n * @param iModelDb The iModel\r\n * @param definitionModelId The [[DefinitionModel]]\r\n * @param name The name/CodeValue of the DisplayStyle3d\r\n * @returns The newly constructed DisplayStyle3d element.\r\n * @throws [[IModelError]] if unable to create the element.\r\n */\r\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string, options?: DisplayStyleCreationOptions): DisplayStyle3d {\r\n options = options ?? {};\r\n let viewflags = options.viewFlags?.toJSON();\r\n if (!viewflags)\r\n viewflags = options.viewflags ?? new ViewFlags().toJSON();\r\n\r\n const backgroundColor = options.backgroundColor instanceof ColorDef ? options.backgroundColor.toJSON() : options.backgroundColor;\r\n\r\n const settings: DisplayStyle3dSettingsProps = {\r\n ...options,\r\n viewflags,\r\n backgroundColor,\r\n };\r\n\r\n const displayStyleProps: DisplayStyle3dProps = {\r\n classFullName: this.classFullName,\r\n code: this.createCode(iModelDb, definitionModelId, name),\r\n model: definitionModelId,\r\n jsonProperties: { styles: settings },\r\n isPrivate: false,\r\n\r\n };\r\n\r\n return new DisplayStyle3d(displayStyleProps, iModelDb);\r\n }\r\n /**\r\n * Insert a DisplayStyle3d for use by a ViewDefinition.\r\n * @param iModelDb Insert into this iModel\r\n * @param definitionModelId Insert the new DisplayStyle3d into this [[DefinitionModel]]\r\n * @param name The name of the DisplayStyle3d\r\n * @returns The Id of the newly inserted DisplayStyle3d element.\r\n * @throws [[IModelError]] if unable to insert the element.\r\n */\r\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, options?: DisplayStyleCreationOptions): Id64String {\r\n const displayStyle = this.create(iModelDb, definitionModelId, name, options);\r\n return iModelDb.elements.insertElement(displayStyle);\r\n }\r\n}\r\n"]}
|