@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,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.fileSystem = fileSystem;
|
|
7
|
+
exports.removeIfPresent = removeIfPresent;
|
|
8
|
+
exports.setFileSystem = setFileSystem;
|
|
9
|
+
var _rnCore = require("@chipmobilesdk/rn-core");
|
|
10
|
+
var _errors = require("../contract/errors.js");
|
|
11
|
+
var _errors2 = require("../diagnostics/errors.js");
|
|
12
|
+
/**
|
|
13
|
+
* The filesystem peer, behind one lazy accessor.
|
|
14
|
+
*
|
|
15
|
+
* Required lazily for the same reason the engine is: a consuming app that
|
|
16
|
+
* only ever runs the in-memory adapter in tests must not have to install a
|
|
17
|
+
* native module to import this package. Confining the require to `platform/`
|
|
18
|
+
* also keeps the native surface four directories wide, which is the layering
|
|
19
|
+
* rule the ESLint config enforces.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Only what the package actually uses. The peer's upload and download
|
|
24
|
+
* helpers are deliberately absent from this type: the package must never
|
|
25
|
+
* make a network request (FR-084, SC-016), and a surface that cannot express
|
|
26
|
+
* one is a stronger guarantee than a rule that says not to.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/** Loaded on first use (rn-core's lazy peer); a missing peer is `STORAGE_ACCESS`. */
|
|
30
|
+
const fs = (0, _rnCore.lazyPeer)('@dr.pogodin/react-native-fs', () => {
|
|
31
|
+
// Inside `try`, so Metro bundles an app that leaves this optional peer out.
|
|
32
|
+
try {
|
|
33
|
+
return require('@dr.pogodin/react-native-fs');
|
|
34
|
+
} catch (cause) {
|
|
35
|
+
throw cause;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
/** Swap the peer. Tests and the demo app's in-memory mode only; `null` restores it. */
|
|
40
|
+
function setFileSystem(module) {
|
|
41
|
+
fs.override(module ?? undefined);
|
|
42
|
+
}
|
|
43
|
+
function fileSystem() {
|
|
44
|
+
return fs.require((_peer, cause) => new _errors2.StorageError(_errors.DiagnosticCodes.STORAGE_ACCESS, {
|
|
45
|
+
message: 'filesystem peer is not installed',
|
|
46
|
+
cause
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Remove a path, treating "already gone" as success (FR-062). */
|
|
51
|
+
async function removeIfPresent(path) {
|
|
52
|
+
try {
|
|
53
|
+
await fileSystem().unlink(path);
|
|
54
|
+
return true;
|
|
55
|
+
} catch {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=fs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_rnCore","require","_errors","_errors2","fs","lazyPeer","cause","setFileSystem","module","override","undefined","fileSystem","_peer","StorageError","DiagnosticCodes","STORAGE_ACCESS","message","removeIfPresent","path","unlink"],"sourceRoot":"../../../src","sources":["platform/fs.ts"],"mappings":";;;;;;;;AAUA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAoBA;AACA;AACA;AACA;AACA;AACA;;AAiBA;AACA,MAAMG,EAAE,GAAG,IAAAC,gBAAQ,EAAC,6BAA6B,EAAE,MAAM;EACxD;EACA,IAAI;IACH,OAAOJ,OAAO,CAAC,6BAA6B,CAAC;EAC9C,CAAC,CAAC,OAAOK,KAAK,EAAE;IACf,MAAMA,KAAK;EACZ;AACD,CAAC,CAAC;;AAEF;AACO,SAASC,aAAaA,CAACC,MAAyB,EAAQ;EAC9DJ,EAAE,CAACK,QAAQ,CAACD,MAAM,IAAIE,SAAS,CAAC;AACjC;AAEO,SAASC,UAAUA,CAAA,EAAe;EACxC,OAAOP,EAAE,CAACH,OAAO,CAChB,CAACW,KAAK,EAAEN,KAAK,KACZ,IAAIO,qBAAY,CAACC,uBAAe,CAACC,cAAc,EAAE;IAChDC,OAAO,EAAE,kCAAkC;IAC3CV;EACD,CAAC,CACH,CAAC;AACF;;AAEA;AACO,eAAeW,eAAeA,CAACC,IAAY,EAAoB;EACrE,IAAI;IACH,MAAMP,UAAU,CAAC,CAAC,CAACQ,MAAM,CAACD,IAAI,CAAC;IAC/B,OAAO,IAAI;EACZ,CAAC,CAAC,MAAM;IACP,OAAO,KAAK;EACb;AACD","ignoreList":[]}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SCOPES_DIR = exports.MANAGED_ROOT_NAME = exports.DATA_FILE = exports.CATALOG_FILE = exports.ARTIFACTS_DIR = void 0;
|
|
7
|
+
exports.assertValidAttachmentId = assertValidAttachmentId;
|
|
8
|
+
exports.assertWithinManagedArea = assertWithinManagedArea;
|
|
9
|
+
exports.createLayout = createLayout;
|
|
10
|
+
exports.layoutFor = layoutFor;
|
|
11
|
+
exports.normalizePath = normalizePath;
|
|
12
|
+
var _errors = require("../contract/errors.js");
|
|
13
|
+
var _errors2 = require("../diagnostics/errors.js");
|
|
14
|
+
var _fs = require("./fs.js");
|
|
15
|
+
/**
|
|
16
|
+
* The managed storage area, and the single guard every filesystem call routes
|
|
17
|
+
* through.
|
|
18
|
+
*
|
|
19
|
+
* POL-011(b) flags media-and-files as a risk because this package deletes
|
|
20
|
+
* files from disk on cascade. The mitigation is that there is exactly one
|
|
21
|
+
* function that turns a caller's intent into a path, and it refuses anything
|
|
22
|
+
* outside the root. One choke point is what makes SC-013a's filesystem
|
|
23
|
+
* tracing pass reliably rather than usually.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
const MANAGED_ROOT_NAME = exports.MANAGED_ROOT_NAME = 'chipmobilesdk-localdb';
|
|
27
|
+
const CATALOG_FILE = exports.CATALOG_FILE = 'catalog.db';
|
|
28
|
+
const SCOPES_DIR = exports.SCOPES_DIR = 'scopes';
|
|
29
|
+
const DATA_FILE = exports.DATA_FILE = 'data.db';
|
|
30
|
+
const ARTIFACTS_DIR = exports.ARTIFACTS_DIR = 'artifacts';
|
|
31
|
+
|
|
32
|
+
/** Normalize separators and collapse redundant segments. No `..` survives. */
|
|
33
|
+
function normalizePath(path) {
|
|
34
|
+
const unified = path.replace(/\\/g, '/');
|
|
35
|
+
const segments = [];
|
|
36
|
+
for (const segment of unified.split('/')) {
|
|
37
|
+
if (segment === '' || segment === '.') {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (segment === '..') {
|
|
41
|
+
segments.pop();
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
segments.push(segment);
|
|
45
|
+
}
|
|
46
|
+
const prefix = unified.startsWith('/') ? '/' : '';
|
|
47
|
+
return prefix + segments.join('/');
|
|
48
|
+
}
|
|
49
|
+
const SCOPE_KEY = /^[0-9a-f]{64}$/;
|
|
50
|
+
const ARTIFACT_ID = /^[A-Za-z0-9._-]{1,128}$/;
|
|
51
|
+
// `.` and `..` are made entirely of permitted characters and are the two that
|
|
52
|
+
// matter: `artifacts/..` resolves to the scope directory itself, still inside
|
|
53
|
+
// the managed root, so the boundary guard would wave it through and a cascade
|
|
54
|
+
// would unlink the whole scope. A leading dot is refused with them, since no
|
|
55
|
+
// attachment id needs one and hidden files are the package's own.
|
|
56
|
+
const DOT_PREFIXED = /^\./;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* An attachment id must be a safe single path segment.
|
|
60
|
+
*
|
|
61
|
+
* Shared by both adapters rather than left to the one that touches a
|
|
62
|
+
* filesystem. The in-memory adapter has no paths to escape, but a consumer
|
|
63
|
+
* whose tests accept `../../etc/passwd` and whose device build refuses it has
|
|
64
|
+
* a test suite that stops predicting the device — which is the one thing the
|
|
65
|
+
* adapter exists to avoid (FR-096).
|
|
66
|
+
*/
|
|
67
|
+
function assertValidAttachmentId(attachmentId) {
|
|
68
|
+
if (!ARTIFACT_ID.test(attachmentId) || DOT_PREFIXED.test(attachmentId)) {
|
|
69
|
+
(0, _errors2.raise)(_errors.DiagnosticCodes.ATTACHMENT_OUT_OF_BOUNDS, {
|
|
70
|
+
message: 'attachment id is not a valid path segment'
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function createLayout(documentDirectory, databaseName) {
|
|
75
|
+
const root = normalizePath(`${documentDirectory}/${MANAGED_ROOT_NAME}/${databaseName}`);
|
|
76
|
+
const scopePath = scopeKey => {
|
|
77
|
+
// The scope key is our own SHA-256 output. Validating its shape here
|
|
78
|
+
// means a caller cannot smuggle a traversal through it even if some
|
|
79
|
+
// future path reaches this function with unvalidated input.
|
|
80
|
+
if (!SCOPE_KEY.test(scopeKey)) {
|
|
81
|
+
(0, _errors2.raise)(_errors.DiagnosticCodes.ATTACHMENT_OUT_OF_BOUNDS, {
|
|
82
|
+
message: 'scope key is not a valid digest'
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return `${root}/${SCOPES_DIR}/${scopeKey}`;
|
|
86
|
+
};
|
|
87
|
+
return {
|
|
88
|
+
root,
|
|
89
|
+
catalogPath: `${root}/${CATALOG_FILE}`,
|
|
90
|
+
scopePath,
|
|
91
|
+
scopeDataPath: scopeKey => `${scopePath(scopeKey)}/${DATA_FILE}`,
|
|
92
|
+
scopeArtifactsPath: scopeKey => `${scopePath(scopeKey)}/${ARTIFACTS_DIR}`,
|
|
93
|
+
artifactPath: (scopeKey, attachmentId) => {
|
|
94
|
+
assertValidAttachmentId(attachmentId);
|
|
95
|
+
return `${scopePath(scopeKey)}/${ARTIFACTS_DIR}/${attachmentId}`;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The layout for one logical database, rooted at the app's private documents
|
|
102
|
+
* directory.
|
|
103
|
+
*
|
|
104
|
+
* Resolved lazily through the filesystem peer rather than captured at module
|
|
105
|
+
* load, so importing this package does not require the peer to be installed —
|
|
106
|
+
* a consumer running only the in-memory adapter never reaches this function.
|
|
107
|
+
*/
|
|
108
|
+
function layoutFor(databaseName) {
|
|
109
|
+
return createLayout((0, _fs.fileSystem)().DocumentDirectoryPath, databaseName);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The guard. Every read, write, and delete passes through this, and anything
|
|
114
|
+
* resolving outside the managed root is refused before it reaches the
|
|
115
|
+
* filesystem (FR-073, FR-073f).
|
|
116
|
+
*/
|
|
117
|
+
function assertWithinManagedArea(layout, candidate) {
|
|
118
|
+
const normalized = normalizePath(candidate);
|
|
119
|
+
const root = normalizePath(layout.root);
|
|
120
|
+
if (normalized !== root && !normalized.startsWith(`${root}/`)) {
|
|
121
|
+
(0, _errors2.raise)(_errors.DiagnosticCodes.ATTACHMENT_OUT_OF_BOUNDS, {
|
|
122
|
+
// The offending path is NOT reported: it may contain a scope
|
|
123
|
+
// component or a user-chosen filename.
|
|
124
|
+
message: 'path resolves outside the managed storage area'
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
return normalized;
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=location.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_errors","require","_errors2","_fs","MANAGED_ROOT_NAME","exports","CATALOG_FILE","SCOPES_DIR","DATA_FILE","ARTIFACTS_DIR","normalizePath","path","unified","replace","segments","segment","split","pop","push","prefix","startsWith","join","SCOPE_KEY","ARTIFACT_ID","DOT_PREFIXED","assertValidAttachmentId","attachmentId","test","raise","DiagnosticCodes","ATTACHMENT_OUT_OF_BOUNDS","message","createLayout","documentDirectory","databaseName","root","scopePath","scopeKey","catalogPath","scopeDataPath","scopeArtifactsPath","artifactPath","layoutFor","fileSystem","DocumentDirectoryPath","assertWithinManagedArea","layout","candidate","normalized"],"sourceRoot":"../../../src","sources":["platform/location.ts"],"mappings":";;;;;;;;;;;AAWA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,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;AACA;AACA;AACA;AACA;AACO,SAASW,uBAAuBA,CAACC,MAAqB,EAAEC,SAAiB,EAAU;EACzF,MAAMC,UAAU,GAAGtC,aAAa,CAACqC,SAAS,CAAC;EAC3C,MAAMZ,IAAI,GAAGzB,aAAa,CAACoC,MAAM,CAACX,IAAI,CAAC;EACvC,IAAIa,UAAU,KAAKb,IAAI,IAAI,CAACa,UAAU,CAAC5B,UAAU,CAAC,GAAGe,IAAI,GAAG,CAAC,EAAE;IAC9D,IAAAP,cAAK,EAACC,uBAAe,CAACC,wBAAwB,EAAE;MAC/C;MACA;MACAC,OAAO,EAAE;IACV,CAAC,CAAC;EACH;EACA,OAAOiB,UAAU;AAClB","ignoreList":[]}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.assertArtifactWithinBudget = assertArtifactWithinBudget;
|
|
7
|
+
exports.assertBatchWithinBudget = assertBatchWithinBudget;
|
|
8
|
+
exports.assertRecordWithinBudget = assertRecordWithinBudget;
|
|
9
|
+
exports.serializedSize = serializedSize;
|
|
10
|
+
exports.utf8Length = utf8Length;
|
|
11
|
+
var _config = require("../contract/config.js");
|
|
12
|
+
var _errors = require("../contract/errors.js");
|
|
13
|
+
var _errors2 = require("../diagnostics/errors.js");
|
|
14
|
+
/**
|
|
15
|
+
* Budget enforcement.
|
|
16
|
+
*
|
|
17
|
+
* Per-record size, page size, and batch size are HARD limits reported through
|
|
18
|
+
* typed errors (FR-088a). The rest are soft: exceeding them must not crash,
|
|
19
|
+
* hang, or drop data silently, and the degraded behavior is documented.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* UTF-8 length of a string, counted rather than encoded: measuring a 256 KB
|
|
24
|
+
* record used to allocate a 256 KB byte array just to read its length.
|
|
25
|
+
*/
|
|
26
|
+
function utf8Length(value) {
|
|
27
|
+
let bytes = 0;
|
|
28
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
29
|
+
const unit = value.charCodeAt(index);
|
|
30
|
+
if (unit < 0x80) {
|
|
31
|
+
bytes += 1;
|
|
32
|
+
} else if (unit < 0x800) {
|
|
33
|
+
bytes += 2;
|
|
34
|
+
} else if (unit >= 0xd800 && unit <= 0xdbff && index + 1 < value.length) {
|
|
35
|
+
// A surrogate pair is one four-byte code point.
|
|
36
|
+
bytes += 4;
|
|
37
|
+
index += 1;
|
|
38
|
+
} else {
|
|
39
|
+
bytes += 3;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return bytes;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** UTF-8 byte length of the serialized payload — what actually hits disk. */
|
|
46
|
+
function serializedSize(data) {
|
|
47
|
+
return utf8Length(JSON.stringify(data ?? {}));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Checks the size budget and returns the serialized payload, so the write that
|
|
52
|
+
* follows stores this string instead of serializing the record a second time.
|
|
53
|
+
*/
|
|
54
|
+
function assertRecordWithinBudget(collection, data) {
|
|
55
|
+
const payload = JSON.stringify(data ?? {});
|
|
56
|
+
const size = utf8Length(payload);
|
|
57
|
+
if (size > _config.Budgets.MAX_RECORD_BYTES) {
|
|
58
|
+
// Truncating would be silent data loss; failing opaquely would leave
|
|
59
|
+
// the consumer guessing. The size and the limit are both safe to
|
|
60
|
+
// report — neither can carry a field value.
|
|
61
|
+
(0, _errors2.raise)(_errors.DiagnosticCodes.RECORD_TOO_LARGE, {
|
|
62
|
+
message: 'record exceeds the per-record size budget',
|
|
63
|
+
detail: {
|
|
64
|
+
collection,
|
|
65
|
+
sizeBytes: size,
|
|
66
|
+
limitBytes: _config.Budgets.MAX_RECORD_BYTES
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return payload;
|
|
71
|
+
}
|
|
72
|
+
function assertBatchWithinBudget(count) {
|
|
73
|
+
if (count > _config.Budgets.MAX_BATCH_OPERATIONS) {
|
|
74
|
+
(0, _errors2.raise)(_errors.DiagnosticCodes.BATCH_TOO_LARGE, {
|
|
75
|
+
message: 'batch exceeds the operation budget',
|
|
76
|
+
detail: {
|
|
77
|
+
count,
|
|
78
|
+
limit: _config.Budgets.MAX_BATCH_OPERATIONS
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function assertArtifactWithinBudget(id, size) {
|
|
84
|
+
if (size > _config.Budgets.MAX_ARTIFACT_BYTES) {
|
|
85
|
+
(0, _errors2.raise)(_errors.DiagnosticCodes.ATTACHMENT_WRITE_FAILED, {
|
|
86
|
+
message: 'artifact exceeds the size budget',
|
|
87
|
+
detail: {
|
|
88
|
+
attachmentId: id,
|
|
89
|
+
sizeBytes: size,
|
|
90
|
+
limitBytes: _config.Budgets.MAX_ARTIFACT_BYTES
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=budgets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_config","require","_errors","_errors2","utf8Length","value","bytes","index","length","unit","charCodeAt","serializedSize","data","JSON","stringify","assertRecordWithinBudget","collection","payload","size","Budgets","MAX_RECORD_BYTES","raise","DiagnosticCodes","RECORD_TOO_LARGE","message","detail","sizeBytes","limitBytes","assertBatchWithinBudget","count","MAX_BATCH_OPERATIONS","BATCH_TOO_LARGE","limit","assertArtifactWithinBudget","id","MAX_ARTIFACT_BYTES","ATTACHMENT_WRITE_FAILED","attachmentId"],"sourceRoot":"../../../src","sources":["query/budgets.ts"],"mappings":";;;;;;;;;;AAQA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AAXA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACO,SA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,OAAOH,OAAO;AACf;AAEO,SAASW,uBAAuBA,CAACC,KAAa,EAAQ;EAC5D,IAAIA,KAAK,GAAGV,eAAO,CAACW,oBAAoB,EAAE;IACzC,IAAAT,cAAK,EAACC,uBAAe,CAACS,eAAe,EAAE;MACtCP,OAAO,EAAE,oCAAoC;MAC7CC,MAAM,EAAE;QAAEI,KAAK;QAAEG,KAAK,EAAEb,eAAO,CAACW;MAAqB;IACtD,CAAC,CAAC;EACH;AACD;AAEO,SAASG,0BAA0BA,CAACC,EAAU,EAAEhB,IAAY,EAAQ;EAC1E,IAAIA,IAAI,GAAGC,eAAO,CAACgB,kBAAkB,EAAE;IACtC,IAAAd,cAAK,EAACC,uBAAe,CAACc,uBAAuB,EAAE;MAC9CZ,OAAO,EAAE,kCAAkC;MAC3CC,MAAM,EAAE;QACPY,YAAY,EAAEH,EAAE;QAChBR,SAAS,EAAER,IAAI;QACfS,UAAU,EAAER,eAAO,CAACgB;MACrB;IACD,CAAC,CAAC;EACH;AACD","ignoreList":[]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.asFilterValue = asFilterValue;
|
|
7
|
+
exports.byteOrder = byteOrder;
|
|
8
|
+
exports.compareValues = compareValues;
|
|
9
|
+
exports.lookupField = lookupField;
|
|
10
|
+
/**
|
|
11
|
+
* Comparison and field access semantics.
|
|
12
|
+
*
|
|
13
|
+
* Defined once here, used by the in-memory adapter directly and by the SQL
|
|
14
|
+
* builder for validation and cursor construction. Two implementations of
|
|
15
|
+
* these rules would drift, and the drift would show up as a conformance
|
|
16
|
+
* divergence that hides a real bug (research.md R8).
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A field is one of three things, and the difference is the whole point of
|
|
21
|
+
* FR-019: present with a value, present and null, or absent.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
function lookupField(data, field) {
|
|
25
|
+
if (!Object.prototype.hasOwnProperty.call(data, field)) {
|
|
26
|
+
return {
|
|
27
|
+
present: false
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const value = data[field];
|
|
31
|
+
if (value === null) {
|
|
32
|
+
return {
|
|
33
|
+
present: true,
|
|
34
|
+
value: null
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
present: true,
|
|
39
|
+
value: value
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Ordering for values of the same declared type.
|
|
45
|
+
*
|
|
46
|
+
* Null sorts before every non-null value, matching SQLite's default so the
|
|
47
|
+
* two adapters agree without the SQL builder emitting NULLS FIRST/LAST
|
|
48
|
+
* clauses that older SQLite versions do not support.
|
|
49
|
+
*/
|
|
50
|
+
function compareValues(a, b) {
|
|
51
|
+
if (a === null && b === null) {
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
if (a === null) {
|
|
55
|
+
return -1;
|
|
56
|
+
}
|
|
57
|
+
if (b === null) {
|
|
58
|
+
return 1;
|
|
59
|
+
}
|
|
60
|
+
if (typeof a === 'boolean' || typeof b === 'boolean') {
|
|
61
|
+
return Number(a) - Number(b);
|
|
62
|
+
}
|
|
63
|
+
if (typeof a === 'number' && typeof b === 'number') {
|
|
64
|
+
if (Number.isNaN(a) || Number.isNaN(b)) {
|
|
65
|
+
return Number.isNaN(a) && Number.isNaN(b) ? 0 : Number.isNaN(a) ? -1 : 1;
|
|
66
|
+
}
|
|
67
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
68
|
+
}
|
|
69
|
+
const sa = String(a);
|
|
70
|
+
const sb = String(b);
|
|
71
|
+
// Byte-order rather than locale collation: a locale-aware comparison would
|
|
72
|
+
// make the stored order depend on device settings, so the same data would
|
|
73
|
+
// page differently on two phones.
|
|
74
|
+
return sa < sb ? -1 : sa > sb ? 1 : 0;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Only primitives can be compared; a nested object is never a filter target. */
|
|
78
|
+
function asFilterValue(value) {
|
|
79
|
+
if (value === null || typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
80
|
+
return value;
|
|
81
|
+
}
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Byte order, not locale collation.
|
|
87
|
+
*
|
|
88
|
+
* A locale-aware sort would make the reported order depend on device
|
|
89
|
+
* settings, so two phones holding identical data would report it differently.
|
|
90
|
+
*/
|
|
91
|
+
function byteOrder(a, b) {
|
|
92
|
+
if (a < b) {
|
|
93
|
+
return -1;
|
|
94
|
+
}
|
|
95
|
+
return a > b ? 1 : 0;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=compare.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["lookupField","data","field","Object","prototype","hasOwnProperty","call","present","value","compareValues","a","b","Number","isNaN","sa","String","sb","asFilterValue","undefined","byteOrder"],"sourceRoot":"../../../src","sources":["query/compare.ts"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;;AAMO,SAASA,WAAWA,CAACC,IAAwB,EAAEC,KAAa,EAAe;EACjF,IAAI,CAACC,MAAM,CAACC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACL,IAAI,EAAEC,KAAK,CAAC,EAAE;IACvD,OAAO;MAAEK,OAAO,EAAE;IAAM,CAAC;EAC1B;EACA,MAAMC,KAAK,GAAGP,IAAI,CAACC,KAAK,CAAC;EACzB,IAAIM,KAAK,KAAK,IAAI,EAAE;IACnB,OAAO;MAAED,OAAO,EAAE,IAAI;MAAEC,KAAK,EAAE;IAAK,CAAC;EACtC;EACA,OAAO;IAAED,OAAO,EAAE,IAAI;IAAEC,KAAK,EAAEA;EAAsC,CAAC;AACvE;;AAE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ACzB,OAAOA,KAAK,KAAK,QAAQ,IACzB,OAAOA,KAAK,KAAK,SAAS,EACzB;IACD,OAAOA,KAAK;EACb;EACA,OAAOU,SAAS;AACjB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,SAASA,CAACT,CAAS,EAAEC,CAAS,EAAU;EACvD,IAAID,CAAC,GAAGC,CAAC,EAAE;IACV,OAAO,CAAC,CAAC;EACV;EACA,OAAOD,CAAC,GAAGC,CAAC,GAAG,CAAC,GAAG,CAAC;AACrB","ignoreList":[]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.decodeCursor = decodeCursor;
|
|
7
|
+
exports.encodeCursor = encodeCursor;
|
|
8
|
+
exports.isAfterCursor = isAfterCursor;
|
|
9
|
+
var _errors = require("../contract/errors.js");
|
|
10
|
+
var _errors2 = require("../diagnostics/errors.js");
|
|
11
|
+
var _compare = require("./compare.js");
|
|
12
|
+
var _sort = require("./sort.js");
|
|
13
|
+
var _bytes = require("../platform/bytes.js");
|
|
14
|
+
/**
|
|
15
|
+
* Keyset pagination cursors.
|
|
16
|
+
*
|
|
17
|
+
* Keyset rather than OFFSET for two reasons, both of which SC-007 measures:
|
|
18
|
+
* OFFSET degrades linearly at the 100,000-record budget because the engine
|
|
19
|
+
* still walks the skipped rows, and it shifts pages under concurrent writes
|
|
20
|
+
* so a record can be skipped or returned twice. A cursor anchored to the last
|
|
21
|
+
* row's sort values has neither problem.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
function shapeOf(sort) {
|
|
25
|
+
return sort.map(key => `${key.field}:${key.direction === 'desc' ? 'd' : 'a'}`).join(',');
|
|
26
|
+
}
|
|
27
|
+
function toBase64(value) {
|
|
28
|
+
if (_bytes.host.btoa) {
|
|
29
|
+
return _bytes.host.btoa(unescape(encodeURIComponent(value)));
|
|
30
|
+
}
|
|
31
|
+
return (0, _bytes.bytesToBase64)((0, _bytes.utf8Bytes)(value));
|
|
32
|
+
}
|
|
33
|
+
function fromBase64(value) {
|
|
34
|
+
if (_bytes.host.atob) {
|
|
35
|
+
return decodeURIComponent(escape(_bytes.host.atob(value)));
|
|
36
|
+
}
|
|
37
|
+
return (0, _bytes.utf8String)((0, _bytes.base64ToBytes)(value));
|
|
38
|
+
}
|
|
39
|
+
function encodeCursor(record, sort) {
|
|
40
|
+
const payload = {
|
|
41
|
+
k: shapeOf(sort),
|
|
42
|
+
v: sort.map(key => (0, _sort.sortValueOf)(record, key.field) ?? null)
|
|
43
|
+
};
|
|
44
|
+
return toBase64(JSON.stringify(payload));
|
|
45
|
+
}
|
|
46
|
+
function decodeCursor(cursor, sort) {
|
|
47
|
+
let payload;
|
|
48
|
+
try {
|
|
49
|
+
payload = JSON.parse(fromBase64(cursor));
|
|
50
|
+
} catch {
|
|
51
|
+
(0, _errors2.raise)(_errors.DiagnosticCodes.CURSOR_INVALID, {
|
|
52
|
+
message: 'cursor is not decodable'
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (!payload || typeof payload.k !== 'string' || !Array.isArray(payload.v)) {
|
|
56
|
+
(0, _errors2.raise)(_errors.DiagnosticCodes.CURSOR_INVALID, {
|
|
57
|
+
message: 'cursor payload is malformed'
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
// A cursor from a differently sorted query would produce a silently wrong
|
|
61
|
+
// page rather than an error, so the shape is part of the cursor.
|
|
62
|
+
if (payload.k !== shapeOf(sort)) {
|
|
63
|
+
(0, _errors2.raise)(_errors.DiagnosticCodes.CURSOR_INVALID, {
|
|
64
|
+
message: 'cursor does not match this query shape'
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
if (payload.v.length !== sort.length) {
|
|
68
|
+
(0, _errors2.raise)(_errors.DiagnosticCodes.CURSOR_INVALID, {
|
|
69
|
+
message: 'cursor arity does not match sort'
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return payload.v;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Is this record strictly after the cursor position, under the sort order?
|
|
77
|
+
*
|
|
78
|
+
* Lexicographic across the sort keys: equal on the first key means the second
|
|
79
|
+
* decides, and so on down to the id tiebreaker that guarantees a total order.
|
|
80
|
+
*/
|
|
81
|
+
function isAfterCursor(record, sort, anchor) {
|
|
82
|
+
for (let i = 0; i < sort.length; i += 1) {
|
|
83
|
+
const key = sort[i];
|
|
84
|
+
const direction = key.direction === 'desc' ? -1 : 1;
|
|
85
|
+
const value = (0, _sort.sortValueOf)(record, key.field) ?? null;
|
|
86
|
+
const result = (0, _compare.compareValues)(value, anchor[i] ?? null) * direction;
|
|
87
|
+
if (result > 0) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
if (result < 0) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// Equal on every key including id — this is the anchor row itself.
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=cursor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_errors","require","_errors2","_compare","_sort","_bytes","shapeOf","sort","map","key","field","direction","join","toBase64","value","host","btoa","unescape","encodeURIComponent","bytesToBase64","utf8Bytes","fromBase64","atob","decodeURIComponent","escape","utf8String","base64ToBytes","encodeCursor","record","payload","k","v","sortValueOf","JSON","stringify","decodeCursor","cursor","parse","raise","DiagnosticCodes","CURSOR_INVALID","message","Array","isArray","length","isAfterCursor","anchor","i","result","compareValues"],"sourceRoot":"../../../src","sources":["query/cursor.ts"],"mappings":";;;;;;;;AAUA,IAAAA,OAAA,GAAAC,OAAA;AAGA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAhBA;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AAG,IAAAC,sBAAa,EAACnC,KAAK,EAAEgC,MAAM,CAACC,CAAC,CAAC,IAAI,IAAI,CAAC,GAAGpC,SAAS;IAClE,IAAIqC,MAAM,GAAG,CAAC,EAAE;MACf,OAAO,IAAI;IACZ;IACA,IAAIA,MAAM,GAAG,CAAC,EAAE;MACf,OAAO,KAAK;IACb;EACD;EACA;EACA,OAAO,KAAK;AACb","ignoreList":[]}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.evaluateFilter = evaluateFilter;
|
|
7
|
+
var _compare = require("./compare.js");
|
|
8
|
+
/**
|
|
9
|
+
* Filter evaluation over a plain record.
|
|
10
|
+
*
|
|
11
|
+
* The in-memory adapter runs this directly. The SQLite adapter translates the
|
|
12
|
+
* same validated tree to SQL. Both must agree, which is why the semantics
|
|
13
|
+
* live here rather than in either of them.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
function equals(a, b) {
|
|
17
|
+
return (0, _compare.compareValues)(a, b) === 0 && a === null === (b === null);
|
|
18
|
+
}
|
|
19
|
+
function evaluateFilter(data, node) {
|
|
20
|
+
switch (node.op) {
|
|
21
|
+
case 'and':
|
|
22
|
+
return node.nodes.every(child => evaluateFilter(data, child));
|
|
23
|
+
case 'or':
|
|
24
|
+
return node.nodes.some(child => evaluateFilter(data, child));
|
|
25
|
+
case 'not':
|
|
26
|
+
return !evaluateFilter(data, node.node);
|
|
27
|
+
default:
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
const lookup = (0, _compare.lookupField)(data, node.field);
|
|
31
|
+
|
|
32
|
+
// `exists` is the only operator that answers a question about presence,
|
|
33
|
+
// which is what keeps "absent" distinguishable from "null" (FR-019).
|
|
34
|
+
if (node.op === 'exists') {
|
|
35
|
+
return lookup.present === node.value;
|
|
36
|
+
}
|
|
37
|
+
if (!lookup.present) {
|
|
38
|
+
// An absent field satisfies nothing else — not even `ne` or `isNull`.
|
|
39
|
+
// SQL agrees: a comparison against a missing column yields NULL, which
|
|
40
|
+
// is not true.
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const value = (0, _compare.asFilterValue)(lookup.value);
|
|
44
|
+
if (value === undefined) {
|
|
45
|
+
// A nested object or array is not comparable. Matching it would be a
|
|
46
|
+
// guess, so it simply does not satisfy a comparison.
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
switch (node.op) {
|
|
50
|
+
case 'isNull':
|
|
51
|
+
return value === null;
|
|
52
|
+
case 'isNotNull':
|
|
53
|
+
return value !== null;
|
|
54
|
+
case 'eq':
|
|
55
|
+
return equals(value, node.value);
|
|
56
|
+
case 'ne':
|
|
57
|
+
return !equals(value, node.value);
|
|
58
|
+
case 'lt':
|
|
59
|
+
return value !== null && node.value !== null && (0, _compare.compareValues)(value, node.value) < 0;
|
|
60
|
+
case 'lte':
|
|
61
|
+
return value !== null && node.value !== null && (0, _compare.compareValues)(value, node.value) <= 0;
|
|
62
|
+
case 'gt':
|
|
63
|
+
return value !== null && node.value !== null && (0, _compare.compareValues)(value, node.value) > 0;
|
|
64
|
+
case 'gte':
|
|
65
|
+
return value !== null && node.value !== null && (0, _compare.compareValues)(value, node.value) >= 0;
|
|
66
|
+
case 'in':
|
|
67
|
+
return node.value.some(candidate => equals(value, candidate));
|
|
68
|
+
case 'nin':
|
|
69
|
+
return !node.value.some(candidate => equals(value, candidate));
|
|
70
|
+
case 'between':
|
|
71
|
+
{
|
|
72
|
+
const [low, high] = node.value;
|
|
73
|
+
if (value === null || low === null || high === null) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
return (0, _compare.compareValues)(value, low) >= 0 && (0, _compare.compareValues)(value, high) <= 0;
|
|
77
|
+
}
|
|
78
|
+
default:
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_compare","require","equals","a","b","compareValues","evaluateFilter","data","node","op","nodes","every","child","some","lookup","lookupField","field","present","value","asFilterValue","undefined","candidate","low","high"],"sourceRoot":"../../../src","sources":["query/filter.ts"],"mappings":";;;;;;AAUA,IAAAA,QAAA,GAAAC,OAAA;AAVA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,SAASC,MAAMA,CAACC,CAAc,EAAEC,CAAc,EAAW;EACxD,OAAO,IAAAC,sBAAa,EAACF,CAAC,EAAEC,CAAC,CAAC,KAAK,CAAC,IAAKD,CAAC,KAAK,IAAI,MAAOC,CAAC,KAAK,IAAI,CAAC;AAClE;AAEO,SAASE,cAAcA,CAACC,IAAwB,EAAEC,IAAgB,EAAW;EACnF,QAAQA,IAAI,CAACC,EAAE;IACd,KAAK,KAAK;MACT,OAAOD,IAAI,CAACE,KAAK,CAACC,KAAK,CAACC,KAAK,IAAIN,cAAc,CAACC,IAAI,EAAEK,KAAK,CAAC,CAAC;IAC9D,KAAK,IAAI;MACR,OAAOJ,IAAI,CAACE,KAAK,CAACG,IAAI,CAACD,KAAK,IAAIN,cAAc,CAACC,IAAI,EAAEK,KAAK,CAAC,CAAC;IAC7D,KAAK,KAAK;MACT,OAAO,CAACN,cAAc,CAACC,IAAI,EAAEC,IAAI,CAACA,IAAI,CAAC;IACxC;MACC;EACF;EAEA,MAAMM,MAAM,GAAG,IAAAC,oBAAW,EAACR,IAAI,EAAEC,IAAI,CAACQ,KAAK,CAAC;;EAE5C;EACA;EACA,IAAIR,IAAI,CAACC,EAAE,KAAK,QAAQ,EAAE;IACzB,OAAOK,MAAM,CAACG,OAAO,KAAKT,IAAI,CAACU,KAAK;EACrC;EAEA,IAAI,CAACJ,MAAM,CAACG,OAAO,EAAE;IACpB;IACA;IACA;IACA,OAAO,KAAK;EACb;EAEA,MAAMC,KAAK,GAAG,IAAAC,sBAAa,EAACL,MAAM,CAACI,K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AInB,MAAM,CAACgB,KAAK,EAAEG,SAAS,CAAC,CAAC;IAC/D,KAAK,SAAS;MAAE;QACf,MAAM,CAACC,GAAG,EAAEC,IAAI,CAAC,GAAGf,IAAI,CAACU,KAAK;QAC9B,IAAIA,KAAK,KAAK,IAAI,IAAII,GAAG,KAAK,IAAI,IAAIC,IAAI,KAAK,IAAI,EAAE;UACpD,OAAO,KAAK;QACb;QACA,OAAO,IAAAlB,sBAAa,EAACa,KAAK,EAAEI,GAAG,CAAC,IAAI,CAAC,IAAI,IAAAjB,sBAAa,EAACa,KAAK,EAAEK,IAAI,CAAC,IAAI,CAAC;MACzE;IACA;MACC,OAAO,KAAK;EACd;AACD","ignoreList":[]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DEFAULT_PAGE_SIZE = void 0;
|
|
7
|
+
exports.applyCursor = applyCursor;
|
|
8
|
+
exports.buildPage = buildPage;
|
|
9
|
+
exports.fetchLimitFor = fetchLimitFor;
|
|
10
|
+
exports.resolvePageSize = resolvePageSize;
|
|
11
|
+
var _config = require("../contract/config.js");
|
|
12
|
+
var _cursor = require("./cursor.js");
|
|
13
|
+
/**
|
|
14
|
+
* Page assembly over already-filtered, already-sorted records.
|
|
15
|
+
*
|
|
16
|
+
* Shared so the in-memory adapter and the SQLite adapter produce identical
|
|
17
|
+
* pages, including the `hasMore` signal and when a cursor is emitted.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const DEFAULT_PAGE_SIZE = exports.DEFAULT_PAGE_SIZE = 50;
|
|
21
|
+
function resolvePageSize(page) {
|
|
22
|
+
return page?.size ?? DEFAULT_PAGE_SIZE;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Fetch one extra row to answer `hasMore` without a second count query. */
|
|
26
|
+
function fetchLimitFor(size) {
|
|
27
|
+
return Math.min(size, _config.Budgets.MAX_PAGE_SIZE) + 1;
|
|
28
|
+
}
|
|
29
|
+
function applyCursor(records, sort, cursor) {
|
|
30
|
+
if (!cursor) {
|
|
31
|
+
return records;
|
|
32
|
+
}
|
|
33
|
+
const anchor = (0, _cursor.decodeCursor)(cursor, sort);
|
|
34
|
+
return records.filter(record => (0, _cursor.isAfterCursor)(record, sort, anchor));
|
|
35
|
+
}
|
|
36
|
+
function buildPage(records, sort, size) {
|
|
37
|
+
const hasMore = records.length > size;
|
|
38
|
+
const page = hasMore ? records.slice(0, size) : records;
|
|
39
|
+
const last = page[page.length - 1];
|
|
40
|
+
return {
|
|
41
|
+
records: page,
|
|
42
|
+
// No cursor on the final page: handing one back invites a consumer to
|
|
43
|
+
// keep paging past the end and treat an empty page as an error.
|
|
44
|
+
cursor: hasMore && last ? (0, _cursor.encodeCursor)(last, sort) : undefined,
|
|
45
|
+
hasMore
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=paginate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_config","require","_cursor","DEFAULT_PAGE_SIZE","exports","resolvePageSize","page","size","fetchLimitFor","Math","min","Budgets","MAX_PAGE_SIZE","applyCursor","records","sort","cursor","anchor","decodeCursor","filter","record","isAfterCursor","buildPage","hasMore","length","slice","last","encodeCursor","undefined"],"sourceRoot":"../../../src","sources":["query/paginate.ts"],"mappings":";;;;;;;;;;AAOA,IAAAA,OAAA,GAAAC,OAAA;AAGA,IAAAC,OAAA,GAAAD,OAAA;AAVA;AACA;AACA;AACA;AACA;AACA;;AAOO,MAAME,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG,EAAE;AAE5B,SAASE,eAAeA,CAACC,IAA6B,EAAU;EACtE,OAAOA,IAAI,EAAEC,IAAI,IAAIJ,iBAAiB;AACvC;;AAEA;AACO,SAASK,aAAaA,CAACD,IAAY,EAAU;EACnD,OAAOE,IAAI,CAACC,GAAG,CAACH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