@itwin/core-backend 4.8.0-dev.21 → 4.8.0-dev.24
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 +8 -1
- package/lib/cjs/BackendHubAccess.js.map +1 -1
- package/lib/cjs/BackendLoggerCategory.js.map +1 -1
- package/lib/cjs/BisCoreSchema.js.map +1 -1
- package/lib/cjs/BlobContainerService.js.map +1 -1
- package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
- package/lib/cjs/BriefcaseManager.js +15 -9
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/Category.js.map +1 -1
- package/lib/cjs/ChangeSummaryManager.d.ts.map +1 -1
- package/lib/cjs/ChangeSummaryManager.js +9 -8
- package/lib/cjs/ChangeSummaryManager.js.map +1 -1
- package/lib/cjs/ChangedElementsDb.d.ts.map +1 -1
- package/lib/cjs/ChangedElementsDb.js +3 -2
- package/lib/cjs/ChangedElementsDb.js.map +1 -1
- package/lib/cjs/ChangedElementsManager.js.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.js +237 -237
- package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
- package/lib/cjs/ChannelControl.js.map +1 -1
- package/lib/cjs/CheckpointManager.d.ts.map +1 -1
- package/lib/cjs/CheckpointManager.js +3 -2
- package/lib/cjs/CheckpointManager.js.map +1 -1
- package/lib/cjs/ClassRegistry.d.ts.map +1 -1
- package/lib/cjs/ClassRegistry.js +8 -7
- package/lib/cjs/ClassRegistry.js.map +1 -1
- package/lib/cjs/CloudSqlite.js.map +1 -1
- package/lib/cjs/CodeService.js.map +1 -1
- package/lib/cjs/CodeSpecs.js.map +1 -1
- package/lib/cjs/ConcurrentQuery.js.map +1 -1
- package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
- package/lib/cjs/DevTools.js.map +1 -1
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/ECDb.d.ts +6 -1
- package/lib/cjs/ECDb.d.ts.map +1 -1
- package/lib/cjs/ECDb.js +17 -12
- 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/Element.js.map +1 -1
- package/lib/cjs/ElementAspect.js.map +1 -1
- package/lib/cjs/ElementGraphics.d.ts.map +1 -1
- package/lib/cjs/ElementGraphics.js +2 -1
- package/lib/cjs/ElementGraphics.js.map +1 -1
- package/lib/cjs/ElementTreeWalker.js.map +1 -1
- package/lib/cjs/Entity.js.map +1 -1
- package/lib/cjs/EntityReferences.js.map +1 -1
- package/lib/cjs/ExportGraphics.js.map +1 -1
- package/lib/cjs/ExternalSource.js.map +1 -1
- package/lib/cjs/GeoCoordConfig.js.map +1 -1
- package/lib/cjs/GeographicCRSServices.js.map +1 -1
- package/lib/cjs/GeometrySummary.d.ts.map +1 -1
- package/lib/cjs/GeometrySummary.js +49 -48
- package/lib/cjs/GeometrySummary.js.map +1 -1
- package/lib/cjs/HubMock.js.map +1 -1
- package/lib/cjs/IModelCloneContext.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +6 -1
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +115 -111
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelElementCloneContext.d.ts.map +1 -1
- package/lib/cjs/IModelElementCloneContext.js +4 -3
- package/lib/cjs/IModelElementCloneContext.js.map +1 -1
- package/lib/cjs/IModelHost.d.ts +1 -1
- package/lib/cjs/IModelHost.js +1 -1
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/IModelJsFs.js.map +1 -1
- package/lib/cjs/IpcHost.d.ts.map +1 -1
- package/lib/cjs/IpcHost.js +13 -12
- package/lib/cjs/IpcHost.js.map +1 -1
- package/lib/cjs/LineStyle.js.map +1 -1
- package/lib/cjs/LocalHub.js +1 -1
- package/lib/cjs/LocalHub.js.map +1 -1
- package/lib/cjs/LocalhostIpcHost.js.map +1 -1
- package/lib/cjs/LockControl.js.map +1 -1
- package/lib/cjs/Material.js.map +1 -1
- package/lib/cjs/Model.js +1 -1
- package/lib/cjs/Model.js.map +1 -1
- package/lib/cjs/NativeAppStorage.js.map +1 -1
- package/lib/cjs/NativeHost.js.map +1 -1
- package/lib/cjs/NavigationRelationship.js.map +1 -1
- package/lib/cjs/PromiseMemoizer.js.map +1 -1
- package/lib/cjs/PropertyStore.js.map +1 -1
- package/lib/cjs/Relationship.d.ts.map +1 -1
- package/lib/cjs/Relationship.js +5 -4
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/RpcBackend.js.map +1 -1
- package/lib/cjs/SQLiteDb.d.ts +6 -1
- package/lib/cjs/SQLiteDb.d.ts.map +1 -1
- package/lib/cjs/SQLiteDb.js +21 -14
- package/lib/cjs/SQLiteDb.js.map +1 -1
- package/lib/cjs/Schema.js.map +1 -1
- package/lib/cjs/SchemaSync.d.ts +3 -0
- package/lib/cjs/SchemaSync.d.ts.map +1 -1
- package/lib/cjs/SchemaSync.js +22 -9
- package/lib/cjs/SchemaSync.js.map +1 -1
- package/lib/cjs/SchemaUtils.js.map +1 -1
- package/lib/cjs/SqliteChangesetReader.js.map +1 -1
- package/lib/cjs/SqliteStatement.js.map +1 -1
- package/lib/cjs/TextAnnotationElement.js.map +1 -1
- package/lib/cjs/TextAnnotationGeometry.js.map +1 -1
- package/lib/cjs/TextAnnotationLayout.js.map +1 -1
- package/lib/cjs/Texture.js.map +1 -1
- package/lib/cjs/TileStorage.js.map +1 -1
- package/lib/cjs/TxnManager.d.ts.map +1 -1
- package/lib/cjs/TxnManager.js +2 -1
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/ViewStateHydrator.js.map +1 -1
- package/lib/cjs/ViewStore.d.ts.map +1 -1
- package/lib/cjs/ViewStore.js +6 -5
- package/lib/cjs/ViewStore.js.map +1 -1
- package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
- package/lib/cjs/assets/Settings/Schemas/Base.Schema.json +32 -32
- package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +27 -27
- package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +94 -94
- package/lib/cjs/assets/Settings/backend.setting.json5 +21 -21
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/domains/FunctionalElements.js.map +1 -1
- package/lib/cjs/domains/FunctionalSchema.d.ts.map +1 -1
- package/lib/cjs/domains/FunctionalSchema.js +2 -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/internal/ChangesetConflictArgs.js.map +1 -1
- package/lib/cjs/internal/ChannelAdmin.d.ts.map +1 -1
- package/lib/cjs/internal/ChannelAdmin.js +1 -1
- package/lib/cjs/internal/ChannelAdmin.js.map +1 -1
- package/lib/cjs/internal/NativePlatform.js.map +1 -1
- package/lib/cjs/internal/NoLocks.js.map +1 -1
- package/lib/cjs/internal/ServerBasedLocks.d.ts.map +1 -1
- package/lib/cjs/internal/ServerBasedLocks.js +1 -1
- package/lib/cjs/internal/ServerBasedLocks.js.map +1 -1
- package/lib/cjs/internal/Symbols.d.ts +2 -0
- package/lib/cjs/internal/Symbols.d.ts.map +1 -1
- package/lib/cjs/internal/Symbols.js +3 -1
- package/lib/cjs/internal/Symbols.js.map +1 -1
- package/lib/cjs/internal/cross-package.d.ts +1 -0
- package/lib/cjs/internal/cross-package.d.ts.map +1 -1
- package/lib/cjs/internal/cross-package.js +3 -1
- package/lib/cjs/internal/cross-package.js.map +1 -1
- package/lib/cjs/internal/workspace/SettingsImpl.js.map +1 -1
- package/lib/cjs/internal/workspace/SettingsSchemasImpl.js.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceImpl.js +9 -9
- package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceSqliteDb.d.ts.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceSqliteDb.js +2 -1
- package/lib/cjs/internal/workspace/WorkspaceSqliteDb.js.map +1 -1
- package/lib/cjs/rpc/multipart.js.map +1 -1
- package/lib/cjs/rpc/tracing.js.map +1 -1
- package/lib/cjs/rpc/web/logging.js.map +1 -1
- package/lib/cjs/rpc/web/request.js.map +1 -1
- package/lib/cjs/rpc/web/response.js.map +1 -1
- package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +5 -4
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +3 -2
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -1
- package/lib/cjs/workspace/Settings.js.map +1 -1
- package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
- package/lib/cjs/workspace/Workspace.js.map +1 -1
- package/lib/cjs/workspace/WorkspaceEditor.js.map +1 -1
- package/package.json +13 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FunctionalSchema.d.ts","sourceRoot":"","sources":["../../../src/domains/FunctionalSchema.ts"],"names":[],"mappings":"AAIA;;GAEG;AAMH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAW,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"FunctionalSchema.d.ts","sourceRoot":"","sources":["../../../src/domains/FunctionalSchema.ts"],"names":[],"mappings":"AAIA;;GAEG;AAMH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAW,MAAM,WAAW,CAAC;AAI5C,cAAc;AACd,qBAAa,gBAAiB,SAAQ,MAAM;IAC1C,WAA2B,UAAU,IAAI,MAAM,CAAyB;IACxE,WAAkB,cAAc,IAAI,MAAM,CAA4H;WACxJ,cAAc;IAQ5B,cAAc;WACM,YAAY,CAAC,QAAQ,EAAE,QAAQ;CASpD"}
|
|
@@ -15,6 +15,7 @@ const ClassRegistry_1 = require("../ClassRegistry");
|
|
|
15
15
|
const IModelHost_1 = require("../IModelHost");
|
|
16
16
|
const Schema_1 = require("../Schema");
|
|
17
17
|
const elementsModule = require("./FunctionalElements");
|
|
18
|
+
const Symbols_1 = require("../internal/Symbols");
|
|
18
19
|
/** @public */
|
|
19
20
|
class FunctionalSchema extends Schema_1.Schema {
|
|
20
21
|
static get schemaName() { return "Functional"; }
|
|
@@ -30,7 +31,7 @@ class FunctionalSchema extends Schema_1.Schema {
|
|
|
30
31
|
static async importSchema(iModelDb) {
|
|
31
32
|
if (iModelDb.isBriefcaseDb())
|
|
32
33
|
await iModelDb.acquireSchemaLock();
|
|
33
|
-
const stat = iModelDb.
|
|
34
|
+
const stat = iModelDb[Symbols_1._nativeDb].importFunctionalSchema();
|
|
34
35
|
if (core_bentley_1.DbResult.BE_SQLITE_OK !== stat) {
|
|
35
36
|
throw new core_common_1.IModelError(stat, "Error importing Functional schema");
|
|
36
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FunctionalSchema.js","sourceRoot":"","sources":["../../../src/domains/FunctionalSchema.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,6BAA6B;AAC7B,sDAA+C;AAC/C,oDAAiD;AACjD,oDAAiD;AAEjD,8CAA+C;AAC/C,sCAA4C;AAC5C,uDAAuD;
|
|
1
|
+
{"version":3,"file":"FunctionalSchema.js","sourceRoot":"","sources":["../../../src/domains/FunctionalSchema.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,6BAA6B;AAC7B,sDAA+C;AAC/C,oDAAiD;AACjD,oDAAiD;AAEjD,8CAA+C;AAC/C,sCAA4C;AAC5C,uDAAuD;AACvD,iDAAgD;AAEhD,cAAc;AACd,MAAa,gBAAiB,SAAQ,eAAM;IACnC,MAAM,KAAc,UAAU,KAAa,OAAO,YAAY,CAAC,CAAC,CAAC;IACjE,MAAM,KAAK,cAAc,KAAa,OAAO,IAAI,CAAC,IAAI,CAAC,2BAAc,CAAC,eAAe,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,gBAAgB,CAAC,UAAU,eAAe,CAAC,CAAC,CAAC,CAAC;IAC/J,MAAM,CAAC,cAAc;QAC1B,IAAI,IAAI,KAAK,gBAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YAC1D,gBAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC1C,gBAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YAC7B,6BAAa,CAAC,cAAc,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;IAED,cAAc;IACP,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,QAAkB;QACjD,IAAI,QAAQ,CAAC,aAAa,EAAE;YAC1B,MAAM,QAAQ,CAAC,iBAAiB,EAAE,CAAC;QAErC,MAAM,IAAI,GAAG,QAAQ,CAAC,mBAAS,CAAC,CAAC,sBAAsB,EAAE,CAAC;QAC1D,IAAI,uBAAQ,CAAC,YAAY,KAAK,IAAI,EAAE,CAAC;YACnC,MAAM,IAAI,yBAAW,CAAC,IAAI,EAAE,mCAAmC,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;CACF;AArBD,4CAqBC","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 { DbResult } from \"@itwin/core-bentley\";\r\nimport { IModelError } from \"@itwin/core-common\";\r\nimport { ClassRegistry } from \"../ClassRegistry\";\r\nimport { IModelDb } from \"../IModelDb\";\r\nimport { KnownLocations } from \"../IModelHost\";\r\nimport { Schema, Schemas } from \"../Schema\";\r\nimport * as elementsModule from \"./FunctionalElements\";\r\nimport { _nativeDb } from \"../internal/Symbols\";\r\n\r\n/** @public */\r\nexport class FunctionalSchema extends Schema {\r\n public static override get schemaName(): string { return \"Functional\"; }\r\n public static get schemaFilePath(): string { return path.join(KnownLocations.nativeAssetsDir, \"ECSchemas\", \"Domain\", `${FunctionalSchema.schemaName}.ecschema.xml`); }\r\n public static registerSchema() {\r\n if (this !== Schemas.getRegisteredSchema(this.schemaName)) {\r\n Schemas.unregisterSchema(this.schemaName);\r\n Schemas.registerSchema(this);\r\n ClassRegistry.registerModule(elementsModule, this);\r\n }\r\n }\r\n\r\n /** @public */\r\n public static async importSchema(iModelDb: IModelDb) {\r\n if (iModelDb.isBriefcaseDb())\r\n await iModelDb.acquireSchemaLock();\r\n\r\n const stat = iModelDb[_nativeDb].importFunctionalSchema();\r\n if (DbResult.BE_SQLITE_OK !== stat) {\r\n throw new IModelError(stat, \"Error importing Functional schema\");\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenericElements.js","sourceRoot":"","sources":["../../../src/domains/GenericElements.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,oDAG4B;AAC5B,wCAGoB;AAEpB,0CAA+C;AAC/C,oCAAmE;AACnE,sEAAyE;AAEzE;;GAEG;AACH,MAAsB,eAAgB,SAAQ,4BAAkB;IACvD,MAAM,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,SAAS,KAAa,OAAO,iBAAiB,CAAC,CAAC,CAAC;IAC5E,YAAmB,KAAiC,EAAE,MAAgB;QACpE,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACvB,CAAC;CACF;AALD,wDAKC","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 Elements\n */\n\nimport { Id64String } from \"@itwin/core-bentley\";\nimport {\n CalloutProps, DefinitionElementProps, ElementProps, GeometricElement2dProps, GeometricElement3dProps, GeometricModel3dProps, IModel,\n InformationPartitionElementProps, ModelProps, PhysicalElementProps, PhysicalTypeProps, TypeDefinitionElementProps, ViewAttachmentLabelProps,\n} from \"@itwin/core-common\";\nimport {\n Document, GraphicalElement2d, GraphicalElement3d, GraphicalPartition3d, GraphicalType2d, GroupInformationElement, GroupInformationPartition,\n PhysicalElement, PhysicalType, SpatialLocationElement,\n} from \"../Element\";\nimport { IModelDb } from \"../IModelDb\";\nimport { PhysicalMaterial } from \"../Material\";\nimport { GraphicalModel3d, GroupInformationModel } from \"../Model\";\nimport { SubjectOwnsPartitionElements } from \"../NavigationRelationship\";\n\n/** A graphical detailing symbol that is placed on a [[Drawing]] or [[Sheet]].\n * @public\n */\nexport abstract class DetailingSymbol extends GraphicalElement2d {\n public static override get className(): string { return \"DetailingSymbol\"; }\n public constructor(props: GeometricElement2dProps, iModel: IModelDb) {\n super(props, iModel);\n }\n}\n\n/** A graphical DetailingSymbol that contains title text.\n * @public\n */\nexport class TitleText extends DetailingSymbol {\n public static override get className(): string { return \"TitleText\"; }\n public constructor(props: GeometricElement2dProps, iModel: IModelDb) {\n super(props, iModel);\n }\n}\n\n/** A graphical DetailingSymbol that contains a view attachment label.\n * @public\n */\nexport class ViewAttachmentLabel extends DetailingSymbol {\n public static override get className(): string { return \"ViewAttachmentLabel\"; }\n public constructor(props: ViewAttachmentLabelProps, iModel: IModelDb) {\n super(props, iModel);\n }\n}\n\n/** A graphical DetailingSymbol that calls out a reference to another drawing.\n * @public\n */\nexport abstract class Callout extends DetailingSymbol {\n public static override get className(): string { return \"Callout\"; }\n public constructor(props: CalloutProps, iModel: IModelDb) {\n super(props, iModel);\n }\n}\n\n/** A graphical Callout that references a section drawing.\n * @public\n */\nexport class SectionCallout extends Callout {\n public static override get className(): string { return \"SectionCallout\"; }\n public constructor(props: CalloutProps, iModel: IModelDb) {\n super(props, iModel);\n }\n}\n\n/** A graphical Callout that references an elevation drawing.\n * @public\n */\nexport class ElevationCallout extends Callout {\n public static override get className(): string { return \"ElevationCallout\"; }\n public constructor(props: CalloutProps, iModel: IModelDb) {\n super(props, iModel);\n }\n}\n\n/** A graphical Callout that references a plan drawing.\n * @public\n */\nexport class PlanCallout extends Callout {\n public static override get className(): string { return \"PlanCallout\"; }\n public constructor(props: CalloutProps, iModel: IModelDb) {\n super(props, iModel);\n }\n}\n\n/** A graphical Callout that references a detail drawing.\n * @public\n */\nexport class DetailCallout extends Callout {\n public static override get className(): string { return \"DetailCallout\"; }\n public constructor(props: CalloutProps, iModel: IModelDb) {\n super(props, iModel);\n }\n}\n\n/** A generic container for persisting BisCore:GraphicalElement3d instances.\n * @public\n */\nexport class GenericGraphicalModel3d extends GraphicalModel3d {\n public static override get className(): string { return \"GraphicalModel3d\"; }\n public constructor(props: GeometricModel3dProps, iModel: IModelDb) {\n super(props, iModel);\n }\n /** Insert a BisCore:GraphicalPartition3d and a Generic:GraphicalModel3d that sub-models it.\n * @param iModelDb Insert into this iModel\n * @param parentSubjectId The GraphicalPartition3d will be inserted as a child of this Subject element.\n * @param name The name of the GraphicalPartition3d that the new Generic:GraphicalModel3d will sub-model.\n * @param isPlanProjection Optional value (default is false) that indicates if the contents of this model are expected to be in an XY plane.\n * @returns The Id of the newly inserted GraphicalPartition3d and GraphicalModel3d (same value).\n * @throws [[IModelError]] if there is an insert problem.\n */\n public static insert(iModelDb: IModelDb, parentSubjectId: Id64String, name: string, isPlanProjection?: boolean): Id64String {\n const partitionProps: InformationPartitionElementProps = {\n classFullName: GraphicalPartition3d.classFullName,\n model: IModel.repositoryModelId,\n parent: new SubjectOwnsPartitionElements(parentSubjectId),\n code: GraphicalPartition3d.createCode(iModelDb, parentSubjectId, name),\n };\n const partitionId = iModelDb.elements.insertElement(partitionProps);\n const modelProps: GeometricModel3dProps = {\n classFullName: this.classFullName,\n modeledElement: { id: partitionId },\n isPlanProjection,\n };\n return iModelDb.models.insertModel(modelProps);\n }\n}\n\n/** The Generic:Graphic3d class is used when 3D graphics cannot be further classified.\n * @note More-specific BisCore:GraphicalElement3d subclasses should be used wherever possible.\n * @public\n */\nexport class Graphic3d extends GraphicalElement3d {\n public static override get className(): string { return \"Graphic3d\"; }\n public constructor(props: GeometricElement3dProps, iModel: IModelDb) {\n super(props, iModel);\n }\n}\n\n/** The Generic:PhysicalObject class is used when physical elements cannot be further classified.\n * @note More-specific BisCore:PhysicalElement subclasses should be used wherever possible.\n * @public\n */\nexport class PhysicalObject extends PhysicalElement {\n public static override get className(): string { return \"PhysicalObject\"; }\n public constructor(props: PhysicalElementProps, iModel: IModelDb) {\n super(props, iModel);\n }\n}\n\n/** The Generic:SpatialLocation class is used when spatial locations cannot be further classified.\n * @note More-specific BisCore:SpatialLocationElement subclasses should be used wherever possible.\n * @public\n */\nexport class SpatialLocation extends SpatialLocationElement {\n public static override get className(): string { return \"SpatialLocation\"; }\n public constructor(props: GeometricElement3dProps, iModel: IModelDb) {\n super(props, iModel);\n }\n}\n\n/** A generic container for BisCore:GroupInformationElement instances.\n * @public\n */\nexport class GroupModel extends GroupInformationModel {\n public static override get className(): string { return \"GroupModel\"; }\n public constructor(props: ModelProps, iModel: IModelDb) {\n super(props, iModel);\n }\n /** Insert a GroupInformationPartition and a GroupModel that breaks it down.\n * @param iModelDb Insert into this iModel\n * @param parentSubjectId The GroupInformationPartition will be inserted as a child of this Subject element.\n * @param name The name of the GroupInformationPartition that the new GroupModel will break down.\n * @returns The Id of the newly inserted GroupModel.\n * @throws [[IModelError]] if there is an insert problem.\n */\n public static insert(iModelDb: IModelDb, parentSubjectId: Id64String, name: string): Id64String {\n const partitionProps: InformationPartitionElementProps = {\n classFullName: GroupInformationPartition.classFullName,\n model: IModel.repositoryModelId,\n parent: new SubjectOwnsPartitionElements(parentSubjectId),\n code: GroupInformationPartition.createCode(iModelDb, parentSubjectId, name),\n };\n const partitionId = iModelDb.elements.insertElement(partitionProps);\n return iModelDb.models.insertModel({\n classFullName: this.classFullName,\n modeledElement: { id: partitionId },\n });\n }\n}\n\n/** The Generic:Group class is used when the group cannot be further classified.\n * @public\n */\nexport class Group extends GroupInformationElement {\n public static override get className(): string { return \"Group\"; }\n public constructor(props: ElementProps, iModel: IModelDb) {\n super(props, iModel);\n }\n}\n\n/** The Generic:Document class is used when a document cannot be further classified.\n * @note More-specific BisCore:Document subclasses should be used wherever possible.\n * @public\n */\nexport class GenericDocument extends Document {\n public static override get className(): string { return \"Document\"; }\n public constructor(props: ElementProps, iModel: IModelDb) {\n super(props, iModel);\n }\n}\n\n/** The Generic:PhysicalMaterial class is used when the physical material cannot be further classified.\n * @note More-specific BisCore:PhysicalMaterial subclasses should be used wherever possible.\n * @public\n */\nexport class GenericPhysicalMaterial extends PhysicalMaterial {\n public static override get className(): string { return \"PhysicalMaterial\"; }\n public constructor(props: DefinitionElementProps, iModel: IModelDb) {\n super(props, iModel);\n }\n}\n\n/** The Generic:PhysicalType class is used when the physical type cannot be further classified.\n * @note More-specific BisCore:PhysicalType subclasses should be used wherever possible.\n * @public\n */\nexport class GenericPhysicalType extends PhysicalType {\n public static override get className(): string { return \"PhysicalType\"; }\n public constructor(props: PhysicalTypeProps, iModel: IModelDb) {\n super(props, iModel);\n }\n}\n\n/** The Generic:GraphicalType2d class is used when graphical types cannot be further classified.\n * @note More-specific BisCore:GraphicalType2d subclasses should be used wherever possible.\n * @public\n */\nexport class GenericGraphicalType2d extends GraphicalType2d {\n public static override get className(): string { return \"GraphicalType2d\"; }\n public constructor(props: TypeDefinitionElementProps, iModel: IModelDb) {\n super(props, iModel);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"GenericElements.js","sourceRoot":"","sources":["../../../src/domains/GenericElements.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,oDAG4B;AAC5B,wCAGoB;AAEpB,0CAA+C;AAC/C,oCAAmE;AACnE,sEAAyE;AAEzE;;GAEG;AACH,MAAsB,eAAgB,SAAQ,4BAAkB;IACvD,MAAM,KAAc,SAAS,KAAa,OAAO,iBAAiB,CAAC,CAAC,CAAC;IAC5E,YAAmB,KAA8B,EAAE,MAAgB;QACjE,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACvB,CAAC;CACF;AALD,0CAKC;AAED;;GAEG;AACH,MAAa,SAAU,SAAQ,eAAe;IACrC,MAAM,KAAc,SAAS,KAAa,OAAO,WAAW,CAAC,CAAC,CAAC;IACtE,YAAmB,KAA8B,EAAE,MAAgB;QACjE,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACvB,CAAC;CACF;AALD,8BAKC;AAED;;GAEG;AACH,MAAa,mBAAoB,SAAQ,eAAe;IAC/C,MAAM,KAAc,SAAS,KAAa,OAAO,qBAAqB,CAAC,CAAC,CAAC;IAChF,YAAmB,KAA+B,EAAE,MAAgB;QAClE,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACvB,CAAC;CACF;AALD,kDAKC;AAED;;GAEG;AACH,MAAsB,OAAQ,SAAQ,eAAe;IAC5C,MAAM,KAAc,SAAS,KAAa,OAAO,SAAS,CAAC,CAAC,CAAC;IACpE,YAAmB,KAAmB,EAAE,MAAgB;QACtD,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACvB,CAAC;CACF;AALD,0BAKC;AAED;;GAEG;AACH,MAAa,cAAe,SAAQ,OAAO;IAClC,MAAM,KAAc,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QAChE,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACvB,CAAC;CACF;AALD,0DAKC;AAED;;;GAGG;AACH,MAAa,mBAAoB,SAAQ,sBAAY;IAC5C,MAAM,KAAc,SAAS,KAAa,OAAO,cAAc,CAAC,CAAC,CAAC;IACzE,YAAmB,KAAwB,EAAE,MAAgB;QAC3D,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACvB,CAAC;CACF;AALD,kDAKC;AAED;;;GAGG;AACH,MAAa,sBAAuB,SAAQ,yBAAe;IAClD,MAAM,KAAc,SAAS,KAAa,OAAO,iBAAiB,CAAC,CAAC,CAAC;IAC5E,YAAmB,KAAiC,EAAE,MAAgB;QACpE,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACvB,CAAC;CACF;AALD,wDAKC","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 Elements\r\n */\r\n\r\nimport { Id64String } from \"@itwin/core-bentley\";\r\nimport {\r\n CalloutProps, DefinitionElementProps, ElementProps, GeometricElement2dProps, GeometricElement3dProps, GeometricModel3dProps, IModel,\r\n InformationPartitionElementProps, ModelProps, PhysicalElementProps, PhysicalTypeProps, TypeDefinitionElementProps, ViewAttachmentLabelProps,\r\n} from \"@itwin/core-common\";\r\nimport {\r\n Document, GraphicalElement2d, GraphicalElement3d, GraphicalPartition3d, GraphicalType2d, GroupInformationElement, GroupInformationPartition,\r\n PhysicalElement, PhysicalType, SpatialLocationElement,\r\n} from \"../Element\";\r\nimport { IModelDb } from \"../IModelDb\";\r\nimport { PhysicalMaterial } from \"../Material\";\r\nimport { GraphicalModel3d, GroupInformationModel } from \"../Model\";\r\nimport { SubjectOwnsPartitionElements } from \"../NavigationRelationship\";\r\n\r\n/** A graphical detailing symbol that is placed on a [[Drawing]] or [[Sheet]].\r\n * @public\r\n */\r\nexport abstract class DetailingSymbol extends GraphicalElement2d {\r\n public static override get className(): string { return \"DetailingSymbol\"; }\r\n public constructor(props: GeometricElement2dProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n }\r\n}\r\n\r\n/** A graphical DetailingSymbol that contains title text.\r\n * @public\r\n */\r\nexport class TitleText extends DetailingSymbol {\r\n public static override get className(): string { return \"TitleText\"; }\r\n public constructor(props: GeometricElement2dProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n }\r\n}\r\n\r\n/** A graphical DetailingSymbol that contains a view attachment label.\r\n * @public\r\n */\r\nexport class ViewAttachmentLabel extends DetailingSymbol {\r\n public static override get className(): string { return \"ViewAttachmentLabel\"; }\r\n public constructor(props: ViewAttachmentLabelProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n }\r\n}\r\n\r\n/** A graphical DetailingSymbol that calls out a reference to another drawing.\r\n * @public\r\n */\r\nexport abstract class Callout extends DetailingSymbol {\r\n public static override get className(): string { return \"Callout\"; }\r\n public constructor(props: CalloutProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n }\r\n}\r\n\r\n/** A graphical Callout that references a section drawing.\r\n * @public\r\n */\r\nexport class SectionCallout extends Callout {\r\n public static override get className(): string { return \"SectionCallout\"; }\r\n public constructor(props: CalloutProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n }\r\n}\r\n\r\n/** A graphical Callout that references an elevation drawing.\r\n * @public\r\n */\r\nexport class ElevationCallout extends Callout {\r\n public static override get className(): string { return \"ElevationCallout\"; }\r\n public constructor(props: CalloutProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n }\r\n}\r\n\r\n/** A graphical Callout that references a plan drawing.\r\n * @public\r\n */\r\nexport class PlanCallout extends Callout {\r\n public static override get className(): string { return \"PlanCallout\"; }\r\n public constructor(props: CalloutProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n }\r\n}\r\n\r\n/** A graphical Callout that references a detail drawing.\r\n * @public\r\n */\r\nexport class DetailCallout extends Callout {\r\n public static override get className(): string { return \"DetailCallout\"; }\r\n public constructor(props: CalloutProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n }\r\n}\r\n\r\n/** A generic container for persisting BisCore:GraphicalElement3d instances.\r\n * @public\r\n */\r\nexport class GenericGraphicalModel3d extends GraphicalModel3d {\r\n public static override get className(): string { return \"GraphicalModel3d\"; }\r\n public constructor(props: GeometricModel3dProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n }\r\n /** Insert a BisCore:GraphicalPartition3d and a Generic:GraphicalModel3d that sub-models it.\r\n * @param iModelDb Insert into this iModel\r\n * @param parentSubjectId The GraphicalPartition3d will be inserted as a child of this Subject element.\r\n * @param name The name of the GraphicalPartition3d that the new Generic:GraphicalModel3d will sub-model.\r\n * @param isPlanProjection Optional value (default is false) that indicates if the contents of this model are expected to be in an XY plane.\r\n * @returns The Id of the newly inserted GraphicalPartition3d and GraphicalModel3d (same value).\r\n * @throws [[IModelError]] if there is an insert problem.\r\n */\r\n public static insert(iModelDb: IModelDb, parentSubjectId: Id64String, name: string, isPlanProjection?: boolean): Id64String {\r\n const partitionProps: InformationPartitionElementProps = {\r\n classFullName: GraphicalPartition3d.classFullName,\r\n model: IModel.repositoryModelId,\r\n parent: new SubjectOwnsPartitionElements(parentSubjectId),\r\n code: GraphicalPartition3d.createCode(iModelDb, parentSubjectId, name),\r\n };\r\n const partitionId = iModelDb.elements.insertElement(partitionProps);\r\n const modelProps: GeometricModel3dProps = {\r\n classFullName: this.classFullName,\r\n modeledElement: { id: partitionId },\r\n isPlanProjection,\r\n };\r\n return iModelDb.models.insertModel(modelProps);\r\n }\r\n}\r\n\r\n/** The Generic:Graphic3d class is used when 3D graphics cannot be further classified.\r\n * @note More-specific BisCore:GraphicalElement3d subclasses should be used wherever possible.\r\n * @public\r\n */\r\nexport class Graphic3d extends GraphicalElement3d {\r\n public static override get className(): string { return \"Graphic3d\"; }\r\n public constructor(props: GeometricElement3dProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n }\r\n}\r\n\r\n/** The Generic:PhysicalObject class is used when physical elements cannot be further classified.\r\n * @note More-specific BisCore:PhysicalElement subclasses should be used wherever possible.\r\n * @public\r\n */\r\nexport class PhysicalObject extends PhysicalElement {\r\n public static override get className(): string { return \"PhysicalObject\"; }\r\n public constructor(props: PhysicalElementProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n }\r\n}\r\n\r\n/** The Generic:SpatialLocation class is used when spatial locations cannot be further classified.\r\n * @note More-specific BisCore:SpatialLocationElement subclasses should be used wherever possible.\r\n * @public\r\n */\r\nexport class SpatialLocation extends SpatialLocationElement {\r\n public static override get className(): string { return \"SpatialLocation\"; }\r\n public constructor(props: GeometricElement3dProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n }\r\n}\r\n\r\n/** A generic container for BisCore:GroupInformationElement instances.\r\n * @public\r\n */\r\nexport class GroupModel extends GroupInformationModel {\r\n public static override get className(): string { return \"GroupModel\"; }\r\n public constructor(props: ModelProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n }\r\n /** Insert a GroupInformationPartition and a GroupModel that breaks it down.\r\n * @param iModelDb Insert into this iModel\r\n * @param parentSubjectId The GroupInformationPartition will be inserted as a child of this Subject element.\r\n * @param name The name of the GroupInformationPartition that the new GroupModel will break down.\r\n * @returns The Id of the newly inserted GroupModel.\r\n * @throws [[IModelError]] if there is an insert problem.\r\n */\r\n public static insert(iModelDb: IModelDb, parentSubjectId: Id64String, name: string): Id64String {\r\n const partitionProps: InformationPartitionElementProps = {\r\n classFullName: GroupInformationPartition.classFullName,\r\n model: IModel.repositoryModelId,\r\n parent: new SubjectOwnsPartitionElements(parentSubjectId),\r\n code: GroupInformationPartition.createCode(iModelDb, parentSubjectId, name),\r\n };\r\n const partitionId = iModelDb.elements.insertElement(partitionProps);\r\n return iModelDb.models.insertModel({\r\n classFullName: this.classFullName,\r\n modeledElement: { id: partitionId },\r\n });\r\n }\r\n}\r\n\r\n/** The Generic:Group class is used when the group cannot be further classified.\r\n * @public\r\n */\r\nexport class Group extends GroupInformationElement {\r\n public static override get className(): string { return \"Group\"; }\r\n public constructor(props: ElementProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n }\r\n}\r\n\r\n/** The Generic:Document class is used when a document cannot be further classified.\r\n * @note More-specific BisCore:Document subclasses should be used wherever possible.\r\n * @public\r\n */\r\nexport class GenericDocument extends Document {\r\n public static override get className(): string { return \"Document\"; }\r\n public constructor(props: ElementProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n }\r\n}\r\n\r\n/** The Generic:PhysicalMaterial class is used when the physical material cannot be further classified.\r\n * @note More-specific BisCore:PhysicalMaterial subclasses should be used wherever possible.\r\n * @public\r\n */\r\nexport class GenericPhysicalMaterial extends PhysicalMaterial {\r\n public static override get className(): string { return \"PhysicalMaterial\"; }\r\n public constructor(props: DefinitionElementProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n }\r\n}\r\n\r\n/** The Generic:PhysicalType class is used when the physical type cannot be further classified.\r\n * @note More-specific BisCore:PhysicalType subclasses should be used wherever possible.\r\n * @public\r\n */\r\nexport class GenericPhysicalType extends PhysicalType {\r\n public static override get className(): string { return \"PhysicalType\"; }\r\n public constructor(props: PhysicalTypeProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n }\r\n}\r\n\r\n/** The Generic:GraphicalType2d class is used when graphical types cannot be further classified.\r\n * @note More-specific BisCore:GraphicalType2d subclasses should be used wherever possible.\r\n * @public\r\n */\r\nexport class GenericGraphicalType2d extends GraphicalType2d {\r\n public static override get className(): string { return \"GraphicalType2d\"; }\r\n public constructor(props: TypeDefinitionElementProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenericSchema.js","sourceRoot":"","sources":["../../../src/domains/GenericSchema.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,6BAA6B;AAC7B,oDAAiD;AACjD,8CAA+C;AAC/C,sCAA4C;AAC5C,oDAAoD;AAEpD,cAAc;AACd,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;IACzJ,MAAM,CAAC,cAAc;QAC1B,IAAI,IAAI,KAAK,gBAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YAC1D,gBAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC1C,gBAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YAC7B,6BAAa,CAAC,cAAc,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;CACF;AAVD,sCAUC","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 { ClassRegistry } from \"../ClassRegistry\";\nimport { KnownLocations } from \"../IModelHost\";\nimport { Schema, Schemas } from \"../Schema\";\nimport * as elementsModule from \"./GenericElements\";\n\n/** @public */\nexport class GenericSchema extends Schema {\n public static override get schemaName(): string { return \"Generic\"; }\n public static get schemaFilePath(): string { return path.join(KnownLocations.nativeAssetsDir, \"ECSchemas\", \"Dgn\", `${GenericSchema.schemaName}.ecschema.xml`); }\n public static registerSchema() {\n if (this !== Schemas.getRegisteredSchema(this.schemaName)) {\n Schemas.unregisterSchema(this.schemaName);\n Schemas.registerSchema(this);\n ClassRegistry.registerModule(elementsModule, this);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"GenericSchema.js","sourceRoot":"","sources":["../../../src/domains/GenericSchema.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,6BAA6B;AAC7B,oDAAiD;AACjD,8CAA+C;AAC/C,sCAA4C;AAC5C,oDAAoD;AAEpD,cAAc;AACd,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;IACzJ,MAAM,CAAC,cAAc;QAC1B,IAAI,IAAI,KAAK,gBAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YAC1D,gBAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC1C,gBAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YAC7B,6BAAa,CAAC,cAAc,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;CACF;AAVD,sCAUC","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 { ClassRegistry } from \"../ClassRegistry\";\r\nimport { KnownLocations } from \"../IModelHost\";\r\nimport { Schema, Schemas } from \"../Schema\";\r\nimport * as elementsModule from \"./GenericElements\";\r\n\r\n/** @public */\r\nexport class GenericSchema extends Schema {\r\n public static override get schemaName(): string { return \"Generic\"; }\r\n public static get schemaFilePath(): string { return path.join(KnownLocations.nativeAssetsDir, \"ECSchemas\", \"Dgn\", `${GenericSchema.schemaName}.ecschema.xml`); }\r\n public static registerSchema() {\r\n if (this !== Schemas.getRegisteredSchema(this.schemaName)) {\r\n Schemas.unregisterSchema(this.schemaName);\r\n Schemas.registerSchema(this);\r\n ClassRegistry.registerModule(elementsModule, this);\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChangesetConflictArgs.js","sourceRoot":"","sources":["../../../src/internal/ChangesetConflictArgs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F","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\n/** @packageDocumentation\n * @module iModels\n */\n\nimport { DbChangeStage, DbConflictCause, DbOpcode, DbValueType, Id64String } from \"@itwin/core-bentley\";\n\nexport interface ChangesetConflictArgs {\n cause: DbConflictCause;\n opcode: DbOpcode;\n indirect: boolean;\n tableName: string;\n changesetFile?: string;\n columnCount: number;\n getForeignKeyConflicts: () => number;\n dump: () => void;\n setLastError: (message: string) => void;\n getPrimaryKeyColumns: () => number[];\n getValueType: (columnIndex: number, stage: DbChangeStage) => DbValueType | null | undefined;\n getValueBinary: (columnIndex: number, stage: DbChangeStage) => Uint8Array | null | undefined;\n getValueId: (columnIndex: number, stage: DbChangeStage) => Id64String | null | undefined;\n getValueText: (columnIndex: number, stage: DbChangeStage) => string | null | undefined;\n getValueInteger: (columnIndex: number, stage: DbChangeStage) => number | null | undefined;\n getValueDouble: (columnIndex: number, stage: DbChangeStage) => number | null | undefined;\n isValueNull: (columnIndex: number, stage: DbChangeStage) => boolean | undefined;\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"ChangesetConflictArgs.js","sourceRoot":"","sources":["../../../src/internal/ChangesetConflictArgs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module iModels\r\n */\r\n\r\nimport { DbChangeStage, DbConflictCause, DbOpcode, DbValueType, Id64String } from \"@itwin/core-bentley\";\r\n\r\nexport interface ChangesetConflictArgs {\r\n cause: DbConflictCause;\r\n opcode: DbOpcode;\r\n indirect: boolean;\r\n tableName: string;\r\n changesetFile?: string;\r\n columnCount: number;\r\n getForeignKeyConflicts: () => number;\r\n dump: () => void;\r\n setLastError: (message: string) => void;\r\n getPrimaryKeyColumns: () => number[];\r\n getValueType: (columnIndex: number, stage: DbChangeStage) => DbValueType | null | undefined;\r\n getValueBinary: (columnIndex: number, stage: DbChangeStage) => Uint8Array | null | undefined;\r\n getValueId: (columnIndex: number, stage: DbChangeStage) => Id64String | null | undefined;\r\n getValueText: (columnIndex: number, stage: DbChangeStage) => string | null | undefined;\r\n getValueInteger: (columnIndex: number, stage: DbChangeStage) => number | null | undefined;\r\n getValueDouble: (columnIndex: number, stage: DbChangeStage) => number | null | undefined;\r\n isValueNull: (columnIndex: number, stage: DbChangeStage) => boolean | undefined;\r\n}\r\n\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChannelAdmin.d.ts","sourceRoot":"","sources":["../../../src/internal/ChannelAdmin.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAY,UAAU,EAAgB,MAAM,qBAAqB,CAAC;AAGzE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,yBAAyB,
|
|
1
|
+
{"version":3,"file":"ChannelAdmin.d.ts","sourceRoot":"","sources":["../../../src/internal/ChannelAdmin.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH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are permitted to change any channel
|
|
63
|
-
if (this._allowedModels.has(modelId) || this._iModel.
|
|
63
|
+
if (this._allowedModels.has(modelId) || this._iModel[Symbols_1._nativeDb].isIndirectChanges())
|
|
64
64
|
return;
|
|
65
65
|
const deniedChannel = this._deniedModels.get(modelId);
|
|
66
66
|
if (undefined !== deniedChannel)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChannelAdmin.js","sourceRoot":"","sources":["../../../src/internal/ChannelAdmin.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;AAEH,sDAAyE;AACzE,oDAAiF;AACjF,wCAAqC;AAErC,8CAA2C;AAC3C,sDAA+D;AAC/D,uCAAsE;AAEtE,MAAM,YAAY;IAQhB,YAA2B,OAAiB;QAAjB,YAAO,GAAP,OAAO,CAAU;QAL5B,QAA2B,GAAG,SAAS,CAAC;QAChD,qBAAgB,GAAG,IAAI,GAAG,EAAc,CAAC;QACzC,mBAAc,GAAG,IAAI,GAAG,EAAc,CAAC;QACvC,kBAAa,GAAG,IAAI,GAAG,EAA0B,CAAC;QAGxD,2GAA2G;QAC3G,IAAI,uBAAU,CAAC,aAAa,EAAE,kBAAkB,KAAK,KAAK;YACxD,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,+BAAc,CAAC,iBAAiB,CAAC,CAAC;IAChE,CAAC;IAEM,iBAAiB,CAAC,UAAsB;QAC7C,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACtC,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;IAEM,oBAAoB,CAAC,UAAsB;QAChD,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACzC,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;IAEM,aAAa,CAAC,SAAqB;QACxC,IAAI,SAAS,KAAK,oBAAM,CAAC,aAAa;YACpC,OAAO,+B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CAAC;AAClC,CAAC;AAFD,oDAEC","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 Elements\n */\n\nimport { DbResult, Id64String, IModelStatus } from \"@itwin/core-bentley\";\nimport { ChannelRootAspectProps, IModel, IModelError } from \"@itwin/core-common\";\nimport { Subject } from \"../Element\";\nimport { IModelDb } from \"../IModelDb\";\nimport { IModelHost } from \"../IModelHost\";\nimport { ChannelControl, ChannelKey } from \"../ChannelControl\";\nimport { _implementationProhibited, _verifyChannel } from \"./Symbols\";\n\nclass ChannelAdmin implements ChannelControl {\n public static readonly channelClassName = \"bis:ChannelRootAspect\";\n\n public readonly [_implementationProhibited] = undefined;\n private _allowedChannels = new Set<ChannelKey>();\n private _allowedModels = new Set<Id64String>();\n private _deniedModels = new Map<Id64String, ChannelKey>();\n\n public constructor(private _iModel: IModelDb) {\n // for backwards compatibility, allow the shared channel unless explicitly turned off in IModelHostOptions.\n if (IModelHost.configuration?.allowSharedChannel !== false)\n this._allowedChannels.add(ChannelControl.sharedChannelName);\n }\n\n public addAllowedChannel(channelKey: ChannelKey) {\n this._allowedChannels.add(channelKey);\n this._deniedModels.clear();\n }\n\n public removeAllowedChannel(channelKey: ChannelKey) {\n this._allowedChannels.delete(channelKey);\n this._allowedModels.clear();\n }\n\n public getChannelKey(elementId: Id64String): ChannelKey {\n if (elementId === IModel.rootSubjectId)\n return ChannelControl.sharedChannelName;\n\n try {\n const channel = this._iModel.withPreparedStatement(`SELECT Owner FROM ${ChannelAdmin.channelClassName} WHERE Element.Id=?`, (stmt) => {\n stmt.bindId(1, elementId);\n return DbResult.BE_SQLITE_ROW === stmt.step() ? stmt.getValue(0).getString() : undefined;\n });\n\n if (channel !== undefined)\n return channel;\n } catch {\n // Exception happens if the iModel is too old: ChannelRootAspect class not present in the BisCore schema (older than v1.0.10).\n // In that case all data in such iModel is assumed to be in the shared channel.\n return ChannelControl.sharedChannelName;\n }\n\n const parentId = this._iModel.withPreparedSqliteStatement(\"SELECT ParentId,ModelId FROM bis_Element WHERE id=?\", (stmt) => {\n stmt.bindId(1, elementId);\n if (DbResult.BE_SQLITE_ROW !== stmt.step())\n throw new IModelError(IModelStatus.NotFound, \"Element does not exist\");\n return stmt.getValueId(0) ?? stmt.getValueId(1); // if parent is undefined, use modelId\n });\n\n return this.getChannelKey(parentId);\n }\n\n public [_verifyChannel](modelId: Id64String): void {\n // Note: indirect changes are permitted to change any channel\n if (this._allowedModels.has(modelId) || this._iModel.nativeDb.isIndirectChanges())\n return;\n\n const deniedChannel = this._deniedModels.get(modelId);\n if (undefined !== deniedChannel)\n throw new Error(`channel \"${deniedChannel}\" is not allowed`);\n\n const channel = this.getChannelKey(modelId);\n if (this._allowedChannels.has(channel)) {\n this._allowedModels.add(modelId);\n return;\n }\n\n this._deniedModels.set(modelId, channel);\n return this[_verifyChannel](modelId);\n }\n\n public makeChannelRoot(args: { elementId: Id64String, channelKey: ChannelKey }) {\n if (ChannelControl.sharedChannelName !== this.getChannelKey(args.elementId))\n throw new Error(\"channels may not nest\");\n\n if (this.queryChannelRoot(args.channelKey) !== undefined)\n throw new Error(\"a channel root for the specified key already exists\");\n\n const props: ChannelRootAspectProps = { classFullName: ChannelAdmin.channelClassName, element: { id: args.elementId }, owner: args.channelKey };\n this._iModel.elements.insertAspect(props);\n }\n\n public insertChannelSubject(args: { subjectName: string, channelKey: ChannelKey, parentSubjectId?: Id64String, description?: string }): Id64String {\n // Check if channelKey already exists before inserting Subject.\n // makeChannelRoot will check that again, but at that point the new Subject is already inserted.\n // Prefer to check twice instead of deleting the Subject in the latter option.\n if (this.queryChannelRoot(args.channelKey) !== undefined)\n throw new Error(\"a channel root for the specified key already exists\");\n\n const elementId = Subject.insert(this._iModel, args.parentSubjectId ?? IModel.rootSubjectId, args.subjectName, args.description);\n this.makeChannelRoot({ elementId, channelKey: args.channelKey });\n return elementId;\n }\n\n public queryChannelRoot(channelKey: ChannelKey): Id64String | undefined {\n if (channelKey === ChannelControl.sharedChannelName)\n // RootSubject acts as the ChannelRoot element of the shared channel\n return IModel.rootSubjectId;\n\n try {\n const channelRoot = this._iModel.withPreparedStatement(`SELECT Element.Id FROM ${ChannelAdmin.channelClassName} WHERE Owner=?`, (stmt) => {\n stmt.bindString(1, channelKey);\n return DbResult.BE_SQLITE_ROW === stmt.step() ? stmt.getValue(0).getId() : undefined;\n });\n\n return channelRoot;\n } catch {\n // Exception happens if the iModel is too old: ChannelRootAspect class not present in the BisCore schema (older than v1.0.10).\n // In that case all data in such iModel is assumed to be in the shared channel.\n return undefined;\n }\n\n }\n}\n\nexport function createChannelControl(iModel: IModelDb): ChannelAdmin {\n return new ChannelAdmin(iModel);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ChannelAdmin.js","sourceRoot":"","sources":["../../../src/internal/ChannelAdmin.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;AAEH,sDAAyE;AACzE,oDAAiF;AACjF,wCAAqC;AAErC,8CAA2C;AAC3C,sDAA+D;AAC/D,uCAAiF;AAEjF,MAAM,YAAY;IAQhB,YAA2B,OAAiB;QAAjB,YAAO,GAAP,OAAO,CAAU;QAL5B,QAA2B,GAAG,SAAS,CAAC;QAChD,qBAAgB,GAAG,IAAI,GAAG,EAAc,CAAC;QACzC,mBAAc,GAAG,IAAI,GAAG,EAAc,CAAC;QACvC,kBAAa,GAAG,IAAI,GAAG,EAA0B,CAAC;QAGxD,2GAA2G;QAC3G,IAAI,uBAAU,CAAC,aAAa,EAAE,kBAAkB,KAAK,KAAK;YACxD,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,+BAAc,CAAC,iBAAiB,CAAC,CAAC;IAChE,CAAC;IAEM,iBAAiB,CAAC,UAAsB;QAC7C,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACtC,I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AAS,CAAC;YACvF,CAAC,CAAC,CAAC;YAEH,OAAO,WAAW,CAAC;QACrB,CAAC;QAAC,MAAM,CAAC;YACP,8HAA8H;YAC9H,+EAA+E;YAC/E,OAAO,SAAS,CAAC;QACnB,CAAC;IAEH,CAAC;;AA/GsB,6BAAgB,GAAG,uBAAuB,AAA1B,CAA2B;AAkHpE,SAAgB,oBAAoB,CAAC,MAAgB;IACnD,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC;AAFD,oDAEC","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 Elements\r\n */\r\n\r\nimport { DbResult, Id64String, IModelStatus } from \"@itwin/core-bentley\";\r\nimport { ChannelRootAspectProps, IModel, IModelError } from \"@itwin/core-common\";\r\nimport { Subject } from \"../Element\";\r\nimport { IModelDb } from \"../IModelDb\";\r\nimport { IModelHost } from \"../IModelHost\";\r\nimport { ChannelControl, ChannelKey } from \"../ChannelControl\";\r\nimport { _implementationProhibited, _nativeDb, _verifyChannel } from \"./Symbols\";\r\n\r\nclass ChannelAdmin implements ChannelControl {\r\n public static readonly channelClassName = \"bis:ChannelRootAspect\";\r\n\r\n public readonly [_implementationProhibited] = undefined;\r\n private _allowedChannels = new Set<ChannelKey>();\r\n private _allowedModels = new Set<Id64String>();\r\n private _deniedModels = new Map<Id64String, ChannelKey>();\r\n\r\n public constructor(private _iModel: IModelDb) {\r\n // for backwards compatibility, allow the shared channel unless explicitly turned off in IModelHostOptions.\r\n if (IModelHost.configuration?.allowSharedChannel !== false)\r\n this._allowedChannels.add(ChannelControl.sharedChannelName);\r\n }\r\n\r\n public addAllowedChannel(channelKey: ChannelKey) {\r\n this._allowedChannels.add(channelKey);\r\n this._deniedModels.clear();\r\n }\r\n\r\n public removeAllowedChannel(channelKey: ChannelKey) {\r\n this._allowedChannels.delete(channelKey);\r\n this._allowedModels.clear();\r\n }\r\n\r\n public getChannelKey(elementId: Id64String): ChannelKey {\r\n if (elementId === IModel.rootSubjectId)\r\n return ChannelControl.sharedChannelName;\r\n\r\n try {\r\n const channel = this._iModel.withPreparedStatement(`SELECT Owner FROM ${ChannelAdmin.channelClassName} WHERE Element.Id=?`, (stmt) => {\r\n stmt.bindId(1, elementId);\r\n return DbResult.BE_SQLITE_ROW === stmt.step() ? stmt.getValue(0).getString() : undefined;\r\n });\r\n\r\n if (channel !== undefined)\r\n return channel;\r\n } catch {\r\n // Exception happens if the iModel is too old: ChannelRootAspect class not present in the BisCore schema (older than v1.0.10).\r\n // In that case all data in such iModel is assumed to be in the shared channel.\r\n return ChannelControl.sharedChannelName;\r\n }\r\n\r\n const parentId = this._iModel.withPreparedSqliteStatement(\"SELECT ParentId,ModelId FROM bis_Element WHERE id=?\", (stmt) => {\r\n stmt.bindId(1, elementId);\r\n if (DbResult.BE_SQLITE_ROW !== stmt.step())\r\n throw new IModelError(IModelStatus.NotFound, \"Element does not exist\");\r\n return stmt.getValueId(0) ?? stmt.getValueId(1); // if parent is undefined, use modelId\r\n });\r\n\r\n return this.getChannelKey(parentId);\r\n }\r\n\r\n public [_verifyChannel](modelId: Id64String): void {\r\n // Note: indirect changes are permitted to change any channel\r\n if (this._allowedModels.has(modelId) || this._iModel[_nativeDb].isIndirectChanges())\r\n return;\r\n\r\n const deniedChannel = this._deniedModels.get(modelId);\r\n if (undefined !== deniedChannel)\r\n throw new Error(`channel \"${deniedChannel}\" is not allowed`);\r\n\r\n const channel = this.getChannelKey(modelId);\r\n if (this._allowedChannels.has(channel)) {\r\n this._allowedModels.add(modelId);\r\n return;\r\n }\r\n\r\n this._deniedModels.set(modelId, channel);\r\n return this[_verifyChannel](modelId);\r\n }\r\n\r\n public makeChannelRoot(args: { elementId: Id64String, channelKey: ChannelKey }) {\r\n if (ChannelControl.sharedChannelName !== this.getChannelKey(args.elementId))\r\n throw new Error(\"channels may not nest\");\r\n\r\n if (this.queryChannelRoot(args.channelKey) !== undefined)\r\n throw new Error(\"a channel root for the specified key already exists\");\r\n\r\n const props: ChannelRootAspectProps = { classFullName: ChannelAdmin.channelClassName, element: { id: args.elementId }, owner: args.channelKey };\r\n this._iModel.elements.insertAspect(props);\r\n }\r\n\r\n public insertChannelSubject(args: { subjectName: string, channelKey: ChannelKey, parentSubjectId?: Id64String, description?: string }): Id64String {\r\n // Check if channelKey already exists before inserting Subject.\r\n // makeChannelRoot will check that again, but at that point the new Subject is already inserted.\r\n // Prefer to check twice instead of deleting the Subject in the latter option.\r\n if (this.queryChannelRoot(args.channelKey) !== undefined)\r\n throw new Error(\"a channel root for the specified key already exists\");\r\n\r\n const elementId = Subject.insert(this._iModel, args.parentSubjectId ?? IModel.rootSubjectId, args.subjectName, args.description);\r\n this.makeChannelRoot({ elementId, channelKey: args.channelKey });\r\n return elementId;\r\n }\r\n\r\n public queryChannelRoot(channelKey: ChannelKey): Id64String | undefined {\r\n if (channelKey === ChannelControl.sharedChannelName)\r\n // RootSubject acts as the ChannelRoot element of the shared channel\r\n return IModel.rootSubjectId;\r\n\r\n try {\r\n const channelRoot = this._iModel.withPreparedStatement(`SELECT Element.Id FROM ${ChannelAdmin.channelClassName} WHERE Owner=?`, (stmt) => {\r\n stmt.bindString(1, channelKey);\r\n return DbResult.BE_SQLITE_ROW === stmt.step() ? stmt.getValue(0).getId() : undefined;\r\n });\r\n\r\n return channelRoot;\r\n } catch {\r\n // Exception happens if the iModel is too old: ChannelRootAspect class not present in the BisCore schema (older than v1.0.10).\r\n // In that case all data in such iModel is assumed to be in the shared channel.\r\n return undefined;\r\n }\r\n\r\n }\r\n}\r\n\r\nexport function createChannelControl(iModel: IModelDb): ChannelAdmin {\r\n return new ChannelAdmin(iModel);\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativePlatform.js","sourceRoot":"","sources":["../../../src/internal/NativePlatform.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,8DAAyE;AACzE,sDAA8D;AAE9D,IAAI,cAAiD,CAAC;AAEtD,IAAI,2BAAqD,CAAC;AAE1D,SAAS,mBAAmB;IAC1B,IAAI,2BAA2B,EAAE,CAAC;QAChC,2BAA2B,EAAE,CAAC;IAChC,CAAC;SAAM,CAAC;QACN,cAAc,EAAE,kBAAkB,EAAE,CAAC;IACvC,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAa,YAAY;IAChB,MAAM,KAAK,QAAQ;QACxB,IAAI,SAAS,KAAK,cAAc,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;QAC7D,CAAC;QAED,OAAO,cAAc,CAAC;IACxB,CAAC;CACF;AARD,oCAQC;AAED,6DAA6D;AAC7D,SAAgB,kBAAkB;IAChC,IAAI,SAAS,KAAK,cAAc,EAAE,CAAC;QACjC,cAAc,GAAG,8BAAe,CAAC,kBAAkB,CAAC,CAAC,CAAE,OAAe,CAAC,cAAc,CAAC,gBAAgB,CAA0B,CAAC,CAAC,CAAC,+BAAa,CAAC,IAAI,EAAE,CAAC;QACxJ,cAAc,CAAC,MAAM,GAAG,qBAAM,CAAC;QAC/B,qBAAM,CAAC,iBAAiB,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,mBAAmB,EAAE,CAAC,CAAC;IACpE,CAAC;AACH,CAAC;AAND,gDAMC;AAED,oCAAoC;AACpC,SAAgB,2BAA2B,CAAC,IAAiB;IAC3D,2BAA2B,GAAG,IAAI,CAAC;AACrC,CAAC;AAFD,kEAEC","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 IModelHost\n */\n\nimport { IModelJsNative, NativeLibrary } from \"@bentley/imodeljs-native\";\nimport { Logger, ProcessDetector } from \"@itwin/core-bentley\";\n\nlet nativePlatform: typeof IModelJsNative | undefined;\n\nlet syncNativeLogLevelsOverride: (() => void) | undefined;\n\nfunction syncNativeLogLevels() {\n if (syncNativeLogLevelsOverride) {\n syncNativeLogLevelsOverride();\n } else {\n nativePlatform?.clearLogLevelCache();\n }\n}\n\n/** Provides access to the internal APIs defined in @bentley/imodeljs-native.\n * @internal\n */\nexport class IModelNative {\n public static get platform(): typeof IModelJsNative {\n if (undefined === nativePlatform) {\n throw new Error(\"IModelHost.startup must be called first\");\n }\n\n return nativePlatform;\n }\n}\n\n/** @internal Strictly to be called by IModelHost.startup. */\nexport function loadNativePlatform(): void {\n if (undefined === nativePlatform) {\n nativePlatform = ProcessDetector.isMobileAppBackend ? (process as any)._linkedBinding(\"iModelJsNative\") as typeof IModelJsNative : NativeLibrary.load();\n nativePlatform.logger = Logger;\n Logger.onLogLevelChanged.addListener(() => syncNativeLogLevels());\n }\n}\n\n/** @internal Strictly for tests. */\nexport function overrideSyncNativeLogLevels(func?: () => void): void {\n syncNativeLogLevelsOverride = func;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"NativePlatform.js","sourceRoot":"","sources":["../../../src/internal/NativePlatform.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,8DAAyE;AACzE,sDAA8D;AAE9D,IAAI,cAAiD,CAAC;AAEtD,IAAI,2BAAqD,CAAC;AAE1D,SAAS,mBAAmB;IAC1B,IAAI,2BAA2B,EAAE,CAAC;QAChC,2BAA2B,EAAE,CAAC;IAChC,CAAC;SAAM,CAAC;QACN,cAAc,EAAE,kBAAkB,EAAE,CAAC;IACvC,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAa,YAAY;IAChB,MAAM,KAAK,QAAQ;QACxB,IAAI,SAAS,KAAK,cAAc,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;QAC7D,CAAC;QAED,OAAO,cAAc,CAAC;IACxB,CAAC;CACF;AARD,oCAQC;AAED,6DAA6D;AAC7D,SAAgB,kBAAkB;IAChC,IAAI,SAAS,KAAK,cAAc,EAAE,CAAC;QACjC,cAAc,GAAG,8BAAe,CAAC,kBAAkB,CAAC,CAAC,CAAE,OAAe,CAAC,cAAc,CAAC,gBAAgB,CAA0B,CAAC,CAAC,CAAC,+BAAa,CAAC,IAAI,EAAE,CAAC;QACxJ,cAAc,CAAC,MAAM,GAAG,qBAAM,CAAC;QAC/B,qBAAM,CAAC,iBAAiB,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,mBAAmB,EAAE,CAAC,CAAC;IACpE,CAAC;AACH,CAAC;AAND,gDAMC;AAED,oCAAoC;AACpC,SAAgB,2BAA2B,CAAC,IAAiB;IAC3D,2BAA2B,GAAG,IAAI,CAAC;AACrC,CAAC;AAFD,kEAEC","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 IModelHost\r\n */\r\n\r\nimport { IModelJsNative, NativeLibrary } from \"@bentley/imodeljs-native\";\r\nimport { Logger, ProcessDetector } from \"@itwin/core-bentley\";\r\n\r\nlet nativePlatform: typeof IModelJsNative | undefined;\r\n\r\nlet syncNativeLogLevelsOverride: (() => void) | undefined;\r\n\r\nfunction syncNativeLogLevels() {\r\n if (syncNativeLogLevelsOverride) {\r\n syncNativeLogLevelsOverride();\r\n } else {\r\n nativePlatform?.clearLogLevelCache();\r\n }\r\n}\r\n\r\n/** Provides access to the internal APIs defined in @bentley/imodeljs-native.\r\n * @internal\r\n */\r\nexport class IModelNative {\r\n public static get platform(): typeof IModelJsNative {\r\n if (undefined === nativePlatform) {\r\n throw new Error(\"IModelHost.startup must be called first\");\r\n }\r\n\r\n return nativePlatform;\r\n }\r\n}\r\n\r\n/** @internal Strictly to be called by IModelHost.startup. */\r\nexport function loadNativePlatform(): void {\r\n if (undefined === nativePlatform) {\r\n nativePlatform = ProcessDetector.isMobileAppBackend ? (process as any)._linkedBinding(\"iModelJsNative\") as typeof IModelJsNative : NativeLibrary.load();\r\n nativePlatform.logger = Logger;\r\n Logger.onLogLevelChanged.addListener(() => syncNativeLogLevels());\r\n }\r\n}\r\n\r\n/** @internal Strictly for tests. */\r\nexport function overrideSyncNativeLogLevels(func?: () => void): void {\r\n syncNativeLogLevelsOverride = func;\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoLocks.js","sourceRoot":"","sources":["../../../src/internal/NoLocks.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;AAO/F,uCAAoG;AAEpG,yJAAyJ;AACzJ,MAAM,OAAO;IAAb;QACkB,QAA2B,GAAG,SAAS,CAAC;IAW1D,CAAC;IAVC,IAAW,aAAa,KAAK,OAAO,KAAK,CAAC,CAAC,CAAC;IACrC,OAFU,mCAAyB,EAElC,gBAAM,EAAC,KAAW,CAAC;IACpB,aAAa,KAAW,CAAC;IACzB,kBAAkB,KAAc,OAAO,KAAK,CAAC,CAAC,CAAC;IAC/C,eAAe,KAAc,OAAO,KAAK,CAAC,CAAC,CAAC;IAC5C,kBAAkB,KAAW,CAAC;IAC9B,eAAe,KAAW,CAAC;IAC3B,CAAC,4BAAkB,CAAC,KAAW,CAAC;IAChC,KAAK,CAAC,YAAY,KAAK,CAAC;IACxB,KAAK,CAAC,CAAC,0BAAgB,CAAC,KAAoB,CAAC;CACrD;AAED,SAAgB,qBAAqB;IACnC,OAAO,IAAI,OAAO,EAAE,CAAC;AACvB,CAAC;AAFD,sDAEC","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\n/** @packageDocumentation\n * @module iModels\n */\n\nimport { LockControl } from \"../LockControl\";\nimport { _close, _elementWasCreated, _implementationProhibited, _releaseAllLocks } from \"./Symbols\";\n\n/** A null-implementation of LockControl that does not attempt to limit access between briefcases. This relies on change-merging to resolve conflicts. */\nclass NoLocks implements LockControl {\n public readonly [_implementationProhibited] = undefined;\n public get isServerBased() { return false; }\n public [_close](): void { }\n public clearAllLocks(): void { }\n public holdsExclusiveLock(): boolean { return false; }\n public holdsSharedLock(): boolean { return false; }\n public checkExclusiveLock(): void { }\n public checkSharedLock(): void { }\n public [_elementWasCreated](): void { }\n public async acquireLocks() { }\n public async [_releaseAllLocks](): Promise<void> { }\n}\n\nexport function createNoOpLockControl(): LockControl {\n return new NoLocks();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"NoLocks.js","sourceRoot":"","sources":["../../../src/internal/NoLocks.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;AAO/F,uCAAoG;AAEpG,yJAAyJ;AACzJ,MAAM,OAAO;IAAb;QACkB,QAA2B,GAAG,SAAS,CAAC;IAW1D,CAAC;IAVC,IAAW,aAAa,KAAK,OAAO,KAAK,CAAC,CAAC,CAAC;IACrC,OAFU,mCAAyB,EAElC,gBAAM,EAAC,KAAW,CAAC;IACpB,aAAa,KAAW,CAAC;IACzB,kBAAkB,KAAc,OAAO,KAAK,CAAC,CAAC,CAAC;IAC/C,eAAe,KAAc,OAAO,KAAK,CAAC,CAAC,CAAC;IAC5C,kBAAkB,KAAW,CAAC;IAC9B,eAAe,KAAW,CAAC;IAC3B,CAAC,4BAAkB,CAAC,KAAW,CAAC;IAChC,KAAK,CAAC,YAAY,KAAK,CAAC;IACxB,KAAK,CAAC,CAAC,0BAAgB,CAAC,KAAoB,CAAC;CACrD;AAED,SAAgB,qBAAqB;IACnC,OAAO,IAAI,OAAO,EAAE,CAAC;AACvB,CAAC;AAFD,sDAEC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module iModels\r\n */\r\n\r\nimport { LockControl } from \"../LockControl\";\r\nimport { _close, _elementWasCreated, _implementationProhibited, _releaseAllLocks } from \"./Symbols\";\r\n\r\n/** A null-implementation of LockControl that does not attempt to limit access between briefcases. This relies on change-merging to resolve conflicts. */\r\nclass NoLocks implements LockControl {\r\n public readonly [_implementationProhibited] = undefined;\r\n public get isServerBased() { return false; }\r\n public [_close](): void { }\r\n public clearAllLocks(): void { }\r\n public holdsExclusiveLock(): boolean { return false; }\r\n public holdsSharedLock(): boolean { return false; }\r\n public checkExclusiveLock(): void { }\r\n public checkSharedLock(): void { }\r\n public [_elementWasCreated](): void { }\r\n public async acquireLocks() { }\r\n public async [_releaseAllLocks](): Promise<void> { }\r\n}\r\n\r\nexport function createNoOpLockControl(): LockControl {\r\n return new NoLocks();\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServerBasedLocks.d.ts","sourceRoot":"","sources":["../../../src/internal/ServerBasedLocks.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAkB,OAAO,EAAE,UAAU,EAA0B,MAAM,qBAAqB,CAAC;AAClG,OAAO,EAAuB,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,yBAAyB,
|
|
1
|
+
{"version":3,"file":"ServerBasedLocks.d.ts","sourceRoot":"","sources":["../../../src/internal/ServerBasedLocks.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAkB,OAAO,EAAE,UAAU,EAA0B,MAAM,qBAAqB,CAAC;AAClG,OAAO,EAAuB,SAAS,EAAE,MAAM,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AO,KAAK,iBAAiB,GAAqD;IAElF,uGAAuG;IAChG,kBAAkB,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IAKzE,kGAAkG;IAC3F,eAAe,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAKvE;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAEvE"}
|
|
@@ -20,7 +20,7 @@ class ServerBasedLocks {
|
|
|
20
20
|
this[_a] = undefined;
|
|
21
21
|
this.lockDb = new SQLiteDb_1.SQLiteDb();
|
|
22
22
|
this.briefcase = iModel;
|
|
23
|
-
const dbName = `${iModel.
|
|
23
|
+
const dbName = `${iModel[Symbols_1._nativeDb].getTempFileBaseName()}-locks`;
|
|
24
24
|
try {
|
|
25
25
|
this.lockDb.openDb(dbName, core_bentley_1.OpenMode.ReadWrite);
|
|
26
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServerBasedLocks.js","sourceRoot":"","sources":["../../../src/internal/ServerBasedLocks.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;AAE/F;;GAEG;AAEH,sDAAkG;AAClG,oDAAoE;AAIpE,8CAA2C;AAC3C,0CAAuC;AACvC,uCAAoG;AAmBpG,MAAa,gBAAgB;IAG3B,IAAW,aAAa,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC;IAI3C,YAAmB,MAAmB;QANtB,QAA2B,GAAG,SAAS,CAAC;QAGrC,WAAM,GAAG,IAAI,mBAAQ,EAAE,CAAC;QAIzC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC;QACxB,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,mBAAmB,EAAE,QAAQ,CAAC;QAChE,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,uBAAQ,CAAC,SAAS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QAChE,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;IAC5B,CAAC;IAED,yDAAyD;IACzD,IAAY,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAElF,uGAAuG;IAChG,kBAAkB,CAAC,EAAc,EAAE,IAAY,EAAE,SAAiB;QACvE,IAAI,IAAI,CAAC,iBAAiB,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC;YACxD,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,WAAW,EAAE,8BAA8B,IAAI,QAAQ,SAAS,QAAQ,EAAE,GAAG,CAAC,CAAC;IACtH,CAAC;IAED,kGAAkG;IAC3F,eAAe,CAAC,EAAc,EAAE,IAAY,EAAE,SAAiB;QACpE,IAAI,IAAI,CAAC,iBAAiB,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC;YACrD,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,WAAW,EAAE,2BAA2B,IAAI,QAAQ,SAAS,QAAQ,EAAE,GAAG,CAAC,CAAC;IACnH,CAAC;CAEF;AApLD,4CAoLC;AAED,SAAgB,sBAAsB,CAAC,MAAmB;IACxD,OAAO,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC;AAFD,wDAEC","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\n/** @packageDocumentation\n * @module iModels\n */\n\nimport { DbResult, Id64, Id64Arg, Id64String, IModelStatus, OpenMode } from \"@itwin/core-bentley\";\nimport { IModel, IModelError, LockState } from \"@itwin/core-common\";\nimport { LockMap } from \"../BackendHubAccess\";\nimport { BriefcaseDb } from \"../IModelDb\";\nimport { LockControl } from \"../LockControl\";\nimport { IModelHost } from \"../IModelHost\";\nimport { SQLiteDb } from \"../SQLiteDb\";\nimport { _close, _elementWasCreated, _implementationProhibited, _releaseAllLocks } from \"./Symbols\";\n\n/**\n * Both the Model and Parent of an element are considered \"owners\" of their member elements. That means:\n * 1) they must hold at least a shared lock before an exclusive lock can be acquired for their members\n * 2) if they hold an exclusive lock, then all of their members are exclusively locked implicitly.\n */\ninterface ElementOwners {\n readonly modelId: Id64String;\n readonly parentId: Id64String | undefined;\n}\n\n// eslint-disable-next-line no-restricted-syntax\nconst enum LockOrigin {\n Acquired = 0,\n NewElement = 1,\n Discovered = 2,\n}\n\nexport class ServerBasedLocks implements LockControl {\n public readonly [_implementationProhibited] = undefined;\n\n public get isServerBased() { return true; }\n protected readonly lockDb = new SQLiteDb();\n protected readonly briefcase: BriefcaseDb;\n\n public constructor(iModel: BriefcaseDb) {\n this.briefcase = iModel;\n const dbName = `${iModel.nativeDb.getTempFileBaseName()}-locks`;\n try {\n this.lockDb.openDb(dbName, OpenMode.ReadWrite);\n } catch (_e) {\n this.lockDb.createDb(dbName);\n this.lockDb.executeSQL(\"CREATE TABLE locks(id INTEGER PRIMARY KEY NOT NULL,state INTEGER NOT NULL,origin INTEGER)\");\n this.lockDb.saveChanges();\n }\n }\n\n public [_close]() {\n if (this.lockDb.isOpen)\n this.lockDb.closeDb();\n }\n\n private getOwners(id: Id64String): ElementOwners {\n return this.briefcase.withPreparedSqliteStatement(\"SELECT ModelId,ParentId FROM bis_Element WHERE id=?\", (stmt) => {\n stmt.bindId(1, id);\n const rc = stmt.step();\n if (DbResult.BE_SQLITE_ROW !== rc)\n throw new IModelError(rc, `element ${id} not found`);\n\n return { modelId: stmt.getValueId(0), parentId: stmt.getValueId(1) };\n });\n }\n\n private getLockState(id?: Id64String): LockState | undefined {\n return (id === undefined || !Id64.isValid(id)) ? undefined : this.lockDb.withPreparedSqliteStatement(\"SELECT state FROM locks WHERE id=?\", (stmt) => {\n stmt.bindId(1, id);\n return (DbResult.BE_SQLITE_ROW === stmt.step()) ? stmt.getValueInteger(0) : undefined;\n });\n }\n\n /** Clear the cache of locally held locks.\n * Note: does *not* release locks from server.\n */\n private clearAllLocks() {\n this.lockDb.executeSQL(\"DELETE FROM locks\");\n this.lockDb.saveChanges();\n }\n\n /** only for tests */\n public getLockCount(state: LockState): number {\n return this.lockDb.withSqliteStatement(\"SELECT count(*) FROM locks WHERE state=?\", (stmt) => {\n stmt.bindInteger(1, state);\n stmt.step();\n return stmt.getValueInteger(0);\n });\n }\n\n public async [_releaseAllLocks](): Promise<void> {\n await IModelHost.hubAccess.releaseAllLocks(this.briefcase); // throws if unsuccessful\n this.clearAllLocks();\n }\n\n private insertLock(id: Id64String, state: LockState, origin: LockOrigin): true {\n this.lockDb.withPreparedSqliteStatement(\"INSERT INTO locks(id,state,origin) VALUES (?,?,?) ON CONFLICT(id) DO UPDATE SET state=excluded.state,origin=excluded.origin\", (stmt) => {\n stmt.bindId(1, id);\n stmt.bindInteger(2, state);\n stmt.bindInteger(3, origin);\n const rc = stmt.step();\n if (DbResult.BE_SQLITE_DONE !== rc)\n throw new IModelError(rc, \"can't insert lock into database\");\n });\n return true;\n }\n\n private ownerHoldsExclusiveLock(id: Id64String | undefined): boolean {\n if (id === undefined || id === IModel.rootSubjectId)\n return false; // has no owners\n\n const { modelId, parentId } = this.getOwners(id);\n if (this.getLockState(modelId) === LockState.Exclusive || this.getLockState(parentId) === LockState.Exclusive)\n return true;\n\n // see if this model is exclusively locked by one of its owners. If so, save that fact on modelId so future tests won't have to descend.\n if (this.ownerHoldsExclusiveLock(modelId))\n return this.insertLock(modelId, LockState.Exclusive, LockOrigin.Discovered);\n\n // see if the parent is exclusively locked by one of its owners. If so, save that fact on parentId so future tests won't have to descend.\n return this.ownerHoldsExclusiveLock(parentId) ? this.insertLock(parentId!, LockState.Exclusive, LockOrigin.Discovered) : false; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n }\n\n /** Determine whether an the exclusive lock is already held by an element (or one of its owners) */\n public holdsExclusiveLock(id: Id64String): boolean {\n // see if we hold the exclusive lock. or if one of the element's owners is exclusively locked (recursively)\n return this.getLockState(id) === LockState.Exclusive || this.ownerHoldsExclusiveLock(id);\n }\n\n public holdsSharedLock(id: Id64String): boolean {\n const state = this.getLockState(id);\n // see if we hold shared or exclusive lock, or if an owner has exclusive lock. If so we implicitly have shared lock, but owner holding shared lock doesn't help.\n return (state === LockState.Shared || state === LockState.Exclusive) || this.ownerHoldsExclusiveLock(id);\n }\n\n /** if the shared lock on the element supplied is not already held, add it to the set of shared locks required. Then, check owners. */\n private addSharedLock(id: Id64String | undefined, locks: Set<Id64String>) {\n // if the id is not valid, or of the lock is already in the set, or if we already hold a shared lock, we're done\n // Note: if we hold a shared lock, it is guaranteed that we also hold all required shared locks on owners.\n if (id === undefined || !Id64.isValid(id) || locks.has(id) || this.holdsSharedLock(id))\n return;\n\n locks.add(id); // add to set of needed shared locks\n this.addOwnerSharedLocks(id, locks); // check parent models and groups\n }\n\n /** add owners (recursively) of an element to a list of required shared locks, if not already held. */\n private addOwnerSharedLocks(id: Id64String, locks: Set<Id64String>) {\n const el = this.getOwners(id);\n this.addSharedLock(el.parentId, locks); // if this element is in a group\n this.addSharedLock(el.modelId, locks); // check its model\n }\n\n /** attempt to acquire all necessary locks for a set of elements */\n private async acquireAllLocks(locks: LockMap) {\n if (locks.size === 0) // no locks are required.\n return;\n\n const sharedLocks = new Set<Id64String>();\n for (const lock of locks)\n this.addOwnerSharedLocks(lock[0], sharedLocks);\n\n for (const shared of sharedLocks) {\n if (!locks.has(shared)) // we may already be asking for exclusive lock\n locks.set(shared, LockState.Shared);\n }\n\n await IModelHost.hubAccess.acquireLocks(this.briefcase, locks); // throws if unsuccessful\n for (const lock of locks)\n this.insertLock(lock[0], lock[1], LockOrigin.Acquired);\n this.lockDb.saveChanges();\n }\n\n public async acquireLocks(arg: { shared?: Id64Arg, exclusive?: Id64Arg }): Promise<void> {\n const locks = new Map<Id64String, LockState>();\n if (arg.shared) {\n for (const id of Id64.iterable(arg.shared)) {\n if (!this.holdsSharedLock(id))\n locks.set(id, LockState.Shared);\n }\n }\n if (arg.exclusive) {\n for (const id of Id64.iterable(arg.exclusive)) {\n if (!this.holdsExclusiveLock(id))\n locks.set(id, LockState.Exclusive);\n }\n }\n return this.acquireAllLocks(locks);\n }\n\n /** When an element is newly created in a session, we hold the lock on it implicitly. Save that fact. */\n public [_elementWasCreated](id: Id64String) {\n this.insertLock(id, LockState.Exclusive, LockOrigin.NewElement);\n this.lockDb.saveChanges();\n }\n\n /** locks are not necessary during change propagation. */\n private get _locksAreRequired() { return !this.briefcase.txns.isIndirectChanges; }\n\n /** throw if locks are currently required and the exclusive lock is not held on the supplied element */\n public checkExclusiveLock(id: Id64String, type: string, operation: string) {\n if (this._locksAreRequired && !this.holdsExclusiveLock(id))\n throw new IModelError(IModelStatus.LockNotHeld, `exclusive lock not held on ${type} for ${operation} (id=${id})`);\n }\n\n /** throw if locks are currently required and a shared lock is not held on the supplied element */\n public checkSharedLock(id: Id64String, type: string, operation: string) {\n if (this._locksAreRequired && !this.holdsSharedLock(id))\n throw new IModelError(IModelStatus.LockNotHeld, `shared lock not held on ${type} for ${operation} (id=${id})`);\n }\n\n}\n\nexport function createServerBasedLocks(iModel: BriefcaseDb): LockControl {\n return new ServerBasedLocks(iModel);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ServerBasedLocks.js","sourceRoot":"","sources":["../../../src/internal/ServerBasedLocks.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;;AAE/F;;GAEG;AAEH,sDAAkG;AAClG,oDAAoE;AAIpE,8CAA2C;AAC3C,0CAAuC;AACvC,uCAA+G;AAmB/G,MAAa,gBAAgB;IAG3B,IAAW,aAAa,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC;IAI3C,YAAmB,MAAmB;QANtB,QAA2B,GAAG,SAAS,CAAC;QAGrC,WAAM,GAAG,IAAI,mBAAQ,EAAE,CAAC;QAIzC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC;QACxB,MA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,eAAe,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAED,wGAAwG;IACjG,CAAC,4BAAkB,CAAC,CAAC,EAAc;QACxC,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,uBAAS,CAAC,SAAS,gCAAwB,CAAC;QAChE,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;IAC5B,CAAC;IAED,yDAAyD;IACzD,IAAY,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAElF,uGAAuG;IAChG,kBAAkB,CAAC,EAAc,EAAE,IAAY,EAAE,SAAiB;QACvE,IAAI,IAAI,CAAC,iBAAiB,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC;YACxD,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,WAAW,EAAE,8BAA8B,IAAI,QAAQ,SAAS,QAAQ,EAAE,GAAG,CAAC,CAAC;IACtH,CAAC;IAED,kGAAkG;IAC3F,eAAe,CAAC,EAAc,EAAE,IAAY,EAAE,SAAiB;QACpE,IAAI,IAAI,CAAC,iBAAiB,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC;YACrD,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,WAAW,EAAE,2BAA2B,IAAI,QAAQ,SAAS,QAAQ,EAAE,GAAG,CAAC,CAAC;IACnH,CAAC;CAEF;AApLD,4CAoLC;AAED,SAAgB,sBAAsB,CAAC,MAAmB;IACxD,OAAO,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC;AAFD,wDAEC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module iModels\r\n */\r\n\r\nimport { DbResult, Id64, Id64Arg, Id64String, IModelStatus, OpenMode } from \"@itwin/core-bentley\";\r\nimport { IModel, IModelError, LockState } from \"@itwin/core-common\";\r\nimport { LockMap } from \"../BackendHubAccess\";\r\nimport { BriefcaseDb } from \"../IModelDb\";\r\nimport { LockControl } from \"../LockControl\";\r\nimport { IModelHost } from \"../IModelHost\";\r\nimport { SQLiteDb } from \"../SQLiteDb\";\r\nimport { _close, _elementWasCreated, _implementationProhibited, _nativeDb, _releaseAllLocks } from \"./Symbols\";\r\n\r\n/**\r\n * Both the Model and Parent of an element are considered \"owners\" of their member elements. That means:\r\n * 1) they must hold at least a shared lock before an exclusive lock can be acquired for their members\r\n * 2) if they hold an exclusive lock, then all of their members are exclusively locked implicitly.\r\n */\r\ninterface ElementOwners {\r\n readonly modelId: Id64String;\r\n readonly parentId: Id64String | undefined;\r\n}\r\n\r\n// eslint-disable-next-line no-restricted-syntax\r\nconst enum LockOrigin {\r\n Acquired = 0,\r\n NewElement = 1,\r\n Discovered = 2,\r\n}\r\n\r\nexport class ServerBasedLocks implements LockControl {\r\n public readonly [_implementationProhibited] = undefined;\r\n\r\n public get isServerBased() { return true; }\r\n protected readonly lockDb = new SQLiteDb();\r\n protected readonly briefcase: BriefcaseDb;\r\n\r\n public constructor(iModel: BriefcaseDb) {\r\n this.briefcase = iModel;\r\n const dbName = `${iModel[_nativeDb].getTempFileBaseName()}-locks`;\r\n try {\r\n this.lockDb.openDb(dbName, OpenMode.ReadWrite);\r\n } catch (_e) {\r\n this.lockDb.createDb(dbName);\r\n this.lockDb.executeSQL(\"CREATE TABLE locks(id INTEGER PRIMARY KEY NOT NULL,state INTEGER NOT NULL,origin INTEGER)\");\r\n this.lockDb.saveChanges();\r\n }\r\n }\r\n\r\n public [_close]() {\r\n if (this.lockDb.isOpen)\r\n this.lockDb.closeDb();\r\n }\r\n\r\n private getOwners(id: Id64String): ElementOwners {\r\n return this.briefcase.withPreparedSqliteStatement(\"SELECT ModelId,ParentId FROM bis_Element WHERE id=?\", (stmt) => {\r\n stmt.bindId(1, id);\r\n const rc = stmt.step();\r\n if (DbResult.BE_SQLITE_ROW !== rc)\r\n throw new IModelError(rc, `element ${id} not found`);\r\n\r\n return { modelId: stmt.getValueId(0), parentId: stmt.getValueId(1) };\r\n });\r\n }\r\n\r\n private getLockState(id?: Id64String): LockState | undefined {\r\n return (id === undefined || !Id64.isValid(id)) ? undefined : this.lockDb.withPreparedSqliteStatement(\"SELECT state FROM locks WHERE id=?\", (stmt) => {\r\n stmt.bindId(1, id);\r\n return (DbResult.BE_SQLITE_ROW === stmt.step()) ? stmt.getValueInteger(0) : undefined;\r\n });\r\n }\r\n\r\n /** Clear the cache of locally held locks.\r\n * Note: does *not* release locks from server.\r\n */\r\n private clearAllLocks() {\r\n this.lockDb.executeSQL(\"DELETE FROM locks\");\r\n this.lockDb.saveChanges();\r\n }\r\n\r\n /** only for tests */\r\n public getLockCount(state: LockState): number {\r\n return this.lockDb.withSqliteStatement(\"SELECT count(*) FROM locks WHERE state=?\", (stmt) => {\r\n stmt.bindInteger(1, state);\r\n stmt.step();\r\n return stmt.getValueInteger(0);\r\n });\r\n }\r\n\r\n public async [_releaseAllLocks](): Promise<void> {\r\n await IModelHost.hubAccess.releaseAllLocks(this.briefcase); // throws if unsuccessful\r\n this.clearAllLocks();\r\n }\r\n\r\n private insertLock(id: Id64String, state: LockState, origin: LockOrigin): true {\r\n this.lockDb.withPreparedSqliteStatement(\"INSERT INTO locks(id,state,origin) VALUES (?,?,?) ON CONFLICT(id) DO UPDATE SET state=excluded.state,origin=excluded.origin\", (stmt) => {\r\n stmt.bindId(1, id);\r\n stmt.bindInteger(2, state);\r\n stmt.bindInteger(3, origin);\r\n const rc = stmt.step();\r\n if (DbResult.BE_SQLITE_DONE !== rc)\r\n throw new IModelError(rc, \"can't insert lock into database\");\r\n });\r\n return true;\r\n }\r\n\r\n private ownerHoldsExclusiveLock(id: Id64String | undefined): boolean {\r\n if (id === undefined || id === IModel.rootSubjectId)\r\n return false; // has no owners\r\n\r\n const { modelId, parentId } = this.getOwners(id);\r\n if (this.getLockState(modelId) === LockState.Exclusive || this.getLockState(parentId) === LockState.Exclusive)\r\n return true;\r\n\r\n // see if this model is exclusively locked by one of its owners. If so, save that fact on modelId so future tests won't have to descend.\r\n if (this.ownerHoldsExclusiveLock(modelId))\r\n return this.insertLock(modelId, LockState.Exclusive, LockOrigin.Discovered);\r\n\r\n // see if the parent is exclusively locked by one of its owners. If so, save that fact on parentId so future tests won't have to descend.\r\n return this.ownerHoldsExclusiveLock(parentId) ? this.insertLock(parentId!, LockState.Exclusive, LockOrigin.Discovered) : false; // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n }\r\n\r\n /** Determine whether an the exclusive lock is already held by an element (or one of its owners) */\r\n public holdsExclusiveLock(id: Id64String): boolean {\r\n // see if we hold the exclusive lock. or if one of the element's owners is exclusively locked (recursively)\r\n return this.getLockState(id) === LockState.Exclusive || this.ownerHoldsExclusiveLock(id);\r\n }\r\n\r\n public holdsSharedLock(id: Id64String): boolean {\r\n const state = this.getLockState(id);\r\n // see if we hold shared or exclusive lock, or if an owner has exclusive lock. If so we implicitly have shared lock, but owner holding shared lock doesn't help.\r\n return (state === LockState.Shared || state === LockState.Exclusive) || this.ownerHoldsExclusiveLock(id);\r\n }\r\n\r\n /** if the shared lock on the element supplied is not already held, add it to the set of shared locks required. Then, check owners. */\r\n private addSharedLock(id: Id64String | undefined, locks: Set<Id64String>) {\r\n // if the id is not valid, or of the lock is already in the set, or if we already hold a shared lock, we're done\r\n // Note: if we hold a shared lock, it is guaranteed that we also hold all required shared locks on owners.\r\n if (id === undefined || !Id64.isValid(id) || locks.has(id) || this.holdsSharedLock(id))\r\n return;\r\n\r\n locks.add(id); // add to set of needed shared locks\r\n this.addOwnerSharedLocks(id, locks); // check parent models and groups\r\n }\r\n\r\n /** add owners (recursively) of an element to a list of required shared locks, if not already held. */\r\n private addOwnerSharedLocks(id: Id64String, locks: Set<Id64String>) {\r\n const el = this.getOwners(id);\r\n this.addSharedLock(el.parentId, locks); // if this element is in a group\r\n this.addSharedLock(el.modelId, locks); // check its model\r\n }\r\n\r\n /** attempt to acquire all necessary locks for a set of elements */\r\n private async acquireAllLocks(locks: LockMap) {\r\n if (locks.size === 0) // no locks are required.\r\n return;\r\n\r\n const sharedLocks = new Set<Id64String>();\r\n for (const lock of locks)\r\n this.addOwnerSharedLocks(lock[0], sharedLocks);\r\n\r\n for (const shared of sharedLocks) {\r\n if (!locks.has(shared)) // we may already be asking for exclusive lock\r\n locks.set(shared, LockState.Shared);\r\n }\r\n\r\n await IModelHost.hubAccess.acquireLocks(this.briefcase, locks); // throws if unsuccessful\r\n for (const lock of locks)\r\n this.insertLock(lock[0], lock[1], LockOrigin.Acquired);\r\n this.lockDb.saveChanges();\r\n }\r\n\r\n public async acquireLocks(arg: { shared?: Id64Arg, exclusive?: Id64Arg }): Promise<void> {\r\n const locks = new Map<Id64String, LockState>();\r\n if (arg.shared) {\r\n for (const id of Id64.iterable(arg.shared)) {\r\n if (!this.holdsSharedLock(id))\r\n locks.set(id, LockState.Shared);\r\n }\r\n }\r\n if (arg.exclusive) {\r\n for (const id of Id64.iterable(arg.exclusive)) {\r\n if (!this.holdsExclusiveLock(id))\r\n locks.set(id, LockState.Exclusive);\r\n }\r\n }\r\n return this.acquireAllLocks(locks);\r\n }\r\n\r\n /** When an element is newly created in a session, we hold the lock on it implicitly. Save that fact. */\r\n public [_elementWasCreated](id: Id64String) {\r\n this.insertLock(id, LockState.Exclusive, LockOrigin.NewElement);\r\n this.lockDb.saveChanges();\r\n }\r\n\r\n /** locks are not necessary during change propagation. */\r\n private get _locksAreRequired() { return !this.briefcase.txns.isIndirectChanges; }\r\n\r\n /** throw if locks are currently required and the exclusive lock is not held on the supplied element */\r\n public checkExclusiveLock(id: Id64String, type: string, operation: string) {\r\n if (this._locksAreRequired && !this.holdsExclusiveLock(id))\r\n throw new IModelError(IModelStatus.LockNotHeld, `exclusive lock not held on ${type} for ${operation} (id=${id})`);\r\n }\r\n\r\n /** throw if locks are currently required and a shared lock is not held on the supplied element */\r\n public checkSharedLock(id: Id64String, type: string, operation: string) {\r\n if (this._locksAreRequired && !this.holdsSharedLock(id))\r\n throw new IModelError(IModelStatus.LockNotHeld, `shared lock not held on ${type} for ${operation} (id=${id})`);\r\n }\r\n\r\n}\r\n\r\nexport function createServerBasedLocks(iModel: BriefcaseDb): LockControl {\r\n return new ServerBasedLocks(iModel);\r\n}\r\n"]}
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
export declare const _implementationProhibited: unique symbol;
|
|
5
5
|
export declare const _close: unique symbol;
|
|
6
6
|
export declare const _elementWasCreated: unique symbol;
|
|
7
|
+
/** @internal */
|
|
8
|
+
export declare const _nativeDb: unique symbol;
|
|
7
9
|
export declare const _releaseAllLocks: unique symbol;
|
|
8
10
|
export declare const _verifyChannel: unique symbol;
|
|
9
11
|
//# sourceMappingURL=Symbols.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Symbols.d.ts","sourceRoot":"","sources":["../../../src/internal/Symbols.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,eAAO,MAAM,yBAAyB,eAAmG,CAAC;AAM1I,eAAO,MAAM,MAAM,eAA2B,CAAC;AAC/C,eAAO,MAAM,kBAAkB,eAAuC,CAAC;AACvE,eAAO,MAAM,gBAAgB,eAAqC,CAAC;AACnE,eAAO,MAAM,cAAc,eAAmC,CAAC"}
|
|
1
|
+
{"version":3,"file":"Symbols.d.ts","sourceRoot":"","sources":["../../../src/internal/Symbols.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,eAAO,MAAM,yBAAyB,eAAmG,CAAC;AAM1I,eAAO,MAAM,MAAM,eAA2B,CAAC;AAC/C,eAAO,MAAM,kBAAkB,eAAuC,CAAC;AACvE,gBAAgB;AAChB,eAAO,MAAM,SAAS,eAA8B,CAAC;AACrD,eAAO,MAAM,gBAAgB,eAAqC,CAAC;AACnE,eAAO,MAAM,cAAc,eAAmC,CAAC"}
|
|
@@ -7,13 +7,15 @@
|
|
|
7
7
|
* @module Workspace
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports._verifyChannel = exports._releaseAllLocks = exports._elementWasCreated = exports._close = exports._implementationProhibited = void 0;
|
|
10
|
+
exports._verifyChannel = exports._releaseAllLocks = exports._nativeDb = exports._elementWasCreated = exports._close = exports._implementationProhibited = void 0;
|
|
11
11
|
exports._implementationProhibited = Symbol.for("Implementations of this interface can only be obtained from the containing package");
|
|
12
12
|
function sym(name) {
|
|
13
13
|
return `${name}_core-backend_INTERNAL_ONLY_DO_NOT_USE`;
|
|
14
14
|
}
|
|
15
15
|
exports._close = Symbol.for(sym("close"));
|
|
16
16
|
exports._elementWasCreated = Symbol.for(sym("elementWasCreated"));
|
|
17
|
+
/** @internal */
|
|
18
|
+
exports._nativeDb = Symbol.for(sym("nativeDb"));
|
|
17
19
|
exports._releaseAllLocks = Symbol.for(sym("releaseAllLocks"));
|
|
18
20
|
exports._verifyChannel = Symbol.for(sym("verifyChannel"));
|
|
19
21
|
//# sourceMappingURL=Symbols.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Symbols.js","sourceRoot":"","sources":["../../../src/internal/Symbols.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEU,QAAA,yBAAyB,GAAG,MAAM,CAAC,GAAG,CAAC,oFAAoF,CAAC,CAAC;AAE1I,SAAS,GAAG,CAAC,IAAY;IACvB,OAAO,GAAG,IAAI,wCAAwC,CAAC;AACzD,CAAC;AAEY,QAAA,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;AAClC,QAAA,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"Symbols.js","sourceRoot":"","sources":["../../../src/internal/Symbols.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEU,QAAA,yBAAyB,GAAG,MAAM,CAAC,GAAG,CAAC,oFAAoF,CAAC,CAAC;AAE1I,SAAS,GAAG,CAAC,IAAY;IACvB,OAAO,GAAG,IAAI,wCAAwC,CAAC;AACzD,CAAC;AAEY,QAAA,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;AAClC,QAAA,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC,CAAC;AACvE,gBAAgB;AACH,QAAA,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;AACxC,QAAA,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC;AACtD,QAAA,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC","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 Workspace\r\n */\r\n\r\nexport const _implementationProhibited = Symbol.for(\"Implementations of this interface can only be obtained from the containing package\");\r\n\r\nfunction sym(name: string): string {\r\n return `${name}_core-backend_INTERNAL_ONLY_DO_NOT_USE`;\r\n}\r\n\r\nexport const _close = Symbol.for(sym(\"close\"));\r\nexport const _elementWasCreated = Symbol.for(sym(\"elementWasCreated\"));\r\n/** @internal */\r\nexport const _nativeDb = Symbol.for(sym(\"nativeDb\"));\r\nexport const _releaseAllLocks = Symbol.for(sym(\"releaseAllLocks\"));\r\nexport const _verifyChannel = Symbol.for(sym(\"verifyChannel\"));\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cross-package.d.ts","sourceRoot":"","sources":["../../../src/internal/cross-package.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACnG,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"cross-package.d.ts","sourceRoot":"","sources":["../../../src/internal/cross-package.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACnG,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EACL,SAAS,GACV,MAAM,WAAW,CAAC"}
|
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.IModelNative = exports.NativeLoggerCategory = exports.NativeCloudSqlite = exports.IModelJsNative = void 0;
|
|
7
|
+
exports._nativeDb = exports.IModelNative = exports.NativeLoggerCategory = exports.NativeCloudSqlite = exports.IModelJsNative = void 0;
|
|
8
8
|
var imodeljs_native_1 = require("@bentley/imodeljs-native");
|
|
9
9
|
Object.defineProperty(exports, "IModelJsNative", { enumerable: true, get: function () { return imodeljs_native_1.IModelJsNative; } });
|
|
10
10
|
Object.defineProperty(exports, "NativeCloudSqlite", { enumerable: true, get: function () { return imodeljs_native_1.NativeCloudSqlite; } });
|
|
11
11
|
Object.defineProperty(exports, "NativeLoggerCategory", { enumerable: true, get: function () { return imodeljs_native_1.NativeLoggerCategory; } });
|
|
12
12
|
var NativePlatform_1 = require("./NativePlatform");
|
|
13
13
|
Object.defineProperty(exports, "IModelNative", { enumerable: true, get: function () { return NativePlatform_1.IModelNative; } });
|
|
14
|
+
var Symbols_1 = require("./Symbols");
|
|
15
|
+
Object.defineProperty(exports, "_nativeDb", { enumerable: true, get: function () { return Symbols_1._nativeDb; } });
|
|
14
16
|
//# sourceMappingURL=cross-package.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cross-package.js","sourceRoot":"","sources":["../../../src/internal/cross-package.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,4DAAmG;AAA1F,iHAAA,cAAc,OAAA;AAAE,oHAAA,iBAAiB,OAAA;AAAE,uHAAA,oBAAoB,OAAA;AAChE,mDAAgD;AAAvC,8GAAA,YAAY,OAAA","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nexport { IModelJsNative, NativeCloudSqlite, NativeLoggerCategory } from \"@bentley/imodeljs-native\";\nexport { IModelNative } from \"./NativePlatform\";\n"]}
|
|
1
|
+
{"version":3,"file":"cross-package.js","sourceRoot":"","sources":["../../../src/internal/cross-package.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,4DAAmG;AAA1F,iHAAA,cAAc,OAAA;AAAE,oHAAA,iBAAiB,OAAA;AAAE,uHAAA,oBAAoB,OAAA;AAChE,mDAAgD;AAAvC,8GAAA,YAAY,OAAA;AACrB,qCAEmB;AADjB,oGAAA,SAAS,OAAA","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nexport { IModelJsNative, NativeCloudSqlite, NativeLoggerCategory } from \"@bentley/imodeljs-native\";\r\nexport { IModelNative } from \"./NativePlatform\";\r\nexport {\r\n _nativeDb,\r\n} from \"./Symbols\";\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SettingsImpl.js","sourceRoot":"","sources":["../../../../src/internal/worksp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;AA9ID,oCA8IC;KA7IkB,mCAAyB","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 Workspace\n */\n\nimport * as fs from \"fs-extra\";\nimport { parse } from \"json5\";\nimport { extname, join } from \"path\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { LocalDirName, LocalFileName } from \"@itwin/core-common\";\nimport { IModelJsFs } from \"../../IModelJsFs\";\nimport { Setting, SettingName, Settings, SettingsContainer, SettingsDictionary, SettingsDictionaryProps, SettingsDictionarySource, SettingsPriority } from \"../../workspace/Settings\";\nimport { IModelHost } from \"../../IModelHost\";\nimport { _implementationProhibited } from \"../Symbols\";\n\nconst dictionaryMatches = (d1: SettingsDictionarySource, d2: SettingsDictionarySource): boolean => {\n return (d1.workspaceDb === d2.workspaceDb) && (d1.name === d2.name);\n};\n\nclass SettingsDictionaryImpl implements SettingsDictionary {\n public readonly [_implementationProhibited] = undefined;\n public readonly props: SettingsDictionaryProps;\n public readonly settings: SettingsContainer;\n\n public constructor(props: SettingsDictionaryProps, settings: SettingsContainer) {\n this.props = { ...props }; // make a copy so it can't be changed by caller\n this.settings = settings;\n }\n\n public getSetting<T extends Setting>(settingName: string): T | undefined {\n const value = this.settings[settingName] as T | undefined;\n return undefined !== value ? Setting.clone(value) : undefined;\n }\n}\n\n/**\n * Internal implementation of Settings interface.\n * @internal\n */\nexport class SettingsImpl implements Settings {\n public readonly [_implementationProhibited] = undefined;\n public dictionaries: SettingsDictionary[] = [];\n protected verifyPriority(_priority: SettingsPriority) { }\n public close() { }\n public readonly onSettingsChanged = new BeEvent<() => void>();\n\n public addFile(fileName: LocalFileName, priority: SettingsPriority) {\n this.addJson({ name: fileName, priority }, fs.readFileSync(fileName, \"utf-8\"));\n }\n\n public addDirectory(dirName: LocalDirName, priority: SettingsPriority) {\n for (const fileName of IModelJsFs.readdirSync(dirName)) {\n const ext = extname(fileName);\n if (ext === \".json5\" || ext === \".json\")\n this.addFile(join(dirName, fileName), priority);\n }\n }\n\n public addJson(props: SettingsDictionaryProps, settingsJson: string) {\n this.addDictionary(props, parse(settingsJson));\n }\n\n public addDictionary(props: SettingsDictionaryProps, settings: SettingsContainer) {\n this.verifyPriority(props.priority);\n this.dropDictionary(props, false); // make sure we don't have the same dictionary twice\n const dict = new SettingsDictionaryImpl(props, settings);\n const doAdd = () => {\n for (let i = 0; i < this.dictionaries.length; ++i) {\n if (this.dictionaries[i].props.priority <= dict.props.priority) {\n this.dictionaries.splice(i, 0, dict);\n return;\n }\n }\n this.dictionaries.push(dict);\n };\n doAdd();\n this.onSettingsChanged.raiseEvent();\n }\n\n public getDictionary(source: SettingsDictionarySource): SettingsDictionary | undefined {\n for (const dictionary of this.dictionaries) {\n if (dictionaryMatches(dictionary.props, source))\n return dictionary;\n }\n return undefined;\n }\n\n public dropDictionary(source: SettingsDictionarySource, raiseEvent = true) {\n for (let i = 0; i < this.dictionaries.length; ++i) {\n if (dictionaryMatches(this.dictionaries[i].props, source)) {\n this.dictionaries.splice(i, 1);\n if (raiseEvent)\n this.onSettingsChanged.raiseEvent();\n return true;\n }\n }\n return false;\n }\n\n public * getSettingEntries<T extends Setting>(settingName: SettingName): Iterable<{ value: T, dictionary: SettingsDictionary}> {\n for (const dictionary of this.dictionaries) {\n const value = dictionary.getSetting<T>(settingName);\n if (undefined !== value) {\n yield { value, dictionary };\n }\n }\n }\n\n public * getSettingValues<T extends Setting>(settingName: SettingName): Iterable<T> {\n for (const entry of this.getSettingEntries<T>(settingName)) {\n yield entry.value;\n }\n }\n\n public getSetting<T extends Setting>(settingName: SettingName, defaultValue?: T): T | undefined {\n for (const value of this.getSettingValues<T>(settingName)) {\n return value;\n }\n\n return defaultValue;\n }\n\n // get the setting and verify the result is either undefined or the correct type. If so, return it. Otherwise throw an exception.\n private getResult<T extends Setting>(name: SettingName, expectedType: string) {\n const out = this.getSetting<T>(name);\n if (out === undefined || typeof out === expectedType)\n return out;\n throw new Error(`setting \"${name}\" is not a ${expectedType}: ${typeof out}`);\n }\n public getString(name: SettingName, defaultValue: string): string;\n public getString(name: SettingName): string | undefined;\n public getString(name: SettingName, defaultValue?: string): string | undefined {\n return this.getResult<string>(name, \"string\") ?? defaultValue;\n }\n public getBoolean(name: SettingName, defaultValue: boolean): boolean;\n public getBoolean(name: SettingName): boolean | undefined;\n public getBoolean(name: SettingName, defaultValue?: boolean): boolean | undefined {\n return this.getResult<boolean>(name, \"boolean\") ?? defaultValue;\n }\n public getNumber(name: SettingName, defaultValue: number): number;\n public getNumber(name: SettingName): number | undefined;\n public getNumber(name: SettingName, defaultValue?: number): number | undefined {\n return this.getResult<number>(name, \"number\") ?? defaultValue;\n }\n public getObject<T extends object>(name: SettingName, defaultValue: T): T;\n public getObject<T extends object>(name: SettingName): T | undefined;\n public getObject<T extends object>(name: SettingName, defaultValue?: T): T | undefined {\n const out = this.getResult<T>(name, \"object\");\n return out ? IModelHost.settingsSchemas.validateSetting(out, name) : defaultValue;\n }\n public getArray<T extends Setting>(name: SettingName, defaultValue: T[]): T[];\n public getArray<T extends Setting>(name: SettingName): T[] | undefined;\n public getArray<T extends Setting>(name: SettingName, defaultValue?: T[]): T[] | undefined {\n if (IModelHost.settingsSchemas.settingDefs.get(name)?.combineArray) {\n return this.getCombinedArray<T>(name, defaultValue);\n }\n\n const out = this.getSetting<T[]>(name);\n if (out === undefined)\n return defaultValue;\n if (!Array.isArray(out))\n throw new Error(`setting ${name} is not an array: ${out}`);\n return IModelHost.settingsSchemas.validateSetting(out, name);\n }\n\n private getCombinedArray<T extends Setting>(name: SettingName, defaultValue?: T[]): T[] | undefined {\n let foundSetting = false;\n const out: T[] = [];\n for (const array of this.getSettingValues<T[]>(name)) {\n foundSetting = true;\n\n IModelHost.settingsSchemas.validateSetting(array, name);\n for (const value of array) {\n if (undefined === out.find((x) => Setting.areEqual(x, value))) {\n out.push(value);\n }\n }\n }\n\n return foundSetting ? out : defaultValue;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SettingsImpl.js","sourceRoot":"","sources":["../../../../src/internal/workspace/SettingsImpl.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;AAEH,+BAA+B;AAC/B,iCAA8B;AAC9B,+BAAqC;AACrC,sDAA8C;AAE9C,iDAA8C;AAC9C,uDAAsL;AACtL,iDAA8C;AAC9C,wCAAuD;AAEvD,MAAM,iBAAiB,GAAG,CAAC,EAA4B,EAAE,EAA4B,EAAW,EAAE;IAChG,OAAO,CAAC,EAAE,CAAC,WAAW,KAAK,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC;AACtE,CAAC,CAAC;AAEF,MAAM,sBAAsB;IAK1B,YAAmB,KAA8B,EAAE,QAA2B;QAJ9D,QAA2B,GAAG,SAAS,CAAC;QAKtD,IAAI,CAAC,KAAK,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC,+CAA+C;QAC1E,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAEM,UAAU,CAAoB,WAAmB;QACtD,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAkB,CAAC;QAC1D,OAAO,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,kBAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAChE,CAAC;CACF;KAbkB,mCAAyB;AAe5C;;;GAGG;AACH,MAAa,YAAY;IAAzB;QACkB,QAA2B,GAAG,SAAS,CAAC;QACjD,iBAAY,GAAyB,EAAE,CAAC;QAG/B,sBAAiB,GAAG,IAAI,sBAAO,EAAc,CAAC;IAyIhE,CAAC;IA3IW,cAAc,CAAC,SAA2B,IAAI,CAAC;IAClD,KAAK,KAAK,CAAC;IAGX,OAAO,CAAC,Q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AAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC;IAC3C,CAAC;CACF;AA9ID,oCA8IC;KA7IkB,mCAAyB","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 Workspace\r\n */\r\n\r\nimport * as fs from \"fs-extra\";\r\nimport { parse } from \"json5\";\r\nimport { extname, join } from \"path\";\r\nimport { BeEvent } from \"@itwin/core-bentley\";\r\nimport { LocalDirName, LocalFileName } from \"@itwin/core-common\";\r\nimport { IModelJsFs } from \"../../IModelJsFs\";\r\nimport { Setting, SettingName, Settings, SettingsContainer, SettingsDictionary, SettingsDictionaryProps, SettingsDictionarySource, SettingsPriority } from \"../../workspace/Settings\";\r\nimport { IModelHost } from \"../../IModelHost\";\r\nimport { _implementationProhibited } from \"../Symbols\";\r\n\r\nconst dictionaryMatches = (d1: SettingsDictionarySource, d2: SettingsDictionarySource): boolean => {\r\n return (d1.workspaceDb === d2.workspaceDb) && (d1.name === d2.name);\r\n};\r\n\r\nclass SettingsDictionaryImpl implements SettingsDictionary {\r\n public readonly [_implementationProhibited] = undefined;\r\n public readonly props: SettingsDictionaryProps;\r\n public readonly settings: SettingsContainer;\r\n\r\n public constructor(props: SettingsDictionaryProps, settings: SettingsContainer) {\r\n this.props = { ...props }; // make a copy so it can't be changed by caller\r\n this.settings = settings;\r\n }\r\n\r\n public getSetting<T extends Setting>(settingName: string): T | undefined {\r\n const value = this.settings[settingName] as T | undefined;\r\n return undefined !== value ? Setting.clone(value) : undefined;\r\n }\r\n}\r\n\r\n/**\r\n * Internal implementation of Settings interface.\r\n * @internal\r\n */\r\nexport class SettingsImpl implements Settings {\r\n public readonly [_implementationProhibited] = undefined;\r\n public dictionaries: SettingsDictionary[] = [];\r\n protected verifyPriority(_priority: SettingsPriority) { }\r\n public close() { }\r\n public readonly onSettingsChanged = new BeEvent<() => void>();\r\n\r\n public addFile(fileName: LocalFileName, priority: SettingsPriority) {\r\n this.addJson({ name: fileName, priority }, fs.readFileSync(fileName, \"utf-8\"));\r\n }\r\n\r\n public addDirectory(dirName: LocalDirName, priority: SettingsPriority) {\r\n for (const fileName of IModelJsFs.readdirSync(dirName)) {\r\n const ext = extname(fileName);\r\n if (ext === \".json5\" || ext === \".json\")\r\n this.addFile(join(dirName, fileName), priority);\r\n }\r\n }\r\n\r\n public addJson(props: SettingsDictionaryProps, settingsJson: string) {\r\n this.addDictionary(props, parse(settingsJson));\r\n }\r\n\r\n public addDictionary(props: SettingsDictionaryProps, settings: SettingsContainer) {\r\n this.verifyPriority(props.priority);\r\n this.dropDictionary(props, false); // make sure we don't have the same dictionary twice\r\n const dict = new SettingsDictionaryImpl(props, settings);\r\n const doAdd = () => {\r\n for (let i = 0; i < this.dictionaries.length; ++i) {\r\n if (this.dictionaries[i].props.priority <= dict.props.priority) {\r\n this.dictionaries.splice(i, 0, dict);\r\n return;\r\n }\r\n }\r\n this.dictionaries.push(dict);\r\n };\r\n doAdd();\r\n this.onSettingsChanged.raiseEvent();\r\n }\r\n\r\n public getDictionary(source: SettingsDictionarySource): SettingsDictionary | undefined {\r\n for (const dictionary of this.dictionaries) {\r\n if (dictionaryMatches(dictionary.props, source))\r\n return dictionary;\r\n }\r\n return undefined;\r\n }\r\n\r\n public dropDictionary(source: SettingsDictionarySource, raiseEvent = true) {\r\n for (let i = 0; i < this.dictionaries.length; ++i) {\r\n if (dictionaryMatches(this.dictionaries[i].props, source)) {\r\n this.dictionaries.splice(i, 1);\r\n if (raiseEvent)\r\n this.onSettingsChanged.raiseEvent();\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n public * getSettingEntries<T extends Setting>(settingName: SettingName): Iterable<{ value: T, dictionary: SettingsDictionary}> {\r\n for (const dictionary of this.dictionaries) {\r\n const value = dictionary.getSetting<T>(settingName);\r\n if (undefined !== value) {\r\n yield { value, dictionary };\r\n }\r\n }\r\n }\r\n\r\n public * getSettingValues<T extends Setting>(settingName: SettingName): Iterable<T> {\r\n for (const entry of this.getSettingEntries<T>(settingName)) {\r\n yield entry.value;\r\n }\r\n }\r\n\r\n public getSetting<T extends Setting>(settingName: SettingName, defaultValue?: T): T | undefined {\r\n for (const value of this.getSettingValues<T>(settingName)) {\r\n return value;\r\n }\r\n\r\n return defaultValue;\r\n }\r\n\r\n // get the setting and verify the result is either undefined or the correct type. If so, return it. Otherwise throw an exception.\r\n private getResult<T extends Setting>(name: SettingName, expectedType: string) {\r\n const out = this.getSetting<T>(name);\r\n if (out === undefined || typeof out === expectedType)\r\n return out;\r\n throw new Error(`setting \"${name}\" is not a ${expectedType}: ${typeof out}`);\r\n }\r\n public getString(name: SettingName, defaultValue: string): string;\r\n public getString(name: SettingName): string | undefined;\r\n public getString(name: SettingName, defaultValue?: string): string | undefined {\r\n return this.getResult<string>(name, \"string\") ?? defaultValue;\r\n }\r\n public getBoolean(name: SettingName, defaultValue: boolean): boolean;\r\n public getBoolean(name: SettingName): boolean | undefined;\r\n public getBoolean(name: SettingName, defaultValue?: boolean): boolean | undefined {\r\n return this.getResult<boolean>(name, \"boolean\") ?? defaultValue;\r\n }\r\n public getNumber(name: SettingName, defaultValue: number): number;\r\n public getNumber(name: SettingName): number | undefined;\r\n public getNumber(name: SettingName, defaultValue?: number): number | undefined {\r\n return this.getResult<number>(name, \"number\") ?? defaultValue;\r\n }\r\n public getObject<T extends object>(name: SettingName, defaultValue: T): T;\r\n public getObject<T extends object>(name: SettingName): T | undefined;\r\n public getObject<T extends object>(name: SettingName, defaultValue?: T): T | undefined {\r\n const out = this.getResult<T>(name, \"object\");\r\n return out ? IModelHost.settingsSchemas.validateSetting(out, name) : defaultValue;\r\n }\r\n public getArray<T extends Setting>(name: SettingName, defaultValue: T[]): T[];\r\n public getArray<T extends Setting>(name: SettingName): T[] | undefined;\r\n public getArray<T extends Setting>(name: SettingName, defaultValue?: T[]): T[] | undefined {\r\n if (IModelHost.settingsSchemas.settingDefs.get(name)?.combineArray) {\r\n return this.getCombinedArray<T>(name, defaultValue);\r\n }\r\n\r\n const out = this.getSetting<T[]>(name);\r\n if (out === undefined)\r\n return defaultValue;\r\n if (!Array.isArray(out))\r\n throw new Error(`setting ${name} is not an array: ${out}`);\r\n return IModelHost.settingsSchemas.validateSetting(out, name);\r\n }\r\n\r\n private getCombinedArray<T extends Setting>(name: SettingName, defaultValue?: T[]): T[] | undefined {\r\n let foundSetting = false;\r\n const out: T[] = [];\r\n for (const array of this.getSettingValues<T[]>(name)) {\r\n foundSetting = true;\r\n\r\n IModelHost.settingsSchemas.validateSetting(array, name);\r\n for (const value of array) {\r\n if (undefined === out.find((x) => Setting.areEqual(x, value))) {\r\n out.push(value);\r\n }\r\n }\r\n }\r\n\r\n return foundSetting ? out : defaultValue;\r\n }\r\n}\r\n"]}
|