@chipmobilesdk/rn-local-db 0.4.0 → 0.5.0

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 (680) hide show
  1. package/CHANGELOG.md +137 -0
  2. package/README.md +69 -8
  3. package/lib/commonjs/adapter/budgets.js +79 -0
  4. package/lib/commonjs/adapter/budgets.js.map +1 -0
  5. package/lib/commonjs/adapter/collection.js +236 -0
  6. package/lib/commonjs/adapter/collection.js.map +1 -0
  7. package/lib/commonjs/adapter/deletion.js +291 -0
  8. package/lib/commonjs/adapter/deletion.js.map +1 -0
  9. package/lib/commonjs/adapter/handle.js +259 -0
  10. package/lib/commonjs/adapter/handle.js.map +1 -0
  11. package/lib/commonjs/adapter/index.js +67 -0
  12. package/lib/commonjs/adapter/index.js.map +1 -0
  13. package/lib/commonjs/adapter/lifecycle.js +176 -0
  14. package/lib/commonjs/adapter/lifecycle.js.map +1 -0
  15. package/lib/commonjs/adapter/schema-sync.js +124 -0
  16. package/lib/commonjs/adapter/schema-sync.js.map +1 -0
  17. package/lib/commonjs/adapter/transaction.js +58 -0
  18. package/lib/commonjs/adapter/transaction.js.map +1 -0
  19. package/lib/commonjs/artifacts/availability.js +90 -0
  20. package/lib/commonjs/artifacts/availability.js.map +1 -0
  21. package/lib/commonjs/artifacts/cascade.js +80 -0
  22. package/lib/commonjs/artifacts/cascade.js.map +1 -0
  23. package/lib/commonjs/artifacts/paths.js +31 -0
  24. package/lib/commonjs/artifacts/paths.js.map +1 -0
  25. package/lib/commonjs/artifacts/reconcile.js +55 -0
  26. package/lib/commonjs/artifacts/reconcile.js.map +1 -0
  27. package/lib/commonjs/artifacts/store.js +300 -0
  28. package/lib/commonjs/artifacts/store.js.map +1 -0
  29. package/lib/commonjs/contract/adapter.js +6 -0
  30. package/lib/commonjs/contract/adapter.js.map +1 -0
  31. package/lib/commonjs/contract/attachment.js +2 -0
  32. package/lib/commonjs/contract/attachment.js.map +1 -0
  33. package/lib/commonjs/contract/backup.js +2 -0
  34. package/lib/commonjs/contract/backup.js.map +1 -0
  35. package/lib/commonjs/contract/config.js +31 -0
  36. package/lib/commonjs/contract/config.js.map +1 -0
  37. package/lib/commonjs/contract/encryption.js +6 -0
  38. package/lib/commonjs/contract/encryption.js.map +1 -0
  39. package/lib/commonjs/contract/errors.js +64 -0
  40. package/lib/commonjs/contract/errors.js.map +1 -0
  41. package/lib/commonjs/contract/migration.js +6 -0
  42. package/lib/commonjs/contract/migration.js.map +1 -0
  43. package/lib/commonjs/contract/query.js +6 -0
  44. package/lib/commonjs/contract/query.js.map +1 -0
  45. package/lib/commonjs/contract/record.js +6 -0
  46. package/lib/commonjs/contract/record.js.map +1 -0
  47. package/lib/commonjs/contract/schema.js +2 -0
  48. package/lib/commonjs/contract/schema.js.map +1 -0
  49. package/lib/commonjs/contract/scope.js +2 -0
  50. package/lib/commonjs/contract/scope.js.map +1 -0
  51. package/lib/commonjs/contract/transaction.js +6 -0
  52. package/lib/commonjs/contract/transaction.js.map +1 -0
  53. package/lib/commonjs/crypto/chunked-cipher.js +147 -0
  54. package/lib/commonjs/crypto/chunked-cipher.js.map +1 -0
  55. package/lib/commonjs/crypto/derive.js +61 -0
  56. package/lib/commonjs/crypto/derive.js.map +1 -0
  57. package/lib/commonjs/crypto/key-provider.js +70 -0
  58. package/lib/commonjs/crypto/key-provider.js.map +1 -0
  59. package/lib/commonjs/crypto/provider.js +54 -0
  60. package/lib/commonjs/crypto/provider.js.map +1 -0
  61. package/lib/commonjs/diagnostics/dev-log.js +127 -0
  62. package/lib/commonjs/diagnostics/dev-log.js.map +1 -0
  63. package/lib/commonjs/diagnostics/errors.js +57 -0
  64. package/lib/commonjs/diagnostics/errors.js.map +1 -0
  65. package/lib/commonjs/diagnostics/faults.js +54 -0
  66. package/lib/commonjs/diagnostics/faults.js.map +1 -0
  67. package/lib/commonjs/diagnostics/map-native.js +98 -0
  68. package/lib/commonjs/diagnostics/map-native.js.map +1 -0
  69. package/lib/commonjs/diagnostics/redact.js +110 -0
  70. package/lib/commonjs/diagnostics/redact.js.map +1 -0
  71. package/lib/commonjs/index.js +70 -0
  72. package/lib/commonjs/index.js.map +1 -0
  73. package/lib/commonjs/migration/executor.js +136 -0
  74. package/lib/commonjs/migration/executor.js.map +1 -0
  75. package/lib/commonjs/migration/ledger.js +64 -0
  76. package/lib/commonjs/migration/ledger.js.map +1 -0
  77. package/lib/commonjs/migration/validate-chain.js +76 -0
  78. package/lib/commonjs/migration/validate-chain.js.map +1 -0
  79. package/lib/commonjs/package.json +1 -0
  80. package/lib/commonjs/platform/backup-android-verify.js +76 -0
  81. package/lib/commonjs/platform/backup-android-verify.js.map +1 -0
  82. package/lib/commonjs/platform/backup-ios.js +50 -0
  83. package/lib/commonjs/platform/backup-ios.js.map +1 -0
  84. package/lib/commonjs/platform/bytes.js +158 -0
  85. package/lib/commonjs/platform/bytes.js.map +1 -0
  86. package/lib/commonjs/platform/fs.js +59 -0
  87. package/lib/commonjs/platform/fs.js.map +1 -0
  88. package/lib/commonjs/platform/location.js +129 -0
  89. package/lib/commonjs/platform/location.js.map +1 -0
  90. package/lib/commonjs/query/budgets.js +95 -0
  91. package/lib/commonjs/query/budgets.js.map +1 -0
  92. package/lib/commonjs/query/compare.js +97 -0
  93. package/lib/commonjs/query/compare.js.map +1 -0
  94. package/lib/commonjs/query/cursor.js +97 -0
  95. package/lib/commonjs/query/cursor.js.map +1 -0
  96. package/lib/commonjs/query/filter.js +82 -0
  97. package/lib/commonjs/query/filter.js.map +1 -0
  98. package/lib/commonjs/query/paginate.js +48 -0
  99. package/lib/commonjs/query/paginate.js.map +1 -0
  100. package/lib/commonjs/query/sort.js +61 -0
  101. package/lib/commonjs/query/sort.js.map +1 -0
  102. package/lib/commonjs/query/validate.js +180 -0
  103. package/lib/commonjs/query/validate.js.map +1 -0
  104. package/lib/commonjs/schema/declare.js +47 -0
  105. package/lib/commonjs/schema/declare.js.map +1 -0
  106. package/lib/commonjs/schema/validate-config.js +115 -0
  107. package/lib/commonjs/schema/validate-config.js.map +1 -0
  108. package/lib/commonjs/scope/hash.js +107 -0
  109. package/lib/commonjs/scope/hash.js.map +1 -0
  110. package/lib/commonjs/scope/normalize.js +73 -0
  111. package/lib/commonjs/scope/normalize.js.map +1 -0
  112. package/lib/commonjs/scope/validate.js +81 -0
  113. package/lib/commonjs/scope/validate.js.map +1 -0
  114. package/lib/commonjs/sqlite/adapter.js +31 -0
  115. package/lib/commonjs/sqlite/adapter.js.map +1 -0
  116. package/lib/commonjs/sqlite/batch.js +218 -0
  117. package/lib/commonjs/sqlite/batch.js.map +1 -0
  118. package/lib/commonjs/sqlite/catalog.js +81 -0
  119. package/lib/commonjs/sqlite/catalog.js.map +1 -0
  120. package/lib/commonjs/sqlite/connection.js +210 -0
  121. package/lib/commonjs/sqlite/connection.js.map +1 -0
  122. package/lib/commonjs/sqlite/index-coverage.js +42 -0
  123. package/lib/commonjs/sqlite/index-coverage.js.map +1 -0
  124. package/lib/commonjs/sqlite/native.js +54 -0
  125. package/lib/commonjs/sqlite/native.js.map +1 -0
  126. package/lib/commonjs/sqlite/row-codec.js +192 -0
  127. package/lib/commonjs/sqlite/row-codec.js.map +1 -0
  128. package/lib/commonjs/sqlite/sql-builder.js +253 -0
  129. package/lib/commonjs/sqlite/sql-builder.js.map +1 -0
  130. package/lib/commonjs/sqlite/statements.js +54 -0
  131. package/lib/commonjs/sqlite/statements.js.map +1 -0
  132. package/lib/commonjs/sqlite/transaction-queue.js +79 -0
  133. package/lib/commonjs/sqlite/transaction-queue.js.map +1 -0
  134. package/lib/commonjs/sqlite/transactions.js +33 -0
  135. package/lib/commonjs/sqlite/transactions.js.map +1 -0
  136. package/lib/commonjs/sqlite/values.js +31 -0
  137. package/lib/commonjs/sqlite/values.js.map +1 -0
  138. package/lib/commonjs/testing/conformance/attachments.js +180 -0
  139. package/lib/commonjs/testing/conformance/attachments.js.map +1 -0
  140. package/lib/commonjs/testing/conformance/encryption.js +187 -0
  141. package/lib/commonjs/testing/conformance/encryption.js.map +1 -0
  142. package/lib/commonjs/testing/conformance/index.js +103 -0
  143. package/lib/commonjs/testing/conformance/index.js.map +1 -0
  144. package/lib/commonjs/testing/conformance/lifecycle.js +134 -0
  145. package/lib/commonjs/testing/conformance/lifecycle.js.map +1 -0
  146. package/lib/commonjs/testing/conformance/migrations.js +167 -0
  147. package/lib/commonjs/testing/conformance/migrations.js.map +1 -0
  148. package/lib/commonjs/testing/conformance/queries.js +278 -0
  149. package/lib/commonjs/testing/conformance/queries.js.map +1 -0
  150. package/lib/commonjs/testing/conformance/records.js +224 -0
  151. package/lib/commonjs/testing/conformance/records.js.map +1 -0
  152. package/lib/commonjs/testing/conformance/scopes.js +107 -0
  153. package/lib/commonjs/testing/conformance/scopes.js.map +1 -0
  154. package/lib/commonjs/testing/conformance/transactions.js +228 -0
  155. package/lib/commonjs/testing/conformance/transactions.js.map +1 -0
  156. package/lib/commonjs/testing/faults.js +38 -0
  157. package/lib/commonjs/testing/faults.js.map +1 -0
  158. package/lib/commonjs/testing/index.js +59 -0
  159. package/lib/commonjs/testing/index.js.map +1 -0
  160. package/lib/commonjs/testing/memory-adapter/attachments.js +145 -0
  161. package/lib/commonjs/testing/memory-adapter/attachments.js.map +1 -0
  162. package/lib/commonjs/testing/memory-adapter/collection.js +224 -0
  163. package/lib/commonjs/testing/memory-adapter/collection.js.map +1 -0
  164. package/lib/commonjs/testing/memory-adapter/index.js +366 -0
  165. package/lib/commonjs/testing/memory-adapter/index.js.map +1 -0
  166. package/lib/commonjs/testing/memory-adapter/migrations.js +126 -0
  167. package/lib/commonjs/testing/memory-adapter/migrations.js.map +1 -0
  168. package/lib/commonjs/testing/memory-adapter/reset.js +49 -0
  169. package/lib/commonjs/testing/memory-adapter/reset.js.map +1 -0
  170. package/lib/commonjs/testing/memory-adapter/store.js +107 -0
  171. package/lib/commonjs/testing/memory-adapter/store.js.map +1 -0
  172. package/lib/module/adapter/budgets.js +51 -0
  173. package/lib/module/adapter/budgets.js.map +1 -0
  174. package/lib/module/adapter/collection.js +232 -0
  175. package/lib/module/adapter/collection.js.map +1 -0
  176. package/lib/module/adapter/deletion.js +280 -0
  177. package/lib/module/adapter/deletion.js.map +1 -0
  178. package/lib/module/adapter/handle.js +254 -0
  179. package/lib/module/adapter/handle.js.map +1 -0
  180. package/lib/module/adapter/index.js +59 -0
  181. package/lib/module/adapter/index.js.map +1 -0
  182. package/lib/module/adapter/lifecycle.js +172 -0
  183. package/lib/module/adapter/lifecycle.js.map +1 -0
  184. package/lib/module/adapter/schema-sync.js +121 -0
  185. package/lib/module/adapter/schema-sync.js.map +1 -0
  186. package/lib/module/adapter/transaction.js +54 -0
  187. package/lib/module/adapter/transaction.js.map +1 -0
  188. package/lib/module/artifacts/availability.js +86 -0
  189. package/lib/module/artifacts/availability.js.map +1 -0
  190. package/lib/module/artifacts/cascade.js +75 -0
  191. package/lib/module/artifacts/cascade.js.map +1 -0
  192. package/lib/module/artifacts/paths.js +26 -0
  193. package/lib/module/artifacts/paths.js.map +1 -0
  194. package/lib/module/artifacts/reconcile.js +51 -0
  195. package/lib/module/artifacts/reconcile.js.map +1 -0
  196. package/lib/module/artifacts/store.js +289 -0
  197. package/lib/module/artifacts/store.js.map +1 -0
  198. package/lib/module/contract/adapter.js +4 -0
  199. package/lib/module/contract/adapter.js.map +1 -0
  200. package/lib/module/contract/attachment.js +2 -0
  201. package/lib/module/contract/attachment.js.map +1 -0
  202. package/lib/module/contract/backup.js +2 -0
  203. package/lib/module/contract/backup.js.map +1 -0
  204. package/lib/module/contract/config.js +27 -0
  205. package/lib/module/contract/config.js.map +1 -0
  206. package/lib/module/contract/encryption.js +4 -0
  207. package/lib/module/contract/encryption.js.map +1 -0
  208. package/lib/module/contract/errors.js +60 -0
  209. package/lib/module/contract/errors.js.map +1 -0
  210. package/lib/module/contract/migration.js +4 -0
  211. package/lib/module/contract/migration.js.map +1 -0
  212. package/lib/module/contract/query.js +4 -0
  213. package/lib/module/contract/query.js.map +1 -0
  214. package/lib/module/contract/record.js +4 -0
  215. package/lib/module/contract/record.js.map +1 -0
  216. package/lib/module/contract/schema.js +2 -0
  217. package/lib/module/contract/schema.js.map +1 -0
  218. package/lib/module/contract/scope.js +2 -0
  219. package/lib/module/contract/scope.js.map +1 -0
  220. package/lib/module/contract/transaction.js +4 -0
  221. package/lib/module/contract/transaction.js.map +1 -0
  222. package/lib/module/crypto/chunked-cipher.js +134 -0
  223. package/lib/module/crypto/chunked-cipher.js.map +1 -0
  224. package/lib/module/crypto/derive.js +56 -0
  225. package/lib/module/crypto/derive.js.map +1 -0
  226. package/lib/module/crypto/key-provider.js +67 -0
  227. package/lib/module/crypto/key-provider.js.map +1 -0
  228. package/lib/module/crypto/provider.js +49 -0
  229. package/lib/module/crypto/provider.js.map +1 -0
  230. package/lib/module/diagnostics/dev-log.js +120 -0
  231. package/lib/module/diagnostics/dev-log.js.map +1 -0
  232. package/lib/module/diagnostics/errors.js +44 -0
  233. package/lib/module/diagnostics/errors.js.map +1 -0
  234. package/lib/module/diagnostics/faults.js +47 -0
  235. package/lib/module/diagnostics/faults.js.map +1 -0
  236. package/lib/module/diagnostics/map-native.js +93 -0
  237. package/lib/module/diagnostics/map-native.js.map +1 -0
  238. package/lib/module/diagnostics/redact.js +102 -0
  239. package/lib/module/diagnostics/redact.js.map +1 -0
  240. package/lib/module/index.js +28 -0
  241. package/lib/module/index.js.map +1 -0
  242. package/lib/module/migration/executor.js +132 -0
  243. package/lib/module/migration/executor.js.map +1 -0
  244. package/lib/module/migration/ledger.js +57 -0
  245. package/lib/module/migration/ledger.js.map +1 -0
  246. package/lib/module/migration/validate-chain.js +70 -0
  247. package/lib/module/migration/validate-chain.js.map +1 -0
  248. package/lib/module/package.json +1 -0
  249. package/lib/module/platform/backup-android-verify.js +69 -0
  250. package/lib/module/platform/backup-android-verify.js.map +1 -0
  251. package/lib/module/platform/backup-ios.js +44 -0
  252. package/lib/module/platform/backup-ios.js.map +1 -0
  253. package/lib/module/platform/bytes.js +148 -0
  254. package/lib/module/platform/bytes.js.map +1 -0
  255. package/lib/module/platform/fs.js +54 -0
  256. package/lib/module/platform/fs.js.map +1 -0
  257. package/lib/module/platform/location.js +120 -0
  258. package/lib/module/platform/location.js.map +1 -0
  259. package/lib/module/query/budgets.js +88 -0
  260. package/lib/module/query/budgets.js.map +1 -0
  261. package/lib/module/query/compare.js +90 -0
  262. package/lib/module/query/compare.js.map +1 -0
  263. package/lib/module/query/cursor.js +91 -0
  264. package/lib/module/query/cursor.js.map +1 -0
  265. package/lib/module/query/filter.js +78 -0
  266. package/lib/module/query/filter.js.map +1 -0
  267. package/lib/module/query/paginate.js +40 -0
  268. package/lib/module/query/paginate.js.map +1 -0
  269. package/lib/module/query/sort.js +53 -0
  270. package/lib/module/query/sort.js.map +1 -0
  271. package/lib/module/query/validate.js +173 -0
  272. package/lib/module/query/validate.js.map +1 -0
  273. package/lib/module/schema/declare.js +37 -0
  274. package/lib/module/schema/declare.js.map +1 -0
  275. package/lib/module/schema/validate-config.js +111 -0
  276. package/lib/module/schema/validate-config.js.map +1 -0
  277. package/lib/module/scope/hash.js +102 -0
  278. package/lib/module/scope/hash.js.map +1 -0
  279. package/lib/module/scope/normalize.js +67 -0
  280. package/lib/module/scope/normalize.js.map +1 -0
  281. package/lib/module/scope/validate.js +76 -0
  282. package/lib/module/scope/validate.js.map +1 -0
  283. package/lib/module/sqlite/adapter.js +27 -0
  284. package/lib/module/sqlite/adapter.js.map +1 -0
  285. package/lib/module/sqlite/batch.js +214 -0
  286. package/lib/module/sqlite/batch.js.map +1 -0
  287. package/lib/module/sqlite/catalog.js +72 -0
  288. package/lib/module/sqlite/catalog.js.map +1 -0
  289. package/lib/module/sqlite/connection.js +206 -0
  290. package/lib/module/sqlite/connection.js.map +1 -0
  291. package/lib/module/sqlite/index-coverage.js +38 -0
  292. package/lib/module/sqlite/index-coverage.js.map +1 -0
  293. package/lib/module/sqlite/native.js +48 -0
  294. package/lib/module/sqlite/native.js.map +1 -0
  295. package/lib/module/sqlite/row-codec.js +176 -0
  296. package/lib/module/sqlite/row-codec.js.map +1 -0
  297. package/lib/module/sqlite/sql-builder.js +247 -0
  298. package/lib/module/sqlite/sql-builder.js.map +1 -0
  299. package/lib/module/sqlite/statements.js +49 -0
  300. package/lib/module/sqlite/statements.js.map +1 -0
  301. package/lib/module/sqlite/transaction-queue.js +75 -0
  302. package/lib/module/sqlite/transaction-queue.js.map +1 -0
  303. package/lib/module/sqlite/transactions.js +29 -0
  304. package/lib/module/sqlite/transactions.js.map +1 -0
  305. package/lib/module/sqlite/values.js +24 -0
  306. package/lib/module/sqlite/values.js.map +1 -0
  307. package/lib/module/testing/conformance/attachments.js +176 -0
  308. package/lib/module/testing/conformance/attachments.js.map +1 -0
  309. package/lib/module/testing/conformance/encryption.js +183 -0
  310. package/lib/module/testing/conformance/encryption.js.map +1 -0
  311. package/lib/module/testing/conformance/index.js +97 -0
  312. package/lib/module/testing/conformance/index.js.map +1 -0
  313. package/lib/module/testing/conformance/lifecycle.js +130 -0
  314. package/lib/module/testing/conformance/lifecycle.js.map +1 -0
  315. package/lib/module/testing/conformance/migrations.js +163 -0
  316. package/lib/module/testing/conformance/migrations.js.map +1 -0
  317. package/lib/module/testing/conformance/queries.js +274 -0
  318. package/lib/module/testing/conformance/queries.js.map +1 -0
  319. package/lib/module/testing/conformance/records.js +220 -0
  320. package/lib/module/testing/conformance/records.js.map +1 -0
  321. package/lib/module/testing/conformance/scopes.js +103 -0
  322. package/lib/module/testing/conformance/scopes.js.map +1 -0
  323. package/lib/module/testing/conformance/transactions.js +224 -0
  324. package/lib/module/testing/conformance/transactions.js.map +1 -0
  325. package/lib/module/testing/faults.js +16 -0
  326. package/lib/module/testing/faults.js.map +1 -0
  327. package/lib/module/testing/index.js +16 -0
  328. package/lib/module/testing/index.js.map +1 -0
  329. package/lib/module/testing/memory-adapter/attachments.js +142 -0
  330. package/lib/module/testing/memory-adapter/attachments.js.map +1 -0
  331. package/lib/module/testing/memory-adapter/collection.js +220 -0
  332. package/lib/module/testing/memory-adapter/collection.js.map +1 -0
  333. package/lib/module/testing/memory-adapter/index.js +351 -0
  334. package/lib/module/testing/memory-adapter/index.js.map +1 -0
  335. package/lib/module/testing/memory-adapter/migrations.js +122 -0
  336. package/lib/module/testing/memory-adapter/migrations.js.map +1 -0
  337. package/lib/module/testing/memory-adapter/reset.js +44 -0
  338. package/lib/module/testing/memory-adapter/reset.js.map +1 -0
  339. package/lib/module/testing/memory-adapter/store.js +94 -0
  340. package/lib/module/testing/memory-adapter/store.js.map +1 -0
  341. package/lib/typescript/commonjs/adapter/budgets.d.ts +19 -0
  342. package/lib/typescript/commonjs/adapter/budgets.d.ts.map +1 -0
  343. package/lib/typescript/commonjs/adapter/collection.d.ts +25 -0
  344. package/lib/typescript/commonjs/adapter/collection.d.ts.map +1 -0
  345. package/lib/typescript/commonjs/adapter/deletion.d.ts +48 -0
  346. package/lib/typescript/commonjs/adapter/deletion.d.ts.map +1 -0
  347. package/lib/typescript/commonjs/adapter/handle.d.ts +30 -0
  348. package/lib/typescript/commonjs/adapter/handle.d.ts.map +1 -0
  349. package/lib/typescript/commonjs/adapter/index.d.ts +30 -0
  350. package/lib/typescript/commonjs/adapter/index.d.ts.map +1 -0
  351. package/lib/typescript/commonjs/adapter/lifecycle.d.ts +25 -0
  352. package/lib/typescript/commonjs/adapter/lifecycle.d.ts.map +1 -0
  353. package/lib/typescript/commonjs/adapter/schema-sync.d.ts +19 -0
  354. package/lib/typescript/commonjs/adapter/schema-sync.d.ts.map +1 -0
  355. package/lib/typescript/commonjs/adapter/transaction.d.ts +32 -0
  356. package/lib/typescript/commonjs/adapter/transaction.d.ts.map +1 -0
  357. package/lib/typescript/commonjs/artifacts/availability.d.ts +19 -0
  358. package/lib/typescript/commonjs/artifacts/availability.d.ts.map +1 -0
  359. package/lib/typescript/commonjs/artifacts/cascade.d.ts +26 -0
  360. package/lib/typescript/commonjs/artifacts/cascade.d.ts.map +1 -0
  361. package/lib/typescript/commonjs/artifacts/paths.d.ts +16 -0
  362. package/lib/typescript/commonjs/artifacts/paths.d.ts.map +1 -0
  363. package/lib/typescript/commonjs/artifacts/reconcile.d.ts +23 -0
  364. package/lib/typescript/commonjs/artifacts/reconcile.d.ts.map +1 -0
  365. package/lib/typescript/commonjs/artifacts/store.d.ts +45 -0
  366. package/lib/typescript/commonjs/artifacts/store.d.ts.map +1 -0
  367. package/lib/typescript/commonjs/contract/adapter.d.ts +55 -0
  368. package/lib/typescript/commonjs/contract/adapter.d.ts.map +1 -0
  369. package/lib/typescript/commonjs/contract/attachment.d.ts +84 -0
  370. package/lib/typescript/commonjs/contract/attachment.d.ts.map +1 -0
  371. package/lib/typescript/commonjs/contract/backup.d.ts +26 -0
  372. package/lib/typescript/commonjs/contract/backup.d.ts.map +1 -0
  373. package/lib/typescript/commonjs/contract/config.d.ts +50 -0
  374. package/lib/typescript/commonjs/contract/config.d.ts.map +1 -0
  375. package/lib/typescript/commonjs/contract/encryption.d.ts +31 -0
  376. package/lib/typescript/commonjs/contract/encryption.d.ts.map +1 -0
  377. package/lib/typescript/commonjs/contract/errors.d.ts +50 -0
  378. package/lib/typescript/commonjs/contract/errors.d.ts.map +1 -0
  379. package/lib/typescript/commonjs/contract/migration.d.ts +37 -0
  380. package/lib/typescript/commonjs/contract/migration.d.ts.map +1 -0
  381. package/lib/typescript/commonjs/contract/query.d.ts +79 -0
  382. package/lib/typescript/commonjs/contract/query.d.ts.map +1 -0
  383. package/lib/typescript/commonjs/contract/record.d.ts +43 -0
  384. package/lib/typescript/commonjs/contract/record.d.ts.map +1 -0
  385. package/lib/typescript/commonjs/contract/schema.d.ts +33 -0
  386. package/lib/typescript/commonjs/contract/schema.d.ts.map +1 -0
  387. package/lib/typescript/commonjs/contract/scope.d.ts +33 -0
  388. package/lib/typescript/commonjs/contract/scope.d.ts.map +1 -0
  389. package/lib/typescript/commonjs/contract/transaction.d.ts +66 -0
  390. package/lib/typescript/commonjs/contract/transaction.d.ts.map +1 -0
  391. package/lib/typescript/commonjs/crypto/chunked-cipher.d.ts +57 -0
  392. package/lib/typescript/commonjs/crypto/chunked-cipher.d.ts.map +1 -0
  393. package/lib/typescript/commonjs/crypto/derive.d.ts +28 -0
  394. package/lib/typescript/commonjs/crypto/derive.d.ts.map +1 -0
  395. package/lib/typescript/commonjs/crypto/key-provider.d.ts +30 -0
  396. package/lib/typescript/commonjs/crypto/key-provider.d.ts.map +1 -0
  397. package/lib/typescript/commonjs/crypto/provider.d.ts +35 -0
  398. package/lib/typescript/commonjs/crypto/provider.d.ts.map +1 -0
  399. package/lib/typescript/commonjs/diagnostics/dev-log.d.ts +35 -0
  400. package/lib/typescript/commonjs/diagnostics/dev-log.d.ts.map +1 -0
  401. package/lib/typescript/commonjs/diagnostics/errors.d.ts +34 -0
  402. package/lib/typescript/commonjs/diagnostics/errors.d.ts.map +1 -0
  403. package/lib/typescript/commonjs/diagnostics/faults.d.ts +26 -0
  404. package/lib/typescript/commonjs/diagnostics/faults.d.ts.map +1 -0
  405. package/lib/typescript/commonjs/diagnostics/map-native.d.ts +31 -0
  406. package/lib/typescript/commonjs/diagnostics/map-native.d.ts.map +1 -0
  407. package/lib/typescript/commonjs/diagnostics/redact.d.ts +70 -0
  408. package/lib/typescript/commonjs/diagnostics/redact.d.ts.map +1 -0
  409. package/lib/typescript/commonjs/index.d.ts +30 -0
  410. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  411. package/lib/typescript/commonjs/migration/executor.d.ts +40 -0
  412. package/lib/typescript/commonjs/migration/executor.d.ts.map +1 -0
  413. package/lib/typescript/commonjs/migration/ledger.d.ts +34 -0
  414. package/lib/typescript/commonjs/migration/ledger.d.ts.map +1 -0
  415. package/lib/typescript/commonjs/migration/validate-chain.d.ts +20 -0
  416. package/lib/typescript/commonjs/migration/validate-chain.d.ts.map +1 -0
  417. package/lib/typescript/commonjs/package.json +1 -0
  418. package/lib/typescript/commonjs/platform/backup-android-verify.d.ts +30 -0
  419. package/lib/typescript/commonjs/platform/backup-android-verify.d.ts.map +1 -0
  420. package/lib/typescript/commonjs/platform/backup-ios.d.ts +26 -0
  421. package/lib/typescript/commonjs/platform/backup-ios.d.ts.map +1 -0
  422. package/lib/typescript/commonjs/platform/bytes.d.ts +36 -0
  423. package/lib/typescript/commonjs/platform/bytes.d.ts.map +1 -0
  424. package/lib/typescript/commonjs/platform/fs.d.ts +47 -0
  425. package/lib/typescript/commonjs/platform/fs.d.ts.map +1 -0
  426. package/lib/typescript/commonjs/platform/location.d.ts +53 -0
  427. package/lib/typescript/commonjs/platform/location.d.ts.map +1 -0
  428. package/lib/typescript/commonjs/query/budgets.d.ts +23 -0
  429. package/lib/typescript/commonjs/query/budgets.d.ts.map +1 -0
  430. package/lib/typescript/commonjs/query/compare.d.ts +42 -0
  431. package/lib/typescript/commonjs/query/compare.d.ts.map +1 -0
  432. package/lib/typescript/commonjs/query/cursor.d.ts +27 -0
  433. package/lib/typescript/commonjs/query/cursor.d.ts.map +1 -0
  434. package/lib/typescript/commonjs/query/filter.d.ts +11 -0
  435. package/lib/typescript/commonjs/query/filter.d.ts.map +1 -0
  436. package/lib/typescript/commonjs/query/paginate.d.ts +15 -0
  437. package/lib/typescript/commonjs/query/paginate.d.ts.map +1 -0
  438. package/lib/typescript/commonjs/query/sort.d.ts +19 -0
  439. package/lib/typescript/commonjs/query/sort.d.ts.map +1 -0
  440. package/lib/typescript/commonjs/query/validate.d.ts +15 -0
  441. package/lib/typescript/commonjs/query/validate.d.ts.map +1 -0
  442. package/lib/typescript/commonjs/schema/declare.d.ts +20 -0
  443. package/lib/typescript/commonjs/schema/declare.d.ts.map +1 -0
  444. package/lib/typescript/commonjs/schema/validate-config.d.ts +11 -0
  445. package/lib/typescript/commonjs/schema/validate-config.d.ts.map +1 -0
  446. package/lib/typescript/commonjs/scope/hash.d.ts +24 -0
  447. package/lib/typescript/commonjs/scope/hash.d.ts.map +1 -0
  448. package/lib/typescript/commonjs/scope/normalize.d.ts +46 -0
  449. package/lib/typescript/commonjs/scope/normalize.d.ts.map +1 -0
  450. package/lib/typescript/commonjs/scope/validate.d.ts +15 -0
  451. package/lib/typescript/commonjs/scope/validate.d.ts.map +1 -0
  452. package/lib/typescript/commonjs/sqlite/adapter.d.ts +16 -0
  453. package/lib/typescript/commonjs/sqlite/adapter.d.ts.map +1 -0
  454. package/lib/typescript/commonjs/sqlite/batch.d.ts +25 -0
  455. package/lib/typescript/commonjs/sqlite/batch.d.ts.map +1 -0
  456. package/lib/typescript/commonjs/sqlite/catalog.d.ts +34 -0
  457. package/lib/typescript/commonjs/sqlite/catalog.d.ts.map +1 -0
  458. package/lib/typescript/commonjs/sqlite/connection.d.ts +58 -0
  459. package/lib/typescript/commonjs/sqlite/connection.d.ts.map +1 -0
  460. package/lib/typescript/commonjs/sqlite/index-coverage.d.ts +18 -0
  461. package/lib/typescript/commonjs/sqlite/index-coverage.d.ts.map +1 -0
  462. package/lib/typescript/commonjs/sqlite/native.d.ts +48 -0
  463. package/lib/typescript/commonjs/sqlite/native.d.ts.map +1 -0
  464. package/lib/typescript/commonjs/sqlite/row-codec.d.ts +69 -0
  465. package/lib/typescript/commonjs/sqlite/row-codec.d.ts.map +1 -0
  466. package/lib/typescript/commonjs/sqlite/sql-builder.d.ts +34 -0
  467. package/lib/typescript/commonjs/sqlite/sql-builder.d.ts.map +1 -0
  468. package/lib/typescript/commonjs/sqlite/statements.d.ts +26 -0
  469. package/lib/typescript/commonjs/sqlite/statements.d.ts.map +1 -0
  470. package/lib/typescript/commonjs/sqlite/transaction-queue.d.ts +31 -0
  471. package/lib/typescript/commonjs/sqlite/transaction-queue.d.ts.map +1 -0
  472. package/lib/typescript/commonjs/sqlite/transactions.d.ts +26 -0
  473. package/lib/typescript/commonjs/sqlite/transactions.d.ts.map +1 -0
  474. package/lib/typescript/commonjs/sqlite/values.d.ts +13 -0
  475. package/lib/typescript/commonjs/sqlite/values.d.ts.map +1 -0
  476. package/lib/typescript/commonjs/testing/conformance/attachments.d.ts +4 -0
  477. package/lib/typescript/commonjs/testing/conformance/attachments.d.ts.map +1 -0
  478. package/lib/typescript/commonjs/testing/conformance/encryption.d.ts +4 -0
  479. package/lib/typescript/commonjs/testing/conformance/encryption.d.ts.map +1 -0
  480. package/lib/typescript/commonjs/testing/conformance/index.d.ts +58 -0
  481. package/lib/typescript/commonjs/testing/conformance/index.d.ts.map +1 -0
  482. package/lib/typescript/commonjs/testing/conformance/lifecycle.d.ts +4 -0
  483. package/lib/typescript/commonjs/testing/conformance/lifecycle.d.ts.map +1 -0
  484. package/lib/typescript/commonjs/testing/conformance/migrations.d.ts +4 -0
  485. package/lib/typescript/commonjs/testing/conformance/migrations.d.ts.map +1 -0
  486. package/lib/typescript/commonjs/testing/conformance/queries.d.ts +4 -0
  487. package/lib/typescript/commonjs/testing/conformance/queries.d.ts.map +1 -0
  488. package/lib/typescript/commonjs/testing/conformance/records.d.ts +4 -0
  489. package/lib/typescript/commonjs/testing/conformance/records.d.ts.map +1 -0
  490. package/lib/typescript/commonjs/testing/conformance/scopes.d.ts +4 -0
  491. package/lib/typescript/commonjs/testing/conformance/scopes.d.ts.map +1 -0
  492. package/lib/typescript/commonjs/testing/conformance/transactions.d.ts +4 -0
  493. package/lib/typescript/commonjs/testing/conformance/transactions.d.ts.map +1 -0
  494. package/lib/typescript/commonjs/testing/faults.d.ts +13 -0
  495. package/lib/typescript/commonjs/testing/faults.d.ts.map +1 -0
  496. package/lib/typescript/commonjs/testing/index.d.ts +13 -0
  497. package/lib/typescript/commonjs/testing/index.d.ts.map +1 -0
  498. package/lib/typescript/commonjs/testing/memory-adapter/attachments.d.ts +23 -0
  499. package/lib/typescript/commonjs/testing/memory-adapter/attachments.d.ts.map +1 -0
  500. package/lib/typescript/commonjs/testing/memory-adapter/collection.d.ts +19 -0
  501. package/lib/typescript/commonjs/testing/memory-adapter/collection.d.ts.map +1 -0
  502. package/lib/typescript/commonjs/testing/memory-adapter/index.d.ts +22 -0
  503. package/lib/typescript/commonjs/testing/memory-adapter/index.d.ts.map +1 -0
  504. package/lib/typescript/commonjs/testing/memory-adapter/migrations.d.ts +11 -0
  505. package/lib/typescript/commonjs/testing/memory-adapter/migrations.d.ts.map +1 -0
  506. package/lib/typescript/commonjs/testing/memory-adapter/reset.d.ts +23 -0
  507. package/lib/typescript/commonjs/testing/memory-adapter/reset.d.ts.map +1 -0
  508. package/lib/typescript/commonjs/testing/memory-adapter/store.d.ts +54 -0
  509. package/lib/typescript/commonjs/testing/memory-adapter/store.d.ts.map +1 -0
  510. package/lib/typescript/module/adapter/budgets.d.ts +19 -0
  511. package/lib/typescript/module/adapter/budgets.d.ts.map +1 -0
  512. package/lib/typescript/module/adapter/collection.d.ts +25 -0
  513. package/lib/typescript/module/adapter/collection.d.ts.map +1 -0
  514. package/lib/typescript/module/adapter/deletion.d.ts +48 -0
  515. package/lib/typescript/module/adapter/deletion.d.ts.map +1 -0
  516. package/lib/typescript/module/adapter/handle.d.ts +30 -0
  517. package/lib/typescript/module/adapter/handle.d.ts.map +1 -0
  518. package/lib/typescript/module/adapter/index.d.ts +30 -0
  519. package/lib/typescript/module/adapter/index.d.ts.map +1 -0
  520. package/lib/typescript/module/adapter/lifecycle.d.ts +25 -0
  521. package/lib/typescript/module/adapter/lifecycle.d.ts.map +1 -0
  522. package/lib/typescript/module/adapter/schema-sync.d.ts +19 -0
  523. package/lib/typescript/module/adapter/schema-sync.d.ts.map +1 -0
  524. package/lib/typescript/module/adapter/transaction.d.ts +32 -0
  525. package/lib/typescript/module/adapter/transaction.d.ts.map +1 -0
  526. package/lib/typescript/module/artifacts/availability.d.ts +19 -0
  527. package/lib/typescript/module/artifacts/availability.d.ts.map +1 -0
  528. package/lib/typescript/module/artifacts/cascade.d.ts +26 -0
  529. package/lib/typescript/module/artifacts/cascade.d.ts.map +1 -0
  530. package/lib/typescript/module/artifacts/paths.d.ts +16 -0
  531. package/lib/typescript/module/artifacts/paths.d.ts.map +1 -0
  532. package/lib/typescript/module/artifacts/reconcile.d.ts +23 -0
  533. package/lib/typescript/module/artifacts/reconcile.d.ts.map +1 -0
  534. package/lib/typescript/module/artifacts/store.d.ts +45 -0
  535. package/lib/typescript/module/artifacts/store.d.ts.map +1 -0
  536. package/lib/typescript/module/contract/adapter.d.ts +55 -0
  537. package/lib/typescript/module/contract/adapter.d.ts.map +1 -0
  538. package/lib/typescript/module/contract/attachment.d.ts +84 -0
  539. package/lib/typescript/module/contract/attachment.d.ts.map +1 -0
  540. package/lib/typescript/module/contract/backup.d.ts +26 -0
  541. package/lib/typescript/module/contract/backup.d.ts.map +1 -0
  542. package/lib/typescript/module/contract/config.d.ts +50 -0
  543. package/lib/typescript/module/contract/config.d.ts.map +1 -0
  544. package/lib/typescript/module/contract/encryption.d.ts +31 -0
  545. package/lib/typescript/module/contract/encryption.d.ts.map +1 -0
  546. package/lib/typescript/module/contract/errors.d.ts +50 -0
  547. package/lib/typescript/module/contract/errors.d.ts.map +1 -0
  548. package/lib/typescript/module/contract/migration.d.ts +37 -0
  549. package/lib/typescript/module/contract/migration.d.ts.map +1 -0
  550. package/lib/typescript/module/contract/query.d.ts +79 -0
  551. package/lib/typescript/module/contract/query.d.ts.map +1 -0
  552. package/lib/typescript/module/contract/record.d.ts +43 -0
  553. package/lib/typescript/module/contract/record.d.ts.map +1 -0
  554. package/lib/typescript/module/contract/schema.d.ts +33 -0
  555. package/lib/typescript/module/contract/schema.d.ts.map +1 -0
  556. package/lib/typescript/module/contract/scope.d.ts +33 -0
  557. package/lib/typescript/module/contract/scope.d.ts.map +1 -0
  558. package/lib/typescript/module/contract/transaction.d.ts +66 -0
  559. package/lib/typescript/module/contract/transaction.d.ts.map +1 -0
  560. package/lib/typescript/module/crypto/chunked-cipher.d.ts +57 -0
  561. package/lib/typescript/module/crypto/chunked-cipher.d.ts.map +1 -0
  562. package/lib/typescript/module/crypto/derive.d.ts +28 -0
  563. package/lib/typescript/module/crypto/derive.d.ts.map +1 -0
  564. package/lib/typescript/module/crypto/key-provider.d.ts +30 -0
  565. package/lib/typescript/module/crypto/key-provider.d.ts.map +1 -0
  566. package/lib/typescript/module/crypto/provider.d.ts +35 -0
  567. package/lib/typescript/module/crypto/provider.d.ts.map +1 -0
  568. package/lib/typescript/module/diagnostics/dev-log.d.ts +35 -0
  569. package/lib/typescript/module/diagnostics/dev-log.d.ts.map +1 -0
  570. package/lib/typescript/module/diagnostics/errors.d.ts +34 -0
  571. package/lib/typescript/module/diagnostics/errors.d.ts.map +1 -0
  572. package/lib/typescript/module/diagnostics/faults.d.ts +26 -0
  573. package/lib/typescript/module/diagnostics/faults.d.ts.map +1 -0
  574. package/lib/typescript/module/diagnostics/map-native.d.ts +31 -0
  575. package/lib/typescript/module/diagnostics/map-native.d.ts.map +1 -0
  576. package/lib/typescript/module/diagnostics/redact.d.ts +70 -0
  577. package/lib/typescript/module/diagnostics/redact.d.ts.map +1 -0
  578. package/lib/typescript/module/index.d.ts +30 -0
  579. package/lib/typescript/module/index.d.ts.map +1 -0
  580. package/lib/typescript/module/migration/executor.d.ts +40 -0
  581. package/lib/typescript/module/migration/executor.d.ts.map +1 -0
  582. package/lib/typescript/module/migration/ledger.d.ts +34 -0
  583. package/lib/typescript/module/migration/ledger.d.ts.map +1 -0
  584. package/lib/typescript/module/migration/validate-chain.d.ts +20 -0
  585. package/lib/typescript/module/migration/validate-chain.d.ts.map +1 -0
  586. package/lib/typescript/module/package.json +1 -0
  587. package/lib/typescript/module/platform/backup-android-verify.d.ts +30 -0
  588. package/lib/typescript/module/platform/backup-android-verify.d.ts.map +1 -0
  589. package/lib/typescript/module/platform/backup-ios.d.ts +26 -0
  590. package/lib/typescript/module/platform/backup-ios.d.ts.map +1 -0
  591. package/lib/typescript/module/platform/bytes.d.ts +36 -0
  592. package/lib/typescript/module/platform/bytes.d.ts.map +1 -0
  593. package/lib/typescript/module/platform/fs.d.ts +47 -0
  594. package/lib/typescript/module/platform/fs.d.ts.map +1 -0
  595. package/lib/typescript/module/platform/location.d.ts +53 -0
  596. package/lib/typescript/module/platform/location.d.ts.map +1 -0
  597. package/lib/typescript/module/query/budgets.d.ts +23 -0
  598. package/lib/typescript/module/query/budgets.d.ts.map +1 -0
  599. package/lib/typescript/module/query/compare.d.ts +42 -0
  600. package/lib/typescript/module/query/compare.d.ts.map +1 -0
  601. package/lib/typescript/module/query/cursor.d.ts +27 -0
  602. package/lib/typescript/module/query/cursor.d.ts.map +1 -0
  603. package/lib/typescript/module/query/filter.d.ts +11 -0
  604. package/lib/typescript/module/query/filter.d.ts.map +1 -0
  605. package/lib/typescript/module/query/paginate.d.ts +15 -0
  606. package/lib/typescript/module/query/paginate.d.ts.map +1 -0
  607. package/lib/typescript/module/query/sort.d.ts +19 -0
  608. package/lib/typescript/module/query/sort.d.ts.map +1 -0
  609. package/lib/typescript/module/query/validate.d.ts +15 -0
  610. package/lib/typescript/module/query/validate.d.ts.map +1 -0
  611. package/lib/typescript/module/schema/declare.d.ts +20 -0
  612. package/lib/typescript/module/schema/declare.d.ts.map +1 -0
  613. package/lib/typescript/module/schema/validate-config.d.ts +11 -0
  614. package/lib/typescript/module/schema/validate-config.d.ts.map +1 -0
  615. package/lib/typescript/module/scope/hash.d.ts +24 -0
  616. package/lib/typescript/module/scope/hash.d.ts.map +1 -0
  617. package/lib/typescript/module/scope/normalize.d.ts +46 -0
  618. package/lib/typescript/module/scope/normalize.d.ts.map +1 -0
  619. package/lib/typescript/module/scope/validate.d.ts +15 -0
  620. package/lib/typescript/module/scope/validate.d.ts.map +1 -0
  621. package/lib/typescript/module/sqlite/adapter.d.ts +16 -0
  622. package/lib/typescript/module/sqlite/adapter.d.ts.map +1 -0
  623. package/lib/typescript/module/sqlite/batch.d.ts +25 -0
  624. package/lib/typescript/module/sqlite/batch.d.ts.map +1 -0
  625. package/lib/typescript/module/sqlite/catalog.d.ts +34 -0
  626. package/lib/typescript/module/sqlite/catalog.d.ts.map +1 -0
  627. package/lib/typescript/module/sqlite/connection.d.ts +58 -0
  628. package/lib/typescript/module/sqlite/connection.d.ts.map +1 -0
  629. package/lib/typescript/module/sqlite/index-coverage.d.ts +18 -0
  630. package/lib/typescript/module/sqlite/index-coverage.d.ts.map +1 -0
  631. package/lib/typescript/module/sqlite/native.d.ts +48 -0
  632. package/lib/typescript/module/sqlite/native.d.ts.map +1 -0
  633. package/lib/typescript/module/sqlite/row-codec.d.ts +69 -0
  634. package/lib/typescript/module/sqlite/row-codec.d.ts.map +1 -0
  635. package/lib/typescript/module/sqlite/sql-builder.d.ts +34 -0
  636. package/lib/typescript/module/sqlite/sql-builder.d.ts.map +1 -0
  637. package/lib/typescript/module/sqlite/statements.d.ts +26 -0
  638. package/lib/typescript/module/sqlite/statements.d.ts.map +1 -0
  639. package/lib/typescript/module/sqlite/transaction-queue.d.ts +31 -0
  640. package/lib/typescript/module/sqlite/transaction-queue.d.ts.map +1 -0
  641. package/lib/typescript/module/sqlite/transactions.d.ts +26 -0
  642. package/lib/typescript/module/sqlite/transactions.d.ts.map +1 -0
  643. package/lib/typescript/module/sqlite/values.d.ts +13 -0
  644. package/lib/typescript/module/sqlite/values.d.ts.map +1 -0
  645. package/lib/typescript/module/testing/conformance/attachments.d.ts +4 -0
  646. package/lib/typescript/module/testing/conformance/attachments.d.ts.map +1 -0
  647. package/lib/typescript/module/testing/conformance/encryption.d.ts +4 -0
  648. package/lib/typescript/module/testing/conformance/encryption.d.ts.map +1 -0
  649. package/lib/typescript/module/testing/conformance/index.d.ts +58 -0
  650. package/lib/typescript/module/testing/conformance/index.d.ts.map +1 -0
  651. package/lib/typescript/module/testing/conformance/lifecycle.d.ts +4 -0
  652. package/lib/typescript/module/testing/conformance/lifecycle.d.ts.map +1 -0
  653. package/lib/typescript/module/testing/conformance/migrations.d.ts +4 -0
  654. package/lib/typescript/module/testing/conformance/migrations.d.ts.map +1 -0
  655. package/lib/typescript/module/testing/conformance/queries.d.ts +4 -0
  656. package/lib/typescript/module/testing/conformance/queries.d.ts.map +1 -0
  657. package/lib/typescript/module/testing/conformance/records.d.ts +4 -0
  658. package/lib/typescript/module/testing/conformance/records.d.ts.map +1 -0
  659. package/lib/typescript/module/testing/conformance/scopes.d.ts +4 -0
  660. package/lib/typescript/module/testing/conformance/scopes.d.ts.map +1 -0
  661. package/lib/typescript/module/testing/conformance/transactions.d.ts +4 -0
  662. package/lib/typescript/module/testing/conformance/transactions.d.ts.map +1 -0
  663. package/lib/typescript/module/testing/faults.d.ts +13 -0
  664. package/lib/typescript/module/testing/faults.d.ts.map +1 -0
  665. package/lib/typescript/module/testing/index.d.ts +13 -0
  666. package/lib/typescript/module/testing/index.d.ts.map +1 -0
  667. package/lib/typescript/module/testing/memory-adapter/attachments.d.ts +23 -0
  668. package/lib/typescript/module/testing/memory-adapter/attachments.d.ts.map +1 -0
  669. package/lib/typescript/module/testing/memory-adapter/collection.d.ts +19 -0
  670. package/lib/typescript/module/testing/memory-adapter/collection.d.ts.map +1 -0
  671. package/lib/typescript/module/testing/memory-adapter/index.d.ts +22 -0
  672. package/lib/typescript/module/testing/memory-adapter/index.d.ts.map +1 -0
  673. package/lib/typescript/module/testing/memory-adapter/migrations.d.ts +11 -0
  674. package/lib/typescript/module/testing/memory-adapter/migrations.d.ts.map +1 -0
  675. package/lib/typescript/module/testing/memory-adapter/reset.d.ts +23 -0
  676. package/lib/typescript/module/testing/memory-adapter/reset.d.ts.map +1 -0
  677. package/lib/typescript/module/testing/memory-adapter/store.d.ts +54 -0
  678. package/lib/typescript/module/testing/memory-adapter/store.d.ts.map +1 -0
  679. package/package.json +51 -16
  680. package/src/crypto/provider.ts +7 -3
@@ -0,0 +1,291 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.clearAllInvalidations = clearAllInvalidations;
7
+ exports.clearScopeInvalidation = clearScopeInvalidation;
8
+ exports.deleteDatabase = deleteDatabase;
9
+ exports.deleteScopeData = deleteScopeData;
10
+ exports.emptyOutcome = emptyOutcome;
11
+ exports.isScopeInvalidated = isScopeInvalidated;
12
+ exports.markScopeInvalidated = markScopeInvalidated;
13
+ exports.registerOpenHandle = registerOpenHandle;
14
+ exports.resetScope = resetScope;
15
+ var _fs = require("../platform/fs.js");
16
+ var _location = require("../platform/location.js");
17
+ var _paths = require("../artifacts/paths.js");
18
+ var _keyProvider = require("../crypto/key-provider.js");
19
+ var _compare = require("../query/compare.js");
20
+ var _validate = require("../scope/validate.js");
21
+ var _catalog = require("../sqlite/catalog.js");
22
+ var _connection = require("../sqlite/connection.js");
23
+ var _values = require("../sqlite/values.js");
24
+ /**
25
+ * Deletion, and the ordering that makes an interrupted one visible.
26
+ *
27
+ * These are module-level functions rather than handle methods because they
28
+ * must work whether or not a handle is open on the target (FR-059) — a
29
+ * sign-out that already closed the handle still has to be able to delete, and
30
+ * an app recovering from a crash has no handle to call a method on.
31
+ *
32
+ * The order is: **mark `deleting` first, clear the catalog row last**
33
+ * (FR-061, FR-063). A crash at any point in between leaves the flag set, so
34
+ * the next open reports a scope mid-deletion rather than presenting it as
35
+ * complete. Clearing the row first would be the natural way to write this and
36
+ * would produce exactly the failure FR-063 exists to prevent: an
37
+ * interruption that looks like a success, leaving a user's data on disk after
38
+ * they asked for it to be gone.
39
+ *
40
+ * Nothing here ever runs on its own. No expiry, no sweep, no deletion on
41
+ * close or on app upgrade (FR-058) — the package deletes when asked, where
42
+ * asked, and not otherwise.
43
+ */
44
+
45
+ /**
46
+ * Scopes deleted beneath a handle that is still open.
47
+ *
48
+ * FR-059a wants the handle to report `SCOPE_DELETED` rather than keep
49
+ * answering from a database that no longer exists — and wants the deletion to
50
+ * proceed rather than wait for the handle to be closed. A shared set is the
51
+ * whole mechanism: the deleter records, the handle checks.
52
+ */
53
+ const invalidated = new Set();
54
+ function invalidationKey(name, scopeKey) {
55
+ return `${name}:${scopeKey}`;
56
+ }
57
+ function markScopeInvalidated(name, scopeKey) {
58
+ invalidated.add(invalidationKey(name, scopeKey));
59
+ }
60
+ function clearScopeInvalidation(name, scopeKey) {
61
+ invalidated.delete(invalidationKey(name, scopeKey));
62
+ }
63
+ function isScopeInvalidated(name, scopeKey) {
64
+ return invalidated.has(invalidationKey(name, scopeKey));
65
+ }
66
+ function clearAllInvalidations() {
67
+ invalidated.clear();
68
+ openHandles.clear();
69
+ }
70
+
71
+ /**
72
+ * Handles open on a scope, so a deletion can take their connection away
73
+ * (LDB-14). Marking alone left the native connection and its handle slot held
74
+ * until the app closed a handle it had been told was dead: eight sign-outs
75
+ * later every open failed, with the unlinked file still pinned by its
76
+ * descriptor.
77
+ */
78
+ const openHandles = new Map();
79
+
80
+ /** Returns the function that takes the handle out of the registry again. */
81
+ function registerOpenHandle(name, scopeKey, revoke) {
82
+ const key = invalidationKey(name, scopeKey);
83
+ const handles = openHandles.get(key) ?? new Set();
84
+ handles.add(revoke);
85
+ openHandles.set(key, handles);
86
+ return () => {
87
+ handles.delete(revoke);
88
+ if (handles.size === 0) {
89
+ openHandles.delete(key);
90
+ }
91
+ };
92
+ }
93
+
94
+ /** Every handle on the scope, or on any scope of the database when none is named. */
95
+ async function revokeHandles(name, scopeKey) {
96
+ const prefix = `${name}:`;
97
+ for (const [key, handles] of [...openHandles]) {
98
+ const matches = scopeKey === undefined ? key.startsWith(prefix) : key === invalidationKey(name, scopeKey);
99
+ if (!matches) {
100
+ continue;
101
+ }
102
+ openHandles.delete(key);
103
+ for (const revoke of handles) {
104
+ // A connection that will not close does not get to stop a deletion.
105
+ await revoke().catch(() => undefined);
106
+ }
107
+ }
108
+ }
109
+
110
+ /** Deleting a scope that holds nothing is success, not an error (FR-062). */
111
+ function emptyOutcome(scope) {
112
+ return {
113
+ ...(scope ? {
114
+ scopeKey: scope.key
115
+ } : {}),
116
+ removedRecords: 0,
117
+ removedArtifacts: [],
118
+ orphanedReferences: [],
119
+ failedRemovals: []
120
+ };
121
+ }
122
+
123
+ /**
124
+ * How many records the scope held, best effort.
125
+ *
126
+ * Best effort because an encrypted scope whose caller supplied no key cannot
127
+ * be opened to be counted — and refusing to delete it on that basis would be
128
+ * the worst possible answer to a deletion request. The files come off disk
129
+ * either way; only the number in the report is unavailable.
130
+ */
131
+ async function countRecords(layout, scopeKey, encryptionKey) {
132
+ let connection = null;
133
+ try {
134
+ connection = await (0, _connection.openConnection)({
135
+ path: layout.scopeDataPath(scopeKey),
136
+ ...(encryptionKey ? {
137
+ encryptionKey
138
+ } : {})
139
+ });
140
+ const tables = await connection.execute("SELECT name FROM sqlite_master WHERE type = 'table' AND name LIKE 'c!_%' ESCAPE '!'");
141
+ let total = 0;
142
+ for (const row of tables.rows) {
143
+ const table = (0, _values.text)(row.name);
144
+ const counted = await connection.execute(`SELECT count(*) AS total FROM "${table}"`);
145
+ total += (0, _values.num)(counted.rows[0]?.total ?? 0);
146
+ }
147
+ return total;
148
+ } catch {
149
+ // Unknown, not zero: a report that said "0 records" about a scope it
150
+ // could not open would understate what was deleted.
151
+ return undefined;
152
+ } finally {
153
+ await connection?.close();
154
+ }
155
+ }
156
+ async function artifactIdsOnDisk(layout, scopeKey) {
157
+ try {
158
+ return (await (0, _fs.fileSystem)().readdir((0, _paths.artifactsDirectory)(layout, scopeKey))).sort(_compare.byteOrder);
159
+ } catch {
160
+ return [];
161
+ }
162
+ }
163
+
164
+ /**
165
+ * The one implementation behind `deleteScopeData` and `resetScope`.
166
+ *
167
+ * They do the same thing to disk and mean entirely different things to the
168
+ * caller: one is a lifecycle operation an app performs on request, the other
169
+ * is an admission that a database is broken and is being discarded to recover
170
+ * from it (FR-057a). Keeping them as two exported names with two docstrings
171
+ * is what stops the destructive one from being reached by accident — there is
172
+ * no path from `openDatabase` to either.
173
+ */
174
+ async function removeScope(config) {
175
+ const scope = (0, _validate.resolveScope)(config.scope);
176
+ const layout = (0, _location.layoutFor)(config.name);
177
+ const catalog = await (0, _connection.openConnection)({
178
+ path: layout.catalogPath
179
+ });
180
+ try {
181
+ await (0, _catalog.ensureCatalog)(catalog);
182
+ const entry = await (0, _catalog.readEntry)(catalog, scope.key);
183
+
184
+ // Mark first. Everything after this point is recoverable-in-principle;
185
+ // this flag is what makes an interruption visible rather than silent.
186
+ if (entry) {
187
+ await (0, _catalog.markDeleting)(catalog, scope.key);
188
+ }
189
+ markScopeInvalidated(config.name, scope.key);
190
+ // Before the files go: a connection still open on them pins them.
191
+ await revokeHandles(config.name, scope.key);
192
+ const removedArtifacts = await artifactIdsOnDisk(layout, scope.key);
193
+
194
+ // The key is needed to count what is being removed, not to remove it,
195
+ // so a key provider that fails — or a key already destroyed for this
196
+ // identity, which FR-104 encourages — costs the count, never the
197
+ // deletion. Until 0.2.0 it failed the whole call after the scope was
198
+ // already marked, leaving it stuck in `deleting`.
199
+ let keyHandle = null;
200
+ if (config.encryption?.enabled) {
201
+ try {
202
+ keyHandle = await (0, _keyProvider.acquireKey)(config.encryption, scope);
203
+ } catch {
204
+ keyHandle = null;
205
+ }
206
+ }
207
+ let counted;
208
+ try {
209
+ counted = config.encryption?.enabled && keyHandle === null ? undefined : await countRecords(layout, scope.key, keyHandle?.value());
210
+ } finally {
211
+ keyHandle?.release();
212
+ }
213
+ const failedRemovals = [];
214
+ if (!(await (0, _fs.removeIfPresent)(layout.scopePath(scope.key))) && entry) {
215
+ // The directory was there and would not go. Reporting it is the
216
+ // point: an app that told the user "deleted" would be wrong.
217
+ const stillThere = await (0, _fs.fileSystem)().exists(layout.scopePath(scope.key)).catch(() => false);
218
+ if (stillThere) {
219
+ failedRemovals.push(scope.key);
220
+ }
221
+ }
222
+ if (failedRemovals.length === 0) {
223
+ // Cleared last, on purpose.
224
+ await (0, _catalog.clearScope)(catalog, scope.key);
225
+ }
226
+ return {
227
+ scopeKey: scope.key,
228
+ removedRecords: counted ?? 0,
229
+ ...(counted === undefined ? {
230
+ recordCountUnavailable: true
231
+ } : {}),
232
+ removedArtifacts,
233
+ orphanedReferences: [],
234
+ failedRemovals
235
+ };
236
+ } finally {
237
+ await catalog.close();
238
+ }
239
+ }
240
+
241
+ /**
242
+ * Remove one scope's data. Every collection in that scope, and nothing
243
+ * outside it (FR-059, SC-012).
244
+ */
245
+ function deleteScopeData(config) {
246
+ return removeScope(config);
247
+ }
248
+
249
+ /**
250
+ * Discard one scope and leave it ready for a clean first-run migration
251
+ * (FR-057a).
252
+ *
253
+ * Destructive, separately named, and never reachable from `openDatabase`. An
254
+ * automatic fallback here would turn a bad migration shipped to production
255
+ * into silent data loss for every user who launched the app.
256
+ */
257
+ function resetScope(config) {
258
+ return removeScope(config);
259
+ }
260
+
261
+ /** Remove the whole database directory: catalog, every scope, every artifact. */
262
+ async function deleteDatabase(config) {
263
+ const layout = (0, _location.layoutFor)(config.name);
264
+ let scopeKeys = [];
265
+ try {
266
+ const catalog = await (0, _connection.openConnection)({
267
+ path: layout.catalogPath
268
+ });
269
+ try {
270
+ await (0, _catalog.ensureCatalog)(catalog);
271
+ scopeKeys = (await (0, _catalog.listEntries)(catalog)).map(entry => entry.scopeKey);
272
+ } finally {
273
+ await catalog.close();
274
+ }
275
+ } catch {
276
+ // No catalog means nothing was ever registered here. The directory
277
+ // removal below is still the right thing to attempt.
278
+ }
279
+ for (const scopeKey of scopeKeys) {
280
+ markScopeInvalidated(config.name, scopeKey);
281
+ }
282
+ await revokeHandles(config.name);
283
+ const removed = await (0, _fs.removeIfPresent)(layout.root);
284
+ return {
285
+ removedRecords: 0,
286
+ removedArtifacts: [],
287
+ orphanedReferences: [],
288
+ failedRemovals: removed || scopeKeys.length === 0 ? [] : scopeKeys
289
+ };
290
+ }
291
+ //# sourceMappingURL=deletion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_fs","require","_location","_paths","_keyProvider","_compare","_validate","_catalog","_connection","_values","invalidated","Set","invalidationKey","name","scopeKey","markScopeInvalidated","add","clearScopeInvalidation","delete","isScopeInvalidated","has","clearAllInvalidations","clear","openHandles","Map","registerOpenHandle","revoke","key","handles","get","set","size","revokeHandles","prefix","matches","undefined","startsWith","catch","emptyOutcome","scope","removedRecords","removedArtifacts","orphanedReferences","failedRemovals","countRecords","layout","encryptionKey","connection","openConnection","path","scopeDataPath","tables","execute","total","row","rows","table","text","counted","num","close","artifactIdsOnDisk","fileSystem","readdir","artifactsDirectory","sort","byteOrder","removeScope","config","resolveScope","layoutFor","catalog","catalogPath","ensureCatalog","entry","readEntry","markDeleting","keyHandle","encryption","enabled","acquireKey","value","release","removeIfPresent","scopePath","stillThere","exists","push","length","clearScope","recordCountUnavailable","deleteScopeData","resetScope","deleteDatabase","scopeKeys","listEntries","map","removed","root"],"sourceRoot":"../../../src","sources":["adapter/deletion.ts"],"mappings":";;;;;;;;;;;;;;AAwBA,IAAAA,GAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AAhCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMS,WAAW,GAAG,IAAIC,GAAG,CAAS,CAAC;AAErC,SAASC,eAAeA,CAACC,IAAY,EAAEC,QAAgB,EAAU;EAChE,OAAO,GAAGD,IAAI,IAAIC,QAAQ,EAAE;AAC7B;AAEO,SAASC,oBAAoBA,CAACF,IAAY,EAAEC,QAAgB,EAAQ;EAC1EJ,WAAW,CAACM,GAAG,CAACJ,eAAe,CAACC,IAAI,EAAEC,QAAQ,CAAC,CAAC;AACjD;AAEO,SAASG,sBAAsBA,CAACJ,IAAY,EAAEC,QAAgB,EAAQ;EAC5EJ,WAAW,CAACQ,MAAM,CAACN,eAAe,CAACC,IAAI,EAAEC,QAAQ,CAAC,CAAC;AACpD;AAEO,SAASK,kBAAkBA,CAACN,IAAY,EAAEC,QAAgB,EAAW;EAC3E,OAAOJ,WAAW,CAACU,GAAG,C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AAe,EAACtC,MAAM,CAACqD,IAAI,CAAC;EAClD,OAAO;IACN1D,cAAc,EAAE,CAAC;IACjBC,gBAAgB,EAAE,EAAE;IACpBC,kBAAkB,EAAE,EAAE;IACtBC,cAAc,EAAEsD,OAAO,IAAIH,SAAS,CAACN,MAAM,KAAK,CAAC,GAAG,EAAE,GAAGM;EAC1D,CAAC;AACF","ignoreList":[]}
@@ -0,0 +1,259 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.buildHandle = buildHandle;
7
+ exports.schemaFor = schemaFor;
8
+ var _errors = require("../contract/errors.js");
9
+ var _availability = require("../artifacts/availability.js");
10
+ var _cascade = require("../artifacts/cascade.js");
11
+ var _reconcile = require("../artifacts/reconcile.js");
12
+ var _store = require("../artifacts/store.js");
13
+ var _derive = require("../crypto/derive.js");
14
+ var _errors2 = require("../diagnostics/errors.js");
15
+ var _devLog = require("../diagnostics/dev-log.js");
16
+ var _faults = require("../diagnostics/faults.js");
17
+ var _sort = require("../query/sort.js");
18
+ var _batch = require("../sqlite/batch.js");
19
+ var _indexCoverage = require("../sqlite/index-coverage.js");
20
+ var _transactions = require("../sqlite/transactions.js");
21
+ var _budgets = require("./budgets.js");
22
+ var _collection = require("./collection.js");
23
+ var _deletion = require("./deletion.js");
24
+ var _transaction = require("./transaction.js");
25
+ /**
26
+ * The handle an open returns: collections, transactions, batches and
27
+ * attachments over one connection, bound to one scope.
28
+ *
29
+ * Scope is bound here and nowhere else. The handle carries its scope key and
30
+ * no operation on it accepts a scope argument, so there is no `switchScope`
31
+ * to misuse and no read that could address another scope (FR-008a, FR-015).
32
+ */
33
+
34
+ function schemaFor(schemas, name) {
35
+ const schema = schemas.get(name);
36
+ if (!schema) {
37
+ (0, _errors2.raise)(_errors.DiagnosticCodes.CONFIG_INVALID, {
38
+ message: 'collection is not declared',
39
+ detail: {
40
+ collection: name
41
+ }
42
+ });
43
+ }
44
+ return schema;
45
+ }
46
+ function buildHandle(context) {
47
+ const {
48
+ config,
49
+ connection,
50
+ layout,
51
+ scope,
52
+ schemas
53
+ } = context;
54
+ let closed = false;
55
+ // Set when a deletion took the connection away rather than the app closing it.
56
+ let revoked = false;
57
+ const releaseNative = async () => {
58
+ // The key goes first: a close that fails at the filesystem must not
59
+ // leave key material alive in a handle nobody can use (FR-098).
60
+ context.key?.release();
61
+ await connection.close();
62
+ (0, _budgets.releaseHandleSlot)();
63
+ };
64
+ const unregister = (0, _deletion.registerOpenHandle)(config.name, scope.key, async () => {
65
+ if (closed) {
66
+ return;
67
+ }
68
+ closed = true;
69
+ revoked = true;
70
+ await releaseNative();
71
+ });
72
+ const assertUsable = () => {
73
+ if (closed && !revoked) {
74
+ (0, _errors2.raise)(_errors.DiagnosticCodes.CLOSED_HANDLE, {
75
+ message: 'handle is closed'
76
+ });
77
+ }
78
+ if (revoked || (0, _deletion.isScopeInvalidated)(config.name, scope.key)) {
79
+ // The deletion did not wait for this handle, and this handle does
80
+ // not get to keep answering from data that is gone (FR-059a).
81
+ (0, _errors2.raise)(_errors.DiagnosticCodes.SCOPE_DELETED, {
82
+ message: 'scope was deleted beneath this handle',
83
+ detail: {
84
+ scopeKey: scope.key
85
+ }
86
+ });
87
+ }
88
+ };
89
+
90
+ // Everything below is built against an explicit executor: the connection for
91
+ // the handle, the transaction's own executor inside `transaction`. Nothing
92
+ // infers which one from the connection's state, which is how a write from
93
+ // outside used to be swallowed by an in-flight transaction (LDB-01).
94
+ const artifactsOn = executor => ({
95
+ executor: () => executor,
96
+ layout,
97
+ scopeKey: scope.key,
98
+ artifactKey: attachmentId => context.key ? (0, _derive.deriveArtifactKey)(context.key.value(), scope.key, attachmentId) : null,
99
+ now: context.now
100
+ });
101
+ const rawCollection = (name, executor) => {
102
+ assertUsable();
103
+ return (0, _devLog.instrument)(name, 'sqlite', (0, _collection.createSqlCollection)({
104
+ executor: () => executor,
105
+ schema: schemaFor(schemas, name),
106
+ now: context.now,
107
+ assertUsable
108
+ }));
109
+ };
110
+
111
+ /**
112
+ * Record deletion optionally takes its artifacts with it (FR-070).
113
+ *
114
+ * Off unless the app asks: a package that deleted a user's files as a side
115
+ * effect of a record delete would be making a decision that is not its to
116
+ * make. The outcome carries what was removed and what could not be.
117
+ */
118
+ const collectionOn = (name, executor, deferred) => {
119
+ const ops = rawCollection(name, executor);
120
+ if (config.cascadeAttachments !== true) {
121
+ return ops;
122
+ }
123
+ return {
124
+ ...ops,
125
+ async delete(id) {
126
+ const outcome = await ops.delete(id);
127
+ const cascade = await (0, _cascade.cascadeForOwner)(artifactsOn(executor), executor, {
128
+ collection: name,
129
+ id
130
+ }, deferred);
131
+ return {
132
+ ...outcome,
133
+ cascade
134
+ };
135
+ }
136
+ };
137
+ };
138
+ const attachmentsOn = (executor, deferred) => {
139
+ const artifacts = artifactsOn(executor);
140
+ return {
141
+ write(input) {
142
+ assertUsable();
143
+ return (0, _store.writeArtifact)(artifacts, input);
144
+ },
145
+ read(id, range) {
146
+ assertUsable();
147
+ return (0, _store.readArtifact)(artifacts, id, range);
148
+ },
149
+ availability(id) {
150
+ assertUsable();
151
+ return (0, _availability.artifactAvailability)(artifacts, executor, id);
152
+ },
153
+ remove(id) {
154
+ assertUsable();
155
+ return (0, _store.removeArtifact)(artifacts, id, deferred);
156
+ },
157
+ listFor(owner) {
158
+ assertUsable();
159
+ return (0, _store.listReferencesFor)(executor, owner);
160
+ },
161
+ reconcile(options) {
162
+ assertUsable();
163
+ return (0, _reconcile.reconcileArtifacts)(artifacts, executor, options);
164
+ }
165
+ };
166
+ };
167
+ const collectionFor = name => collectionOn(name, connection);
168
+ const attachments = attachmentsOn(connection);
169
+ const handle = {
170
+ scopeKey: scope.key,
171
+ schemaVersion: context.schemaVersion,
172
+ backupPosture: context.posture,
173
+ isEncrypted: context.key !== null,
174
+ collection: collectionFor,
175
+ async transaction(fn) {
176
+ assertUsable();
177
+ const pendingUnlinks = [];
178
+ const deferred = {
179
+ add: path => pendingUnlinks.push(path)
180
+ };
181
+ let aborted = false;
182
+ const result = await (0, _transactions.runInTransaction)(connection, async tx => {
183
+ const managed = (0, _transaction.createTransaction)({
184
+ collection: name => collectionOn(name, tx, deferred),
185
+ attachments: () => attachmentsOn(tx, deferred),
186
+ rollback: async () => {
187
+ aborted = true;
188
+ await tx.rollback();
189
+ }
190
+ });
191
+ const value = await fn(managed.transaction);
192
+ if (!managed.isSettled()) {
193
+ (0, _faults.throwIfFaulted)('commit');
194
+ }
195
+ managed.settle();
196
+ return value;
197
+ });
198
+ // Committed (a thrown body never gets here). Only now are files whose
199
+ // references the transaction deleted safe to remove; one that cannot be
200
+ // removed stays on disk as an orphan reconciliation reports.
201
+ if (!aborted) {
202
+ for (const path of pendingUnlinks) {
203
+ await (0, _cascade.unlinkArtifact)(path);
204
+ }
205
+ }
206
+ return result;
207
+ },
208
+ async batch(operations) {
209
+ assertUsable();
210
+ const outcome = await (0, _batch.runBatch)({
211
+ connection,
212
+ schemaFor: name => schemaFor(schemas, name),
213
+ now: context.now
214
+ }, operations);
215
+ if (config.cascadeAttachments !== true) {
216
+ return outcome;
217
+ }
218
+ // The batch has committed, so its hard deletes cascade exactly as a
219
+ // collection delete does. Skipping them left every attachment of a
220
+ // batch-deleted record behind as an orphan.
221
+ const artifacts = artifactsOn(connection);
222
+ const outcomes = [];
223
+ for (const [index, operation] of operations.entries()) {
224
+ const written = outcome.outcomes[index];
225
+ if (operation.type !== 'delete') {
226
+ outcomes.push(written);
227
+ continue;
228
+ }
229
+ const cascade = await (0, _cascade.cascadeForOwner)(artifacts, connection, {
230
+ collection: operation.collection,
231
+ id: operation.id
232
+ });
233
+ outcomes.push({
234
+ ...written,
235
+ cascade
236
+ });
237
+ }
238
+ return {
239
+ ...outcome,
240
+ outcomes
241
+ };
242
+ },
243
+ attachments: () => attachments,
244
+ explain(collection, query) {
245
+ assertUsable();
246
+ return (0, _indexCoverage.explainQuery)(connection, schemaFor(schemas, collection), query, (0, _sort.withStableTiebreaker)(query?.sort));
247
+ },
248
+ async close() {
249
+ if (closed) {
250
+ return;
251
+ }
252
+ closed = true;
253
+ unregister();
254
+ await releaseNative();
255
+ }
256
+ };
257
+ return handle;
258
+ }
259
+ //# sourceMappingURL=handle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_errors","require","_availability","_cascade","_reconcile","_store","_derive","_errors2","_devLog","_faults","_sort","_batch","_indexCoverage","_transactions","_budgets","_collection","_deletion","_transaction","schemaFor","schemas","name","schema","get","raise","DiagnosticCodes","CONFIG_INVALID","message","detail","collection","buildHandle","context","config","connection","layout","scope","closed","revoked","releaseNative","key","release","close","releaseHandleSlot","unregister","registerOpenHandle","assertUsable","CLOSED_HANDLE","isScopeInvalidated","SCOPE_DELETED","scopeKey","artifactsOn","executor","artifactKey","attachmentId","deriveArtifactKey","value","now","rawCollection","instrument","createSqlCollection","collectionOn","deferred","ops","cascadeAttachments","delete","id","outcome","cascade","cascadeForOwner","attachmentsOn","artifacts","write","input","writeArtifact","read","range","readArtifact","availability","artifactAvailability","remove","removeArtifact","listFor","owner","listReferencesFor","reconcile","options","reconcileArtifacts","collectionFor","attachments","handle","schemaVersion","backupPosture","posture","isEncrypted","transaction","fn","pendingUnlinks","add","path","push","aborted","result","runInTransaction","tx","managed","createTransaction","rollback","isSettled","throwIfFaulted","settle","unlinkArtifact","batch","operations","runBatch","outcomes","index","operation","entries","written","type","explain","query","explainQuery","withStableTiebreaker","sort"],"sourceRoot":"../../../src","sources":["adapter/handle.ts"],"mappings":";;;;;;;AAmBA,IAAAA,OAAA,GAAAC,OAAA;AAWA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAOA,IAAAK,OAAA,GAAAL,OAAA;AAEA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AAEA,IAAAS,KA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E;QACxC,IAAIC,SAAS,CAACG,IAAI,KAAK,QAAQ,EAAE;UAChCL,QAAQ,CAACf,IAAI,CAACmB,OAAO,CAAC;UACtB;QACD;QACA,MAAMnD,OAAO,GAAG,MAAM,IAAAC,wBAAe,EAACE,SAAS,EAAErC,UAAU,EAAE;UAC5DJ,UAAU,EAAEuF,SAAS,CAACvF,UAAU;UAChCoC,EAAE,EAAEmD,SAAS,CAACnD;QACf,CAAC,CAAC;QACFiD,QAAQ,CAACf,IAAI,CAAC;UAAE,GAAGmB,OAAO;UAAEnD;QAAQ,CAAC,CAAC;MACvC;MACA,OAAO;QAAE,GAAGD,OAAO;QAAEgD;MAAS,CAAC;IAChC,CAAC;IAED1B,WAAW,EAAEA,CAAA,KAAMA,WAAW;IAE9BgC,OAAOA,CAAC3F,UAAkB,EAAE4F,KAAa,EAAgC;MACxE5E,YAAY,CAAC,CAAC;MACd,OAAO,IAAA6E,2BAAY,EAClBzF,UAAU,EACVd,SAAS,CAACC,OAAO,EAAES,UAAU,CAAC,EAC9B4F,KAAK,EACL,IAAAE,0BAAoB,EAACF,KAAK,EAAEG,IAAI,CACjC,CAAC;IACF,CAAC;IAED,MAAMnF,KAAKA,CAAA,EAAkB;MAC5B,IAAIL,MAAM,EAAE;QACX;MACD;MACAA,MAAM,GAAG,IAAI;MACbO,UAAU,CAAC,CAAC;MACZ,MAAML,aAAa,CAAC,CAAC;IACtB;EACD,CAAC;EAED,OAAOmD,MAAM;AACd","ignoreList":[]}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.deleteDatabase = deleteDatabase;
7
+ exports.deleteScopeData = deleteScopeData;
8
+ exports.openDatabase = openDatabase;
9
+ exports.resetScope = resetScope;
10
+ exports.setStorageAdapter = setStorageAdapter;
11
+ /**
12
+ * The public lifecycle functions.
13
+ *
14
+ * Scope deletion and reset are module-level rather than handle methods: they
15
+ * must work whether or not a handle is open on the target (FR-059), and
16
+ * `resetScope` in particular must never be reachable as a fallback from
17
+ * `openDatabase` (FR-057a).
18
+ *
19
+ * The active adapter is resolved lazily so a consuming app that only ever
20
+ * uses the in-memory adapter in tests never loads the native peers.
21
+ */
22
+
23
+ let override = null;
24
+ let cached = null;
25
+
26
+ /**
27
+ * Swap the adapter. Intended for tests and for the demo app's in-memory
28
+ * mode; production code never calls this.
29
+ */
30
+ function setStorageAdapter(adapter) {
31
+ override = adapter;
32
+ }
33
+ function activeAdapter() {
34
+ if (override) {
35
+ return override;
36
+ }
37
+ if (!cached) {
38
+ // Lazy require, matching how rn-auth and rn-camera reach their native
39
+ // peers: importing at module scope would pull op-sqlite into every
40
+ // consumer, including ones that only run the in-memory adapter.
41
+ const {
42
+ createSqliteAdapter
43
+ } = require('../sqlite/adapter');
44
+ cached = createSqliteAdapter();
45
+ }
46
+ return cached;
47
+ }
48
+ function openDatabase(config) {
49
+ return activeAdapter().open(config);
50
+ }
51
+ function deleteScopeData(config) {
52
+ return activeAdapter().deleteScopeData(config);
53
+ }
54
+ function deleteDatabase(config) {
55
+ return activeAdapter().deleteDatabase(config);
56
+ }
57
+
58
+ /**
59
+ * Destructive. Discards one scope's data and leaves it ready for a clean
60
+ * first-run migration. Named apart from `deleteScopeData` deliberately: one
61
+ * is a lifecycle operation, the other is an admission that a database is
62
+ * broken.
63
+ */
64
+ function resetScope(config) {
65
+ return activeAdapter().resetScope(config);
66
+ }
67
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["override","cached","setStorageAdapter","adapter","activeAdapter","createSqliteAdapter","require","openDatabase","config","open","deleteScopeData","deleteDatabase","resetScope"],"sourceRoot":"../../../src","sources":["adapter/index.ts"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,IAAIA,QAA+B,GAAG,IAAI;AAC1C,IAAIC,MAA6B,GAAG,IAAI;;AAExC;AACA;AACA;AACA;AACO,SAASC,iBAAiBA,CAACC,OAA8B,EAAQ;EACvEH,QAAQ,GAAGG,OAAO;AACnB;AAEA,SAASC,aAAaA,CAAA,EAAmB;EACxC,IAAIJ,QAAQ,EAAE;IACb,OAAOA,QAAQ;EAChB;EACA,IAAI,CAACC,MAAM,EAAE;IACZ;IACA;IACA;IACA,MAAM;MAAEI;IAAoB,CAAC,GAAGC,OAAO,CAAC,mBAAmB,CAE1D;IACDL,MAAM,GAAGI,mBAAmB,CAAC,CAAC;EAC/B;EACA,OAAOJ,MAAM;AACd;AAEO,SAASM,YAAYA,CAACC,MAAsB,EAA2B;EAC7E,OAAOJ,aAAa,CAAC,CAAC,CAACK,IAAI,CAACD,MAAM,CAAC;AACpC;AAEO,SAASE,eAAeA,CAACF,MAAyB,EAA4B;EACpF,OAAOJ,aAAa,CAAC,CAAC,CAACM,eAAe,CAACF,MAAM,CAAC;AAC/C;AAEO,SAASG,cAAcA,CAACH,MAA4B,EAA4B;EACtF,OAAOJ,aAAa,CAAC,CAAC,CAACO,cAAc,CAACH,MAAM,CAAC;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,UAAUA,CAACJ,MAAyB,EAA4B;EAC/E,OAAOJ,aAAa,CAAC,CAAC,CAACQ,UAAU,CAACJ,MAAM,CAAC;AAC1C","ignoreList":[]}