@itwin/core-backend 3.6.0-dev.36 → 3.6.0-dev.38

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 (243) hide show
  1. package/lib/cjs/AliCloudStorageService.d.ts +23 -23
  2. package/lib/cjs/AliCloudStorageService.js +71 -71
  3. package/lib/cjs/AliCloudStorageService.js.map +1 -1
  4. package/lib/cjs/BackendHubAccess.d.ts +224 -224
  5. package/lib/cjs/BackendHubAccess.js +41 -41
  6. package/lib/cjs/BackendHubAccess.js.map +1 -1
  7. package/lib/cjs/BackendLoggerCategory.d.ts +91 -91
  8. package/lib/cjs/BackendLoggerCategory.js +99 -99
  9. package/lib/cjs/BackendLoggerCategory.js.map +1 -1
  10. package/lib/cjs/BisCoreSchema.d.ts +21 -21
  11. package/lib/cjs/BisCoreSchema.js +60 -60
  12. package/lib/cjs/BisCoreSchema.js.map +1 -1
  13. package/lib/cjs/BriefcaseManager.d.ts +170 -170
  14. package/lib/cjs/BriefcaseManager.js +413 -413
  15. package/lib/cjs/BriefcaseManager.js.map +1 -1
  16. package/lib/cjs/Category.d.ts +153 -153
  17. package/lib/cjs/Category.js +243 -243
  18. package/lib/cjs/Category.js.map +1 -1
  19. package/lib/cjs/ChangeSummaryManager.d.ts +187 -187
  20. package/lib/cjs/ChangeSummaryManager.js +447 -447
  21. package/lib/cjs/ChangeSummaryManager.js.map +1 -1
  22. package/lib/cjs/ChangedElementsDb.d.ts +99 -99
  23. package/lib/cjs/ChangedElementsDb.js +165 -165
  24. package/lib/cjs/ChangedElementsDb.js.map +1 -1
  25. package/lib/cjs/ChangedElementsManager.d.ts +39 -39
  26. package/lib/cjs/ChangedElementsManager.js +88 -88
  27. package/lib/cjs/ChangedElementsManager.js.map +1 -1
  28. package/lib/cjs/CheckpointManager.d.ts +122 -122
  29. package/lib/cjs/CheckpointManager.js +343 -343
  30. package/lib/cjs/CheckpointManager.js.map +1 -1
  31. package/lib/cjs/ClassRegistry.d.ts +79 -79
  32. package/lib/cjs/ClassRegistry.js +249 -249
  33. package/lib/cjs/ClassRegistry.js.map +1 -1
  34. package/lib/cjs/CloudSqlite.d.ts +350 -350
  35. package/lib/cjs/CloudSqlite.js +153 -153
  36. package/lib/cjs/CloudSqlite.js.map +1 -1
  37. package/lib/cjs/CloudStorageBackend.d.ts +58 -58
  38. package/lib/cjs/CloudStorageBackend.js +173 -173
  39. package/lib/cjs/CloudStorageBackend.js.map +1 -1
  40. package/lib/cjs/CodeService.d.ts +396 -396
  41. package/lib/cjs/CodeService.js +63 -63
  42. package/lib/cjs/CodeService.js.map +1 -1
  43. package/lib/cjs/CodeSpecs.d.ts +50 -50
  44. package/lib/cjs/CodeSpecs.js +112 -112
  45. package/lib/cjs/CodeSpecs.js.map +1 -1
  46. package/lib/cjs/ConcurrentQuery.d.ts +13 -13
  47. package/lib/cjs/ConcurrentQuery.js +36 -36
  48. package/lib/cjs/ConcurrentQuery.js.map +1 -1
  49. package/lib/cjs/CustomViewState3dCreator.d.ts +21 -21
  50. package/lib/cjs/CustomViewState3dCreator.js +81 -81
  51. package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
  52. package/lib/cjs/DevTools.d.ts +71 -71
  53. package/lib/cjs/DevTools.js +154 -154
  54. package/lib/cjs/DevTools.js.map +1 -1
  55. package/lib/cjs/DisplayStyle.d.ts +106 -106
  56. package/lib/cjs/DisplayStyle.js +256 -256
  57. package/lib/cjs/DisplayStyle.js.map +1 -1
  58. package/lib/cjs/ECDb.d.ts +191 -191
  59. package/lib/cjs/ECDb.js +350 -350
  60. package/lib/cjs/ECDb.js.map +1 -1
  61. package/lib/cjs/ECSchemaXmlContext.d.ts +18 -18
  62. package/lib/cjs/ECSchemaXmlContext.js +41 -41
  63. package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
  64. package/lib/cjs/ECSqlStatement.d.ts +473 -473
  65. package/lib/cjs/ECSqlStatement.js +791 -791
  66. package/lib/cjs/ECSqlStatement.js.map +1 -1
  67. package/lib/cjs/Element.d.ts +1102 -1102
  68. package/lib/cjs/Element.js +1416 -1416
  69. package/lib/cjs/Element.js.map +1 -1
  70. package/lib/cjs/ElementAspect.d.ts +176 -176
  71. package/lib/cjs/ElementAspect.js +211 -211
  72. package/lib/cjs/ElementAspect.js.map +1 -1
  73. package/lib/cjs/ElementGraphics.d.ts +9 -9
  74. package/lib/cjs/ElementGraphics.js +41 -41
  75. package/lib/cjs/ElementGraphics.js.map +1 -1
  76. package/lib/cjs/ElementTreeWalker.d.ts +162 -162
  77. package/lib/cjs/ElementTreeWalker.js +409 -409
  78. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  79. package/lib/cjs/Entity.d.ts +106 -106
  80. package/lib/cjs/Entity.js +134 -134
  81. package/lib/cjs/Entity.js.map +1 -1
  82. package/lib/cjs/EntityReferences.d.ts +49 -49
  83. package/lib/cjs/EntityReferences.js +95 -95
  84. package/lib/cjs/EntityReferences.js.map +1 -1
  85. package/lib/cjs/ExportGraphics.d.ts +317 -317
  86. package/lib/cjs/ExportGraphics.js +208 -208
  87. package/lib/cjs/ExportGraphics.js.map +1 -1
  88. package/lib/cjs/ExternalSource.d.ts +96 -96
  89. package/lib/cjs/ExternalSource.js +131 -131
  90. package/lib/cjs/ExternalSource.js.map +1 -1
  91. package/lib/cjs/GeoCoordConfig.d.ts +19 -19
  92. package/lib/cjs/GeoCoordConfig.js +85 -85
  93. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  94. package/lib/cjs/GeometrySummary.d.ts +4 -4
  95. package/lib/cjs/GeometrySummary.js +380 -380
  96. package/lib/cjs/GeometrySummary.js.map +1 -1
  97. package/lib/cjs/HubMock.d.ts +94 -94
  98. package/lib/cjs/HubMock.js +222 -222
  99. package/lib/cjs/HubMock.js.map +1 -1
  100. package/lib/cjs/IModelCloneContext.d.ts +8 -8
  101. package/lib/cjs/IModelCloneContext.js +15 -15
  102. package/lib/cjs/IModelCloneContext.js.map +1 -1
  103. package/lib/cjs/IModelDb.d.ts +1183 -1183
  104. package/lib/cjs/IModelDb.js +2374 -2374
  105. package/lib/cjs/IModelDb.js.map +1 -1
  106. package/lib/cjs/IModelElementCloneContext.d.ts +89 -89
  107. package/lib/cjs/IModelElementCloneContext.js +159 -159
  108. package/lib/cjs/IModelElementCloneContext.js.map +1 -1
  109. package/lib/cjs/IModelHost.d.ts +370 -370
  110. package/lib/cjs/IModelHost.js +496 -496
  111. package/lib/cjs/IModelHost.js.map +1 -1
  112. package/lib/cjs/IModelJsFs.d.ts +62 -62
  113. package/lib/cjs/IModelJsFs.js +140 -140
  114. package/lib/cjs/IModelJsFs.js.map +1 -1
  115. package/lib/cjs/IpcHost.d.ts +104 -104
  116. package/lib/cjs/IpcHost.js +278 -278
  117. package/lib/cjs/IpcHost.js.map +1 -1
  118. package/lib/cjs/LineStyle.d.ts +311 -311
  119. package/lib/cjs/LineStyle.js +295 -295
  120. package/lib/cjs/LineStyle.js.map +1 -1
  121. package/lib/cjs/LocalHub.d.ts +162 -162
  122. package/lib/cjs/LocalHub.js +587 -587
  123. package/lib/cjs/LocalHub.js.map +1 -1
  124. package/lib/cjs/LocalhostIpcHost.d.ts +20 -20
  125. package/lib/cjs/LocalhostIpcHost.js +81 -81
  126. package/lib/cjs/LocalhostIpcHost.js.map +1 -1
  127. package/lib/cjs/Material.d.ts +103 -103
  128. package/lib/cjs/Material.js +147 -147
  129. package/lib/cjs/Material.js.map +1 -1
  130. package/lib/cjs/Model.d.ts +392 -392
  131. package/lib/cjs/Model.js +485 -485
  132. package/lib/cjs/Model.js.map +1 -1
  133. package/lib/cjs/NativeAppStorage.d.ts +51 -51
  134. package/lib/cjs/NativeAppStorage.js +202 -202
  135. package/lib/cjs/NativeAppStorage.js.map +1 -1
  136. package/lib/cjs/NativeHost.d.ts +52 -52
  137. package/lib/cjs/NativeHost.js +163 -163
  138. package/lib/cjs/NativeHost.js.map +1 -1
  139. package/lib/cjs/NavigationRelationship.d.ts +156 -156
  140. package/lib/cjs/NavigationRelationship.js +225 -225
  141. package/lib/cjs/NavigationRelationship.js.map +1 -1
  142. package/lib/cjs/PromiseMemoizer.d.ts +51 -51
  143. package/lib/cjs/PromiseMemoizer.js +101 -101
  144. package/lib/cjs/PromiseMemoizer.js.map +1 -1
  145. package/lib/cjs/PropertyStore.d.ts +132 -132
  146. package/lib/cjs/PropertyStore.js +11 -11
  147. package/lib/cjs/PropertyStore.js.map +1 -1
  148. package/lib/cjs/Relationship.d.ts +416 -416
  149. package/lib/cjs/Relationship.js +494 -494
  150. package/lib/cjs/Relationship.js.map +1 -1
  151. package/lib/cjs/RpcBackend.d.ts +5 -5
  152. package/lib/cjs/RpcBackend.js +31 -31
  153. package/lib/cjs/RpcBackend.js.map +1 -1
  154. package/lib/cjs/SQLiteDb.d.ts +219 -219
  155. package/lib/cjs/SQLiteDb.js +214 -214
  156. package/lib/cjs/SQLiteDb.js.map +1 -1
  157. package/lib/cjs/Schema.d.ts +55 -55
  158. package/lib/cjs/Schema.js +83 -83
  159. package/lib/cjs/Schema.js.map +1 -1
  160. package/lib/cjs/ServerBasedLocks.d.ts +57 -57
  161. package/lib/cjs/ServerBasedLocks.js +168 -168
  162. package/lib/cjs/ServerBasedLocks.js.map +1 -1
  163. package/lib/cjs/SqliteStatement.d.ts +360 -360
  164. package/lib/cjs/SqliteStatement.js +586 -586
  165. package/lib/cjs/SqliteStatement.js.map +1 -1
  166. package/lib/cjs/Texture.d.ts +58 -58
  167. package/lib/cjs/Texture.js +82 -82
  168. package/lib/cjs/Texture.js.map +1 -1
  169. package/lib/cjs/TileStorage.d.ts +18 -18
  170. package/lib/cjs/TileStorage.js +90 -90
  171. package/lib/cjs/TileStorage.js.map +1 -1
  172. package/lib/cjs/TxnManager.d.ts +202 -202
  173. package/lib/cjs/TxnManager.js +356 -356
  174. package/lib/cjs/TxnManager.js.map +1 -1
  175. package/lib/cjs/ViewDefinition.d.ts +439 -439
  176. package/lib/cjs/ViewDefinition.js +646 -646
  177. package/lib/cjs/ViewDefinition.js.map +1 -1
  178. package/lib/cjs/ViewStateHydrator.d.ts +13 -13
  179. package/lib/cjs/ViewStateHydrator.js +103 -103
  180. package/lib/cjs/ViewStateHydrator.js.map +1 -1
  181. package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
  182. package/lib/cjs/assets/Settings/Schemas/Cloud.Schema.json +67 -67
  183. package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +31 -31
  184. package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +52 -52
  185. package/lib/cjs/assets/Settings/backend.setting.json5 +138 -138
  186. package/lib/cjs/core-backend.d.ts +184 -184
  187. package/lib/cjs/core-backend.js +204 -204
  188. package/lib/cjs/core-backend.js.map +1 -1
  189. package/lib/cjs/domains/FunctionalElements.d.ts +101 -101
  190. package/lib/cjs/domains/FunctionalElements.js +145 -145
  191. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  192. package/lib/cjs/domains/FunctionalSchema.d.ts +13 -13
  193. package/lib/cjs/domains/FunctionalSchema.js +40 -40
  194. package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
  195. package/lib/cjs/domains/GenericElements.d.ts +177 -177
  196. package/lib/cjs/domains/GenericElements.js +263 -263
  197. package/lib/cjs/domains/GenericElements.js.map +1 -1
  198. package/lib/cjs/domains/GenericSchema.d.ts +10 -10
  199. package/lib/cjs/domains/GenericSchema.js +28 -28
  200. package/lib/cjs/domains/GenericSchema.js.map +1 -1
  201. package/lib/cjs/rpc/multipart.d.ts +11 -11
  202. package/lib/cjs/rpc/multipart.js +70 -70
  203. package/lib/cjs/rpc/multipart.js.map +1 -1
  204. package/lib/cjs/rpc/tracing.d.ts +28 -28
  205. package/lib/cjs/rpc/tracing.js +73 -73
  206. package/lib/cjs/rpc/tracing.js.map +1 -1
  207. package/lib/cjs/rpc/web/logging.d.ts +9 -9
  208. package/lib/cjs/rpc/web/logging.js +42 -42
  209. package/lib/cjs/rpc/web/logging.js.map +1 -1
  210. package/lib/cjs/rpc/web/request.d.ts +6 -6
  211. package/lib/cjs/rpc/web/request.js +73 -73
  212. package/lib/cjs/rpc/web/request.js.map +1 -1
  213. package/lib/cjs/rpc/web/response.d.ts +6 -6
  214. package/lib/cjs/rpc/web/response.js +105 -105
  215. package/lib/cjs/rpc/web/response.js.map +1 -1
  216. package/lib/cjs/rpc-impl/DevToolsRpcImpl.d.ts +15 -15
  217. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js +32 -32
  218. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
  219. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +47 -47
  220. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +291 -291
  221. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  222. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts +22 -22
  223. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +202 -202
  224. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  225. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +36 -36
  226. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +168 -168
  227. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  228. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.d.ts +16 -16
  229. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js +43 -43
  230. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  231. package/lib/cjs/rpc-impl/WipRpcImpl.d.ts +15 -15
  232. package/lib/cjs/rpc-impl/WipRpcImpl.js +37 -37
  233. package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -1
  234. package/lib/cjs/workspace/Settings.d.ts +186 -186
  235. package/lib/cjs/workspace/Settings.js +155 -155
  236. package/lib/cjs/workspace/Settings.js.map +1 -1
  237. package/lib/cjs/workspace/SettingsSchemas.d.ts +75 -75
  238. package/lib/cjs/workspace/SettingsSchemas.js +191 -191
  239. package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
  240. package/lib/cjs/workspace/Workspace.d.ts +414 -414
  241. package/lib/cjs/workspace/Workspace.js +543 -543
  242. package/lib/cjs/workspace/Workspace.js.map +1 -1
  243. package/package.json +12 -12
@@ -1,351 +1,351 @@
1
- /** @packageDocumentation
2
- * @module SQLiteDb
3
- */
4
- import { GuidString } from "@itwin/core-bentley";
5
- import { LocalDirName, LocalFileName } from "@itwin/core-common";
6
- /** Types for using SQLite files stored in cloud containers.
7
- * @beta
8
- */
9
- export declare namespace CloudSqlite {
10
- function createCloudContainer(args: ContainerAccessProps): CloudContainer;
11
- function createCloudCache(args: CloudSqlite.CacheProps): CloudSqlite.CloudCache;
12
- function startCloudPrefetch(container: CloudSqlite.CloudContainer, dbName: string, args?: CloudSqlite.PrefetchProps): CloudSqlite.CloudPrefetch;
13
- /** Properties that specify how to access the account for a cloud blob-store container. */
14
- interface AccountAccessProps {
15
- /** blob storage module: e.g. "azure", "google", "aws". May also include URI style parameters. */
16
- storageType: string;
17
- /** blob store account name, or a URI for custom domains. */
18
- accessName: string;
19
- }
20
- /** Properties of a CloudContainer. */
21
- interface ContainerProps {
22
- /** the name of the container. */
23
- containerId: string;
24
- /** an alias for the container. Defaults to `containerId` */
25
- alias?: string;
26
- /** token that grants access to the container. For sas=1 `storageType`s, this is the sasToken. For sas=0, this is the account key */
27
- accessToken: string;
28
- /** if true, container is attached with write permissions, and accessToken must provide write access to the cloud container. */
29
- writeable?: boolean;
30
- /** if true, container is attached in "secure" mode (blocks are encrypted). Only supported in daemon mode. */
31
- secure?: boolean;
32
- }
33
- /** Returned from `CloudContainer.queryDatabase` describing one database in the container */
34
- interface CachedDbProps {
35
- /** The total of (4Mb) blocks in the database. */
36
- readonly totalBlocks: number;
37
- /** the number of blocks of the database that have been downloaded into the CloudCache */
38
- readonly localBlocks: number;
39
- /** the number of blocks from this database that have been modified in the CloudCache and need to be uploaded. */
40
- readonly dirtyBlocks: number;
41
- /** If true, the database currently has transactions in the WAL file and may not be uploaded until they have been checkPointed. */
42
- readonly transactions: boolean;
43
- /** the state of this database. Indicates whether the database is new or deleted since last upload */
44
- readonly state: "" | "copied" | "deleted";
45
- }
46
- /** Properties for accessing a CloudContainer */
47
- type ContainerAccessProps = AccountAccessProps & ContainerProps & {
48
- /** Duration for holding write lock, in seconds. After this time the write lock expires if not refreshed. Default is one hour. */
49
- durationSeconds?: number;
50
- };
51
- /** The name of a CloudSqlite database within a CloudContainer. */
52
- interface DbNameProp {
53
- /** the name of the database within the CloudContainer.
54
- * @note names of databases within a CloudContainer are always **case sensitive** on all platforms.*/
55
- dbName: string;
56
- }
57
- /** Properties for accessing a database within a CloudContainer */
58
- interface DbProps extends DbNameProp {
59
- /** the name of the local file to access the database. */
60
- localFileName: LocalFileName;
61
- }
62
- type TransferDirection = "upload" | "download";
63
- interface TransferProgress {
64
- /** a user-supplied progress function called during the transfer operation. Return a non-0 value to abort the transfer. */
65
- onProgress?: (loaded: number, total: number) => number;
66
- }
67
- interface CloudHttpProps {
68
- /** The number of simultaneous HTTP requests. Default is 6. */
69
- nRequests?: number;
70
- }
71
- interface PrefetchProps extends CloudHttpProps {
72
- /** timeout between requests, in milliseconds. Default is 100. */
73
- timeout?: number;
74
- /** The number of prefetch requests to issue while there is foreground activity. Default is 3. */
75
- minRequests?: number;
76
- }
77
- type TransferDbProps = DbProps & TransferProgress & CloudHttpProps;
78
- /** Properties for creating a CloudCache. */
79
- interface CacheProps extends CloudHttpProps {
80
- /** 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. */
81
- rootDir: string;
82
- /** name of this cache. It is possible to have more than one CloudCache in the same session. */
83
- name: string;
84
- /** maximum cache Size. Must be a number followed by either M (for megabytes) or G (for gigabytes.) Default is 1G */
85
- cacheSize?: string;
86
- /** turn on diagnostics for `curl` (outputs to stderr) */
87
- curlDiagnostics?: boolean;
88
- }
89
- /** Parameters used to obtain the write lock on a cloud container
90
- * @internal
91
- */
92
- interface ObtainLockParams {
93
- /** The name of the user attempting to acquire the write lock. This name will be shown to other users while the lock is held. */
94
- user?: string;
95
- /** number of times to retry in the event the lock currently held by someone else.
96
- * After this number of attempts, `onFailure` is called. Default is 20.
97
- */
98
- nRetries: number;
99
- /** Delay between retries, in milliseconds. Default is 100. */
100
- retryDelayMs: number;
101
- /** function called if lock cannot be obtained after all retries. It is called with the name of the user currently holding the lock and
102
- * generally is expected that the user will be consulted whether to wait further.
103
- * If this function returns "stop", an exception will be thrown. Otherwise the retry cycle is restarted.
104
- */
105
- onFailure?: WriteLockBusyHandler;
106
- }
107
- /** @internal */
108
- interface LockAndOpenArgs {
109
- /** the name to be displayed in the event of lock collisions */
110
- user: string;
111
- /** the name of the database within the container */
112
- dbName: string;
113
- /** the CloudContainer on which the operation will be performed */
114
- container: CloudContainer;
115
- /** if present, function called when the write lock is currently held by another user. */
116
- busyHandler?: WriteLockBusyHandler;
117
- }
118
- /** Logging categories for `CloudCache.setLogMask` */
119
- enum LoggingMask {
120
- /** log all HTTP requests and responses */
121
- HTTP = 1,
122
- /** log as blocks become dirty and must be uploaded */
123
- DirtyBlocks = 2,
124
- /** log as blocks are added to the delete list */
125
- AddToDelete = 4,
126
- /** log container lifecycle events (e.g. authorization requests, disconnects, and state transitions) */
127
- LifecycleEvents = 8,
128
- /** Turn on all logging categories */
129
- All = 255,
130
- /** Disable logging */
131
- None = 0
132
- }
133
- /**
134
- * A cache for storing data from CloudSqlite databases. This object refers to a directory on a local filesystem
135
- * and is used to **connect** CloudContainers so they may be accessed. The contents of the cache directory are entirely
136
- * controlled by CloudSqlite and should be empty when the cache is first created and never modified directly. It maintains
137
- * the state of the local data across sessions.
138
- */
139
- interface CloudCache {
140
- /** `true` if this CloudCache is connected to a daemon process */
141
- get isDaemon(): boolean;
142
- /** The name for this CloudCache. */
143
- get name(): string;
144
- /** The root directory of this CloudCache on a local drive. */
145
- get rootDir(): LocalDirName;
146
- /** The guid for this CloudCache. Used for acquiring write lock. */
147
- get guid(): GuidString;
148
- /** Configure logging for this CloudCache.
149
- * @param mask A bitmask of `LoggingMask` values
150
- * @note this method does nothing if [[isDaemon]] is true. Daemon logging is configured when the daemon is started.
151
- * @note HTTP logging can be happen on multiple threads and may be buffered. To see buffered log messages, periodically call
152
- * `IModelHost.flushLog`
153
- */
154
- setLogMask(mask: number): void;
155
- /** destroy this CloudCache. All CloudContainers should be detached before calling this. */
156
- destroy(): void;
157
- }
158
- /** A CloudSqlite container that may be connected to a CloudCache. */
159
- interface CloudContainer {
160
- readonly cache?: CloudCache;
161
- /** The ContainerId. */
162
- get containerId(): string;
163
- /** The *alias* to identify this CloudContainer in a CloudCache. Usually just the ContainerId. */
164
- get alias(): string;
165
- /** true if this CloudContainer is currently connected to a CloudCache via the `connect` method. */
166
- get isConnected(): boolean;
167
- /** true if this CloudContainer was created with the `writeable` flag (and its `accessToken` supplies write access). */
168
- get isWriteable(): boolean;
169
- /** true if this CloudContainer currently holds the write lock for its container in the cloud. */
170
- get hasWriteLock(): boolean;
171
- /** true if this CloudContainer has local changes that have not be uploaded to its container in the cloud. */
172
- get hasLocalChanges(): boolean;
173
- /** The current accessToken providing access to the cloud container */
174
- get accessToken(): string;
175
- set accessToken(val: string);
176
- /** Get the number of garbage blocks in this container that can be purged. */
177
- get garbageBlocks(): number;
178
- /** The block size for this CloudContainer. */
179
- get blockSize(): number;
180
- /**
181
- * initialize a cloud blob-store container to be used as a new Sqlite CloudContainer. This creates the manifest, and should be
182
- * performed on an empty container. If an existing manifest is present, it is destroyed and a new one is created (essentially emptying the container.)
183
- */
184
- initializeContainer(opts?: {
185
- checksumBlockNames?: boolean;
186
- blockSize?: number;
187
- }): void;
188
- /**
189
- * Attempt to acquire the write lock for this CloudContainer. For this to succeed:
190
- * 1. it must be connected to a `CloudCache`
191
- * 2. this CloudContainer must have been constructed with `writeable: true`
192
- * 3. the `accessToken` must authorize write access
193
- * 4. no other process may be holding an unexpired write lock
194
- * @throws exception if any of the above conditions fail
195
- * @note Write locks *expire* after the duration specified in the `durationSeconds` property of the constructor argument, in case a process
196
- * crashes or otherwise fails to release the lock. Calling `acquireWriteLock` with the lock already held resets the lock duration from the current time,
197
- * 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
198
- * before it expires.)
199
- * @note on success, the manifest is polled before the promise resolves.
200
- * @param user An identifier of the process/user locking the CloudContainer. In the event of a write lock
201
- * collision, this string will be included in the exception string of the *other* process attempting to obtain a write lock.
202
- */
203
- acquireWriteLock(user: string): void;
204
- /**
205
- * Release the write lock if it is currently held.
206
- * @note if there are local changes that have not been uploaded, they are automatically uploaded before the write lock is released.
207
- * @note if the write lock is not held, this method does nothing.
208
- */
209
- releaseWriteLock(): void;
210
- /**
211
- * Destroy any currently valid write lock from this or any other process. This is obviously very dangerous and defeats the purpose of write locking.
212
- * 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.
213
- * For this to succeed, all of the conditions of `acquireWriteLock` must be true other than #4.
214
- */
215
- clearWriteLock(): void;
216
- /**
217
- * Abandon any local changes in this container. If the write lock is currently held, it is released.
218
- * This function fails with BE_SQLITE_BUSY if one or more clients have open read or write transactions
219
- * on any database in the container.
220
- */
221
- abandonChanges(): void;
222
- /**
223
- * Connect this CloudContainer to a CloudCache for reading or writing its manifest, write lock, and databases.
224
- * @note A CloudCache is a local directory holding copies of information from the cloud. Its content is persistent across sessions,
225
- * but this method must be called each session to (re)establish the connection to the cache. If the CloudCache was previously populated,
226
- * this method may be called and will succeed *even when offline* or without a valid `accessToken`.
227
- * @note all operations that access the contents of databases or the manifest require this method be called (`isConnected === true`).
228
- */
229
- connect(cache: CloudCache): void;
230
- /**
231
- * Disconnect this CloudContainer from its CloudCache. There must be no open databases from this container. Leaves the container attached to the
232
- * CloudCache so it is available for future sessions.
233
- */
234
- disconnect(): void;
235
- /**
236
- * Permanently Detach and Disconnect this CloudContainer from its CloudCache. There must be no open databases from this container.
237
- */
238
- detach(): void;
239
- /**
240
- * Poll cloud storage for changes from other processes. *No changes* made by other processes are visible to
241
- * this CloudContainer unless/until this method is called.
242
- * @note this is automatically called whenever the write lock is obtained to ensure all changes are against the latest version.
243
- */
244
- checkForChanges(): void;
245
- /**
246
- * Upload any changed blocks from all databases in this CloudContainer.
247
- * @note this is called automatically from `releaseWriteLock` before the write lock is released. It is only necessary to call this directly if you
248
- * wish to upload changes while the write lock is still held.
249
- * @see hasLocalChanges
250
- */
251
- uploadChanges(): Promise<void>;
252
- /**
253
- * Clean any unused deleted blocks from cloud storage. When a database is written, a subset of its blocks are replaced
254
- * by new versions, sometimes leaving the originals unused. In this case, they are not deleted immediately.
255
- * Instead, they are scheduled for deletion at some later time. Calling this method deletes all blocks in the cloud container
256
- * for which the scheduled deletion time has passed.
257
- * @param nSeconds Any block that was marked as unused before this number of seconds ago will be deleted. Specifying a non-zero
258
- * value gives a period of time for other clients to refresh their manifests and stop using the now-garbage blocks. Otherwise they may get
259
- * a 404 error. Default is 1 hour.
260
- */
261
- cleanDeletedBlocks(nSeconds?: number): Promise<void>;
262
- /**
263
- * Create a copy of an existing database within this CloudContainer with a new name.
264
- * @note CloudSqlite uses copy-on-write semantics for this operation. That is, this method merely makes a
265
- * new entry in the manifest with the new name that *shares* all of its blocks with the original database.
266
- * If either database subsequently changes, the only modified blocks are not shared.
267
- */
268
- copyDatabase(dbName: string, toAlias: string): Promise<void>;
269
- /** Remove a database from this CloudContainer.
270
- * @see cleanDeletedBlocks
271
- */
272
- deleteDatabase(dbName: string): Promise<void>;
273
- /** Get the list of database names in this CloudContainer.
274
- * @param globArg if present, filter the results with SQLite [GLOB](https://www.sqlite.org/lang_expr.html#glob) operator.
275
- */
276
- queryDatabases(globArg?: string): string[];
277
- /**
278
- * Get the status of a specific database in this CloudContainer.
279
- * @param dbName the name of the database of interest
280
- */
281
- queryDatabase(dbName: string): CloudSqlite.CachedDbProps | undefined;
282
- /**
283
- * Get the SHA1 hash of the content of a database.
284
- * @param dbName the name of the database of interest
285
- * @note the hash will be empty if the database does not exist
286
- */
287
- queryDatabaseHash(dbName: string): string;
288
- }
289
- /** @internal */
290
- interface CloudPrefetch {
291
- readonly cloudContainer: CloudContainer;
292
- readonly dbName: string;
293
- /** Cancel a currently pending prefetch. The promise will be resolved immediately after this call. */
294
- cancel(): void;
295
- /**
296
- * Promise that is resolved when the prefetch completes or is cancelled. Await this promise to ensure that the
297
- * database has been fully downloaded before going offline, for example.
298
- * @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.
299
- * @note the promise is *not* rejected on `cancel`. Some progress may (or may not) have been made by the request.
300
- * @note To monitor the progress being made during prefetch, call `CloudContainer.queryDatabase` periodically.
301
- */
302
- promise: Promise<boolean>;
303
- }
304
- /** @internal */
305
- function transferDb(direction: TransferDirection, container: CloudContainer, props: TransferDbProps): Promise<void>;
306
- /** Upload a database into a CloudContainer
307
- * @param container the CloudContainer holding the database. Must be connected.
308
- * @param props the properties that describe the database to be downloaded, plus optionally an `onProgress` function.
309
- * @note this function requires that the write lock be held on the container
310
- */
311
- function uploadDb(container: CloudContainer, props: TransferDbProps): Promise<void>;
312
- /** Download a database from a CloudContainer
313
- * @param container the CloudContainer holding the database. Must be connected.
314
- * @param props the properties that describe the database to be downloaded, plus optionally an `onProgress` function.
315
- * @returns a Promise that is resolved when the download completes.
316
- * @note the download is "restartable." If the transfer is aborted and then re-requested, it will continue from where
317
- * it left off rather than re-downloading the entire file.
318
- */
319
- function downloadDb(container: CloudContainer, props: TransferDbProps): Promise<void>;
320
- /** Optional method to be called when an attempt to acquire the write lock fails because another user currently holds it.
321
- * @param lockedBy The identifier supplied by the application/user that currently holds the lock.
322
- * @param expires a stringified Date (in local time) indicating when the lock will expire.
323
- * @return "stop" to give up and stop retrying. Generally, it's a good idea to wait for some time before returning.
324
- */
325
- type WriteLockBusyHandler = (lockedBy: string, expires: string) => Promise<void | "stop">;
326
- /**
327
- * Attempt to acquire the write lock for a container, with retries.
328
- * If write lock is held by another user, call busyHandler if supplied. If no busyHandler, or handler returns "stop", throw. Otherwise try again.
329
- * @note if write lock is already held, this function does nothing.
330
- * @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
331
- * @param container the CloudContainer for which the lock is to be acquired
332
- * @param busyHandler if present, function called when the write lock is currently held by another user.
333
- */
334
- function acquireWriteLock(user: string, container: CloudContainer, busyHandler?: WriteLockBusyHandler): Promise<void>;
335
- /**
336
- * Perform an asynchronous write operation on a CloudContainer with the write lock held.
337
- * 1. if write lock is already held, call operation and return.
338
- * 2. attempt to acquire the write lock, with retries. Throw if unable to obtain write lock.
339
- * 3. perform the operation
340
- * 3.a if the operation throws, abandon all changes and re-throw
341
- * 4. release the write lock.
342
- * 5. return value from operation
343
- * @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
344
- * @param container the CloudContainer for which the lock is to be acquired
345
- * @param operation an asynchronous operation performed with the write lock held.
346
- * @param busyHandler if present, function called when the write lock is currently held by another user.
347
- * @returns a Promise with the result of `operation`
348
- */
349
- function withWriteLock<T>(user: string, container: CloudContainer, operation: () => T, busyHandler?: WriteLockBusyHandler): Promise<T>;
350
- }
1
+ /** @packageDocumentation
2
+ * @module SQLiteDb
3
+ */
4
+ import { GuidString } from "@itwin/core-bentley";
5
+ import { LocalDirName, LocalFileName } from "@itwin/core-common";
6
+ /** Types for using SQLite files stored in cloud containers.
7
+ * @beta
8
+ */
9
+ export declare namespace CloudSqlite {
10
+ function createCloudContainer(args: ContainerAccessProps): CloudContainer;
11
+ function createCloudCache(args: CloudSqlite.CacheProps): CloudSqlite.CloudCache;
12
+ function startCloudPrefetch(container: CloudSqlite.CloudContainer, dbName: string, args?: CloudSqlite.PrefetchProps): CloudSqlite.CloudPrefetch;
13
+ /** Properties that specify how to access the account for a cloud blob-store container. */
14
+ interface AccountAccessProps {
15
+ /** blob storage module: e.g. "azure", "google", "aws". May also include URI style parameters. */
16
+ storageType: string;
17
+ /** blob store account name, or a URI for custom domains. */
18
+ accessName: string;
19
+ }
20
+ /** Properties of a CloudContainer. */
21
+ interface ContainerProps {
22
+ /** the name of the container. */
23
+ containerId: string;
24
+ /** an alias for the container. Defaults to `containerId` */
25
+ alias?: string;
26
+ /** token that grants access to the container. For sas=1 `storageType`s, this is the sasToken. For sas=0, this is the account key */
27
+ accessToken: string;
28
+ /** if true, container is attached with write permissions, and accessToken must provide write access to the cloud container. */
29
+ writeable?: boolean;
30
+ /** if true, container is attached in "secure" mode (blocks are encrypted). Only supported in daemon mode. */
31
+ secure?: boolean;
32
+ }
33
+ /** Returned from `CloudContainer.queryDatabase` describing one database in the container */
34
+ interface CachedDbProps {
35
+ /** The total of (4Mb) blocks in the database. */
36
+ readonly totalBlocks: number;
37
+ /** the number of blocks of the database that have been downloaded into the CloudCache */
38
+ readonly localBlocks: number;
39
+ /** the number of blocks from this database that have been modified in the CloudCache and need to be uploaded. */
40
+ readonly dirtyBlocks: number;
41
+ /** If true, the database currently has transactions in the WAL file and may not be uploaded until they have been checkPointed. */
42
+ readonly transactions: boolean;
43
+ /** the state of this database. Indicates whether the database is new or deleted since last upload */
44
+ readonly state: "" | "copied" | "deleted";
45
+ }
46
+ /** Properties for accessing a CloudContainer */
47
+ type ContainerAccessProps = AccountAccessProps & ContainerProps & {
48
+ /** Duration for holding write lock, in seconds. After this time the write lock expires if not refreshed. Default is one hour. */
49
+ durationSeconds?: number;
50
+ };
51
+ /** The name of a CloudSqlite database within a CloudContainer. */
52
+ interface DbNameProp {
53
+ /** the name of the database within the CloudContainer.
54
+ * @note names of databases within a CloudContainer are always **case sensitive** on all platforms.*/
55
+ dbName: string;
56
+ }
57
+ /** Properties for accessing a database within a CloudContainer */
58
+ interface DbProps extends DbNameProp {
59
+ /** the name of the local file to access the database. */
60
+ localFileName: LocalFileName;
61
+ }
62
+ type TransferDirection = "upload" | "download";
63
+ interface TransferProgress {
64
+ /** a user-supplied progress function called during the transfer operation. Return a non-0 value to abort the transfer. */
65
+ onProgress?: (loaded: number, total: number) => number;
66
+ }
67
+ interface CloudHttpProps {
68
+ /** The number of simultaneous HTTP requests. Default is 6. */
69
+ nRequests?: number;
70
+ }
71
+ interface PrefetchProps extends CloudHttpProps {
72
+ /** timeout between requests, in milliseconds. Default is 100. */
73
+ timeout?: number;
74
+ /** The number of prefetch requests to issue while there is foreground activity. Default is 3. */
75
+ minRequests?: number;
76
+ }
77
+ type TransferDbProps = DbProps & TransferProgress & CloudHttpProps;
78
+ /** Properties for creating a CloudCache. */
79
+ interface CacheProps extends CloudHttpProps {
80
+ /** 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. */
81
+ rootDir: string;
82
+ /** name of this cache. It is possible to have more than one CloudCache in the same session. */
83
+ name: string;
84
+ /** maximum cache Size. Must be a number followed by either M (for megabytes) or G (for gigabytes.) Default is 1G */
85
+ cacheSize?: string;
86
+ /** turn on diagnostics for `curl` (outputs to stderr) */
87
+ curlDiagnostics?: boolean;
88
+ }
89
+ /** Parameters used to obtain the write lock on a cloud container
90
+ * @internal
91
+ */
92
+ interface ObtainLockParams {
93
+ /** The name of the user attempting to acquire the write lock. This name will be shown to other users while the lock is held. */
94
+ user?: string;
95
+ /** number of times to retry in the event the lock currently held by someone else.
96
+ * After this number of attempts, `onFailure` is called. Default is 20.
97
+ */
98
+ nRetries: number;
99
+ /** Delay between retries, in milliseconds. Default is 100. */
100
+ retryDelayMs: number;
101
+ /** function called if lock cannot be obtained after all retries. It is called with the name of the user currently holding the lock and
102
+ * generally is expected that the user will be consulted whether to wait further.
103
+ * If this function returns "stop", an exception will be thrown. Otherwise the retry cycle is restarted.
104
+ */
105
+ onFailure?: WriteLockBusyHandler;
106
+ }
107
+ /** @internal */
108
+ interface LockAndOpenArgs {
109
+ /** the name to be displayed in the event of lock collisions */
110
+ user: string;
111
+ /** the name of the database within the container */
112
+ dbName: string;
113
+ /** the CloudContainer on which the operation will be performed */
114
+ container: CloudContainer;
115
+ /** if present, function called when the write lock is currently held by another user. */
116
+ busyHandler?: WriteLockBusyHandler;
117
+ }
118
+ /** Logging categories for `CloudCache.setLogMask` */
119
+ enum LoggingMask {
120
+ /** log all HTTP requests and responses */
121
+ HTTP = 1,
122
+ /** log as blocks become dirty and must be uploaded */
123
+ DirtyBlocks = 2,
124
+ /** log as blocks are added to the delete list */
125
+ AddToDelete = 4,
126
+ /** log container lifecycle events (e.g. authorization requests, disconnects, and state transitions) */
127
+ LifecycleEvents = 8,
128
+ /** Turn on all logging categories */
129
+ All = 255,
130
+ /** Disable logging */
131
+ None = 0
132
+ }
133
+ /**
134
+ * A cache for storing data from CloudSqlite databases. This object refers to a directory on a local filesystem
135
+ * and is used to **connect** CloudContainers so they may be accessed. The contents of the cache directory are entirely
136
+ * controlled by CloudSqlite and should be empty when the cache is first created and never modified directly. It maintains
137
+ * the state of the local data across sessions.
138
+ */
139
+ interface CloudCache {
140
+ /** `true` if this CloudCache is connected to a daemon process */
141
+ get isDaemon(): boolean;
142
+ /** The name for this CloudCache. */
143
+ get name(): string;
144
+ /** The root directory of this CloudCache on a local drive. */
145
+ get rootDir(): LocalDirName;
146
+ /** The guid for this CloudCache. Used for acquiring write lock. */
147
+ get guid(): GuidString;
148
+ /** Configure logging for this CloudCache.
149
+ * @param mask A bitmask of `LoggingMask` values
150
+ * @note this method does nothing if [[isDaemon]] is true. Daemon logging is configured when the daemon is started.
151
+ * @note HTTP logging can be happen on multiple threads and may be buffered. To see buffered log messages, periodically call
152
+ * `IModelHost.flushLog`
153
+ */
154
+ setLogMask(mask: number): void;
155
+ /** destroy this CloudCache. All CloudContainers should be detached before calling this. */
156
+ destroy(): void;
157
+ }
158
+ /** A CloudSqlite container that may be connected to a CloudCache. */
159
+ interface CloudContainer {
160
+ readonly cache?: CloudCache;
161
+ /** The ContainerId. */
162
+ get containerId(): string;
163
+ /** The *alias* to identify this CloudContainer in a CloudCache. Usually just the ContainerId. */
164
+ get alias(): string;
165
+ /** true if this CloudContainer is currently connected to a CloudCache via the `connect` method. */
166
+ get isConnected(): boolean;
167
+ /** true if this CloudContainer was created with the `writeable` flag (and its `accessToken` supplies write access). */
168
+ get isWriteable(): boolean;
169
+ /** true if this CloudContainer currently holds the write lock for its container in the cloud. */
170
+ get hasWriteLock(): boolean;
171
+ /** true if this CloudContainer has local changes that have not be uploaded to its container in the cloud. */
172
+ get hasLocalChanges(): boolean;
173
+ /** The current accessToken providing access to the cloud container */
174
+ get accessToken(): string;
175
+ set accessToken(val: string);
176
+ /** Get the number of garbage blocks in this container that can be purged. */
177
+ get garbageBlocks(): number;
178
+ /** The block size for this CloudContainer. */
179
+ get blockSize(): number;
180
+ /**
181
+ * initialize a cloud blob-store container to be used as a new Sqlite CloudContainer. This creates the manifest, and should be
182
+ * performed on an empty container. If an existing manifest is present, it is destroyed and a new one is created (essentially emptying the container.)
183
+ */
184
+ initializeContainer(opts?: {
185
+ checksumBlockNames?: boolean;
186
+ blockSize?: number;
187
+ }): void;
188
+ /**
189
+ * Attempt to acquire the write lock for this CloudContainer. For this to succeed:
190
+ * 1. it must be connected to a `CloudCache`
191
+ * 2. this CloudContainer must have been constructed with `writeable: true`
192
+ * 3. the `accessToken` must authorize write access
193
+ * 4. no other process may be holding an unexpired write lock
194
+ * @throws exception if any of the above conditions fail
195
+ * @note Write locks *expire* after the duration specified in the `durationSeconds` property of the constructor argument, in case a process
196
+ * crashes or otherwise fails to release the lock. Calling `acquireWriteLock` with the lock already held resets the lock duration from the current time,
197
+ * 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
198
+ * before it expires.)
199
+ * @note on success, the manifest is polled before the promise resolves.
200
+ * @param user An identifier of the process/user locking the CloudContainer. In the event of a write lock
201
+ * collision, this string will be included in the exception string of the *other* process attempting to obtain a write lock.
202
+ */
203
+ acquireWriteLock(user: string): void;
204
+ /**
205
+ * Release the write lock if it is currently held.
206
+ * @note if there are local changes that have not been uploaded, they are automatically uploaded before the write lock is released.
207
+ * @note if the write lock is not held, this method does nothing.
208
+ */
209
+ releaseWriteLock(): void;
210
+ /**
211
+ * Destroy any currently valid write lock from this or any other process. This is obviously very dangerous and defeats the purpose of write locking.
212
+ * 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.
213
+ * For this to succeed, all of the conditions of `acquireWriteLock` must be true other than #4.
214
+ */
215
+ clearWriteLock(): void;
216
+ /**
217
+ * Abandon any local changes in this container. If the write lock is currently held, it is released.
218
+ * This function fails with BE_SQLITE_BUSY if one or more clients have open read or write transactions
219
+ * on any database in the container.
220
+ */
221
+ abandonChanges(): void;
222
+ /**
223
+ * Connect this CloudContainer to a CloudCache for reading or writing its manifest, write lock, and databases.
224
+ * @note A CloudCache is a local directory holding copies of information from the cloud. Its content is persistent across sessions,
225
+ * but this method must be called each session to (re)establish the connection to the cache. If the CloudCache was previously populated,
226
+ * this method may be called and will succeed *even when offline* or without a valid `accessToken`.
227
+ * @note all operations that access the contents of databases or the manifest require this method be called (`isConnected === true`).
228
+ */
229
+ connect(cache: CloudCache): void;
230
+ /**
231
+ * Disconnect this CloudContainer from its CloudCache. There must be no open databases from this container. Leaves the container attached to the
232
+ * CloudCache so it is available for future sessions.
233
+ */
234
+ disconnect(): void;
235
+ /**
236
+ * Permanently Detach and Disconnect this CloudContainer from its CloudCache. There must be no open databases from this container.
237
+ */
238
+ detach(): void;
239
+ /**
240
+ * Poll cloud storage for changes from other processes. *No changes* made by other processes are visible to
241
+ * this CloudContainer unless/until this method is called.
242
+ * @note this is automatically called whenever the write lock is obtained to ensure all changes are against the latest version.
243
+ */
244
+ checkForChanges(): void;
245
+ /**
246
+ * Upload any changed blocks from all databases in this CloudContainer.
247
+ * @note this is called automatically from `releaseWriteLock` before the write lock is released. It is only necessary to call this directly if you
248
+ * wish to upload changes while the write lock is still held.
249
+ * @see hasLocalChanges
250
+ */
251
+ uploadChanges(): Promise<void>;
252
+ /**
253
+ * Clean any unused deleted blocks from cloud storage. When a database is written, a subset of its blocks are replaced
254
+ * by new versions, sometimes leaving the originals unused. In this case, they are not deleted immediately.
255
+ * Instead, they are scheduled for deletion at some later time. Calling this method deletes all blocks in the cloud container
256
+ * for which the scheduled deletion time has passed.
257
+ * @param nSeconds Any block that was marked as unused before this number of seconds ago will be deleted. Specifying a non-zero
258
+ * value gives a period of time for other clients to refresh their manifests and stop using the now-garbage blocks. Otherwise they may get
259
+ * a 404 error. Default is 1 hour.
260
+ */
261
+ cleanDeletedBlocks(nSeconds?: number): Promise<void>;
262
+ /**
263
+ * Create a copy of an existing database within this CloudContainer with a new name.
264
+ * @note CloudSqlite uses copy-on-write semantics for this operation. That is, this method merely makes a
265
+ * new entry in the manifest with the new name that *shares* all of its blocks with the original database.
266
+ * If either database subsequently changes, the only modified blocks are not shared.
267
+ */
268
+ copyDatabase(dbName: string, toAlias: string): Promise<void>;
269
+ /** Remove a database from this CloudContainer.
270
+ * @see cleanDeletedBlocks
271
+ */
272
+ deleteDatabase(dbName: string): Promise<void>;
273
+ /** Get the list of database names in this CloudContainer.
274
+ * @param globArg if present, filter the results with SQLite [GLOB](https://www.sqlite.org/lang_expr.html#glob) operator.
275
+ */
276
+ queryDatabases(globArg?: string): string[];
277
+ /**
278
+ * Get the status of a specific database in this CloudContainer.
279
+ * @param dbName the name of the database of interest
280
+ */
281
+ queryDatabase(dbName: string): CloudSqlite.CachedDbProps | undefined;
282
+ /**
283
+ * Get the SHA1 hash of the content of a database.
284
+ * @param dbName the name of the database of interest
285
+ * @note the hash will be empty if the database does not exist
286
+ */
287
+ queryDatabaseHash(dbName: string): string;
288
+ }
289
+ /** @internal */
290
+ interface CloudPrefetch {
291
+ readonly cloudContainer: CloudContainer;
292
+ readonly dbName: string;
293
+ /** Cancel a currently pending prefetch. The promise will be resolved immediately after this call. */
294
+ cancel(): void;
295
+ /**
296
+ * Promise that is resolved when the prefetch completes or is cancelled. Await this promise to ensure that the
297
+ * database has been fully downloaded before going offline, for example.
298
+ * @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.
299
+ * @note the promise is *not* rejected on `cancel`. Some progress may (or may not) have been made by the request.
300
+ * @note To monitor the progress being made during prefetch, call `CloudContainer.queryDatabase` periodically.
301
+ */
302
+ promise: Promise<boolean>;
303
+ }
304
+ /** @internal */
305
+ function transferDb(direction: TransferDirection, container: CloudContainer, props: TransferDbProps): Promise<void>;
306
+ /** Upload a database into a CloudContainer
307
+ * @param container the CloudContainer holding the database. Must be connected.
308
+ * @param props the properties that describe the database to be downloaded, plus optionally an `onProgress` function.
309
+ * @note this function requires that the write lock be held on the container
310
+ */
311
+ function uploadDb(container: CloudContainer, props: TransferDbProps): Promise<void>;
312
+ /** Download a database from a CloudContainer
313
+ * @param container the CloudContainer holding the database. Must be connected.
314
+ * @param props the properties that describe the database to be downloaded, plus optionally an `onProgress` function.
315
+ * @returns a Promise that is resolved when the download completes.
316
+ * @note the download is "restartable." If the transfer is aborted and then re-requested, it will continue from where
317
+ * it left off rather than re-downloading the entire file.
318
+ */
319
+ function downloadDb(container: CloudContainer, props: TransferDbProps): Promise<void>;
320
+ /** Optional method to be called when an attempt to acquire the write lock fails because another user currently holds it.
321
+ * @param lockedBy The identifier supplied by the application/user that currently holds the lock.
322
+ * @param expires a stringified Date (in local time) indicating when the lock will expire.
323
+ * @return "stop" to give up and stop retrying. Generally, it's a good idea to wait for some time before returning.
324
+ */
325
+ type WriteLockBusyHandler = (lockedBy: string, expires: string) => Promise<void | "stop">;
326
+ /**
327
+ * Attempt to acquire the write lock for a container, with retries.
328
+ * If write lock is held by another user, call busyHandler if supplied. If no busyHandler, or handler returns "stop", throw. Otherwise try again.
329
+ * @note if write lock is already held, this function does nothing.
330
+ * @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
331
+ * @param container the CloudContainer for which the lock is to be acquired
332
+ * @param busyHandler if present, function called when the write lock is currently held by another user.
333
+ */
334
+ function acquireWriteLock(user: string, container: CloudContainer, busyHandler?: WriteLockBusyHandler): Promise<void>;
335
+ /**
336
+ * Perform an asynchronous write operation on a CloudContainer with the write lock held.
337
+ * 1. if write lock is already held, call operation and return.
338
+ * 2. attempt to acquire the write lock, with retries. Throw if unable to obtain write lock.
339
+ * 3. perform the operation
340
+ * 3.a if the operation throws, abandon all changes and re-throw
341
+ * 4. release the write lock.
342
+ * 5. return value from operation
343
+ * @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
344
+ * @param container the CloudContainer for which the lock is to be acquired
345
+ * @param operation an asynchronous operation performed with the write lock held.
346
+ * @param busyHandler if present, function called when the write lock is currently held by another user.
347
+ * @returns a Promise with the result of `operation`
348
+ */
349
+ function withWriteLock<T>(user: string, container: CloudContainer, operation: () => T, busyHandler?: WriteLockBusyHandler): Promise<T>;
350
+ }
351
351
  //# sourceMappingURL=CloudSqlite.d.ts.map