@itwin/core-backend 4.8.0-dev.6 → 4.8.0-dev.8
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/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.js.map +1 -1
- package/lib/cjs/Category.js.map +1 -1
- package/lib/cjs/ChangeSummaryManager.js +2 -2
- package/lib/cjs/ChangeSummaryManager.js.map +1 -1
- package/lib/cjs/ChangedElementsDb.d.ts +1 -0
- package/lib/cjs/ChangedElementsDb.d.ts.map +1 -1
- package/lib/cjs/ChangedElementsDb.js +1 -1
- 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.js.map +1 -1
- package/lib/cjs/ClassRegistry.js +5 -5
- package/lib/cjs/ClassRegistry.js.map +1 -1
- package/lib/cjs/CloudSqlite.d.ts +28 -11
- package/lib/cjs/CloudSqlite.d.ts.map +1 -1
- package/lib/cjs/CloudSqlite.js +42 -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.js.map +1 -1
- package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/Element.d.ts +1 -1
- package/lib/cjs/Element.js +1 -1
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/ElementAspect.js.map +1 -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.js +47 -47
- 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 +1 -1
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +14 -9
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelElementCloneContext.js.map +1 -1
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/IModelJsFs.js.map +1 -1
- 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/Material.js.map +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.js.map +1 -1
- package/lib/cjs/RpcBackend.js.map +1 -1
- package/lib/cjs/SQLiteDb.js.map +1 -1
- package/lib/cjs/Schema.js.map +1 -1
- package/lib/cjs/SchemaSync.js.map +1 -1
- package/lib/cjs/SchemaUtils.js.map +1 -1
- package/lib/cjs/ServerBasedLocks.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.js.map +1 -1
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/ViewStateHydrator.js.map +1 -1
- 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.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/ImplementationProhibited.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.map +1 -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.js.map +1 -1
- 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":"FunctionalElements.js","sourceRoot":"","sources":["../../../src/domains/FunctionalElements.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,oDAE4B;AAC5B,wCAA6F;AAE7F,oCAAqC;AACrC,sEAAyE;AACzE,kDAA2F;AAE3F;;;GAGG;AACH,MAAa,mBAAoB,SAAQ,qCAA2B;IAClE,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,qBAAqB,CAAC,CAAC,CAAC;IAEhF,YAAsB,KAAuC,EAAE,MAAgB;QAC7E,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACvB,CAAC;CACF;AAPD,kDAOC;AAED;;GAEG;AACH,MAAa,eAAgB,SAAQ,iBAAS;IAC5C,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,iBAAiB,CAAC,CAAC,CAAC;IAE5E,YAAmB,KAAiB,EAAE,MAAgB;QACpD,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACvB,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CAAC,QAAkB,EAAE,eAA2B,EAAE,IAAY;QAChF,MAAM,cAAc,GAAqC;YACvD,aAAa,EAAE,mBAAmB,CAAC,aAAa;YAChD,KAAK,EAAE,oBAAM,CAAC,iBAAiB;YAC/B,MAA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vF,YAAsB,KAA6B,EAAE,MAAgB;QACnE,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACvB,CAAC;CACF;AAPD,gEAOC;AAED;;GAEG;AACH,MAAsB,cAAe,SAAQ,+BAAqB;IAChE,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,gBAAgB,CAAC,CAAC,CAAC;IAE3E,YAAsB,KAAiC,EAAE,MAAgB;QACvE,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACvB,CAAC;CACF;AAPD,wCAOC;AAED;;GAEG;AACH,MAAa,yBAA0B,SAAQ,4BAAc;IAC3D,gBAAgB;IACT,MAAM,KAAK,SAAS,KAAa,OAAO,2BAA2B,CAAC,CAAC,CAAC;IAE7E,YAAmB,EAAc,EAAE,eAAuB,yBAAyB,CAAC,aAAa;QAC/F,KAAK,CAAC,EAAE,EAAE,EAAE,YAAY,EAAE,CAAC,CAAC;IAC9B,CAAC;;AANH,8DAOC;AAJe,uCAAa,GAAG,sCAAsC,CAAC;AAMvE;;GAEG;AACH,MAAa,+BAAgC,SAAQ,sCAAuB;IAC1E,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,iCAAiC,CAAC,CAAC,CAAC;CAC7F;AAHD,0EAGC;AAED;;GAEG;AACH,MAAa,yCAA0C,SAAQ,8CAA+B;IAC5F,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,2CAA2C,CAAC,CAAC,CAAC;CACvG;AAHD,8FAGC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"FunctionalElements.js","sourceRoot":"","sources":["../../../src/domains/FunctionalElements.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,oDAE4B;AAC5B,wCAA6F;AAE7F,oCAAqC;AACrC,sEAAyE;AACzE,kDAA2F;AAE3F;;;GAGG;AACH,MAAa,mBAAoB,SAAQ,qCAA2B;IAClE,gBAAgB;IACT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GAEG;AACH,MAAa,+BAAgC,SAAQ,sCAAuB;IAC1E,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,iCAAiC,CAAC,CAAC,CAAC;CAC7F;AAHD,0EAGC;AAED;;GAEG;AACH,MAAa,yCAA0C,SAAQ,8CAA+B;IAC5F,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,2CAA2C,CAAC,CAAC,CAAC;CACvG;AAHD,8FAGC","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 FunctionalElementProps, IModel, InformationPartitionElementProps, ModelProps, RelatedElement, TypeDefinitionElementProps,\n} from \"@itwin/core-common\";\nimport { InformationPartitionElement, RoleElement, TypeDefinitionElement } from \"../Element\";\nimport { IModelDb } from \"../IModelDb\";\nimport { RoleModel } from \"../Model\";\nimport { SubjectOwnsPartitionElements } from \"../NavigationRelationship\";\nimport { DrawingGraphicRepresentsElement, ElementRefersToElements } from \"../Relationship\";\n\n/** A FunctionalPartition element is a key part of the iModel information hierarchy and is always parented\n * to a Subject and broken down by a FunctionalModel.\n * @public\n */\nexport class FunctionalPartition extends InformationPartitionElement {\n /** @internal */\n public static override get className(): string { return \"FunctionalPartition\"; }\n\n protected constructor(props: InformationPartitionElementProps, iModel: IModelDb) {\n super(props, iModel);\n }\n}\n\n/** A container for persisting FunctionalElements.\n * @public\n */\nexport class FunctionalModel extends RoleModel {\n /** @internal */\n public static override get className(): string { return \"FunctionalModel\"; }\n\n public constructor(props: ModelProps, iModel: IModelDb) {\n super(props, iModel);\n }\n\n /** Insert a FunctionalPartition and a FunctionalModel that breaks it down.\n * @param iModelDb Insert into this iModel\n * @param parentSubjectId The FunctionalPartition will be inserted as a child of this Subject element.\n * @param name The name of the FunctionalPartition that the new FunctionalModel will break down.\n * @returns The Id of the newly inserted FunctionalPartition and FunctionalModel (same value).\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: FunctionalPartition.classFullName,\n model: IModel.repositoryModelId,\n parent: new SubjectOwnsPartitionElements(parentSubjectId),\n code: FunctionalPartition.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/** A FunctionalElement captures functional requirements that will ultimately be fulfilled by a PhysicalElement.\n * @public\n */\nexport abstract class FunctionalElement extends RoleElement {\n /** @internal */\n public static override get className(): string { return \"FunctionalElement\"; }\n\n protected constructor(props: FunctionalElementProps, iModel: IModelDb) {\n super(props, iModel);\n }\n}\n\n/** A FunctionalBreakdownElement is a *folder* node in the functional hierarchy.\n * @public\n */\nexport abstract class FunctionalBreakdownElement extends FunctionalElement {\n /** @internal */\n public static override get className(): string { return \"FunctionalBreakdownElement\"; }\n\n protected constructor(props: FunctionalElementProps, iModel: IModelDb) {\n super(props, iModel);\n }\n}\n\n/** @public */\nexport class FunctionalComposite extends FunctionalBreakdownElement {\n /** @internal */\n public static override get className(): string { return \"FunctionalComposite\"; }\n\n protected constructor(props: FunctionalElementProps, iModel: IModelDb) {\n super(props, iModel);\n }\n}\n\n/** A FunctionalComponentElement is a *leaf* node in the functional hierarchy.\n * @public\n */\nexport abstract class FunctionalComponentElement extends FunctionalElement {\n /** @internal */\n public static override get className(): string { return \"FunctionalComponentElement\"; }\n\n protected constructor(props: FunctionalElementProps, iModel: IModelDb) {\n super(props, iModel);\n }\n}\n\n/** Defines a set of properties (the 'type') that can be associated with a Functional Element.\n * @public\n */\nexport abstract class FunctionalType extends TypeDefinitionElement {\n /** @internal */\n public static override get className(): string { return \"FunctionalType\"; }\n\n protected constructor(props: TypeDefinitionElementProps, iModel: IModelDb) {\n super(props, iModel);\n }\n}\n\n/** Relates a [[FunctionalElement]] to its [[FunctionalType]]\n * @public\n */\nexport class FunctionalElementIsOfType extends RelatedElement {\n /** @internal */\n public static get className(): string { return \"FunctionalElementIsOfType\"; }\n public static classFullName = \"Functional:FunctionalElementIsOfType\";\n public constructor(id: Id64String, relClassName: string = FunctionalElementIsOfType.classFullName) {\n super({ id, relClassName });\n }\n}\n\n/** Relates a [[PhysicalElement]] to the [[FunctionalElement]] elements that it fulfills.\n * @public\n */\nexport class PhysicalElementFulfillsFunction extends ElementRefersToElements {\n /** @internal */\n public static override get className(): string { return \"PhysicalElementFulfillsFunction\"; }\n}\n\n/** Relates a [[DrawingGraphic]] to the [[FunctionalElement]] that it represents\n * @public\n */\nexport class DrawingGraphicRepresentsFunctionalElement extends DrawingGraphicRepresentsElement {\n /** @internal */\n public static override get className(): string { return \"DrawingGraphicRepresentsFunctionalElement\"; }\n}\n"]}
|
|
@@ -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;AAEvD,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,QAAQ,CAAC,sBAAsB,EAAE,CAAC;QACxD,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":["/*---------------------------------------------------------------------------------------------\
|
|
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;AAEvD,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,QAAQ,CAAC,sBAAsB,EAAE,CAAC;QACxD,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":["/*---------------------------------------------------------------------------------------------\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 { DbResult } from \"@itwin/core-bentley\";\nimport { IModelError } from \"@itwin/core-common\";\nimport { ClassRegistry } from \"../ClassRegistry\";\nimport { IModelDb } from \"../IModelDb\";\nimport { KnownLocations } from \"../IModelHost\";\nimport { Schema, Schemas } from \"../Schema\";\nimport * as elementsModule from \"./FunctionalElements\";\n\n/** @public */\nexport class FunctionalSchema extends Schema {\n public static override get schemaName(): string { return \"Functional\"; }\n public static get schemaFilePath(): string { return path.join(KnownLocations.nativeAssetsDir, \"ECSchemas\", \"Domain\", `${FunctionalSchema.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 /** @public */\n public static async importSchema(iModelDb: IModelDb) {\n if (iModelDb.isBriefcaseDb())\n await iModelDb.acquireSchemaLock();\n\n const stat = iModelDb.nativeDb.importFunctionalSchema();\n if (DbResult.BE_SQLITE_OK !== stat) {\n throw new IModelError(stat, \"Error importing Functional schema\");\n }\n }\n}\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;IAC9D,gBAAgB;IACT,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;AAND,0CAMC;AAED;;GAEG;AACH,MAAa,SAAU,SAAQ,eAAe;IAC5C,gBAAgB;IACT,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;AAND,8BAMC;AAED;;GAEG;AACH,MAAa,mBAAoB,SAAQ,eAAe;IACtD,gBAAgB;IACT,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;AAND,kDAMC;AAED;;GAEG;AACH,MAAsB,OAAQ,SAAQ,eAAe;IACnD,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OA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AAQ,kBAAQ;IAC3C,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,UAAU,CAAC,CAAC,CAAC;IACrE,YAAmB,KAAmB,EAAE,MAAgB;QACtD,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACvB,CAAC;CACF;AAND,0CAMC;AAED;;;GAGG;AACH,MAAa,uBAAwB,SAAQ,2BAAgB;IAC3D,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,kBAAkB,CAAC,CAAC,CAAC;IAC7E,YAAmB,KAA6B,EAAE,MAAgB;QAChE,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACvB,CAAC;CACF;AAND,0DAMC;AAED;;;GAGG;AACH,MAAa,mBAAoB,SAAQ,sBAAY;IACnD,gBAAgB;IACT,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;AAND,kDAMC;AAED;;;GAGG;AACH,MAAa,sBAAuB,SAAQ,yBAAe;IACzD,gBAAgB;IACT,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;AAND,wDAMC","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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\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
|
+
{"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;IAC9D,gBAAgB;IACT,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;AAND,0CAMC;AAED;;GAEG;AACH,MAAa,SAAU,SAAQ,eAAe;IAC5C,gBAAgB;IACT,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;AAND,8BAMC;AAED;;GAEG;AACH,MAAa,mBAAoB,SAAQ,eAAe;IACtD,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,qBAAqB,CAAC,CAAC,CAAC;IAChF,YAAmB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Ac,SAAS,KAAa,OAAO,OAAO,CAAC,CAAC,CAAC;IAClE,YAAmB,KAAmB,EAAE,MAAgB;QACtD,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACvB,CAAC;CACF;AAND,sBAMC;AAED;;;GAGG;AACH,MAAa,eAAgB,SAAQ,kBAAQ;IAC3C,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,UAAU,CAAC,CAAC,CAAC;IACrE,YAAmB,KAAmB,EAAE,MAAgB;QACtD,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACvB,CAAC;CACF;AAND,0CAMC;AAED;;;GAGG;AACH,MAAa,uBAAwB,SAAQ,2BAAgB;IAC3D,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,kBAAkB,CAAC,CAAC,CAAC;IAC7E,YAAmB,KAA6B,EAAE,MAAgB;QAChE,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACvB,CAAC;CACF;AAND,0DAMC;AAED;;;GAGG;AACH,MAAa,mBAAoB,SAAQ,sBAAY;IACnD,gBAAgB;IACT,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;AAND,kDAMC;AAED;;;GAGG;AACH,MAAa,sBAAuB,SAAQ,yBAAe;IACzD,gBAAgB;IACT,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;AAND,wDAMC","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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\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 /** @internal */\n public static override get className(): string { return \"GraphicalType2d\"; }\n public constructor(props: TypeDefinitionElementProps, iModel: IModelDb) {\n super(props, iModel);\n }\n}\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":["/*---------------------------------------------------------------------------------------------\
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImplementationProhibited.js","sourceRoot":"","sources":["../../../src/internal/ImplementationProhibited.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACU,QAAA,wBAAwB,GAAG,MAAM,CAAC,2BAA2B,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"ImplementationProhibited.js","sourceRoot":"","sources":["../../../src/internal/ImplementationProhibited.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACU,QAAA,wBAAwB,GAAG,MAAM,CAAC,2BAA2B,CAAC,CAAC","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\n/** A symbol used to prevent implementations of an interface from being created outside of the package that defines the interface.\n * This is useful when a package defines a public interface with one or more private implementations.\n * The only way for users of the package to obtain an implementation of the interface is by calling a method in the package's public API that returns one.\n * It permits the package to add new required properties and methods to the interface without breaking API compatibility, because no one\n * else can possibly have created their own implementations lacking those new properties or methods.\n *\n * Simple example:\n * ```ts\n * // @public\n * interface Thing {\n * name: string;\n * [implementationProhibited]: unknown;\n * }\n *\n * // Not exported\n * class ThingImpl implements Thing {\n * constructor(public name: string) { }\n * public readonly [implementationProhibited] = undefined;\n * }\n *\n * // @public\n * export function getThing(name: string): Thing { return new ThingImpl(name); }\n * ```\n *\n * This effectively turns the interface into a nominal type, bypassing TypeScript's structural typing.\n * If someone attempts to supply their own implementation of `Thing`:\n *\n * ```ts\n * const thing: Thing = { name: \"my thing\" };\n * ```\n *\n * ...they will receive a compiler error. Because they cannot access the `implementationProhibited` symbol,\n * they will not be able to appease the compiler except by casting to `any`.\n *\n * Of course, you must make sure not to export the symbol from the package - that would defeat the whole purpose.\n * It is exported here from the internal API for consumption inside the package only. It is not exported from the package's barrel file.\n *\n * The vast majority of interfaces do not need this.\n */\nexport const implementationProhibited = Symbol(\"implementation prohibited\");\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
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AAC,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC;IAC3C,CAAC;CACF;AA9ID,oCA8IC;KA7IkB,mDAAwB","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 \"../ImplementationProhibited\";\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"]}
|
|
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,0EAAuE;AAEvE,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,QAA0B,GAAG,SAAS,CAAC;QAKrD,IAAI,CAAC,KAAK,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC,+CAA+C;QAC1E,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC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I,YAAY,GAAG,KAAK,CAAC;QACzB,MAAM,GAAG,GAAQ,EAAE,CAAC;QACpB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,gBAAgB,CAAM,IAAI,CAAC,EAAE,CAAC;YACrD,YAAY,GAAG,IAAI,CAAC;YAEpB,uBAAU,CAAC,eAAe,CAAC,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YACxD,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE,CAAC;gBAC1B,IAAI,SAAS,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,kBAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;oBAC9D,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAClB,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC;IAC3C,CAAC;CACF;AA9ID,oCA8IC;KA7IkB,mDAAwB","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 \"../ImplementationProhibited\";\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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SettingsSchemasImpl.js","sourceRoot":"","sources":["../../../../src/internal/workspace/SettingsSchemasImpl.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;AAEH,+BAA+B;AAC/B,iCAA8B;AAC9B,+BAAqC;AACrC,sDAAmG;AAEnG,iDAA8C;AAE9C,0EAAuE;AAEvE,MAAM,cAAc,GAAG,CAAC,MAAc,EAAE,GAAW,EAAE,EAAE,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC;AAE3E,MAAM,mBAAmB;IAAzB;QACkB,QAA0B,GAAG,SAAS,CAAC;QACtC,eAAU,GAAG,IAAI,GAAG,EAA8B,CAAC;QACpE,mDAAmD;QACnC,gBAAW,GAAG,IAAI,GAAG,EAAyB,CAAC;QAC/D,wCAAwC;QACxB,aAAQ,GAAG,IAAI,G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AC;YACf,KAAK,SAAS,CAAC;YACf,KAAK,QAAQ;gBACX,OAAO,CAAC,CAAC;YACX,KAAK,QAAQ;gBACX,OAAO,EAAE,CAAC;YACZ,KAAK,OAAO;gBACV,OAAO,EAAE,CAAC;YACZ,KAAK,QAAQ;gBACX,OAAO,EAAE,CAAC;YACZ;gBACE,OAAO,SAAS,CAAC;QACrB,CAAC;IACH,CAAC;CACF;KAjRkB,mDAAwB;AAmR3C,SAAgB,wBAAwB;IACtC,OAAO,IAAI,mBAAmB,EAAE,CAAC;AACnC,CAAC;AAFD,4DAEC","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 { assert, BeEvent, JSONSchemaType, JSONSchemaTypeName, Mutable } from \"@itwin/core-bentley\";\r\nimport { LocalDirName, LocalFileName } from \"@itwin/core-common\";\r\nimport { IModelJsFs } from \"../../IModelJsFs\";\r\nimport { SettingGroupSchema, SettingSchema, SettingsSchemas } from \"../../workspace/SettingsSchemas\";\r\nimport { implementationProhibited } from \"../ImplementationProhibited\";\r\n\r\nconst makeSettingKey = (prefix: string, key: string) => `${prefix}/${key}`;\r\n\r\nclass SettingsSchemasImpl implements SettingsSchemas {\r\n public readonly [implementationProhibited] = undefined;\r\n private readonly _allGroups = new Map<string, SettingGroupSchema>();\r\n /** a map of all registered Setting Definitions */\r\n public readonly settingDefs = new Map<string, SettingSchema>();\r\n /** a map of all registered TypeDefs */\r\n public readonly typeDefs = new Map<string, SettingSchema>();\r\n /** event that signals that the values in [[allSchemas]] have changed in some way. */\r\n public readonly onSchemaChanged = new BeEvent<() => void>();\r\n\r\n private verifyType<T>(val: T, expectedType: JSONSchemaTypeName, path: string) {\r\n if (expectedType === \"integer\") {\r\n if (Number.isInteger(val))\r\n return;\r\n } else if (expectedType === \"null\") {\r\n if (val === null || val === undefined)\r\n return;\r\n } else if (typeof val === expectedType)\r\n return;\r\n\r\n throw new Error(`value for ${path}: \"${val}\" is wrong type, expected ${expectedType}`);\r\n }\r\n\r\n public validateSetting<T>(value: T, settingName: string): T {\r\n const settingDef = this.settingDefs.get(settingName);\r\n if (undefined !== settingDef) // if there's no setting definition, there's no rules so just return ok\r\n this.validateProperty(value, settingDef, settingName);\r\n return value;\r\n }\r\n\r\n /** @internal */\r\n public getObjectProperties(propDef: Readonly<SettingSchema>, scope: string): { required?: string[], properties: { [name: string]: SettingSchema } } {\r\n let required = propDef.required;\r\n let properties = propDef.properties;\r\n\r\n // if this object extends a typeDef, add typeDef's properties and required values, recursively\r\n if (propDef.extends !== undefined) {\r\n const typeDef = this.typeDefs.get(propDef.extends);\r\n if (undefined === typeDef)\r\n throw new Error(`typeDef ${propDef.extends} does not exist for ${scope}`);\r\n const expanded = this.getObjectProperties(typeDef, `${scope}.${propDef.extends}`);\r\n if (expanded.required)\r\n required = required ? [...required, ...expanded.required] : expanded.required;\r\n if (expanded.properties) {\r\n properties = properties ? { ...expanded.properties, ...properties } : expanded.properties;\r\n }\r\n }\r\n properties = properties ?? {};\r\n return { required, properties };\r\n }\r\n\r\n /** @internal */\r\n public getArrayItems(propDef: Readonly<SettingSchema>, scope: string): SettingSchema {\r\n let items = propDef.items;\r\n if (undefined === items && propDef.extends) {\r\n const typeDef = this.typeDefs.get(propDef.extends);\r\n if (undefined === typeDef)\r\n throw new Error(`typeDef ${propDef.extends} does not exist for ${scope}`);\r\n items = typeDef.items;\r\n }\r\n if (undefined === items)\r\n throw new Error(`array ${scope} has no items definition`);\r\n return items;\r\n }\r\n\r\n private validateProperty<T>(val: T, propDef: Readonly<SettingSchema>, path: string) {\r\n switch (propDef.type) {\r\n case \"boolean\":\r\n case \"number\":\r\n case \"string\":\r\n case \"integer\":\r\n case \"null\":\r\n return this.verifyType(val, propDef.type, path);\r\n\r\n case \"array\":\r\n if (!Array.isArray(val))\r\n throw new Error(`Property ${path} must be an array`);\r\n const items = this.getArrayItems(propDef, path);\r\n for (let i = 0; i < val.length; ++i)\r\n this.validateProperty(val[i], items, `${path}[${i}]`);\r\n return;\r\n }\r\n if (!val || typeof val !== \"object\")\r\n throw new Error(`${path} must be an object`);\r\n\r\n const { required, properties } = this.getObjectProperties(propDef, path);\r\n\r\n // first ensure all required properties are present\r\n if (undefined !== required) {\r\n for (const entry of required) {\r\n const value = (val as any)[entry];\r\n if (undefined === value)\r\n throw new Error(`required value for \"${entry}\" is missing in \"${path}\"`);\r\n }\r\n }\r\n\r\n // you can supply default values in typeDefs. See if any members are undefined that have a default.\r\n if (undefined !== properties) {\r\n for (const [key, prop] of Object.entries(properties)) {\r\n if ((val as any)[key] === undefined && prop.default)\r\n (val as any)[key] = prop.default;\r\n }\r\n }\r\n\r\n // then validate all values in the supplied object are valid\r\n for (const key of Object.keys(val)) {\r\n const prop = properties[key];\r\n if (prop !== undefined) { // note: extra values are ignored.\r\n this.validateProperty((val as any)[key], prop, `${path}.${key}`);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Add one or more [[SettingSchemaGroup]]s. `SettingSchemaGroup`s must include a `schemaPrefix` member that is used\r\n * to identify the group. If a group with the same name is already registered, the old values are first removed and then the new group is added.\r\n */\r\n public addGroup(settingsGroup: SettingGroupSchema | SettingGroupSchema[]): void {\r\n if (!Array.isArray(settingsGroup))\r\n settingsGroup = [settingsGroup];\r\n\r\n this.doAdd(settingsGroup);\r\n this.onSchemaChanged.raiseEvent();\r\n }\r\n\r\n /** Add a [[SettingSchemaGroup]] from stringified json5. */\r\n public addJson(settingSchema: string): void {\r\n this.addGroup(parse(settingSchema));\r\n }\r\n\r\n /** Add a [[SettingSchemaGroup]] from a json5 file. */\r\n public addFile(fileName: LocalFileName): void {\r\n try {\r\n this.addJson(fs.readFileSync(fileName, \"utf-8\"));\r\n } catch (e: any) {\r\n throw new Error(`parsing SettingSchema file \"${fileName}\": ${e.message}\"`);\r\n }\r\n }\r\n\r\n /** Add all files with a either \".json\" or \".json5\" extension from a supplied directory. */\r\n public addDirectory(dirName: LocalDirName) {\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));\r\n }\r\n }\r\n\r\n /** Remove a previously added [[SettingSchemaGroup]] by schemaPrefix */\r\n public removeGroup(schemaPrefix: string): void {\r\n this.doRemove(schemaPrefix);\r\n this.onSchemaChanged.raiseEvent();\r\n }\r\n\r\n private doAdd(settingsGroup: SettingGroupSchema[]) {\r\n settingsGroup.forEach((group) => {\r\n if (undefined === group.schemaPrefix)\r\n throw new Error(`settings group has no \"schemaPrefix\" member`);\r\n\r\n this.doRemove(group.schemaPrefix);\r\n this.validateAndAdd(group);\r\n this._allGroups.set(group.schemaPrefix, group);\r\n });\r\n }\r\n\r\n private doRemove(schemaPrefix: string) {\r\n const group = this._allGroups.get(schemaPrefix);\r\n if (undefined !== group?.settingDefs) {\r\n for (const key of Object.keys(group.settingDefs))\r\n this.settingDefs.delete(makeSettingKey(schemaPrefix, key));\r\n }\r\n if (undefined !== group?.typeDefs) {\r\n for (const key of Object.keys(group.typeDefs))\r\n this.settingDefs.delete(makeSettingKey(schemaPrefix, key));\r\n }\r\n this._allGroups.delete(schemaPrefix);\r\n }\r\n\r\n private validateName(name: string) {\r\n if (!name.trim())\r\n throw new Error(`empty property name`);\r\n }\r\n\r\n private verifyPropertyDef(name: string, property: SettingSchema | undefined) {\r\n if (!property)\r\n throw new Error(`missing required property ${name}`);\r\n\r\n if (!property.type)\r\n throw new Error(`property ${name} has no type`);\r\n\r\n switch (property.type) {\r\n case \"boolean\":\r\n case \"integer\":\r\n case \"null\":\r\n case \"number\":\r\n case \"string\":\r\n return;\r\n\r\n case \"object\":\r\n const required = property.required;\r\n const props = property.properties;\r\n if (required && props) {\r\n for (const entry of required) {\r\n if (undefined === props[entry])\r\n throw new Error(`missing required property of ${name}: \"${entry}\"`);\r\n }\r\n }\r\n if (props) {\r\n for (const key of Object.keys(props))\r\n try {\r\n this.verifyPropertyDef(key, props[key]);\r\n } catch (e: any) {\r\n throw new Error(`property ${key} of ${name}: ${e.message}`);\r\n }\r\n }\r\n return;\r\n\r\n case \"array\":\r\n if (typeof property.extends === \"string\")\r\n return;\r\n if (typeof property.items !== \"object\")\r\n throw new Error(`array property ${name} has no items member`);\r\n try {\r\n this.verifyPropertyDef(\"items\", property.items);\r\n } catch (e: any) {\r\n throw new Error(`array property ${name}: ${e.message}`);\r\n }\r\n return;\r\n\r\n default:\r\n throw new Error(`property ${name} has illegal type \"${property.type}\"`);\r\n }\r\n }\r\n\r\n private validateAndAdd(group: SettingGroupSchema) {\r\n const settingDefs = group.settingDefs;\r\n if (undefined !== settingDefs) {\r\n for (const key of Object.keys(settingDefs)) {\r\n this.validateName(key);\r\n this.verifyPropertyDef(key, settingDefs[key]);\r\n const property: Mutable<SettingSchema> | undefined = settingDefs[key];\r\n assert(undefined !== property);\r\n property.default = property.default ?? this.getDefaultValue(property.type);\r\n this.settingDefs.set(makeSettingKey(group.schemaPrefix, key), property);\r\n }\r\n }\r\n const typeDefs = group.typeDefs ?? {};\r\n for (const key of Object.keys(typeDefs)) {\r\n this.validateName(key);\r\n this.verifyPropertyDef(key, typeDefs[key]);\r\n const typeDef = typeDefs[key];\r\n assert(undefined !== typeDef);\r\n this.typeDefs.set(makeSettingKey(group.schemaPrefix, key), typeDef);\r\n }\r\n }\r\n\r\n private getDefaultValue(type: JSONSchemaTypeName | JSONSchemaTypeName[]): JSONSchemaType | undefined {\r\n type = Array.isArray(type) ? type[0] : type;\r\n switch (type) {\r\n case \"boolean\":\r\n return false;\r\n case \"integer\":\r\n case \"number\":\r\n return 0;\r\n case \"string\":\r\n return \"\";\r\n case \"array\":\r\n return [];\r\n case \"object\":\r\n return {};\r\n default:\r\n return undefined;\r\n }\r\n }\r\n}\r\n\r\nexport function constructSettingsSchemas(): SettingsSchemas {\r\n return new SettingsSchemasImpl();\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"SettingsSchemasImpl.js","sourceRoot":"","sources":["../../../../src/internal/workspace/SettingsSchemasImpl.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;AAEH,+BAA+B;AAC/B,iCAA8B;AAC9B,+BAAqC;AACrC,sDAAmG;AAEnG,iDAA8C;AAE9C,0EAAuE;AAEvE,MAAM,cAAc,GAAG,CAAC,MAAc,EAAE,GAAW,EAAE,EAAE,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC;AAE3E,MAAM,mBAAmB;IAAzB;QACkB,QAA0B,GAAG,SAAS,CAAC;QACtC,eAAU,GAAG,IAAI,GAAG,EAA8B,CAAC;QACpE,mDAAmD;QACnC,gBAAW,GAAG,IAAI,GAAG,EAAyB,CAAC;QAC/D,wCAAwC;QACxB,aAAQ,GAAG,IAAI,GAAG,EAAyB,CAAC;QAC5D,qFAAqF;QACrE,oBAAe,GAAG,IAAI,sBAAO,EAAc,CAAC;IA0Q9D,CAAC;IAxQS,UAAU,CAAI,GAAM,EAAE,YAAgC,EAAE,IAAY;QAC1E,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;YAC/B,IAAI,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC;gBACvB,OAAO;QACX,CAAC;aAAM,IAAI,YAAY,KAAK,MAAM,EAAE,CAAC;YACnC,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS;gBACnC,OAAO;QACX,CAAC;aAAM,IAAI,OAAO,GAAG,KAAK,YAAY;YACpC,OAAO;QAET,MAAM,IAAI,KAAK,CAAC,aAAa,IAAI,MAAM,GAAG,6BAA6B,YAAY,EAAE,CAAC,CAAC;IACzF,CAAC;IAEM,eAAe,CAAI,KAAQ,EAAE,WAAmB;QACrD,MAAM,UAAU,GAAG,IAAI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,CAAC,QAAQ,CAAC,EAAE,CAAC;YACxC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;YACvB,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;YAC3C,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;YAC9B,IAAA,qBAAM,EAAC,SAAS,KAAK,OAAO,CAAC,CAAC;YAC9B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,cAAc,CAAC,KAAK,CAAC,YAAY,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;QACtE,CAAC;IACH,CAAC;IAEO,eAAe,CAAC,IAA+C;QACrE,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAC5C,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,SAAS;gBACZ,OAAO,KAAK,CAAC;YACf,KAAK,SAAS,CAAC;YACf,KAAK,QAAQ;gBACX,OAAO,CAAC,CAAC;YACX,KAAK,QAAQ;gBACX,OAAO,EAAE,CAAC;YACZ,KAAK,OAAO;gBACV,OAAO,EAAE,CAAC;YACZ,KAAK,QAAQ;gBACX,OAAO,EAAE,CAAC;YACZ;gBACE,OAAO,SAAS,CAAC;QACrB,CAAC;IACH,CAAC;CACF;KAjRkB,mDAAwB;AAmR3C,SAAgB,wBAAwB;IACtC,OAAO,IAAI,mBAAmB,EAAE,CAAC;AACnC,CAAC;AAFD,4DAEC","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 { assert, BeEvent, JSONSchemaType, JSONSchemaTypeName, Mutable } from \"@itwin/core-bentley\";\nimport { LocalDirName, LocalFileName } from \"@itwin/core-common\";\nimport { IModelJsFs } from \"../../IModelJsFs\";\nimport { SettingGroupSchema, SettingSchema, SettingsSchemas } from \"../../workspace/SettingsSchemas\";\nimport { implementationProhibited } from \"../ImplementationProhibited\";\n\nconst makeSettingKey = (prefix: string, key: string) => `${prefix}/${key}`;\n\nclass SettingsSchemasImpl implements SettingsSchemas {\n public readonly [implementationProhibited] = undefined;\n private readonly _allGroups = new Map<string, SettingGroupSchema>();\n /** a map of all registered Setting Definitions */\n public readonly settingDefs = new Map<string, SettingSchema>();\n /** a map of all registered TypeDefs */\n public readonly typeDefs = new Map<string, SettingSchema>();\n /** event that signals that the values in [[allSchemas]] have changed in some way. */\n public readonly onSchemaChanged = new BeEvent<() => void>();\n\n private verifyType<T>(val: T, expectedType: JSONSchemaTypeName, path: string) {\n if (expectedType === \"integer\") {\n if (Number.isInteger(val))\n return;\n } else if (expectedType === \"null\") {\n if (val === null || val === undefined)\n return;\n } else if (typeof val === expectedType)\n return;\n\n throw new Error(`value for ${path}: \"${val}\" is wrong type, expected ${expectedType}`);\n }\n\n public validateSetting<T>(value: T, settingName: string): T {\n const settingDef = this.settingDefs.get(settingName);\n if (undefined !== settingDef) // if there's no setting definition, there's no rules so just return ok\n this.validateProperty(value, settingDef, settingName);\n return value;\n }\n\n /** @internal */\n public getObjectProperties(propDef: Readonly<SettingSchema>, scope: string): { required?: string[], properties: { [name: string]: SettingSchema } } {\n let required = propDef.required;\n let properties = propDef.properties;\n\n // if this object extends a typeDef, add typeDef's properties and required values, recursively\n if (propDef.extends !== undefined) {\n const typeDef = this.typeDefs.get(propDef.extends);\n if (undefined === typeDef)\n throw new Error(`typeDef ${propDef.extends} does not exist for ${scope}`);\n const expanded = this.getObjectProperties(typeDef, `${scope}.${propDef.extends}`);\n if (expanded.required)\n required = required ? [...required, ...expanded.required] : expanded.required;\n if (expanded.properties) {\n properties = properties ? { ...expanded.properties, ...properties } : expanded.properties;\n }\n }\n properties = properties ?? {};\n return { required, properties };\n }\n\n /** @internal */\n public getArrayItems(propDef: Readonly<SettingSchema>, scope: string): SettingSchema {\n let items = propDef.items;\n if (undefined === items && propDef.extends) {\n const typeDef = this.typeDefs.get(propDef.extends);\n if (undefined === typeDef)\n throw new Error(`typeDef ${propDef.extends} does not exist for ${scope}`);\n items = typeDef.items;\n }\n if (undefined === items)\n throw new Error(`array ${scope} has no items definition`);\n return items;\n }\n\n private validateProperty<T>(val: T, propDef: Readonly<SettingSchema>, path: string) {\n switch (propDef.type) {\n case \"boolean\":\n case \"number\":\n case \"string\":\n case \"integer\":\n case \"null\":\n return this.verifyType(val, propDef.type, path);\n\n case \"array\":\n if (!Array.isArray(val))\n throw new Error(`Property ${path} must be an array`);\n const items = this.getArrayItems(propDef, path);\n for (let i = 0; i < val.length; ++i)\n this.validateProperty(val[i], items, `${path}[${i}]`);\n return;\n }\n if (!val || typeof val !== \"object\")\n throw new Error(`${path} must be an object`);\n\n const { required, properties } = this.getObjectProperties(propDef, path);\n\n // first ensure all required properties are present\n if (undefined !== required) {\n for (const entry of required) {\n const value = (val as any)[entry];\n if (undefined === value)\n throw new Error(`required value for \"${entry}\" is missing in \"${path}\"`);\n }\n }\n\n // you can supply default values in typeDefs. See if any members are undefined that have a default.\n if (undefined !== properties) {\n for (const [key, prop] of Object.entries(properties)) {\n if ((val as any)[key] === undefined && prop.default)\n (val as any)[key] = prop.default;\n }\n }\n\n // then validate all values in the supplied object are valid\n for (const key of Object.keys(val)) {\n const prop = properties[key];\n if (prop !== undefined) { // note: extra values are ignored.\n this.validateProperty((val as any)[key], prop, `${path}.${key}`);\n }\n }\n }\n\n /**\n * Add one or more [[SettingSchemaGroup]]s. `SettingSchemaGroup`s must include a `schemaPrefix` member that is used\n * to identify the group. If a group with the same name is already registered, the old values are first removed and then the new group is added.\n */\n public addGroup(settingsGroup: SettingGroupSchema | SettingGroupSchema[]): void {\n if (!Array.isArray(settingsGroup))\n settingsGroup = [settingsGroup];\n\n this.doAdd(settingsGroup);\n this.onSchemaChanged.raiseEvent();\n }\n\n /** Add a [[SettingSchemaGroup]] from stringified json5. */\n public addJson(settingSchema: string): void {\n this.addGroup(parse(settingSchema));\n }\n\n /** Add a [[SettingSchemaGroup]] from a json5 file. */\n public addFile(fileName: LocalFileName): void {\n try {\n this.addJson(fs.readFileSync(fileName, \"utf-8\"));\n } catch (e: any) {\n throw new Error(`parsing SettingSchema file \"${fileName}\": ${e.message}\"`);\n }\n }\n\n /** Add all files with a either \".json\" or \".json5\" extension from a supplied directory. */\n public addDirectory(dirName: LocalDirName) {\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));\n }\n }\n\n /** Remove a previously added [[SettingSchemaGroup]] by schemaPrefix */\n public removeGroup(schemaPrefix: string): void {\n this.doRemove(schemaPrefix);\n this.onSchemaChanged.raiseEvent();\n }\n\n private doAdd(settingsGroup: SettingGroupSchema[]) {\n settingsGroup.forEach((group) => {\n if (undefined === group.schemaPrefix)\n throw new Error(`settings group has no \"schemaPrefix\" member`);\n\n this.doRemove(group.schemaPrefix);\n this.validateAndAdd(group);\n this._allGroups.set(group.schemaPrefix, group);\n });\n }\n\n private doRemove(schemaPrefix: string) {\n const group = this._allGroups.get(schemaPrefix);\n if (undefined !== group?.settingDefs) {\n for (const key of Object.keys(group.settingDefs))\n this.settingDefs.delete(makeSettingKey(schemaPrefix, key));\n }\n if (undefined !== group?.typeDefs) {\n for (const key of Object.keys(group.typeDefs))\n this.settingDefs.delete(makeSettingKey(schemaPrefix, key));\n }\n this._allGroups.delete(schemaPrefix);\n }\n\n private validateName(name: string) {\n if (!name.trim())\n throw new Error(`empty property name`);\n }\n\n private verifyPropertyDef(name: string, property: SettingSchema | undefined) {\n if (!property)\n throw new Error(`missing required property ${name}`);\n\n if (!property.type)\n throw new Error(`property ${name} has no type`);\n\n switch (property.type) {\n case \"boolean\":\n case \"integer\":\n case \"null\":\n case \"number\":\n case \"string\":\n return;\n\n case \"object\":\n const required = property.required;\n const props = property.properties;\n if (required && props) {\n for (const entry of required) {\n if (undefined === props[entry])\n throw new Error(`missing required property of ${name}: \"${entry}\"`);\n }\n }\n if (props) {\n for (const key of Object.keys(props))\n try {\n this.verifyPropertyDef(key, props[key]);\n } catch (e: any) {\n throw new Error(`property ${key} of ${name}: ${e.message}`);\n }\n }\n return;\n\n case \"array\":\n if (typeof property.extends === \"string\")\n return;\n if (typeof property.items !== \"object\")\n throw new Error(`array property ${name} has no items member`);\n try {\n this.verifyPropertyDef(\"items\", property.items);\n } catch (e: any) {\n throw new Error(`array property ${name}: ${e.message}`);\n }\n return;\n\n default:\n throw new Error(`property ${name} has illegal type \"${property.type}\"`);\n }\n }\n\n private validateAndAdd(group: SettingGroupSchema) {\n const settingDefs = group.settingDefs;\n if (undefined !== settingDefs) {\n for (const key of Object.keys(settingDefs)) {\n this.validateName(key);\n this.verifyPropertyDef(key, settingDefs[key]);\n const property: Mutable<SettingSchema> | undefined = settingDefs[key];\n assert(undefined !== property);\n property.default = property.default ?? this.getDefaultValue(property.type);\n this.settingDefs.set(makeSettingKey(group.schemaPrefix, key), property);\n }\n }\n const typeDefs = group.typeDefs ?? {};\n for (const key of Object.keys(typeDefs)) {\n this.validateName(key);\n this.verifyPropertyDef(key, typeDefs[key]);\n const typeDef = typeDefs[key];\n assert(undefined !== typeDef);\n this.typeDefs.set(makeSettingKey(group.schemaPrefix, key), typeDef);\n }\n }\n\n private getDefaultValue(type: JSONSchemaTypeName | JSONSchemaTypeName[]): JSONSchemaType | undefined {\n type = Array.isArray(type) ? type[0] : type;\n switch (type) {\n case \"boolean\":\n return false;\n case \"integer\":\n case \"number\":\n return 0;\n case \"string\":\n return \"\";\n case \"array\":\n return [];\n case \"object\":\n return {};\n default:\n return undefined;\n }\n }\n}\n\nexport function constructSettingsSchemas(): SettingsSchemas {\n return new SettingsSchemasImpl();\n}\n"]}
|