@itwin/core-backend 4.1.0-dev.8 → 4.1.0-dev.80

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.
Files changed (188) hide show
  1. package/CHANGELOG.md +99 -1
  2. package/lib/cjs/BackendHubAccess.js.map +1 -1
  3. package/lib/cjs/BackendLoggerCategory.js.map +1 -1
  4. package/lib/cjs/BisCoreSchema.js.map +1 -1
  5. package/lib/cjs/BlobContainerService.d.ts +38 -28
  6. package/lib/cjs/BlobContainerService.d.ts.map +1 -1
  7. package/lib/cjs/BlobContainerService.js.map +1 -1
  8. package/lib/cjs/BriefcaseManager.d.ts +8 -5
  9. package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
  10. package/lib/cjs/BriefcaseManager.js +9 -16
  11. package/lib/cjs/BriefcaseManager.js.map +1 -1
  12. package/lib/cjs/Category.d.ts +4 -16
  13. package/lib/cjs/Category.d.ts.map +1 -1
  14. package/lib/cjs/Category.js +0 -12
  15. package/lib/cjs/Category.js.map +1 -1
  16. package/lib/cjs/ChangeSummaryManager.js +2 -2
  17. package/lib/cjs/ChangeSummaryManager.js.map +1 -1
  18. package/lib/cjs/ChangedElementsDb.js.map +1 -1
  19. package/lib/cjs/ChangedElementsManager.js.map +1 -1
  20. package/lib/cjs/ChannelControl.d.ts +5 -1
  21. package/lib/cjs/ChannelControl.d.ts.map +1 -1
  22. package/lib/cjs/ChannelControl.js +10 -5
  23. package/lib/cjs/ChannelControl.js.map +1 -1
  24. package/lib/cjs/CheckpointManager.d.ts.map +1 -1
  25. package/lib/cjs/CheckpointManager.js +20 -9
  26. package/lib/cjs/CheckpointManager.js.map +1 -1
  27. package/lib/cjs/ClassRegistry.d.ts +2 -1
  28. package/lib/cjs/ClassRegistry.d.ts.map +1 -1
  29. package/lib/cjs/ClassRegistry.js +7 -6
  30. package/lib/cjs/ClassRegistry.js.map +1 -1
  31. package/lib/cjs/CloudSqlite.d.ts +57 -40
  32. package/lib/cjs/CloudSqlite.d.ts.map +1 -1
  33. package/lib/cjs/CloudSqlite.js +54 -39
  34. package/lib/cjs/CloudSqlite.js.map +1 -1
  35. package/lib/cjs/CodeService.js.map +1 -1
  36. package/lib/cjs/CodeSpecs.js.map +1 -1
  37. package/lib/cjs/ConcurrentQuery.js.map +1 -1
  38. package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
  39. package/lib/cjs/DevTools.js.map +1 -1
  40. package/lib/cjs/DisplayStyle.d.ts +2 -5
  41. package/lib/cjs/DisplayStyle.d.ts.map +1 -1
  42. package/lib/cjs/DisplayStyle.js +0 -3
  43. package/lib/cjs/DisplayStyle.js.map +1 -1
  44. package/lib/cjs/ECDb.d.ts +6 -0
  45. package/lib/cjs/ECDb.d.ts.map +1 -1
  46. package/lib/cjs/ECDb.js +6 -0
  47. package/lib/cjs/ECDb.js.map +1 -1
  48. package/lib/cjs/ECSchemaXmlContext.d.ts +28 -1
  49. package/lib/cjs/ECSchemaXmlContext.d.ts.map +1 -1
  50. package/lib/cjs/ECSchemaXmlContext.js +28 -1
  51. package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
  52. package/lib/cjs/ECSqlStatement.js.map +1 -1
  53. package/lib/cjs/Element.d.ts +40 -97
  54. package/lib/cjs/Element.d.ts.map +1 -1
  55. package/lib/cjs/Element.js +0 -57
  56. package/lib/cjs/Element.js.map +1 -1
  57. package/lib/cjs/ElementAspect.d.ts +2 -4
  58. package/lib/cjs/ElementAspect.d.ts.map +1 -1
  59. package/lib/cjs/ElementAspect.js +2 -4
  60. package/lib/cjs/ElementAspect.js.map +1 -1
  61. package/lib/cjs/ElementGraphics.js.map +1 -1
  62. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  63. package/lib/cjs/Entity.d.ts +5 -2
  64. package/lib/cjs/Entity.d.ts.map +1 -1
  65. package/lib/cjs/Entity.js +10 -2
  66. package/lib/cjs/Entity.js.map +1 -1
  67. package/lib/cjs/EntityReferences.js.map +1 -1
  68. package/lib/cjs/ExportGraphics.js.map +1 -1
  69. package/lib/cjs/ExternalSource.d.ts +4 -11
  70. package/lib/cjs/ExternalSource.d.ts.map +1 -1
  71. package/lib/cjs/ExternalSource.js +0 -7
  72. package/lib/cjs/ExternalSource.js.map +1 -1
  73. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  74. package/lib/cjs/GeometrySummary.js +47 -47
  75. package/lib/cjs/GeometrySummary.js.map +1 -1
  76. package/lib/cjs/HubMock.js.map +1 -1
  77. package/lib/cjs/IModelCloneContext.js.map +1 -1
  78. package/lib/cjs/IModelDb.d.ts +61 -26
  79. package/lib/cjs/IModelDb.d.ts.map +1 -1
  80. package/lib/cjs/IModelDb.js +164 -83
  81. package/lib/cjs/IModelDb.js.map +1 -1
  82. package/lib/cjs/IModelElementCloneContext.js.map +1 -1
  83. package/lib/cjs/IModelHost.d.ts +1 -3
  84. package/lib/cjs/IModelHost.d.ts.map +1 -1
  85. package/lib/cjs/IModelHost.js +3 -5
  86. package/lib/cjs/IModelHost.js.map +1 -1
  87. package/lib/cjs/IModelJsFs.js.map +1 -1
  88. package/lib/cjs/IpcHost.js.map +1 -1
  89. package/lib/cjs/LineStyle.js.map +1 -1
  90. package/lib/cjs/LocalHub.js +1 -1
  91. package/lib/cjs/LocalHub.js.map +1 -1
  92. package/lib/cjs/LocalhostIpcHost.js.map +1 -1
  93. package/lib/cjs/Material.d.ts +0 -1
  94. package/lib/cjs/Material.d.ts.map +1 -1
  95. package/lib/cjs/Material.js +1 -2
  96. package/lib/cjs/Material.js.map +1 -1
  97. package/lib/cjs/Model.d.ts +4 -13
  98. package/lib/cjs/Model.d.ts.map +1 -1
  99. package/lib/cjs/Model.js +0 -9
  100. package/lib/cjs/Model.js.map +1 -1
  101. package/lib/cjs/NativeAppStorage.js.map +1 -1
  102. package/lib/cjs/NativeHost.js.map +1 -1
  103. package/lib/cjs/NavigationRelationship.js.map +1 -1
  104. package/lib/cjs/PromiseMemoizer.js.map +1 -1
  105. package/lib/cjs/PropertyStore.d.ts +3 -3
  106. package/lib/cjs/PropertyStore.d.ts.map +1 -1
  107. package/lib/cjs/PropertyStore.js +2 -5
  108. package/lib/cjs/PropertyStore.js.map +1 -1
  109. package/lib/cjs/Relationship.d.ts +2 -5
  110. package/lib/cjs/Relationship.d.ts.map +1 -1
  111. package/lib/cjs/Relationship.js +0 -3
  112. package/lib/cjs/Relationship.js.map +1 -1
  113. package/lib/cjs/RpcBackend.js.map +1 -1
  114. package/lib/cjs/SQLiteDb.d.ts +1 -1
  115. package/lib/cjs/SQLiteDb.d.ts.map +1 -1
  116. package/lib/cjs/SQLiteDb.js +1 -1
  117. package/lib/cjs/SQLiteDb.js.map +1 -1
  118. package/lib/cjs/Schema.d.ts +0 -1
  119. package/lib/cjs/Schema.d.ts.map +1 -1
  120. package/lib/cjs/Schema.js +0 -1
  121. package/lib/cjs/Schema.js.map +1 -1
  122. package/lib/cjs/SchemaUtils.d.ts +19 -0
  123. package/lib/cjs/SchemaUtils.d.ts.map +1 -0
  124. package/lib/cjs/SchemaUtils.js +42 -0
  125. package/lib/cjs/SchemaUtils.js.map +1 -0
  126. package/lib/cjs/ServerBasedLocks.js.map +1 -1
  127. package/lib/cjs/SqliteStatement.d.ts +13 -1
  128. package/lib/cjs/SqliteStatement.d.ts.map +1 -1
  129. package/lib/cjs/SqliteStatement.js +23 -1
  130. package/lib/cjs/SqliteStatement.js.map +1 -1
  131. package/lib/cjs/Texture.d.ts +3 -4
  132. package/lib/cjs/Texture.d.ts.map +1 -1
  133. package/lib/cjs/Texture.js +1 -2
  134. package/lib/cjs/Texture.js.map +1 -1
  135. package/lib/cjs/TileStorage.d.ts +3 -0
  136. package/lib/cjs/TileStorage.d.ts.map +1 -1
  137. package/lib/cjs/TileStorage.js +9 -1
  138. package/lib/cjs/TileStorage.js.map +1 -1
  139. package/lib/cjs/TxnManager.js.map +1 -1
  140. package/lib/cjs/ViewDefinition.d.ts +7 -28
  141. package/lib/cjs/ViewDefinition.d.ts.map +1 -1
  142. package/lib/cjs/ViewDefinition.js +0 -21
  143. package/lib/cjs/ViewDefinition.js.map +1 -1
  144. package/lib/cjs/ViewStateHydrator.js.map +1 -1
  145. package/lib/cjs/ViewStore.d.ts +488 -0
  146. package/lib/cjs/ViewStore.d.ts.map +1 -0
  147. package/lib/cjs/ViewStore.js +1246 -0
  148. package/lib/cjs/ViewStore.js.map +1 -0
  149. package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
  150. package/lib/cjs/assets/Settings/Schemas/Cloud.Schema.json +44 -44
  151. package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +31 -31
  152. package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +52 -52
  153. package/lib/cjs/assets/Settings/backend.setting.json5 +132 -132
  154. package/lib/cjs/core-backend.d.ts +2 -0
  155. package/lib/cjs/core-backend.d.ts.map +1 -1
  156. package/lib/cjs/core-backend.js +2 -0
  157. package/lib/cjs/core-backend.js.map +1 -1
  158. package/lib/cjs/domains/FunctionalElements.d.ts +6 -12
  159. package/lib/cjs/domains/FunctionalElements.d.ts.map +1 -1
  160. package/lib/cjs/domains/FunctionalElements.js +0 -6
  161. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  162. package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
  163. package/lib/cjs/domains/GenericElements.js.map +1 -1
  164. package/lib/cjs/domains/GenericSchema.js.map +1 -1
  165. package/lib/cjs/rpc/multipart.js.map +1 -1
  166. package/lib/cjs/rpc/tracing.js +2 -2
  167. package/lib/cjs/rpc/tracing.js.map +1 -1
  168. package/lib/cjs/rpc/web/logging.js.map +1 -1
  169. package/lib/cjs/rpc/web/request.js.map +1 -1
  170. package/lib/cjs/rpc/web/response.js.map +1 -1
  171. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
  172. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +5 -3
  173. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
  174. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +53 -36
  175. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  176. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  177. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts.map +1 -1
  178. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +0 -2
  179. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  180. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  181. package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -1
  182. package/lib/cjs/workspace/Settings.js.map +1 -1
  183. package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
  184. package/lib/cjs/workspace/Workspace.d.ts +1 -1
  185. package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
  186. package/lib/cjs/workspace/Workspace.js +4 -4
  187. package/lib/cjs/workspace/Workspace.js.map +1 -1
  188. package/package.json +21 -40
@@ -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,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,CAA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;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.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 `collectReferenceIds` 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 \"collectReferenceIds\",\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[\"collectReferenceIds\"];\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.toLower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AG,EAAE,MAAM,CAAC,CAAC;IACvD,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,eAAe,CAAC,aAAqB,IAAI,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC;IACnH;;;;OAIG;IACI,MAAM,CAAC,qBAAqB,CAAC,MAAqB;QACvD,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;YAC9C,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM;gBAC5B,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SAClC;IACH,CAAC;;AA/OuB,uBAAS,GAAG,IAAI,GAAG,EAAyB,CAAC;AAD1D,sCAAa;AAmP1B;;;;GAIG;AACH,MAAa,gBAAgB;IAA7B;QACU,cAAS,GAAgC,IAAI,GAAG,EAA0B,CAAC;IAOrF,CAAC;IALC,wCAAwC;IACjC,IAAI,CAAC,aAAqB,IAAgC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC;IAE1H,gCAAgC;IACzB,GAAG,CAAC,aAAqB,EAAE,QAAwB,IAAU,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;CACjI;AARD,4CAQC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Schema\n */\n\nimport { DbResult, Id64, IModelStatus, Logger } from \"@itwin/core-bentley\";\nimport { EntityMetaData, EntityReferenceSet, IModelError, RelatedElement } from \"@itwin/core-common\";\nimport { Entity } from \"./Entity\";\nimport { IModelDb } from \"./IModelDb\";\nimport { Schema, Schemas } from \"./Schema\";\nimport { EntityReferences } from \"./EntityReferences\";\nimport * as assert from \"assert\";\n\nconst isGeneratedClassTag = Symbol(\"isGeneratedClassTag\");\n\n/** The mapping between a BIS class name (in the form \"schema:class\") and its JavaScript constructor function\n * @public\n */\nexport class ClassRegistry {\n private static readonly _classMap = new Map<string, typeof Entity>();\n /** @internal */\n public static isNotFoundError(err: any) { return (err instanceof IModelError) && (err.errorNumber === IModelStatus.NotFound); }\n /** @internal */\n public static makeMetaDataNotFoundError(className: string): IModelError { return new IModelError(IModelStatus.NotFound, `metadata not found for ${className}`); }\n /** @internal */\n public static register(entityClass: typeof Entity, schema: typeof Schema) {\n entityClass.schema = schema;\n const key = (`${schema.schemaName}:${entityClass.className}`).toLowerCase();\n if (this._classMap.has(key)) {\n const errMsg = `Class ${key} is already registered. Make sure static className member is correct on JavaScript class ${entityClass.name}`;\n Logger.logError(\"core-frontend.classRegistry\", errMsg);\n throw new Error(errMsg);\n }\n\n this._classMap.set(key, entityClass);\n }\n\n /** Generate a proxy Schema for a domain that has not been registered. */\n private static generateProxySchema(domain: string, iModel: IModelDb): typeof Schema {\n const hasBehavior = iModel.withPreparedSqliteStatement(`\n SELECT NULL FROM [ec_CustomAttribute] [c]\n JOIN [ec_schema] [s] ON [s].[Id] = [c].[ContainerId]\n JOIN [ec_class] [e] ON [e].[Id] = [c].[ClassId]\n JOIN [ec_schema] [b] ON [e].[SchemaId] = [b].[Id]\n WHERE [c].[ContainerType] = 1 AND [s].[Name] = ? AND [b].[Name] || '.' || [e].[name] = ?`, (stmt) => {\n stmt.bindString(1, domain);\n stmt.bindString(2, \"BisCore.SchemaHasBehavior\");\n return stmt.step() === DbResult.BE_SQLITE_ROW;\n });\n\n const schemaClass = class extends Schema {\n public static override get schemaName() { return domain; }\n public static override get missingRequiredBehavior() { return hasBehavior; }\n };\n\n Schemas.registerSchema(schemaClass); // register the class before we return it.\n return schemaClass;\n }\n\n /** First, finds the root BisCore entity class for an entity, by traversing base classes and mixin targets (AppliesTo).\n * Then, gets its metadata and returns that.\n * @param iModel - iModel containing the metadata for this type\n * @param ecTypeQualifier - a full name of an ECEntityClass to find the root of\n * @returns the qualified full name of an ECEntityClass\n * @internal public for testing only\n */\n public static getRootEntity(iModel: IModelDb, ecTypeQualifier: string): string {\n const [classSchema, className] = ecTypeQualifier.split(\".\");\n const schemaItemJson = iModel.nativeDb.getSchemaItem(classSchema, className);\n if (schemaItemJson.error)\n throw new IModelError(schemaItemJson.error.status, `failed to get schema item '${ecTypeQualifier}'`);\n\n assert(undefined !== schemaItemJson.result);\n const schemaItem = JSON.parse(schemaItemJson.result);\n if (!(\"appliesTo\" in schemaItem) && schemaItem.baseClass === undefined) {\n return ecTypeQualifier;\n }\n\n // typescript doesn't understand that the inverse of the above condition is\n // (\"appliesTo\" in rootclassMetaData || rootClassMetaData.baseClass !== undefined)\n const parentItemQualifier = schemaItem.appliesTo ?? schemaItem.baseClass as string;\n return this.getRootEntity(iModel, parentItemQualifier);\n }\n\n /** Generate a JavaScript class from Entity metadata.\n * @param entityMetaData The Entity metadata that defines the class\n */\n private static generateClassForEntity(entityMetaData: EntityMetaData, iModel: IModelDb): typeof Entity {\n const name = entityMetaData.ecclass.split(\":\");\n const domainName = name[0];\n const className = name[1];\n\n if (0 === entityMetaData.baseClasses.length) // metadata must contain a superclass\n throw new IModelError(IModelStatus.BadArg, `class ${name} has no superclass`);\n\n // make sure schema exists\n let schema = Schemas.getRegisteredSchema(domainName);\n if (undefined === schema)\n schema = this.generateProxySchema(domainName, iModel); // no schema found, create it too\n\n const superclass = this._classMap.get(entityMetaData.baseClasses[0].toLowerCase());\n if (undefined === superclass)\n throw new IModelError(IModelStatus.NotFound, `cannot find superclass for class ${name}`);\n\n // user defined class hierarchies may skip a class in the hierarchy, and therefore their JS base class cannot\n // be used to tell if there are any generated classes in the hierarchy\n let generatedClassHasNonGeneratedNonCoreAncestor = false;\n let currentSuperclass = superclass;\n const MAX_ITERS = 1000;\n for (let i = 0; i < MAX_ITERS; ++i) {\n if (currentSuperclass.schema.schemaName === \"BisCore\")\n break;\n\n if (!currentSuperclass.isGeneratedClass) {\n generatedClassHasNonGeneratedNonCoreAncestor = true;\n break;\n }\n const superclassMetaData = iModel.classMetaDataRegistry.find(currentSuperclass.classFullName);\n if (superclassMetaData === undefined)\n throw new IModelError(IModelStatus.BadSchema, `could not find the metadata for class '${currentSuperclass.name}', class metadata should be loaded by now`);\n const maybeNextSuperclass = this.getClass(superclassMetaData.baseClasses[0], iModel);\n if (maybeNextSuperclass === undefined)\n throw new IModelError(IModelStatus.BadSchema, `could not find the base class of '${currentSuperclass.name}', all generated classes must have a base class`);\n currentSuperclass = maybeNextSuperclass;\n }\n\n const generatedClass = class extends superclass {\n public static override get className() { return className; }\n private static [isGeneratedClassTag] = true;\n public static override get isGeneratedClass() { return this.hasOwnProperty(isGeneratedClassTag); }\n };\n\n // the above creates an anonymous class. For help debugging, set the \"constructor.name\" property to be the same as the bisClassName.\n Object.defineProperty(generatedClass, \"name\", { get: () => className }); // this is the (only) way to change that readonly property.\n\n // a class only gets an automatic `collectReferenceIds` implementation if:\n // - it is not in the `BisCore` schema\n // - there are no ancestors with manually registered JS implementations, (excluding BisCore base classes)\n if (!generatedClassHasNonGeneratedNonCoreAncestor) {\n const navigationProps = Object.entries(entityMetaData.properties)\n .filter(([_name, prop]) => prop.isNavigation)\n // eslint-disable-next-line @typescript-eslint/no-shadow\n .map(([name, prop]) => {\n assert(prop.relationshipClass);\n const maybeMetaData = iModel.nativeDb.getSchemaItem(...prop.relationshipClass.split(\":\") as [string, string]);\n assert(maybeMetaData.result !== undefined, \"The nav props relationship metadata was not found\");\n const relMetaData = JSON.parse(maybeMetaData.result);\n const rootClassMetaData = ClassRegistry.getRootEntity(iModel, relMetaData.target.constraintClasses[0]);\n // root class must be in BisCore so should be loaded since biscore classes will never get this\n // generated implementation\n const normalizeClassName = (clsName: string) => clsName.replace(\".\", \":\");\n const rootClass = ClassRegistry.findRegisteredClass(normalizeClassName(rootClassMetaData));\n assert(rootClass, `The root class for ${prop.relationshipClass} was not in BisCore.`);\n return { name, concreteEntityType: EntityReferences.typeFromClass(rootClass) };\n });\n\n Object.defineProperty(\n generatedClass.prototype,\n \"collectReferenceIds\",\n {\n value(this: typeof generatedClass, referenceIds: EntityReferenceSet) {\n // eslint-disable-next-line @typescript-eslint/dot-notation\n const superImpl = superclass.prototype[\"collectReferenceIds\"];\n superImpl.call(this, referenceIds);\n for (const navProp of navigationProps) {\n const relatedElem: RelatedElement | undefined = (this as any)[navProp.name]; // cast to any since subclass can have any extensions\n if (!relatedElem || !Id64.isValid(relatedElem.id))\n continue;\n const referenceId = EntityReferences.fromEntityType(relatedElem.id, navProp.concreteEntityType);\n referenceIds.add(referenceId);\n }\n },\n // defaults for methods on a prototype (required for sinon to stub out methods on tests)\n writable: true,\n configurable: true,\n },\n );\n }\n\n // if the schema is a proxy for a domain with behavior, throw exceptions for all protected operations\n if (schema.missingRequiredBehavior) {\n const throwError = () => {\n throw new IModelError(IModelStatus.WrongHandler, `Schema [${domainName}] not registered, but is marked with SchemaHasBehavior`);\n };\n\n superclass.protectedOperations.forEach((operation) => (generatedClass as any)[operation] = throwError);\n }\n\n this.register(generatedClass, schema); // register it before returning\n return generatedClass;\n }\n\n /** Register all of the classes found in the given module that derive from Entity. See the example in [[Schema]]\n * @param moduleObj The module to search for subclasses of Entity\n * @param schema The schema for all found classes\n */\n public static registerModule(moduleObj: any, schema: typeof Schema) {\n for (const thisMember in moduleObj) { // eslint-disable-line guard-for-in\n const thisClass = moduleObj[thisMember];\n if (thisClass.prototype instanceof Entity)\n this.register(thisClass, schema);\n }\n }\n\n /**\n * This function fetches the specified Entity from the imodel, generates a JavaScript class for it, and registers the generated\n * class. This function also ensures that all of the base classes of the Entity exist and are registered.\n */\n private static generateClass(classFullName: string, iModel: IModelDb): typeof Entity {\n const metadata: EntityMetaData | undefined = iModel.classMetaDataRegistry.find(classFullName);\n if (metadata === undefined || metadata.ecclass === undefined)\n throw this.makeMetaDataNotFoundError(classFullName);\n\n // Make sure we have all base classes registered.\n if (metadata.baseClasses && (0 !== metadata.baseClasses.length))\n this.getClass(metadata.baseClasses[0], iModel);\n\n // Now we can generate the class from the classDef.\n return this.generateClassForEntity(metadata, iModel);\n }\n\n /** Find a registered class by classFullName.\n * @param classFullName class to find\n * @param iModel The IModel that contains the class definitions\n * @returns The Entity class or undefined\n */\n public static findRegisteredClass(classFullName: string): typeof Entity | undefined {\n return this._classMap.get(classFullName.toLowerCase());\n }\n\n /** Get the Entity class for the specified Entity className.\n * @param classFullName The full BIS class name of the Entity\n * @param iModel The IModel that contains the class definitions\n * @returns The Entity class\n */\n public static getClass(classFullName: string, iModel: IModelDb): typeof Entity {\n const key = classFullName.toLowerCase();\n const ctor = this._classMap.get(key);\n return ctor ? ctor : this.generateClass(key, iModel);\n }\n\n /** Unregister a class, by name, if one is already registered.\n * This function is not normally needed, but is useful for cases where a generated *proxy* class needs to be replaced by the *real* class.\n * @param classFullName Name of the class to unregister\n * @return true if the class was unregistered\n * @internal\n */\n public static unregisterCLass(classFullName: string) { return this._classMap.delete(classFullName.toLowerCase()); }\n /** Unregister all classes from a schema.\n * This function is not normally needed, but is useful for cases where a generated *proxy* schema needs to be replaced by the *real* schema.\n * @param schema Name of the schema to unregister\n * @internal\n */\n public static unregisterClassesFrom(schema: typeof Schema) {\n for (const entry of Array.from(this._classMap)) {\n if (entry[1].schema === schema)\n this.unregisterCLass(entry[0]);\n }\n }\n}\n\n/**\n * A cache that records the mapping between class names and class metadata.\n * @see [[IModelDb.classMetaDataRegistry]] to access the registry for a specific iModel.\n * @internal\n */\nexport class MetaDataRegistry {\n private _registry: Map<string, EntityMetaData> = new Map<string, EntityMetaData>();\n\n /** Get the specified Entity metadata */\n public find(classFullName: string): EntityMetaData | undefined { return this._registry.get(classFullName.toLowerCase()); }\n\n /** Add metadata to the cache */\n public add(classFullName: string, metaData: EntityMetaData): void { this._registry.set(classFullName.toLowerCase(), metaData); }\n}\n"]}
@@ -1,8 +1,9 @@
1
1
  /** @packageDocumentation
2
2
  * @module SQLiteDb
3
3
  */
4
- import { AccessToken, Constructor, GuidString, PickAsyncMethods, PickMethods } from "@itwin/core-bentley";
4
+ import { AccessToken, Constructor, GuidString, OpenMode, Optional, PickAsyncMethods, PickMethods } from "@itwin/core-bentley";
5
5
  import { LocalDirName, LocalFileName } from "@itwin/core-common";
6
+ import { BlobContainer } from "./BlobContainerService";
6
7
  import type { VersionedSqliteDb } from "./SQLiteDb";
7
8
  /**
8
9
  * Types for accessing SQLite databases stored in cloud containers.
@@ -13,41 +14,48 @@ export declare namespace CloudSqlite {
13
14
  * Request a new AccessToken for a cloud container using the [[BlobContainer]] service.
14
15
  * If the service is unavailable or returns an error, an empty token is returned.
15
16
  */
16
- function requestToken(args: ContainerTokenProps): Promise<AccessToken>;
17
+ function requestToken(args: Optional<BlobContainer.RequestTokenProps, "userToken">): Promise<AccessToken>;
17
18
  /**
18
19
  * Create a new CloudContainer from a ContainerAccessProps. For non-public containers, a valid accessToken must be provided before the container
19
20
  * can be used (e.g. via [[CloudSqlite.requestToken]]).
20
21
  * @note After the container is successfully connected to a CloudCache, it will begin auto-refreshing its accessToken every `tokenRefreshSeconds` seconds (default is 1 hour)
21
22
  * until it is disconnected. However, if the container is public, or if `tokenRefreshSeconds` is <=0, auto-refresh is not enabled.
22
23
  */
23
- function createCloudContainer(args: ContainerAccessProps): CloudContainer;
24
+ function createCloudContainer(args: ContainerAccessProps & {
25
+ accessLevel?: BlobContainer.RequestAccessLevel;
26
+ }): CloudContainer;
24
27
  /** Begin prefetching all blocks for a database in a CloudContainer in the background. */
25
28
  function startCloudPrefetch(container: CloudContainer, dbName: string, args?: PrefetchProps): CloudPrefetch;
26
- /** Properties of a CloudContainer. */
27
29
  interface ContainerProps {
28
- /** blob storage provider */
30
+ /** The type of storage provider. */
29
31
  storageType: "azure" | "google";
30
- /** base URI for container. */
32
+ /** The base URI for the container. */
31
33
  baseUri: string;
32
- /** the name of the container. */
34
+ /** The name of the container. */
33
35
  containerId: string;
36
+ /** true if the container is public (doesn't require authorization) */
37
+ isPublic?: boolean;
38
+ }
39
+ /** Properties to access a CloudContainer. */
40
+ interface ContainerAccessProps extends ContainerProps {
34
41
  /** an alias for the container. Defaults to `containerId` */
35
42
  alias?: string;
36
43
  /** SAS token that grants access to the container. */
37
44
  accessToken: string;
38
- /** if true, container is attached with write permissions, and accessToken must provide write access to the cloud container. */
45
+ /** if true, container is allowed to request the write lock. */
39
46
  writeable?: boolean;
40
47
  /** if true, container is attached in "secure" mode (blocks are encrypted). Only supported in daemon mode. */
41
48
  secure?: boolean;
42
- /** true if the container is public (doesn't require authorization) */
43
- isPublic?: boolean;
44
49
  /** string attached to log messages from CloudSQLite. This is most useful for identifying usage from daemon mode. */
45
50
  logId?: string;
51
+ /** Duration for holding write lock, in seconds. After this time the write lock expires if not refreshed. Default is one hour. */
52
+ lockExpireSeconds?: number;
53
+ /** number of seconds between auto-refresh of access token. If <=0 no auto-refresh. Default is 1 hour (60*60) */
54
+ tokenRefreshSeconds?: number;
46
55
  }
47
- type ContainerTokenProps = Omit<ContainerProps, "accessToken">;
48
56
  /** Returned from `CloudContainer.queryDatabase` describing one database in the container */
49
57
  interface CachedDbProps {
50
- /** The total of (4Mb) blocks in the database. */
58
+ /** The total number of blocks in the database. */
51
59
  readonly totalBlocks: number;
52
60
  /** the number of blocks of the database that have been downloaded into the CloudCache */
53
61
  readonly localBlocks: number;
@@ -90,13 +98,6 @@ export declare namespace CloudSqlite {
90
98
  /** HTTP response code (e.g. 200) */
91
99
  readonly httpcode: number;
92
100
  }
93
- /** Properties for accessing a CloudContainer */
94
- type ContainerAccessProps = ContainerProps & {
95
- /** Duration for holding write lock, in seconds. After this time the write lock expires if not refreshed. Default is one hour. */
96
- lockExpireSeconds?: number;
97
- /** number of seconds between auto-refresh of access token. If <=0 no auto-refresh. Default is 1 hour (60*60) */
98
- tokenRefreshSeconds?: number;
99
- };
100
101
  /** The name of a CloudSqlite database within a CloudContainer. */
101
102
  interface DbNameProp {
102
103
  /** the name of the database within the CloudContainer.
@@ -138,7 +139,7 @@ export declare namespace CloudSqlite {
138
139
  /** Parameters used to obtain the write lock on a cloud container */
139
140
  interface ObtainLockParams {
140
141
  /** a string that identifies me to others if I hold the lock while they attempt to acquire it. */
141
- moniker?: string;
142
+ user?: string;
142
143
  /** number of times to retry in the event the lock currently held by someone else.
143
144
  * After this number of attempts, `onFailure` is called. Default is 20.
144
145
  */
@@ -154,7 +155,7 @@ export declare namespace CloudSqlite {
154
155
  /** @internal */
155
156
  interface LockAndOpenArgs {
156
157
  /** a string that identifies me to others if I hold the lock while they attempt to acquire it. */
157
- moniker: string;
158
+ user: string;
158
159
  /** the name of the database within the container */
159
160
  dbName: string;
160
161
  /** the CloudContainer on which the operation will be performed */
@@ -240,6 +241,10 @@ export declare namespace CloudSqlite {
240
241
  onDisconnect?: (container: CloudContainer, detach: boolean) => void;
241
242
  onDisconnected?: (container: CloudContainer, detach: boolean) => void;
242
243
  readonly cache?: CloudCache;
244
+ /** the baseUri of this container */
245
+ get baseUri(): string;
246
+ /** the storageType of this container */
247
+ get storageType(): string;
243
248
  /** The ContainerId within a storage account. */
244
249
  get containerId(): string;
245
250
  /** The *alias* to identify this CloudContainer in a CloudCache. Usually just the ContainerId. */
@@ -267,7 +272,7 @@ export declare namespace CloudSqlite {
267
272
  * initialize a cloud blob-store container to be used as a new CloudContainer. This creates the container's manifest of its contents, and should be
268
273
  * performed on an empty container. If an existing manifest is present, it is destroyed and a new one is created (essentially emptying the container.)
269
274
  */
270
- initializeContainer(opts?: {
275
+ initializeContainer(args: {
271
276
  checksumBlockNames?: boolean;
272
277
  blockSize: number;
273
278
  }): void;
@@ -433,22 +438,30 @@ export declare namespace CloudSqlite {
433
438
  * @param busyHandler if present, function called when the write lock is currently held by another user.
434
439
  * @throws if [[container]] is not connected to a CloudCache.
435
440
  */
436
- function acquireWriteLock(user: string, container: CloudContainer, busyHandler?: WriteLockBusyHandler): Promise<void>;
441
+ function acquireWriteLock(args: {
442
+ user: string;
443
+ container: CloudContainer;
444
+ busyHandler?: WriteLockBusyHandler;
445
+ }): Promise<void>;
437
446
  /**
438
- * Perform an asynchronous write operation on a CloudContainer with the write lock held.
439
- * 1. if write lock is already held, call operation and return.
440
- * 2. attempt to acquire the write lock, with retries. Throw if unable to obtain write lock.
441
- * 3. perform the operation
442
- * 3.a if the operation throws, abandon all changes and re-throw
443
- * 4. release the write lock.
444
- * 5. return value from operation
445
- * @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
446
- * @param container the CloudContainer for which the lock is to be acquired
447
- * @param operation an asynchronous operation performed with the write lock held.
448
- * @param busyHandler if present, function called when the write lock is currently held by another user.
449
- * @returns a Promise with the result of `operation`
450
- */
451
- function withWriteLock<T>(user: string, container: CloudContainer, operation: () => Promise<T>, busyHandler?: WriteLockBusyHandler): Promise<T>;
447
+ * Perform an asynchronous write operation on a CloudContainer with the write lock held.
448
+ * 1. if write lock is already held by the current user, call operation and return.
449
+ * 2. attempt to acquire the write lock, with retries. Throw if unable to obtain write lock.
450
+ * 3. perform the operation
451
+ * 3.a if the operation throws, abandon all changes and re-throw
452
+ * 4. release the write lock.
453
+ * 5. return value from operation
454
+ * @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
455
+ * @param container the CloudContainer for which the lock is to be acquired
456
+ * @param operation an asynchronous operation performed with the write lock held.
457
+ * @param busyHandler if present, function called when the write lock is currently held by another user.
458
+ * @returns a Promise with the result of `operation`
459
+ */
460
+ function withWriteLock<T>(args: {
461
+ user: string;
462
+ container: CloudContainer;
463
+ busyHandler?: WriteLockBusyHandler;
464
+ }, operation: () => Promise<T>): Promise<T>;
452
465
  /** Arguments to create or find a CloudCache */
453
466
  interface CreateCloudCacheArg {
454
467
  /** The name of the CloudCache. CloudCache names must be unique. */
@@ -524,7 +537,7 @@ export declare namespace CloudSqlite {
524
537
  /** Close the database for this DbAccess if it is opened, and disconnect this `DbAccess from its CloudContainer. */
525
538
  close(): void;
526
539
  /**
527
- * Initialize a cloud container to hold a Cloud SQliteDb. The container must first be created via its storage supplier api (e.g. Azure, or AWS).
540
+ * Initialize a cloud container to hold a Cloud SQliteDb. The container must first be created via its storage supplier api (e.g. Azure, or Google).
528
541
  * A valid sasToken that grants write access must be supplied. This function creates and uploads an empty database into the container.
529
542
  * @note this deletes any existing content in the container.
530
543
  */
@@ -532,7 +545,7 @@ export declare namespace CloudSqlite {
532
545
  dbType: typeof VersionedSqliteDb;
533
546
  props: ContainerAccessProps;
534
547
  dbName: string;
535
- blockSize?: number;
548
+ blockSize?: "64K" | "4M";
536
549
  }): Promise<void>;
537
550
  /**
538
551
  * Synchronize the local cache of this database with any changes by made by others.
@@ -557,7 +570,11 @@ export declare namespace CloudSqlite {
557
570
  * @note Most uses of `CloudSqliteDbAccess` require that the lock not be held by any operation for long. Make sure you don't
558
571
  * do any avoidable or time consuming work in your operation function.
559
572
  */
560
- withLockedDb<T>(operationName: string, operation: () => Promise<T>): Promise<T>;
573
+ withLockedDb<T>(args: {
574
+ operationName: string;
575
+ openMode?: OpenMode;
576
+ user?: string;
577
+ }, operation: () => Promise<T>): Promise<T>;
561
578
  /** get a method member, by name, from the database object. Throws if not a Function. */
562
579
  private getDbMethod;
563
580
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"CloudSqlite.d.ts","sourceRoot":"","sources":["../../src/CloudSqlite.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAAE,WAAW,EAA+B,WAAW,EAAE,UAAU,EAAoB,gBAAgB,EAAE,WAAW,EAAa,MAAM,qBAAqB,CAAC;AACpK,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAIpD;;;GAGG;AACH,yBAAiB,WAAW,CAAC;IAK3B;;;OAGG;IACH,SAA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;YAAC,SAAS,CAAC,EAAE,KAAK,GAAG,IAAI,CAAA;SAAE;QAatJ;;;;;;;WAOG;QACI,oBAAoB;QAK3B;;;WAGG;QACI,WAAW,IAAI,MAAM;QAM5B;;;;;;;;WAQG;QACU,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE;YAAE,aAAa,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;QAmC1I,wFAAwF;QACxF,OAAO,CAAC,WAAW;QAOnB;;;;;;;;;;;;WAYG;QACH,IAAW,WAAW,mCAOrB;QAED;;;WAGG;QACH,IAAW,MAAM,6BAOhB;KACF;CACF"}
@@ -12,9 +12,10 @@ const fs_1 = require("fs");
12
12
  const path_1 = require("path");
13
13
  const imodeljs_native_1 = require("@bentley/imodeljs-native");
14
14
  const core_bentley_1 = require("@itwin/core-bentley");
15
+ const BlobContainerService_1 = require("./BlobContainerService");
15
16
  const IModelHost_1 = require("./IModelHost");
16
17
  const IModelJsFs_1 = require("./IModelJsFs");
17
- const BlobContainerService_1 = require("./BlobContainerService");
18
+ const tracing_1 = require("./rpc/tracing");
18
19
  // spell:ignore logmsg httpcode
19
20
  /**
20
21
  * Types for accessing SQLite databases stored in cloud containers.
@@ -29,8 +30,9 @@ var CloudSqlite;
29
30
  * If the service is unavailable or returns an error, an empty token is returned.
30
31
  */
31
32
  async function requestToken(args) {
32
- const userToken = await IModelHost_1.IModelHost.getAccessToken();
33
- const response = await BlobContainerService_1.BlobContainer.service?.requestToken({ address: { id: args.containerId, baseUri: args.baseUri }, userToken, forWriteAccess: args.writeable });
33
+ // allow the userToken to be supplied via Rpc. If not supplied, or blank, use the backend's accessToken.
34
+ const userToken = args.userToken ? args.userToken : (await IModelHost_1.IModelHost.getAccessToken());
35
+ const response = await BlobContainerService_1.BlobContainer.service?.requestToken({ ...args, userToken });
34
36
  return response?.token ?? "";
35
37
  }
36
38
  CloudSqlite.requestToken = requestToken;
@@ -43,9 +45,10 @@ var CloudSqlite;
43
45
  function createCloudContainer(args) {
44
46
  const container = new imodeljs_native_1.NativeLibrary.nativeLib.CloudContainer(args);
45
47
  const refreshSeconds = (undefined !== args.tokenRefreshSeconds) ? args.tokenRefreshSeconds : 60 * 60; // default is 1 hour
48
+ container.lockExpireSeconds = args.lockExpireSeconds ?? 60 * 60; // default is 1 hour
46
49
  // don't refresh tokens for public containers or if refreshSeconds<=0
47
50
  if (!args.isPublic && refreshSeconds > 0) {
48
- const tokenProps = { baseUri: args.baseUri, storageType: args.storageType, containerId: args.containerId, writeable: args.writeable };
51
+ const tokenProps = { baseUri: args.baseUri, containerId: args.containerId, storageType: args.storageType, accessLevel: args.accessLevel };
49
52
  const doRefresh = async () => {
50
53
  let newToken;
51
54
  const url = `[${tokenProps.baseUri}/${tokenProps.containerId}]`;
@@ -159,15 +162,23 @@ var CloudSqlite;
159
162
  * @param busyHandler if present, function called when the write lock is currently held by another user.
160
163
  * @throws if [[container]] is not connected to a CloudCache.
161
164
  */
162
- async function acquireWriteLock(user, container, busyHandler) {
163
- if (container.hasWriteLock)
164
- return;
165
+ async function acquireWriteLock(args) {
166
+ const container = args.container;
165
167
  while (true) {
166
168
  try {
167
- return container.acquireWriteLock(user);
169
+ if (container.hasWriteLock) {
170
+ if (container.writeLockHeldBy === args.user)
171
+ return; // current user already has the lock
172
+ const err = new Error(); // lock held by another user within this process
173
+ err.errorNumber = 5;
174
+ err.lockedBy = container.writeLockHeldBy;
175
+ err.expires = container.writeLockExpires;
176
+ throw err;
177
+ }
178
+ return container.acquireWriteLock(args.user);
168
179
  }
169
180
  catch (e) {
170
- if (e.errorNumber === 5 && busyHandler && "stop" !== await busyHandler(e.lockedBy, e.expires)) // 5 === BE_SQLITE_BUSY
181
+ if (e.errorNumber === 5 && args.busyHandler && "stop" !== await args.busyHandler(e.lockedBy, e.expires)) // 5 === BE_SQLITE_BUSY
171
182
  continue; // busy handler wants to try again
172
183
  throw e;
173
184
  }
@@ -175,31 +186,34 @@ var CloudSqlite;
175
186
  }
176
187
  CloudSqlite.acquireWriteLock = acquireWriteLock;
177
188
  /**
178
- * Perform an asynchronous write operation on a CloudContainer with the write lock held.
179
- * 1. if write lock is already held, call operation and return.
180
- * 2. attempt to acquire the write lock, with retries. Throw if unable to obtain write lock.
181
- * 3. perform the operation
182
- * 3.a if the operation throws, abandon all changes and re-throw
183
- * 4. release the write lock.
184
- * 5. return value from operation
185
- * @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
186
- * @param container the CloudContainer for which the lock is to be acquired
187
- * @param operation an asynchronous operation performed with the write lock held.
188
- * @param busyHandler if present, function called when the write lock is currently held by another user.
189
- * @returns a Promise with the result of `operation`
190
- */
191
- async function withWriteLock(user, container, operation, busyHandler) {
192
- if (container.hasWriteLock)
193
- return operation();
194
- await acquireWriteLock(user, container, busyHandler);
189
+ * Perform an asynchronous write operation on a CloudContainer with the write lock held.
190
+ * 1. if write lock is already held by the current user, call operation and return.
191
+ * 2. attempt to acquire the write lock, with retries. Throw if unable to obtain write lock.
192
+ * 3. perform the operation
193
+ * 3.a if the operation throws, abandon all changes and re-throw
194
+ * 4. release the write lock.
195
+ * 5. return value from operation
196
+ * @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
197
+ * @param container the CloudContainer for which the lock is to be acquired
198
+ * @param operation an asynchronous operation performed with the write lock held.
199
+ * @param busyHandler if present, function called when the write lock is currently held by another user.
200
+ * @returns a Promise with the result of `operation`
201
+ */
202
+ async function withWriteLock(args, operation) {
203
+ await acquireWriteLock(args);
195
204
  try {
205
+ const containerInternal = args.container;
206
+ containerInternal.writeLockHeldBy = args.user;
207
+ containerInternal.writeLockExpires = new Date(Date.now() + 1000 * containerInternal.lockExpireSeconds).toLocaleString();
196
208
  // eslint-disable-next-line @typescript-eslint/await-thenable
197
209
  const val = await operation(); // wait for work to finish or fail
198
- container.releaseWriteLock();
210
+ containerInternal.releaseWriteLock();
211
+ containerInternal.writeLockHeldBy = undefined;
212
+ containerInternal.writeLockExpires = undefined;
199
213
  return val;
200
214
  }
201
215
  catch (e) {
202
- container.abandonChanges(); // if operation threw, abandon all changes
216
+ args.container.abandonChanges(); // if operation threw, abandon all changes
203
217
  throw e;
204
218
  }
205
219
  }
@@ -281,14 +295,14 @@ var CloudSqlite;
281
295
  constructor(args) {
282
296
  /** Parameters for obtaining the write lock for this container. */
283
297
  this.lockParams = {
284
- moniker: "",
298
+ user: "",
285
299
  nRetries: 20,
286
300
  retryDelayMs: 100,
287
301
  };
288
302
  this._container = createCloudContainer({ writeable: true, ...args.props });
289
303
  this._cloudDb = new args.dbType(args.props);
290
304
  this.dbName = args.dbName;
291
- this.lockParams.moniker = IModelHost_1.IModelHost.userMoniker;
305
+ this.lockParams.user = IModelHost_1.IModelHost.userMoniker;
292
306
  }
293
307
  /** Close the database for this DbAccess, if it is open */
294
308
  closeDb() {
@@ -301,15 +315,15 @@ var CloudSqlite;
301
315
  this._container.disconnect();
302
316
  }
303
317
  /**
304
- * Initialize a cloud container to hold a Cloud SQliteDb. The container must first be created via its storage supplier api (e.g. Azure, or AWS).
318
+ * Initialize a cloud container to hold a Cloud SQliteDb. The container must first be created via its storage supplier api (e.g. Azure, or Google).
305
319
  * A valid sasToken that grants write access must be supplied. This function creates and uploads an empty database into the container.
306
320
  * @note this deletes any existing content in the container.
307
321
  */
308
322
  static async _initializeDb(args) {
309
323
  const container = createCloudContainer({ ...args.props, writeable: true });
310
- container.initializeContainer({ blockSize: args.blockSize ?? 64 * 1024 });
324
+ container.initializeContainer({ blockSize: args.blockSize === "4M" ? 4 * 1024 * 1024 : 64 * 1024 });
311
325
  container.connect(CloudCaches.getCache({ cacheName: this._cacheName }));
312
- await withWriteLock("initialize", container, async () => {
326
+ await withWriteLock({ user: "initialize", container }, async () => {
313
327
  const localFileName = (0, path_1.join)(IModelHost_1.KnownLocations.tmpdir, "blank.db");
314
328
  args.dbType.createNewDb(localFileName);
315
329
  await transferDb("upload", container, { dbName: args.dbName, localFileName });
@@ -347,10 +361,10 @@ var CloudSqlite;
347
361
  * @note Most uses of `CloudSqliteDbAccess` require that the lock not be held by any operation for long. Make sure you don't
348
362
  * do any avoidable or time consuming work in your operation function.
349
363
  */
350
- async withLockedDb(operationName, operation) {
364
+ async withLockedDb(args, operation) {
351
365
  let nRetries = this.lockParams.nRetries;
352
366
  const cacheGuid = this.container.cache.guid; // eslint-disable-line @typescript-eslint/no-non-null-assertion
353
- const moniker = this.lockParams.moniker ?? cacheGuid;
367
+ const user = args.user ?? this.lockParams.user ?? cacheGuid;
354
368
  const timer = new core_bentley_1.StopWatch(undefined, true);
355
369
  const showMs = () => `(${timer.elapsed.milliseconds}ms)`;
356
370
  const busyHandler = async (lockedBy, expires) => {
@@ -365,8 +379,9 @@ var CloudSqlite;
365
379
  };
366
380
  this.closeDb(); // in case it is currently open for read.
367
381
  let lockObtained = false;
382
+ const operationName = args.operationName;
368
383
  try {
369
- return await this._cloudDb.withLockedContainer({ moniker, dbName: this.dbName, container: this.container, busyHandler }, async () => {
384
+ return await this._cloudDb.withLockedContainer({ user, dbName: this.dbName, container: this.container, busyHandler }, async () => {
370
385
  lockObtained = true;
371
386
  logInfo(`lock acquired by ${cacheGuid} for ${operationName} ${showMs()}`);
372
387
  return operation();
@@ -401,9 +416,9 @@ var CloudSqlite;
401
416
  */
402
417
  get writeLocker() {
403
418
  return this._writeLockProxy ??= new Proxy(this, {
404
- get(access, methodName) {
405
- const fn = access.getDbMethod(methodName);
406
- return async (...args) => access.withLockedDb(methodName, fn.bind(access._cloudDb, ...args));
419
+ get(access, operationName) {
420
+ const fn = access.getDbMethod(operationName);
421
+ return async (...args) => access.withLockedDb({ operationName, user: tracing_1.RpcTrace.currentActivity?.user }, fn.bind(access._cloudDb, ...args));
407
422
  },
408
423
  });
409
424
  }