@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 @@
|
|
|
1
|
+
{"version":3,"names":["_store","require","_rowCodec","_values","DDL_VERSION","FINGERPRINT_KEY","fingerprintOf","config","JSON","stringify","collections","appliedFingerprint","connection","result","execute","row","rows","text","value","definitionOf","sql","unique","test","columns","slice","lastIndexOf","replace","syncIndexes","schema","table","name","existing","current","Map","map","wanted","createIndexSql","statement","exec","index","indexes","has","physicalIndexName","get","ours","startsWith","undefined","values","ensureCollection","createTableSql","info","present","Set","field","fields","column","addColumnSql","path","syncSchema","fingerprint","unchanged","record","ensureAttachmentTable"],"sourceRoot":"../../../src","sources":["adapter/schema-sync.ts"],"mappings":"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","ignoreList":[]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createTransaction = createTransaction;
|
|
7
|
+
var _errors = require("../contract/errors.js");
|
|
8
|
+
var _errors2 = require("../diagnostics/errors.js");
|
|
9
|
+
/**
|
|
10
|
+
* The `Transaction` a consumer actually holds.
|
|
11
|
+
*
|
|
12
|
+
* Two rules live here rather than in either adapter, so both are held to the
|
|
13
|
+
* same standard:
|
|
14
|
+
*
|
|
15
|
+
* **Read-your-own-writes** (FR-043). Every collection reached through `tx`
|
|
16
|
+
* runs against the transaction's executor, so a read inside sees the writes
|
|
17
|
+
* made inside. A collection reached through the handle during a transaction
|
|
18
|
+
* would not, and handing one out would be a quiet correctness trap.
|
|
19
|
+
*
|
|
20
|
+
* **Terminal state is terminal** (FR-044). After a commit or an abort, using
|
|
21
|
+
* the transaction raises rather than silently writing outside it — the
|
|
22
|
+
* failure mode where a caller's cleanup code lands in the database after the
|
|
23
|
+
* rollback it was supposed to be part of.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
function createTransaction(host) {
|
|
27
|
+
let settled = false;
|
|
28
|
+
const assertLive = () => {
|
|
29
|
+
if (settled) {
|
|
30
|
+
(0, _errors2.raise)(_errors.DiagnosticCodes.TRANSACTION_STATE, {
|
|
31
|
+
message: 'transaction already settled'
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const transaction = {
|
|
36
|
+
collection(name) {
|
|
37
|
+
assertLive();
|
|
38
|
+
return host.collection(name);
|
|
39
|
+
},
|
|
40
|
+
attachments() {
|
|
41
|
+
assertLive();
|
|
42
|
+
return host.attachments();
|
|
43
|
+
},
|
|
44
|
+
async abort() {
|
|
45
|
+
assertLive();
|
|
46
|
+
settled = true;
|
|
47
|
+
await host.rollback();
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
return {
|
|
51
|
+
transaction,
|
|
52
|
+
isSettled: () => settled,
|
|
53
|
+
settle: () => {
|
|
54
|
+
settled = true;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=transaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_errors","require","_errors2","createTransaction","host","settled","assertLive","raise","DiagnosticCodes","TRANSACTION_STATE","message","transaction","collection","name","attachments","abort","rollback","isSettled","settle"],"sourceRoot":"../../../src","sources":["adapter/transaction.ts"],"mappings":";;;;;;AAiBA,IAAAA,OAAA,GAAAC,OAAA;AAIA,IAAAC,QAAA,GAAAD,OAAA;AArBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqBO,SAASE,iBAAiBA,CAACC,IAAqB,EAAsB;EAC5E,IAAIC,OAAO,GAAG,KAAK;EAEnB,MAAMC,UAAU,GAAGA,CAAA,KAAY;IAC9B,IAAID,OAAO,EAAE;MACZ,IAAAE,cAAK,EAACC,uBAAe,CAACC,iBAAiB,EAAE;QACxCC,OAAO,EAAE;MACV,CAAC,CAAC;IACH;EACD,CAAC;EAED,MAAMC,WAAwB,GAAG;IAChCC,UAAUA,CAA+BC,IAAY,EAAoB;MACxEP,UAAU,CAAC,CAAC;MACZ,OAAOF,IAAI,CAACQ,UAAU,CAAIC,IAAI,CAAC;IAChC,CAAC;IACDC,WAAWA,CAAA,EAAgB;MAC1BR,UAAU,CAAC,CAAC;MACZ,OAAOF,IAAI,CAACU,WAAW,CAAC,CAAC;IAC1B,CAAC;IACD,MAAMC,KAAKA,CAAA,EAAkB;MAC5BT,UAAU,CAAC,CAAC;MACZD,OAAO,GAAG,IAAI;MACd,MAAMD,IAAI,CAACY,QAAQ,CAAC,CAAC;IACtB;EACD,CAAC;EAED,OAAO;IACNL,WAAW;IACXM,SAAS,EAAEA,CAAA,KAAMZ,OAAO;IACxBa,MAAM,EAAEA,CAAA,KAAM;MACbb,OAAO,GAAG,IAAI;IACf;EACD,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.artifactAvailability = artifactAvailability;
|
|
7
|
+
var _fs = require("../platform/fs.js");
|
|
8
|
+
var _bytes = require("../platform/bytes.js");
|
|
9
|
+
var _chunkedCipher = require("../crypto/chunked-cipher.js");
|
|
10
|
+
var _paths = require("./paths.js");
|
|
11
|
+
var _store = require("./store.js");
|
|
12
|
+
/**
|
|
13
|
+
* "Is this artifact still there?", answered without opening it.
|
|
14
|
+
*
|
|
15
|
+
* `stat()` and, for an encrypted artifact, the 22-byte header. Never a
|
|
16
|
+
* content byte and never a decryption (FR-073e, FR-107b). An availability
|
|
17
|
+
* check that decrypted would make a gallery screen showing fifty thumbnails
|
|
18
|
+
* decrypt fifty artifacts to answer a question none of them asked, and would
|
|
19
|
+
* put key material in play for an operation that does not need it.
|
|
20
|
+
*
|
|
21
|
+
* The four states are deliberately four rather than two. `missing` is data
|
|
22
|
+
* that is gone; `undecryptable` is data that exists under a key that does not
|
|
23
|
+
* open it, which is often recoverable and always a different conversation to
|
|
24
|
+
* have with the user (FR-107c).
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
async function artifactAvailability(context, executor, id) {
|
|
28
|
+
const reference = await (0, _store.readReference)(executor, id);
|
|
29
|
+
if (!reference) {
|
|
30
|
+
// No reference is "missing" rather than an error: the caller asked
|
|
31
|
+
// about an artifact this scope does not claim to have.
|
|
32
|
+
return {
|
|
33
|
+
id,
|
|
34
|
+
state: 'missing'
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const path = (0, _paths.artifactPath)(context.layout, context.scopeKey, id);
|
|
38
|
+
let size;
|
|
39
|
+
try {
|
|
40
|
+
const stat = await (0, _fs.fileSystem)().stat(path);
|
|
41
|
+
if (!stat.isFile()) {
|
|
42
|
+
return {
|
|
43
|
+
id,
|
|
44
|
+
state: 'inaccessible'
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
size = stat.size;
|
|
48
|
+
} catch {
|
|
49
|
+
return {
|
|
50
|
+
id,
|
|
51
|
+
state: 'missing'
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
if (context.artifactKey(id) === null) {
|
|
55
|
+
return {
|
|
56
|
+
id,
|
|
57
|
+
state: 'available',
|
|
58
|
+
size: reference.size
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (size < _chunkedCipher.HEADER_BYTES) {
|
|
62
|
+
return {
|
|
63
|
+
id,
|
|
64
|
+
state: 'undecryptable',
|
|
65
|
+
size: reference.size
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
const header = (0, _bytes.base64ToBytes)(await (0, _fs.fileSystem)().read(path, _chunkedCipher.HEADER_BYTES, 0, 'base64'));
|
|
70
|
+
if ((0, _bytes.asciiAt)(header, 0, 4) !== _chunkedCipher.MAGIC) {
|
|
71
|
+
return {
|
|
72
|
+
id,
|
|
73
|
+
state: 'undecryptable',
|
|
74
|
+
size: reference.size
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
} catch {
|
|
78
|
+
return {
|
|
79
|
+
id,
|
|
80
|
+
state: 'inaccessible',
|
|
81
|
+
size: reference.size
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
id,
|
|
86
|
+
state: 'available',
|
|
87
|
+
size: reference.size
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=availability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_fs","require","_bytes","_chunkedCipher","_paths","_store","artifactAvailability","context","executor","id","reference","readReference","state","path","artifactPath","layout","scopeKey","size","stat","fileSystem","isFile","artifactKey","HEADER_BYTES","header","base64ToBytes","read","asciiAt","MAGIC"],"sourceRoot":"../../../src","sources":["artifacts/availability.ts"],"mappings":";;;;;;AAgBA,IAAAA,GAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AArBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUO,eAAeK,oBAAoBA,CACzCC,OAAwB,EACxBC,QAAkB,EAClBC,EAAU,EACwB;EAClC,MAAMC,SAAS,GAAG,MAAM,IAAAC,oBAAa,EAACH,QAAQ,EAAEC,EAAE,CAAC;EACnD,IAAI,CAACC,SAAS,EAAE;IACf;IACA;IACA,OAAO;MAAED,EAAE;MAAEG,KAAK,EAAE;IAAU,CAAC;EAChC;EAEA,MAAMC,IAAI,GAAG,IAAAC,mBAAY,EAACP,OAAO,CAACQ,MAAM,EAAER,OAAO,CAACS,QAAQ,EAAEP,EAAE,CAAC;EAE/D,IAAIQ,IAAY;EAChB,IAAI;IACH,MAAMC,IAAI,GAAG,MAAM,IAAAC,cAAU,EAAC,CAAC,CAACD,IAAI,CAACL,IAAI,CAAC;IAC1C,IAAI,CAACK,IAAI,CAACE,MAAM,CAAC,CAAC,EAAE;MACnB,OAAO;QAAEX,EAAE;QAAEG,KAAK,EAAE;MAAe,CAAC;IACrC;IACAK,IAAI,GAAGC,IAAI,CAACD,IAAI;EACjB,CAAC,CAAC,MAAM;IACP,OAAO;MAAER,EAAE;MAAEG,KAAK,EAAE;IAAU,CAAC;EAChC;EAEA,IAAIL,OAAO,CAACc,WAAW,CAACZ,EAAE,CAAC,KAAK,IAAI,EAAE;IACrC,OAAO;MAAEA,EAAE;MAAEG,KAAK,EAAE,WAAW;MAAEK,IAAI,EAAEP,SAAS,CAACO;IAAK,CAAC;EACxD;EAEA,IAAIA,IAAI,GAAGK,2BAAY,EAAE;IACxB,OAAO;MAAEb,EAAE;MAAEG,KAAK,EAAE,eAAe;MAAEK,IAAI,EAAEP,SAAS,CAACO;IAAK,CAAC;EAC5D;EAEA,IAAI;IACH,MAAMM,MAAM,GAAG,IAAAC,oBAAa,EAAC,MAAM,IAAAL,cAAU,EAAC,CAAC,CAACM,IAAI,CAACZ,IAAI,EAAES,2BAAY,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC;IACtF,IAAI,IAAAI,cAAO,EAACH,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,KAAKI,oBAAK,EAAE;MACpC,OAAO;QAAElB,EAAE;QAAEG,KAAK,EAAE,eAAe;QAAEK,IAAI,EAAEP,SAAS,CAACO;MAAK,CAAC;IAC5D;EACD,CAAC,CAAC,MAAM;IACP,OAAO;MAAER,EAAE;MAAEG,KAAK,EAAE,cAAc;MAAEK,IAAI,EAAEP,SAAS,CAACO;IAAK,CAAC;EAC3D;EAEA,OAAO;IAAER,EAAE;IAAEG,KAAK,EAAE,WAAW;IAAEK,IAAI,EAAEP,SAAS,CAACO;EAAK,CAAC;AACxD","ignoreList":[]}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.cascadeForOwner = cascadeForOwner;
|
|
7
|
+
exports.unlinkArtifact = unlinkArtifact;
|
|
8
|
+
var _fs = require("../platform/fs.js");
|
|
9
|
+
var _paths = require("./paths.js");
|
|
10
|
+
var _store = require("./store.js");
|
|
11
|
+
/**
|
|
12
|
+
* Cascading artifact removal.
|
|
13
|
+
*
|
|
14
|
+
* The package deletes the files, because the Q2 clarification made it the
|
|
15
|
+
* owner of them (FR-073c). That is the single riskiest thing this package
|
|
16
|
+
* does — POL-011(b)'s media-and-files row exists for it — so two rules hold
|
|
17
|
+
* without exception: every path goes through the boundary guard in
|
|
18
|
+
* `paths.ts`, and the outcome reports what was removed **and what could not
|
|
19
|
+
* be**, never a bare success (FR-071).
|
|
20
|
+
*
|
|
21
|
+
* A failed removal is reported rather than retried or swallowed. A file the
|
|
22
|
+
* package could not delete is still on disk holding the user's data, and an
|
|
23
|
+
* app that told them "deleted" would have said something untrue.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/** Unlinks one artifact file. True when the file is gone afterwards, whoever removed it. */
|
|
27
|
+
async function unlinkArtifact(path) {
|
|
28
|
+
if (await (0, _fs.removeIfPresent)(path)) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
// `removeIfPresent` cannot tell "already gone" from "could not remove". A
|
|
32
|
+
// file that was already gone counts as removed: the end state the caller
|
|
33
|
+
// asked for is the end state they got.
|
|
34
|
+
try {
|
|
35
|
+
return !(await (0, _fs.fileSystem)().exists(path));
|
|
36
|
+
} catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async function removeAll(context, executor, ids, deferred) {
|
|
41
|
+
const removedArtifacts = [];
|
|
42
|
+
const failedRemovals = [];
|
|
43
|
+
for (const id of ids) {
|
|
44
|
+
// The reference first. A reference left pointing at a deleted file is
|
|
45
|
+
// the unrecoverable state; a file left without its reference is an
|
|
46
|
+
// orphan reconciliation finds.
|
|
47
|
+
if (!(await (0, _store.deleteReference)(executor, id))) {
|
|
48
|
+
failedRemovals.push(id);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const path = (0, _paths.artifactPath)(context.layout, context.scopeKey, id);
|
|
52
|
+
if (deferred) {
|
|
53
|
+
deferred.add(path);
|
|
54
|
+
removedArtifacts.push(id);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (await unlinkArtifact(path)) {
|
|
58
|
+
removedArtifacts.push(id);
|
|
59
|
+
} else {
|
|
60
|
+
// Still on disk holding the user's data: reported, never claimed removed.
|
|
61
|
+
failedRemovals.push(id);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
removedRecords: 0,
|
|
66
|
+
removedArtifacts,
|
|
67
|
+
orphanedReferences: [],
|
|
68
|
+
failedRemovals
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Everything belonging to one record, for the FR-070 cascade. Inside a
|
|
74
|
+
* transaction pass `deferred`: the files are removed only once it commits.
|
|
75
|
+
*/
|
|
76
|
+
async function cascadeForOwner(context, executor, owner, deferred) {
|
|
77
|
+
const references = await (0, _store.listReferencesFor)(executor, owner);
|
|
78
|
+
return removeAll(context, executor, references.map(reference => reference.id), deferred);
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=cascade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_fs","require","_paths","_store","unlinkArtifact","path","removeIfPresent","fileSystem","exists","removeAll","context","executor","ids","deferred","removedArtifacts","failedRemovals","id","deleteReference","push","artifactPath","layout","scopeKey","add","removedRecords","orphanedReferences","cascadeForOwner","owner","references","listReferencesFor","map","reference"],"sourceRoot":"../../../src","sources":["artifacts/cascade.ts"],"mappings":";;;;;;;AAgBA,IAAAA,GAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAnBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAeA;AACO,eAAeG,cAAcA,CAACC,IAAY,EAAoB;EACpE,IAAI,MAAM,IAAAC,mBAAe,EAACD,IAAI,CAAC,EAAE;IAChC,OAAO,IAAI;EACZ;EACA;EACA;EACA;EACA,IAAI;IACH,OAAO,EAAE,MAAM,IAAAE,cAAU,EAAC,CAAC,CAACC,MAAM,CAACH,IAAI,CAAC,CAAC;EAC1C,CAAC,CAAC,MAAM;IACP,OAAO,KAAK;EACb;AACD;AAEA,eAAeI,SAASA,CACvBC,OAAwB,EACxBC,QAAkB,EAClBC,GAAa,EACbC,QAA0B,EACC;EAC3B,MAAMC,gBAA0B,GAAG,EAAE;EACrC,MAAMC,cAAwB,GAAG,EAAE;EAEnC,KAAK,MAAMC,EAAE,IAAIJ,GAAG,EAAE;IACrB;IACA;IACA;IACA,IAAI,EAAE,MAAM,IAAAK,sBAAe,EAACN,QAAQ,EAAEK,EAAE,CAAC,CAAC,EAAE;MAC3CD,cAAc,CAACG,IAAI,CAACF,EAAE,CAAC;MACvB;IACD;IACA,MAAMX,IAAI,GAAG,IAAAc,mBAAY,EAACT,OAAO,CAACU,MAAM,EAAEV,OAAO,CAACW,QAAQ,EAAEL,EAAE,CAAC;IAC/D,IAAIH,QAAQ,EAAE;MACbA,QAAQ,CAACS,GAAG,CAACjB,IAAI,CAAC;MAClBS,gBAAgB,CAACI,IAAI,CAACF,EAAE,CAAC;MACzB;IACD;IACA,IAAI,MAAMZ,cAAc,CAACC,IAAI,CAAC,EAAE;MAC/BS,gBAAgB,CAACI,IAAI,CAACF,EAAE,CAAC;IAC1B,CAAC,MAAM;MACN;MACAD,cAAc,CAACG,IAAI,CAACF,EAAE,CAAC;IACxB;EACD;EAEA,OAAO;IACNO,cAAc,EAAE,CAAC;IACjBT,gBAAgB;IAChBU,kBAAkB,EAAE,EAAE;IACtBT;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACO,eAAeU,eAAeA,CACpCf,OAAwB,EACxBC,QAAkB,EAClBe,KAAsB,EACtBb,QAA0B,EACC;EAC3B,MAAMc,UAAU,GAAG,MAAM,IAAAC,wBAAiB,EAACjB,QAAQ,EAAEe,KAAK,CAAC;EAC3D,OAAOjB,SAAS,CACfC,OAAO,EACPC,QAAQ,EACRgB,UAAU,CAACE,GAAG,CAACC,SAAS,IAAIA,SAAS,CAACd,EAAE,CAAC,EACzCH,QACD,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.artifactPath = artifactPath;
|
|
7
|
+
exports.artifactsDirectory = artifactsDirectory;
|
|
8
|
+
var _location = require("../platform/location.js");
|
|
9
|
+
/**
|
|
10
|
+
* Every artifact path, resolved through one guard.
|
|
11
|
+
*
|
|
12
|
+
* POL-011(b) flags media-and-files as a risk precisely because this package
|
|
13
|
+
* deletes files from disk on cascade. The mitigation is structural rather
|
|
14
|
+
* than procedural: no code in `artifacts/` builds a path by string
|
|
15
|
+
* concatenation, and the one function that turns an attachment id into a path
|
|
16
|
+
* refuses anything escaping the managed root (FR-073, FR-073f).
|
|
17
|
+
*
|
|
18
|
+
* That is what makes SC-013a's filesystem tracing pass reliably rather than
|
|
19
|
+
* usually — there is no second path to audit.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
function artifactsDirectory(layout, scopeKey) {
|
|
23
|
+
return (0, _location.assertWithinManagedArea)(layout, layout.scopeArtifactsPath(scopeKey));
|
|
24
|
+
}
|
|
25
|
+
function artifactPath(layout, scopeKey, attachmentId) {
|
|
26
|
+
// `layout.artifactPath` already rejects an id that is not a safe single
|
|
27
|
+
// path segment; the guard then re-checks the assembled result, so a change
|
|
28
|
+
// to either one alone cannot open a hole.
|
|
29
|
+
return (0, _location.assertWithinManagedArea)(layout, layout.artifactPath(scopeKey, attachmentId));
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_location","require","artifactsDirectory","layout","scopeKey","assertWithinManagedArea","scopeArtifactsPath","artifactPath","attachmentId"],"sourceRoot":"../../../src","sources":["artifacts/paths.ts"],"mappings":";;;;;;;AAaA,IAAAA,SAAA,GAAAC,OAAA;AAbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIO,SAASC,kBAAkBA,CAACC,MAAqB,EAAEC,QAAgB,EAAU;EACnF,OAAO,IAAAC,iCAAuB,EAACF,MAAM,EAAEA,MAAM,CAACG,kBAAkB,CAACF,QAAQ,CAAC,CAAC;AAC5E;AAEO,SAASG,YAAYA,CAC3BJ,MAAqB,EACrBC,QAAgB,EAChBI,YAAoB,EACX;EACT;EACA;EACA;EACA,OAAO,IAAAH,iCAAuB,EAACF,MAAM,EAAEA,MAAM,CAACI,YAAY,CAACH,QAAQ,EAAEI,YAAY,CAAC,CAAC;AACpF","ignoreList":[]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.reconcileArtifacts = reconcileArtifacts;
|
|
7
|
+
var _fs = require("../platform/fs.js");
|
|
8
|
+
var _compare = require("../query/compare.js");
|
|
9
|
+
var _paths = require("./paths.js");
|
|
10
|
+
var _store = require("./store.js");
|
|
11
|
+
/**
|
|
12
|
+
* Reconciliation: the two ways the database and the disk can disagree.
|
|
13
|
+
*
|
|
14
|
+
* An **orphaned artifact** is a file with no reference — left by a rolled-back
|
|
15
|
+
* transaction, or by a crash between the write and the insert. A **dangling
|
|
16
|
+
* reference** is the reverse: a row pointing at a file the operating system
|
|
17
|
+
* reclaimed, or the user deleted through a file manager.
|
|
18
|
+
*
|
|
19
|
+
* App-triggered only (FR-073d). A background sweep would run during a user's
|
|
20
|
+
* session without their knowledge, delete files it believes are orphans, and
|
|
21
|
+
* have no way to distinguish "orphan" from "written by a transaction that has
|
|
22
|
+
* not committed yet". Handing the trigger to the app makes that an explicit
|
|
23
|
+
* decision at a moment the app knows is quiet.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
async function filesOnDisk(context) {
|
|
27
|
+
try {
|
|
28
|
+
return await (0, _fs.fileSystem)().readdir((0, _paths.artifactsDirectory)(context.layout, context.scopeKey));
|
|
29
|
+
} catch {
|
|
30
|
+
// No directory means no artifacts, which is a valid answer rather than
|
|
31
|
+
// a failure — a scope that never wrote one never created it.
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async function reconcileArtifacts(context, executor, options = {}) {
|
|
36
|
+
const references = await (0, _store.listReferences)(executor);
|
|
37
|
+
const referenced = new Set(references.map(reference => reference.id));
|
|
38
|
+
const present = new Set(await filesOnDisk(context));
|
|
39
|
+
const orphanedArtifacts = [...present].filter(id => !referenced.has(id)).sort(_compare.byteOrder);
|
|
40
|
+
const danglingReferences = references.filter(reference => !present.has(reference.id)).map(reference => reference.id).sort(_compare.byteOrder);
|
|
41
|
+
const removedArtifacts = [];
|
|
42
|
+
if (options.removeOrphans) {
|
|
43
|
+
for (const id of orphanedArtifacts) {
|
|
44
|
+
if (await (0, _fs.removeIfPresent)((0, _paths.artifactPath)(context.layout, context.scopeKey, id))) {
|
|
45
|
+
removedArtifacts.push(id);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
orphanedArtifacts,
|
|
51
|
+
danglingReferences,
|
|
52
|
+
removedArtifacts
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=reconcile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_fs","require","_compare","_paths","_store","filesOnDisk","context","fileSystem","readdir","artifactsDirectory","layout","scopeKey","reconcileArtifacts","executor","options","references","listReferences","referenced","Set","map","reference","id","present","orphanedArtifacts","filter","has","sort","byteOrder","danglingReferences","removedArtifacts","removeOrphans","removeIfPresent","artifactPath","push"],"sourceRoot":"../../../src","sources":["artifacts/reconcile.ts"],"mappings":";;;;;;AAgBA,IAAAA,GAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AApBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA,eAAeI,WAAWA,CAACC,OAAwB,EAAqB;EACvE,IAAI;IACH,OAAO,MAAM,IAAAC,cAAU,EAAC,CAAC,CAACC,OAAO,CAAC,IAAAC,yBAAkB,EAACH,OAAO,CAACI,MAAM,EAAEJ,OAAO,CAACK,QAAQ,CAAC,CAAC;EACxF,CAAC,CAAC,MAAM;IACP;IACA;IACA,OAAO,EAAE;EACV;AACD;AAEO,eAAeC,kBAAkBA,CACvCN,OAAwB,EACxBO,QAAkB,EAClBC,OAAyB,GAAG,CAAC,CAAC,EACE;EAChC,MAAMC,UAAU,GAAG,MAAM,IAAAC,qBAAc,EAACH,QAAQ,CAAC;EACjD,MAAMI,UAAU,GAAG,IAAIC,GAAG,CAACH,UAAU,CAACI,GAAG,CAACC,SAAS,IAAIA,SAAS,CAACC,EAAE,CAAC,CAAC;EACrE,MAAMC,OAAO,GAAG,IAAIJ,GAAG,CAAC,MAAMb,WAAW,CAACC,OAAO,CAAC,CAAC;EAEnD,MAAMiB,iBAAiB,GAAG,CAAC,GAAGD,OAAO,CAAC,CAACE,MAAM,CAACH,EAAE,IAAI,CAACJ,UAAU,CAACQ,GAAG,CAACJ,EAAE,CAAC,CAAC,CAACK,IAAI,CAACC,kBAAS,CAAC;EACxF,MAAMC,kBAAkB,GAAGb,UAAU,CACnCS,MAAM,CAACJ,SAAS,IAAI,CAACE,OAAO,CAACG,GAAG,CAACL,SAAS,CAACC,EAAE,CAAC,CAAC,CAC/CF,GAAG,CAACC,SAAS,IAAIA,SAAS,CAACC,EAAE,CAAC,CAC9BK,IAAI,CAACC,kBAAS,CAAC;EAEjB,MAAME,gBAA0B,GAAG,EAAE;EACrC,IAAIf,OAAO,CAACgB,aAAa,EAAE;IAC1B,KAAK,MAAMT,EAAE,IAAIE,iBAAiB,EAAE;MACnC,IAAI,MAAM,IAAAQ,mBAAe,EAAC,IAAAC,mBAAY,EAAC1B,OAAO,CAACI,MAAM,EAAEJ,OAAO,CAACK,QAAQ,EAAEU,EAAE,CAAC,CAAC,EAAE;QAC9EQ,gBAAgB,CAACI,IAAI,CAACZ,EAAE,CAAC;MAC1B;IACD;EACD;EAEA,OAAO;IAAEE,iBAAiB;IAAEK,kBAAkB;IAAEC;EAAiB,CAAC;AACnE","ignoreList":[]}
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.deleteReference = deleteReference;
|
|
7
|
+
exports.ensureAttachmentTable = ensureAttachmentTable;
|
|
8
|
+
exports.listReferences = listReferences;
|
|
9
|
+
exports.listReferencesFor = listReferencesFor;
|
|
10
|
+
exports.readArtifact = readArtifact;
|
|
11
|
+
exports.readReference = readReference;
|
|
12
|
+
exports.removeArtifact = removeArtifact;
|
|
13
|
+
exports.writeArtifact = writeArtifact;
|
|
14
|
+
var _config = require("../contract/config.js");
|
|
15
|
+
var _errors = require("../contract/errors.js");
|
|
16
|
+
var _errors2 = require("../diagnostics/errors.js");
|
|
17
|
+
var _faults = require("../diagnostics/faults.js");
|
|
18
|
+
var _mapNative = require("../diagnostics/map-native.js");
|
|
19
|
+
var _fs = require("../platform/fs.js");
|
|
20
|
+
var _bytes = require("../platform/bytes.js");
|
|
21
|
+
var _budgets = require("../query/budgets.js");
|
|
22
|
+
var _chunkedCipher = require("../crypto/chunked-cipher.js");
|
|
23
|
+
var _values = require("../sqlite/values.js");
|
|
24
|
+
var _paths = require("./paths.js");
|
|
25
|
+
/**
|
|
26
|
+
* Artifacts: the file on disk and the reference to it.
|
|
27
|
+
*
|
|
28
|
+
* The reference lives in the scope's own database, so a reference created
|
|
29
|
+
* inside a transaction rolls back with it (FR-072) — no bookkeeping required,
|
|
30
|
+
* because the connection routes through the transaction in flight.
|
|
31
|
+
*
|
|
32
|
+
* The file does not roll back. A filesystem write is not part of a SQL
|
|
33
|
+
* transaction and cannot be made part of one, so a rolled-back transaction
|
|
34
|
+
* leaves an artifact on disk with nothing pointing at it. That is not a bug
|
|
35
|
+
* to be engineered away; it is why reconciliation exists (FR-073d), and why
|
|
36
|
+
* the write order is deliberate: **the file completes first, then the
|
|
37
|
+
* reference**. The reverse order would produce a reference to a file that
|
|
38
|
+
* does not exist, which is the failure a consumer cannot recover from — it
|
|
39
|
+
* looks like data the app has and does not.
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
const CREATE_ATTACHMENTS = `CREATE TABLE IF NOT EXISTS _attachments (
|
|
43
|
+
id TEXT PRIMARY KEY,
|
|
44
|
+
owner_collection TEXT,
|
|
45
|
+
owner_id TEXT,
|
|
46
|
+
content_type TEXT NOT NULL,
|
|
47
|
+
size INTEGER NOT NULL,
|
|
48
|
+
chunk_size INTEGER,
|
|
49
|
+
chunk_count INTEGER,
|
|
50
|
+
created_at INTEGER NOT NULL
|
|
51
|
+
)`;
|
|
52
|
+
const CREATE_OWNER_INDEX = 'CREATE INDEX IF NOT EXISTS _attachments_owner ON _attachments (owner_collection, owner_id)';
|
|
53
|
+
async function ensureAttachmentTable(executor) {
|
|
54
|
+
await executor.execute(CREATE_ATTACHMENTS);
|
|
55
|
+
await executor.execute(CREATE_OWNER_INDEX);
|
|
56
|
+
}
|
|
57
|
+
function toReference(row) {
|
|
58
|
+
const reference = {
|
|
59
|
+
id: (0, _values.text)(row.id),
|
|
60
|
+
contentType: (0, _values.text)(row.content_type),
|
|
61
|
+
size: (0, _values.num)(row.size),
|
|
62
|
+
createdAt: (0, _values.num)(row.created_at)
|
|
63
|
+
};
|
|
64
|
+
if (row.owner_collection != null && row.owner_id != null) {
|
|
65
|
+
reference.owner = {
|
|
66
|
+
collection: (0, _values.text)(row.owner_collection),
|
|
67
|
+
id: (0, _values.text)(row.owner_id)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const chunkSize = (0, _values.maybeNum)(row.chunk_size);
|
|
71
|
+
if (chunkSize !== null) {
|
|
72
|
+
reference.chunkSize = chunkSize;
|
|
73
|
+
reference.chunkCount = (0, _values.num)(row.chunk_count);
|
|
74
|
+
}
|
|
75
|
+
return reference;
|
|
76
|
+
}
|
|
77
|
+
async function readReference(executor, id) {
|
|
78
|
+
const result = await executor.execute('SELECT * FROM _attachments WHERE id = ?', [id]);
|
|
79
|
+
const row = result.rows[0];
|
|
80
|
+
return row ? toReference(row) : null;
|
|
81
|
+
}
|
|
82
|
+
async function listReferences(executor) {
|
|
83
|
+
const result = await executor.execute('SELECT * FROM _attachments ORDER BY id ASC');
|
|
84
|
+
return result.rows.map(toReference);
|
|
85
|
+
}
|
|
86
|
+
async function listReferencesFor(executor, owner) {
|
|
87
|
+
const result = await executor.execute('SELECT * FROM _attachments WHERE owner_collection = ? AND owner_id = ? ORDER BY id ASC', [owner.collection, owner.id]);
|
|
88
|
+
return result.rows.map(toReference);
|
|
89
|
+
}
|
|
90
|
+
async function insertReference(executor, reference) {
|
|
91
|
+
await executor.execute(`INSERT INTO _attachments
|
|
92
|
+
(id, owner_collection, owner_id, content_type, size, chunk_size, chunk_count, created_at)
|
|
93
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
94
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
95
|
+
owner_collection = excluded.owner_collection,
|
|
96
|
+
owner_id = excluded.owner_id,
|
|
97
|
+
content_type = excluded.content_type,
|
|
98
|
+
size = excluded.size,
|
|
99
|
+
chunk_size = excluded.chunk_size,
|
|
100
|
+
chunk_count = excluded.chunk_count,
|
|
101
|
+
created_at = excluded.created_at`, [reference.id, reference.owner?.collection ?? null, reference.owner?.id ?? null, reference.contentType, reference.size, reference.chunkSize ?? null, reference.chunkCount ?? null, reference.createdAt]);
|
|
102
|
+
}
|
|
103
|
+
async function deleteReference(executor, id) {
|
|
104
|
+
const result = await executor.execute('DELETE FROM _attachments WHERE id = ?', [id]);
|
|
105
|
+
return result.rowsAffected > 0;
|
|
106
|
+
}
|
|
107
|
+
async function writePlaintext(path, content) {
|
|
108
|
+
await (0, _fs.fileSystem)().writeFile(path, content, 'base64');
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Where an artifact's bytes come from: how many, and any one chunk of them. */
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Encrypted write, one chunk in flight.
|
|
115
|
+
*
|
|
116
|
+
* The header goes down first because its contents — chunk size, chunk count,
|
|
117
|
+
* plaintext length — are all known from the input length before any
|
|
118
|
+
* encryption happens. Only the tags depend on the ciphertext, and they follow
|
|
119
|
+
* their own chunk, so the whole write is append-only and peak memory is one
|
|
120
|
+
* chunk regardless of artifact size when the source is a file (FR-107a).
|
|
121
|
+
*/
|
|
122
|
+
async function writeEncrypted(path, key, source) {
|
|
123
|
+
const header = (0, _chunkedCipher.headerFor)(source.size, _config.Budgets.ARTIFACT_CHUNK_BYTES);
|
|
124
|
+
await (0, _fs.fileSystem)().writeFile(path, (0, _bytes.bytesToBase64)((0, _chunkedCipher.encodeHeader)(header)), 'base64');
|
|
125
|
+
for (let index = 0; index < header.chunkCount; index += 1) {
|
|
126
|
+
const chunk = await source.chunk(index * header.chunkSize, (0, _chunkedCipher.chunkPlaintextLength)(header, index));
|
|
127
|
+
await (0, _fs.fileSystem)().appendFile(path, (0, _bytes.bytesToBase64)((0, _chunkedCipher.encryptChunk)(key, index, chunk)), 'base64');
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
chunkSize: header.chunkSize,
|
|
131
|
+
chunkCount: header.chunkCount
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function sourceFileOf(input) {
|
|
135
|
+
if (typeof input.sourcePath !== 'string') {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
return input.sourcePath.startsWith('file://') ? input.sourcePath.slice('file://'.length) : input.sourcePath;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* The input as something to read from. A base64 `content` is decoded whole,
|
|
143
|
+
* which is the cost of that form; a `sourcePath` is only measured here and
|
|
144
|
+
* read a chunk at a time, or not read by JS at all (LDB-09).
|
|
145
|
+
*/
|
|
146
|
+
async function byteSourceFor(input) {
|
|
147
|
+
const file = sourceFileOf(input);
|
|
148
|
+
if (file === null) {
|
|
149
|
+
if (typeof input.content !== 'string') {
|
|
150
|
+
(0, _errors2.raise)(_errors.DiagnosticCodes.CONFIG_INVALID, {
|
|
151
|
+
message: 'an attachment needs content or sourcePath',
|
|
152
|
+
detail: {
|
|
153
|
+
attachmentId: input.id
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
const plaintext = (0, _bytes.base64ToBytes)(input.content);
|
|
158
|
+
return {
|
|
159
|
+
size: plaintext.length,
|
|
160
|
+
chunk: async (offset, length) => plaintext.subarray(offset, offset + length)
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
let size;
|
|
164
|
+
try {
|
|
165
|
+
size = (await (0, _fs.fileSystem)().stat(file)).size;
|
|
166
|
+
} catch (error) {
|
|
167
|
+
(0, _mapNative.raiseNative)(error, {
|
|
168
|
+
operation: 'attachment'
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
size,
|
|
173
|
+
chunk: async (offset, length) => (0, _bytes.base64ToBytes)(await (0, _fs.fileSystem)().read(file, length, offset, 'base64'))
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
async function writeArtifact(context, input) {
|
|
177
|
+
(0, _faults.throwIfFaulted)('attachmentWrite');
|
|
178
|
+
const source = await byteSourceFor(input);
|
|
179
|
+
(0, _budgets.assertArtifactWithinBudget)(input.id, source.size);
|
|
180
|
+
const path = (0, _paths.artifactPath)(context.layout, context.scopeKey, input.id);
|
|
181
|
+
const key = context.artifactKey(input.id);
|
|
182
|
+
const file = sourceFileOf(input);
|
|
183
|
+
let chunking;
|
|
184
|
+
try {
|
|
185
|
+
await (0, _fs.fileSystem)().mkdir((0, _paths.artifactsDirectory)(context.layout, context.scopeKey));
|
|
186
|
+
if (key) {
|
|
187
|
+
chunking = await writeEncrypted(path, key, source);
|
|
188
|
+
} else if (file !== null) {
|
|
189
|
+
await (0, _fs.fileSystem)().copyFile(file, path);
|
|
190
|
+
} else {
|
|
191
|
+
await writePlaintext(path, input.content);
|
|
192
|
+
}
|
|
193
|
+
} catch (error) {
|
|
194
|
+
// A partial file with no reference is an orphan reconciliation can
|
|
195
|
+
// find; a reference to a partial file is data the app believes it has.
|
|
196
|
+
await (0, _fs.removeIfPresent)(path);
|
|
197
|
+
(0, _mapNative.raiseNative)(error, {
|
|
198
|
+
operation: 'attachment'
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
const reference = {
|
|
202
|
+
id: input.id,
|
|
203
|
+
contentType: input.contentType,
|
|
204
|
+
size: source.size,
|
|
205
|
+
createdAt: context.now()
|
|
206
|
+
};
|
|
207
|
+
if (input.owner) {
|
|
208
|
+
reference.owner = input.owner;
|
|
209
|
+
}
|
|
210
|
+
if (chunking) {
|
|
211
|
+
reference.chunkSize = chunking.chunkSize;
|
|
212
|
+
reference.chunkCount = chunking.chunkCount;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Only now. See the note at the top of this file.
|
|
216
|
+
await insertReference(context.executor(), reference);
|
|
217
|
+
return reference;
|
|
218
|
+
}
|
|
219
|
+
async function readPlaintext(path, range) {
|
|
220
|
+
if (!range) {
|
|
221
|
+
return (0, _fs.fileSystem)().readFile(path, 'base64');
|
|
222
|
+
}
|
|
223
|
+
return (0, _fs.fileSystem)().read(path, range.length, range.offset, 'base64');
|
|
224
|
+
}
|
|
225
|
+
async function readEncrypted(path, key, range) {
|
|
226
|
+
const headerBytes = (0, _bytes.base64ToBytes)(await (0, _fs.fileSystem)().read(path, _chunkedCipher.HEADER_BYTES, 0, 'base64'));
|
|
227
|
+
const header = (0, _chunkedCipher.decodeHeader)(headerBytes);
|
|
228
|
+
const from = range?.offset ?? 0;
|
|
229
|
+
const to = range ? Math.min(header.plaintextSize, from + range.length) : header.plaintextSize;
|
|
230
|
+
if (to <= from) {
|
|
231
|
+
return '';
|
|
232
|
+
}
|
|
233
|
+
const first = Math.floor(from / header.chunkSize);
|
|
234
|
+
const last = Math.floor((to - 1) / header.chunkSize);
|
|
235
|
+
const pieces = [];
|
|
236
|
+
for (let index = first; index <= last; index += 1) {
|
|
237
|
+
const stored = (0, _bytes.base64ToBytes)(await (0, _fs.fileSystem)().read(path, (0, _chunkedCipher.chunkPlaintextLength)(header, index) + _chunkedCipher.TAG_BYTES, (0, _chunkedCipher.chunkOffset)(header, index), 'base64'));
|
|
238
|
+
const decrypted = (0, _chunkedCipher.decryptChunk)(key, index, stored);
|
|
239
|
+
const chunkStart = index * header.chunkSize;
|
|
240
|
+
pieces.push(decrypted.subarray(Math.max(0, from - chunkStart), Math.min(decrypted.length, to - chunkStart)));
|
|
241
|
+
}
|
|
242
|
+
return (0, _bytes.bytesToBase64)((0, _bytes.concatBytes)(pieces));
|
|
243
|
+
}
|
|
244
|
+
async function readArtifact(context, id, range) {
|
|
245
|
+
const path = (0, _paths.artifactPath)(context.layout, context.scopeKey, id);
|
|
246
|
+
const key = context.artifactKey(id);
|
|
247
|
+
try {
|
|
248
|
+
return key ? await readEncrypted(path, key, range) : await readPlaintext(path, range);
|
|
249
|
+
} catch (error) {
|
|
250
|
+
// A typed error the package already classified — an unreadable header,
|
|
251
|
+
// a failing tag — says something more specific than "missing" and must
|
|
252
|
+
// survive. Anything else reaching here is the file not being there.
|
|
253
|
+
if ((0, _errors2.isStorageError)(error)) {
|
|
254
|
+
throw error;
|
|
255
|
+
}
|
|
256
|
+
(0, _errors2.raise)(_errors.DiagnosticCodes.ATTACHMENT_MISSING, {
|
|
257
|
+
message: 'artifact is missing',
|
|
258
|
+
detail: {
|
|
259
|
+
attachmentId: id
|
|
260
|
+
},
|
|
261
|
+
cause: error
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Collects file removals until the transaction that deleted their references
|
|
268
|
+
* commits. A file unlinked inside the transaction is gone even if the
|
|
269
|
+
* transaction then rolls back and the reference returns — a dangling
|
|
270
|
+
* reference to data nobody can recover.
|
|
271
|
+
*/
|
|
272
|
+
|
|
273
|
+
async function removeArtifact(context, id, deferred) {
|
|
274
|
+
const path = (0, _paths.artifactPath)(context.layout, context.scopeKey, id);
|
|
275
|
+
if (deferred) {
|
|
276
|
+
// Inside a transaction: the reference goes now and rolls back with it;
|
|
277
|
+
// the file goes once the transaction commits.
|
|
278
|
+
const hadReference = await deleteReference(context.executor(), id);
|
|
279
|
+
if (hadReference) {
|
|
280
|
+
deferred.add(path);
|
|
281
|
+
}
|
|
282
|
+
return {
|
|
283
|
+
removedRecords: 0,
|
|
284
|
+
removedArtifacts: hadReference ? [id] : [],
|
|
285
|
+
orphanedReferences: [],
|
|
286
|
+
failedRemovals: []
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
const removed = await (0, _fs.removeIfPresent)(path);
|
|
290
|
+
const hadReference = await deleteReference(context.executor(), id);
|
|
291
|
+
return {
|
|
292
|
+
removedRecords: 0,
|
|
293
|
+
removedArtifacts: removed ? [id] : [],
|
|
294
|
+
// A reference with no file left behind is worth reporting rather than
|
|
295
|
+
// rounding up to success (FR-071).
|
|
296
|
+
orphanedReferences: !removed && hadReference ? [id] : [],
|
|
297
|
+
failedRemovals: []
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
//# sourceMappingURL=store.js.map
|