@itwin/core-backend 4.0.0-dev.48 → 4.0.0-dev.50

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 (246) 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 +408 -408
  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 +446 -446
  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/ChannelControl.d.ts +69 -69
  29. package/lib/cjs/ChannelControl.js +88 -88
  30. package/lib/cjs/ChannelControl.js.map +1 -1
  31. package/lib/cjs/CheckpointManager.d.ts +121 -121
  32. package/lib/cjs/CheckpointManager.js +351 -351
  33. package/lib/cjs/CheckpointManager.js.map +1 -1
  34. package/lib/cjs/ClassRegistry.d.ts +79 -79
  35. package/lib/cjs/ClassRegistry.js +249 -249
  36. package/lib/cjs/ClassRegistry.js.map +1 -1
  37. package/lib/cjs/CloudSqlite.d.ts +355 -355
  38. package/lib/cjs/CloudSqlite.js +154 -154
  39. package/lib/cjs/CloudSqlite.js.map +1 -1
  40. package/lib/cjs/CloudStorageBackend.d.ts +58 -58
  41. package/lib/cjs/CloudStorageBackend.js +170 -170
  42. package/lib/cjs/CloudStorageBackend.js.map +1 -1
  43. package/lib/cjs/CodeService.d.ts +396 -396
  44. package/lib/cjs/CodeService.js +63 -63
  45. package/lib/cjs/CodeService.js.map +1 -1
  46. package/lib/cjs/CodeSpecs.d.ts +55 -55
  47. package/lib/cjs/CodeSpecs.js +124 -124
  48. package/lib/cjs/CodeSpecs.js.map +1 -1
  49. package/lib/cjs/ConcurrentQuery.d.ts +13 -13
  50. package/lib/cjs/ConcurrentQuery.js +36 -36
  51. package/lib/cjs/ConcurrentQuery.js.map +1 -1
  52. package/lib/cjs/CustomViewState3dCreator.d.ts +21 -21
  53. package/lib/cjs/CustomViewState3dCreator.js +81 -81
  54. package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
  55. package/lib/cjs/DevTools.d.ts +73 -73
  56. package/lib/cjs/DevTools.js +156 -156
  57. package/lib/cjs/DevTools.js.map +1 -1
  58. package/lib/cjs/DisplayStyle.d.ts +106 -106
  59. package/lib/cjs/DisplayStyle.js +253 -253
  60. package/lib/cjs/DisplayStyle.js.map +1 -1
  61. package/lib/cjs/ECDb.d.ts +191 -191
  62. package/lib/cjs/ECDb.js +348 -348
  63. package/lib/cjs/ECDb.js.map +1 -1
  64. package/lib/cjs/ECSchemaXmlContext.d.ts +18 -18
  65. package/lib/cjs/ECSchemaXmlContext.js +41 -41
  66. package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
  67. package/lib/cjs/ECSqlStatement.d.ts +473 -473
  68. package/lib/cjs/ECSqlStatement.js +791 -791
  69. package/lib/cjs/ECSqlStatement.js.map +1 -1
  70. package/lib/cjs/Element.d.ts +1113 -1113
  71. package/lib/cjs/Element.js +1424 -1424
  72. package/lib/cjs/Element.js.map +1 -1
  73. package/lib/cjs/ElementAspect.d.ts +176 -176
  74. package/lib/cjs/ElementAspect.js +203 -203
  75. package/lib/cjs/ElementAspect.js.map +1 -1
  76. package/lib/cjs/ElementGraphics.d.ts +9 -9
  77. package/lib/cjs/ElementGraphics.js +41 -41
  78. package/lib/cjs/ElementGraphics.js.map +1 -1
  79. package/lib/cjs/ElementTreeWalker.d.ts +162 -162
  80. package/lib/cjs/ElementTreeWalker.js +409 -409
  81. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  82. package/lib/cjs/Entity.d.ts +106 -106
  83. package/lib/cjs/Entity.js +134 -134
  84. package/lib/cjs/Entity.js.map +1 -1
  85. package/lib/cjs/EntityReferences.d.ts +49 -49
  86. package/lib/cjs/EntityReferences.js +95 -95
  87. package/lib/cjs/EntityReferences.js.map +1 -1
  88. package/lib/cjs/ExportGraphics.d.ts +317 -317
  89. package/lib/cjs/ExportGraphics.js +208 -208
  90. package/lib/cjs/ExportGraphics.js.map +1 -1
  91. package/lib/cjs/ExternalSource.d.ts +96 -96
  92. package/lib/cjs/ExternalSource.js +131 -131
  93. package/lib/cjs/ExternalSource.js.map +1 -1
  94. package/lib/cjs/GeoCoordConfig.d.ts +19 -19
  95. package/lib/cjs/GeoCoordConfig.js +85 -85
  96. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  97. package/lib/cjs/GeometrySummary.d.ts +4 -4
  98. package/lib/cjs/GeometrySummary.js +380 -380
  99. package/lib/cjs/GeometrySummary.js.map +1 -1
  100. package/lib/cjs/HubMock.d.ts +94 -94
  101. package/lib/cjs/HubMock.js +220 -220
  102. package/lib/cjs/HubMock.js.map +1 -1
  103. package/lib/cjs/IModelCloneContext.d.ts +8 -8
  104. package/lib/cjs/IModelCloneContext.js +15 -15
  105. package/lib/cjs/IModelCloneContext.js.map +1 -1
  106. package/lib/cjs/IModelDb.d.ts +1213 -1213
  107. package/lib/cjs/IModelDb.js +2380 -2380
  108. package/lib/cjs/IModelDb.js.map +1 -1
  109. package/lib/cjs/IModelElementCloneContext.d.ts +89 -89
  110. package/lib/cjs/IModelElementCloneContext.js +159 -159
  111. package/lib/cjs/IModelElementCloneContext.js.map +1 -1
  112. package/lib/cjs/IModelHost.d.ts +369 -369
  113. package/lib/cjs/IModelHost.js +488 -488
  114. package/lib/cjs/IModelHost.js.map +1 -1
  115. package/lib/cjs/IModelJsFs.d.ts +62 -62
  116. package/lib/cjs/IModelJsFs.js +139 -139
  117. package/lib/cjs/IModelJsFs.js.map +1 -1
  118. package/lib/cjs/IpcHost.d.ts +104 -104
  119. package/lib/cjs/IpcHost.js +276 -276
  120. package/lib/cjs/IpcHost.js.map +1 -1
  121. package/lib/cjs/LineStyle.d.ts +311 -311
  122. package/lib/cjs/LineStyle.js +295 -295
  123. package/lib/cjs/LineStyle.js.map +1 -1
  124. package/lib/cjs/LocalHub.d.ts +162 -162
  125. package/lib/cjs/LocalHub.js +580 -580
  126. package/lib/cjs/LocalHub.js.map +1 -1
  127. package/lib/cjs/LocalhostIpcHost.d.ts +20 -20
  128. package/lib/cjs/LocalhostIpcHost.js +79 -79
  129. package/lib/cjs/LocalhostIpcHost.js.map +1 -1
  130. package/lib/cjs/Material.d.ts +131 -131
  131. package/lib/cjs/Material.js +180 -180
  132. package/lib/cjs/Material.js.map +1 -1
  133. package/lib/cjs/Model.d.ts +392 -392
  134. package/lib/cjs/Model.js +489 -489
  135. package/lib/cjs/Model.js.map +1 -1
  136. package/lib/cjs/NativeAppStorage.d.ts +51 -51
  137. package/lib/cjs/NativeAppStorage.js +202 -202
  138. package/lib/cjs/NativeAppStorage.js.map +1 -1
  139. package/lib/cjs/NativeHost.d.ts +52 -52
  140. package/lib/cjs/NativeHost.js +160 -160
  141. package/lib/cjs/NativeHost.js.map +1 -1
  142. package/lib/cjs/NavigationRelationship.d.ts +156 -156
  143. package/lib/cjs/NavigationRelationship.js +225 -225
  144. package/lib/cjs/NavigationRelationship.js.map +1 -1
  145. package/lib/cjs/PromiseMemoizer.d.ts +51 -51
  146. package/lib/cjs/PromiseMemoizer.js +101 -101
  147. package/lib/cjs/PromiseMemoizer.js.map +1 -1
  148. package/lib/cjs/PropertyStore.d.ts +132 -132
  149. package/lib/cjs/PropertyStore.js +11 -11
  150. package/lib/cjs/PropertyStore.js.map +1 -1
  151. package/lib/cjs/Relationship.d.ts +416 -416
  152. package/lib/cjs/Relationship.js +494 -494
  153. package/lib/cjs/Relationship.js.map +1 -1
  154. package/lib/cjs/RpcBackend.d.ts +5 -5
  155. package/lib/cjs/RpcBackend.js +32 -32
  156. package/lib/cjs/RpcBackend.js.map +1 -1
  157. package/lib/cjs/SQLiteDb.d.ts +219 -219
  158. package/lib/cjs/SQLiteDb.js +212 -212
  159. package/lib/cjs/SQLiteDb.js.map +1 -1
  160. package/lib/cjs/Schema.d.ts +55 -55
  161. package/lib/cjs/Schema.js +83 -83
  162. package/lib/cjs/Schema.js.map +1 -1
  163. package/lib/cjs/ServerBasedLocks.d.ts +57 -57
  164. package/lib/cjs/ServerBasedLocks.js +168 -168
  165. package/lib/cjs/ServerBasedLocks.js.map +1 -1
  166. package/lib/cjs/SqliteStatement.d.ts +360 -360
  167. package/lib/cjs/SqliteStatement.js +586 -586
  168. package/lib/cjs/SqliteStatement.js.map +1 -1
  169. package/lib/cjs/Texture.d.ts +58 -58
  170. package/lib/cjs/Texture.js +82 -82
  171. package/lib/cjs/Texture.js.map +1 -1
  172. package/lib/cjs/TileStorage.d.ts +18 -18
  173. package/lib/cjs/TileStorage.js +87 -87
  174. package/lib/cjs/TileStorage.js.map +1 -1
  175. package/lib/cjs/TxnManager.d.ts +202 -202
  176. package/lib/cjs/TxnManager.js +356 -356
  177. package/lib/cjs/TxnManager.js.map +1 -1
  178. package/lib/cjs/ViewDefinition.d.ts +435 -435
  179. package/lib/cjs/ViewDefinition.js +646 -646
  180. package/lib/cjs/ViewDefinition.js.map +1 -1
  181. package/lib/cjs/ViewStateHydrator.d.ts +13 -13
  182. package/lib/cjs/ViewStateHydrator.js +103 -103
  183. package/lib/cjs/ViewStateHydrator.js.map +1 -1
  184. package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
  185. package/lib/cjs/assets/Settings/Schemas/Cloud.Schema.json +67 -67
  186. package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +31 -31
  187. package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +52 -52
  188. package/lib/cjs/assets/Settings/backend.setting.json5 +138 -138
  189. package/lib/cjs/core-backend.d.ts +185 -185
  190. package/lib/cjs/core-backend.js +205 -205
  191. package/lib/cjs/core-backend.js.map +1 -1
  192. package/lib/cjs/domains/FunctionalElements.d.ts +101 -101
  193. package/lib/cjs/domains/FunctionalElements.js +145 -145
  194. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  195. package/lib/cjs/domains/FunctionalSchema.d.ts +13 -13
  196. package/lib/cjs/domains/FunctionalSchema.js +39 -39
  197. package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
  198. package/lib/cjs/domains/GenericElements.d.ts +177 -177
  199. package/lib/cjs/domains/GenericElements.js +263 -263
  200. package/lib/cjs/domains/GenericElements.js.map +1 -1
  201. package/lib/cjs/domains/GenericSchema.d.ts +10 -10
  202. package/lib/cjs/domains/GenericSchema.js +28 -28
  203. package/lib/cjs/domains/GenericSchema.js.map +1 -1
  204. package/lib/cjs/rpc/multipart.d.ts +11 -11
  205. package/lib/cjs/rpc/multipart.js +71 -71
  206. package/lib/cjs/rpc/multipart.js.map +1 -1
  207. package/lib/cjs/rpc/tracing.d.ts +28 -28
  208. package/lib/cjs/rpc/tracing.js +73 -73
  209. package/lib/cjs/rpc/tracing.js.map +1 -1
  210. package/lib/cjs/rpc/web/logging.d.ts +9 -9
  211. package/lib/cjs/rpc/web/logging.js +43 -43
  212. package/lib/cjs/rpc/web/logging.js.map +1 -1
  213. package/lib/cjs/rpc/web/request.d.ts +6 -6
  214. package/lib/cjs/rpc/web/request.js +73 -73
  215. package/lib/cjs/rpc/web/request.js.map +1 -1
  216. package/lib/cjs/rpc/web/response.d.ts +6 -6
  217. package/lib/cjs/rpc/web/response.js +105 -105
  218. package/lib/cjs/rpc/web/response.js.map +1 -1
  219. package/lib/cjs/rpc-impl/DevToolsRpcImpl.d.ts +15 -15
  220. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js +32 -32
  221. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
  222. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +47 -47
  223. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +293 -293
  224. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  225. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts +22 -22
  226. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +202 -202
  227. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  228. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +36 -36
  229. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +166 -166
  230. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  231. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.d.ts +16 -16
  232. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js +42 -42
  233. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  234. package/lib/cjs/rpc-impl/WipRpcImpl.d.ts +15 -15
  235. package/lib/cjs/rpc-impl/WipRpcImpl.js +37 -37
  236. package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -1
  237. package/lib/cjs/workspace/Settings.d.ts +186 -186
  238. package/lib/cjs/workspace/Settings.js +154 -154
  239. package/lib/cjs/workspace/Settings.js.map +1 -1
  240. package/lib/cjs/workspace/SettingsSchemas.d.ts +75 -75
  241. package/lib/cjs/workspace/SettingsSchemas.js +190 -190
  242. package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
  243. package/lib/cjs/workspace/Workspace.d.ts +414 -414
  244. package/lib/cjs/workspace/Workspace.js +537 -537
  245. package/lib/cjs/workspace/Workspace.js.map +1 -1
  246. package/package.json +10 -10
@@ -1,356 +1,356 @@
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
- * @note All methods and accessors of this interface (other than `initializeContainer`) require that the `connect` method be successfully called first.
160
- * Otherwise they will throw an exception or return meaningless values.
161
- */
162
- interface CloudContainer {
163
- readonly cache?: CloudCache;
164
- /** The ContainerId. */
165
- get containerId(): string;
166
- /** The *alias* to identify this CloudContainer in a CloudCache. Usually just the ContainerId. */
167
- get alias(): string;
168
- /** true if this CloudContainer is currently connected to a CloudCache via the `connect` method. */
169
- get isConnected(): boolean;
170
- /** true if this CloudContainer was created with the `writeable` flag (and its `accessToken` supplies write access). */
171
- get isWriteable(): boolean;
172
- /** true if this CloudContainer currently holds the write lock for its container in the cloud. */
173
- get hasWriteLock(): boolean;
174
- /** true if this CloudContainer has local changes that have not be uploaded to its container in the cloud. */
175
- get hasLocalChanges(): boolean;
176
- /** The current accessToken providing access to the cloud container */
177
- get accessToken(): string;
178
- set accessToken(val: string);
179
- /** Get the number of garbage blocks in this container that can be purged. */
180
- get garbageBlocks(): number;
181
- /** The block size for this CloudContainer. */
182
- get blockSize(): number;
183
- /**
184
- * initialize a cloud blob-store container to be used as a new Sqlite CloudContainer. This creates the manifest, and should be
185
- * performed on an empty container. If an existing manifest is present, it is destroyed and a new one is created (essentially emptying the container.)
186
- */
187
- initializeContainer(opts?: {
188
- checksumBlockNames?: boolean;
189
- blockSize?: number;
190
- }): void;
191
- /**
192
- * Connect this CloudContainer to a CloudCache for reading or writing its manifest, write lock, and databases.
193
- * @note A CloudCache is a local directory holding copies of information from the cloud. Its content is persistent across sessions,
194
- * but this method must be called each session to (re)establish the connection to the cache. If the CloudCache was previously populated,
195
- * this method may be called and will succeed *even when offline* or without a valid `accessToken`.
196
- * @note all operations that access the contents of databases or the manifest require this method be successfully called (i.e. `isConnected === true`).
197
- */
198
- connect(cache: CloudCache): void;
199
- /**
200
- * Attempt to acquire the write lock for this CloudContainer. For this to succeed:
201
- * 1. it must be connected to a `CloudCache`
202
- * 2. this CloudContainer must have been constructed with `writeable: true`
203
- * 3. the `accessToken` must authorize write access
204
- * 4. no other process may be holding an unexpired write lock
205
- * @throws if any of the above conditions fail
206
- * @note Write locks *expire* after the duration specified in the `durationSeconds` property of the constructor argument, in case a process
207
- * crashes or otherwise fails to release the lock. Calling `acquireWriteLock` with the lock already held resets the lock duration from the current time,
208
- * 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
209
- * before it expires.)
210
- * @note on success, the manifest is polled before the promise resolves.
211
- * @param user An identifier of the process/user locking the CloudContainer. In the event of a write lock
212
- * collision, this string will be included in the exception string of the *other* process attempting to obtain a write lock.
213
- */
214
- acquireWriteLock(user: string): void;
215
- /**
216
- * Release the write lock if it is currently held.
217
- * @note if there are local changes that have not been uploaded, they are automatically uploaded before the write lock is released.
218
- * @note if the write lock is not held, this method does nothing.
219
- */
220
- releaseWriteLock(): void;
221
- /**
222
- * Destroy any currently valid write lock from this or any other process. This is obviously very dangerous and defeats the purpose of write locking.
223
- * 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.
224
- * For this to succeed, all of the conditions of `acquireWriteLock` must be true other than #4.
225
- */
226
- clearWriteLock(): void;
227
- /**
228
- * Abandon any local changes in this container. If the write lock is currently held, it is released.
229
- * This function fails with BE_SQLITE_BUSY if one or more clients have open read or write transactions
230
- * on any database in the container.
231
- */
232
- abandonChanges(): void;
233
- /**
234
- * Disconnect this CloudContainer from its CloudCache. There must be no open databases from this container. Leaves the container attached to the
235
- * CloudCache so it is available for future sessions.
236
- * @note This function does nothing (and does not throw) if the CloudContainer is not connected to a CloudCache.
237
- */
238
- disconnect(): void;
239
- /**
240
- * Permanently Detach and Disconnect this CloudContainer from its CloudCache. There must be no open databases from this container.
241
- */
242
- detach(): void;
243
- /**
244
- * Poll cloud storage for changes from other processes. *No changes* made by other processes are visible to
245
- * this CloudContainer unless/until this method is called.
246
- * @note this is automatically called whenever the write lock is obtained to ensure all changes are against the latest version.
247
- */
248
- checkForChanges(): void;
249
- /**
250
- * Upload any changed blocks from all databases in this CloudContainer.
251
- * @note this is called automatically from `releaseWriteLock` before the write lock is released. It is only necessary to call this directly if you
252
- * wish to upload changes while the write lock is still held.
253
- * @see hasLocalChanges
254
- */
255
- uploadChanges(): Promise<void>;
256
- /**
257
- * Clean any unused deleted blocks from cloud storage. When a database is written, a subset of its blocks are replaced
258
- * by new versions, sometimes leaving the originals unused. In this case, they are not deleted immediately.
259
- * Instead, they are scheduled for deletion at some later time. Calling this method deletes all blocks in the cloud container
260
- * for which the scheduled deletion time has passed.
261
- * @param nSeconds Any block that was marked as unused before this number of seconds ago will be deleted. Specifying a non-zero
262
- * value gives a period of time for other clients to refresh their manifests and stop using the now-garbage blocks. Otherwise they may get
263
- * a 404 error. Default is 1 hour.
264
- */
265
- cleanDeletedBlocks(nSeconds?: number): Promise<void>;
266
- /**
267
- * Create a copy of an existing database within this CloudContainer with a new name.
268
- * @note CloudSqlite uses copy-on-write semantics for this operation. That is, this method merely makes a
269
- * new entry in the manifest with the new name that *shares* all of its blocks with the original database.
270
- * If either database subsequently changes, the only modified blocks are not shared.
271
- */
272
- copyDatabase(dbName: string, toAlias: string): Promise<void>;
273
- /** Remove a database from this CloudContainer.
274
- * @see cleanDeletedBlocks
275
- */
276
- deleteDatabase(dbName: string): Promise<void>;
277
- /** Get the list of database names in this CloudContainer.
278
- * @param globArg if present, filter the results with SQLite [GLOB](https://www.sqlite.org/lang_expr.html#glob) operator.
279
- */
280
- queryDatabases(globArg?: string): string[];
281
- /**
282
- * Get the status of a specific database in this CloudContainer.
283
- * @param dbName the name of the database of interest
284
- */
285
- queryDatabase(dbName: string): CloudSqlite.CachedDbProps | undefined;
286
- /**
287
- * Get the SHA1 hash of the content of a database.
288
- * @param dbName the name of the database of interest
289
- * @note the hash will be empty if the database does not exist
290
- */
291
- queryDatabaseHash(dbName: string): string;
292
- }
293
- /** @internal */
294
- interface CloudPrefetch {
295
- readonly cloudContainer: CloudContainer;
296
- readonly dbName: string;
297
- /** Cancel a currently pending prefetch. The promise will be resolved immediately after this call. */
298
- cancel(): void;
299
- /**
300
- * Promise that is resolved when the prefetch completes or is cancelled. Await this promise to ensure that the
301
- * database has been fully downloaded before going offline, for example.
302
- * @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.
303
- * @note the promise is *not* rejected on `cancel`. Some progress may (or may not) have been made by the request.
304
- * @note To monitor the progress being made during prefetch, call `CloudContainer.queryDatabase` periodically.
305
- */
306
- promise: Promise<boolean>;
307
- }
308
- /** @internal */
309
- function transferDb(direction: TransferDirection, container: CloudContainer, props: TransferDbProps): Promise<void>;
310
- /** Upload a database into a CloudContainer
311
- * @param container the CloudContainer holding the database. Must be connected.
312
- * @param props the properties that describe the database to be downloaded, plus optionally an `onProgress` function.
313
- * @note this function requires that the write lock be held on the container
314
- */
315
- function uploadDb(container: CloudContainer, props: TransferDbProps): Promise<void>;
316
- /** Download a database from a CloudContainer
317
- * @param container the CloudContainer holding the database. Must be connected.
318
- * @param props the properties that describe the database to be downloaded, plus optionally an `onProgress` function.
319
- * @returns a Promise that is resolved when the download completes.
320
- * @note the download is "restartable." If the transfer is aborted and then re-requested, it will continue from where
321
- * it left off rather than re-downloading the entire file.
322
- */
323
- function downloadDb(container: CloudContainer, props: TransferDbProps): Promise<void>;
324
- /** Optional method to be called when an attempt to acquire the write lock fails because another user currently holds it.
325
- * @param lockedBy The identifier supplied by the application/user that currently holds the lock.
326
- * @param expires a stringified Date (in local time) indicating when the lock will expire.
327
- * @return "stop" to give up and stop retrying. Generally, it's a good idea to wait for some time before returning.
328
- */
329
- type WriteLockBusyHandler = (lockedBy: string, expires: string) => Promise<void | "stop">;
330
- /**
331
- * Attempt to acquire the write lock for a container, with retries.
332
- * If write lock is held by another user, call busyHandler if supplied. If no busyHandler, or handler returns "stop", throw. Otherwise try again.
333
- * @note if write lock is already held, this function does nothing.
334
- * @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
335
- * @param container the CloudContainer for which the lock is to be acquired
336
- * @param busyHandler if present, function called when the write lock is currently held by another user.
337
- * @throws if [[container]] is not connected to a CloudCache.
338
- */
339
- function acquireWriteLock(user: string, container: CloudContainer, busyHandler?: WriteLockBusyHandler): Promise<void>;
340
- /**
341
- * Perform an asynchronous write operation on a CloudContainer with the write lock held.
342
- * 1. if write lock is already held, call operation and return.
343
- * 2. attempt to acquire the write lock, with retries. Throw if unable to obtain write lock.
344
- * 3. perform the operation
345
- * 3.a if the operation throws, abandon all changes and re-throw
346
- * 4. release the write lock.
347
- * 5. return value from operation
348
- * @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
349
- * @param container the CloudContainer for which the lock is to be acquired
350
- * @param operation an asynchronous operation performed with the write lock held.
351
- * @param busyHandler if present, function called when the write lock is currently held by another user.
352
- * @returns a Promise with the result of `operation`
353
- */
354
- function withWriteLock<T>(user: string, container: CloudContainer, operation: () => T, busyHandler?: WriteLockBusyHandler): Promise<T>;
355
- }
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
+ * @note All methods and accessors of this interface (other than `initializeContainer`) require that the `connect` method be successfully called first.
160
+ * Otherwise they will throw an exception or return meaningless values.
161
+ */
162
+ interface CloudContainer {
163
+ readonly cache?: CloudCache;
164
+ /** The ContainerId. */
165
+ get containerId(): string;
166
+ /** The *alias* to identify this CloudContainer in a CloudCache. Usually just the ContainerId. */
167
+ get alias(): string;
168
+ /** true if this CloudContainer is currently connected to a CloudCache via the `connect` method. */
169
+ get isConnected(): boolean;
170
+ /** true if this CloudContainer was created with the `writeable` flag (and its `accessToken` supplies write access). */
171
+ get isWriteable(): boolean;
172
+ /** true if this CloudContainer currently holds the write lock for its container in the cloud. */
173
+ get hasWriteLock(): boolean;
174
+ /** true if this CloudContainer has local changes that have not be uploaded to its container in the cloud. */
175
+ get hasLocalChanges(): boolean;
176
+ /** The current accessToken providing access to the cloud container */
177
+ get accessToken(): string;
178
+ set accessToken(val: string);
179
+ /** Get the number of garbage blocks in this container that can be purged. */
180
+ get garbageBlocks(): number;
181
+ /** The block size for this CloudContainer. */
182
+ get blockSize(): number;
183
+ /**
184
+ * initialize a cloud blob-store container to be used as a new Sqlite CloudContainer. This creates the manifest, and should be
185
+ * performed on an empty container. If an existing manifest is present, it is destroyed and a new one is created (essentially emptying the container.)
186
+ */
187
+ initializeContainer(opts?: {
188
+ checksumBlockNames?: boolean;
189
+ blockSize?: number;
190
+ }): void;
191
+ /**
192
+ * Connect this CloudContainer to a CloudCache for reading or writing its manifest, write lock, and databases.
193
+ * @note A CloudCache is a local directory holding copies of information from the cloud. Its content is persistent across sessions,
194
+ * but this method must be called each session to (re)establish the connection to the cache. If the CloudCache was previously populated,
195
+ * this method may be called and will succeed *even when offline* or without a valid `accessToken`.
196
+ * @note all operations that access the contents of databases or the manifest require this method be successfully called (i.e. `isConnected === true`).
197
+ */
198
+ connect(cache: CloudCache): void;
199
+ /**
200
+ * Attempt to acquire the write lock for this CloudContainer. For this to succeed:
201
+ * 1. it must be connected to a `CloudCache`
202
+ * 2. this CloudContainer must have been constructed with `writeable: true`
203
+ * 3. the `accessToken` must authorize write access
204
+ * 4. no other process may be holding an unexpired write lock
205
+ * @throws if any of the above conditions fail
206
+ * @note Write locks *expire* after the duration specified in the `durationSeconds` property of the constructor argument, in case a process
207
+ * crashes or otherwise fails to release the lock. Calling `acquireWriteLock` with the lock already held resets the lock duration from the current time,
208
+ * 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
209
+ * before it expires.)
210
+ * @note on success, the manifest is polled before the promise resolves.
211
+ * @param user An identifier of the process/user locking the CloudContainer. In the event of a write lock
212
+ * collision, this string will be included in the exception string of the *other* process attempting to obtain a write lock.
213
+ */
214
+ acquireWriteLock(user: string): void;
215
+ /**
216
+ * Release the write lock if it is currently held.
217
+ * @note if there are local changes that have not been uploaded, they are automatically uploaded before the write lock is released.
218
+ * @note if the write lock is not held, this method does nothing.
219
+ */
220
+ releaseWriteLock(): void;
221
+ /**
222
+ * Destroy any currently valid write lock from this or any other process. This is obviously very dangerous and defeats the purpose of write locking.
223
+ * 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.
224
+ * For this to succeed, all of the conditions of `acquireWriteLock` must be true other than #4.
225
+ */
226
+ clearWriteLock(): void;
227
+ /**
228
+ * Abandon any local changes in this container. If the write lock is currently held, it is released.
229
+ * This function fails with BE_SQLITE_BUSY if one or more clients have open read or write transactions
230
+ * on any database in the container.
231
+ */
232
+ abandonChanges(): void;
233
+ /**
234
+ * Disconnect this CloudContainer from its CloudCache. There must be no open databases from this container. Leaves the container attached to the
235
+ * CloudCache so it is available for future sessions.
236
+ * @note This function does nothing (and does not throw) if the CloudContainer is not connected to a CloudCache.
237
+ */
238
+ disconnect(): void;
239
+ /**
240
+ * Permanently Detach and Disconnect this CloudContainer from its CloudCache. There must be no open databases from this container.
241
+ */
242
+ detach(): void;
243
+ /**
244
+ * Poll cloud storage for changes from other processes. *No changes* made by other processes are visible to
245
+ * this CloudContainer unless/until this method is called.
246
+ * @note this is automatically called whenever the write lock is obtained to ensure all changes are against the latest version.
247
+ */
248
+ checkForChanges(): void;
249
+ /**
250
+ * Upload any changed blocks from all databases in this CloudContainer.
251
+ * @note this is called automatically from `releaseWriteLock` before the write lock is released. It is only necessary to call this directly if you
252
+ * wish to upload changes while the write lock is still held.
253
+ * @see hasLocalChanges
254
+ */
255
+ uploadChanges(): Promise<void>;
256
+ /**
257
+ * Clean any unused deleted blocks from cloud storage. When a database is written, a subset of its blocks are replaced
258
+ * by new versions, sometimes leaving the originals unused. In this case, they are not deleted immediately.
259
+ * Instead, they are scheduled for deletion at some later time. Calling this method deletes all blocks in the cloud container
260
+ * for which the scheduled deletion time has passed.
261
+ * @param nSeconds Any block that was marked as unused before this number of seconds ago will be deleted. Specifying a non-zero
262
+ * value gives a period of time for other clients to refresh their manifests and stop using the now-garbage blocks. Otherwise they may get
263
+ * a 404 error. Default is 1 hour.
264
+ */
265
+ cleanDeletedBlocks(nSeconds?: number): Promise<void>;
266
+ /**
267
+ * Create a copy of an existing database within this CloudContainer with a new name.
268
+ * @note CloudSqlite uses copy-on-write semantics for this operation. That is, this method merely makes a
269
+ * new entry in the manifest with the new name that *shares* all of its blocks with the original database.
270
+ * If either database subsequently changes, the only modified blocks are not shared.
271
+ */
272
+ copyDatabase(dbName: string, toAlias: string): Promise<void>;
273
+ /** Remove a database from this CloudContainer.
274
+ * @see cleanDeletedBlocks
275
+ */
276
+ deleteDatabase(dbName: string): Promise<void>;
277
+ /** Get the list of database names in this CloudContainer.
278
+ * @param globArg if present, filter the results with SQLite [GLOB](https://www.sqlite.org/lang_expr.html#glob) operator.
279
+ */
280
+ queryDatabases(globArg?: string): string[];
281
+ /**
282
+ * Get the status of a specific database in this CloudContainer.
283
+ * @param dbName the name of the database of interest
284
+ */
285
+ queryDatabase(dbName: string): CloudSqlite.CachedDbProps | undefined;
286
+ /**
287
+ * Get the SHA1 hash of the content of a database.
288
+ * @param dbName the name of the database of interest
289
+ * @note the hash will be empty if the database does not exist
290
+ */
291
+ queryDatabaseHash(dbName: string): string;
292
+ }
293
+ /** @internal */
294
+ interface CloudPrefetch {
295
+ readonly cloudContainer: CloudContainer;
296
+ readonly dbName: string;
297
+ /** Cancel a currently pending prefetch. The promise will be resolved immediately after this call. */
298
+ cancel(): void;
299
+ /**
300
+ * Promise that is resolved when the prefetch completes or is cancelled. Await this promise to ensure that the
301
+ * database has been fully downloaded before going offline, for example.
302
+ * @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.
303
+ * @note the promise is *not* rejected on `cancel`. Some progress may (or may not) have been made by the request.
304
+ * @note To monitor the progress being made during prefetch, call `CloudContainer.queryDatabase` periodically.
305
+ */
306
+ promise: Promise<boolean>;
307
+ }
308
+ /** @internal */
309
+ function transferDb(direction: TransferDirection, container: CloudContainer, props: TransferDbProps): Promise<void>;
310
+ /** Upload a database into a CloudContainer
311
+ * @param container the CloudContainer holding the database. Must be connected.
312
+ * @param props the properties that describe the database to be downloaded, plus optionally an `onProgress` function.
313
+ * @note this function requires that the write lock be held on the container
314
+ */
315
+ function uploadDb(container: CloudContainer, props: TransferDbProps): Promise<void>;
316
+ /** Download a database from a CloudContainer
317
+ * @param container the CloudContainer holding the database. Must be connected.
318
+ * @param props the properties that describe the database to be downloaded, plus optionally an `onProgress` function.
319
+ * @returns a Promise that is resolved when the download completes.
320
+ * @note the download is "restartable." If the transfer is aborted and then re-requested, it will continue from where
321
+ * it left off rather than re-downloading the entire file.
322
+ */
323
+ function downloadDb(container: CloudContainer, props: TransferDbProps): Promise<void>;
324
+ /** Optional method to be called when an attempt to acquire the write lock fails because another user currently holds it.
325
+ * @param lockedBy The identifier supplied by the application/user that currently holds the lock.
326
+ * @param expires a stringified Date (in local time) indicating when the lock will expire.
327
+ * @return "stop" to give up and stop retrying. Generally, it's a good idea to wait for some time before returning.
328
+ */
329
+ type WriteLockBusyHandler = (lockedBy: string, expires: string) => Promise<void | "stop">;
330
+ /**
331
+ * Attempt to acquire the write lock for a container, with retries.
332
+ * If write lock is held by another user, call busyHandler if supplied. If no busyHandler, or handler returns "stop", throw. Otherwise try again.
333
+ * @note if write lock is already held, this function does nothing.
334
+ * @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
335
+ * @param container the CloudContainer for which the lock is to be acquired
336
+ * @param busyHandler if present, function called when the write lock is currently held by another user.
337
+ * @throws if [[container]] is not connected to a CloudCache.
338
+ */
339
+ function acquireWriteLock(user: string, container: CloudContainer, busyHandler?: WriteLockBusyHandler): Promise<void>;
340
+ /**
341
+ * Perform an asynchronous write operation on a CloudContainer with the write lock held.
342
+ * 1. if write lock is already held, call operation and return.
343
+ * 2. attempt to acquire the write lock, with retries. Throw if unable to obtain write lock.
344
+ * 3. perform the operation
345
+ * 3.a if the operation throws, abandon all changes and re-throw
346
+ * 4. release the write lock.
347
+ * 5. return value from operation
348
+ * @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
349
+ * @param container the CloudContainer for which the lock is to be acquired
350
+ * @param operation an asynchronous operation performed with the write lock held.
351
+ * @param busyHandler if present, function called when the write lock is currently held by another user.
352
+ * @returns a Promise with the result of `operation`
353
+ */
354
+ function withWriteLock<T>(user: string, container: CloudContainer, operation: () => T, busyHandler?: WriteLockBusyHandler): Promise<T>;
355
+ }
356
356
  //# sourceMappingURL=CloudSqlite.d.ts.map