@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,280 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Deletion, and the ordering that makes an interrupted one visible.
|
|
5
|
+
*
|
|
6
|
+
* These are module-level functions rather than handle methods because they
|
|
7
|
+
* must work whether or not a handle is open on the target (FR-059) — a
|
|
8
|
+
* sign-out that already closed the handle still has to be able to delete, and
|
|
9
|
+
* an app recovering from a crash has no handle to call a method on.
|
|
10
|
+
*
|
|
11
|
+
* The order is: **mark `deleting` first, clear the catalog row last**
|
|
12
|
+
* (FR-061, FR-063). A crash at any point in between leaves the flag set, so
|
|
13
|
+
* the next open reports a scope mid-deletion rather than presenting it as
|
|
14
|
+
* complete. Clearing the row first would be the natural way to write this and
|
|
15
|
+
* would produce exactly the failure FR-063 exists to prevent: an
|
|
16
|
+
* interruption that looks like a success, leaving a user's data on disk after
|
|
17
|
+
* they asked for it to be gone.
|
|
18
|
+
*
|
|
19
|
+
* Nothing here ever runs on its own. No expiry, no sweep, no deletion on
|
|
20
|
+
* close or on app upgrade (FR-058) — the package deletes when asked, where
|
|
21
|
+
* asked, and not otherwise.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { fileSystem, removeIfPresent } from "../platform/fs.js";
|
|
25
|
+
import { layoutFor } from "../platform/location.js";
|
|
26
|
+
import { artifactsDirectory } from "../artifacts/paths.js";
|
|
27
|
+
import { acquireKey } from "../crypto/key-provider.js";
|
|
28
|
+
import { byteOrder } from "../query/compare.js";
|
|
29
|
+
import { resolveScope } from "../scope/validate.js";
|
|
30
|
+
import { clearScope, ensureCatalog, listEntries, markDeleting, readEntry } from "../sqlite/catalog.js";
|
|
31
|
+
import { openConnection } from "../sqlite/connection.js";
|
|
32
|
+
import { num, text } from "../sqlite/values.js";
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Scopes deleted beneath a handle that is still open.
|
|
36
|
+
*
|
|
37
|
+
* FR-059a wants the handle to report `SCOPE_DELETED` rather than keep
|
|
38
|
+
* answering from a database that no longer exists — and wants the deletion to
|
|
39
|
+
* proceed rather than wait for the handle to be closed. A shared set is the
|
|
40
|
+
* whole mechanism: the deleter records, the handle checks.
|
|
41
|
+
*/
|
|
42
|
+
const invalidated = new Set();
|
|
43
|
+
function invalidationKey(name, scopeKey) {
|
|
44
|
+
return `${name}:${scopeKey}`;
|
|
45
|
+
}
|
|
46
|
+
export function markScopeInvalidated(name, scopeKey) {
|
|
47
|
+
invalidated.add(invalidationKey(name, scopeKey));
|
|
48
|
+
}
|
|
49
|
+
export function clearScopeInvalidation(name, scopeKey) {
|
|
50
|
+
invalidated.delete(invalidationKey(name, scopeKey));
|
|
51
|
+
}
|
|
52
|
+
export function isScopeInvalidated(name, scopeKey) {
|
|
53
|
+
return invalidated.has(invalidationKey(name, scopeKey));
|
|
54
|
+
}
|
|
55
|
+
export function clearAllInvalidations() {
|
|
56
|
+
invalidated.clear();
|
|
57
|
+
openHandles.clear();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Handles open on a scope, so a deletion can take their connection away
|
|
62
|
+
* (LDB-14). Marking alone left the native connection and its handle slot held
|
|
63
|
+
* until the app closed a handle it had been told was dead: eight sign-outs
|
|
64
|
+
* later every open failed, with the unlinked file still pinned by its
|
|
65
|
+
* descriptor.
|
|
66
|
+
*/
|
|
67
|
+
const openHandles = new Map();
|
|
68
|
+
|
|
69
|
+
/** Returns the function that takes the handle out of the registry again. */
|
|
70
|
+
export function registerOpenHandle(name, scopeKey, revoke) {
|
|
71
|
+
const key = invalidationKey(name, scopeKey);
|
|
72
|
+
const handles = openHandles.get(key) ?? new Set();
|
|
73
|
+
handles.add(revoke);
|
|
74
|
+
openHandles.set(key, handles);
|
|
75
|
+
return () => {
|
|
76
|
+
handles.delete(revoke);
|
|
77
|
+
if (handles.size === 0) {
|
|
78
|
+
openHandles.delete(key);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Every handle on the scope, or on any scope of the database when none is named. */
|
|
84
|
+
async function revokeHandles(name, scopeKey) {
|
|
85
|
+
const prefix = `${name}:`;
|
|
86
|
+
for (const [key, handles] of [...openHandles]) {
|
|
87
|
+
const matches = scopeKey === undefined ? key.startsWith(prefix) : key === invalidationKey(name, scopeKey);
|
|
88
|
+
if (!matches) {
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
openHandles.delete(key);
|
|
92
|
+
for (const revoke of handles) {
|
|
93
|
+
// A connection that will not close does not get to stop a deletion.
|
|
94
|
+
await revoke().catch(() => undefined);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Deleting a scope that holds nothing is success, not an error (FR-062). */
|
|
100
|
+
export function emptyOutcome(scope) {
|
|
101
|
+
return {
|
|
102
|
+
...(scope ? {
|
|
103
|
+
scopeKey: scope.key
|
|
104
|
+
} : {}),
|
|
105
|
+
removedRecords: 0,
|
|
106
|
+
removedArtifacts: [],
|
|
107
|
+
orphanedReferences: [],
|
|
108
|
+
failedRemovals: []
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* How many records the scope held, best effort.
|
|
114
|
+
*
|
|
115
|
+
* Best effort because an encrypted scope whose caller supplied no key cannot
|
|
116
|
+
* be opened to be counted — and refusing to delete it on that basis would be
|
|
117
|
+
* the worst possible answer to a deletion request. The files come off disk
|
|
118
|
+
* either way; only the number in the report is unavailable.
|
|
119
|
+
*/
|
|
120
|
+
async function countRecords(layout, scopeKey, encryptionKey) {
|
|
121
|
+
let connection = null;
|
|
122
|
+
try {
|
|
123
|
+
connection = await openConnection({
|
|
124
|
+
path: layout.scopeDataPath(scopeKey),
|
|
125
|
+
...(encryptionKey ? {
|
|
126
|
+
encryptionKey
|
|
127
|
+
} : {})
|
|
128
|
+
});
|
|
129
|
+
const tables = await connection.execute("SELECT name FROM sqlite_master WHERE type = 'table' AND name LIKE 'c!_%' ESCAPE '!'");
|
|
130
|
+
let total = 0;
|
|
131
|
+
for (const row of tables.rows) {
|
|
132
|
+
const table = text(row.name);
|
|
133
|
+
const counted = await connection.execute(`SELECT count(*) AS total FROM "${table}"`);
|
|
134
|
+
total += num(counted.rows[0]?.total ?? 0);
|
|
135
|
+
}
|
|
136
|
+
return total;
|
|
137
|
+
} catch {
|
|
138
|
+
// Unknown, not zero: a report that said "0 records" about a scope it
|
|
139
|
+
// could not open would understate what was deleted.
|
|
140
|
+
return undefined;
|
|
141
|
+
} finally {
|
|
142
|
+
await connection?.close();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
async function artifactIdsOnDisk(layout, scopeKey) {
|
|
146
|
+
try {
|
|
147
|
+
return (await fileSystem().readdir(artifactsDirectory(layout, scopeKey))).sort(byteOrder);
|
|
148
|
+
} catch {
|
|
149
|
+
return [];
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* The one implementation behind `deleteScopeData` and `resetScope`.
|
|
155
|
+
*
|
|
156
|
+
* They do the same thing to disk and mean entirely different things to the
|
|
157
|
+
* caller: one is a lifecycle operation an app performs on request, the other
|
|
158
|
+
* is an admission that a database is broken and is being discarded to recover
|
|
159
|
+
* from it (FR-057a). Keeping them as two exported names with two docstrings
|
|
160
|
+
* is what stops the destructive one from being reached by accident — there is
|
|
161
|
+
* no path from `openDatabase` to either.
|
|
162
|
+
*/
|
|
163
|
+
async function removeScope(config) {
|
|
164
|
+
const scope = resolveScope(config.scope);
|
|
165
|
+
const layout = layoutFor(config.name);
|
|
166
|
+
const catalog = await openConnection({
|
|
167
|
+
path: layout.catalogPath
|
|
168
|
+
});
|
|
169
|
+
try {
|
|
170
|
+
await ensureCatalog(catalog);
|
|
171
|
+
const entry = await readEntry(catalog, scope.key);
|
|
172
|
+
|
|
173
|
+
// Mark first. Everything after this point is recoverable-in-principle;
|
|
174
|
+
// this flag is what makes an interruption visible rather than silent.
|
|
175
|
+
if (entry) {
|
|
176
|
+
await markDeleting(catalog, scope.key);
|
|
177
|
+
}
|
|
178
|
+
markScopeInvalidated(config.name, scope.key);
|
|
179
|
+
// Before the files go: a connection still open on them pins them.
|
|
180
|
+
await revokeHandles(config.name, scope.key);
|
|
181
|
+
const removedArtifacts = await artifactIdsOnDisk(layout, scope.key);
|
|
182
|
+
|
|
183
|
+
// The key is needed to count what is being removed, not to remove it,
|
|
184
|
+
// so a key provider that fails — or a key already destroyed for this
|
|
185
|
+
// identity, which FR-104 encourages — costs the count, never the
|
|
186
|
+
// deletion. Until 0.2.0 it failed the whole call after the scope was
|
|
187
|
+
// already marked, leaving it stuck in `deleting`.
|
|
188
|
+
let keyHandle = null;
|
|
189
|
+
if (config.encryption?.enabled) {
|
|
190
|
+
try {
|
|
191
|
+
keyHandle = await acquireKey(config.encryption, scope);
|
|
192
|
+
} catch {
|
|
193
|
+
keyHandle = null;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
let counted;
|
|
197
|
+
try {
|
|
198
|
+
counted = config.encryption?.enabled && keyHandle === null ? undefined : await countRecords(layout, scope.key, keyHandle?.value());
|
|
199
|
+
} finally {
|
|
200
|
+
keyHandle?.release();
|
|
201
|
+
}
|
|
202
|
+
const failedRemovals = [];
|
|
203
|
+
if (!(await removeIfPresent(layout.scopePath(scope.key))) && entry) {
|
|
204
|
+
// The directory was there and would not go. Reporting it is the
|
|
205
|
+
// point: an app that told the user "deleted" would be wrong.
|
|
206
|
+
const stillThere = await fileSystem().exists(layout.scopePath(scope.key)).catch(() => false);
|
|
207
|
+
if (stillThere) {
|
|
208
|
+
failedRemovals.push(scope.key);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (failedRemovals.length === 0) {
|
|
212
|
+
// Cleared last, on purpose.
|
|
213
|
+
await clearScope(catalog, scope.key);
|
|
214
|
+
}
|
|
215
|
+
return {
|
|
216
|
+
scopeKey: scope.key,
|
|
217
|
+
removedRecords: counted ?? 0,
|
|
218
|
+
...(counted === undefined ? {
|
|
219
|
+
recordCountUnavailable: true
|
|
220
|
+
} : {}),
|
|
221
|
+
removedArtifacts,
|
|
222
|
+
orphanedReferences: [],
|
|
223
|
+
failedRemovals
|
|
224
|
+
};
|
|
225
|
+
} finally {
|
|
226
|
+
await catalog.close();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Remove one scope's data. Every collection in that scope, and nothing
|
|
232
|
+
* outside it (FR-059, SC-012).
|
|
233
|
+
*/
|
|
234
|
+
export function deleteScopeData(config) {
|
|
235
|
+
return removeScope(config);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Discard one scope and leave it ready for a clean first-run migration
|
|
240
|
+
* (FR-057a).
|
|
241
|
+
*
|
|
242
|
+
* Destructive, separately named, and never reachable from `openDatabase`. An
|
|
243
|
+
* automatic fallback here would turn a bad migration shipped to production
|
|
244
|
+
* into silent data loss for every user who launched the app.
|
|
245
|
+
*/
|
|
246
|
+
export function resetScope(config) {
|
|
247
|
+
return removeScope(config);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** Remove the whole database directory: catalog, every scope, every artifact. */
|
|
251
|
+
export async function deleteDatabase(config) {
|
|
252
|
+
const layout = layoutFor(config.name);
|
|
253
|
+
let scopeKeys = [];
|
|
254
|
+
try {
|
|
255
|
+
const catalog = await openConnection({
|
|
256
|
+
path: layout.catalogPath
|
|
257
|
+
});
|
|
258
|
+
try {
|
|
259
|
+
await ensureCatalog(catalog);
|
|
260
|
+
scopeKeys = (await listEntries(catalog)).map(entry => entry.scopeKey);
|
|
261
|
+
} finally {
|
|
262
|
+
await catalog.close();
|
|
263
|
+
}
|
|
264
|
+
} catch {
|
|
265
|
+
// No catalog means nothing was ever registered here. The directory
|
|
266
|
+
// removal below is still the right thing to attempt.
|
|
267
|
+
}
|
|
268
|
+
for (const scopeKey of scopeKeys) {
|
|
269
|
+
markScopeInvalidated(config.name, scopeKey);
|
|
270
|
+
}
|
|
271
|
+
await revokeHandles(config.name);
|
|
272
|
+
const removed = await removeIfPresent(layout.root);
|
|
273
|
+
return {
|
|
274
|
+
removedRecords: 0,
|
|
275
|
+
removedArtifacts: [],
|
|
276
|
+
orphanedReferences: [],
|
|
277
|
+
failedRemovals: removed || scopeKeys.length === 0 ? [] : scopeKeys
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
//# sourceMappingURL=deletion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["fileSystem","removeIfPresent","layoutFor","artifactsDirectory","acquireKey","byteOrder","resolveScope","clearScope","ensureCatalog","listEntries","markDeleting","readEntry","openConnection","num","text","invalidated","Set","invalidationKey","name","scopeKey","markScopeInvalidated","add","clearScopeInvalidation","delete","isScopeInvalidated","has","clearAllInvalidations","clear","openHandles","Map","registerOpenHandle","revoke","key","handles","get","set","size","revokeHandles","prefix","matches","undefined","startsWith","catch","emptyOutcome","scope","removedRecords","removedArtifacts","orphanedReferences","failedRemovals","countRecords","layout","encryptionKey","connection","path","scopeDataPath","tables","execute","total","row","rows","table","counted","close","artifactIdsOnDisk","readdir","sort","removeScope","config","catalog","catalogPath","entry","keyHandle","encryption","enabled","value","release","scopePath","stillThere","exists","push","length","recordCountUnavailable","deleteScopeData","resetScope","deleteDatabase","scopeKeys","map","removed","root"],"sourceRoot":"../../../src","sources":["adapter/deletion.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,SAASA,UAAU,EAAEC,eAAe,QAAQ,mBAAgB;AAC5D,SAASC,SAAS,QAA4B,yBAAsB;AACpE,SAASC,kBAAkB,QAAQ,uBAAoB;AACvD,SAASC,UAAU,QAAQ,2BAAwB;AACnD,SAASC,SAAS,QAAQ,qBAAkB;AAC5C,SAASC,YAAY,QAAQ,sBAAmB;AAChD,SAASC,UAAU,EAAEC,aAAa,EAAEC,WAAW,EAAEC,YAAY,EAAEC,SAAS,QAAQ,sBAAmB;AACnG,SAASC,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OAAO,GAAG,MAAMxD,cAAc,CAAC;MAAEyC,IAAI,EAAEH,MAAM,CAACmB;IAAY,CAAC,CAAC;IAClE,IAAI;MACH,MAAM7D,aAAa,CAAC4D,OAAO,CAAC;MAC5BiB,SAAS,GAAG,CAAC,MAAM5E,WAAW,CAAC2D,OAAO,CAAC,EAAEkB,GAAG,CAAChB,KAAK,IAAIA,KAAK,CAACnD,QAAQ,CAAC;IACtE,CAAC,SAAS;MACT,MAAMiD,OAAO,CAACN,KAAK,CAAC,CAAC;IACtB;EACD,CAAC,CAAC,MAAM;IACP;IACA;EAAA;EAGD,KAAK,MAAM3C,QAAQ,IAAIkE,SAAS,EAAE;IACjCjE,oBAAoB,CAAC+C,MAAM,CAACjD,IAAI,EAAEC,QAAQ,CAAC;EAC5C;EACA,MAAMkB,aAAa,CAAC8B,MAAM,CAACjD,IAAI,CAAC;EAEhC,MAAMqE,OAAO,GAAG,MAAMtF,eAAe,CAACiD,MAAM,CAACsC,IAAI,CAAC;EAClD,OAAO;IACN3C,cAAc,EAAE,CAAC;IACjBC,gBAAgB,EAAE,EAAE;IACpBC,kBAAkB,EAAE,EAAE;IACtBC,cAAc,EAAEuC,OAAO,IAAIF,SAAS,CAACL,MAAM,KAAK,CAAC,GAAG,EAAE,GAAGK;EAC1D,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The handle an open returns: collections, transactions, batches and
|
|
5
|
+
* attachments over one connection, bound to one scope.
|
|
6
|
+
*
|
|
7
|
+
* Scope is bound here and nowhere else. The handle carries its scope key and
|
|
8
|
+
* no operation on it accepts a scope argument, so there is no `switchScope`
|
|
9
|
+
* to misuse and no read that could address another scope (FR-008a, FR-015).
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { DiagnosticCodes } from "../contract/errors.js";
|
|
13
|
+
import { artifactAvailability } from "../artifacts/availability.js";
|
|
14
|
+
import { cascadeForOwner, unlinkArtifact } from "../artifacts/cascade.js";
|
|
15
|
+
import { reconcileArtifacts } from "../artifacts/reconcile.js";
|
|
16
|
+
import { listReferencesFor, readArtifact, removeArtifact, writeArtifact } from "../artifacts/store.js";
|
|
17
|
+
import { deriveArtifactKey } from "../crypto/derive.js";
|
|
18
|
+
import { raise } from "../diagnostics/errors.js";
|
|
19
|
+
import { instrument } from "../diagnostics/dev-log.js";
|
|
20
|
+
import { throwIfFaulted } from "../diagnostics/faults.js";
|
|
21
|
+
import { withStableTiebreaker } from "../query/sort.js";
|
|
22
|
+
import { runBatch } from "../sqlite/batch.js";
|
|
23
|
+
import { explainQuery } from "../sqlite/index-coverage.js";
|
|
24
|
+
import { runInTransaction } from "../sqlite/transactions.js";
|
|
25
|
+
import { releaseHandleSlot } from "./budgets.js";
|
|
26
|
+
import { createSqlCollection } from "./collection.js";
|
|
27
|
+
import { isScopeInvalidated, registerOpenHandle } from "./deletion.js";
|
|
28
|
+
import { createTransaction } from "./transaction.js";
|
|
29
|
+
export function schemaFor(schemas, name) {
|
|
30
|
+
const schema = schemas.get(name);
|
|
31
|
+
if (!schema) {
|
|
32
|
+
raise(DiagnosticCodes.CONFIG_INVALID, {
|
|
33
|
+
message: 'collection is not declared',
|
|
34
|
+
detail: {
|
|
35
|
+
collection: name
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return schema;
|
|
40
|
+
}
|
|
41
|
+
export function buildHandle(context) {
|
|
42
|
+
const {
|
|
43
|
+
config,
|
|
44
|
+
connection,
|
|
45
|
+
layout,
|
|
46
|
+
scope,
|
|
47
|
+
schemas
|
|
48
|
+
} = context;
|
|
49
|
+
let closed = false;
|
|
50
|
+
// Set when a deletion took the connection away rather than the app closing it.
|
|
51
|
+
let revoked = false;
|
|
52
|
+
const releaseNative = async () => {
|
|
53
|
+
// The key goes first: a close that fails at the filesystem must not
|
|
54
|
+
// leave key material alive in a handle nobody can use (FR-098).
|
|
55
|
+
context.key?.release();
|
|
56
|
+
await connection.close();
|
|
57
|
+
releaseHandleSlot();
|
|
58
|
+
};
|
|
59
|
+
const unregister = registerOpenHandle(config.name, scope.key, async () => {
|
|
60
|
+
if (closed) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
closed = true;
|
|
64
|
+
revoked = true;
|
|
65
|
+
await releaseNative();
|
|
66
|
+
});
|
|
67
|
+
const assertUsable = () => {
|
|
68
|
+
if (closed && !revoked) {
|
|
69
|
+
raise(DiagnosticCodes.CLOSED_HANDLE, {
|
|
70
|
+
message: 'handle is closed'
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
if (revoked || isScopeInvalidated(config.name, scope.key)) {
|
|
74
|
+
// The deletion did not wait for this handle, and this handle does
|
|
75
|
+
// not get to keep answering from data that is gone (FR-059a).
|
|
76
|
+
raise(DiagnosticCodes.SCOPE_DELETED, {
|
|
77
|
+
message: 'scope was deleted beneath this handle',
|
|
78
|
+
detail: {
|
|
79
|
+
scopeKey: scope.key
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// Everything below is built against an explicit executor: the connection for
|
|
86
|
+
// the handle, the transaction's own executor inside `transaction`. Nothing
|
|
87
|
+
// infers which one from the connection's state, which is how a write from
|
|
88
|
+
// outside used to be swallowed by an in-flight transaction (LDB-01).
|
|
89
|
+
const artifactsOn = executor => ({
|
|
90
|
+
executor: () => executor,
|
|
91
|
+
layout,
|
|
92
|
+
scopeKey: scope.key,
|
|
93
|
+
artifactKey: attachmentId => context.key ? deriveArtifactKey(context.key.value(), scope.key, attachmentId) : null,
|
|
94
|
+
now: context.now
|
|
95
|
+
});
|
|
96
|
+
const rawCollection = (name, executor) => {
|
|
97
|
+
assertUsable();
|
|
98
|
+
return instrument(name, 'sqlite', createSqlCollection({
|
|
99
|
+
executor: () => executor,
|
|
100
|
+
schema: schemaFor(schemas, name),
|
|
101
|
+
now: context.now,
|
|
102
|
+
assertUsable
|
|
103
|
+
}));
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Record deletion optionally takes its artifacts with it (FR-070).
|
|
108
|
+
*
|
|
109
|
+
* Off unless the app asks: a package that deleted a user's files as a side
|
|
110
|
+
* effect of a record delete would be making a decision that is not its to
|
|
111
|
+
* make. The outcome carries what was removed and what could not be.
|
|
112
|
+
*/
|
|
113
|
+
const collectionOn = (name, executor, deferred) => {
|
|
114
|
+
const ops = rawCollection(name, executor);
|
|
115
|
+
if (config.cascadeAttachments !== true) {
|
|
116
|
+
return ops;
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
...ops,
|
|
120
|
+
async delete(id) {
|
|
121
|
+
const outcome = await ops.delete(id);
|
|
122
|
+
const cascade = await cascadeForOwner(artifactsOn(executor), executor, {
|
|
123
|
+
collection: name,
|
|
124
|
+
id
|
|
125
|
+
}, deferred);
|
|
126
|
+
return {
|
|
127
|
+
...outcome,
|
|
128
|
+
cascade
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
const attachmentsOn = (executor, deferred) => {
|
|
134
|
+
const artifacts = artifactsOn(executor);
|
|
135
|
+
return {
|
|
136
|
+
write(input) {
|
|
137
|
+
assertUsable();
|
|
138
|
+
return writeArtifact(artifacts, input);
|
|
139
|
+
},
|
|
140
|
+
read(id, range) {
|
|
141
|
+
assertUsable();
|
|
142
|
+
return readArtifact(artifacts, id, range);
|
|
143
|
+
},
|
|
144
|
+
availability(id) {
|
|
145
|
+
assertUsable();
|
|
146
|
+
return artifactAvailability(artifacts, executor, id);
|
|
147
|
+
},
|
|
148
|
+
remove(id) {
|
|
149
|
+
assertUsable();
|
|
150
|
+
return removeArtifact(artifacts, id, deferred);
|
|
151
|
+
},
|
|
152
|
+
listFor(owner) {
|
|
153
|
+
assertUsable();
|
|
154
|
+
return listReferencesFor(executor, owner);
|
|
155
|
+
},
|
|
156
|
+
reconcile(options) {
|
|
157
|
+
assertUsable();
|
|
158
|
+
return reconcileArtifacts(artifacts, executor, options);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
const collectionFor = name => collectionOn(name, connection);
|
|
163
|
+
const attachments = attachmentsOn(connection);
|
|
164
|
+
const handle = {
|
|
165
|
+
scopeKey: scope.key,
|
|
166
|
+
schemaVersion: context.schemaVersion,
|
|
167
|
+
backupPosture: context.posture,
|
|
168
|
+
isEncrypted: context.key !== null,
|
|
169
|
+
collection: collectionFor,
|
|
170
|
+
async transaction(fn) {
|
|
171
|
+
assertUsable();
|
|
172
|
+
const pendingUnlinks = [];
|
|
173
|
+
const deferred = {
|
|
174
|
+
add: path => pendingUnlinks.push(path)
|
|
175
|
+
};
|
|
176
|
+
let aborted = false;
|
|
177
|
+
const result = await runInTransaction(connection, async tx => {
|
|
178
|
+
const managed = createTransaction({
|
|
179
|
+
collection: name => collectionOn(name, tx, deferred),
|
|
180
|
+
attachments: () => attachmentsOn(tx, deferred),
|
|
181
|
+
rollback: async () => {
|
|
182
|
+
aborted = true;
|
|
183
|
+
await tx.rollback();
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
const value = await fn(managed.transaction);
|
|
187
|
+
if (!managed.isSettled()) {
|
|
188
|
+
throwIfFaulted('commit');
|
|
189
|
+
}
|
|
190
|
+
managed.settle();
|
|
191
|
+
return value;
|
|
192
|
+
});
|
|
193
|
+
// Committed (a thrown body never gets here). Only now are files whose
|
|
194
|
+
// references the transaction deleted safe to remove; one that cannot be
|
|
195
|
+
// removed stays on disk as an orphan reconciliation reports.
|
|
196
|
+
if (!aborted) {
|
|
197
|
+
for (const path of pendingUnlinks) {
|
|
198
|
+
await unlinkArtifact(path);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return result;
|
|
202
|
+
},
|
|
203
|
+
async batch(operations) {
|
|
204
|
+
assertUsable();
|
|
205
|
+
const outcome = await runBatch({
|
|
206
|
+
connection,
|
|
207
|
+
schemaFor: name => schemaFor(schemas, name),
|
|
208
|
+
now: context.now
|
|
209
|
+
}, operations);
|
|
210
|
+
if (config.cascadeAttachments !== true) {
|
|
211
|
+
return outcome;
|
|
212
|
+
}
|
|
213
|
+
// The batch has committed, so its hard deletes cascade exactly as a
|
|
214
|
+
// collection delete does. Skipping them left every attachment of a
|
|
215
|
+
// batch-deleted record behind as an orphan.
|
|
216
|
+
const artifacts = artifactsOn(connection);
|
|
217
|
+
const outcomes = [];
|
|
218
|
+
for (const [index, operation] of operations.entries()) {
|
|
219
|
+
const written = outcome.outcomes[index];
|
|
220
|
+
if (operation.type !== 'delete') {
|
|
221
|
+
outcomes.push(written);
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
const cascade = await cascadeForOwner(artifacts, connection, {
|
|
225
|
+
collection: operation.collection,
|
|
226
|
+
id: operation.id
|
|
227
|
+
});
|
|
228
|
+
outcomes.push({
|
|
229
|
+
...written,
|
|
230
|
+
cascade
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
return {
|
|
234
|
+
...outcome,
|
|
235
|
+
outcomes
|
|
236
|
+
};
|
|
237
|
+
},
|
|
238
|
+
attachments: () => attachments,
|
|
239
|
+
explain(collection, query) {
|
|
240
|
+
assertUsable();
|
|
241
|
+
return explainQuery(connection, schemaFor(schemas, collection), query, withStableTiebreaker(query?.sort));
|
|
242
|
+
},
|
|
243
|
+
async close() {
|
|
244
|
+
if (closed) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
closed = true;
|
|
248
|
+
unregister();
|
|
249
|
+
await releaseNative();
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
return handle;
|
|
253
|
+
}
|
|
254
|
+
//# sourceMappingURL=handle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DiagnosticCodes","artifactAvailability","cascadeForOwner","unlinkArtifact","reconcileArtifacts","listReferencesFor","readArtifact","removeArtifact","writeArtifact","deriveArtifactKey","raise","instrument","throwIfFaulted","withStableTiebreaker","runBatch","explainQuery","runInTransaction","releaseHandleSlot","createSqlCollection","isScopeInvalidated","registerOpenHandle","createTransaction","schemaFor","schemas","name","schema","get","CONFIG_INVALID","message","detail","collection","buildHandle","context","config","connection","layout","scope","closed","revoked","releaseNative","key","release","close","unregister","assertUsable","CLOSED_HANDLE","SCOPE_DELETED","scopeKey","artifactsOn","executor","artifactKey","attachmentId","value","now","rawCollection","collectionOn","deferred","ops","cascadeAttachments","delete","id","outcome","cascade","attachmentsOn","artifacts","write","input","read","range","availability","remove","listFor","owner","reconcile","options","collectionFor","attachments","handle","schemaVersion","backupPosture","posture","isEncrypted","transaction","fn","pendingUnlinks","add","path","push","aborted","result","tx","managed","rollback","isSettled","settle","batch","operations","outcomes","index","operation","entries","written","type","explain","query","sort"],"sourceRoot":"../../../src","sources":["adapter/handle.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA,SAASA,eAAe,QAAQ,uBAAoB;AAWpD,SAASC,oBAAoB,QAAQ,8BAA2B;AAChE,SAASC,eAAe,EAAEC,cAAc,QAA8B,yBAAsB;AAC5F,SAASC,kBAAkB,QAAQ,2BAAwB;AAC3D,SACCC,iBAAiB,EACjBC,YAAY,EACZC,cAAc,EACdC,aAAa,QAEP,uBAAoB;AAC3B,SAASC,iBAAiB,QAAQ,qBAAkB;AAEpD,SAASC,KAAK,QAAQ,0BAAuB;AAC7C,SAASC,UAAU,QAAQ,2BAAwB;AACnD,SAASC,cAAc,QAAQ,0BAAuB;AAEtD,SAASC,oBAAoB,QAAQ,kBAAe;AACpD,SAASC,QAAQ,QAAQ,oBAAiB;AAE1C,SAASC,YAAY,QAAQ,6BAA0B;AACvD,SAASC,gBAAgB,QAAQ,2BAAwB;AACzD,SAASC,iBAAiB,QAAQ,cAAW;AAC7C,SAASC,mBAAmB,QAAQ,iBAAc;AAClD,SAASC,kBAAkB,EAAEC,kBAAkB,QAAQ,eAA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CAAC;MACvC;MACA,OAAO;QAAE,GAAGD,OAAO;QAAEoC;MAAS,CAAC;IAChC,CAAC;IAEDrB,WAAW,EAAEA,CAAA,KAAMA,WAAW;IAE9B2B,OAAOA,CAACzE,UAAkB,EAAE0E,KAAa,EAAgC;MACxE5D,YAAY,CAAC,CAAC;MACd,OAAO7B,YAAY,CAClBmB,UAAU,EACVZ,SAAS,CAACC,OAAO,EAAEO,UAAU,CAAC,EAC9B0E,KAAK,EACL3F,oBAAoB,CAAC2F,KAAK,EAAEC,IAAI,CACjC,CAAC;IACF,CAAC;IAED,MAAM/D,KAAKA,CAAA,EAAkB;MAC5B,IAAIL,MAAM,EAAE;QACX;MACD;MACAA,MAAM,GAAG,IAAI;MACbM,UAAU,CAAC,CAAC;MACZ,MAAMJ,aAAa,CAAC,CAAC;IACtB;EACD,CAAC;EAED,OAAOsC,MAAM;AACd","ignoreList":[]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The public lifecycle functions.
|
|
5
|
+
*
|
|
6
|
+
* Scope deletion and reset are module-level rather than handle methods: they
|
|
7
|
+
* must work whether or not a handle is open on the target (FR-059), and
|
|
8
|
+
* `resetScope` in particular must never be reachable as a fallback from
|
|
9
|
+
* `openDatabase` (FR-057a).
|
|
10
|
+
*
|
|
11
|
+
* The active adapter is resolved lazily so a consuming app that only ever
|
|
12
|
+
* uses the in-memory adapter in tests never loads the native peers.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
let override = null;
|
|
16
|
+
let cached = null;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Swap the adapter. Intended for tests and for the demo app's in-memory
|
|
20
|
+
* mode; production code never calls this.
|
|
21
|
+
*/
|
|
22
|
+
export function setStorageAdapter(adapter) {
|
|
23
|
+
override = adapter;
|
|
24
|
+
}
|
|
25
|
+
function activeAdapter() {
|
|
26
|
+
if (override) {
|
|
27
|
+
return override;
|
|
28
|
+
}
|
|
29
|
+
if (!cached) {
|
|
30
|
+
// Lazy require, matching how rn-auth and rn-camera reach their native
|
|
31
|
+
// peers: importing at module scope would pull op-sqlite into every
|
|
32
|
+
// consumer, including ones that only run the in-memory adapter.
|
|
33
|
+
const {
|
|
34
|
+
createSqliteAdapter
|
|
35
|
+
} = require('../sqlite/adapter');
|
|
36
|
+
cached = createSqliteAdapter();
|
|
37
|
+
}
|
|
38
|
+
return cached;
|
|
39
|
+
}
|
|
40
|
+
export function openDatabase(config) {
|
|
41
|
+
return activeAdapter().open(config);
|
|
42
|
+
}
|
|
43
|
+
export function deleteScopeData(config) {
|
|
44
|
+
return activeAdapter().deleteScopeData(config);
|
|
45
|
+
}
|
|
46
|
+
export function deleteDatabase(config) {
|
|
47
|
+
return activeAdapter().deleteDatabase(config);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Destructive. Discards one scope's data and leaves it ready for a clean
|
|
52
|
+
* first-run migration. Named apart from `deleteScopeData` deliberately: one
|
|
53
|
+
* is a lifecycle operation, the other is an admission that a database is
|
|
54
|
+
* broken.
|
|
55
|
+
*/
|
|
56
|
+
export function resetScope(config) {
|
|
57
|
+
return activeAdapter().resetScope(config);
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["override","cached","setStorageAdapter","adapter","activeAdapter","createSqliteAdapter","require","openDatabase","config","open","deleteScopeData","deleteDatabase","resetScope"],"sourceRoot":"../../../src","sources":["adapter/index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,IAAIA,QAA+B,GAAG,IAAI;AAC1C,IAAIC,MAA6B,GAAG,IAAI;;AAExC;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAACC,OAA8B,EAAQ;EACvEH,QAAQ,GAAGG,OAAO;AACnB;AAEA,SAASC,aAAaA,CAAA,EAAmB;EACxC,IAAIJ,QAAQ,EAAE;IACb,OAAOA,QAAQ;EAChB;EACA,IAAI,CAACC,MAAM,EAAE;IACZ;IACA;IACA;IACA,MAAM;MAAEI;IAAoB,CAAC,GAAGC,OAAO,CAAC,mBAAmB,CAE1D;IACDL,MAAM,GAAGI,mBAAmB,CAAC,CAAC;EAC/B;EACA,OAAOJ,MAAM;AACd;AAEA,OAAO,SAASM,YAAYA,CAACC,MAAsB,EAA2B;EAC7E,OAAOJ,aAAa,CAAC,CAAC,CAACK,IAAI,CAACD,MAAM,CAAC;AACpC;AAEA,OAAO,SAASE,eAAeA,CAACF,MAAyB,EAA4B;EACpF,OAAOJ,aAAa,CAAC,CAAC,CAACM,eAAe,CAACF,MAAM,CAAC;AAC/C;AAEA,OAAO,SAASG,cAAcA,CAACH,MAA4B,EAA4B;EACtF,OAAOJ,aAAa,CAAC,CAAC,CAACO,cAAc,CAACH,MAAM,CAAC;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,UAAUA,CAACJ,MAAyB,EAA4B;EAC/E,OAAOJ,aAAa,CAAC,CAAC,CAACQ,UAAU,CAACJ,MAAM,CAAC;AAC1C","ignoreList":[]}
|