@chipmobilesdk/rn-local-db 0.3.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.
- package/CHANGELOG.md +160 -1
- package/README.md +99 -19
- package/lib/commonjs/adapter/budgets.js +79 -0
- package/lib/commonjs/adapter/budgets.js.map +1 -0
- package/lib/commonjs/adapter/collection.js +236 -0
- package/lib/commonjs/adapter/collection.js.map +1 -0
- package/lib/commonjs/adapter/deletion.js +291 -0
- package/lib/commonjs/adapter/deletion.js.map +1 -0
- package/lib/commonjs/adapter/handle.js +259 -0
- package/lib/commonjs/adapter/handle.js.map +1 -0
- package/lib/commonjs/adapter/index.js +67 -0
- package/lib/commonjs/adapter/index.js.map +1 -0
- package/lib/commonjs/adapter/lifecycle.js +176 -0
- package/lib/commonjs/adapter/lifecycle.js.map +1 -0
- package/lib/commonjs/adapter/schema-sync.js +124 -0
- package/lib/commonjs/adapter/schema-sync.js.map +1 -0
- package/lib/commonjs/adapter/transaction.js +58 -0
- package/lib/commonjs/adapter/transaction.js.map +1 -0
- package/lib/commonjs/artifacts/availability.js +90 -0
- package/lib/commonjs/artifacts/availability.js.map +1 -0
- package/lib/commonjs/artifacts/cascade.js +80 -0
- package/lib/commonjs/artifacts/cascade.js.map +1 -0
- package/lib/commonjs/artifacts/paths.js +31 -0
- package/lib/commonjs/artifacts/paths.js.map +1 -0
- package/lib/commonjs/artifacts/reconcile.js +55 -0
- package/lib/commonjs/artifacts/reconcile.js.map +1 -0
- package/lib/commonjs/artifacts/store.js +300 -0
- package/lib/commonjs/artifacts/store.js.map +1 -0
- package/lib/commonjs/contract/adapter.js +6 -0
- package/lib/commonjs/contract/adapter.js.map +1 -0
- package/lib/commonjs/contract/attachment.js +2 -0
- package/lib/commonjs/contract/attachment.js.map +1 -0
- package/lib/commonjs/contract/backup.js +2 -0
- package/lib/commonjs/contract/backup.js.map +1 -0
- package/lib/commonjs/contract/config.js +31 -0
- package/lib/commonjs/contract/config.js.map +1 -0
- package/lib/commonjs/contract/encryption.js +6 -0
- package/lib/commonjs/contract/encryption.js.map +1 -0
- package/lib/commonjs/contract/errors.js +64 -0
- package/lib/commonjs/contract/errors.js.map +1 -0
- package/lib/commonjs/contract/migration.js +6 -0
- package/lib/commonjs/contract/migration.js.map +1 -0
- package/lib/commonjs/contract/query.js +6 -0
- package/lib/commonjs/contract/query.js.map +1 -0
- package/lib/commonjs/contract/record.js +6 -0
- package/lib/commonjs/contract/record.js.map +1 -0
- package/lib/commonjs/contract/schema.js +2 -0
- package/lib/commonjs/contract/schema.js.map +1 -0
- package/lib/commonjs/contract/scope.js +2 -0
- package/lib/commonjs/contract/scope.js.map +1 -0
- package/lib/commonjs/contract/transaction.js +6 -0
- package/lib/commonjs/contract/transaction.js.map +1 -0
- package/lib/commonjs/crypto/chunked-cipher.js +147 -0
- package/lib/commonjs/crypto/chunked-cipher.js.map +1 -0
- package/lib/commonjs/crypto/derive.js +61 -0
- package/lib/commonjs/crypto/derive.js.map +1 -0
- package/lib/commonjs/crypto/key-provider.js +70 -0
- package/lib/commonjs/crypto/key-provider.js.map +1 -0
- package/lib/commonjs/crypto/provider.js +54 -0
- package/lib/commonjs/crypto/provider.js.map +1 -0
- package/lib/commonjs/diagnostics/dev-log.js +127 -0
- package/lib/commonjs/diagnostics/dev-log.js.map +1 -0
- package/lib/commonjs/diagnostics/errors.js +57 -0
- package/lib/commonjs/diagnostics/errors.js.map +1 -0
- package/lib/commonjs/diagnostics/faults.js +54 -0
- package/lib/commonjs/diagnostics/faults.js.map +1 -0
- package/lib/commonjs/diagnostics/map-native.js +98 -0
- package/lib/commonjs/diagnostics/map-native.js.map +1 -0
- package/lib/commonjs/diagnostics/redact.js +110 -0
- package/lib/commonjs/diagnostics/redact.js.map +1 -0
- package/lib/commonjs/index.js +70 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/migration/executor.js +136 -0
- package/lib/commonjs/migration/executor.js.map +1 -0
- package/lib/commonjs/migration/ledger.js +64 -0
- package/lib/commonjs/migration/ledger.js.map +1 -0
- package/lib/commonjs/migration/validate-chain.js +76 -0
- package/lib/commonjs/migration/validate-chain.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/platform/backup-android-verify.js +76 -0
- package/lib/commonjs/platform/backup-android-verify.js.map +1 -0
- package/lib/commonjs/platform/backup-ios.js +50 -0
- package/lib/commonjs/platform/backup-ios.js.map +1 -0
- package/lib/commonjs/platform/bytes.js +158 -0
- package/lib/commonjs/platform/bytes.js.map +1 -0
- package/lib/commonjs/platform/fs.js +59 -0
- package/lib/commonjs/platform/fs.js.map +1 -0
- package/lib/commonjs/platform/location.js +129 -0
- package/lib/commonjs/platform/location.js.map +1 -0
- package/lib/commonjs/query/budgets.js +95 -0
- package/lib/commonjs/query/budgets.js.map +1 -0
- package/lib/commonjs/query/compare.js +97 -0
- package/lib/commonjs/query/compare.js.map +1 -0
- package/lib/commonjs/query/cursor.js +97 -0
- package/lib/commonjs/query/cursor.js.map +1 -0
- package/lib/commonjs/query/filter.js +82 -0
- package/lib/commonjs/query/filter.js.map +1 -0
- package/lib/commonjs/query/paginate.js +48 -0
- package/lib/commonjs/query/paginate.js.map +1 -0
- package/lib/commonjs/query/sort.js +61 -0
- package/lib/commonjs/query/sort.js.map +1 -0
- package/lib/commonjs/query/validate.js +180 -0
- package/lib/commonjs/query/validate.js.map +1 -0
- package/lib/commonjs/schema/declare.js +47 -0
- package/lib/commonjs/schema/declare.js.map +1 -0
- package/lib/commonjs/schema/validate-config.js +115 -0
- package/lib/commonjs/schema/validate-config.js.map +1 -0
- package/lib/commonjs/scope/hash.js +107 -0
- package/lib/commonjs/scope/hash.js.map +1 -0
- package/lib/commonjs/scope/normalize.js +73 -0
- package/lib/commonjs/scope/normalize.js.map +1 -0
- package/lib/commonjs/scope/validate.js +81 -0
- package/lib/commonjs/scope/validate.js.map +1 -0
- package/lib/commonjs/sqlite/adapter.js +31 -0
- package/lib/commonjs/sqlite/adapter.js.map +1 -0
- package/lib/commonjs/sqlite/batch.js +218 -0
- package/lib/commonjs/sqlite/batch.js.map +1 -0
- package/lib/commonjs/sqlite/catalog.js +81 -0
- package/lib/commonjs/sqlite/catalog.js.map +1 -0
- package/lib/commonjs/sqlite/connection.js +210 -0
- package/lib/commonjs/sqlite/connection.js.map +1 -0
- package/lib/commonjs/sqlite/index-coverage.js +42 -0
- package/lib/commonjs/sqlite/index-coverage.js.map +1 -0
- package/lib/commonjs/sqlite/native.js +54 -0
- package/lib/commonjs/sqlite/native.js.map +1 -0
- package/lib/commonjs/sqlite/row-codec.js +192 -0
- package/lib/commonjs/sqlite/row-codec.js.map +1 -0
- package/lib/commonjs/sqlite/sql-builder.js +253 -0
- package/lib/commonjs/sqlite/sql-builder.js.map +1 -0
- package/lib/commonjs/sqlite/statements.js +54 -0
- package/lib/commonjs/sqlite/statements.js.map +1 -0
- package/lib/commonjs/sqlite/transaction-queue.js +79 -0
- package/lib/commonjs/sqlite/transaction-queue.js.map +1 -0
- package/lib/commonjs/sqlite/transactions.js +33 -0
- package/lib/commonjs/sqlite/transactions.js.map +1 -0
- package/lib/commonjs/sqlite/values.js +31 -0
- package/lib/commonjs/sqlite/values.js.map +1 -0
- package/lib/commonjs/testing/conformance/attachments.js +180 -0
- package/lib/commonjs/testing/conformance/attachments.js.map +1 -0
- package/lib/commonjs/testing/conformance/encryption.js +187 -0
- package/lib/commonjs/testing/conformance/encryption.js.map +1 -0
- package/lib/commonjs/testing/conformance/index.js +103 -0
- package/lib/commonjs/testing/conformance/index.js.map +1 -0
- package/lib/commonjs/testing/conformance/lifecycle.js +134 -0
- package/lib/commonjs/testing/conformance/lifecycle.js.map +1 -0
- package/lib/commonjs/testing/conformance/migrations.js +167 -0
- package/lib/commonjs/testing/conformance/migrations.js.map +1 -0
- package/lib/commonjs/testing/conformance/queries.js +278 -0
- package/lib/commonjs/testing/conformance/queries.js.map +1 -0
- package/lib/commonjs/testing/conformance/records.js +224 -0
- package/lib/commonjs/testing/conformance/records.js.map +1 -0
- package/lib/commonjs/testing/conformance/scopes.js +107 -0
- package/lib/commonjs/testing/conformance/scopes.js.map +1 -0
- package/lib/commonjs/testing/conformance/transactions.js +228 -0
- package/lib/commonjs/testing/conformance/transactions.js.map +1 -0
- package/lib/commonjs/testing/faults.js +38 -0
- package/lib/commonjs/testing/faults.js.map +1 -0
- package/lib/commonjs/testing/index.js +59 -0
- package/lib/commonjs/testing/index.js.map +1 -0
- package/lib/commonjs/testing/memory-adapter/attachments.js +145 -0
- package/lib/commonjs/testing/memory-adapter/attachments.js.map +1 -0
- package/lib/commonjs/testing/memory-adapter/collection.js +224 -0
- package/lib/commonjs/testing/memory-adapter/collection.js.map +1 -0
- package/lib/commonjs/testing/memory-adapter/index.js +366 -0
- package/lib/commonjs/testing/memory-adapter/index.js.map +1 -0
- package/lib/commonjs/testing/memory-adapter/migrations.js +126 -0
- package/lib/commonjs/testing/memory-adapter/migrations.js.map +1 -0
- package/lib/commonjs/testing/memory-adapter/reset.js +49 -0
- package/lib/commonjs/testing/memory-adapter/reset.js.map +1 -0
- package/lib/commonjs/testing/memory-adapter/store.js +107 -0
- package/lib/commonjs/testing/memory-adapter/store.js.map +1 -0
- package/lib/module/adapter/budgets.js +51 -0
- package/lib/module/adapter/budgets.js.map +1 -0
- package/lib/module/adapter/collection.js +232 -0
- package/lib/module/adapter/collection.js.map +1 -0
- package/lib/module/adapter/deletion.js +280 -0
- package/lib/module/adapter/deletion.js.map +1 -0
- package/lib/module/adapter/handle.js +254 -0
- package/lib/module/adapter/handle.js.map +1 -0
- package/lib/module/adapter/index.js +59 -0
- package/lib/module/adapter/index.js.map +1 -0
- package/lib/module/adapter/lifecycle.js +172 -0
- package/lib/module/adapter/lifecycle.js.map +1 -0
- package/lib/module/adapter/schema-sync.js +121 -0
- package/lib/module/adapter/schema-sync.js.map +1 -0
- package/lib/module/adapter/transaction.js +54 -0
- package/lib/module/adapter/transaction.js.map +1 -0
- package/lib/module/artifacts/availability.js +86 -0
- package/lib/module/artifacts/availability.js.map +1 -0
- package/lib/module/artifacts/cascade.js +75 -0
- package/lib/module/artifacts/cascade.js.map +1 -0
- package/lib/module/artifacts/paths.js +26 -0
- package/lib/module/artifacts/paths.js.map +1 -0
- package/lib/module/artifacts/reconcile.js +51 -0
- package/lib/module/artifacts/reconcile.js.map +1 -0
- package/lib/module/artifacts/store.js +289 -0
- package/lib/module/artifacts/store.js.map +1 -0
- package/lib/module/contract/adapter.js +4 -0
- package/lib/module/contract/adapter.js.map +1 -0
- package/lib/module/contract/attachment.js +2 -0
- package/lib/module/contract/attachment.js.map +1 -0
- package/lib/module/contract/backup.js +2 -0
- package/lib/module/contract/backup.js.map +1 -0
- package/lib/module/contract/config.js +27 -0
- package/lib/module/contract/config.js.map +1 -0
- package/lib/module/contract/encryption.js +4 -0
- package/lib/module/contract/encryption.js.map +1 -0
- package/lib/module/contract/errors.js +60 -0
- package/lib/module/contract/errors.js.map +1 -0
- package/lib/module/contract/migration.js +4 -0
- package/lib/module/contract/migration.js.map +1 -0
- package/lib/module/contract/query.js +4 -0
- package/lib/module/contract/query.js.map +1 -0
- package/lib/module/contract/record.js +4 -0
- package/lib/module/contract/record.js.map +1 -0
- package/lib/module/contract/schema.js +2 -0
- package/lib/module/contract/schema.js.map +1 -0
- package/lib/module/contract/scope.js +2 -0
- package/lib/module/contract/scope.js.map +1 -0
- package/lib/module/contract/transaction.js +4 -0
- package/lib/module/contract/transaction.js.map +1 -0
- package/lib/module/crypto/chunked-cipher.js +134 -0
- package/lib/module/crypto/chunked-cipher.js.map +1 -0
- package/lib/module/crypto/derive.js +56 -0
- package/lib/module/crypto/derive.js.map +1 -0
- package/lib/module/crypto/key-provider.js +67 -0
- package/lib/module/crypto/key-provider.js.map +1 -0
- package/lib/module/crypto/provider.js +49 -0
- package/lib/module/crypto/provider.js.map +1 -0
- package/lib/module/diagnostics/dev-log.js +120 -0
- package/lib/module/diagnostics/dev-log.js.map +1 -0
- package/lib/module/diagnostics/errors.js +44 -0
- package/lib/module/diagnostics/errors.js.map +1 -0
- package/lib/module/diagnostics/faults.js +47 -0
- package/lib/module/diagnostics/faults.js.map +1 -0
- package/lib/module/diagnostics/map-native.js +93 -0
- package/lib/module/diagnostics/map-native.js.map +1 -0
- package/lib/module/diagnostics/redact.js +102 -0
- package/lib/module/diagnostics/redact.js.map +1 -0
- package/lib/module/index.js +28 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/migration/executor.js +132 -0
- package/lib/module/migration/executor.js.map +1 -0
- package/lib/module/migration/ledger.js +57 -0
- package/lib/module/migration/ledger.js.map +1 -0
- package/lib/module/migration/validate-chain.js +70 -0
- package/lib/module/migration/validate-chain.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/platform/backup-android-verify.js +69 -0
- package/lib/module/platform/backup-android-verify.js.map +1 -0
- package/lib/module/platform/backup-ios.js +44 -0
- package/lib/module/platform/backup-ios.js.map +1 -0
- package/lib/module/platform/bytes.js +148 -0
- package/lib/module/platform/bytes.js.map +1 -0
- package/lib/module/platform/fs.js +54 -0
- package/lib/module/platform/fs.js.map +1 -0
- package/lib/module/platform/location.js +120 -0
- package/lib/module/platform/location.js.map +1 -0
- package/lib/module/query/budgets.js +88 -0
- package/lib/module/query/budgets.js.map +1 -0
- package/lib/module/query/compare.js +90 -0
- package/lib/module/query/compare.js.map +1 -0
- package/lib/module/query/cursor.js +91 -0
- package/lib/module/query/cursor.js.map +1 -0
- package/lib/module/query/filter.js +78 -0
- package/lib/module/query/filter.js.map +1 -0
- package/lib/module/query/paginate.js +40 -0
- package/lib/module/query/paginate.js.map +1 -0
- package/lib/module/query/sort.js +53 -0
- package/lib/module/query/sort.js.map +1 -0
- package/lib/module/query/validate.js +173 -0
- package/lib/module/query/validate.js.map +1 -0
- package/lib/module/schema/declare.js +37 -0
- package/lib/module/schema/declare.js.map +1 -0
- package/lib/module/schema/validate-config.js +111 -0
- package/lib/module/schema/validate-config.js.map +1 -0
- package/lib/module/scope/hash.js +102 -0
- package/lib/module/scope/hash.js.map +1 -0
- package/lib/module/scope/normalize.js +67 -0
- package/lib/module/scope/normalize.js.map +1 -0
- package/lib/module/scope/validate.js +76 -0
- package/lib/module/scope/validate.js.map +1 -0
- package/lib/module/sqlite/adapter.js +27 -0
- package/lib/module/sqlite/adapter.js.map +1 -0
- package/lib/module/sqlite/batch.js +214 -0
- package/lib/module/sqlite/batch.js.map +1 -0
- package/lib/module/sqlite/catalog.js +72 -0
- package/lib/module/sqlite/catalog.js.map +1 -0
- package/lib/module/sqlite/connection.js +206 -0
- package/lib/module/sqlite/connection.js.map +1 -0
- package/lib/module/sqlite/index-coverage.js +38 -0
- package/lib/module/sqlite/index-coverage.js.map +1 -0
- package/lib/module/sqlite/native.js +48 -0
- package/lib/module/sqlite/native.js.map +1 -0
- package/lib/module/sqlite/row-codec.js +176 -0
- package/lib/module/sqlite/row-codec.js.map +1 -0
- package/lib/module/sqlite/sql-builder.js +247 -0
- package/lib/module/sqlite/sql-builder.js.map +1 -0
- package/lib/module/sqlite/statements.js +49 -0
- package/lib/module/sqlite/statements.js.map +1 -0
- package/lib/module/sqlite/transaction-queue.js +75 -0
- package/lib/module/sqlite/transaction-queue.js.map +1 -0
- package/lib/module/sqlite/transactions.js +29 -0
- package/lib/module/sqlite/transactions.js.map +1 -0
- package/lib/module/sqlite/values.js +24 -0
- package/lib/module/sqlite/values.js.map +1 -0
- package/lib/module/testing/conformance/attachments.js +176 -0
- package/lib/module/testing/conformance/attachments.js.map +1 -0
- package/lib/module/testing/conformance/encryption.js +183 -0
- package/lib/module/testing/conformance/encryption.js.map +1 -0
- package/lib/module/testing/conformance/index.js +97 -0
- package/lib/module/testing/conformance/index.js.map +1 -0
- package/lib/module/testing/conformance/lifecycle.js +130 -0
- package/lib/module/testing/conformance/lifecycle.js.map +1 -0
- package/lib/module/testing/conformance/migrations.js +163 -0
- package/lib/module/testing/conformance/migrations.js.map +1 -0
- package/lib/module/testing/conformance/queries.js +274 -0
- package/lib/module/testing/conformance/queries.js.map +1 -0
- package/lib/module/testing/conformance/records.js +220 -0
- package/lib/module/testing/conformance/records.js.map +1 -0
- package/lib/module/testing/conformance/scopes.js +103 -0
- package/lib/module/testing/conformance/scopes.js.map +1 -0
- package/lib/module/testing/conformance/transactions.js +224 -0
- package/lib/module/testing/conformance/transactions.js.map +1 -0
- package/lib/module/testing/faults.js +16 -0
- package/lib/module/testing/faults.js.map +1 -0
- package/lib/module/testing/index.js +16 -0
- package/lib/module/testing/index.js.map +1 -0
- package/lib/module/testing/memory-adapter/attachments.js +142 -0
- package/lib/module/testing/memory-adapter/attachments.js.map +1 -0
- package/lib/module/testing/memory-adapter/collection.js +220 -0
- package/lib/module/testing/memory-adapter/collection.js.map +1 -0
- package/lib/module/testing/memory-adapter/index.js +351 -0
- package/lib/module/testing/memory-adapter/index.js.map +1 -0
- package/lib/module/testing/memory-adapter/migrations.js +122 -0
- package/lib/module/testing/memory-adapter/migrations.js.map +1 -0
- package/lib/module/testing/memory-adapter/reset.js +44 -0
- package/lib/module/testing/memory-adapter/reset.js.map +1 -0
- package/lib/module/testing/memory-adapter/store.js +94 -0
- package/lib/module/testing/memory-adapter/store.js.map +1 -0
- package/lib/typescript/commonjs/adapter/budgets.d.ts +19 -0
- package/lib/typescript/commonjs/adapter/budgets.d.ts.map +1 -0
- package/lib/typescript/commonjs/adapter/collection.d.ts +25 -0
- package/lib/typescript/commonjs/adapter/collection.d.ts.map +1 -0
- package/lib/typescript/commonjs/adapter/deletion.d.ts +48 -0
- package/lib/typescript/commonjs/adapter/deletion.d.ts.map +1 -0
- package/lib/typescript/commonjs/adapter/handle.d.ts +30 -0
- package/lib/typescript/commonjs/adapter/handle.d.ts.map +1 -0
- package/lib/typescript/commonjs/adapter/index.d.ts +30 -0
- package/lib/typescript/commonjs/adapter/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/adapter/lifecycle.d.ts +25 -0
- package/lib/typescript/commonjs/adapter/lifecycle.d.ts.map +1 -0
- package/lib/typescript/commonjs/adapter/schema-sync.d.ts +19 -0
- package/lib/typescript/commonjs/adapter/schema-sync.d.ts.map +1 -0
- package/lib/typescript/commonjs/adapter/transaction.d.ts +32 -0
- package/lib/typescript/commonjs/adapter/transaction.d.ts.map +1 -0
- package/lib/typescript/commonjs/artifacts/availability.d.ts +19 -0
- package/lib/typescript/commonjs/artifacts/availability.d.ts.map +1 -0
- package/lib/typescript/commonjs/artifacts/cascade.d.ts +26 -0
- package/lib/typescript/commonjs/artifacts/cascade.d.ts.map +1 -0
- package/lib/typescript/commonjs/artifacts/paths.d.ts +16 -0
- package/lib/typescript/commonjs/artifacts/paths.d.ts.map +1 -0
- package/lib/typescript/commonjs/artifacts/reconcile.d.ts +23 -0
- package/lib/typescript/commonjs/artifacts/reconcile.d.ts.map +1 -0
- package/lib/typescript/commonjs/artifacts/store.d.ts +45 -0
- package/lib/typescript/commonjs/artifacts/store.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/adapter.d.ts +55 -0
- package/lib/typescript/commonjs/contract/adapter.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/attachment.d.ts +84 -0
- package/lib/typescript/commonjs/contract/attachment.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/backup.d.ts +26 -0
- package/lib/typescript/commonjs/contract/backup.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/config.d.ts +50 -0
- package/lib/typescript/commonjs/contract/config.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/encryption.d.ts +31 -0
- package/lib/typescript/commonjs/contract/encryption.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/errors.d.ts +50 -0
- package/lib/typescript/commonjs/contract/errors.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/migration.d.ts +37 -0
- package/lib/typescript/commonjs/contract/migration.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/query.d.ts +79 -0
- package/lib/typescript/commonjs/contract/query.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/record.d.ts +43 -0
- package/lib/typescript/commonjs/contract/record.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/schema.d.ts +33 -0
- package/lib/typescript/commonjs/contract/schema.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/scope.d.ts +33 -0
- package/lib/typescript/commonjs/contract/scope.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/transaction.d.ts +66 -0
- package/lib/typescript/commonjs/contract/transaction.d.ts.map +1 -0
- package/lib/typescript/commonjs/crypto/chunked-cipher.d.ts +57 -0
- package/lib/typescript/commonjs/crypto/chunked-cipher.d.ts.map +1 -0
- package/lib/typescript/commonjs/crypto/derive.d.ts +28 -0
- package/lib/typescript/commonjs/crypto/derive.d.ts.map +1 -0
- package/lib/typescript/commonjs/crypto/key-provider.d.ts +30 -0
- package/lib/typescript/commonjs/crypto/key-provider.d.ts.map +1 -0
- package/lib/typescript/commonjs/crypto/provider.d.ts +35 -0
- package/lib/typescript/commonjs/crypto/provider.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/dev-log.d.ts +35 -0
- package/lib/typescript/commonjs/diagnostics/dev-log.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/errors.d.ts +34 -0
- package/lib/typescript/commonjs/diagnostics/errors.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/faults.d.ts +26 -0
- package/lib/typescript/commonjs/diagnostics/faults.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/map-native.d.ts +31 -0
- package/lib/typescript/commonjs/diagnostics/map-native.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/redact.d.ts +70 -0
- package/lib/typescript/commonjs/diagnostics/redact.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +30 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/migration/executor.d.ts +40 -0
- package/lib/typescript/commonjs/migration/executor.d.ts.map +1 -0
- package/lib/typescript/commonjs/migration/ledger.d.ts +34 -0
- package/lib/typescript/commonjs/migration/ledger.d.ts.map +1 -0
- package/lib/typescript/commonjs/migration/validate-chain.d.ts +20 -0
- package/lib/typescript/commonjs/migration/validate-chain.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/platform/backup-android-verify.d.ts +30 -0
- package/lib/typescript/commonjs/platform/backup-android-verify.d.ts.map +1 -0
- package/lib/typescript/commonjs/platform/backup-ios.d.ts +26 -0
- package/lib/typescript/commonjs/platform/backup-ios.d.ts.map +1 -0
- package/lib/typescript/commonjs/platform/bytes.d.ts +36 -0
- package/lib/typescript/commonjs/platform/bytes.d.ts.map +1 -0
- package/lib/typescript/commonjs/platform/fs.d.ts +47 -0
- package/lib/typescript/commonjs/platform/fs.d.ts.map +1 -0
- package/lib/typescript/commonjs/platform/location.d.ts +53 -0
- package/lib/typescript/commonjs/platform/location.d.ts.map +1 -0
- package/lib/typescript/commonjs/query/budgets.d.ts +23 -0
- package/lib/typescript/commonjs/query/budgets.d.ts.map +1 -0
- package/lib/typescript/commonjs/query/compare.d.ts +42 -0
- package/lib/typescript/commonjs/query/compare.d.ts.map +1 -0
- package/lib/typescript/commonjs/query/cursor.d.ts +27 -0
- package/lib/typescript/commonjs/query/cursor.d.ts.map +1 -0
- package/lib/typescript/commonjs/query/filter.d.ts +11 -0
- package/lib/typescript/commonjs/query/filter.d.ts.map +1 -0
- package/lib/typescript/commonjs/query/paginate.d.ts +15 -0
- package/lib/typescript/commonjs/query/paginate.d.ts.map +1 -0
- package/lib/typescript/commonjs/query/sort.d.ts +19 -0
- package/lib/typescript/commonjs/query/sort.d.ts.map +1 -0
- package/lib/typescript/commonjs/query/validate.d.ts +15 -0
- package/lib/typescript/commonjs/query/validate.d.ts.map +1 -0
- package/lib/typescript/commonjs/schema/declare.d.ts +20 -0
- package/lib/typescript/commonjs/schema/declare.d.ts.map +1 -0
- package/lib/typescript/commonjs/schema/validate-config.d.ts +11 -0
- package/lib/typescript/commonjs/schema/validate-config.d.ts.map +1 -0
- package/lib/typescript/commonjs/scope/hash.d.ts +24 -0
- package/lib/typescript/commonjs/scope/hash.d.ts.map +1 -0
- package/lib/typescript/commonjs/scope/normalize.d.ts +46 -0
- package/lib/typescript/commonjs/scope/normalize.d.ts.map +1 -0
- package/lib/typescript/commonjs/scope/validate.d.ts +15 -0
- package/lib/typescript/commonjs/scope/validate.d.ts.map +1 -0
- package/lib/typescript/commonjs/sqlite/adapter.d.ts +16 -0
- package/lib/typescript/commonjs/sqlite/adapter.d.ts.map +1 -0
- package/lib/typescript/commonjs/sqlite/batch.d.ts +25 -0
- package/lib/typescript/commonjs/sqlite/batch.d.ts.map +1 -0
- package/lib/typescript/commonjs/sqlite/catalog.d.ts +34 -0
- package/lib/typescript/commonjs/sqlite/catalog.d.ts.map +1 -0
- package/lib/typescript/commonjs/sqlite/connection.d.ts +58 -0
- package/lib/typescript/commonjs/sqlite/connection.d.ts.map +1 -0
- package/lib/typescript/commonjs/sqlite/index-coverage.d.ts +18 -0
- package/lib/typescript/commonjs/sqlite/index-coverage.d.ts.map +1 -0
- package/lib/typescript/commonjs/sqlite/native.d.ts +48 -0
- package/lib/typescript/commonjs/sqlite/native.d.ts.map +1 -0
- package/lib/typescript/commonjs/sqlite/row-codec.d.ts +69 -0
- package/lib/typescript/commonjs/sqlite/row-codec.d.ts.map +1 -0
- package/lib/typescript/commonjs/sqlite/sql-builder.d.ts +34 -0
- package/lib/typescript/commonjs/sqlite/sql-builder.d.ts.map +1 -0
- package/lib/typescript/commonjs/sqlite/statements.d.ts +26 -0
- package/lib/typescript/commonjs/sqlite/statements.d.ts.map +1 -0
- package/lib/typescript/commonjs/sqlite/transaction-queue.d.ts +31 -0
- package/lib/typescript/commonjs/sqlite/transaction-queue.d.ts.map +1 -0
- package/lib/typescript/commonjs/sqlite/transactions.d.ts +26 -0
- package/lib/typescript/commonjs/sqlite/transactions.d.ts.map +1 -0
- package/lib/typescript/commonjs/sqlite/values.d.ts +13 -0
- package/lib/typescript/commonjs/sqlite/values.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/conformance/attachments.d.ts +4 -0
- package/lib/typescript/commonjs/testing/conformance/attachments.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/conformance/encryption.d.ts +4 -0
- package/lib/typescript/commonjs/testing/conformance/encryption.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/conformance/index.d.ts +58 -0
- package/lib/typescript/commonjs/testing/conformance/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/conformance/lifecycle.d.ts +4 -0
- package/lib/typescript/commonjs/testing/conformance/lifecycle.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/conformance/migrations.d.ts +4 -0
- package/lib/typescript/commonjs/testing/conformance/migrations.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/conformance/queries.d.ts +4 -0
- package/lib/typescript/commonjs/testing/conformance/queries.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/conformance/records.d.ts +4 -0
- package/lib/typescript/commonjs/testing/conformance/records.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/conformance/scopes.d.ts +4 -0
- package/lib/typescript/commonjs/testing/conformance/scopes.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/conformance/transactions.d.ts +4 -0
- package/lib/typescript/commonjs/testing/conformance/transactions.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/faults.d.ts +13 -0
- package/lib/typescript/commonjs/testing/faults.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/index.d.ts +13 -0
- package/lib/typescript/commonjs/testing/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/memory-adapter/attachments.d.ts +23 -0
- package/lib/typescript/commonjs/testing/memory-adapter/attachments.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/memory-adapter/collection.d.ts +19 -0
- package/lib/typescript/commonjs/testing/memory-adapter/collection.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/memory-adapter/index.d.ts +22 -0
- package/lib/typescript/commonjs/testing/memory-adapter/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/memory-adapter/migrations.d.ts +11 -0
- package/lib/typescript/commonjs/testing/memory-adapter/migrations.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/memory-adapter/reset.d.ts +23 -0
- package/lib/typescript/commonjs/testing/memory-adapter/reset.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/memory-adapter/store.d.ts +54 -0
- package/lib/typescript/commonjs/testing/memory-adapter/store.d.ts.map +1 -0
- package/lib/typescript/module/adapter/budgets.d.ts +19 -0
- package/lib/typescript/module/adapter/budgets.d.ts.map +1 -0
- package/lib/typescript/module/adapter/collection.d.ts +25 -0
- package/lib/typescript/module/adapter/collection.d.ts.map +1 -0
- package/lib/typescript/module/adapter/deletion.d.ts +48 -0
- package/lib/typescript/module/adapter/deletion.d.ts.map +1 -0
- package/lib/typescript/module/adapter/handle.d.ts +30 -0
- package/lib/typescript/module/adapter/handle.d.ts.map +1 -0
- package/lib/typescript/module/adapter/index.d.ts +30 -0
- package/lib/typescript/module/adapter/index.d.ts.map +1 -0
- package/lib/typescript/module/adapter/lifecycle.d.ts +25 -0
- package/lib/typescript/module/adapter/lifecycle.d.ts.map +1 -0
- package/lib/typescript/module/adapter/schema-sync.d.ts +19 -0
- package/lib/typescript/module/adapter/schema-sync.d.ts.map +1 -0
- package/lib/typescript/module/adapter/transaction.d.ts +32 -0
- package/lib/typescript/module/adapter/transaction.d.ts.map +1 -0
- package/lib/typescript/module/artifacts/availability.d.ts +19 -0
- package/lib/typescript/module/artifacts/availability.d.ts.map +1 -0
- package/lib/typescript/module/artifacts/cascade.d.ts +26 -0
- package/lib/typescript/module/artifacts/cascade.d.ts.map +1 -0
- package/lib/typescript/module/artifacts/paths.d.ts +16 -0
- package/lib/typescript/module/artifacts/paths.d.ts.map +1 -0
- package/lib/typescript/module/artifacts/reconcile.d.ts +23 -0
- package/lib/typescript/module/artifacts/reconcile.d.ts.map +1 -0
- package/lib/typescript/module/artifacts/store.d.ts +45 -0
- package/lib/typescript/module/artifacts/store.d.ts.map +1 -0
- package/lib/typescript/module/contract/adapter.d.ts +55 -0
- package/lib/typescript/module/contract/adapter.d.ts.map +1 -0
- package/lib/typescript/module/contract/attachment.d.ts +84 -0
- package/lib/typescript/module/contract/attachment.d.ts.map +1 -0
- package/lib/typescript/module/contract/backup.d.ts +26 -0
- package/lib/typescript/module/contract/backup.d.ts.map +1 -0
- package/lib/typescript/module/contract/config.d.ts +50 -0
- package/lib/typescript/module/contract/config.d.ts.map +1 -0
- package/lib/typescript/module/contract/encryption.d.ts +31 -0
- package/lib/typescript/module/contract/encryption.d.ts.map +1 -0
- package/lib/typescript/module/contract/errors.d.ts +50 -0
- package/lib/typescript/module/contract/errors.d.ts.map +1 -0
- package/lib/typescript/module/contract/migration.d.ts +37 -0
- package/lib/typescript/module/contract/migration.d.ts.map +1 -0
- package/lib/typescript/module/contract/query.d.ts +79 -0
- package/lib/typescript/module/contract/query.d.ts.map +1 -0
- package/lib/typescript/module/contract/record.d.ts +43 -0
- package/lib/typescript/module/contract/record.d.ts.map +1 -0
- package/lib/typescript/module/contract/schema.d.ts +33 -0
- package/lib/typescript/module/contract/schema.d.ts.map +1 -0
- package/lib/typescript/module/contract/scope.d.ts +33 -0
- package/lib/typescript/module/contract/scope.d.ts.map +1 -0
- package/lib/typescript/module/contract/transaction.d.ts +66 -0
- package/lib/typescript/module/contract/transaction.d.ts.map +1 -0
- package/lib/typescript/module/crypto/chunked-cipher.d.ts +57 -0
- package/lib/typescript/module/crypto/chunked-cipher.d.ts.map +1 -0
- package/lib/typescript/module/crypto/derive.d.ts +28 -0
- package/lib/typescript/module/crypto/derive.d.ts.map +1 -0
- package/lib/typescript/module/crypto/key-provider.d.ts +30 -0
- package/lib/typescript/module/crypto/key-provider.d.ts.map +1 -0
- package/lib/typescript/module/crypto/provider.d.ts +35 -0
- package/lib/typescript/module/crypto/provider.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/dev-log.d.ts +35 -0
- package/lib/typescript/module/diagnostics/dev-log.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/errors.d.ts +34 -0
- package/lib/typescript/module/diagnostics/errors.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/faults.d.ts +26 -0
- package/lib/typescript/module/diagnostics/faults.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/map-native.d.ts +31 -0
- package/lib/typescript/module/diagnostics/map-native.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/redact.d.ts +70 -0
- package/lib/typescript/module/diagnostics/redact.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +30 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/migration/executor.d.ts +40 -0
- package/lib/typescript/module/migration/executor.d.ts.map +1 -0
- package/lib/typescript/module/migration/ledger.d.ts +34 -0
- package/lib/typescript/module/migration/ledger.d.ts.map +1 -0
- package/lib/typescript/module/migration/validate-chain.d.ts +20 -0
- package/lib/typescript/module/migration/validate-chain.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/platform/backup-android-verify.d.ts +30 -0
- package/lib/typescript/module/platform/backup-android-verify.d.ts.map +1 -0
- package/lib/typescript/module/platform/backup-ios.d.ts +26 -0
- package/lib/typescript/module/platform/backup-ios.d.ts.map +1 -0
- package/lib/typescript/module/platform/bytes.d.ts +36 -0
- package/lib/typescript/module/platform/bytes.d.ts.map +1 -0
- package/lib/typescript/module/platform/fs.d.ts +47 -0
- package/lib/typescript/module/platform/fs.d.ts.map +1 -0
- package/lib/typescript/module/platform/location.d.ts +53 -0
- package/lib/typescript/module/platform/location.d.ts.map +1 -0
- package/lib/typescript/module/query/budgets.d.ts +23 -0
- package/lib/typescript/module/query/budgets.d.ts.map +1 -0
- package/lib/typescript/module/query/compare.d.ts +42 -0
- package/lib/typescript/module/query/compare.d.ts.map +1 -0
- package/lib/typescript/module/query/cursor.d.ts +27 -0
- package/lib/typescript/module/query/cursor.d.ts.map +1 -0
- package/lib/typescript/module/query/filter.d.ts +11 -0
- package/lib/typescript/module/query/filter.d.ts.map +1 -0
- package/lib/typescript/module/query/paginate.d.ts +15 -0
- package/lib/typescript/module/query/paginate.d.ts.map +1 -0
- package/lib/typescript/module/query/sort.d.ts +19 -0
- package/lib/typescript/module/query/sort.d.ts.map +1 -0
- package/lib/typescript/module/query/validate.d.ts +15 -0
- package/lib/typescript/module/query/validate.d.ts.map +1 -0
- package/lib/typescript/module/schema/declare.d.ts +20 -0
- package/lib/typescript/module/schema/declare.d.ts.map +1 -0
- package/lib/typescript/module/schema/validate-config.d.ts +11 -0
- package/lib/typescript/module/schema/validate-config.d.ts.map +1 -0
- package/lib/typescript/module/scope/hash.d.ts +24 -0
- package/lib/typescript/module/scope/hash.d.ts.map +1 -0
- package/lib/typescript/module/scope/normalize.d.ts +46 -0
- package/lib/typescript/module/scope/normalize.d.ts.map +1 -0
- package/lib/typescript/module/scope/validate.d.ts +15 -0
- package/lib/typescript/module/scope/validate.d.ts.map +1 -0
- package/lib/typescript/module/sqlite/adapter.d.ts +16 -0
- package/lib/typescript/module/sqlite/adapter.d.ts.map +1 -0
- package/lib/typescript/module/sqlite/batch.d.ts +25 -0
- package/lib/typescript/module/sqlite/batch.d.ts.map +1 -0
- package/lib/typescript/module/sqlite/catalog.d.ts +34 -0
- package/lib/typescript/module/sqlite/catalog.d.ts.map +1 -0
- package/lib/typescript/module/sqlite/connection.d.ts +58 -0
- package/lib/typescript/module/sqlite/connection.d.ts.map +1 -0
- package/lib/typescript/module/sqlite/index-coverage.d.ts +18 -0
- package/lib/typescript/module/sqlite/index-coverage.d.ts.map +1 -0
- package/lib/typescript/module/sqlite/native.d.ts +48 -0
- package/lib/typescript/module/sqlite/native.d.ts.map +1 -0
- package/lib/typescript/module/sqlite/row-codec.d.ts +69 -0
- package/lib/typescript/module/sqlite/row-codec.d.ts.map +1 -0
- package/lib/typescript/module/sqlite/sql-builder.d.ts +34 -0
- package/lib/typescript/module/sqlite/sql-builder.d.ts.map +1 -0
- package/lib/typescript/module/sqlite/statements.d.ts +26 -0
- package/lib/typescript/module/sqlite/statements.d.ts.map +1 -0
- package/lib/typescript/module/sqlite/transaction-queue.d.ts +31 -0
- package/lib/typescript/module/sqlite/transaction-queue.d.ts.map +1 -0
- package/lib/typescript/module/sqlite/transactions.d.ts +26 -0
- package/lib/typescript/module/sqlite/transactions.d.ts.map +1 -0
- package/lib/typescript/module/sqlite/values.d.ts +13 -0
- package/lib/typescript/module/sqlite/values.d.ts.map +1 -0
- package/lib/typescript/module/testing/conformance/attachments.d.ts +4 -0
- package/lib/typescript/module/testing/conformance/attachments.d.ts.map +1 -0
- package/lib/typescript/module/testing/conformance/encryption.d.ts +4 -0
- package/lib/typescript/module/testing/conformance/encryption.d.ts.map +1 -0
- package/lib/typescript/module/testing/conformance/index.d.ts +58 -0
- package/lib/typescript/module/testing/conformance/index.d.ts.map +1 -0
- package/lib/typescript/module/testing/conformance/lifecycle.d.ts +4 -0
- package/lib/typescript/module/testing/conformance/lifecycle.d.ts.map +1 -0
- package/lib/typescript/module/testing/conformance/migrations.d.ts +4 -0
- package/lib/typescript/module/testing/conformance/migrations.d.ts.map +1 -0
- package/lib/typescript/module/testing/conformance/queries.d.ts +4 -0
- package/lib/typescript/module/testing/conformance/queries.d.ts.map +1 -0
- package/lib/typescript/module/testing/conformance/records.d.ts +4 -0
- package/lib/typescript/module/testing/conformance/records.d.ts.map +1 -0
- package/lib/typescript/module/testing/conformance/scopes.d.ts +4 -0
- package/lib/typescript/module/testing/conformance/scopes.d.ts.map +1 -0
- package/lib/typescript/module/testing/conformance/transactions.d.ts +4 -0
- package/lib/typescript/module/testing/conformance/transactions.d.ts.map +1 -0
- package/lib/typescript/module/testing/faults.d.ts +13 -0
- package/lib/typescript/module/testing/faults.d.ts.map +1 -0
- package/lib/typescript/module/testing/index.d.ts +13 -0
- package/lib/typescript/module/testing/index.d.ts.map +1 -0
- package/lib/typescript/module/testing/memory-adapter/attachments.d.ts +23 -0
- package/lib/typescript/module/testing/memory-adapter/attachments.d.ts.map +1 -0
- package/lib/typescript/module/testing/memory-adapter/collection.d.ts +19 -0
- package/lib/typescript/module/testing/memory-adapter/collection.d.ts.map +1 -0
- package/lib/typescript/module/testing/memory-adapter/index.d.ts +22 -0
- package/lib/typescript/module/testing/memory-adapter/index.d.ts.map +1 -0
- package/lib/typescript/module/testing/memory-adapter/migrations.d.ts +11 -0
- package/lib/typescript/module/testing/memory-adapter/migrations.d.ts.map +1 -0
- package/lib/typescript/module/testing/memory-adapter/reset.d.ts +23 -0
- package/lib/typescript/module/testing/memory-adapter/reset.d.ts.map +1 -0
- package/lib/typescript/module/testing/memory-adapter/store.d.ts +54 -0
- package/lib/typescript/module/testing/memory-adapter/store.d.ts.map +1 -0
- package/package.json +51 -16
- package/skills/sdk-rn-local-db/SKILL.md +1 -1
- package/src/adapter/budgets.ts +1 -10
- package/src/adapter/collection.ts +38 -66
- package/src/adapter/deletion.ts +48 -0
- package/src/adapter/handle.ts +311 -0
- package/src/adapter/lifecycle.ts +10 -338
- package/src/adapter/schema-sync.ts +155 -0
- package/src/artifacts/cascade.ts +0 -14
- package/src/artifacts/store.ts +60 -10
- package/src/contract/attachment.ts +24 -3
- package/src/contract/migration.ts +4 -1
- package/src/crypto/provider.ts +7 -3
- package/src/diagnostics/dev-log.ts +5 -1
- package/src/migration/executor.ts +27 -6
- package/src/migration/ledger.ts +18 -27
- package/src/platform/fs.ts +2 -8
- package/src/platform/location.ts +0 -3
- package/src/query/budgets.ts +32 -5
- package/src/schema/validate-config.ts +3 -53
- package/src/sqlite/batch.ts +40 -51
- package/src/sqlite/connection.ts +0 -9
- package/src/sqlite/row-codec.ts +5 -2
- package/src/sqlite/statements.ts +74 -0
- package/src/testing/index.ts +2 -0
- package/src/testing/memory-adapter/attachments.ts +146 -0
- package/src/testing/memory-adapter/index.ts +13 -111
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bringing the physical tables in line with the declared schema, and skipping
|
|
3
|
+
* that work when nothing changed (LDB-07, LDB-11).
|
|
4
|
+
*
|
|
5
|
+
* Until 0.4.0 every open ran the whole set — CREATE TABLE, PRAGMA table_info,
|
|
6
|
+
* CREATE INDEX per index, for every collection — some sixty native round-trips
|
|
7
|
+
* for ten collections, on the startup path. The applied schema is now recorded
|
|
8
|
+
* in `_meta`; an open whose declaration matches it runs no DDL at all.
|
|
9
|
+
*/
|
|
10
|
+
import type { DatabaseConfig } from '../contract/config';
|
|
11
|
+
import type { CollectionSchema } from '../contract/schema';
|
|
12
|
+
import { ensureAttachmentTable } from '../artifacts/store';
|
|
13
|
+
import type { Connection } from '../sqlite/connection';
|
|
14
|
+
import {
|
|
15
|
+
addColumnSql,
|
|
16
|
+
createIndexSql,
|
|
17
|
+
createTableSql,
|
|
18
|
+
physicalIndexName,
|
|
19
|
+
} from '../sqlite/row-codec';
|
|
20
|
+
import { text } from '../sqlite/values';
|
|
21
|
+
|
|
22
|
+
/** Bumped whenever the DDL this package generates changes, so it is re-applied once. */
|
|
23
|
+
const DDL_VERSION = 1;
|
|
24
|
+
const FINGERPRINT_KEY = 'schema_fingerprint';
|
|
25
|
+
|
|
26
|
+
/** What was declared, and by which generation of this package's DDL. */
|
|
27
|
+
function fingerprintOf(config: DatabaseConfig): string {
|
|
28
|
+
return JSON.stringify([DDL_VERSION, config.collections]);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function appliedFingerprint(connection: Connection): Promise<string | null> {
|
|
32
|
+
try {
|
|
33
|
+
const result = await connection.execute('SELECT value FROM _meta WHERE key = ?', [
|
|
34
|
+
FINGERPRINT_KEY,
|
|
35
|
+
]);
|
|
36
|
+
const row = result.rows[0];
|
|
37
|
+
return row ? text(row.value) : null;
|
|
38
|
+
} catch {
|
|
39
|
+
// A database that has never been opened has no `_meta` yet.
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** `unique` and the column list of an index, read back from the statement SQLite stored. */
|
|
45
|
+
function definitionOf(sql: string): string {
|
|
46
|
+
const unique = /^\s*CREATE\s+UNIQUE\s/i.test(sql);
|
|
47
|
+
const columns = sql.slice(sql.lastIndexOf('(') + 1, sql.lastIndexOf(')')).replace(/["\s]/g, '');
|
|
48
|
+
return `${unique ? 'unique' : 'plain'}:${columns}`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Indexes follow their declaration (LDB-11). `CREATE INDEX IF NOT EXISTS` keyed
|
|
53
|
+
* on the name alone meant that adding `unique: true` to an existing index, or
|
|
54
|
+
* changing its fields, did nothing, and an index no longer declared stayed
|
|
55
|
+
* forever. An index whose definition changed is dropped and recreated, and one
|
|
56
|
+
* of this package's that is no longer declared is dropped. Only indexes carrying
|
|
57
|
+
* the collection's own prefix are touched.
|
|
58
|
+
*/
|
|
59
|
+
async function syncIndexes(connection: Connection, schema: CollectionSchema): Promise<void> {
|
|
60
|
+
const table = `c_${schema.name}`;
|
|
61
|
+
const existing = await connection.execute(
|
|
62
|
+
"SELECT name, sql FROM sqlite_master WHERE type = 'index' AND tbl_name = ? AND sql IS NOT NULL",
|
|
63
|
+
[table],
|
|
64
|
+
);
|
|
65
|
+
const current = new Map(existing.rows.map(row => [text(row.name), text(row.sql)]));
|
|
66
|
+
const wanted = new Map(
|
|
67
|
+
createIndexSql(schema).map(statement => {
|
|
68
|
+
const name = /INDEX IF NOT EXISTS "([^"]+)"/.exec(statement)?.[1] ?? '';
|
|
69
|
+
return [name, statement] as const;
|
|
70
|
+
}),
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
for (const index of schema.indexes ?? []) {
|
|
74
|
+
// Indexes created before 0.2.0 carry the bare declared name; they are
|
|
75
|
+
// recreated under the collection-scoped one. No row data moves.
|
|
76
|
+
if (current.has(index.name) && index.name !== physicalIndexName(schema, index.name)) {
|
|
77
|
+
await connection.execute(`DROP INDEX IF EXISTS "${index.name}"`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
for (const [name, sql] of current) {
|
|
81
|
+
const statement = wanted.get(name);
|
|
82
|
+
const ours = name.startsWith(`${table}__`);
|
|
83
|
+
if (
|
|
84
|
+
(statement === undefined && ours) ||
|
|
85
|
+
(statement && definitionOf(statement) !== definitionOf(sql))
|
|
86
|
+
) {
|
|
87
|
+
await connection.execute(`DROP INDEX IF EXISTS "${name}"`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
for (const statement of wanted.values()) {
|
|
91
|
+
await connection.execute(statement);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Adding a column rather than recreating the table is what makes declaring a
|
|
97
|
+
* new queryable field non-destructive: the payload already holds the value, so
|
|
98
|
+
* the new column is backfilled from it and no record is rewritten by hand
|
|
99
|
+
* (research.md R6).
|
|
100
|
+
*/
|
|
101
|
+
async function ensureCollection(connection: Connection, schema: CollectionSchema): Promise<void> {
|
|
102
|
+
await connection.execute(createTableSql(schema));
|
|
103
|
+
|
|
104
|
+
const info = await connection.execute(`PRAGMA table_info("c_${schema.name}")`);
|
|
105
|
+
const present = new Set(info.rows.map(row => text(row.name)));
|
|
106
|
+
|
|
107
|
+
for (const field of schema.fields ?? []) {
|
|
108
|
+
const column = `f_${field.name}`;
|
|
109
|
+
if (present.has(column)) {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
await connection.execute(addColumnSql(schema, field));
|
|
113
|
+
// The same projection a write applies (`projectValue`): an object or an
|
|
114
|
+
// array projects to NULL. A bare json_extract backfilled those as JSON
|
|
115
|
+
// text, so a filter matched old records and new ones differently (LDB-11).
|
|
116
|
+
const path = `'$."${field.name}"'`;
|
|
117
|
+
await connection.execute(
|
|
118
|
+
`UPDATE "c_${schema.name}" SET "${column}" = CASE WHEN json_type(payload, ${path}) IN ('object', 'array') THEN NULL ELSE json_extract(payload, ${path}) END`,
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
await syncIndexes(connection, schema);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface SchemaSync {
|
|
126
|
+
/** True when the stored schema already matched, so `_meta` exists and no DDL ran. */
|
|
127
|
+
readonly unchanged: boolean;
|
|
128
|
+
/** Records the declaration as applied. Call once the open has succeeded. */
|
|
129
|
+
record(): Promise<void>;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export async function syncSchema(
|
|
133
|
+
connection: Connection,
|
|
134
|
+
config: DatabaseConfig,
|
|
135
|
+
): Promise<SchemaSync> {
|
|
136
|
+
const fingerprint = fingerprintOf(config);
|
|
137
|
+
if ((await appliedFingerprint(connection)) === fingerprint) {
|
|
138
|
+
return { unchanged: true, record: async () => undefined };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
for (const schema of config.collections) {
|
|
142
|
+
await ensureCollection(connection, schema);
|
|
143
|
+
}
|
|
144
|
+
await ensureAttachmentTable(connection);
|
|
145
|
+
|
|
146
|
+
return {
|
|
147
|
+
unchanged: false,
|
|
148
|
+
async record() {
|
|
149
|
+
await connection.execute(
|
|
150
|
+
'INSERT INTO _meta (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value',
|
|
151
|
+
[FINGERPRINT_KEY, fingerprint],
|
|
152
|
+
);
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
}
|
package/src/artifacts/cascade.ts
CHANGED
|
@@ -19,7 +19,6 @@ import type { Executor } from '../sqlite/connection';
|
|
|
19
19
|
import { artifactPath } from './paths';
|
|
20
20
|
import {
|
|
21
21
|
deleteReference,
|
|
22
|
-
listReferences,
|
|
23
22
|
listReferencesFor,
|
|
24
23
|
type ArtifactContext,
|
|
25
24
|
type DeferredUnlinks,
|
|
@@ -99,16 +98,3 @@ export async function cascadeForOwner(
|
|
|
99
98
|
deferred,
|
|
100
99
|
);
|
|
101
100
|
}
|
|
102
|
-
|
|
103
|
-
/** Everything in the scope, for scope deletion. */
|
|
104
|
-
export async function cascadeAll(
|
|
105
|
-
context: ArtifactContext,
|
|
106
|
-
executor: Executor,
|
|
107
|
-
): Promise<DeletionOutcome> {
|
|
108
|
-
const references = await listReferences(executor);
|
|
109
|
-
return removeAll(
|
|
110
|
-
context,
|
|
111
|
-
executor,
|
|
112
|
-
references.map(reference => reference.id),
|
|
113
|
-
);
|
|
114
|
-
}
|
package/src/artifacts/store.ts
CHANGED
|
@@ -152,6 +152,12 @@ async function writePlaintext(path: string, content: string): Promise<void> {
|
|
|
152
152
|
await fileSystem().writeFile(path, content, 'base64');
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
+
/** Where an artifact's bytes come from: how many, and any one chunk of them. */
|
|
156
|
+
type ByteSource = {
|
|
157
|
+
size: number;
|
|
158
|
+
chunk(offset: number, length: number): Promise<Uint8Array>;
|
|
159
|
+
};
|
|
160
|
+
|
|
155
161
|
/**
|
|
156
162
|
* Encrypted write, one chunk in flight.
|
|
157
163
|
*
|
|
@@ -159,43 +165,87 @@ async function writePlaintext(path: string, content: string): Promise<void> {
|
|
|
159
165
|
* plaintext length — are all known from the input length before any
|
|
160
166
|
* encryption happens. Only the tags depend on the ciphertext, and they follow
|
|
161
167
|
* their own chunk, so the whole write is append-only and peak memory is one
|
|
162
|
-
* chunk regardless of artifact size (FR-107a).
|
|
168
|
+
* chunk regardless of artifact size when the source is a file (FR-107a).
|
|
163
169
|
*/
|
|
164
170
|
async function writeEncrypted(
|
|
165
171
|
path: string,
|
|
166
172
|
key: Uint8Array,
|
|
167
|
-
|
|
173
|
+
source: ByteSource,
|
|
168
174
|
): Promise<{ chunkSize: number; chunkCount: number }> {
|
|
169
|
-
const header = headerFor(
|
|
175
|
+
const header = headerFor(source.size, Budgets.ARTIFACT_CHUNK_BYTES);
|
|
170
176
|
await fileSystem().writeFile(path, bytesToBase64(encodeHeader(header)), 'base64');
|
|
171
177
|
|
|
172
178
|
for (let index = 0; index < header.chunkCount; index += 1) {
|
|
173
|
-
const
|
|
174
|
-
const chunk = plaintext.subarray(start, start + chunkPlaintextLength(header, index));
|
|
179
|
+
const chunk = await source.chunk(index * header.chunkSize, chunkPlaintextLength(header, index));
|
|
175
180
|
await fileSystem().appendFile(path, bytesToBase64(encryptChunk(key, index, chunk)), 'base64');
|
|
176
181
|
}
|
|
177
182
|
|
|
178
183
|
return { chunkSize: header.chunkSize, chunkCount: header.chunkCount };
|
|
179
184
|
}
|
|
180
185
|
|
|
186
|
+
function sourceFileOf(input: AttachmentInput): string | null {
|
|
187
|
+
if (typeof input.sourcePath !== 'string') {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
return input.sourcePath.startsWith('file://')
|
|
191
|
+
? input.sourcePath.slice('file://'.length)
|
|
192
|
+
: input.sourcePath;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* The input as something to read from. A base64 `content` is decoded whole,
|
|
197
|
+
* which is the cost of that form; a `sourcePath` is only measured here and
|
|
198
|
+
* read a chunk at a time, or not read by JS at all (LDB-09).
|
|
199
|
+
*/
|
|
200
|
+
async function byteSourceFor(input: AttachmentInput): Promise<ByteSource> {
|
|
201
|
+
const file = sourceFileOf(input);
|
|
202
|
+
if (file === null) {
|
|
203
|
+
if (typeof input.content !== 'string') {
|
|
204
|
+
raise(DiagnosticCodes.CONFIG_INVALID, {
|
|
205
|
+
message: 'an attachment needs content or sourcePath',
|
|
206
|
+
detail: { attachmentId: input.id },
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
const plaintext = base64ToBytes(input.content);
|
|
210
|
+
return {
|
|
211
|
+
size: plaintext.length,
|
|
212
|
+
chunk: async (offset, length) => plaintext.subarray(offset, offset + length),
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
let size: number;
|
|
216
|
+
try {
|
|
217
|
+
size = (await fileSystem().stat(file)).size;
|
|
218
|
+
} catch (error) {
|
|
219
|
+
raiseNative(error, { operation: 'attachment' });
|
|
220
|
+
}
|
|
221
|
+
return {
|
|
222
|
+
size,
|
|
223
|
+
chunk: async (offset, length) =>
|
|
224
|
+
base64ToBytes(await fileSystem().read(file, length, offset, 'base64')),
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
|
|
181
228
|
export async function writeArtifact(
|
|
182
229
|
context: ArtifactContext,
|
|
183
230
|
input: AttachmentInput,
|
|
184
231
|
): Promise<AttachmentReference> {
|
|
185
232
|
throwIfFaulted('attachmentWrite');
|
|
186
|
-
const
|
|
187
|
-
assertArtifactWithinBudget(input.id,
|
|
233
|
+
const source = await byteSourceFor(input);
|
|
234
|
+
assertArtifactWithinBudget(input.id, source.size);
|
|
188
235
|
|
|
189
236
|
const path = artifactPath(context.layout, context.scopeKey, input.id);
|
|
190
237
|
const key = context.artifactKey(input.id);
|
|
238
|
+
const file = sourceFileOf(input);
|
|
191
239
|
|
|
192
240
|
let chunking: { chunkSize: number; chunkCount: number } | undefined;
|
|
193
241
|
try {
|
|
194
242
|
await fileSystem().mkdir(artifactsDirectory(context.layout, context.scopeKey));
|
|
195
243
|
if (key) {
|
|
196
|
-
chunking = await writeEncrypted(path, key,
|
|
244
|
+
chunking = await writeEncrypted(path, key, source);
|
|
245
|
+
} else if (file !== null) {
|
|
246
|
+
await fileSystem().copyFile(file, path);
|
|
197
247
|
} else {
|
|
198
|
-
await writePlaintext(path, input.content);
|
|
248
|
+
await writePlaintext(path, input.content as string);
|
|
199
249
|
}
|
|
200
250
|
} catch (error) {
|
|
201
251
|
// A partial file with no reference is an orphan reconciliation can
|
|
@@ -207,7 +257,7 @@ export async function writeArtifact(
|
|
|
207
257
|
const reference: AttachmentReference = {
|
|
208
258
|
id: input.id,
|
|
209
259
|
contentType: input.contentType,
|
|
210
|
-
size:
|
|
260
|
+
size: source.size,
|
|
211
261
|
createdAt: context.now(),
|
|
212
262
|
};
|
|
213
263
|
if (input.owner) {
|
|
@@ -11,15 +11,36 @@ export type AttachmentOwner = {
|
|
|
11
11
|
id: string;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
type AttachmentDescription = {
|
|
15
15
|
id: string;
|
|
16
16
|
/** Absent means the attachment belongs to the scope rather than a record. */
|
|
17
17
|
owner?: AttachmentOwner | undefined;
|
|
18
18
|
contentType: string;
|
|
19
|
-
/** Base64 content. Written incrementally; never held whole when encrypted. */
|
|
20
|
-
content: string;
|
|
21
19
|
};
|
|
22
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Where the bytes come from. Exactly one of the two.
|
|
23
|
+
*
|
|
24
|
+
* `sourcePath` is the one to use for anything large — a photo, a recording.
|
|
25
|
+
* The file is copied (or, when encrypted, read and encrypted 256 KB at a
|
|
26
|
+
* time), so memory does not grow with its size. `content` holds the whole
|
|
27
|
+
* payload in JS as base64 and is decoded in one piece: fine for a thumbnail,
|
|
28
|
+
* several times the file's size in memory for a video.
|
|
29
|
+
*/
|
|
30
|
+
export type AttachmentInput = AttachmentDescription &
|
|
31
|
+
(
|
|
32
|
+
| {
|
|
33
|
+
/** The complete content, base64. Held and decoded whole. */
|
|
34
|
+
content: string;
|
|
35
|
+
sourcePath?: undefined;
|
|
36
|
+
}
|
|
37
|
+
| {
|
|
38
|
+
/** Absolute path of a file the app can read. A `file://` prefix is accepted. */
|
|
39
|
+
sourcePath: string;
|
|
40
|
+
content?: undefined;
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
|
|
23
44
|
export type AttachmentReference = {
|
|
24
45
|
id: string;
|
|
25
46
|
owner?: AttachmentOwner | undefined;
|
|
@@ -10,9 +10,12 @@ import type { Transaction } from './transaction';
|
|
|
10
10
|
/** Low-level escape hatch for schema work a migration needs. */
|
|
11
11
|
// Attachments are not part of a migration: a migration reshapes records, and
|
|
12
12
|
// files written inside one would survive its rollback with nothing to own them.
|
|
13
|
+
/** A value SQLite can bind. */
|
|
14
|
+
export type SqlParameter = string | number | boolean | null;
|
|
15
|
+
|
|
13
16
|
export type MigrationContext = Omit<Transaction, 'attachments'> & {
|
|
14
17
|
/** Execute a raw statement against the scope's database. */
|
|
15
|
-
execute(sql: string, params?:
|
|
18
|
+
execute(sql: string, params?: SqlParameter[]): Promise<void>;
|
|
16
19
|
};
|
|
17
20
|
|
|
18
21
|
export type Migration = {
|
package/src/crypto/provider.ts
CHANGED
|
@@ -14,6 +14,13 @@ import { lazyPeer } from '@chipmobilesdk/rn-core';
|
|
|
14
14
|
import { DiagnosticCodes } from '../contract/errors';
|
|
15
15
|
import { StorageError } from '../diagnostics/errors';
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* The two things this package asks of a cipher: AES-256-GCM for artifacts, and
|
|
19
|
+
* HKDF to derive each artifact's subkey. Hashing is not among them — the scope
|
|
20
|
+
* digest is SHA-256 in plain TypeScript (`scope/hash.ts`), because it runs on
|
|
21
|
+
* every scope resolution including the ones that never open an encrypted
|
|
22
|
+
* database, where a native module may not be installed at all (WS4-08).
|
|
23
|
+
*/
|
|
17
24
|
export type CipherModule = {
|
|
18
25
|
createCipheriv(
|
|
19
26
|
algorithm: string,
|
|
@@ -40,9 +47,6 @@ export type CipherModule = {
|
|
|
40
47
|
info: Uint8Array,
|
|
41
48
|
length: number,
|
|
42
49
|
): ArrayBuffer;
|
|
43
|
-
createHash(algorithm: string): {
|
|
44
|
-
update(data: Uint8Array | string): { digest(encoding: string): string };
|
|
45
|
-
};
|
|
46
50
|
};
|
|
47
51
|
|
|
48
52
|
/** Loaded on first use (rn-core's lazy peer); optional, so absence is a normal answer. */
|
|
@@ -73,7 +73,7 @@ export function isLogging(): boolean {
|
|
|
73
73
|
* installed and the build is a development build, so a production bundle pays
|
|
74
74
|
* nothing and emits nothing (FR-081).
|
|
75
75
|
*/
|
|
76
|
-
export function instrument<T extends
|
|
76
|
+
export function instrument<T extends object>(
|
|
77
77
|
collection: string,
|
|
78
78
|
adapter: 'sqlite' | 'memory',
|
|
79
79
|
operations: T,
|
|
@@ -85,6 +85,10 @@ export function instrument<T extends Record<string, (...args: never[]) => unknow
|
|
|
85
85
|
|
|
86
86
|
const wrapped: Record<string, unknown> = {};
|
|
87
87
|
for (const [name, operation] of Object.entries(operations)) {
|
|
88
|
+
if (typeof operation !== 'function') {
|
|
89
|
+
wrapped[name] = operation;
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
88
92
|
wrapped[name] = async (...args: never[]): Promise<unknown> => {
|
|
89
93
|
const started = Date.now();
|
|
90
94
|
try {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
import type { DatabaseConfig } from '../contract/config';
|
|
23
23
|
import { DiagnosticCodes } from '../contract/errors';
|
|
24
|
-
import type { MigrationContext } from '../contract/migration';
|
|
24
|
+
import type { MigrationContext, SqlParameter } from '../contract/migration';
|
|
25
25
|
import type { StorableRecordData } from '../contract/record';
|
|
26
26
|
import type { CollectionSchema } from '../contract/schema';
|
|
27
27
|
import type { CollectionOps } from '../contract/transaction';
|
|
@@ -29,7 +29,13 @@ import { raise } from '../diagnostics/errors';
|
|
|
29
29
|
import { throwIfFaulted } from '../diagnostics/faults';
|
|
30
30
|
import { createSqlCollection } from '../adapter/collection';
|
|
31
31
|
import type { Connection, Executor } from '../sqlite/connection';
|
|
32
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
ensureLedger,
|
|
34
|
+
FORMAT_VERSION,
|
|
35
|
+
readVersions,
|
|
36
|
+
recordAttempt,
|
|
37
|
+
writeSchemaVersion,
|
|
38
|
+
} from './ledger';
|
|
33
39
|
import { pendingMigrations, validateMigrationChain } from './validate-chain';
|
|
34
40
|
|
|
35
41
|
export type MigrationRunContext = {
|
|
@@ -44,6 +50,8 @@ export type MigrationRunContext = {
|
|
|
44
50
|
* still be holding something usable (FR-050).
|
|
45
51
|
*/
|
|
46
52
|
closeOnFailure(): Promise<void>;
|
|
53
|
+
/** The bookkeeping tables are known to exist, so creating them is skipped (LDB-07). */
|
|
54
|
+
ledgerReady?: boolean;
|
|
47
55
|
};
|
|
48
56
|
|
|
49
57
|
function migrationContextFor(context: MigrationRunContext, executor: Executor): MigrationContext {
|
|
@@ -66,8 +74,8 @@ function migrationContextFor(context: MigrationRunContext, executor: Executor):
|
|
|
66
74
|
message: 'a migration cannot abort its own transaction',
|
|
67
75
|
});
|
|
68
76
|
},
|
|
69
|
-
async execute(sql: string, params?:
|
|
70
|
-
await executor.execute(sql, params
|
|
77
|
+
async execute(sql: string, params?: SqlParameter[]): Promise<void> {
|
|
78
|
+
await executor.execute(sql, params);
|
|
71
79
|
},
|
|
72
80
|
};
|
|
73
81
|
}
|
|
@@ -75,9 +83,22 @@ function migrationContextFor(context: MigrationRunContext, executor: Executor):
|
|
|
75
83
|
export async function runMigrations(context: MigrationRunContext): Promise<number> {
|
|
76
84
|
const { config, connection } = context;
|
|
77
85
|
validateMigrationChain(config);
|
|
78
|
-
|
|
86
|
+
// Skipped when the open already found its bookkeeping tables in place.
|
|
87
|
+
if (context.ledgerReady !== true) {
|
|
88
|
+
await ensureLedger(connection);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const { schema: recorded, format } = await readVersions(connection);
|
|
79
92
|
|
|
80
|
-
|
|
93
|
+
if (format > FORMAT_VERSION) {
|
|
94
|
+
// A file laid out by a newer release of this package. Reading it with
|
|
95
|
+
// older code is the same hazard as a schema downgrade, one layer down.
|
|
96
|
+
await context.closeOnFailure();
|
|
97
|
+
raise(DiagnosticCodes.SCHEMA_DOWNGRADE, {
|
|
98
|
+
message: 'database was written by a newer version of this package',
|
|
99
|
+
detail: { recordedVersion: format, version: FORMAT_VERSION },
|
|
100
|
+
});
|
|
101
|
+
}
|
|
81
102
|
|
|
82
103
|
if (recorded > config.schemaVersion) {
|
|
83
104
|
// Opening anyway would mean newer data read by older code, which drops
|
package/src/migration/ledger.ts
CHANGED
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
* with a long half-life, sitting in a file the next crash report might carry.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import type {
|
|
15
|
+
import type { MigrationOutcome } from '../contract/migration';
|
|
16
16
|
import type { Executor } from '../sqlite/connection';
|
|
17
|
-
import {
|
|
17
|
+
import { text } from '../sqlite/values';
|
|
18
18
|
|
|
19
19
|
/** Physical layout version, independent of the app's schema version. */
|
|
20
20
|
export const FORMAT_VERSION = 1;
|
|
@@ -44,20 +44,23 @@ export async function ensureLedger(executor: Executor): Promise<void> {
|
|
|
44
44
|
);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
export async function readSchemaVersion(executor: Executor): Promise<number> {
|
|
54
|
-
const raw = await readMeta(executor, 'schema_version');
|
|
55
|
-
return raw === null ? 0 : Number(raw);
|
|
56
|
-
}
|
|
47
|
+
export type RecordedVersions = {
|
|
48
|
+
/** The app's schema version this scope has been migrated to. */
|
|
49
|
+
schema: number;
|
|
50
|
+
/** The physical layout this package wrote the file with. */
|
|
51
|
+
format: number;
|
|
52
|
+
};
|
|
57
53
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
/** Both versions in one read: every open asks for them. */
|
|
55
|
+
export async function readVersions(executor: Executor): Promise<RecordedVersions> {
|
|
56
|
+
const result = await executor.execute(
|
|
57
|
+
"SELECT key, value FROM _meta WHERE key IN ('schema_version', 'format_version')",
|
|
58
|
+
);
|
|
59
|
+
const values = new Map(result.rows.map(row => [text(row.key), Number(text(row.value))]));
|
|
60
|
+
return {
|
|
61
|
+
schema: values.get('schema_version') ?? 0,
|
|
62
|
+
format: values.get('format_version') ?? FORMAT_VERSION,
|
|
63
|
+
};
|
|
61
64
|
}
|
|
62
65
|
|
|
63
66
|
export async function writeSchemaVersion(executor: Executor, version: number): Promise<void> {
|
|
@@ -81,15 +84,3 @@ export async function recordAttempt(
|
|
|
81
84
|
[entry.version, entry.attemptedAt, entry.outcome, entry.failureCode ?? null],
|
|
82
85
|
);
|
|
83
86
|
}
|
|
84
|
-
|
|
85
|
-
export async function readLedger(executor: Executor): Promise<MigrationLedgerEntry[]> {
|
|
86
|
-
const result = await executor.execute(
|
|
87
|
-
'SELECT version, attempted_at, outcome, failure_code FROM _migrations ORDER BY version ASC',
|
|
88
|
-
);
|
|
89
|
-
return result.rows.map(row => ({
|
|
90
|
-
version: num(row.version),
|
|
91
|
-
attemptedAt: num(row.attempted_at),
|
|
92
|
-
outcome: text(row.outcome) as MigrationOutcome,
|
|
93
|
-
...(maybeText(row.failure_code) === null ? {} : { failureCode: text(row.failure_code) }),
|
|
94
|
-
}));
|
|
95
|
-
}
|
package/src/platform/fs.ts
CHANGED
|
@@ -40,6 +40,8 @@ export type FileSystem = {
|
|
|
40
40
|
readFile(path: string, encoding?: string): Promise<string>;
|
|
41
41
|
/** Chunked read at an offset — what FR-107a's flat memory bound rests on. */
|
|
42
42
|
read(path: string, length: number, position: number, encoding?: string): Promise<string>;
|
|
43
|
+
/** One native call, no bytes through JS: how an unencrypted file becomes an artifact. */
|
|
44
|
+
copyFile(from: string, into: string): Promise<void>;
|
|
43
45
|
stat(path: string): Promise<FileStat>;
|
|
44
46
|
readdir(path: string): Promise<string[]>;
|
|
45
47
|
unlink(path: string): Promise<void>;
|
|
@@ -71,14 +73,6 @@ export function fileSystem(): FileSystem {
|
|
|
71
73
|
);
|
|
72
74
|
}
|
|
73
75
|
|
|
74
|
-
export async function pathExists(path: string): Promise<boolean> {
|
|
75
|
-
try {
|
|
76
|
-
return await fileSystem().exists(path);
|
|
77
|
-
} catch {
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
76
|
/** Remove a path, treating "already gone" as success (FR-062). */
|
|
83
77
|
export async function removeIfPresent(path: string): Promise<boolean> {
|
|
84
78
|
try {
|
package/src/platform/location.ts
CHANGED
|
@@ -18,7 +18,6 @@ export const CATALOG_FILE = 'catalog.db';
|
|
|
18
18
|
export const SCOPES_DIR = 'scopes';
|
|
19
19
|
export const DATA_FILE = 'data.db';
|
|
20
20
|
export const ARTIFACTS_DIR = 'artifacts';
|
|
21
|
-
export const MARKER_FILE = '.localdb-marker';
|
|
22
21
|
|
|
23
22
|
/** Normalize separators and collapse redundant segments. No `..` survives. */
|
|
24
23
|
export function normalizePath(path: string): string {
|
|
@@ -46,7 +45,6 @@ export type StorageLayout = {
|
|
|
46
45
|
scopeDataPath(scopeKey: string): string;
|
|
47
46
|
scopeArtifactsPath(scopeKey: string): string;
|
|
48
47
|
artifactPath(scopeKey: string, attachmentId: string): string;
|
|
49
|
-
markerPath: string;
|
|
50
48
|
};
|
|
51
49
|
|
|
52
50
|
const SCOPE_KEY = /^[0-9a-f]{64}$/;
|
|
@@ -93,7 +91,6 @@ export function createLayout(documentDirectory: string, databaseName: string): S
|
|
|
93
91
|
return {
|
|
94
92
|
root,
|
|
95
93
|
catalogPath: `${root}/${CATALOG_FILE}`,
|
|
96
|
-
markerPath: `${root}/${MARKER_FILE}`,
|
|
97
94
|
scopePath,
|
|
98
95
|
scopeDataPath: scopeKey => `${scopePath(scopeKey)}/${DATA_FILE}`,
|
|
99
96
|
scopeArtifactsPath: scopeKey => `${scopePath(scopeKey)}/${ARTIFACTS_DIR}`,
|
package/src/query/budgets.ts
CHANGED
|
@@ -10,16 +10,42 @@ import { Budgets } from '../contract/config';
|
|
|
10
10
|
import { DiagnosticCodes } from '../contract/errors';
|
|
11
11
|
import type { StorableRecordData } from '../contract/record';
|
|
12
12
|
import { raise } from '../diagnostics/errors';
|
|
13
|
-
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* UTF-8 length of a string, counted rather than encoded: measuring a 256 KB
|
|
16
|
+
* record used to allocate a 256 KB byte array just to read its length.
|
|
17
|
+
*/
|
|
18
|
+
export function utf8Length(value: string): number {
|
|
19
|
+
let bytes = 0;
|
|
20
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
21
|
+
const unit = value.charCodeAt(index);
|
|
22
|
+
if (unit < 0x80) {
|
|
23
|
+
bytes += 1;
|
|
24
|
+
} else if (unit < 0x800) {
|
|
25
|
+
bytes += 2;
|
|
26
|
+
} else if (unit >= 0xd800 && unit <= 0xdbff && index + 1 < value.length) {
|
|
27
|
+
// A surrogate pair is one four-byte code point.
|
|
28
|
+
bytes += 4;
|
|
29
|
+
index += 1;
|
|
30
|
+
} else {
|
|
31
|
+
bytes += 3;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return bytes;
|
|
35
|
+
}
|
|
14
36
|
|
|
15
37
|
/** UTF-8 byte length of the serialized payload — what actually hits disk. */
|
|
16
38
|
export function serializedSize(data: StorableRecordData): number {
|
|
17
|
-
|
|
18
|
-
return utf8Bytes(json).length;
|
|
39
|
+
return utf8Length(JSON.stringify(data ?? {}));
|
|
19
40
|
}
|
|
20
41
|
|
|
21
|
-
|
|
22
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Checks the size budget and returns the serialized payload, so the write that
|
|
44
|
+
* follows stores this string instead of serializing the record a second time.
|
|
45
|
+
*/
|
|
46
|
+
export function assertRecordWithinBudget(collection: string, data: StorableRecordData): string {
|
|
47
|
+
const payload = JSON.stringify(data ?? {});
|
|
48
|
+
const size = utf8Length(payload);
|
|
23
49
|
if (size > Budgets.MAX_RECORD_BYTES) {
|
|
24
50
|
// Truncating would be silent data loss; failing opaquely would leave
|
|
25
51
|
// the consumer guessing. The size and the limit are both safe to
|
|
@@ -29,6 +55,7 @@ export function assertRecordWithinBudget(collection: string, data: StorableRecor
|
|
|
29
55
|
detail: { collection, sizeBytes: size, limitBytes: Budgets.MAX_RECORD_BYTES },
|
|
30
56
|
});
|
|
31
57
|
}
|
|
58
|
+
return payload;
|
|
32
59
|
}
|
|
33
60
|
|
|
34
61
|
export function assertBatchWithinBudget(count: number): void {
|