@itwin/core-backend 3.6.0-dev.8 → 4.0.0-dev.1
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 +28 -1
- package/LICENSE.md +1 -1
- package/lib/cjs/AliCloudStorageService.d.ts +2 -2
- package/lib/cjs/AliCloudStorageService.js +1 -1
- package/lib/cjs/AliCloudStorageService.js.map +1 -1
- package/lib/cjs/BackendHubAccess.d.ts +2 -2
- package/lib/cjs/BackendHubAccess.js.map +1 -1
- package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
- package/lib/cjs/BriefcaseManager.js +1 -0
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/ChangeSummaryManager.d.ts +2 -2
- package/lib/cjs/ChangeSummaryManager.js +1 -1
- package/lib/cjs/ChangeSummaryManager.js.map +1 -1
- package/lib/cjs/CheckpointManager.d.ts +3 -2
- package/lib/cjs/CheckpointManager.d.ts.map +1 -1
- package/lib/cjs/CheckpointManager.js +14 -8
- package/lib/cjs/CheckpointManager.js.map +1 -1
- package/lib/cjs/ClassRegistry.d.ts.map +1 -1
- package/lib/cjs/ClassRegistry.js +2 -1
- package/lib/cjs/ClassRegistry.js.map +1 -1
- package/lib/cjs/CloudSqlite.d.ts.map +1 -1
- package/lib/cjs/CloudSqlite.js +2 -1
- package/lib/cjs/CloudSqlite.js.map +1 -1
- package/lib/cjs/CloudStorageBackend.d.ts +4 -4
- package/lib/cjs/CloudStorageBackend.js +3 -3
- package/lib/cjs/CloudStorageBackend.js.map +1 -1
- package/lib/cjs/CodeSpecs.d.ts +5 -0
- package/lib/cjs/CodeSpecs.d.ts.map +1 -1
- package/lib/cjs/CodeSpecs.js +12 -0
- package/lib/cjs/CodeSpecs.js.map +1 -1
- package/lib/cjs/ECSqlStatement.d.ts +8 -1
- package/lib/cjs/ECSqlStatement.d.ts.map +1 -1
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/Element.d.ts +10 -3
- package/lib/cjs/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +17 -6
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/ElementAspect.d.ts +5 -2
- package/lib/cjs/ElementAspect.d.ts.map +1 -1
- package/lib/cjs/ElementAspect.js +1 -1
- package/lib/cjs/ElementAspect.js.map +1 -1
- package/lib/cjs/IModelCloneContext.d.ts +2 -2
- package/lib/cjs/IModelCloneContext.d.ts.map +1 -1
- package/lib/cjs/IModelCloneContext.js +1 -1
- package/lib/cjs/IModelCloneContext.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +14 -1
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +22 -4
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelHost.d.ts +7 -8
- package/lib/cjs/IModelHost.d.ts.map +1 -1
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/IpcHost.js +4 -4
- package/lib/cjs/IpcHost.js.map +1 -1
- package/lib/cjs/LocalHub.d.ts.map +1 -1
- package/lib/cjs/LocalHub.js +1 -3
- package/lib/cjs/LocalHub.js.map +1 -1
- package/lib/cjs/Material.d.ts +49 -21
- package/lib/cjs/Material.d.ts.map +1 -1
- package/lib/cjs/Material.js +41 -7
- package/lib/cjs/Material.js.map +1 -1
- package/lib/cjs/RpcBackend.d.ts.map +1 -1
- package/lib/cjs/RpcBackend.js +1 -0
- package/lib/cjs/RpcBackend.js.map +1 -1
- package/lib/cjs/domains/FunctionalSchema.d.ts +1 -1
- package/lib/cjs/domains/FunctionalSchema.d.ts.map +1 -1
- package/lib/cjs/domains/FunctionalSchema.js +1 -1
- package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
- package/lib/cjs/rpc/multipart.d.ts.map +1 -1
- package/lib/cjs/rpc/multipart.js +1 -0
- package/lib/cjs/rpc/multipart.js.map +1 -1
- package/lib/cjs/rpc/tracing.d.ts.map +1 -1
- package/lib/cjs/rpc/tracing.js +1 -0
- package/lib/cjs/rpc/tracing.js.map +1 -1
- package/lib/cjs/rpc/web/logging.d.ts.map +1 -1
- package/lib/cjs/rpc/web/logging.js +1 -0
- package/lib/cjs/rpc/web/logging.js.map +1 -1
- package/lib/cjs/rpc/web/request.d.ts.map +1 -1
- package/lib/cjs/rpc/web/request.js +1 -0
- package/lib/cjs/rpc/web/request.js.map +1 -1
- package/lib/cjs/rpc/web/response.d.ts.map +1 -1
- package/lib/cjs/rpc/web/response.js +1 -0
- 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 +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +34 -31
- 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 +10 -7
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +2 -2
- 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/Workspace.js +2 -2
- package/lib/cjs/workspace/Workspace.js.map +1 -1
- package/package.json +13 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClassRegistry.js","sourceRoot":"","sources":["../../src/ClassRegistry.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA2E;AAC3E,oDAAqG;AACrG,qCAAkC;AAElC,qCAA2C;AAC3C,yDAAsD;AACtD,iCAAiC;AAEjC,MAAM,mBAAmB,GAAG,M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YAC9C,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM;gBAC5B,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SAClC;IACH,CAAC;;AA7OH,sCA8OC;AA7OyB,uBAAS,GAAG,IAAI,GAAG,EAAyB,CAAC;AA+OvE;;;GAGG;AACH,MAAa,gBAAgB;IAA7B;QACU,cAAS,GAAgC,IAAI,GAAG,EAA0B,CAAC;IAOrF,CAAC;IALC,wCAAwC;IACjC,IAAI,CAAC,aAAqB,IAAgC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC;IAE1H,gCAAgC;IACzB,GAAG,CAAC,aAAqB,EAAE,QAAwB,IAAU,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;CACjI;AARD,4CAQC","sourcesContent":["/*---------------------------------------------------------------------------------------------\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 { DbResult, Id64, IModelStatus, Logger } from \"@itwin/core-bentley\";\r\nimport { EntityMetaData, EntityReferenceSet, IModelError, RelatedElement } from \"@itwin/core-common\";\r\nimport { Entity } from \"./Entity\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { Schema, Schemas } from \"./Schema\";\r\nimport { EntityReferences } from \"./EntityReferences\";\r\nimport * as assert from \"assert\";\r\n\r\nconst isGeneratedClassTag = Symbol(\"isGeneratedClassTag\");\r\n\r\n/** The mapping between a BIS class name (in the form \"schema:class\") and its JavaScript constructor function\r\n * @public\r\n */\r\nexport class ClassRegistry {\r\n private static readonly _classMap = new Map<string, typeof Entity>();\r\n /** @internal */\r\n public static isNotFoundError(err: any) { return (err instanceof IModelError) && (err.errorNumber === IModelStatus.NotFound); }\r\n /** @internal */\r\n public static makeMetaDataNotFoundError(className: string): IModelError { return new IModelError(IModelStatus.NotFound, `metadata not found for ${className}`); }\r\n /** @internal */\r\n public static register(entityClass: typeof Entity, schema: typeof Schema) {\r\n entityClass.schema = schema;\r\n const key = (`${schema.schemaName}:${entityClass.className}`).toLowerCase();\r\n if (this._classMap.has(key)) {\r\n const errMsg = `Class ${key} is already registered. Make sure static className member is correct on JavaScript class ${entityClass.name}`;\r\n Logger.logError(\"core-frontend.classRegistry\", errMsg);\r\n throw new Error(errMsg);\r\n }\r\n\r\n this._classMap.set(key, entityClass);\r\n }\r\n\r\n /** Generate a proxy Schema for a domain that has not been registered. */\r\n private static generateProxySchema(domain: string, iModel: IModelDb): typeof Schema {\r\n const hasBehavior = iModel.withPreparedSqliteStatement(`\r\n SELECT NULL FROM [ec_CustomAttribute] [c]\r\n JOIN [ec_schema] [s] ON [s].[Id] = [c].[ContainerId]\r\n JOIN [ec_class] [e] ON [e].[Id] = [c].[ClassId]\r\n JOIN [ec_schema] [b] ON [e].[SchemaId] = [b].[Id]\r\n WHERE [c].[ContainerType] = 1 AND [s].[Name] = ? AND [b].[Name] || '.' || [e].[name] = ?`, (stmt) => {\r\n stmt.bindString(1, domain);\r\n stmt.bindString(2, \"BisCore.SchemaHasBehavior\");\r\n return stmt.step() === DbResult.BE_SQLITE_ROW;\r\n });\r\n\r\n const schemaClass = class extends Schema {\r\n public static override get schemaName() { return domain; }\r\n public static override get missingRequiredBehavior() { return hasBehavior; }\r\n };\r\n\r\n Schemas.registerSchema(schemaClass); // register the class before we return it.\r\n return schemaClass;\r\n }\r\n\r\n /** First, finds the root BisCore entity class for an entity, by traversing base classes and mixin targets (AppliesTo).\r\n * Then, gets its metadata and returns that.\r\n * @param iModel - iModel containing the metadata for this type\r\n * @param ecTypeQualifier - a full name of an ECEntityClass to find the root of\r\n * @returns the qualified full name of an ECEntityClass\r\n * @internal public for testing only\r\n */\r\n public static getRootEntity(iModel: IModelDb, ecTypeQualifier: string): string {\r\n const [classSchema, className] = ecTypeQualifier.split(\".\");\r\n const schemaItemJson = iModel.nativeDb.getSchemaItem(classSchema, className);\r\n if (schemaItemJson.error)\r\n throw new IModelError(schemaItemJson.error, `failed to get schema item '${ecTypeQualifier}'`);\r\n const schemaItem = JSON.parse(schemaItemJson.result as string);\r\n if (!(\"appliesTo\" in schemaItem) && schemaItem.baseClass === undefined) {\r\n return ecTypeQualifier;\r\n }\r\n // typescript doesn't understand that the inverse of the above condition is\r\n // (\"appliesTo\" in rootclassMetaData || rootClassMetaData.baseClass !== undefined)\r\n const parentItemQualifier = schemaItem.appliesTo ?? schemaItem.baseClass as string;\r\n return this.getRootEntity(iModel, parentItemQualifier);\r\n }\r\n\r\n /** Generate a JavaScript class from Entity metadata.\r\n * @param entityMetaData The Entity metadata that defines the class\r\n */\r\n private static generateClassForEntity(entityMetaData: EntityMetaData, iModel: IModelDb): typeof Entity {\r\n const name = entityMetaData.ecclass.split(\":\");\r\n const domainName = name[0];\r\n const className = name[1];\r\n\r\n if (0 === entityMetaData.baseClasses.length) // metadata must contain a superclass\r\n throw new IModelError(IModelStatus.BadArg, `class ${name} has no superclass`);\r\n\r\n // make sure schema exists\r\n let schema = Schemas.getRegisteredSchema(domainName);\r\n if (undefined === schema)\r\n schema = this.generateProxySchema(domainName, iModel); // no schema found, create it too\r\n\r\n const superclass = this._classMap.get(entityMetaData.baseClasses[0].toLowerCase());\r\n if (undefined === superclass)\r\n throw new IModelError(IModelStatus.NotFound, `cannot find superclass for class ${name}`);\r\n\r\n // user defined class hierarchies may skip a class in the hierarchy, and therefore their JS base class cannot\r\n // be used to tell if there are any generated classes in the hierarchy\r\n let generatedClassHasNonGeneratedNonCoreAncestor = false;\r\n let currentSuperclass = superclass;\r\n const MAX_ITERS = 1000;\r\n for (let i = 0; i < MAX_ITERS; ++i) {\r\n if (currentSuperclass.schema.schemaName === \"BisCore\")\r\n break;\r\n\r\n if (!currentSuperclass.isGeneratedClass) {\r\n generatedClassHasNonGeneratedNonCoreAncestor = true;\r\n break;\r\n }\r\n const superclassMetaData = iModel.classMetaDataRegistry.find(currentSuperclass.classFullName);\r\n if (superclassMetaData === undefined)\r\n throw new IModelError(IModelStatus.BadSchema, `could not find the metadata for class '${currentSuperclass.name}', class metadata should be loaded by now`);\r\n const maybeNextSuperclass = this.getClass(superclassMetaData.baseClasses[0], iModel);\r\n if (maybeNextSuperclass === undefined)\r\n throw new IModelError(IModelStatus.BadSchema, `could not find the base class of '${currentSuperclass.name}', all generated classes must have a base class`);\r\n currentSuperclass = maybeNextSuperclass;\r\n }\r\n\r\n const generatedClass = class extends superclass {\r\n public static override get className() { return className; }\r\n private static [isGeneratedClassTag] = true;\r\n public static override get isGeneratedClass() { return this.hasOwnProperty(isGeneratedClassTag); }\r\n };\r\n\r\n // the above creates an anonymous class. For help debugging, set the \"constructor.name\" property to be the same as the bisClassName.\r\n Object.defineProperty(generatedClass, \"name\", { get: () => className }); // this is the (only) way to change that readonly property.\r\n\r\n // a class only gets an automatic `collectReferenceConcreteIds` implementation if:\r\n // - it is not in the `BisCore` schema\r\n // - there are no ancestors with manually registered JS implementations, (excluding BisCore base classes)\r\n if (!generatedClassHasNonGeneratedNonCoreAncestor) {\r\n const navigationProps = Object.entries(entityMetaData.properties)\r\n .filter(([_name, prop]) => prop.isNavigation)\r\n // eslint-disable-next-line @typescript-eslint/no-shadow\r\n .map(([name, prop]) => {\r\n assert(prop.relationshipClass);\r\n const maybeMetaData = iModel.nativeDb.getSchemaItem(...prop.relationshipClass.split(\":\") as [string, string]);\r\n assert(maybeMetaData.result !== undefined, \"The nav props relationship metadata was not found\");\r\n const relMetaData = JSON.parse(maybeMetaData.result);\r\n const rootClassMetaData = ClassRegistry.getRootEntity(iModel, relMetaData.target.constraintClasses[0]);\r\n // root class must be in BisCore so should be loaded since biscore classes will never get this\r\n // generated implementation\r\n const normalizeClassName = (clsName: string) => clsName.replace(\".\", \":\");\r\n const rootClass = ClassRegistry.findRegisteredClass(normalizeClassName(rootClassMetaData));\r\n assert(rootClass, `The root class for ${prop.relationshipClass} was not in BisCore.`);\r\n return { name, concreteEntityType: EntityReferences.typeFromClass(rootClass) };\r\n });\r\n\r\n Object.defineProperty(\r\n generatedClass.prototype,\r\n \"collectReferenceConcreteIds\",\r\n {\r\n value(this: typeof generatedClass, referenceIds: EntityReferenceSet) {\r\n // eslint-disable-next-line @typescript-eslint/dot-notation\r\n const superImpl = superclass.prototype[\"collectReferenceConcreteIds\"];\r\n superImpl.call(this, referenceIds);\r\n for (const navProp of navigationProps) {\r\n const relatedElem: RelatedElement | undefined = (this as any)[navProp.name]; // cast to any since subclass can have any extensions\r\n if (!relatedElem || !Id64.isValid(relatedElem.id))\r\n continue;\r\n const referenceId = EntityReferences.fromEntityType(relatedElem.id, navProp.concreteEntityType);\r\n referenceIds.add(referenceId);\r\n }\r\n },\r\n // defaults for methods on a prototype (required for sinon to stub out methods on tests)\r\n writable: true,\r\n configurable: true,\r\n }\r\n );\r\n }\r\n\r\n // if the schema is a proxy for a domain with behavior, throw exceptions for all protected operations\r\n if (schema.missingRequiredBehavior) {\r\n const throwError = () => {\r\n throw new IModelError(IModelStatus.WrongHandler, `Schema [${domainName}] not registered, but is marked with SchemaHasBehavior`);\r\n };\r\n\r\n superclass.protectedOperations.forEach((operation) => (generatedClass as any)[operation] = throwError);\r\n }\r\n\r\n this.register(generatedClass, schema); // register it before returning\r\n return generatedClass;\r\n }\r\n\r\n /** Register all of the classes found in the given module that derive from Entity. See the example in [[Schema]]\r\n * @param moduleObj The module to search for subclasses of Entity\r\n * @param schema The schema for all found classes\r\n */\r\n public static registerModule(moduleObj: any, schema: typeof Schema) {\r\n for (const thisMember in moduleObj) { // eslint-disable-line guard-for-in\r\n const thisClass = moduleObj[thisMember];\r\n if (thisClass.prototype instanceof Entity)\r\n this.register(thisClass, schema);\r\n }\r\n }\r\n\r\n /**\r\n * This function fetches the specified Entity from the imodel, generates a JavaScript class for it, and registers the generated\r\n * class. This function also ensures that all of the base classes of the Entity exist and are registered.\r\n */\r\n private static generateClass(classFullName: string, iModel: IModelDb): typeof Entity {\r\n const metadata: EntityMetaData | undefined = iModel.classMetaDataRegistry.find(classFullName);\r\n if (metadata === undefined || metadata.ecclass === undefined)\r\n throw this.makeMetaDataNotFoundError(classFullName);\r\n\r\n // Make sure we have all base classes registered.\r\n if (metadata.baseClasses && (0 !== metadata.baseClasses.length))\r\n this.getClass(metadata.baseClasses[0], iModel);\r\n\r\n // Now we can generate the class from the classDef.\r\n return this.generateClassForEntity(metadata, iModel);\r\n }\r\n\r\n /** Find a registered class by classFullName.\r\n * @param classFullName class to find\r\n * @param iModel The IModel that contains the class definitions\r\n * @returns The Entity class or undefined\r\n */\r\n public static findRegisteredClass(classFullName: string): typeof Entity | undefined {\r\n return this._classMap.get(classFullName.toLowerCase());\r\n }\r\n\r\n /** Get the Entity class for the specified Entity className.\r\n * @param classFullName The full BIS class name of the Entity\r\n * @param iModel The IModel that contains the class definitions\r\n * @returns The Entity class\r\n */\r\n public static getClass(classFullName: string, iModel: IModelDb): typeof Entity {\r\n const key = classFullName.toLowerCase();\r\n const ctor = this._classMap.get(key);\r\n return ctor ? ctor : this.generateClass(key, iModel);\r\n }\r\n\r\n /** Unregister a class, by name, if one is already registered.\r\n * This function is not normally needed, but is useful for cases where a generated *proxy* class needs to be replaced by the *real* class.\r\n * @param classFullName Name of the class to unregister\r\n * @return true if the class was unregistered\r\n * @internal\r\n */\r\n public static unregisterCLass(classFullName: string) { return this._classMap.delete(classFullName.toLowerCase()); }\r\n /** Unregister all classes from a schema.\r\n * This function is not normally needed, but is useful for cases where a generated *proxy* schema needs to be replaced by the *real* schema.\r\n * @param schema Name of the schema to unregister\r\n * @internal\r\n */\r\n public static unregisterClassesFrom(schema: typeof Schema) {\r\n for (const entry of Array.from(this._classMap)) {\r\n if (entry[1].schema === schema)\r\n this.unregisterCLass(entry[0]);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * A cache that records the mapping between class names and class metadata\r\n * @internal\r\n */\r\nexport class MetaDataRegistry {\r\n private _registry: Map<string, EntityMetaData> = new Map<string, EntityMetaData>();\r\n\r\n /** Get the specified Entity metadata */\r\n public find(classFullName: string): EntityMetaData | undefined { return this._registry.get(classFullName.toLowerCase()); }\r\n\r\n /** Add metadata to the cache */\r\n public add(classFullName: string, metaData: EntityMetaData): void { this._registry.set(classFullName.toLowerCase(), metaData); }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"ClassRegistry.js","sourceRoot":"","sources":["../../src/ClassRegistry.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA2E;AAC3E,oDAAqG;AACrG,qCAAkC;AAElC,qCAA2C;AAC3C,yDAAsD;AACtD,iCAAiC;AAEjC,MAAM,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;AAE1D;;GAEG;AACH,MAAa,aAAa;IAExB,gBAAgB;IACT,MAAM,CAAC,eAAe,CAAC,GAAQ,IAAI,OAAO,CAAC,GAAG,YAAY,yBAAW,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,KAAK,2BAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC/H,gBAAgB;IACT,MAAM,CAAC,yBAAyB,CAAC,SAAiB,IAAiB,OAAO,IAAI,yBAAW,CAAC,2BAAY,CAAC,QAAQ,EAAE,0BAA0B,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;IACjK,gBAAgB;IACT,MAAM,CAAC,QAAQ,CAAC,WAA0B,EAAE,MAAqB;QACtE,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC;QAC5B,MAAM,GAAG,GAAG,CAAC,GAAG,MAAM,CAAC,UAAU,IAAI,WAAW,CAAC,SAAS,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QAC5E,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAA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AARD,4CAQC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Schema\r\n */\r\n\r\nimport { DbResult, Id64, IModelStatus, Logger } from \"@itwin/core-bentley\";\r\nimport { EntityMetaData, EntityReferenceSet, IModelError, RelatedElement } from \"@itwin/core-common\";\r\nimport { Entity } from \"./Entity\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { Schema, Schemas } from \"./Schema\";\r\nimport { EntityReferences } from \"./EntityReferences\";\r\nimport * as assert from \"assert\";\r\n\r\nconst isGeneratedClassTag = Symbol(\"isGeneratedClassTag\");\r\n\r\n/** The mapping between a BIS class name (in the form \"schema:class\") and its JavaScript constructor function\r\n * @public\r\n */\r\nexport class ClassRegistry {\r\n private static readonly _classMap = new Map<string, typeof Entity>();\r\n /** @internal */\r\n public static isNotFoundError(err: any) { return (err instanceof IModelError) && (err.errorNumber === IModelStatus.NotFound); }\r\n /** @internal */\r\n public static makeMetaDataNotFoundError(className: string): IModelError { return new IModelError(IModelStatus.NotFound, `metadata not found for ${className}`); }\r\n /** @internal */\r\n public static register(entityClass: typeof Entity, schema: typeof Schema) {\r\n entityClass.schema = schema;\r\n const key = (`${schema.schemaName}:${entityClass.className}`).toLowerCase();\r\n if (this._classMap.has(key)) {\r\n const errMsg = `Class ${key} is already registered. Make sure static className member is correct on JavaScript class ${entityClass.name}`;\r\n Logger.logError(\"core-frontend.classRegistry\", errMsg);\r\n throw new Error(errMsg);\r\n }\r\n\r\n this._classMap.set(key, entityClass);\r\n }\r\n\r\n /** Generate a proxy Schema for a domain that has not been registered. */\r\n private static generateProxySchema(domain: string, iModel: IModelDb): typeof Schema {\r\n const hasBehavior = iModel.withPreparedSqliteStatement(`\r\n SELECT NULL FROM [ec_CustomAttribute] [c]\r\n JOIN [ec_schema] [s] ON [s].[Id] = [c].[ContainerId]\r\n JOIN [ec_class] [e] ON [e].[Id] = [c].[ClassId]\r\n JOIN [ec_schema] [b] ON [e].[SchemaId] = [b].[Id]\r\n WHERE [c].[ContainerType] = 1 AND [s].[Name] = ? AND [b].[Name] || '.' || [e].[name] = ?`, (stmt) => {\r\n stmt.bindString(1, domain);\r\n stmt.bindString(2, \"BisCore.SchemaHasBehavior\");\r\n return stmt.step() === DbResult.BE_SQLITE_ROW;\r\n });\r\n\r\n const schemaClass = class extends Schema {\r\n public static override get schemaName() { return domain; }\r\n public static override get missingRequiredBehavior() { return hasBehavior; }\r\n };\r\n\r\n Schemas.registerSchema(schemaClass); // register the class before we return it.\r\n return schemaClass;\r\n }\r\n\r\n /** First, finds the root BisCore entity class for an entity, by traversing base classes and mixin targets (AppliesTo).\r\n * Then, gets its metadata and returns that.\r\n * @param iModel - iModel containing the metadata for this type\r\n * @param ecTypeQualifier - a full name of an ECEntityClass to find the root of\r\n * @returns the qualified full name of an ECEntityClass\r\n * @internal public for testing only\r\n */\r\n public static getRootEntity(iModel: IModelDb, ecTypeQualifier: string): string {\r\n const [classSchema, className] = ecTypeQualifier.split(\".\");\r\n const schemaItemJson = iModel.nativeDb.getSchemaItem(classSchema, className);\r\n if (schemaItemJson.error)\r\n throw new IModelError(schemaItemJson.error.status, `failed to get schema item '${ecTypeQualifier}'`);\r\n\r\n assert(undefined !== schemaItemJson.result);\r\n const schemaItem = JSON.parse(schemaItemJson.result);\r\n if (!(\"appliesTo\" in schemaItem) && schemaItem.baseClass === undefined) {\r\n return ecTypeQualifier;\r\n }\r\n\r\n // typescript doesn't understand that the inverse of the above condition is\r\n // (\"appliesTo\" in rootclassMetaData || rootClassMetaData.baseClass !== undefined)\r\n const parentItemQualifier = schemaItem.appliesTo ?? schemaItem.baseClass as string;\r\n return this.getRootEntity(iModel, parentItemQualifier);\r\n }\r\n\r\n /** Generate a JavaScript class from Entity metadata.\r\n * @param entityMetaData The Entity metadata that defines the class\r\n */\r\n private static generateClassForEntity(entityMetaData: EntityMetaData, iModel: IModelDb): typeof Entity {\r\n const name = entityMetaData.ecclass.split(\":\");\r\n const domainName = name[0];\r\n const className = name[1];\r\n\r\n if (0 === entityMetaData.baseClasses.length) // metadata must contain a superclass\r\n throw new IModelError(IModelStatus.BadArg, `class ${name} has no superclass`);\r\n\r\n // make sure schema exists\r\n let schema = Schemas.getRegisteredSchema(domainName);\r\n if (undefined === schema)\r\n schema = this.generateProxySchema(domainName, iModel); // no schema found, create it too\r\n\r\n const superclass = this._classMap.get(entityMetaData.baseClasses[0].toLowerCase());\r\n if (undefined === superclass)\r\n throw new IModelError(IModelStatus.NotFound, `cannot find superclass for class ${name}`);\r\n\r\n // user defined class hierarchies may skip a class in the hierarchy, and therefore their JS base class cannot\r\n // be used to tell if there are any generated classes in the hierarchy\r\n let generatedClassHasNonGeneratedNonCoreAncestor = false;\r\n let currentSuperclass = superclass;\r\n const MAX_ITERS = 1000;\r\n for (let i = 0; i < MAX_ITERS; ++i) {\r\n if (currentSuperclass.schema.schemaName === \"BisCore\")\r\n break;\r\n\r\n if (!currentSuperclass.isGeneratedClass) {\r\n generatedClassHasNonGeneratedNonCoreAncestor = true;\r\n break;\r\n }\r\n const superclassMetaData = iModel.classMetaDataRegistry.find(currentSuperclass.classFullName);\r\n if (superclassMetaData === undefined)\r\n throw new IModelError(IModelStatus.BadSchema, `could not find the metadata for class '${currentSuperclass.name}', class metadata should be loaded by now`);\r\n const maybeNextSuperclass = this.getClass(superclassMetaData.baseClasses[0], iModel);\r\n if (maybeNextSuperclass === undefined)\r\n throw new IModelError(IModelStatus.BadSchema, `could not find the base class of '${currentSuperclass.name}', all generated classes must have a base class`);\r\n currentSuperclass = maybeNextSuperclass;\r\n }\r\n\r\n const generatedClass = class extends superclass {\r\n public static override get className() { return className; }\r\n private static [isGeneratedClassTag] = true;\r\n public static override get isGeneratedClass() { return this.hasOwnProperty(isGeneratedClassTag); }\r\n };\r\n\r\n // the above creates an anonymous class. For help debugging, set the \"constructor.name\" property to be the same as the bisClassName.\r\n Object.defineProperty(generatedClass, \"name\", { get: () => className }); // this is the (only) way to change that readonly property.\r\n\r\n // a class only gets an automatic `collectReferenceConcreteIds` implementation if:\r\n // - it is not in the `BisCore` schema\r\n // - there are no ancestors with manually registered JS implementations, (excluding BisCore base classes)\r\n if (!generatedClassHasNonGeneratedNonCoreAncestor) {\r\n const navigationProps = Object.entries(entityMetaData.properties)\r\n .filter(([_name, prop]) => prop.isNavigation)\r\n // eslint-disable-next-line @typescript-eslint/no-shadow\r\n .map(([name, prop]) => {\r\n assert(prop.relationshipClass);\r\n const maybeMetaData = iModel.nativeDb.getSchemaItem(...prop.relationshipClass.split(\":\") as [string, string]);\r\n assert(maybeMetaData.result !== undefined, \"The nav props relationship metadata was not found\");\r\n const relMetaData = JSON.parse(maybeMetaData.result);\r\n const rootClassMetaData = ClassRegistry.getRootEntity(iModel, relMetaData.target.constraintClasses[0]);\r\n // root class must be in BisCore so should be loaded since biscore classes will never get this\r\n // generated implementation\r\n const normalizeClassName = (clsName: string) => clsName.replace(\".\", \":\");\r\n const rootClass = ClassRegistry.findRegisteredClass(normalizeClassName(rootClassMetaData));\r\n assert(rootClass, `The root class for ${prop.relationshipClass} was not in BisCore.`);\r\n return { name, concreteEntityType: EntityReferences.typeFromClass(rootClass) };\r\n });\r\n\r\n Object.defineProperty(\r\n generatedClass.prototype,\r\n \"collectReferenceConcreteIds\",\r\n {\r\n value(this: typeof generatedClass, referenceIds: EntityReferenceSet) {\r\n // eslint-disable-next-line @typescript-eslint/dot-notation\r\n const superImpl = superclass.prototype[\"collectReferenceConcreteIds\"];\r\n superImpl.call(this, referenceIds);\r\n for (const navProp of navigationProps) {\r\n const relatedElem: RelatedElement | undefined = (this as any)[navProp.name]; // cast to any since subclass can have any extensions\r\n if (!relatedElem || !Id64.isValid(relatedElem.id))\r\n continue;\r\n const referenceId = EntityReferences.fromEntityType(relatedElem.id, navProp.concreteEntityType);\r\n referenceIds.add(referenceId);\r\n }\r\n },\r\n // defaults for methods on a prototype (required for sinon to stub out methods on tests)\r\n writable: true,\r\n configurable: true,\r\n }\r\n );\r\n }\r\n\r\n // if the schema is a proxy for a domain with behavior, throw exceptions for all protected operations\r\n if (schema.missingRequiredBehavior) {\r\n const throwError = () => {\r\n throw new IModelError(IModelStatus.WrongHandler, `Schema [${domainName}] not registered, but is marked with SchemaHasBehavior`);\r\n };\r\n\r\n superclass.protectedOperations.forEach((operation) => (generatedClass as any)[operation] = throwError);\r\n }\r\n\r\n this.register(generatedClass, schema); // register it before returning\r\n return generatedClass;\r\n }\r\n\r\n /** Register all of the classes found in the given module that derive from Entity. See the example in [[Schema]]\r\n * @param moduleObj The module to search for subclasses of Entity\r\n * @param schema The schema for all found classes\r\n */\r\n public static registerModule(moduleObj: any, schema: typeof Schema) {\r\n for (const thisMember in moduleObj) { // eslint-disable-line guard-for-in\r\n const thisClass = moduleObj[thisMember];\r\n if (thisClass.prototype instanceof Entity)\r\n this.register(thisClass, schema);\r\n }\r\n }\r\n\r\n /**\r\n * This function fetches the specified Entity from the imodel, generates a JavaScript class for it, and registers the generated\r\n * class. This function also ensures that all of the base classes of the Entity exist and are registered.\r\n */\r\n private static generateClass(classFullName: string, iModel: IModelDb): typeof Entity {\r\n const metadata: EntityMetaData | undefined = iModel.classMetaDataRegistry.find(classFullName);\r\n if (metadata === undefined || metadata.ecclass === undefined)\r\n throw this.makeMetaDataNotFoundError(classFullName);\r\n\r\n // Make sure we have all base classes registered.\r\n if (metadata.baseClasses && (0 !== metadata.baseClasses.length))\r\n this.getClass(metadata.baseClasses[0], iModel);\r\n\r\n // Now we can generate the class from the classDef.\r\n return this.generateClassForEntity(metadata, iModel);\r\n }\r\n\r\n /** Find a registered class by classFullName.\r\n * @param classFullName class to find\r\n * @param iModel The IModel that contains the class definitions\r\n * @returns The Entity class or undefined\r\n */\r\n public static findRegisteredClass(classFullName: string): typeof Entity | undefined {\r\n return this._classMap.get(classFullName.toLowerCase());\r\n }\r\n\r\n /** Get the Entity class for the specified Entity className.\r\n * @param classFullName The full BIS class name of the Entity\r\n * @param iModel The IModel that contains the class definitions\r\n * @returns The Entity class\r\n */\r\n public static getClass(classFullName: string, iModel: IModelDb): typeof Entity {\r\n const key = classFullName.toLowerCase();\r\n const ctor = this._classMap.get(key);\r\n return ctor ? ctor : this.generateClass(key, iModel);\r\n }\r\n\r\n /** Unregister a class, by name, if one is already registered.\r\n * This function is not normally needed, but is useful for cases where a generated *proxy* class needs to be replaced by the *real* class.\r\n * @param classFullName Name of the class to unregister\r\n * @return true if the class was unregistered\r\n * @internal\r\n */\r\n public static unregisterCLass(classFullName: string) { return this._classMap.delete(classFullName.toLowerCase()); }\r\n /** Unregister all classes from a schema.\r\n * This function is not normally needed, but is useful for cases where a generated *proxy* schema needs to be replaced by the *real* schema.\r\n * @param schema Name of the schema to unregister\r\n * @internal\r\n */\r\n public static unregisterClassesFrom(schema: typeof Schema) {\r\n for (const entry of Array.from(this._classMap)) {\r\n if (entry[1].schema === schema)\r\n this.unregisterCLass(entry[0]);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * A cache that records the mapping between class names and class metadata\r\n * @internal\r\n */\r\nexport class MetaDataRegistry {\r\n private _registry: Map<string, EntityMetaData> = new Map<string, EntityMetaData>();\r\n\r\n /** Get the specified Entity metadata */\r\n public find(classFullName: string): EntityMetaData | undefined { return this._registry.get(classFullName.toLowerCase()); }\r\n\r\n /** Add metadata to the cache */\r\n public add(classFullName: string, metaData: EntityMetaData): void { this._registry.set(classFullName.toLowerCase(), metaData); }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudSqlite.d.ts","sourceRoot":"","sources":["../../src/CloudSqlite.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,
|
|
1
|
+
{"version":3,"file":"CloudSqlite.d.ts","sourceRoot":"","sources":["../../src/CloudSqlite.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAAmB,UAA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11,6 +11,7 @@ exports.CloudSqlite = void 0;
|
|
|
11
11
|
const fs_1 = require("fs");
|
|
12
12
|
const path_1 = require("path");
|
|
13
13
|
const imodeljs_native_1 = require("@bentley/imodeljs-native");
|
|
14
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
14
15
|
/** Types for using SQLite files stored in cloud containers.
|
|
15
16
|
* @beta
|
|
16
17
|
*/
|
|
@@ -66,7 +67,7 @@ var CloudSqlite;
|
|
|
66
67
|
}
|
|
67
68
|
catch (err) {
|
|
68
69
|
if (err.message === "cancelled")
|
|
69
|
-
err.errorNumber =
|
|
70
|
+
err.errorNumber = core_bentley_1.BriefcaseStatus.DownloadCancelled;
|
|
70
71
|
throw err;
|
|
71
72
|
}
|
|
72
73
|
finally {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudSqlite.js","sourceRoot":"","sources":["../../src/CloudSqlite.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,2BAA+B;AAC/B,+BAA+B;AAC/B,8DAAyD;AAIzD;;GAEG;AACH,IAAiB,WAAW,CA6b3B;AA7bD,WAAiB,WAAW;IAC1B,SAAgB,oBAAoB,CAAC,IAA0B;QAC7D,OAAO,IAAI,+BAAa,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IAC1D,CAAC;IAFe,gCAAoB,uBAEnC,CAAA;IACD,SAAgB,gBAAgB,CAAC,IAA4B;QAC3D,OAAO,IAAI,+BAAa,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAFe,4BAAgB,mBAE/B,CAAA;IACD,SAAgB,kBAAkB,CAAC,SAAqC,EAAE,MAAc,EAAE,IAAgC;QACxH,OAAO,IAAI,+BAAa,CAAC,SAAS,CAAC,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAC5E,CAAC;IAFe,8BAAkB,qBAEjC,CAAA;IAwHD,qD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AAE,SAAyB,EAAE,SAAkB,EAAE,WAAkC;QACpI,IAAI,SAAS,CAAC,YAAY;YACxB,OAAO,SAAS,EAAE,CAAC;QAErB,MAAM,gBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;QACrD,IAAI;YACF,6DAA6D;YAC7D,MAAM,GAAG,GAAG,MAAM,SAAS,EAAE,CAAC,CAAC,kCAAkC;YACjE,SAAS,CAAC,gBAAgB,EAAE,CAAC;YAC7B,OAAO,GAAG,CAAC;SACZ;QAAC,OAAO,CAAC,EAAE;YACV,SAAS,CAAC,cAAc,EAAE,CAAC,CAAE,0CAA0C;YACvE,MAAM,CAAC,CAAC;SACT;IACH,CAAC;IAdqB,yBAAa,gBAclC,CAAA;AACH,CAAC,EA7bgB,WAAW,GAAX,mBAAW,KAAX,mBAAW,QA6b3B","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 SQLiteDb\r\n */\r\n\r\nimport { mkdirSync } from \"fs\";\r\nimport { dirname } from \"path\";\r\nimport { NativeLibrary } from \"@bentley/imodeljs-native\";\r\nimport { GuidString } from \"@itwin/core-bentley\";\r\nimport { LocalDirName, LocalFileName } from \"@itwin/core-common\";\r\n\r\n/** Types for using SQLite files stored in cloud containers.\r\n * @beta\r\n */\r\nexport namespace CloudSqlite {\r\n export function createCloudContainer(args: ContainerAccessProps): CloudContainer {\r\n return new NativeLibrary.nativeLib.CloudContainer(args);\r\n }\r\n export function createCloudCache(args: CloudSqlite.CacheProps): CloudSqlite.CloudCache {\r\n return new NativeLibrary.nativeLib.CloudCache(args);\r\n }\r\n export function startCloudPrefetch(container: CloudSqlite.CloudContainer, dbName: string, args?: CloudSqlite.PrefetchProps): CloudSqlite.CloudPrefetch {\r\n return new NativeLibrary.nativeLib.CloudPrefetch(container, dbName, args);\r\n }\r\n\r\n /** Properties that specify how to access the account for a cloud blob-store container. */\r\n export interface AccountAccessProps {\r\n /** blob storage module: e.g. \"azure\", \"google\", \"aws\". May also include URI style parameters. */\r\n storageType: string;\r\n /** blob store account name, or a URI for custom domains. */\r\n accessName: string;\r\n }\r\n\r\n /** Properties of a CloudContainer. */\r\n export interface ContainerProps {\r\n /** the name of the container. */\r\n containerId: string;\r\n /** an alias for the container. Defaults to `containerId` */\r\n alias?: string;\r\n /** token that grants access to the container. For sas=1 `storageType`s, this is the sasToken. For sas=0, this is the account key */\r\n accessToken: string;\r\n /** if true, container is attached with write permissions, and accessToken must provide write access to the cloud container. */\r\n writeable?: boolean;\r\n /** if true, container is attached in \"secure\" mode (blocks are encrypted). Only supported in daemon mode. */\r\n secure?: boolean;\r\n }\r\n\r\n /** Returned from `CloudContainer.queryDatabase` describing one database in the container */\r\n export interface CachedDbProps {\r\n /** The total of (4Mb) blocks in the database. */\r\n readonly totalBlocks: number;\r\n /** the number of blocks of the database that have been downloaded into the CloudCache */\r\n readonly localBlocks: number;\r\n /** the number of blocks from this database that have been modified in the CloudCache and need to be uploaded. */\r\n readonly dirtyBlocks: number;\r\n /** If true, the database currently has transactions in the WAL file and may not be uploaded until they have been checkPointed. */\r\n readonly transactions: boolean;\r\n /** the state of this database. Indicates whether the database is new or deleted since last upload */\r\n readonly state: \"\" | \"copied\" | \"deleted\";\r\n }\r\n\r\n /** Properties for accessing a CloudContainer */\r\n export type ContainerAccessProps = AccountAccessProps & ContainerProps & {\r\n /** Duration for holding write lock, in seconds. After this time the write lock expires if not refreshed. Default is one hour. */\r\n durationSeconds?: number;\r\n };\r\n\r\n /** The name of a CloudSqlite database within a CloudContainer. */\r\n export interface DbNameProp {\r\n /** the name of the database within the CloudContainer.\r\n * @note names of databases within a CloudContainer are always **case sensitive** on all platforms.*/\r\n dbName: string;\r\n }\r\n\r\n /** Properties for accessing a database within a CloudContainer */\r\n export interface DbProps extends DbNameProp {\r\n /** the name of the local file to access the database. */\r\n localFileName: LocalFileName;\r\n }\r\n\r\n export type TransferDirection = \"upload\" | \"download\";\r\n export interface TransferProgress {\r\n /** a user-supplied progress function called during the transfer operation. Return a non-0 value to abort the transfer. */\r\n onProgress?: (loaded: number, total: number) => number;\r\n }\r\n\r\n export interface CloudHttpProps {\r\n /** The number of simultaneous HTTP requests. Default is 6. */\r\n nRequests?: number;\r\n }\r\n\r\n export interface PrefetchProps extends CloudHttpProps {\r\n /** timeout between requests, in milliseconds. Default is 100. */\r\n timeout?: number;\r\n /** The number of prefetch requests to issue while there is foreground activity. Default is 3. */\r\n minRequests?: number;\r\n }\r\n\r\n export type TransferDbProps = DbProps & TransferProgress & CloudHttpProps;\r\n\r\n /** Properties for creating a CloudCache. */\r\n export interface CacheProps extends CloudHttpProps {\r\n /** full path of directory for cache to store its files. Must be on a (preferably fast) local drive, and must be empty when the cache is first created. */\r\n rootDir: string;\r\n /** name of this cache. It is possible to have more than one CloudCache in the same session. */\r\n name: string;\r\n /** maximum cache Size. Must be a number followed by either M (for megabytes) or G (for gigabytes.) Default is 1G */\r\n cacheSize?: string;\r\n /** turn on diagnostics for `curl` (outputs to stderr) */\r\n curlDiagnostics?: boolean;\r\n }\r\n\r\n /** Parameters used to obtain the write lock on a cloud container\r\n * @internal\r\n */\r\n export interface ObtainLockParams {\r\n /** The name of the user attempting to acquire the write lock. This name will be shown to other users while the lock is held. */\r\n user?: string;\r\n /** number of times to retry in the event the lock currently held by someone else.\r\n * After this number of attempts, `onFailure` is called. Default is 20.\r\n */\r\n nRetries: number;\r\n /** Delay between retries, in milliseconds. Default is 100. */\r\n retryDelayMs: number;\r\n /** function called if lock cannot be obtained after all retries. It is called with the name of the user currently holding the lock and\r\n * generally is expected that the user will be consulted whether to wait further.\r\n * If this function returns \"stop\", an exception will be thrown. Otherwise the retry cycle is restarted.\r\n */\r\n onFailure?: WriteLockBusyHandler;\r\n }\r\n\r\n /** @internal */\r\n export interface LockAndOpenArgs {\r\n /** the name to be displayed in the event of lock collisions */\r\n user: string;\r\n /** the name of the database within the container */\r\n dbName: string;\r\n /** the CloudContainer on which the operation will be performed */\r\n container: CloudContainer;\r\n /** if present, function called when the write lock is currently held by another user. */\r\n busyHandler?: WriteLockBusyHandler;\r\n }\r\n\r\n /** Logging categories for `CloudCache.setLogMask` */\r\n export enum LoggingMask {\r\n /** log all HTTP requests and responses */\r\n HTTP = 0x01,\r\n /** log as blocks become dirty and must be uploaded */\r\n DirtyBlocks = 0x02,\r\n /** log as blocks are added to the delete list */\r\n AddToDelete = 0x04,\r\n /** log container lifecycle events (e.g. authorization requests, disconnects, and state transitions) */\r\n LifecycleEvents = 0x08,\r\n /** Turn on all logging categories */\r\n All = 0xff,\r\n /** Disable logging */\r\n None = 0,\r\n }\r\n\r\n /**\r\n * A cache for storing data from CloudSqlite databases. This object refers to a directory on a local filesystem\r\n * and is used to **connect** CloudContainers so they may be accessed. The contents of the cache directory are entirely\r\n * controlled by CloudSqlite and should be empty when the cache is first created and never modified directly. It maintains\r\n * the state of the local data across sessions.\r\n */\r\n export interface CloudCache {\r\n /** `true` if this CloudCache is connected to a daemon process */\r\n get isDaemon(): boolean;\r\n /** The name for this CloudCache. */\r\n get name(): string;\r\n /** The root directory of this CloudCache on a local drive. */\r\n get rootDir(): LocalDirName;\r\n /** The guid for this CloudCache. Used for acquiring write lock. */\r\n get guid(): GuidString;\r\n /** Configure logging for this CloudCache.\r\n * @param mask A bitmask of `LoggingMask` values\r\n * @note this method does nothing if [[isDaemon]] is true. Daemon logging is configured when the daemon is started.\r\n * @note HTTP logging can be happen on multiple threads and may be buffered. To see buffered log messages, periodically call\r\n * `IModelHost.flushLog`\r\n */\r\n setLogMask(mask: number): void;\r\n /** destroy this CloudCache. All CloudContainers should be detached before calling this. */\r\n destroy(): void;\r\n }\r\n\r\n /** A CloudSqlite container that may be connected to a CloudCache. */\r\n export interface CloudContainer {\r\n readonly cache?: CloudCache;\r\n /** The ContainerId. */\r\n get containerId(): string;\r\n /** The *alias* to identify this CloudContainer in a CloudCache. Usually just the ContainerId. */\r\n get alias(): string;\r\n /** true if this CloudContainer is currently connected to a CloudCache via the `connect` method. */\r\n get isConnected(): boolean;\r\n /** true if this CloudContainer was created with the `writeable` flag (and its `accessToken` supplies write access). */\r\n get isWriteable(): boolean;\r\n /** true if this CloudContainer currently holds the write lock for its container in the cloud. */\r\n get hasWriteLock(): boolean;\r\n /** true if this CloudContainer has local changes that have not be uploaded to its container in the cloud. */\r\n get hasLocalChanges(): boolean;\r\n /** The current accessToken providing access to the cloud container */\r\n get accessToken(): string;\r\n set accessToken(val: string);\r\n /** Get the number of garbage blocks in this container that can be purged. */\r\n get garbageBlocks(): number;\r\n /** The block size for this CloudContainer. */\r\n get blockSize(): number;\r\n\r\n /**\r\n * initialize a cloud blob-store container to be used as a new Sqlite CloudContainer. This creates the manifest, and should be\r\n * performed on an empty container. If an existing manifest is present, it is destroyed and a new one is created (essentially emptying the container.)\r\n */\r\n initializeContainer(opts?: { checksumBlockNames?: boolean, blockSize?: number }): void;\r\n\r\n /**\r\n * Attempt to acquire the write lock for this CloudContainer. For this to succeed:\r\n * 1. it must be connected to a `CloudCache`\r\n * 2. this CloudContainer must have been constructed with `writeable: true`\r\n * 3. the `accessToken` must authorize write access\r\n * 4. no other process may be holding an unexpired write lock\r\n * @throws exception if any of the above conditions fail\r\n * @note Write locks *expire* after the duration specified in the `durationSeconds` property of the constructor argument, in case a process\r\n * crashes or otherwise fails to release the lock. Calling `acquireWriteLock` with the lock already held resets the lock duration from the current time,\r\n * so long running processes should call this method periodically to ensure their lock doesn't expire (they should also make sure their accessToken is refreshed\r\n * before it expires.)\r\n * @note on success, the manifest is polled before the promise resolves.\r\n * @param user An identifier of the process/user locking the CloudContainer. In the event of a write lock\r\n * collision, this string will be included in the exception string of the *other* process attempting to obtain a write lock.\r\n */\r\n acquireWriteLock(user: string): void;\r\n\r\n /**\r\n * Release the write lock if it is currently held.\r\n * @note if there are local changes that have not been uploaded, they are automatically uploaded before the write lock is released.\r\n * @note if the write lock is not held, this method does nothing.\r\n */\r\n releaseWriteLock(): void;\r\n\r\n /**\r\n * Destroy any currently valid write lock from this or any other process. This is obviously very dangerous and defeats the purpose of write locking.\r\n * This method exists only for administrator tools to clear a failed process without waiting for the expiration period. It can also be useful for tests.\r\n * For this to succeed, all of the conditions of `acquireWriteLock` must be true other than #4.\r\n */\r\n clearWriteLock(): void;\r\n\r\n /**\r\n * Abandon any local changes in this container. If the write lock is currently held, it is released.\r\n * This function fails with BE_SQLITE_BUSY if one or more clients have open read or write transactions\r\n * on any database in the container.\r\n */\r\n abandonChanges(): void;\r\n\r\n /**\r\n * Connect this CloudContainer to a CloudCache for reading or writing its manifest, write lock, and databases.\r\n * @note A CloudCache is a local directory holding copies of information from the cloud. Its content is persistent across sessions,\r\n * but this method must be called each session to (re)establish the connection to the cache. If the CloudCache was previously populated,\r\n * this method may be called and will succeed *even when offline* or without a valid `accessToken`.\r\n * @note all operations that access the contents of databases or the manifest require this method be called (`isConnected === true`).\r\n */\r\n connect(cache: CloudCache): void;\r\n\r\n /**\r\n * Disconnect this CloudContainer from its CloudCache. There must be no open databases from this container. Leaves the container attached to the\r\n * CloudCache so it is available for future sessions.\r\n */\r\n disconnect(): void;\r\n\r\n /**\r\n * Permanently Detach and Disconnect this CloudContainer from its CloudCache. There must be no open databases from this container.\r\n */\r\n detach(): void;\r\n\r\n /**\r\n * Poll cloud storage for changes from other processes. *No changes* made by other processes are visible to\r\n * this CloudContainer unless/until this method is called.\r\n * @note this is automatically called whenever the write lock is obtained to ensure all changes are against the latest version.\r\n */\r\n checkForChanges(): void;\r\n\r\n /**\r\n * Upload any changed blocks from all databases in this CloudContainer.\r\n * @note this is called automatically from `releaseWriteLock` before the write lock is released. It is only necessary to call this directly if you\r\n * wish to upload changes while the write lock is still held.\r\n * @see hasLocalChanges\r\n */\r\n uploadChanges(): Promise<void>;\r\n\r\n /**\r\n * Clean any unused deleted blocks from cloud storage. When a database is written, a subset of its blocks are replaced\r\n * by new versions, sometimes leaving the originals unused. In this case, they are not deleted immediately.\r\n * Instead, they are scheduled for deletion at some later time. Calling this method deletes all blocks in the cloud container\r\n * for which the scheduled deletion time has passed.\r\n * @param nSeconds Any block that was marked as unused before this number of seconds ago will be deleted. Specifying a non-zero\r\n * value gives a period of time for other clients to refresh their manifests and stop using the now-garbage blocks. Otherwise they may get\r\n * a 404 error. Default is 1 hour.\r\n */\r\n cleanDeletedBlocks(nSeconds?: number): Promise<void>;\r\n\r\n /**\r\n * Create a copy of an existing database within this CloudContainer with a new name.\r\n * @note CloudSqlite uses copy-on-write semantics for this operation. That is, this method merely makes a\r\n * new entry in the manifest with the new name that *shares* all of its blocks with the original database.\r\n * If either database subsequently changes, the only modified blocks are not shared.\r\n */\r\n copyDatabase(dbName: string, toAlias: string): Promise<void>;\r\n\r\n /** Remove a database from this CloudContainer.\r\n * @see cleanDeletedBlocks\r\n */\r\n deleteDatabase(dbName: string): Promise<void>;\r\n\r\n /** Get the list of database names in this CloudContainer.\r\n * @param globArg if present, filter the results with SQLite [GLOB](https://www.sqlite.org/lang_expr.html#glob) operator.\r\n */\r\n queryDatabases(globArg?: string): string[];\r\n\r\n /**\r\n * Get the status of a specific database in this CloudContainer.\r\n * @param dbName the name of the database of interest\r\n */\r\n queryDatabase(dbName: string): CloudSqlite.CachedDbProps | undefined;\r\n\r\n /**\r\n * Get the SHA1 hash of the content of a database.\r\n * @param dbName the name of the database of interest\r\n * @note the hash will be empty if the database does not exist\r\n */\r\n queryDatabaseHash(dbName: string): string;\r\n }\r\n\r\n /** @internal */\r\n export interface CloudPrefetch {\r\n readonly cloudContainer: CloudContainer;\r\n readonly dbName: string;\r\n\r\n /** Cancel a currently pending prefetch. The promise will be resolved immediately after this call. */\r\n cancel(): void;\r\n\r\n /**\r\n * Promise that is resolved when the prefetch completes or is cancelled. Await this promise to ensure that the\r\n * database has been fully downloaded before going offline, for example.\r\n * @returns a Promise that resolves to `true` if the prefetch completed and the entire database is local, or `false` if it was aborted or failed.\r\n * @note the promise is *not* rejected on `cancel`. Some progress may (or may not) have been made by the request.\r\n * @note To monitor the progress being made during prefetch, call `CloudContainer.queryDatabase` periodically.\r\n */\r\n promise: Promise<boolean>;\r\n }\r\n\r\n /** @internal */\r\n export async function transferDb(direction: TransferDirection, container: CloudContainer, props: TransferDbProps) {\r\n if (direction === \"download\")\r\n mkdirSync(dirname(props.localFileName), { recursive: true }); // make sure the directory exists before starting download\r\n\r\n let timer: NodeJS.Timeout | undefined;\r\n try {\r\n const transfer = new NativeLibrary.nativeLib.CloudDbTransfer(direction, container, props);\r\n let total = 0;\r\n const onProgress = props.onProgress;\r\n if (onProgress) {\r\n timer = setInterval(async () => { // set an interval timer to show progress every 250ms\r\n const progress = transfer.getProgress();\r\n total = progress.total;\r\n if (onProgress(progress.loaded, progress.total))\r\n transfer.cancelTransfer();\r\n }, 250);\r\n }\r\n await transfer.promise;\r\n onProgress?.(total, total); // make sure we call progress func one last time when download completes\r\n } catch (err: any) {\r\n if (err.message === \"cancelled\")\r\n err.errorNumber = 131079; // BriefcaseStatus.DownloadCancelled\r\n\r\n throw err;\r\n } finally {\r\n if (timer)\r\n clearInterval(timer);\r\n }\r\n }\r\n\r\n /** Upload a database into a CloudContainer\r\n * @param container the CloudContainer holding the database. Must be connected.\r\n * @param props the properties that describe the database to be downloaded, plus optionally an `onProgress` function.\r\n * @note this function requires that the write lock be held on the container\r\n */\r\n export async function uploadDb(container: CloudContainer, props: TransferDbProps): Promise<void> {\r\n await transferDb(\"upload\", container, props);\r\n container.checkForChanges(); // re-read the manifest so the database is available locally.\r\n }\r\n\r\n /** Download a database from a CloudContainer\r\n * @param container the CloudContainer holding the database. Must be connected.\r\n * @param props the properties that describe the database to be downloaded, plus optionally an `onProgress` function.\r\n * @returns a Promise that is resolved when the download completes.\r\n * @note the download is \"restartable.\" If the transfer is aborted and then re-requested, it will continue from where\r\n * it left off rather than re-downloading the entire file.\r\n */\r\n export async function downloadDb(container: CloudContainer, props: TransferDbProps): Promise<void> {\r\n await transferDb(\"download\", container, props);\r\n }\r\n\r\n /** Optional method to be called when an attempt to acquire the write lock fails because another user currently holds it.\r\n * @param lockedBy The identifier supplied by the application/user that currently holds the lock.\r\n * @param expires a stringified Date (in local time) indicating when the lock will expire.\r\n * @return \"stop\" to give up and stop retrying. Generally, it's a good idea to wait for some time before returning.\r\n */\r\n export type WriteLockBusyHandler = (lockedBy: string, expires: string) => Promise<void | \"stop\">;\r\n\r\n /**\r\n * Attempt to acquire the write lock for a container, with retries.\r\n * If write lock is held by another user, call busyHandler if supplied. If no busyHandler, or handler returns \"stop\", throw. Otherwise try again.\r\n * @note if write lock is already held, this function does nothing.\r\n * @param user the name to be displayed to other users in the event they attempt to obtain the lock while it is held by us\r\n * @param container the CloudContainer for which the lock is to be acquired\r\n * @param busyHandler if present, function called when the write lock is currently held by another user.\r\n */\r\n export async function acquireWriteLock(user: string, container: CloudContainer, busyHandler?: WriteLockBusyHandler) {\r\n if (container.hasWriteLock)\r\n return;\r\n\r\n while (true) {\r\n try {\r\n return container.acquireWriteLock(user);\r\n } catch (e: any) {\r\n if (e.errorNumber === 5 && busyHandler && \"stop\" !== await busyHandler(e.lockedBy, e.expires)) // 5 === BE_SQLITE_BUSY\r\n continue; // busy handler wants to try again\r\n throw e;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Perform an asynchronous write operation on a CloudContainer with the write lock held.\r\n * 1. if write lock is already held, call operation and return.\r\n * 2. attempt to acquire the write lock, with retries. Throw if unable to obtain write lock.\r\n * 3. perform the operation\r\n * 3.a if the operation throws, abandon all changes and re-throw\r\n * 4. release the write lock.\r\n * 5. return value from operation\r\n * @param user the name to be displayed to other users in the event they attempt to obtain the lock while it is held by us\r\n * @param container the CloudContainer for which the lock is to be acquired\r\n * @param operation an asynchronous operation performed with the write lock held.\r\n * @param busyHandler if present, function called when the write lock is currently held by another user.\r\n * @returns a Promise with the result of `operation`\r\n */\r\n export async function withWriteLock<T>(user: string, container: CloudContainer, operation: () => T, busyHandler?: WriteLockBusyHandler) {\r\n if (container.hasWriteLock)\r\n return operation();\r\n\r\n await acquireWriteLock(user, container, busyHandler);\r\n try {\r\n // eslint-disable-next-line @typescript-eslint/await-thenable\r\n const val = await operation(); // wait for work to finish or fail\r\n container.releaseWriteLock();\r\n return val;\r\n } catch (e) {\r\n container.abandonChanges(); // if operation threw, abandon all changes\r\n throw e;\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"CloudSqlite.js","sourceRoot":"","sources":["../../src/CloudSqlite.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,2BAA+B;AAC/B,+BAA+B;AAC/B,8DAAyD;AACzD,sDAAkE;AAGlE;;GAEG;AACH,IAAiB,WAAW,CA6b3B;AA7bD,WAAiB,WAAW;IAC1B,SAAgB,oBAAoB,CAAC,IAA0B;QAC7D,OAAO,IAAI,+BAAa,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IAC1D,CAAC;IAFe,gCAAoB,uBAEnC,CAAA;IACD,SAAgB,gBAAgB,CAAC,IAA4B;QAC3D,OAAO,IAAI,+BAAa,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAFe,4BAAgB,mBAE/B,CAAA;IACD,SAAgB,kBAAkB,CAAC,SAAqC,EAAE,MAAc,EAAE,IAAgC;QACxH,OAAO,IAAI,+BAAa,CAAC,SAAS,CAAC,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAC5E,CAAC;IAFe,8BAAkB,qBAEjC,CAAA;IAwHD,qDAAqD;IACrD,IAAY,WAaX;IAbD,WAAY,WAAW;QACrB,0CAA0C;QAC1C,6CAAW,CAAA;QACX,sDAAsD;QACtD,2DAAkB,CAAA;QAClB,iDAAiD;QACjD,2DAAkB,CAAA;QAClB,uGAAuG;QACvG,mEAAsB,CAAA;QACtB,qCAAqC;QACrC,6CAAU,C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AG,GAAG,MAAM,SAAS,EAAE,CAAC,CAAC,kCAAkC;YACjE,SAAS,CAAC,gBAAgB,EAAE,CAAC;YAC7B,OAAO,GAAG,CAAC;SACZ;QAAC,OAAO,CAAC,EAAE;YACV,SAAS,CAAC,cAAc,EAAE,CAAC,CAAE,0CAA0C;YACvE,MAAM,CAAC,CAAC;SACT;IACH,CAAC;IAdqB,yBAAa,gBAclC,CAAA;AACH,CAAC,EA7bgB,WAAW,GAAX,mBAAW,KAAX,mBAAW,QA6b3B","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 SQLiteDb\r\n */\r\n\r\nimport { mkdirSync } from \"fs\";\r\nimport { dirname } from \"path\";\r\nimport { NativeLibrary } from \"@bentley/imodeljs-native\";\r\nimport { BriefcaseStatus, GuidString } from \"@itwin/core-bentley\";\r\nimport { LocalDirName, LocalFileName } from \"@itwin/core-common\";\r\n\r\n/** Types for using SQLite files stored in cloud containers.\r\n * @beta\r\n */\r\nexport namespace CloudSqlite {\r\n export function createCloudContainer(args: ContainerAccessProps): CloudContainer {\r\n return new NativeLibrary.nativeLib.CloudContainer(args);\r\n }\r\n export function createCloudCache(args: CloudSqlite.CacheProps): CloudSqlite.CloudCache {\r\n return new NativeLibrary.nativeLib.CloudCache(args);\r\n }\r\n export function startCloudPrefetch(container: CloudSqlite.CloudContainer, dbName: string, args?: CloudSqlite.PrefetchProps): CloudSqlite.CloudPrefetch {\r\n return new NativeLibrary.nativeLib.CloudPrefetch(container, dbName, args);\r\n }\r\n\r\n /** Properties that specify how to access the account for a cloud blob-store container. */\r\n export interface AccountAccessProps {\r\n /** blob storage module: e.g. \"azure\", \"google\", \"aws\". May also include URI style parameters. */\r\n storageType: string;\r\n /** blob store account name, or a URI for custom domains. */\r\n accessName: string;\r\n }\r\n\r\n /** Properties of a CloudContainer. */\r\n export interface ContainerProps {\r\n /** the name of the container. */\r\n containerId: string;\r\n /** an alias for the container. Defaults to `containerId` */\r\n alias?: string;\r\n /** token that grants access to the container. For sas=1 `storageType`s, this is the sasToken. For sas=0, this is the account key */\r\n accessToken: string;\r\n /** if true, container is attached with write permissions, and accessToken must provide write access to the cloud container. */\r\n writeable?: boolean;\r\n /** if true, container is attached in \"secure\" mode (blocks are encrypted). Only supported in daemon mode. */\r\n secure?: boolean;\r\n }\r\n\r\n /** Returned from `CloudContainer.queryDatabase` describing one database in the container */\r\n export interface CachedDbProps {\r\n /** The total of (4Mb) blocks in the database. */\r\n readonly totalBlocks: number;\r\n /** the number of blocks of the database that have been downloaded into the CloudCache */\r\n readonly localBlocks: number;\r\n /** the number of blocks from this database that have been modified in the CloudCache and need to be uploaded. */\r\n readonly dirtyBlocks: number;\r\n /** If true, the database currently has transactions in the WAL file and may not be uploaded until they have been checkPointed. */\r\n readonly transactions: boolean;\r\n /** the state of this database. Indicates whether the database is new or deleted since last upload */\r\n readonly state: \"\" | \"copied\" | \"deleted\";\r\n }\r\n\r\n /** Properties for accessing a CloudContainer */\r\n export type ContainerAccessProps = AccountAccessProps & ContainerProps & {\r\n /** Duration for holding write lock, in seconds. After this time the write lock expires if not refreshed. Default is one hour. */\r\n durationSeconds?: number;\r\n };\r\n\r\n /** The name of a CloudSqlite database within a CloudContainer. */\r\n export interface DbNameProp {\r\n /** the name of the database within the CloudContainer.\r\n * @note names of databases within a CloudContainer are always **case sensitive** on all platforms.*/\r\n dbName: string;\r\n }\r\n\r\n /** Properties for accessing a database within a CloudContainer */\r\n export interface DbProps extends DbNameProp {\r\n /** the name of the local file to access the database. */\r\n localFileName: LocalFileName;\r\n }\r\n\r\n export type TransferDirection = \"upload\" | \"download\";\r\n export interface TransferProgress {\r\n /** a user-supplied progress function called during the transfer operation. Return a non-0 value to abort the transfer. */\r\n onProgress?: (loaded: number, total: number) => number;\r\n }\r\n\r\n export interface CloudHttpProps {\r\n /** The number of simultaneous HTTP requests. Default is 6. */\r\n nRequests?: number;\r\n }\r\n\r\n export interface PrefetchProps extends CloudHttpProps {\r\n /** timeout between requests, in milliseconds. Default is 100. */\r\n timeout?: number;\r\n /** The number of prefetch requests to issue while there is foreground activity. Default is 3. */\r\n minRequests?: number;\r\n }\r\n\r\n export type TransferDbProps = DbProps & TransferProgress & CloudHttpProps;\r\n\r\n /** Properties for creating a CloudCache. */\r\n export interface CacheProps extends CloudHttpProps {\r\n /** full path of directory for cache to store its files. Must be on a (preferably fast) local drive, and must be empty when the cache is first created. */\r\n rootDir: string;\r\n /** name of this cache. It is possible to have more than one CloudCache in the same session. */\r\n name: string;\r\n /** maximum cache Size. Must be a number followed by either M (for megabytes) or G (for gigabytes.) Default is 1G */\r\n cacheSize?: string;\r\n /** turn on diagnostics for `curl` (outputs to stderr) */\r\n curlDiagnostics?: boolean;\r\n }\r\n\r\n /** Parameters used to obtain the write lock on a cloud container\r\n * @internal\r\n */\r\n export interface ObtainLockParams {\r\n /** The name of the user attempting to acquire the write lock. This name will be shown to other users while the lock is held. */\r\n user?: string;\r\n /** number of times to retry in the event the lock currently held by someone else.\r\n * After this number of attempts, `onFailure` is called. Default is 20.\r\n */\r\n nRetries: number;\r\n /** Delay between retries, in milliseconds. Default is 100. */\r\n retryDelayMs: number;\r\n /** function called if lock cannot be obtained after all retries. It is called with the name of the user currently holding the lock and\r\n * generally is expected that the user will be consulted whether to wait further.\r\n * If this function returns \"stop\", an exception will be thrown. Otherwise the retry cycle is restarted.\r\n */\r\n onFailure?: WriteLockBusyHandler;\r\n }\r\n\r\n /** @internal */\r\n export interface LockAndOpenArgs {\r\n /** the name to be displayed in the event of lock collisions */\r\n user: string;\r\n /** the name of the database within the container */\r\n dbName: string;\r\n /** the CloudContainer on which the operation will be performed */\r\n container: CloudContainer;\r\n /** if present, function called when the write lock is currently held by another user. */\r\n busyHandler?: WriteLockBusyHandler;\r\n }\r\n\r\n /** Logging categories for `CloudCache.setLogMask` */\r\n export enum LoggingMask {\r\n /** log all HTTP requests and responses */\r\n HTTP = 0x01,\r\n /** log as blocks become dirty and must be uploaded */\r\n DirtyBlocks = 0x02,\r\n /** log as blocks are added to the delete list */\r\n AddToDelete = 0x04,\r\n /** log container lifecycle events (e.g. authorization requests, disconnects, and state transitions) */\r\n LifecycleEvents = 0x08,\r\n /** Turn on all logging categories */\r\n All = 0xff,\r\n /** Disable logging */\r\n None = 0,\r\n }\r\n\r\n /**\r\n * A cache for storing data from CloudSqlite databases. This object refers to a directory on a local filesystem\r\n * and is used to **connect** CloudContainers so they may be accessed. The contents of the cache directory are entirely\r\n * controlled by CloudSqlite and should be empty when the cache is first created and never modified directly. It maintains\r\n * the state of the local data across sessions.\r\n */\r\n export interface CloudCache {\r\n /** `true` if this CloudCache is connected to a daemon process */\r\n get isDaemon(): boolean;\r\n /** The name for this CloudCache. */\r\n get name(): string;\r\n /** The root directory of this CloudCache on a local drive. */\r\n get rootDir(): LocalDirName;\r\n /** The guid for this CloudCache. Used for acquiring write lock. */\r\n get guid(): GuidString;\r\n /** Configure logging for this CloudCache.\r\n * @param mask A bitmask of `LoggingMask` values\r\n * @note this method does nothing if [[isDaemon]] is true. Daemon logging is configured when the daemon is started.\r\n * @note HTTP logging can be happen on multiple threads and may be buffered. To see buffered log messages, periodically call\r\n * `IModelHost.flushLog`\r\n */\r\n setLogMask(mask: number): void;\r\n /** destroy this CloudCache. All CloudContainers should be detached before calling this. */\r\n destroy(): void;\r\n }\r\n\r\n /** A CloudSqlite container that may be connected to a CloudCache. */\r\n export interface CloudContainer {\r\n readonly cache?: CloudCache;\r\n /** The ContainerId. */\r\n get containerId(): string;\r\n /** The *alias* to identify this CloudContainer in a CloudCache. Usually just the ContainerId. */\r\n get alias(): string;\r\n /** true if this CloudContainer is currently connected to a CloudCache via the `connect` method. */\r\n get isConnected(): boolean;\r\n /** true if this CloudContainer was created with the `writeable` flag (and its `accessToken` supplies write access). */\r\n get isWriteable(): boolean;\r\n /** true if this CloudContainer currently holds the write lock for its container in the cloud. */\r\n get hasWriteLock(): boolean;\r\n /** true if this CloudContainer has local changes that have not be uploaded to its container in the cloud. */\r\n get hasLocalChanges(): boolean;\r\n /** The current accessToken providing access to the cloud container */\r\n get accessToken(): string;\r\n set accessToken(val: string);\r\n /** Get the number of garbage blocks in this container that can be purged. */\r\n get garbageBlocks(): number;\r\n /** The block size for this CloudContainer. */\r\n get blockSize(): number;\r\n\r\n /**\r\n * initialize a cloud blob-store container to be used as a new Sqlite CloudContainer. This creates the manifest, and should be\r\n * performed on an empty container. If an existing manifest is present, it is destroyed and a new one is created (essentially emptying the container.)\r\n */\r\n initializeContainer(opts?: { checksumBlockNames?: boolean, blockSize?: number }): void;\r\n\r\n /**\r\n * Attempt to acquire the write lock for this CloudContainer. For this to succeed:\r\n * 1. it must be connected to a `CloudCache`\r\n * 2. this CloudContainer must have been constructed with `writeable: true`\r\n * 3. the `accessToken` must authorize write access\r\n * 4. no other process may be holding an unexpired write lock\r\n * @throws exception if any of the above conditions fail\r\n * @note Write locks *expire* after the duration specified in the `durationSeconds` property of the constructor argument, in case a process\r\n * crashes or otherwise fails to release the lock. Calling `acquireWriteLock` with the lock already held resets the lock duration from the current time,\r\n * so long running processes should call this method periodically to ensure their lock doesn't expire (they should also make sure their accessToken is refreshed\r\n * before it expires.)\r\n * @note on success, the manifest is polled before the promise resolves.\r\n * @param user An identifier of the process/user locking the CloudContainer. In the event of a write lock\r\n * collision, this string will be included in the exception string of the *other* process attempting to obtain a write lock.\r\n */\r\n acquireWriteLock(user: string): void;\r\n\r\n /**\r\n * Release the write lock if it is currently held.\r\n * @note if there are local changes that have not been uploaded, they are automatically uploaded before the write lock is released.\r\n * @note if the write lock is not held, this method does nothing.\r\n */\r\n releaseWriteLock(): void;\r\n\r\n /**\r\n * Destroy any currently valid write lock from this or any other process. This is obviously very dangerous and defeats the purpose of write locking.\r\n * This method exists only for administrator tools to clear a failed process without waiting for the expiration period. It can also be useful for tests.\r\n * For this to succeed, all of the conditions of `acquireWriteLock` must be true other than #4.\r\n */\r\n clearWriteLock(): void;\r\n\r\n /**\r\n * Abandon any local changes in this container. If the write lock is currently held, it is released.\r\n * This function fails with BE_SQLITE_BUSY if one or more clients have open read or write transactions\r\n * on any database in the container.\r\n */\r\n abandonChanges(): void;\r\n\r\n /**\r\n * Connect this CloudContainer to a CloudCache for reading or writing its manifest, write lock, and databases.\r\n * @note A CloudCache is a local directory holding copies of information from the cloud. Its content is persistent across sessions,\r\n * but this method must be called each session to (re)establish the connection to the cache. If the CloudCache was previously populated,\r\n * this method may be called and will succeed *even when offline* or without a valid `accessToken`.\r\n * @note all operations that access the contents of databases or the manifest require this method be called (`isConnected === true`).\r\n */\r\n connect(cache: CloudCache): void;\r\n\r\n /**\r\n * Disconnect this CloudContainer from its CloudCache. There must be no open databases from this container. Leaves the container attached to the\r\n * CloudCache so it is available for future sessions.\r\n */\r\n disconnect(): void;\r\n\r\n /**\r\n * Permanently Detach and Disconnect this CloudContainer from its CloudCache. There must be no open databases from this container.\r\n */\r\n detach(): void;\r\n\r\n /**\r\n * Poll cloud storage for changes from other processes. *No changes* made by other processes are visible to\r\n * this CloudContainer unless/until this method is called.\r\n * @note this is automatically called whenever the write lock is obtained to ensure all changes are against the latest version.\r\n */\r\n checkForChanges(): void;\r\n\r\n /**\r\n * Upload any changed blocks from all databases in this CloudContainer.\r\n * @note this is called automatically from `releaseWriteLock` before the write lock is released. It is only necessary to call this directly if you\r\n * wish to upload changes while the write lock is still held.\r\n * @see hasLocalChanges\r\n */\r\n uploadChanges(): Promise<void>;\r\n\r\n /**\r\n * Clean any unused deleted blocks from cloud storage. When a database is written, a subset of its blocks are replaced\r\n * by new versions, sometimes leaving the originals unused. In this case, they are not deleted immediately.\r\n * Instead, they are scheduled for deletion at some later time. Calling this method deletes all blocks in the cloud container\r\n * for which the scheduled deletion time has passed.\r\n * @param nSeconds Any block that was marked as unused before this number of seconds ago will be deleted. Specifying a non-zero\r\n * value gives a period of time for other clients to refresh their manifests and stop using the now-garbage blocks. Otherwise they may get\r\n * a 404 error. Default is 1 hour.\r\n */\r\n cleanDeletedBlocks(nSeconds?: number): Promise<void>;\r\n\r\n /**\r\n * Create a copy of an existing database within this CloudContainer with a new name.\r\n * @note CloudSqlite uses copy-on-write semantics for this operation. That is, this method merely makes a\r\n * new entry in the manifest with the new name that *shares* all of its blocks with the original database.\r\n * If either database subsequently changes, the only modified blocks are not shared.\r\n */\r\n copyDatabase(dbName: string, toAlias: string): Promise<void>;\r\n\r\n /** Remove a database from this CloudContainer.\r\n * @see cleanDeletedBlocks\r\n */\r\n deleteDatabase(dbName: string): Promise<void>;\r\n\r\n /** Get the list of database names in this CloudContainer.\r\n * @param globArg if present, filter the results with SQLite [GLOB](https://www.sqlite.org/lang_expr.html#glob) operator.\r\n */\r\n queryDatabases(globArg?: string): string[];\r\n\r\n /**\r\n * Get the status of a specific database in this CloudContainer.\r\n * @param dbName the name of the database of interest\r\n */\r\n queryDatabase(dbName: string): CloudSqlite.CachedDbProps | undefined;\r\n\r\n /**\r\n * Get the SHA1 hash of the content of a database.\r\n * @param dbName the name of the database of interest\r\n * @note the hash will be empty if the database does not exist\r\n */\r\n queryDatabaseHash(dbName: string): string;\r\n }\r\n\r\n /** @internal */\r\n export interface CloudPrefetch {\r\n readonly cloudContainer: CloudContainer;\r\n readonly dbName: string;\r\n\r\n /** Cancel a currently pending prefetch. The promise will be resolved immediately after this call. */\r\n cancel(): void;\r\n\r\n /**\r\n * Promise that is resolved when the prefetch completes or is cancelled. Await this promise to ensure that the\r\n * database has been fully downloaded before going offline, for example.\r\n * @returns a Promise that resolves to `true` if the prefetch completed and the entire database is local, or `false` if it was aborted or failed.\r\n * @note the promise is *not* rejected on `cancel`. Some progress may (or may not) have been made by the request.\r\n * @note To monitor the progress being made during prefetch, call `CloudContainer.queryDatabase` periodically.\r\n */\r\n promise: Promise<boolean>;\r\n }\r\n\r\n /** @internal */\r\n export async function transferDb(direction: TransferDirection, container: CloudContainer, props: TransferDbProps) {\r\n if (direction === \"download\")\r\n mkdirSync(dirname(props.localFileName), { recursive: true }); // make sure the directory exists before starting download\r\n\r\n let timer: NodeJS.Timeout | undefined;\r\n try {\r\n const transfer = new NativeLibrary.nativeLib.CloudDbTransfer(direction, container, props);\r\n let total = 0;\r\n const onProgress = props.onProgress;\r\n if (onProgress) {\r\n timer = setInterval(async () => { // set an interval timer to show progress every 250ms\r\n const progress = transfer.getProgress();\r\n total = progress.total;\r\n if (onProgress(progress.loaded, progress.total))\r\n transfer.cancelTransfer();\r\n }, 250);\r\n }\r\n await transfer.promise;\r\n onProgress?.(total, total); // make sure we call progress func one last time when download completes\r\n } catch (err: any) {\r\n if (err.message === \"cancelled\")\r\n err.errorNumber = BriefcaseStatus.DownloadCancelled;\r\n\r\n throw err;\r\n } finally {\r\n if (timer)\r\n clearInterval(timer);\r\n }\r\n }\r\n\r\n /** Upload a database into a CloudContainer\r\n * @param container the CloudContainer holding the database. Must be connected.\r\n * @param props the properties that describe the database to be downloaded, plus optionally an `onProgress` function.\r\n * @note this function requires that the write lock be held on the container\r\n */\r\n export async function uploadDb(container: CloudContainer, props: TransferDbProps): Promise<void> {\r\n await transferDb(\"upload\", container, props);\r\n container.checkForChanges(); // re-read the manifest so the database is available locally.\r\n }\r\n\r\n /** Download a database from a CloudContainer\r\n * @param container the CloudContainer holding the database. Must be connected.\r\n * @param props the properties that describe the database to be downloaded, plus optionally an `onProgress` function.\r\n * @returns a Promise that is resolved when the download completes.\r\n * @note the download is \"restartable.\" If the transfer is aborted and then re-requested, it will continue from where\r\n * it left off rather than re-downloading the entire file.\r\n */\r\n export async function downloadDb(container: CloudContainer, props: TransferDbProps): Promise<void> {\r\n await transferDb(\"download\", container, props);\r\n }\r\n\r\n /** Optional method to be called when an attempt to acquire the write lock fails because another user currently holds it.\r\n * @param lockedBy The identifier supplied by the application/user that currently holds the lock.\r\n * @param expires a stringified Date (in local time) indicating when the lock will expire.\r\n * @return \"stop\" to give up and stop retrying. Generally, it's a good idea to wait for some time before returning.\r\n */\r\n export type WriteLockBusyHandler = (lockedBy: string, expires: string) => Promise<void | \"stop\">;\r\n\r\n /**\r\n * Attempt to acquire the write lock for a container, with retries.\r\n * If write lock is held by another user, call busyHandler if supplied. If no busyHandler, or handler returns \"stop\", throw. Otherwise try again.\r\n * @note if write lock is already held, this function does nothing.\r\n * @param user the name to be displayed to other users in the event they attempt to obtain the lock while it is held by us\r\n * @param container the CloudContainer for which the lock is to be acquired\r\n * @param busyHandler if present, function called when the write lock is currently held by another user.\r\n */\r\n export async function acquireWriteLock(user: string, container: CloudContainer, busyHandler?: WriteLockBusyHandler) {\r\n if (container.hasWriteLock)\r\n return;\r\n\r\n while (true) {\r\n try {\r\n return container.acquireWriteLock(user);\r\n } catch (e: any) {\r\n if (e.errorNumber === 5 && busyHandler && \"stop\" !== await busyHandler(e.lockedBy, e.expires)) // 5 === BE_SQLITE_BUSY\r\n continue; // busy handler wants to try again\r\n throw e;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Perform an asynchronous write operation on a CloudContainer with the write lock held.\r\n * 1. if write lock is already held, call operation and return.\r\n * 2. attempt to acquire the write lock, with retries. Throw if unable to obtain write lock.\r\n * 3. perform the operation\r\n * 3.a if the operation throws, abandon all changes and re-throw\r\n * 4. release the write lock.\r\n * 5. return value from operation\r\n * @param user the name to be displayed to other users in the event they attempt to obtain the lock while it is held by us\r\n * @param container the CloudContainer for which the lock is to be acquired\r\n * @param operation an asynchronous operation performed with the write lock held.\r\n * @param busyHandler if present, function called when the write lock is currently held by another user.\r\n * @returns a Promise with the result of `operation`\r\n */\r\n export async function withWriteLock<T>(user: string, container: CloudContainer, operation: () => T, busyHandler?: WriteLockBusyHandler) {\r\n if (container.hasWriteLock)\r\n return operation();\r\n\r\n await acquireWriteLock(user, container, busyHandler);\r\n try {\r\n // eslint-disable-next-line @typescript-eslint/await-thenable\r\n const val = await operation(); // wait for work to finish or fail\r\n container.releaseWriteLock();\r\n return val;\r\n } catch (e) {\r\n container.abandonChanges(); // if operation threw, abandon all changes\r\n throw e;\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -9,7 +9,7 @@ export interface AzureBlobStorageCredentials {
|
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* @beta
|
|
12
|
-
* @deprecated
|
|
12
|
+
* @deprecated in 3.x.
|
|
13
13
|
*/
|
|
14
14
|
export interface CloudStorageUploadOptions {
|
|
15
15
|
type?: string;
|
|
@@ -18,7 +18,7 @@ export interface CloudStorageUploadOptions {
|
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* @beta
|
|
21
|
-
* @deprecated
|
|
21
|
+
* @deprecated in 3.x.
|
|
22
22
|
*/
|
|
23
23
|
export declare abstract class CloudStorageService {
|
|
24
24
|
initialize(): void;
|
|
@@ -34,7 +34,7 @@ export declare abstract class CloudStorageService {
|
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* @beta
|
|
37
|
-
* @deprecated
|
|
37
|
+
* @deprecated in 3.x.
|
|
38
38
|
*/
|
|
39
39
|
export declare class AzureBlobStorage extends CloudStorageService {
|
|
40
40
|
private _service;
|
|
@@ -48,7 +48,7 @@ export declare class AzureBlobStorage extends CloudStorageService {
|
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* @beta
|
|
51
|
-
* @deprecated
|
|
51
|
+
* @deprecated in 3.x.
|
|
52
52
|
*/
|
|
53
53
|
export declare class CloudStorageTileUploader {
|
|
54
54
|
private _activeUploads;
|
|
@@ -14,7 +14,7 @@ const BackendLoggerCategory_1 = require("./BackendLoggerCategory");
|
|
|
14
14
|
const IModelHost_1 = require("./IModelHost");
|
|
15
15
|
/**
|
|
16
16
|
* @beta
|
|
17
|
-
* @deprecated
|
|
17
|
+
* @deprecated in 3.x.
|
|
18
18
|
*/
|
|
19
19
|
class CloudStorageService {
|
|
20
20
|
initialize() { }
|
|
@@ -27,7 +27,7 @@ class CloudStorageService {
|
|
|
27
27
|
exports.CloudStorageService = CloudStorageService;
|
|
28
28
|
/**
|
|
29
29
|
* @beta
|
|
30
|
-
* @deprecated
|
|
30
|
+
* @deprecated in 3.x.
|
|
31
31
|
*/
|
|
32
32
|
class AzureBlobStorage extends CloudStorageService {
|
|
33
33
|
constructor(credentials) {
|
|
@@ -130,7 +130,7 @@ class AzureBlobStorage extends CloudStorageService {
|
|
|
130
130
|
exports.AzureBlobStorage = AzureBlobStorage;
|
|
131
131
|
/**
|
|
132
132
|
* @beta
|
|
133
|
-
* @deprecated
|
|
133
|
+
* @deprecated in 3.x.
|
|
134
134
|
*/
|
|
135
135
|
class CloudStorageTileUploader {
|
|
136
136
|
constructor() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudStorageBackend.js","sourceRoot":"","sources":["../../src/CloudStorageBackend.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,mCAA+C;AAC/C,6BAA6B;AAC7B,6CAA6C;AAC7C,sDAAyD;AACzD,oDAG4B;AAC5B,mEAAgE;AAChE,6CAA0C;AAqB1C;;;GAGG;AACH,MAAsB,mBAAmB;IAChC,UAAU,KAAW,CAAC;IACtB,SAAS,KAAW,CAAC;IAIrB,KAAK,CAAC,QAAQ,CAAC,KAAa,IAAmC,OAAO,SAAS,CAAC,CAAC,CAAC;IAE/E,cAAc,CAAC,EAAmC;QAC1D,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;IAC9C,CAAC;CACF;AAXD,kDAWC;AAED;;;GAGG;AACH,MAAa,gBAAiB,SAAQ,mBAAmB;IAKvD,YAAmB,WAAwC;;QACzD,KAAK,EAAE,CAAC;QAcM,OAAE,GAAG,kCAAoB,CAAC,KAAK,CAAC;QAZ9C,IAAI,CAAC,WAAW,CAAC,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE;YAClD,MAAM,IAAI,yBAAW,CAAC,2BAAa,CAAC,KAA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C,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;SACxH;QAED,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,YAAY,GAAG,WAAW,CAAC,CAAC;IACzD,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,UAA0B,EAAE,MAAc,EAAE,SAAiB,EAAE,OAAmB,EAAE,IAAwB,EAAE,QAAiB;QACpJ,MAAM,EAAE,GAA0B,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QAE1E,MAAM,KAAK,GAAG,mCAAqB,CAAC,QAAQ,EAAE,CAAC;QAC/C,MAAM,YAAY,GAAG,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;QACjD,MAAM,WAAW,GAAG,KAAK,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;QAC/C,MAAM,GAAG,GAAG,YAAY,GAAG,WAAW,CAAC;QAEvC,IAAI,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC;YAC9B,OAAO;QAET,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;QACrF,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACtC,MAAM,OAAO,CAAC;IAChB,CAAC;CACF;AA1CD,4DA0CC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { PassThrough, Readable } from \"stream\";\r\nimport * as zlib from \"zlib\";\r\nimport * as Azure from \"@azure/storage-blob\";\r\nimport { Logger, PerfLogger } from \"@itwin/core-bentley\";\r\nimport {\r\n BentleyStatus, CloudStorageContainerDescriptor, CloudStorageContainerUrl, CloudStorageProvider, CloudStorageTileCache, IModelError, IModelRpcProps,\r\n TileContentIdentifier,\r\n} from \"@itwin/core-common\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { IModelHost } from \"./IModelHost\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** @beta */\r\nexport interface AzureBlobStorageCredentials {\r\n account: string;\r\n accessKey: string;\r\n baseUrl?: string;\r\n}\r\n\r\n/**\r\n * @beta\r\n * @deprecated\r\n */\r\nexport interface CloudStorageUploadOptions {\r\n type?: string;\r\n cacheControl?: string;\r\n contentEncoding?: \"gzip\";\r\n}\r\n\r\n/**\r\n * @beta\r\n * @deprecated\r\n */\r\nexport abstract class CloudStorageService {\r\n public initialize(): void { }\r\n public terminate(): void { }\r\n public abstract id: CloudStorageProvider;\r\n public abstract obtainContainerUrl(id: CloudStorageContainerDescriptor, expiry: Date, clientIp?: string): CloudStorageContainerUrl;\r\n public abstract upload(container: string, name: string, data: Uint8Array, options?: CloudStorageUploadOptions, metadata?: object): Promise<string>;\r\n public async download(_name: string): Promise<Readable | undefined> { return undefined; }\r\n\r\n protected makeDescriptor(id: CloudStorageContainerDescriptor) {\r\n return { name: id.name, provider: this.id };\r\n }\r\n}\r\n\r\n/**\r\n * @beta\r\n * @deprecated\r\n */\r\nexport class AzureBlobStorage extends CloudStorageService {\r\n private _service: Azure.BlobServiceClient;\r\n private _credential: Azure.StorageSharedKeyCredential;\r\n private _baseUrl: string;\r\n\r\n public constructor(credentials: AzureBlobStorageCredentials) {\r\n super();\r\n\r\n if (!credentials.account || !credentials.accessKey) {\r\n throw new IModelError(BentleyStatus.ERROR, \"Invalid credentials for Azure blob storage.\");\r\n }\r\n\r\n this._baseUrl = credentials.baseUrl ?? `https://${credentials.account}.blob.core.windows.net`;\r\n\r\n this._credential = new Azure.StorageSharedKeyCredential(credentials.account, credentials.accessKey);\r\n const options: Azure.StoragePipelineOptions = {};\r\n const pipeline = Azure.newPipeline(this._credential, options);\r\n this._service = new Azure.BlobServiceClient(this._baseUrl, pipeline);\r\n }\r\n\r\n public readonly id = CloudStorageProvider.Azure;\r\n\r\n public obtainContainerUrl(id: CloudStorageContainerDescriptor, expiry: Date, clientIp?: string): CloudStorageContainerUrl {\r\n const policy: Azure.BlobSASSignatureValues = {\r\n containerName: id.name,\r\n permissions: Azure.ContainerSASPermissions.parse(\"rl\"),\r\n expiresOn: expiry,\r\n };\r\n\r\n if (clientIp && clientIp !== \"localhost\" && clientIp !== \"127.0.0.1\" && clientIp !== \"::1\") {\r\n policy.ipRange = { start: clientIp };\r\n }\r\n\r\n const token = Azure.generateBlobSASQueryParameters(policy, this._credential);\r\n const url = new URL(this._baseUrl);\r\n url.pathname = `${url.pathname.replace(/\\/*$/, \"\")}/${id.name}`;\r\n url.search = token.toString();\r\n\r\n const urlObject: CloudStorageContainerUrl = {\r\n descriptor: this.makeDescriptor(id),\r\n valid: 0,\r\n expires: expiry.getTime(),\r\n url: url.toString(),\r\n };\r\n\r\n return urlObject;\r\n }\r\n\r\n public async ensureContainer(name: string): Promise<void> {\r\n try {\r\n const container = this._service.getContainerClient(name);\r\n await container.create();\r\n return;\r\n } catch (maybeErr) {\r\n try {\r\n const err = maybeErr as Azure.RestError;\r\n if (err.statusCode === 409 && err.code === \"ContainerAlreadyExists\") {\r\n return;\r\n }\r\n } catch { }\r\n\r\n if (typeof (maybeErr) !== \"undefined\" && maybeErr) {\r\n throw maybeErr;\r\n }\r\n\r\n throw new IModelError(BentleyStatus.ERROR, `Unable to create container \"${name}\".`);\r\n }\r\n }\r\n\r\n public async upload(container: string, name: string, data: Uint8Array, options?: CloudStorageUploadOptions, metadata?: object): Promise<string> {\r\n try {\r\n await this.ensureContainer(container);\r\n\r\n const containerClient = this._service.getContainerClient(container);\r\n const blocks = containerClient.getBlockBlobClient(name);\r\n const blobHTTPHeaders = {\r\n blobContentType: options?.type ?? \"application/octet-stream\",\r\n blobCacheControl: options?.cacheControl ?? \"private, max-age=31536000, immutable\",\r\n };\r\n\r\n const blobOptions: Azure.BlockBlobUploadStreamOptions = metadata ?\r\n {\r\n blobHTTPHeaders,\r\n metadata: { ...metadata },\r\n } : {\r\n blobHTTPHeaders,\r\n };\r\n\r\n const dataStream = new PassThrough();\r\n dataStream.end(data);\r\n\r\n let source: Readable;\r\n\r\n if (options && options.contentEncoding === \"gzip\") {\r\n if (undefined === blobOptions.blobHTTPHeaders)\r\n throw new IModelError(BentleyStatus.ERROR, \"Blob HTTP headers object is undefined.\");\r\n\r\n blobOptions.blobHTTPHeaders.blobContentEncoding = options.contentEncoding;\r\n const compressor = zlib.createGzip();\r\n source = dataStream.pipe(compressor);\r\n } else {\r\n source = dataStream;\r\n }\r\n\r\n const blockSize = 100 * 1024 * 1024;\r\n const concurrency = 1;\r\n const result = await blocks.uploadStream(source, blockSize, concurrency, blobOptions);\r\n return result.etag ?? \"\";\r\n } catch (maybeErr) {\r\n if (typeof (maybeErr) !== \"undefined\" && maybeErr) {\r\n throw maybeErr;\r\n }\r\n\r\n throw new IModelError(BentleyStatus.ERROR, `Unable to upload \"${name}\".`);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * @beta\r\n * @deprecated\r\n */\r\nexport class CloudStorageTileUploader {\r\n private _activeUploads: Map<string, Promise<void>> = new Map();\r\n\r\n public get activeUploads(): Iterable<Promise<void>> {\r\n return this._activeUploads.values();\r\n }\r\n\r\n private async uploadToCache(id: TileContentIdentifier, content: Uint8Array, containerKey: string, resourceKey: string, metadata?: object,) {\r\n await new Promise((resolve) => setTimeout(resolve));\r\n\r\n try {\r\n const options: CloudStorageUploadOptions = {};\r\n if (IModelHost.compressCachedTiles) {\r\n options.contentEncoding = \"gzip\";\r\n }\r\n\r\n const perfInfo = { ...id.tokenProps, treeId: id.treeId, contentId: id.contentId, size: content.byteLength, compress: IModelHost.compressCachedTiles };\r\n const perfLogger = new PerfLogger(\"Uploading tile to external tile cache\", () => perfInfo);\r\n await IModelHost.tileCacheService?.upload(containerKey, resourceKey, content, options, metadata);\r\n perfLogger.dispose();\r\n } catch (err) {\r\n Logger.logError(BackendLoggerCategory.IModelTileUpload, (err instanceof Error) ? err.toString() : JSON.stringify(err));\r\n }\r\n\r\n this._activeUploads.delete(containerKey + resourceKey);\r\n }\r\n\r\n public async cacheTile(tokenProps: IModelRpcProps, treeId: string, contentId: string, content: Uint8Array, guid: string | undefined, metadata?: object): Promise<void> {\r\n const id: TileContentIdentifier = { tokenProps, treeId, contentId, guid };\r\n\r\n const cache = CloudStorageTileCache.getCache();\r\n const containerKey = cache.formContainerName(id);\r\n const resourceKey = cache.formResourceName(id);\r\n const key = containerKey + resourceKey;\r\n\r\n if (this._activeUploads.has(key))\r\n return;\r\n\r\n const promise = this.uploadToCache(id, content, containerKey, resourceKey, metadata);\r\n this._activeUploads.set(key, promise);\r\n await promise;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"CloudStorageBackend.js","sourceRoot":"","sources":["../../src/CloudStorageBackend.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,mCAA+C;AAC/C,6BAA6B;AAC7B,6CAA6C;AAC7C,sDAAyD;AACzD,oDAG4B;AAC5B,mEAAgE;AAChE,6CAA0C;AAqB1C;;;GAGG;AACH,MAAsB,mBAAmB;IAChC,UAAU,KAAW,CAAC;IACtB,SAAS,KAAW,CAAC;IAIrB,KAAK,CAAC,QAAQ,CAAC,KAAa,IAAmC,OAAO,SAAS,CAAC,CAAC,CAAC;IAE/E,cAAc,CAAC,EAAmC;QAC1D,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;IAC9C,CAAC;CACF;AAXD,kDAWC;AAED;;;GAGG;AACH,MAAa,gBAAiB,SAAQ,mBAAmB;IAKvD,YAAmB,WAAwC;;QACzD,KAAK,EAAE,CAAC;QAcM,OAAE,GAAG,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CAAC,CAAA,CAAC;YACjG,UAAU,CAAC,OAAO,EAAE,CAAC;SACtB;QAAC,OAAO,GAAG,EAAE;YACZ,qBAAM,CAAC,QAAQ,CAAC,6CAAqB,CAAC,gBAAgB,EAAE,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;SACxH;QAED,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,YAAY,GAAG,WAAW,CAAC,CAAC;IACzD,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,UAA0B,EAAE,MAAc,EAAE,SAAiB,EAAE,OAAmB,EAAE,IAAwB,EAAE,QAAiB;QACpJ,MAAM,EAAE,GAA0B,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QAE1E,MAAM,KAAK,GAAG,mCAAqB,CAAC,QAAQ,EAAE,CAAC;QAC/C,MAAM,YAAY,GAAG,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;QACjD,MAAM,WAAW,GAAG,KAAK,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;QAC/C,MAAM,GAAG,GAAG,YAAY,GAAG,WAAW,CAAC;QAEvC,IAAI,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC;YAC9B,OAAO;QAET,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;QACrF,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACtC,MAAM,OAAO,CAAC;IAChB,CAAC;CACF;AA1CD,4DA0CC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { PassThrough, Readable } from \"stream\";\r\nimport * as zlib from \"zlib\";\r\nimport * as Azure from \"@azure/storage-blob\";\r\nimport { Logger, PerfLogger } from \"@itwin/core-bentley\";\r\nimport {\r\n BentleyStatus, CloudStorageContainerDescriptor, CloudStorageContainerUrl, CloudStorageProvider, CloudStorageTileCache, IModelError, IModelRpcProps,\r\n TileContentIdentifier,\r\n} from \"@itwin/core-common\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { IModelHost } from \"./IModelHost\";\r\n\r\n/* eslint-disable deprecation/deprecation */\r\n\r\n/** @beta */\r\nexport interface AzureBlobStorageCredentials {\r\n account: string;\r\n accessKey: string;\r\n baseUrl?: string;\r\n}\r\n\r\n/**\r\n * @beta\r\n * @deprecated in 3.x.\r\n */\r\nexport interface CloudStorageUploadOptions {\r\n type?: string;\r\n cacheControl?: string;\r\n contentEncoding?: \"gzip\";\r\n}\r\n\r\n/**\r\n * @beta\r\n * @deprecated in 3.x.\r\n */\r\nexport abstract class CloudStorageService {\r\n public initialize(): void { }\r\n public terminate(): void { }\r\n public abstract id: CloudStorageProvider;\r\n public abstract obtainContainerUrl(id: CloudStorageContainerDescriptor, expiry: Date, clientIp?: string): CloudStorageContainerUrl;\r\n public abstract upload(container: string, name: string, data: Uint8Array, options?: CloudStorageUploadOptions, metadata?: object): Promise<string>;\r\n public async download(_name: string): Promise<Readable | undefined> { return undefined; }\r\n\r\n protected makeDescriptor(id: CloudStorageContainerDescriptor) {\r\n return { name: id.name, provider: this.id };\r\n }\r\n}\r\n\r\n/**\r\n * @beta\r\n * @deprecated in 3.x.\r\n */\r\nexport class AzureBlobStorage extends CloudStorageService {\r\n private _service: Azure.BlobServiceClient;\r\n private _credential: Azure.StorageSharedKeyCredential;\r\n private _baseUrl: string;\r\n\r\n public constructor(credentials: AzureBlobStorageCredentials) {\r\n super();\r\n\r\n if (!credentials.account || !credentials.accessKey) {\r\n throw new IModelError(BentleyStatus.ERROR, \"Invalid credentials for Azure blob storage.\");\r\n }\r\n\r\n this._baseUrl = credentials.baseUrl ?? `https://${credentials.account}.blob.core.windows.net`;\r\n\r\n this._credential = new Azure.StorageSharedKeyCredential(credentials.account, credentials.accessKey);\r\n const options: Azure.StoragePipelineOptions = {};\r\n const pipeline = Azure.newPipeline(this._credential, options);\r\n this._service = new Azure.BlobServiceClient(this._baseUrl, pipeline);\r\n }\r\n\r\n public readonly id = CloudStorageProvider.Azure;\r\n\r\n public obtainContainerUrl(id: CloudStorageContainerDescriptor, expiry: Date, clientIp?: string): CloudStorageContainerUrl {\r\n const policy: Azure.BlobSASSignatureValues = {\r\n containerName: id.name,\r\n permissions: Azure.ContainerSASPermissions.parse(\"rl\"),\r\n expiresOn: expiry,\r\n };\r\n\r\n if (clientIp && clientIp !== \"localhost\" && clientIp !== \"127.0.0.1\" && clientIp !== \"::1\") {\r\n policy.ipRange = { start: clientIp };\r\n }\r\n\r\n const token = Azure.generateBlobSASQueryParameters(policy, this._credential);\r\n const url = new URL(this._baseUrl);\r\n url.pathname = `${url.pathname.replace(/\\/*$/, \"\")}/${id.name}`;\r\n url.search = token.toString();\r\n\r\n const urlObject: CloudStorageContainerUrl = {\r\n descriptor: this.makeDescriptor(id),\r\n valid: 0,\r\n expires: expiry.getTime(),\r\n url: url.toString(),\r\n };\r\n\r\n return urlObject;\r\n }\r\n\r\n public async ensureContainer(name: string): Promise<void> {\r\n try {\r\n const container = this._service.getContainerClient(name);\r\n await container.create();\r\n return;\r\n } catch (maybeErr) {\r\n try {\r\n const err = maybeErr as Azure.RestError;\r\n if (err.statusCode === 409 && err.code === \"ContainerAlreadyExists\") {\r\n return;\r\n }\r\n } catch { }\r\n\r\n if (typeof (maybeErr) !== \"undefined\" && maybeErr) {\r\n throw maybeErr;\r\n }\r\n\r\n throw new IModelError(BentleyStatus.ERROR, `Unable to create container \"${name}\".`);\r\n }\r\n }\r\n\r\n public async upload(container: string, name: string, data: Uint8Array, options?: CloudStorageUploadOptions, metadata?: object): Promise<string> {\r\n try {\r\n await this.ensureContainer(container);\r\n\r\n const containerClient = this._service.getContainerClient(container);\r\n const blocks = containerClient.getBlockBlobClient(name);\r\n const blobHTTPHeaders = {\r\n blobContentType: options?.type ?? \"application/octet-stream\",\r\n blobCacheControl: options?.cacheControl ?? \"private, max-age=31536000, immutable\",\r\n };\r\n\r\n const blobOptions: Azure.BlockBlobUploadStreamOptions = metadata ?\r\n {\r\n blobHTTPHeaders,\r\n metadata: { ...metadata },\r\n } : {\r\n blobHTTPHeaders,\r\n };\r\n\r\n const dataStream = new PassThrough();\r\n dataStream.end(data);\r\n\r\n let source: Readable;\r\n\r\n if (options && options.contentEncoding === \"gzip\") {\r\n if (undefined === blobOptions.blobHTTPHeaders)\r\n throw new IModelError(BentleyStatus.ERROR, \"Blob HTTP headers object is undefined.\");\r\n\r\n blobOptions.blobHTTPHeaders.blobContentEncoding = options.contentEncoding;\r\n const compressor = zlib.createGzip();\r\n source = dataStream.pipe(compressor);\r\n } else {\r\n source = dataStream;\r\n }\r\n\r\n const blockSize = 100 * 1024 * 1024;\r\n const concurrency = 1;\r\n const result = await blocks.uploadStream(source, blockSize, concurrency, blobOptions);\r\n return result.etag ?? \"\";\r\n } catch (maybeErr) {\r\n if (typeof (maybeErr) !== \"undefined\" && maybeErr) {\r\n throw maybeErr;\r\n }\r\n\r\n throw new IModelError(BentleyStatus.ERROR, `Unable to upload \"${name}\".`);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * @beta\r\n * @deprecated in 3.x.\r\n */\r\nexport class CloudStorageTileUploader {\r\n private _activeUploads: Map<string, Promise<void>> = new Map();\r\n\r\n public get activeUploads(): Iterable<Promise<void>> {\r\n return this._activeUploads.values();\r\n }\r\n\r\n private async uploadToCache(id: TileContentIdentifier, content: Uint8Array, containerKey: string, resourceKey: string, metadata?: object,) {\r\n await new Promise((resolve) => setTimeout(resolve));\r\n\r\n try {\r\n const options: CloudStorageUploadOptions = {};\r\n if (IModelHost.compressCachedTiles) {\r\n options.contentEncoding = \"gzip\";\r\n }\r\n\r\n const perfInfo = { ...id.tokenProps, treeId: id.treeId, contentId: id.contentId, size: content.byteLength, compress: IModelHost.compressCachedTiles };\r\n const perfLogger = new PerfLogger(\"Uploading tile to external tile cache\", () => perfInfo);\r\n await IModelHost.tileCacheService?.upload(containerKey, resourceKey, content, options, metadata);\r\n perfLogger.dispose();\r\n } catch (err) {\r\n Logger.logError(BackendLoggerCategory.IModelTileUpload, (err instanceof Error) ? err.toString() : JSON.stringify(err));\r\n }\r\n\r\n this._activeUploads.delete(containerKey + resourceKey);\r\n }\r\n\r\n public async cacheTile(tokenProps: IModelRpcProps, treeId: string, contentId: string, content: Uint8Array, guid: string | undefined, metadata?: object): Promise<void> {\r\n const id: TileContentIdentifier = { tokenProps, treeId, contentId, guid };\r\n\r\n const cache = CloudStorageTileCache.getCache();\r\n const containerKey = cache.formContainerName(id);\r\n const resourceKey = cache.formResourceName(id);\r\n const key = containerKey + resourceKey;\r\n\r\n if (this._activeUploads.has(key))\r\n return;\r\n\r\n const promise = this.uploadToCache(id, content, containerKey, resourceKey, metadata);\r\n this._activeUploads.set(key, promise);\r\n await promise;\r\n }\r\n}\r\n"]}
|
package/lib/cjs/CodeSpecs.d.ts
CHANGED
|
@@ -43,6 +43,11 @@ export declare class CodeSpecs {
|
|
|
43
43
|
* @throws IModelError if the insertion fails
|
|
44
44
|
*/
|
|
45
45
|
insert(name: string, scopeType: CodeScopeSpec.Type): Id64String;
|
|
46
|
+
/** Update the Json properties of an existing CodeSpec.
|
|
47
|
+
* @param codeSpec The codeSpec holding Json properties values to update
|
|
48
|
+
* @throws if unable to update the codeSpec.
|
|
49
|
+
*/
|
|
50
|
+
updateProperties(codeSpec: CodeSpec): void;
|
|
46
51
|
/** Load a CodeSpec from the iModel
|
|
47
52
|
* @param id The persistent Id of the CodeSpec to load
|
|
48
53
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"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;IACpB,OAAO,CAAC,OAAO,CAAW;IAC1B,OAAO,CAAC,gBAAgB,CAAkB;gBAE9B,MAAM,EAAE,QAAQ;IAO5B,8DAA8D;IACvD,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU;IASxC;;;;OAIG;IACI,OAAO,CAAC,UAAU,EAAE,UAAU,GAAG,QAAQ;IAehD,uEAAuE;IAChE,KAAK,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO;IAQ7C;;;;OAIG;IACI,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ;IAWxC,yEAAyE;IAClE,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAQrC;;;;;OAKG;IACI,MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,UAAU;IAC7C;;;;;OAKG;IACI,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,CAAC,IAAI,GAAG,UAAU;IAgBtE;;;KAGC;IACM,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IASjD;;OAEG;IACI,IAAI,CAAC,EAAE,EAAE,UAAU,GAAG,QAAQ;CAatC"}
|
package/lib/cjs/CodeSpecs.js
CHANGED
|
@@ -94,6 +94,18 @@ class CodeSpecs {
|
|
|
94
94
|
}
|
|
95
95
|
throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadArg, "Invalid argument");
|
|
96
96
|
}
|
|
97
|
+
/** Update the Json properties of an existing CodeSpec.
|
|
98
|
+
* @param codeSpec The codeSpec holding Json properties values to update
|
|
99
|
+
* @throws if unable to update the codeSpec.
|
|
100
|
+
*/
|
|
101
|
+
updateProperties(codeSpec) {
|
|
102
|
+
this._imodel.withPreparedSqliteStatement("UPDATE bis_CodeSpec SET JsonProperties=? WHERE Id=?", (stmt) => {
|
|
103
|
+
stmt.bindString(1, JSON.stringify(codeSpec.properties));
|
|
104
|
+
stmt.bindId(2, codeSpec.id);
|
|
105
|
+
if (core_bentley_1.DbResult.BE_SQLITE_DONE !== stmt.step())
|
|
106
|
+
throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadArg, "error updating CodeSpec properties");
|
|
107
|
+
});
|
|
108
|
+
}
|
|
97
109
|
/** Load a CodeSpec from the iModel
|
|
98
110
|
* @param id The persistent Id of the CodeSpec to load
|
|
99
111
|
*/
|
package/lib/cjs/CodeSpecs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeSpecs.js","sourceRoot":"","sources":["../../src/CodeSpecs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA+E;AAC/E,oDAA0E;AAI1E;;GAEG;AACH,MAAa,SAAS;IAIpB,YAAY,MAAgB;QAFpB,qBAAgB,GAAe,EAAE,CAAC;QAGxC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,MAAM,CAAC,aAAa,EAAE,EAAE;YAC1B,MAAM,CAAC,kBAAkB,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;SAC/E;IACH,CAAC;IAED,8DAA8D;IACvD,OAAO,CAAC,IAAY;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,4DAA4D,EAAE,CAAC,IAAoB,EAAE,EAAE;YAC/H,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAC9B,IAAI,uBAAQ,CAAC,aAAa,KAAK,IAAI,CAAC,IAAI,EAAE;gBACxC,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,QAAQ,EAAE,oBAAoB,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;YACvF,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IAC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C,SAAS,EAAE,oBAAoB,CAAC,CAAC;YAEtE,MAAM,GAAG,GAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;YAC/B,OAAO,sBAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC;QAC7F,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAxHD,8BAwHC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Codes\r\n */\r\n\r\nimport { DbResult, Id64, Id64String, IModelStatus } from \"@itwin/core-bentley\";\r\nimport { CodeScopeSpec, CodeSpec, IModelError } from \"@itwin/core-common\";\r\nimport { ECSqlStatement } from \"./ECSqlStatement\";\r\nimport { IModelDb } from \"./IModelDb\";\r\n\r\n/** Manages [CodeSpecs]($docs/BIS/guide/fundamentals/element-fundamentals.md#codespec) within an [[IModelDb]]\r\n * @public\r\n */\r\nexport class CodeSpecs {\r\n private _imodel: IModelDb;\r\n private _loadedCodeSpecs: CodeSpec[] = [];\r\n\r\n constructor(imodel: IModelDb) {\r\n this._imodel = imodel;\r\n if (imodel.isBriefcaseDb()) {\r\n imodel.onChangesetApplied.addListener(() => this._loadedCodeSpecs.length = 0);\r\n }\r\n }\r\n\r\n /** Look up the Id of the CodeSpec with the specified name. */\r\n public queryId(name: string): Id64String {\r\n return this._imodel.withPreparedStatement(\"SELECT ECInstanceId FROM BisCore.CodeSpec WHERE Name=:name\", (stmt: ECSqlStatement) => {\r\n stmt.bindString(\"name\", name);\r\n if (DbResult.BE_SQLITE_ROW !== stmt.step())\r\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\", () => ({ name }));\r\n return stmt.getValue(0).getId();\r\n });\r\n }\r\n\r\n /** Look up a CodeSpec by Id. The CodeSpec will be loaded from the database if necessary.\r\n * @param codeSpecId The Id of the CodeSpec to load\r\n * @returns The CodeSpec with the specified Id\r\n * @throws [[IModelError]] if the Id is invalid or if no CodeSpec with that Id could be found.\r\n */\r\n public getById(codeSpecId: Id64String): CodeSpec {\r\n if (Id64.isInvalid(codeSpecId))\r\n throw new IModelError(IModelStatus.InvalidId, \"Invalid codeSpecId\");\r\n\r\n // good chance it is already loaded - check there before running a query\r\n const found = this._loadedCodeSpecs.find((codeSpec) => codeSpec.id === codeSpecId);\r\n if (found !== undefined)\r\n return found;\r\n\r\n // must load this codespec\r\n const loadedCodeSpec = this.load(codeSpecId);\r\n this._loadedCodeSpecs.push(loadedCodeSpec);\r\n return loadedCodeSpec;\r\n }\r\n\r\n /** Returns true if the IModelDb has a CodeSpec of the specified Id. */\r\n public hasId(codeSpecId: Id64String): boolean {\r\n try {\r\n return undefined !== this.getById(codeSpecId);\r\n } catch (error) {\r\n return false;\r\n }\r\n }\r\n\r\n /** Look up a CodeSpec by name. The CodeSpec will be loaded from the database if necessary.\r\n * @param name The name of the CodeSpec to load\r\n * @returns The CodeSpec with the specified name\r\n * @throws [[IModelError]] if no CodeSpec with the specified name could be found.\r\n */\r\n public getByName(name: string): CodeSpec {\r\n // good chance it is already loaded - check there before running a query\r\n const found: CodeSpec | undefined = this._loadedCodeSpecs.find((codeSpec) => codeSpec.name === name);\r\n if (found !== undefined)\r\n return found;\r\n const codeSpecId = this.queryId(name);\r\n if (codeSpecId === undefined)\r\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\", () => ({ name }));\r\n return this.getById(codeSpecId);\r\n }\r\n\r\n /** Returns true if the IModelDb has a CodeSpec of the specified name. */\r\n public hasName(name: string): boolean {\r\n try {\r\n return undefined !== this.getByName(name);\r\n } catch (error) {\r\n return false;\r\n }\r\n }\r\n\r\n /** Add a new CodeSpec to the iModel.\r\n * @param codeSpec The CodeSpec to insert\r\n * @returns The Id of the persistent CodeSpec.\r\n * @note If successful, this method will assign a valid CodeSpecId to the supplied CodeSpec\r\n * @throws IModelError if the insertion fails\r\n */\r\n public insert(codeSpec: CodeSpec): Id64String;\r\n /** Add a new CodeSpec to the IModelDb.\r\n * @param name The name for the new CodeSpec.\r\n * @param scopeType The scope type\r\n * @returns The Id of the persistent CodeSpec.\r\n * @throws IModelError if the insertion fails\r\n */\r\n public insert(name: string, scopeType: CodeScopeSpec.Type): Id64String;\r\n public insert(codeSpecOrName: CodeSpec | string, scopeType?: CodeScopeSpec.Type): Id64String {\r\n if (codeSpecOrName instanceof CodeSpec) {\r\n const codeSpec = codeSpecOrName;\r\n const id: Id64String = this._imodel.insertCodeSpec(codeSpec);\r\n codeSpec.id = id;\r\n return id;\r\n }\r\n if (typeof codeSpecOrName === \"string\") {\r\n const name = codeSpecOrName;\r\n if (scopeType)\r\n return this._imodel.insertCodeSpec(CodeSpec.create(this._imodel, name, scopeType));\r\n }\r\n throw new IModelError(IModelStatus.BadArg, \"Invalid argument\");\r\n }\r\n\r\n /** Load a CodeSpec from the iModel\r\n * @param id The persistent Id of the CodeSpec to load\r\n */\r\n public load(id: Id64String): CodeSpec {\r\n if (Id64.isInvalid(id))\r\n throw new IModelError(IModelStatus.InvalidId, \"Invalid codeSpecId\");\r\n\r\n return this._imodel.withPreparedStatement(\"SELECT name,jsonProperties FROM BisCore.CodeSpec WHERE ECInstanceId=?\", (stmt: ECSqlStatement) => {\r\n stmt.bindId(1, id);\r\n if (DbResult.BE_SQLITE_ROW !== stmt.step())\r\n throw new IModelError(IModelStatus.InvalidId, \"Invalid codeSpecId\");\r\n\r\n const row: any = stmt.getRow();\r\n return CodeSpec.createFromJson(this._imodel, id, row.name, JSON.parse(row.jsonProperties));\r\n });\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"CodeSpecs.js","sourceRoot":"","sources":["../../src/CodeSpecs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;A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uBAAQ,CAAC,aAAa,KAAK,IAAI,CAAC,IAAI,EAAE;gBACxC,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;YAEtE,MAAM,GAAG,GAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;YAC/B,OAAO,sBAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC;QAC7F,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AArID,8BAqIC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Codes\r\n */\r\n\r\nimport { DbResult, Id64, Id64String, IModelStatus } from \"@itwin/core-bentley\";\r\nimport { CodeScopeSpec, CodeSpec, IModelError } from \"@itwin/core-common\";\r\nimport { ECSqlStatement } from \"./ECSqlStatement\";\r\nimport { IModelDb } from \"./IModelDb\";\r\n\r\n/** Manages [CodeSpecs]($docs/BIS/guide/fundamentals/element-fundamentals.md#codespec) within an [[IModelDb]]\r\n * @public\r\n */\r\nexport class CodeSpecs {\r\n private _imodel: IModelDb;\r\n private _loadedCodeSpecs: CodeSpec[] = [];\r\n\r\n constructor(imodel: IModelDb) {\r\n this._imodel = imodel;\r\n if (imodel.isBriefcaseDb()) {\r\n imodel.onChangesetApplied.addListener(() => this._loadedCodeSpecs.length = 0);\r\n }\r\n }\r\n\r\n /** Look up the Id of the CodeSpec with the specified name. */\r\n public queryId(name: string): Id64String {\r\n return this._imodel.withPreparedStatement(\"SELECT ECInstanceId FROM BisCore.CodeSpec WHERE Name=:name\", (stmt: ECSqlStatement) => {\r\n stmt.bindString(\"name\", name);\r\n if (DbResult.BE_SQLITE_ROW !== stmt.step())\r\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\", () => ({ name }));\r\n return stmt.getValue(0).getId();\r\n });\r\n }\r\n\r\n /** Look up a CodeSpec by Id. The CodeSpec will be loaded from the database if necessary.\r\n * @param codeSpecId The Id of the CodeSpec to load\r\n * @returns The CodeSpec with the specified Id\r\n * @throws [[IModelError]] if the Id is invalid or if no CodeSpec with that Id could be found.\r\n */\r\n public getById(codeSpecId: Id64String): CodeSpec {\r\n if (Id64.isInvalid(codeSpecId))\r\n throw new IModelError(IModelStatus.InvalidId, \"Invalid codeSpecId\");\r\n\r\n // good chance it is already loaded - check there before running a query\r\n const found = this._loadedCodeSpecs.find((codeSpec) => codeSpec.id === codeSpecId);\r\n if (found !== undefined)\r\n return found;\r\n\r\n // must load this codespec\r\n const loadedCodeSpec = this.load(codeSpecId);\r\n this._loadedCodeSpecs.push(loadedCodeSpec);\r\n return loadedCodeSpec;\r\n }\r\n\r\n /** Returns true if the IModelDb has a CodeSpec of the specified Id. */\r\n public hasId(codeSpecId: Id64String): boolean {\r\n try {\r\n return undefined !== this.getById(codeSpecId);\r\n } catch (error) {\r\n return false;\r\n }\r\n }\r\n\r\n /** Look up a CodeSpec by name. The CodeSpec will be loaded from the database if necessary.\r\n * @param name The name of the CodeSpec to load\r\n * @returns The CodeSpec with the specified name\r\n * @throws [[IModelError]] if no CodeSpec with the specified name could be found.\r\n */\r\n public getByName(name: string): CodeSpec {\r\n // good chance it is already loaded - check there before running a query\r\n const found: CodeSpec | undefined = this._loadedCodeSpecs.find((codeSpec) => codeSpec.name === name);\r\n if (found !== undefined)\r\n return found;\r\n const codeSpecId = this.queryId(name);\r\n if (codeSpecId === undefined)\r\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\", () => ({ name }));\r\n return this.getById(codeSpecId);\r\n }\r\n\r\n /** Returns true if the IModelDb has a CodeSpec of the specified name. */\r\n public hasName(name: string): boolean {\r\n try {\r\n return undefined !== this.getByName(name);\r\n } catch (error) {\r\n return false;\r\n }\r\n }\r\n\r\n /** Add a new CodeSpec to the iModel.\r\n * @param codeSpec The CodeSpec to insert\r\n * @returns The Id of the persistent CodeSpec.\r\n * @note If successful, this method will assign a valid CodeSpecId to the supplied CodeSpec\r\n * @throws IModelError if the insertion fails\r\n */\r\n public insert(codeSpec: CodeSpec): Id64String;\r\n /** Add a new CodeSpec to the IModelDb.\r\n * @param name The name for the new CodeSpec.\r\n * @param scopeType The scope type\r\n * @returns The Id of the persistent CodeSpec.\r\n * @throws IModelError if the insertion fails\r\n */\r\n public insert(name: string, scopeType: CodeScopeSpec.Type): Id64String;\r\n public insert(codeSpecOrName: CodeSpec | string, scopeType?: CodeScopeSpec.Type): Id64String {\r\n if (codeSpecOrName instanceof CodeSpec) {\r\n const codeSpec = codeSpecOrName;\r\n const id: Id64String = this._imodel.insertCodeSpec(codeSpec);\r\n codeSpec.id = id;\r\n return id;\r\n }\r\n if (typeof codeSpecOrName === \"string\") {\r\n const name = codeSpecOrName;\r\n if (scopeType)\r\n return this._imodel.insertCodeSpec(CodeSpec.create(this._imodel, name, scopeType));\r\n }\r\n throw new IModelError(IModelStatus.BadArg, \"Invalid argument\");\r\n }\r\n\r\n /** Update the Json properties of an existing CodeSpec.\r\n * @param codeSpec The codeSpec holding Json properties values to update\r\n * @throws if unable to update the codeSpec.\r\n */\r\n public updateProperties(codeSpec: CodeSpec): void {\r\n this._imodel.withPreparedSqliteStatement(\"UPDATE bis_CodeSpec SET JsonProperties=? WHERE Id=?\", (stmt) => {\r\n stmt.bindString(1, JSON.stringify(codeSpec.properties));\r\n stmt.bindId(2, codeSpec.id);\r\n if (DbResult.BE_SQLITE_DONE !== stmt.step())\r\n throw new IModelError(IModelStatus.BadArg, \"error updating CodeSpec properties\");\r\n });\r\n }\r\n\r\n /** Load a CodeSpec from the iModel\r\n * @param id The persistent Id of the CodeSpec to load\r\n */\r\n public load(id: Id64String): CodeSpec {\r\n if (Id64.isInvalid(id))\r\n throw new IModelError(IModelStatus.InvalidId, \"Invalid codeSpecId\");\r\n\r\n return this._imodel.withPreparedStatement(\"SELECT name,jsonProperties FROM BisCore.CodeSpec WHERE ECInstanceId=?\", (stmt: ECSqlStatement) => {\r\n stmt.bindId(1, id);\r\n if (DbResult.BE_SQLITE_ROW !== stmt.step())\r\n throw new IModelError(IModelStatus.InvalidId, \"Invalid codeSpecId\");\r\n\r\n const row: any = stmt.getRow();\r\n return CodeSpec.createFromJson(this._imodel, id, row.name, JSON.parse(row.jsonProperties));\r\n });\r\n }\r\n}\r\n"]}
|
|
@@ -436,9 +436,16 @@ export interface ECSqlColumnInfo {
|
|
|
436
436
|
getType(): ECSqlValueType;
|
|
437
437
|
/** Gets the name of the property backing the column.
|
|
438
438
|
* > If this column is backed by a generated property, i.e. it represents ECSQL expression,
|
|
439
|
-
* > the access string consists of the name of the generated property.
|
|
439
|
+
* > the access string consists of the name of the generated property. [[ECSqlColumnInfo.getOriginPropertyName]]
|
|
440
|
+
* > can be used to obtain the non-aliased name in that case.
|
|
440
441
|
*/
|
|
441
442
|
getPropertyName(): string;
|
|
443
|
+
/** Gets the name of the original property that the column data is from.
|
|
444
|
+
* > Other than [[ECSqlColumnInfo.getPropertyName]], this ignores aliases and allows getting the name
|
|
445
|
+
* > of the property which is being used for the column. A column may not be backed
|
|
446
|
+
* > by a property, in which case this returns undefined.
|
|
447
|
+
*/
|
|
448
|
+
getOriginPropertyName(): string | undefined;
|
|
442
449
|
/** Gets the full access string to the corresponding ECSqlValue starting from the root class.
|
|
443
450
|
* > If this column is backed by a generated property, i.e. it represents ECSQL expression,
|
|
444
451
|
* > the access string consists of the ECSQL expression.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECSqlStatement.d.ts","sourceRoot":"","sources":["../../src/ECSqlStatement.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,qBAAq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