@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,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.runMigrations = runMigrations;
|
|
7
|
+
var _errors = require("../contract/errors.js");
|
|
8
|
+
var _errors2 = require("../diagnostics/errors.js");
|
|
9
|
+
var _faults = require("../diagnostics/faults.js");
|
|
10
|
+
var _collection = require("../adapter/collection.js");
|
|
11
|
+
var _ledger = require("./ledger.js");
|
|
12
|
+
var _validateChain = require("./validate-chain.js");
|
|
13
|
+
/**
|
|
14
|
+
* The migration executor.
|
|
15
|
+
*
|
|
16
|
+
* Four rules, each of which exists because the alternative loses data:
|
|
17
|
+
*
|
|
18
|
+
* - **Ascending, and pending only.** A migration whose version is at or below
|
|
19
|
+
* the recorded one has already run against this scope (FR-047, FR-049).
|
|
20
|
+
* - **One transaction per migration.** A failure unwinds that migration and
|
|
21
|
+
* nothing else, so the recorded version and the data always agree.
|
|
22
|
+
* - **The recorded version moves only on success**, inside the same
|
|
23
|
+
* transaction as the migration's own writes. Writing it separately would
|
|
24
|
+
* leave a window where a crash records a migration that did not happen.
|
|
25
|
+
* - **A failure returns no handle** (FR-050). Half-migrated data behind a
|
|
26
|
+
* working handle is the failure this whole design exists to prevent, and it
|
|
27
|
+
* is worse than being unable to open at all: the app writes to it.
|
|
28
|
+
*
|
|
29
|
+
* A retry starts from the same version rather than skipping ahead (FR-051),
|
|
30
|
+
* which is what makes a transient failure — a locked keychain, a full disk
|
|
31
|
+
* mid-migration — recoverable on the next launch instead of permanent.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
function migrationContextFor(context, executor) {
|
|
35
|
+
return {
|
|
36
|
+
collection(name) {
|
|
37
|
+
return (0, _collection.createSqlCollection)({
|
|
38
|
+
executor: () => executor,
|
|
39
|
+
schema: context.schemaFor(name),
|
|
40
|
+
now: context.now,
|
|
41
|
+
// Inside a migration the handle does not exist yet, so there is
|
|
42
|
+
// no closed-handle or deleted-scope state to guard against.
|
|
43
|
+
assertUsable: () => {}
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
async abort() {
|
|
47
|
+
// A migration that wants to give up should throw; aborting the
|
|
48
|
+
// transaction from inside while the executor still believes it is
|
|
49
|
+
// running would record an outcome that never happened.
|
|
50
|
+
(0, _errors2.raise)(_errors.DiagnosticCodes.TRANSACTION_STATE, {
|
|
51
|
+
message: 'a migration cannot abort its own transaction'
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
async execute(sql, params) {
|
|
55
|
+
await executor.execute(sql, params);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
async function runMigrations(context) {
|
|
60
|
+
const {
|
|
61
|
+
config,
|
|
62
|
+
connection
|
|
63
|
+
} = context;
|
|
64
|
+
(0, _validateChain.validateMigrationChain)(config);
|
|
65
|
+
// Skipped when the open already found its bookkeeping tables in place.
|
|
66
|
+
if (context.ledgerReady !== true) {
|
|
67
|
+
await (0, _ledger.ensureLedger)(connection);
|
|
68
|
+
}
|
|
69
|
+
const {
|
|
70
|
+
schema: recorded,
|
|
71
|
+
format
|
|
72
|
+
} = await (0, _ledger.readVersions)(connection);
|
|
73
|
+
if (format > _ledger.FORMAT_VERSION) {
|
|
74
|
+
// A file laid out by a newer release of this package. Reading it with
|
|
75
|
+
// older code is the same hazard as a schema downgrade, one layer down.
|
|
76
|
+
await context.closeOnFailure();
|
|
77
|
+
(0, _errors2.raise)(_errors.DiagnosticCodes.SCHEMA_DOWNGRADE, {
|
|
78
|
+
message: 'database was written by a newer version of this package',
|
|
79
|
+
detail: {
|
|
80
|
+
recordedVersion: format,
|
|
81
|
+
version: _ledger.FORMAT_VERSION
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
if (recorded > config.schemaVersion) {
|
|
86
|
+
// Opening anyway would mean newer data read by older code, which drops
|
|
87
|
+
// whatever the newer schema added — silently, and on write (FR-052).
|
|
88
|
+
await context.closeOnFailure();
|
|
89
|
+
(0, _errors2.raise)(_errors.DiagnosticCodes.SCHEMA_DOWNGRADE, {
|
|
90
|
+
message: 'recorded schema version is newer than the declared one',
|
|
91
|
+
detail: {
|
|
92
|
+
recordedVersion: recorded,
|
|
93
|
+
version: config.schemaVersion
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
let current = recorded;
|
|
98
|
+
for (const migration of (0, _validateChain.pendingMigrations)(config, recorded)) {
|
|
99
|
+
try {
|
|
100
|
+
await connection.transaction(async tx => {
|
|
101
|
+
(0, _faults.throwIfFaulted)('migration');
|
|
102
|
+
await migration.migrate(migrationContextFor(context, tx));
|
|
103
|
+
await (0, _ledger.writeSchemaVersion)(tx, migration.version);
|
|
104
|
+
await (0, _ledger.recordAttempt)(tx, {
|
|
105
|
+
version: migration.version,
|
|
106
|
+
attemptedAt: context.now(),
|
|
107
|
+
outcome: 'applied'
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
current = migration.version;
|
|
111
|
+
} catch (error) {
|
|
112
|
+
// Recorded outside the rolled-back transaction, or it would vanish
|
|
113
|
+
// with the migration it describes.
|
|
114
|
+
await (0, _ledger.recordAttempt)(connection, {
|
|
115
|
+
version: migration.version,
|
|
116
|
+
attemptedAt: context.now(),
|
|
117
|
+
outcome: 'failed',
|
|
118
|
+
failureCode: error.code ?? _errors.DiagnosticCodes.MIGRATION_FAILED
|
|
119
|
+
});
|
|
120
|
+
await context.closeOnFailure();
|
|
121
|
+
(0, _errors2.raise)(_errors.DiagnosticCodes.MIGRATION_FAILED, {
|
|
122
|
+
message: 'migration failed',
|
|
123
|
+
migration: {
|
|
124
|
+
// Unchanged: the next open retries from here rather than
|
|
125
|
+
// skipping the migration that failed.
|
|
126
|
+
recordedVersion: current,
|
|
127
|
+
failingVersion: migration.version,
|
|
128
|
+
outcome: 'failed'
|
|
129
|
+
},
|
|
130
|
+
cause: error
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return current;
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_errors","require","_errors2","_faults","_collection","_ledger","_validateChain","migrationContextFor","context","executor","collection","name","createSqlCollection","schema","schemaFor","now","assertUsable","abort","raise","DiagnosticCodes","TRANSACTION_STATE","message","execute","sql","params","runMigrations","config","connection","validateMigrationChain","ledgerReady","ensureLedger","recorded","format","readVersions","FORMAT_VERSION","closeOnFailure","SCHEMA_DOWNGRADE","detail","recordedVersion","version","schemaVersion","current","migration","pendingMigrations","transaction","tx","throwIfFaulted","migrate","writeSchemaVersion","recordAttempt","attemptedAt","outcome","error","failureCode","code","MIGRATION_FAILED","failingVersion","cause"],"sourceRoot":"../../../src","sources":["migration/executor.ts"],"mappings":";;;;;;AAsBA,IAAAA,OAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAEA,IAAAI,OAAA,GAAAJ,OAAA;AAOA,IAAAK,cAAA,GAAAL,OAAA;AAtCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqCA,SAASM,mBAAmBA,CAACC,OAA4B,EAAEC,QAAkB,EAAoB;EAChG,OAAO;IACNC,UAAUA,CAA+BC,IAAY,EAAoB;MACxE,OAAO,IAAAC,+BAAmB,EAAI;QAC7BH,QAAQ,EAAEA,CAAA,KAAMA,QAAQ;QACxBI,MAAM,EAAEL,OAAO,CAACM,SAAS,CAACH,IAAI,CAAC;QAC/BI,GAAG,EAAEP,OAAO,CAACO,GAAG;QAChB;QACA;QACAC,YAAY,EAAEA,CAAA,KAAM,CAAC;MACtB,CAAC,CAAC;IACH,CAAC;IACD,MAAMC,KAAKA,CAAA,EAAkB;MAC5B;MACA;MACA;MACA,IAAAC,cAAK,EAACC,uBAAe,CAACC,iBAAiB,EAAE;QACxCC,OAAO,EAAE;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+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.FORMAT_VERSION = void 0;
|
|
7
|
+
exports.ensureLedger = ensureLedger;
|
|
8
|
+
exports.readVersions = readVersions;
|
|
9
|
+
exports.recordAttempt = recordAttempt;
|
|
10
|
+
exports.writeSchemaVersion = writeSchemaVersion;
|
|
11
|
+
var _values = require("../sqlite/values.js");
|
|
12
|
+
/**
|
|
13
|
+
* The per-scope migration ledger.
|
|
14
|
+
*
|
|
15
|
+
* Per scope, not per database, and that is the whole reason FR-054 works: a
|
|
16
|
+
* scope created after a migration shipped starts at version 0 and is migrated
|
|
17
|
+
* on first open, rather than being assumed current because some other scope
|
|
18
|
+
* already ran the chain.
|
|
19
|
+
*
|
|
20
|
+
* The ledger records a **code**, never a message (FR-079). A migration that
|
|
21
|
+
* failed because a domain constraint was violated could otherwise write the
|
|
22
|
+
* offending value into a table that outlives the failure — a payload leak
|
|
23
|
+
* with a long half-life, sitting in a file the next crash report might carry.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/** Physical layout version, independent of the app's schema version. */
|
|
27
|
+
const FORMAT_VERSION = exports.FORMAT_VERSION = 1;
|
|
28
|
+
const CREATE_META = `CREATE TABLE IF NOT EXISTS _meta (
|
|
29
|
+
key TEXT PRIMARY KEY,
|
|
30
|
+
value TEXT NOT NULL
|
|
31
|
+
)`;
|
|
32
|
+
const CREATE_MIGRATIONS = `CREATE TABLE IF NOT EXISTS _migrations (
|
|
33
|
+
version INTEGER PRIMARY KEY,
|
|
34
|
+
attempted_at INTEGER NOT NULL,
|
|
35
|
+
outcome TEXT NOT NULL,
|
|
36
|
+
failure_code TEXT
|
|
37
|
+
)`;
|
|
38
|
+
async function ensureLedger(executor) {
|
|
39
|
+
await executor.execute(CREATE_META);
|
|
40
|
+
await executor.execute(CREATE_MIGRATIONS);
|
|
41
|
+
await executor.execute('INSERT INTO _meta (key, value) VALUES (?, ?) ON CONFLICT(key) DO NOTHING', ['format_version', String(FORMAT_VERSION)]);
|
|
42
|
+
await executor.execute('INSERT INTO _meta (key, value) VALUES (?, ?) ON CONFLICT(key) DO NOTHING', ['schema_version', '0']);
|
|
43
|
+
}
|
|
44
|
+
/** Both versions in one read: every open asks for them. */
|
|
45
|
+
async function readVersions(executor) {
|
|
46
|
+
const result = await executor.execute("SELECT key, value FROM _meta WHERE key IN ('schema_version', 'format_version')");
|
|
47
|
+
const values = new Map(result.rows.map(row => [(0, _values.text)(row.key), Number((0, _values.text)(row.value))]));
|
|
48
|
+
return {
|
|
49
|
+
schema: values.get('schema_version') ?? 0,
|
|
50
|
+
format: values.get('format_version') ?? FORMAT_VERSION
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
async function writeSchemaVersion(executor, version) {
|
|
54
|
+
await executor.execute('INSERT INTO _meta (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value', ['schema_version', String(version)]);
|
|
55
|
+
}
|
|
56
|
+
async function recordAttempt(executor, entry) {
|
|
57
|
+
await executor.execute(`INSERT INTO _migrations (version, attempted_at, outcome, failure_code)
|
|
58
|
+
VALUES (?, ?, ?, ?)
|
|
59
|
+
ON CONFLICT(version) DO UPDATE SET
|
|
60
|
+
attempted_at = excluded.attempted_at,
|
|
61
|
+
outcome = excluded.outcome,
|
|
62
|
+
failure_code = excluded.failure_code`, [entry.version, entry.attemptedAt, entry.outcome, entry.failureCode ?? null]);
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=ledger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_values","require","FORMAT_VERSION","exports","CREATE_META","CREATE_MIGRATIONS","ensureLedger","executor","execute","String","readVersions","result","values","Map","rows","map","row","text","key","Number","value","schema","get","format","writeSchemaVersion","version","recordAttempt","entry","attemptedAt","outcome","failureCode"],"sourceRoot":"../../../src","sources":["migration/ledger.ts"],"mappings":";;;;;;;;;;AAgBA,IAAAA,OAAA,GAAAC,OAAA;AAhBA;AACA;AACA;AACA;AACA;AAC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nC,CAAC;AACF;AAEO,eAAeC,aAAaA,CAClCnB,QAAkB,EAClBoB,KAAgG,EAChF;EAChB,MAAMpB,QAAQ,CAACC,OAAO,CACrB;AACF;AACA;AACA;AACA;AACA,0CAA0C,EACxC,CAACmB,KAAK,CAACF,OAAO,EAAEE,KAAK,CAACC,WAAW,EAAED,KAAK,CAACE,OAAO,EAAEF,KAAK,CAACG,WAAW,IAAI,IAAI,CAC5E,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.orderedMigrations = orderedMigrations;
|
|
7
|
+
exports.pendingMigrations = pendingMigrations;
|
|
8
|
+
exports.validateMigrationChain = validateMigrationChain;
|
|
9
|
+
var _errors = require("../contract/errors.js");
|
|
10
|
+
var _errors2 = require("../diagnostics/errors.js");
|
|
11
|
+
/**
|
|
12
|
+
* Migration chain validation, run before any migration executes (FR-053).
|
|
13
|
+
*
|
|
14
|
+
* Validating first is what stops a half-run chain from being the thing that
|
|
15
|
+
* discovers the problem. A duplicate version, a gap, or a chain that does not
|
|
16
|
+
* reach the declared `schemaVersion` are all configuration errors the
|
|
17
|
+
* developer can fix; discovering them after migration 3 of 5 has already
|
|
18
|
+
* rewritten a user's data is not.
|
|
19
|
+
*
|
|
20
|
+
* A gap is refused rather than skipped over deliberately. A user upgrading
|
|
21
|
+
* from the version inside the gap has no path across it, and opening anyway
|
|
22
|
+
* would hand them a database the code believes is current and is not.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
function invalid(message, detail) {
|
|
26
|
+
(0, _errors2.raise)(_errors.DiagnosticCodes.MIGRATION_CONFIG_INVALID, {
|
|
27
|
+
message,
|
|
28
|
+
detail
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function validateMigrationChain(config) {
|
|
32
|
+
const migrations = config.migrations ?? [];
|
|
33
|
+
if (!Number.isInteger(config.schemaVersion) || config.schemaVersion < 1) {
|
|
34
|
+
invalid('schemaVersion must be a positive integer');
|
|
35
|
+
}
|
|
36
|
+
const versions = new Set();
|
|
37
|
+
for (const migration of migrations) {
|
|
38
|
+
if (!Number.isInteger(migration.version) || migration.version < 1) {
|
|
39
|
+
invalid('migration version must be a positive integer');
|
|
40
|
+
}
|
|
41
|
+
if (versions.has(migration.version)) {
|
|
42
|
+
invalid('duplicate migration version', {
|
|
43
|
+
version: migration.version
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
versions.add(migration.version);
|
|
47
|
+
if (typeof migration.migrate !== 'function') {
|
|
48
|
+
invalid('migration has no migrate function', {
|
|
49
|
+
version: migration.version
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
for (let version = 1; version <= config.schemaVersion; version += 1) {
|
|
54
|
+
if (!versions.has(version)) {
|
|
55
|
+
invalid('migration chain has a gap', {
|
|
56
|
+
version
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
for (const version of versions) {
|
|
61
|
+
if (version > config.schemaVersion) {
|
|
62
|
+
invalid('migration version exceeds the declared schemaVersion', {
|
|
63
|
+
version
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Ascending, because the order a consumer declared them in is not a contract. */
|
|
70
|
+
function orderedMigrations(config) {
|
|
71
|
+
return [...(config.migrations ?? [])].sort((a, b) => a.version - b.version);
|
|
72
|
+
}
|
|
73
|
+
function pendingMigrations(config, recordedVersion) {
|
|
74
|
+
return orderedMigrations(config).filter(migration => migration.version > recordedVersion);
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=validate-chain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_errors","require","_errors2","invalid","message","detail","raise","DiagnosticCodes","MIGRATION_CONFIG_INVALID","validateMigrationChain","config","migrations","Number","isInteger","schemaVersion","versions","Set","migration","version","has","add","migrate","orderedMigrations","sort","a","b","pendingMigrations","recordedVersion","filter"],"sourceRoot":"../../../src","sources":["migration/validate-chain.ts"],"mappings":";;;;;;;;AAeA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AAjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA,SAASE,OAAOA,CAACC,OAAe,EAAEC,MAAgC,EAAS;EAC1E,IAAAC,cAAK,EAACC,uBAAe,CAACC,wBAAwB,EAAE;IAAEJ,OAAO;IAAEC;EAAO,CAAC,CAAC;AACrE;AAEO,SAASI,sBAAsBA,CAACC,MAAsB,EAAQ;EACpE,MAAMC,UAAU,GAAGD,MAAM,CAACC,UAAU,IAAI,EAAE;EAE1C,IAAI,CAACC,MAAM,CAACC,SAAS,CAACH,MAAM,CAACI,aAAa,CAAC,IAAIJ,MAAM,CAACI,aAAa,GAAG,CAAC,EAAE;IACxEX,OAAO,CAAC,0CAA0C,CAAC;EACpD;EAEA,MAAMY,QAAQ,GAAG,IAAIC,GAAG,CAAS,CAAC;EAClC,KAAK,MAAMC,SAAS,IAAIN,UAAU,EAAE;IACnC,IAAI,CAACC,MAAM,CAACC,SAAS,CAACI,SAAS,CAACC,OAAO,CAAC,IAAID,SAAS,CAACC,OAAO,GAAG,CAAC,EAAE;MAClEf,OAAO,CAAC,8CAA8C,CAAC;IACxD;IACA,IAAIY,QAAQ,CAACI,GAAG,CAACF,SAAS,CAACC,OAAO,CAAC,EAAE;MACpCf,OAAO,CAAC,6BAA6B,EAAE;QAAEe,OAAO,EAAED,SAAS,CAACC;MAAQ,CAAC,CAAC;IACvE;IACAH,QAAQ,CAACK,GAAG,CAACH,SAAS,CAACC,OAAO,CAAC;IAC/B,IAAI,OAAOD,SAAS,CAACI,OAAO,KAAK,UAAU,EAAE;MAC5ClB,OAAO,CAAC,mCAAmC,EAAE;QAAEe,OAAO,EAAED,SAAS,CAACC;MAAQ,CAAC,CAAC;IAC7E;EACD;EAEA,KAAK,IAAIA,OAAO,GAAG,CAAC,EAAEA,OAAO,IAAIR,MAAM,CAACI,aAAa,EAAEI,OAAO,IAAI,CAAC,EAAE;IACpE,IAAI,CAACH,QAAQ,CAACI,GAAG,CAACD,OAAO,CAAC,EAAE;MAC3Bf,OAAO,CAAC,2BAA2B,EAAE;QAAEe;MAAQ,CAAC,CAAC;IAClD;EACD;EAEA,KAAK,MAAMA,OAAO,IAAIH,QAAQ,EAAE;IAC/B,IAAIG,OAAO,GAAGR,MAAM,CAACI,aAAa,EAAE;MACnCX,OAAO,CAAC,sDAAsD,EAAE;QAAEe;MAAQ,CAAC,CAAC;IAC7E;EACD;AACD;;AAEA;AACO,SAASI,iBAAiBA,CAACZ,MAAsB,EAAe;EACtE,OAAO,CAAC,IAAIA,MAAM,CAACC,UAAU,IAAI,EAAE,CAAC,CAAC,CAACY,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACN,OAAO,GAAGO,CAAC,CAACP,OAAO,CAAC;AAC5E;AAEO,SAASQ,iBAAiBA,CAAChB,MAAsB,EAAEiB,eAAuB,EAAe;EAC/F,OAAOL,iBAAiB,CAACZ,MAAM,CAAC,CAACkB,MAAM,CAACX,SAAS,IAAIA,SAAS,CAACC,OAAO,GAAGS,eAAe,CAAC;AAC1F","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.androidPosture = androidPosture;
|
|
7
|
+
exports.coveragePathFor = coveragePathFor;
|
|
8
|
+
exports.effectivePostureFor = effectivePostureFor;
|
|
9
|
+
exports.isAndroid = isAndroid;
|
|
10
|
+
var _reactNative = require("react-native");
|
|
11
|
+
var _location = require("./location.js");
|
|
12
|
+
/**
|
|
13
|
+
* Android backup posture: verified and reported, never enforced.
|
|
14
|
+
*
|
|
15
|
+
* Android decides backup participation from `android:dataExtractionRules` in
|
|
16
|
+
* the app's manifest. That is build-time and app-owned, and this package
|
|
17
|
+
* authors no native code, so it cannot contribute an entry and cannot change
|
|
18
|
+
* the answer at runtime (research.md R5).
|
|
19
|
+
*
|
|
20
|
+
* What it can do is check the one thing that silently breaks the documented
|
|
21
|
+
* fix: the rule the README tells an app to ship addresses the `file` domain,
|
|
22
|
+
* which is the app's `files/` directory. If the managed root did not land
|
|
23
|
+
* under that directory, the app can ship the XML exactly as documented and
|
|
24
|
+
* still have an unprotected database. That mismatch is detectable here, and
|
|
25
|
+
* an app learning it from this report is the whole point of FR-111 — the
|
|
26
|
+
* alternative is learning it from an incident.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
function isAndroid() {
|
|
30
|
+
return _reactNative.Platform.OS === 'android';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The `path` an app's exclusion rule must name for the root it actually got. */
|
|
34
|
+
function coveragePathFor(layout) {
|
|
35
|
+
const root = (0, _location.normalizePath)(layout.root);
|
|
36
|
+
const marker = `/files/`;
|
|
37
|
+
const index = root.indexOf(marker);
|
|
38
|
+
if (index === -1) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
return root.slice(index + marker.length);
|
|
42
|
+
}
|
|
43
|
+
function androidPosture(layout, includeInPlatformBackup) {
|
|
44
|
+
const requested = includeInPlatformBackup ? 'included' : 'excluded';
|
|
45
|
+
const coverage = coveragePathFor(layout);
|
|
46
|
+
if (coverage === null) {
|
|
47
|
+
return {
|
|
48
|
+
requested,
|
|
49
|
+
// Not "excluded" and not "included": the package genuinely does not
|
|
50
|
+
// know, and saying either would be a claim it cannot support.
|
|
51
|
+
observed: 'unknown',
|
|
52
|
+
enforcedBy: 'app-manifest',
|
|
53
|
+
warning: 'The managed storage area is not under the Android file domain, so the ' + 'documented data_extraction_rules.xml entry will not cover it. Backup ' + 'posture cannot be honoured on this platform until the app supplies a ' + 'rule matching the actual storage location.'
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
requested,
|
|
58
|
+
observed: 'unknown',
|
|
59
|
+
enforcedBy: 'app-manifest',
|
|
60
|
+
warning: `Android backup participation is declared by the app, not this package. ` + `Confirm android/app/src/main/res/xml/data_extraction_rules.xml contains an ` + `entry for domain="file" path="${_location.MANAGED_ROOT_NAME}/" and that ` + `AndroidManifest.xml references it; the observed posture cannot be verified ` + `from JavaScript.`
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The posture the handle reports (FR-111).
|
|
66
|
+
*
|
|
67
|
+
* Split by platform rather than smoothed over, because a consumer writing a
|
|
68
|
+
* privacy disclosure needs to know which of the two answers it is holding.
|
|
69
|
+
*/
|
|
70
|
+
function effectivePostureFor(layout, includeInPlatformBackup, iosPostureFor) {
|
|
71
|
+
if (isAndroid()) {
|
|
72
|
+
return androidPosture(layout, includeInPlatformBackup);
|
|
73
|
+
}
|
|
74
|
+
return iosPostureFor(includeInPlatformBackup);
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=backup-android-verify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_location","isAndroid","Platform","OS","coveragePathFor","layout","root","normalizePath","marker","index","indexOf","slice","length","androidPosture","includeInPlatformBackup","requested","coverage","observed","enforcedBy","warning","MANAGED_ROOT_NAME","effectivePostureFor","iosPostureFor"],"sourceRoot":"../../../src","sources":["platform/backup-android-verify.ts"],"mappings":";;;;;;;;;AAiBA,IAAAA,YAAA,GAAAC,OAAA;AAGA,IAAAC,SAAA,GAAAD,OAAA;AApBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOO,SAASE,SAASA,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|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ensureManagedRoot = ensureManagedRoot;
|
|
7
|
+
exports.iosPosture = iosPosture;
|
|
8
|
+
exports.isIos = isIos;
|
|
9
|
+
var _reactNative = require("react-native");
|
|
10
|
+
var _fs = require("./fs.js");
|
|
11
|
+
/**
|
|
12
|
+
* iOS backup exclusion.
|
|
13
|
+
*
|
|
14
|
+
* `NSURLIsExcludedFromBackupKey` is set on the managed root at creation, and
|
|
15
|
+
* the attribute is inherited by everything beneath it — so one call covers
|
|
16
|
+
* the catalog, every scope database, and every artifact, including ones
|
|
17
|
+
* created years later. Setting it per file would leave a window in which a
|
|
18
|
+
* freshly written artifact is backed up before the attribute lands.
|
|
19
|
+
*
|
|
20
|
+
* This is the half of FR-109 the package can actually enforce. Android is
|
|
21
|
+
* manifest-owned; see backup-android-verify.ts and research.md R5.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
function isIos() {
|
|
25
|
+
return _reactNative.Platform.OS === 'ios';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Create the managed root with the exclusion attribute already on it.
|
|
30
|
+
*
|
|
31
|
+
* Idempotent: `mkdir` on an existing directory re-applies the attribute,
|
|
32
|
+
* which matters because an app that flips the posture between launches must
|
|
33
|
+
* get the new one without a reinstall.
|
|
34
|
+
*/
|
|
35
|
+
async function ensureManagedRoot(layout, includeInPlatformBackup) {
|
|
36
|
+
await (0, _fs.fileSystem)().mkdir(layout.root, isIos() ? {
|
|
37
|
+
NSURLIsExcludedFromBackupKey: !includeInPlatformBackup
|
|
38
|
+
} : {});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** What the package can state about iOS, where it enforces rather than reports. */
|
|
42
|
+
function iosPosture(includeInPlatformBackup) {
|
|
43
|
+
const requested = includeInPlatformBackup ? 'included' : 'excluded';
|
|
44
|
+
return {
|
|
45
|
+
requested,
|
|
46
|
+
observed: requested,
|
|
47
|
+
enforcedBy: 'package'
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=backup-ios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_fs","isIos","Platform","OS","ensureManagedRoot","layout","includeInPlatformBackup","fileSystem","mkdir","root","NSURLIsExcludedFromBackupKey","iosPosture","requested","observed","enforcedBy"],"sourceRoot":"../../../src","sources":["platform/backup-ios.ts"],"mappings":";;;;;;;;AAaA,IAAAA,YAAA,GAAAC,OAAA;AAGA,IAAAC,GAAA,GAAAD,OAAA;AAhBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQO,SAASE,KAAKA,CAAA,EAAY;EAChC,OAAOC,qBAAQ,CAACC,EAAE,KAAK,KAAK;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeC,iBAAiBA,CACtCC,MAAqB,EACrBC,uBAAgC,EAChB;EAChB,MAAM,IAAAC,cAAU,EAAC,CAAC,CAACC,KAAK,CACvBH,MAAM,CAACI,IAAI,EACXR,KAAK,CAAC,CAAC,GAAG;IAAES,4BAA4B,EAAE,CAACJ;EAAwB,CAAC,GAAG,CAAC,CACzE,CAAC;AACF;;AAEA;AACO,SAASK,UAAUA,CAACL,uBAAgC,EAAoB;EAC9E,MAAMM,SAAS,GAAGN,uBAAuB,GAAG,UAAU,GAAG,UAAU;EACnE,OAAO;IACNM,SAAS;IACTC,QAAQ,EAAED,SAAS;IACnBE,UAAU,EAAE;EACb,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.asciiAt = asciiAt;
|
|
7
|
+
exports.base64ToBytes = base64ToBytes;
|
|
8
|
+
exports.bytesToBase64 = bytesToBase64;
|
|
9
|
+
exports.concatBytes = concatBytes;
|
|
10
|
+
exports.host = void 0;
|
|
11
|
+
exports.utf8Bytes = utf8Bytes;
|
|
12
|
+
exports.utf8String = utf8String;
|
|
13
|
+
/**
|
|
14
|
+
* Byte handling without Node's `Buffer`.
|
|
15
|
+
*
|
|
16
|
+
* Hermes has no global `Buffer`, and `react-native-quick-crypto` installs one
|
|
17
|
+
* only when the app calls its `install()` — which nothing in this package or its
|
|
18
|
+
* documentation asked for. Until 0.2.0 attachment writes and reads used the
|
|
19
|
+
* global anyway, so on a device every attachment operation threw. Everything
|
|
20
|
+
* here is plain `Uint8Array` and a self-contained base64 codec, identical on
|
|
21
|
+
* Hermes and in Node.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
const ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
25
|
+
const LOOKUP = (() => {
|
|
26
|
+
const table = new Int16Array(128).fill(-1);
|
|
27
|
+
for (let index = 0; index < ALPHABET.length; index += 1) {
|
|
28
|
+
table[ALPHABET.charCodeAt(index)] = index;
|
|
29
|
+
}
|
|
30
|
+
// The URL-safe variants decode too, since some file APIs return them.
|
|
31
|
+
table['-'.charCodeAt(0)] = 62;
|
|
32
|
+
table['_'.charCodeAt(0)] = 63;
|
|
33
|
+
return table;
|
|
34
|
+
})();
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Codecs Hermes and Node provide but React Native's type declarations omit.
|
|
38
|
+
* Read through this view so the package type-checks without DOM or Node types.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
const host = exports.host = globalThis;
|
|
42
|
+
|
|
43
|
+
/* eslint-disable no-bitwise -- base64 is bit packing; there is no clearer way to write it. */
|
|
44
|
+
|
|
45
|
+
/** Characters per `String.fromCharCode` call; large spreads overflow the stack. */
|
|
46
|
+
const CHUNK = 0x8000;
|
|
47
|
+
function base64ToBytes(base64) {
|
|
48
|
+
if (host.atob) {
|
|
49
|
+
let binary;
|
|
50
|
+
try {
|
|
51
|
+
binary = host.atob(base64.replace(/-/g, '+').replace(/_/g, '/'));
|
|
52
|
+
} catch {
|
|
53
|
+
// atob is strict where Buffer was lenient; fall through to the
|
|
54
|
+
// tolerant decoder rather than turn stray characters into a crash.
|
|
55
|
+
}
|
|
56
|
+
if (binary !== undefined) {
|
|
57
|
+
const bytes = new Uint8Array(binary.length);
|
|
58
|
+
for (let index = 0; index < binary.length; index += 1) {
|
|
59
|
+
bytes[index] = binary.charCodeAt(index);
|
|
60
|
+
}
|
|
61
|
+
return bytes;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// Decode directly, skipping padding and anything outside the alphabet.
|
|
65
|
+
const bytes = new Uint8Array(Math.ceil(base64.length * 3 / 4));
|
|
66
|
+
let out = 0;
|
|
67
|
+
let buffer = 0;
|
|
68
|
+
let bits = 0;
|
|
69
|
+
for (let index = 0; index < base64.length; index += 1) {
|
|
70
|
+
const code = base64.charCodeAt(index);
|
|
71
|
+
const value = code < 128 ? LOOKUP[code] : -1;
|
|
72
|
+
if (value < 0) continue;
|
|
73
|
+
buffer = buffer << 6 | value;
|
|
74
|
+
bits += 6;
|
|
75
|
+
if (bits >= 8) {
|
|
76
|
+
bits -= 8;
|
|
77
|
+
bytes[out++] = buffer >> bits & 0xff;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return bytes.subarray(0, out);
|
|
81
|
+
}
|
|
82
|
+
function bytesToBase64(bytes) {
|
|
83
|
+
if (host.btoa) {
|
|
84
|
+
const parts = [];
|
|
85
|
+
for (let index = 0; index < bytes.length; index += CHUNK) {
|
|
86
|
+
parts.push(String.fromCharCode(...bytes.subarray(index, index + CHUNK)));
|
|
87
|
+
}
|
|
88
|
+
return host.btoa(parts.join(''));
|
|
89
|
+
}
|
|
90
|
+
const parts = [];
|
|
91
|
+
for (let start = 0; start < bytes.length; start += CHUNK * 3) {
|
|
92
|
+
let piece = '';
|
|
93
|
+
const end = Math.min(bytes.length, start + CHUNK * 3);
|
|
94
|
+
let index = start;
|
|
95
|
+
for (; index + 2 < end; index += 3) {
|
|
96
|
+
const triple = bytes[index] << 16 | bytes[index + 1] << 8 | bytes[index + 2];
|
|
97
|
+
piece += ALPHABET[triple >> 18] + ALPHABET[triple >> 12 & 63] + ALPHABET[triple >> 6 & 63] + ALPHABET[triple & 63];
|
|
98
|
+
}
|
|
99
|
+
const remaining = end - index;
|
|
100
|
+
if (remaining === 1) {
|
|
101
|
+
const value = bytes[index];
|
|
102
|
+
piece += `${ALPHABET[value >> 2]}${ALPHABET[(value & 3) << 4]}==`;
|
|
103
|
+
} else if (remaining === 2) {
|
|
104
|
+
const value = bytes[index] << 8 | bytes[index + 1];
|
|
105
|
+
piece += `${ALPHABET[value >> 10]}${ALPHABET[value >> 4 & 63]}${ALPHABET[(value & 15) << 2]}=`;
|
|
106
|
+
}
|
|
107
|
+
parts.push(piece);
|
|
108
|
+
}
|
|
109
|
+
return parts.join('');
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** UTF-8 encoding. `TextEncoder` is in Hermes and Node; the loop is the fallback. */
|
|
113
|
+
function utf8Bytes(value) {
|
|
114
|
+
if (host.TextEncoder) {
|
|
115
|
+
return new host.TextEncoder().encode(value);
|
|
116
|
+
}
|
|
117
|
+
const encoded = unescape(encodeURIComponent(value));
|
|
118
|
+
const bytes = new Uint8Array(encoded.length);
|
|
119
|
+
for (let index = 0; index < encoded.length; index += 1) {
|
|
120
|
+
bytes[index] = encoded.charCodeAt(index);
|
|
121
|
+
}
|
|
122
|
+
return bytes;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** UTF-8 decoding, the inverse of `utf8Bytes`. */
|
|
126
|
+
function utf8String(bytes) {
|
|
127
|
+
if (host.TextDecoder) {
|
|
128
|
+
return new host.TextDecoder().decode(bytes);
|
|
129
|
+
}
|
|
130
|
+
let binary = '';
|
|
131
|
+
for (const byte of bytes) {
|
|
132
|
+
binary += String.fromCharCode(byte);
|
|
133
|
+
}
|
|
134
|
+
return decodeURIComponent(escape(binary));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/* eslint-enable no-bitwise */
|
|
138
|
+
|
|
139
|
+
function concatBytes(parts) {
|
|
140
|
+
const total = parts.reduce((sum, part) => sum + part.length, 0);
|
|
141
|
+
const joined = new Uint8Array(total);
|
|
142
|
+
let offset = 0;
|
|
143
|
+
for (const part of parts) {
|
|
144
|
+
joined.set(part, offset);
|
|
145
|
+
offset += part.length;
|
|
146
|
+
}
|
|
147
|
+
return joined;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** The ASCII text of `length` bytes from `start`, for magic numbers. */
|
|
151
|
+
function asciiAt(bytes, start, length) {
|
|
152
|
+
let text = '';
|
|
153
|
+
for (let index = start; index < start + length && index < bytes.length; index += 1) {
|
|
154
|
+
text += String.fromCharCode(bytes[index]);
|
|
155
|
+
}
|
|
156
|
+
return text;
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=bytes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ALPHABET","LOOKUP","table","Int16Array","fill","index","length","charCodeAt","host","exports","globalThis","CHUNK","base64ToBytes","base64","atob","binary","replace","undefined","bytes","Uint8Array","Math","ceil","out","buffer","bits","code","value","subarray","bytesToBase64","btoa","parts","push","String","fromCharCode","join","start","piece","end","min","triple","remaining","utf8Bytes","TextEncoder","encode","encoded","unescape","encodeURIComponent","utf8String","TextDecoder","decode","byte","decodeURIComponent","escape","concatBytes","total","reduce","sum","part","joined","offset","set","asciiAt","text"],"sourceRoot":"../../../src","sources":["platform/bytes.ts"],"mappings":";;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMA,QAAQ,GAAG,kEAAkE;AACnF,MAAMC,MAAM,GAAG,CAAC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