@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,120 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * The managed storage area, and the single guard every filesystem call routes
5
+ * through.
6
+ *
7
+ * POL-011(b) flags media-and-files as a risk because this package deletes
8
+ * files from disk on cascade. The mitigation is that there is exactly one
9
+ * function that turns a caller's intent into a path, and it refuses anything
10
+ * outside the root. One choke point is what makes SC-013a's filesystem
11
+ * tracing pass reliably rather than usually.
12
+ */
13
+
14
+ import { DiagnosticCodes } from "../contract/errors.js";
15
+ import { raise } from "../diagnostics/errors.js";
16
+ import { fileSystem } from "./fs.js";
17
+ export const MANAGED_ROOT_NAME = 'chipmobilesdk-localdb';
18
+ export const CATALOG_FILE = 'catalog.db';
19
+ export const SCOPES_DIR = 'scopes';
20
+ export const DATA_FILE = 'data.db';
21
+ export const ARTIFACTS_DIR = 'artifacts';
22
+
23
+ /** Normalize separators and collapse redundant segments. No `..` survives. */
24
+ export function normalizePath(path) {
25
+ const unified = path.replace(/\\/g, '/');
26
+ const segments = [];
27
+ for (const segment of unified.split('/')) {
28
+ if (segment === '' || segment === '.') {
29
+ continue;
30
+ }
31
+ if (segment === '..') {
32
+ segments.pop();
33
+ continue;
34
+ }
35
+ segments.push(segment);
36
+ }
37
+ const prefix = unified.startsWith('/') ? '/' : '';
38
+ return prefix + segments.join('/');
39
+ }
40
+ const SCOPE_KEY = /^[0-9a-f]{64}$/;
41
+ const ARTIFACT_ID = /^[A-Za-z0-9._-]{1,128}$/;
42
+ // `.` and `..` are made entirely of permitted characters and are the two that
43
+ // matter: `artifacts/..` resolves to the scope directory itself, still inside
44
+ // the managed root, so the boundary guard would wave it through and a cascade
45
+ // would unlink the whole scope. A leading dot is refused with them, since no
46
+ // attachment id needs one and hidden files are the package's own.
47
+ const DOT_PREFIXED = /^\./;
48
+
49
+ /**
50
+ * An attachment id must be a safe single path segment.
51
+ *
52
+ * Shared by both adapters rather than left to the one that touches a
53
+ * filesystem. The in-memory adapter has no paths to escape, but a consumer
54
+ * whose tests accept `../../etc/passwd` and whose device build refuses it has
55
+ * a test suite that stops predicting the device — which is the one thing the
56
+ * adapter exists to avoid (FR-096).
57
+ */
58
+ export function assertValidAttachmentId(attachmentId) {
59
+ if (!ARTIFACT_ID.test(attachmentId) || DOT_PREFIXED.test(attachmentId)) {
60
+ raise(DiagnosticCodes.ATTACHMENT_OUT_OF_BOUNDS, {
61
+ message: 'attachment id is not a valid path segment'
62
+ });
63
+ }
64
+ }
65
+ export function createLayout(documentDirectory, databaseName) {
66
+ const root = normalizePath(`${documentDirectory}/${MANAGED_ROOT_NAME}/${databaseName}`);
67
+ const scopePath = scopeKey => {
68
+ // The scope key is our own SHA-256 output. Validating its shape here
69
+ // means a caller cannot smuggle a traversal through it even if some
70
+ // future path reaches this function with unvalidated input.
71
+ if (!SCOPE_KEY.test(scopeKey)) {
72
+ raise(DiagnosticCodes.ATTACHMENT_OUT_OF_BOUNDS, {
73
+ message: 'scope key is not a valid digest'
74
+ });
75
+ }
76
+ return `${root}/${SCOPES_DIR}/${scopeKey}`;
77
+ };
78
+ return {
79
+ root,
80
+ catalogPath: `${root}/${CATALOG_FILE}`,
81
+ scopePath,
82
+ scopeDataPath: scopeKey => `${scopePath(scopeKey)}/${DATA_FILE}`,
83
+ scopeArtifactsPath: scopeKey => `${scopePath(scopeKey)}/${ARTIFACTS_DIR}`,
84
+ artifactPath: (scopeKey, attachmentId) => {
85
+ assertValidAttachmentId(attachmentId);
86
+ return `${scopePath(scopeKey)}/${ARTIFACTS_DIR}/${attachmentId}`;
87
+ }
88
+ };
89
+ }
90
+
91
+ /**
92
+ * The layout for one logical database, rooted at the app's private documents
93
+ * directory.
94
+ *
95
+ * Resolved lazily through the filesystem peer rather than captured at module
96
+ * load, so importing this package does not require the peer to be installed —
97
+ * a consumer running only the in-memory adapter never reaches this function.
98
+ */
99
+ export function layoutFor(databaseName) {
100
+ return createLayout(fileSystem().DocumentDirectoryPath, databaseName);
101
+ }
102
+
103
+ /**
104
+ * The guard. Every read, write, and delete passes through this, and anything
105
+ * resolving outside the managed root is refused before it reaches the
106
+ * filesystem (FR-073, FR-073f).
107
+ */
108
+ export function assertWithinManagedArea(layout, candidate) {
109
+ const normalized = normalizePath(candidate);
110
+ const root = normalizePath(layout.root);
111
+ if (normalized !== root && !normalized.startsWith(`${root}/`)) {
112
+ raise(DiagnosticCodes.ATTACHMENT_OUT_OF_BOUNDS, {
113
+ // The offending path is NOT reported: it may contain a scope
114
+ // component or a user-chosen filename.
115
+ message: 'path resolves outside the managed storage area'
116
+ });
117
+ }
118
+ return normalized;
119
+ }
120
+ //# sourceMappingURL=location.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["DiagnosticCodes","raise","fileSystem","MANAGED_ROOT_NAME","CATALOG_FILE","SCOPES_DIR","DATA_FILE","ARTIFACTS_DIR","normalizePath","path","unified","replace","segments","segment","split","pop","push","prefix","startsWith","join","SCOPE_KEY","ARTIFACT_ID","DOT_PREFIXED","assertValidAttachmentId","attachmentId","test","ATTACHMENT_OUT_OF_BOUNDS","message","createLayout","documentDirectory","databaseName","root","scopePath","scopeKey","catalogPath","scopeDataPath","scopeArtifactsPath","artifactPath","layoutFor","DocumentDirectoryPath","assertWithinManagedArea","layout","candidate","normalized"],"sourceRoot":"../../../src","sources":["platform/location.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,eAAe,QAAQ,uBAAoB;AACpD,SAASC,KAAK,QAAQ,0BAAuB;AAC7C,SAASC,UAAU,QAAQ,SAAM;AAEjC,OAAO,MAAMC,iBAAiB,GAAG,uBAAuB;AACxD,OAAO,MAAMC,YAAY,GAAG,YAAY;AACxC,OAAO,MAAMC,UAAU,GAAG,QAAQ;AAClC,OAAO,MAAMC,SAAS,GAAG,SAAS;AAClC,OAAO,MAAMC,aAAa,GAAG,WAAW;;AAExC;AACA,OAAO,SAASC,aAAaA,CAACC,IAAY,EAAU;EACnD,MAAMC,OAAO,GAAGD,IAAI,CAACE,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;EACxC,MAAMC,QAAkB,GAAG,EAAE;EAC7B,KAAK,MAAMC,OAAO,IAAIH,OAAO,CAACI,KAAK,CAAC,GAAG,CAAC,EAAE;IACzC,IAAID,OAAO,KAAK,EAAE,IAAIA,OAAO,KAAK,GAAG,EAAE;MACtC;IACD;IACA,IAAIA,OAAO,KAAK,IAAI,EAAE;MACrBD,QAAQ,CAACG,GAAG,CAAC,CAAC;MACd;IACD;IACAH,QAAQ,CAACI,IAAI,C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B,EAAEH,QAAQ,IAAI,GAAGD,SAAS,CAACC,QAAQ,CAAC,IAAI1B,aAAa,EAAE;IACzE8B,YAAY,EAAEA,CAACJ,QAAQ,EAAET,YAAY,KAAK;MACzCD,uBAAuB,CAACC,YAAY,CAAC;MACrC,OAAO,GAAGQ,SAAS,CAACC,QAAQ,CAAC,IAAI1B,aAAa,IAAIiB,YAAY,EAAE;IACjE;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASc,SAASA,CAACR,YAAoB,EAAiB;EAC9D,OAAOF,YAAY,CAAC1B,UAAU,CAAC,CAAC,CAACqC,qBAAqB,EAAET,YAAY,CAAC;AACtE;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASU,uBAAuBA,CAACC,MAAqB,EAAEC,SAAiB,EAAU;EACzF,MAAMC,UAAU,GAAGnC,aAAa,CAACkC,SAAS,CAAC;EAC3C,MAAMX,IAAI,GAAGvB,aAAa,CAACiC,MAAM,CAACV,IAAI,CAAC;EACvC,IAAIY,UAAU,KAAKZ,IAAI,IAAI,CAACY,UAAU,CAACzB,UAAU,CAAC,GAAGa,IAAI,GAAG,CAAC,EAAE;IAC9D9B,KAAK,CAACD,eAAe,CAAC0B,wBAAwB,EAAE;MAC/C;MACA;MACAC,OAAO,EAAE;IACV,CAAC,CAAC;EACH;EACA,OAAOgB,UAAU;AAClB","ignoreList":[]}
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Budget enforcement.
5
+ *
6
+ * Per-record size, page size, and batch size are HARD limits reported through
7
+ * typed errors (FR-088a). The rest are soft: exceeding them must not crash,
8
+ * hang, or drop data silently, and the degraded behavior is documented.
9
+ */
10
+
11
+ import { Budgets } from "../contract/config.js";
12
+ import { DiagnosticCodes } from "../contract/errors.js";
13
+ import { raise } from "../diagnostics/errors.js";
14
+
15
+ /**
16
+ * UTF-8 length of a string, counted rather than encoded: measuring a 256 KB
17
+ * record used to allocate a 256 KB byte array just to read its length.
18
+ */
19
+ export function utf8Length(value) {
20
+ let bytes = 0;
21
+ for (let index = 0; index < value.length; index += 1) {
22
+ const unit = value.charCodeAt(index);
23
+ if (unit < 0x80) {
24
+ bytes += 1;
25
+ } else if (unit < 0x800) {
26
+ bytes += 2;
27
+ } else if (unit >= 0xd800 && unit <= 0xdbff && index + 1 < value.length) {
28
+ // A surrogate pair is one four-byte code point.
29
+ bytes += 4;
30
+ index += 1;
31
+ } else {
32
+ bytes += 3;
33
+ }
34
+ }
35
+ return bytes;
36
+ }
37
+
38
+ /** UTF-8 byte length of the serialized payload — what actually hits disk. */
39
+ export function serializedSize(data) {
40
+ return utf8Length(JSON.stringify(data ?? {}));
41
+ }
42
+
43
+ /**
44
+ * Checks the size budget and returns the serialized payload, so the write that
45
+ * follows stores this string instead of serializing the record a second time.
46
+ */
47
+ export function assertRecordWithinBudget(collection, data) {
48
+ const payload = JSON.stringify(data ?? {});
49
+ const size = utf8Length(payload);
50
+ if (size > Budgets.MAX_RECORD_BYTES) {
51
+ // Truncating would be silent data loss; failing opaquely would leave
52
+ // the consumer guessing. The size and the limit are both safe to
53
+ // report — neither can carry a field value.
54
+ raise(DiagnosticCodes.RECORD_TOO_LARGE, {
55
+ message: 'record exceeds the per-record size budget',
56
+ detail: {
57
+ collection,
58
+ sizeBytes: size,
59
+ limitBytes: Budgets.MAX_RECORD_BYTES
60
+ }
61
+ });
62
+ }
63
+ return payload;
64
+ }
65
+ export function assertBatchWithinBudget(count) {
66
+ if (count > Budgets.MAX_BATCH_OPERATIONS) {
67
+ raise(DiagnosticCodes.BATCH_TOO_LARGE, {
68
+ message: 'batch exceeds the operation budget',
69
+ detail: {
70
+ count,
71
+ limit: Budgets.MAX_BATCH_OPERATIONS
72
+ }
73
+ });
74
+ }
75
+ }
76
+ export function assertArtifactWithinBudget(id, size) {
77
+ if (size > Budgets.MAX_ARTIFACT_BYTES) {
78
+ raise(DiagnosticCodes.ATTACHMENT_WRITE_FAILED, {
79
+ message: 'artifact exceeds the size budget',
80
+ detail: {
81
+ attachmentId: id,
82
+ sizeBytes: size,
83
+ limitBytes: Budgets.MAX_ARTIFACT_BYTES
84
+ }
85
+ });
86
+ }
87
+ }
88
+ //# sourceMappingURL=budgets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Budgets","DiagnosticCodes","raise","utf8Length","value","bytes","index","length","unit","charCodeAt","serializedSize","data","JSON","stringify","assertRecordWithinBudget","collection","payload","size","MAX_RECORD_BYTES","RECORD_TOO_LARGE","message","detail","sizeBytes","limitBytes","assertBatchWithinBudget","count","MAX_BATCH_OPERATIONS","BATCH_TOO_LARGE","limit","assertArtifactWithinBudget","id","MAX_ARTIFACT_BYTES","ATTACHMENT_WRITE_FAILED","attachmentId"],"sourceRoot":"../../../src","sources":["query/budgets.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,QAAQ,uBAAoB;AAC5C,SAASC,eAAe,QAAQ,uBAAoB;AAEpD,SAASC,KAAK,QAAQ,0BAAuB;;AAE7C;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CAACC,KAAa,EAAU;EACjD,IAAIC,KAAK,GAAG,CAAC;EACb,KAAK,IAAIC,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGF,KAAK,CAACG,MAAM,EAAED,KAAK,IAAI,CAAC,EAAE;IACrD,MAAME,IAAI,GAAGJ,KAAK,CAACK,UAAU,CAACH,KAAK,CAAC;IACpC,IAAIE,IAAI,GAAG,IAAI,EAAE;MAChBH,KAAK,IAAI,CAAC;IACX,CAAC,MAAM,IAAIG,IAAI,GAAG,KAAK,EAAE;MACxBH,KAAK,IAAI,CAAC;IACX,CAAC,MAAM,IAAIG,IAAI,IAAI,MAAM,IAAIA,IAAI,IAAI,MAAM,IAAIF,KAAK,GAAG,CAAC,GAAGF,KAAK,CAACG,MAAM,EAAE;MACxE;MACAF,KAAK,IAAI,CAAC;MACVC,KAAK,IAAI,CA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;QACPY,YAAY,EAAEH,EAAE;QAChBR,SAAS,EAAEL,IAAI;QACfM,UAAU,EAAEvB,OAAO,CAAC+B;MACrB;IACD,CAAC,CAAC;EACH;AACD","ignoreList":[]}
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Comparison and field access semantics.
5
+ *
6
+ * Defined once here, used by the in-memory adapter directly and by the SQL
7
+ * builder for validation and cursor construction. Two implementations of
8
+ * these rules would drift, and the drift would show up as a conformance
9
+ * divergence that hides a real bug (research.md R8).
10
+ */
11
+
12
+ /**
13
+ * A field is one of three things, and the difference is the whole point of
14
+ * FR-019: present with a value, present and null, or absent.
15
+ */
16
+
17
+ export function lookupField(data, field) {
18
+ if (!Object.prototype.hasOwnProperty.call(data, field)) {
19
+ return {
20
+ present: false
21
+ };
22
+ }
23
+ const value = data[field];
24
+ if (value === null) {
25
+ return {
26
+ present: true,
27
+ value: null
28
+ };
29
+ }
30
+ return {
31
+ present: true,
32
+ value: value
33
+ };
34
+ }
35
+
36
+ /**
37
+ * Ordering for values of the same declared type.
38
+ *
39
+ * Null sorts before every non-null value, matching SQLite's default so the
40
+ * two adapters agree without the SQL builder emitting NULLS FIRST/LAST
41
+ * clauses that older SQLite versions do not support.
42
+ */
43
+ export function compareValues(a, b) {
44
+ if (a === null && b === null) {
45
+ return 0;
46
+ }
47
+ if (a === null) {
48
+ return -1;
49
+ }
50
+ if (b === null) {
51
+ return 1;
52
+ }
53
+ if (typeof a === 'boolean' || typeof b === 'boolean') {
54
+ return Number(a) - Number(b);
55
+ }
56
+ if (typeof a === 'number' && typeof b === 'number') {
57
+ if (Number.isNaN(a) || Number.isNaN(b)) {
58
+ return Number.isNaN(a) && Number.isNaN(b) ? 0 : Number.isNaN(a) ? -1 : 1;
59
+ }
60
+ return a < b ? -1 : a > b ? 1 : 0;
61
+ }
62
+ const sa = String(a);
63
+ const sb = String(b);
64
+ // Byte-order rather than locale collation: a locale-aware comparison would
65
+ // make the stored order depend on device settings, so the same data would
66
+ // page differently on two phones.
67
+ return sa < sb ? -1 : sa > sb ? 1 : 0;
68
+ }
69
+
70
+ /** Only primitives can be compared; a nested object is never a filter target. */
71
+ export function asFilterValue(value) {
72
+ if (value === null || typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
73
+ return value;
74
+ }
75
+ return undefined;
76
+ }
77
+
78
+ /**
79
+ * Byte order, not locale collation.
80
+ *
81
+ * A locale-aware sort would make the reported order depend on device
82
+ * settings, so two phones holding identical data would report it differently.
83
+ */
84
+ export function byteOrder(a, b) {
85
+ if (a < b) {
86
+ return -1;
87
+ }
88
+ return a > b ? 1 : 0;
89
+ }
90
+ //# sourceMappingURL=compare.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["lookupField","data","field","Object","prototype","hasOwnProperty","call","present","value","compareValues","a","b","Number","isNaN","sa","String","sb","asFilterValue","undefined","byteOrder"],"sourceRoot":"../../../src","sources":["query/compare.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;;AAMA,OAAO,SAASA,WAAWA,CAACC,IAAwB,EAAEC,KAAa,EAAe;EACjF,IAAI,CAACC,MAAM,CAACC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACL,IAAI,EAAEC,KAAK,CAAC,EAAE;IACvD,OAAO;MAAEK,OAAO,EAAE;IAAM,CAAC;EAC1B;EACA,MAAMC,KAAK,GAAGP,IAAI,CAACC,KAAK,CAAC;EACzB,IAAIM,KAAK,KAAK,IAAI,EAAE;IACnB,OAAO;MAAED,OAAO,EAAE,IAAI;MAAEC,KAAK,EAAE;IAAK,CAAC;EACtC;EACA,OAAO;IAAED,OAAO,EAAE,IAAI;IAAEC,KAAK,EAAEA;EAAsC,CAAC;AACvE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAACC,CAAc,EAAEC,CAAc,EAAU;EACrE,IAAID,CAAC,KAAK,IAAI,IAAIC,CAAC,KAA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;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,SAASA,CAACT,CAAS,EAAEC,CAAS,EAAU;EACvD,IAAID,CAAC,GAAGC,CAAC,EAAE;IACV,OAAO,CAAC,CAAC;EACV;EACA,OAAOD,CAAC,GAAGC,CAAC,GAAG,CAAC,GAAG,CAAC;AACrB","ignoreList":[]}
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Keyset pagination cursors.
5
+ *
6
+ * Keyset rather than OFFSET for two reasons, both of which SC-007 measures:
7
+ * OFFSET degrades linearly at the 100,000-record budget because the engine
8
+ * still walks the skipped rows, and it shifts pages under concurrent writes
9
+ * so a record can be skipped or returned twice. A cursor anchored to the last
10
+ * row's sort values has neither problem.
11
+ */
12
+
13
+ import { DiagnosticCodes } from "../contract/errors.js";
14
+ import { raise } from "../diagnostics/errors.js";
15
+ import { compareValues } from "./compare.js";
16
+ import { sortValueOf } from "./sort.js";
17
+ import { base64ToBytes, bytesToBase64, host, utf8Bytes, utf8String } from "../platform/bytes.js";
18
+ function shapeOf(sort) {
19
+ return sort.map(key => `${key.field}:${key.direction === 'desc' ? 'd' : 'a'}`).join(',');
20
+ }
21
+ function toBase64(value) {
22
+ if (host.btoa) {
23
+ return host.btoa(unescape(encodeURIComponent(value)));
24
+ }
25
+ return bytesToBase64(utf8Bytes(value));
26
+ }
27
+ function fromBase64(value) {
28
+ if (host.atob) {
29
+ return decodeURIComponent(escape(host.atob(value)));
30
+ }
31
+ return utf8String(base64ToBytes(value));
32
+ }
33
+ export function encodeCursor(record, sort) {
34
+ const payload = {
35
+ k: shapeOf(sort),
36
+ v: sort.map(key => sortValueOf(record, key.field) ?? null)
37
+ };
38
+ return toBase64(JSON.stringify(payload));
39
+ }
40
+ export function decodeCursor(cursor, sort) {
41
+ let payload;
42
+ try {
43
+ payload = JSON.parse(fromBase64(cursor));
44
+ } catch {
45
+ raise(DiagnosticCodes.CURSOR_INVALID, {
46
+ message: 'cursor is not decodable'
47
+ });
48
+ }
49
+ if (!payload || typeof payload.k !== 'string' || !Array.isArray(payload.v)) {
50
+ raise(DiagnosticCodes.CURSOR_INVALID, {
51
+ message: 'cursor payload is malformed'
52
+ });
53
+ }
54
+ // A cursor from a differently sorted query would produce a silently wrong
55
+ // page rather than an error, so the shape is part of the cursor.
56
+ if (payload.k !== shapeOf(sort)) {
57
+ raise(DiagnosticCodes.CURSOR_INVALID, {
58
+ message: 'cursor does not match this query shape'
59
+ });
60
+ }
61
+ if (payload.v.length !== sort.length) {
62
+ raise(DiagnosticCodes.CURSOR_INVALID, {
63
+ message: 'cursor arity does not match sort'
64
+ });
65
+ }
66
+ return payload.v;
67
+ }
68
+
69
+ /**
70
+ * Is this record strictly after the cursor position, under the sort order?
71
+ *
72
+ * Lexicographic across the sort keys: equal on the first key means the second
73
+ * decides, and so on down to the id tiebreaker that guarantees a total order.
74
+ */
75
+ export function isAfterCursor(record, sort, anchor) {
76
+ for (let i = 0; i < sort.length; i += 1) {
77
+ const key = sort[i];
78
+ const direction = key.direction === 'desc' ? -1 : 1;
79
+ const value = sortValueOf(record, key.field) ?? null;
80
+ const result = compareValues(value, anchor[i] ?? null) * direction;
81
+ if (result > 0) {
82
+ return true;
83
+ }
84
+ if (result < 0) {
85
+ return false;
86
+ }
87
+ }
88
+ // Equal on every key including id — this is the anchor row itself.
89
+ return false;
90
+ }
91
+ //# sourceMappingURL=cursor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["DiagnosticCodes","raise","compareValues","sortValueOf","base64ToBytes","bytesToBase64","host","utf8Bytes","utf8String","shapeOf","sort","map","key","field","direction","join","toBase64","value","btoa","unescape","encodeURIComponent","fromBase64","atob","decodeURIComponent","escape","encodeCursor","record","payload","k","v","JSON","stringify","decodeCursor","cursor","parse","CURSOR_INVALID","message","Array","isArray","length","isAfterCursor","anchor","i","result"],"sourceRoot":"../../../src","sources":["query/cursor.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;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AAC,CAAC,GAAG,CAAC;IACnD,MAAMG,KAAK,GAAGd,WAAW,CAACuB,MAAM,EAAEd,GAAG,CAACC,KAAK,CAAC,IAAI,IAAI;IACpD,MAAM8B,MAAM,GAAGzC,aAAa,CAACe,KAAK,EAAEwB,MAAM,CAACC,CAAC,CAAC,IAAI,IAAI,CAAC,GAAG5B,SAAS;IAClE,IAAI6B,MAAM,GAAG,CAAC,EAAE;MACf,OAAO,IAAI;IACZ;IACA,IAAIA,MAAM,GAAG,CAAC,EAAE;MACf,OAAO,KAAK;IACb;EACD;EACA;EACA,OAAO,KAAK;AACb","ignoreList":[]}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Filter evaluation over a plain record.
5
+ *
6
+ * The in-memory adapter runs this directly. The SQLite adapter translates the
7
+ * same validated tree to SQL. Both must agree, which is why the semantics
8
+ * live here rather than in either of them.
9
+ */
10
+
11
+ import { asFilterValue, compareValues, lookupField } from "./compare.js";
12
+ function equals(a, b) {
13
+ return compareValues(a, b) === 0 && a === null === (b === null);
14
+ }
15
+ export function evaluateFilter(data, node) {
16
+ switch (node.op) {
17
+ case 'and':
18
+ return node.nodes.every(child => evaluateFilter(data, child));
19
+ case 'or':
20
+ return node.nodes.some(child => evaluateFilter(data, child));
21
+ case 'not':
22
+ return !evaluateFilter(data, node.node);
23
+ default:
24
+ break;
25
+ }
26
+ const lookup = lookupField(data, node.field);
27
+
28
+ // `exists` is the only operator that answers a question about presence,
29
+ // which is what keeps "absent" distinguishable from "null" (FR-019).
30
+ if (node.op === 'exists') {
31
+ return lookup.present === node.value;
32
+ }
33
+ if (!lookup.present) {
34
+ // An absent field satisfies nothing else — not even `ne` or `isNull`.
35
+ // SQL agrees: a comparison against a missing column yields NULL, which
36
+ // is not true.
37
+ return false;
38
+ }
39
+ const value = asFilterValue(lookup.value);
40
+ if (value === undefined) {
41
+ // A nested object or array is not comparable. Matching it would be a
42
+ // guess, so it simply does not satisfy a comparison.
43
+ return false;
44
+ }
45
+ switch (node.op) {
46
+ case 'isNull':
47
+ return value === null;
48
+ case 'isNotNull':
49
+ return value !== null;
50
+ case 'eq':
51
+ return equals(value, node.value);
52
+ case 'ne':
53
+ return !equals(value, node.value);
54
+ case 'lt':
55
+ return value !== null && node.value !== null && compareValues(value, node.value) < 0;
56
+ case 'lte':
57
+ return value !== null && node.value !== null && compareValues(value, node.value) <= 0;
58
+ case 'gt':
59
+ return value !== null && node.value !== null && compareValues(value, node.value) > 0;
60
+ case 'gte':
61
+ return value !== null && node.value !== null && compareValues(value, node.value) >= 0;
62
+ case 'in':
63
+ return node.value.some(candidate => equals(value, candidate));
64
+ case 'nin':
65
+ return !node.value.some(candidate => equals(value, candidate));
66
+ case 'between':
67
+ {
68
+ const [low, high] = node.value;
69
+ if (value === null || low === null || high === null) {
70
+ return false;
71
+ }
72
+ return compareValues(value, low) >= 0 && compareValues(value, high) <= 0;
73
+ }
74
+ default:
75
+ return false;
76
+ }
77
+ }
78
+ //# sourceMappingURL=filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["asFilterValue","compareValues","lookupField","equals","a","b","evaluateFilter","data","node","op","nodes","every","child","some","lookup","field","present","value","undefined","candidate","low","high"],"sourceRoot":"../../../src","sources":["query/filter.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,aAAa,EAAEC,aAAa,EAAEC,WAAW,QAAQ,cAAW;AAErE,SAASC,MAAMA,CAACC,CAAc,EAAEC,CAAc,EAAW;EACxD,OAAOJ,aAAa,CAACG,CAAC,EAAEC,CAAC,CAAC,KAAK,CAAC,IAAKD,CAAC,KAAK,IAAI,MAAOC,CAAC,KAAK,IAAI,CAAC;AAClE;AAEA,OAAO,SAASC,cAAcA,CAACC,IAAwB,EAAEC,IAAgB,EAAW;EACnF,QAAQA,IAAI,CAACC,EAAE;IACd,KAAK,KAAK;MACT,OAAOD,IAAI,CAACE,KAAK,CAACC,KAAK,CAACC,KAAK,IAAIN,cAAc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B,KAAK,EAAET,IAAI,CAACS,KAAK,CAAC,IAAI,CAAC;IACtF,KAAK,IAAI;MACR,OAAOA,KAAK,KAAK,IAAI,IAAIT,IAAI,CAACS,KAAK,KAAK,IAAI,IAAIhB,aAAa,CAACgB,KAAK,EAAET,IAAI,CAACS,KAAK,CAAC,GAAG,CAAC;IACrF,KAAK,KAAK;MACT,OAAOA,KAAK,KAAK,IAAI,IAAIT,IAAI,CAACS,KAAK,KAAK,IAAI,IAAIhB,aAAa,CAACgB,KAAK,EAAET,IAAI,CAACS,KAAK,CAAC,IAAI,CAAC;IACtF,KAAK,IAAI;MACR,OAAOT,IAAI,CAACS,KAAK,CAACJ,IAAI,CAACM,SAAS,IAAIhB,MAAM,CAACc,KAAK,EAAEE,SAAS,CAAC,CAAC;IAC9D,KAAK,KAAK;MACT,OAAO,CAACX,IAAI,CAACS,KAAK,CAACJ,IAAI,CAACM,SAAS,IAAIhB,MAAM,CAACc,KAAK,EAAEE,SAAS,CAAC,CAAC;IAC/D,KAAK,SAAS;MAAE;QACf,MAAM,CAACC,GAAG,EAAEC,IAAI,CAAC,GAAGb,IAAI,CAACS,KAAK;QAC9B,IAAIA,KAAK,KAAK,IAAI,IAAIG,GAAG,KAAK,IAAI,IAAIC,IAAI,KAAK,IAAI,EAAE;UACpD,OAAO,KAAK;QACb;QACA,OAAOpB,aAAa,CAACgB,KAAK,EAAEG,GAAG,CAAC,IAAI,CAAC,IAAInB,aAAa,CAACgB,KAAK,EAAEI,IAAI,CAAC,IAAI,CAAC;MACzE;IACA;MACC,OAAO,KAAK;EACd;AACD","ignoreList":[]}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Page assembly over already-filtered, already-sorted records.
5
+ *
6
+ * Shared so the in-memory adapter and the SQLite adapter produce identical
7
+ * pages, including the `hasMore` signal and when a cursor is emitted.
8
+ */
9
+
10
+ import { Budgets } from "../contract/config.js";
11
+ import { decodeCursor, encodeCursor, isAfterCursor } from "./cursor.js";
12
+ export const DEFAULT_PAGE_SIZE = 50;
13
+ export function resolvePageSize(page) {
14
+ return page?.size ?? DEFAULT_PAGE_SIZE;
15
+ }
16
+
17
+ /** Fetch one extra row to answer `hasMore` without a second count query. */
18
+ export function fetchLimitFor(size) {
19
+ return Math.min(size, Budgets.MAX_PAGE_SIZE) + 1;
20
+ }
21
+ export function applyCursor(records, sort, cursor) {
22
+ if (!cursor) {
23
+ return records;
24
+ }
25
+ const anchor = decodeCursor(cursor, sort);
26
+ return records.filter(record => isAfterCursor(record, sort, anchor));
27
+ }
28
+ export function buildPage(records, sort, size) {
29
+ const hasMore = records.length > size;
30
+ const page = hasMore ? records.slice(0, size) : records;
31
+ const last = page[page.length - 1];
32
+ return {
33
+ records: page,
34
+ // No cursor on the final page: handing one back invites a consumer to
35
+ // keep paging past the end and treat an empty page as an error.
36
+ cursor: hasMore && last ? encodeCursor(last, sort) : undefined,
37
+ hasMore
38
+ };
39
+ }
40
+ //# sourceMappingURL=paginate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Budgets","decodeCursor","encodeCursor","isAfterCursor","DEFAULT_PAGE_SIZE","resolvePageSize","page","size","fetchLimitFor","Math","min","MAX_PAGE_SIZE","applyCursor","records","sort","cursor","anchor","filter","record","buildPage","hasMore","length","slice","last","undefined"],"sourceRoot":"../../../src","sources":["query/paginate.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,QAAQ,uBAAoB;AAG5C,SAASC,YAAY,EAAEC,YAAY,EAAEC,aAAa,QAAQ,aAAU;AAEpE,OAAO,MAAMC,iBAAiB,GAAG,EAAE;AAEnC,OAAO,SAASC,eAAeA,CAACC,IAA6B,EAAU;EACtE,OAAOA,IAAI,EAAEC,IAAI,IAAIH,iBAAiB;AACvC;;AAEA;AACA,OAAO,SAASI,aAAaA,CAACD,IAAY,EAAU;EACnD,OAAOE,IAAI,CAACC,GAAG,CAACH,IAAI,EAAEP,OAAO,CAACW,aAAa,CAAC,GAAG,CAAC;AACjD;AAEA,OAAO,SAASC,WAAWA,CAC1BC,OAAY,EACZC,IAAe,EACfC,MAA0B,EACpB;EACN,IAAI,CAACA,MAAM,EAAE;IACZ,OAAOF,OAAO;EACf;EACA,MAAMG,MAAM,GAAGf,YAAY,CAACc,MAAM,EAAED,IAAI,CAAC;EACzC,OAAOD,OAAO,CAACI,MAAM,CAACC,MAAM,IAAIf,aAAa,CAACe,MAAM,EAAEJ,IAAI,EAAEE,MAAM,CAAC,CAAC;AACrE;AAEA,OAAO,SAASG,SAASA,CACxBN,OAA0B,EAC1BC,IAAe,EACfP,IAAY,EACI;EAChB,MAAMa,OAAO,GAAGP,OAAO,CAACQ,MAAM,GAAGd,IAAI;EACrC,MAAMD,IAAI,GAAGc,OAAO,GAAGP,OAAO,CAACS,KAAK,CAAC,CAAC,EAAEf,IAAI,CAAC,GAAGM,OAAO;EACvD,MAAMU,IAAI,GAAGjB,IAAI,CAACA,IAAI,CAACe,MAAM,GAAG,CAAC,CAAC;EAClC,OAAO;IACNR,OAAO,EAAEP,IAAI;IACb;IACA;IACAS,MAAM,EAAEK,OAAO,IAAIG,IAAI,GAAGrB,YAAY,CAACqB,IAAI,EAAET,IAAI,CAAC,GAAGU,SAAS;IAC9DJ;EACD,CAAC;AACF","ignoreList":[]}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Sort ordering.
5
+ *
6
+ * The record id is always appended as the final sort key (FR-031). Without a
7
+ * tiebreaker, records with equal sort values come back in whatever order the
8
+ * engine happens to produce, which makes keyset pagination lose or repeat
9
+ * rows — the exact failure SC-007 forbids.
10
+ */
11
+
12
+ import { asFilterValue, compareValues, lookupField } from "./compare.js";
13
+ export const ID_SORT_KEY = {
14
+ field: 'id',
15
+ direction: 'asc'
16
+ };
17
+
18
+ /** Append `id ASC` unless the caller already sorted by it. */
19
+ export function withStableTiebreaker(sort) {
20
+ const keys = sort ? [...sort] : [];
21
+ if (!keys.some(key => key.field === 'id')) {
22
+ keys.push(ID_SORT_KEY);
23
+ }
24
+ return keys;
25
+ }
26
+
27
+ /** Sort values come from the record id or from a declared field. */
28
+ export function sortValueOf(record, field) {
29
+ if (field === 'id') {
30
+ return record.id;
31
+ }
32
+ const lookup = lookupField(record.data, field);
33
+ if (!lookup.present) {
34
+ // Absent sorts alongside null, matching how SQLite treats a NULL
35
+ // column, so the two adapters agree without special-casing.
36
+ return null;
37
+ }
38
+ return asFilterValue(lookup.value) ?? null;
39
+ }
40
+ export function compareRecords(a, b, sort) {
41
+ for (const key of sort) {
42
+ const direction = key.direction === 'desc' ? -1 : 1;
43
+ const result = compareValues(sortValueOf(a, key.field) ?? null, sortValueOf(b, key.field) ?? null);
44
+ if (result !== 0) {
45
+ return result * direction;
46
+ }
47
+ }
48
+ return 0;
49
+ }
50
+ export function sortRecords(records, sort) {
51
+ return [...records].sort((a, b) => compareRecords(a, b, sort));
52
+ }
53
+ //# sourceMappingURL=sort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["asFilterValue","compareValues","lookupField","ID_SORT_KEY","field","direction","withStableTiebreaker","sort","keys","some","key","push","sortValueOf","record","id","lookup","data","present","value","compareRecords","a","b","result","sortRecords","records"],"sourceRoot":"../../../src","sources":["query/sort.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,aAAa,EAAEC,aAAa,EAAEC,WAAW,QAAQ,cAAW;AAErE,OAAO,MAAMC,WAAoB,GAAG;EAAEC,KAAK,EAAE,IAAI;EAAEC,SAAS,EAAE;AAAM,CAAC;;AAErE;AACA,OAAO,SAASC,oBAAoBA,CAACC,IAA2B,EAAa;EAC5E,MAAMC,IAAI,GAAGD,IAAI,GAAG,CAAC,GAAGA,IAAI,CAAC,GAAG,EAAE;EAClC,IAAI,CAACC,IAAI,CAACC,IAAI,CAACC,GAAG,IAAIA,GAAG,CAACN,KAAK,KAAK,IAAI,CAAC,EAAE;IAC1CI,IAAI,CAACG,IAAI,CA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