@chipmobilesdk/rn-local-db 0.4.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 +137 -0
- package/README.md +69 -8
- 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/src/crypto/provider.ts +7 -3
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Query validation, run before any SQL is built.
|
|
5
|
+
*
|
|
6
|
+
* Two things fall out of validating first: FR-034 is satisfied, and no
|
|
7
|
+
* consumer-supplied string ever reaches SQL construction — field names are
|
|
8
|
+
* resolved through the schema to a known column, and values bind as
|
|
9
|
+
* parameters. Injection stops being a thing to remember.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { Budgets } from "../contract/config.js";
|
|
13
|
+
import { DiagnosticCodes } from "../contract/errors.js";
|
|
14
|
+
import { raise } from "../diagnostics/errors.js";
|
|
15
|
+
import { sanitizeIdentifier } from "../diagnostics/redact.js";
|
|
16
|
+
import { fieldOf } from "../schema/declare.js";
|
|
17
|
+
function queryInvalid(message, collection) {
|
|
18
|
+
// The field name is named; its *value* never is (FR-079).
|
|
19
|
+
raise(DiagnosticCodes.QUERY_INVALID, {
|
|
20
|
+
message,
|
|
21
|
+
detail: {
|
|
22
|
+
collection
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
const ORDERED_OPERATORS = new Set(['lt', 'lte', 'gt', 'gte', 'between']);
|
|
27
|
+
function typeMatches(type, value) {
|
|
28
|
+
if (value === null) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
switch (type) {
|
|
32
|
+
case 'string':
|
|
33
|
+
return typeof value === 'string';
|
|
34
|
+
case 'number':
|
|
35
|
+
case 'timestamp':
|
|
36
|
+
return typeof value === 'number';
|
|
37
|
+
case 'boolean':
|
|
38
|
+
return typeof value === 'boolean';
|
|
39
|
+
default:
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function validateField(collection, field) {
|
|
44
|
+
const declared = fieldOf(collection, field);
|
|
45
|
+
if (!declared) {
|
|
46
|
+
// Returning everything or nothing here would be worse than failing:
|
|
47
|
+
// a typo would silently change what the user sees.
|
|
48
|
+
queryInvalid(`filter references undeclared field ${sanitizeIdentifier(field)}`, collection.name);
|
|
49
|
+
}
|
|
50
|
+
return declared;
|
|
51
|
+
}
|
|
52
|
+
export function validateFilter(collection, node) {
|
|
53
|
+
switch (node.op) {
|
|
54
|
+
case 'and':
|
|
55
|
+
case 'or':
|
|
56
|
+
{
|
|
57
|
+
if (!Array.isArray(node.nodes) || node.nodes.length === 0) {
|
|
58
|
+
queryInvalid(`${node.op} requires at least one child`, collection.name);
|
|
59
|
+
}
|
|
60
|
+
for (const child of node.nodes) {
|
|
61
|
+
validateFilter(collection, child);
|
|
62
|
+
}
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
case 'not':
|
|
66
|
+
{
|
|
67
|
+
if (!node.node) {
|
|
68
|
+
queryInvalid('not requires a child', collection.name);
|
|
69
|
+
}
|
|
70
|
+
validateFilter(collection, node.node);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
case 'isNull':
|
|
74
|
+
case 'isNotNull':
|
|
75
|
+
{
|
|
76
|
+
validateField(collection, node.field);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
case 'exists':
|
|
80
|
+
{
|
|
81
|
+
validateField(collection, node.field);
|
|
82
|
+
if (typeof node.value !== 'boolean') {
|
|
83
|
+
queryInvalid('exists requires a boolean', collection.name);
|
|
84
|
+
}
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
case 'in':
|
|
88
|
+
case 'nin':
|
|
89
|
+
{
|
|
90
|
+
const declared = validateField(collection, node.field);
|
|
91
|
+
if (!Array.isArray(node.value) || node.value.length === 0) {
|
|
92
|
+
queryInvalid(`${node.op} requires a non-empty array`, collection.name);
|
|
93
|
+
}
|
|
94
|
+
for (const value of node.value) {
|
|
95
|
+
if (!typeMatches(declared.type, value)) {
|
|
96
|
+
queryInvalid(`${node.op} value does not match field type`, collection.name);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
case 'between':
|
|
102
|
+
{
|
|
103
|
+
const declared = validateField(collection, node.field);
|
|
104
|
+
if (!Array.isArray(node.value) || node.value.length !== 2) {
|
|
105
|
+
queryInvalid('between requires exactly two bounds', collection.name);
|
|
106
|
+
}
|
|
107
|
+
for (const value of node.value) {
|
|
108
|
+
if (!typeMatches(declared.type, value)) {
|
|
109
|
+
queryInvalid('between bound does not match field type', collection.name);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
case 'eq':
|
|
115
|
+
case 'ne':
|
|
116
|
+
case 'lt':
|
|
117
|
+
case 'lte':
|
|
118
|
+
case 'gt':
|
|
119
|
+
case 'gte':
|
|
120
|
+
{
|
|
121
|
+
const declared = validateField(collection, node.field);
|
|
122
|
+
if (declared.type === 'boolean' && ORDERED_OPERATORS.has(node.op)) {
|
|
123
|
+
queryInvalid('ordered comparison is not defined for a boolean', collection.name);
|
|
124
|
+
}
|
|
125
|
+
if (!typeMatches(declared.type, node.value)) {
|
|
126
|
+
queryInvalid('filter value does not match field type', collection.name);
|
|
127
|
+
}
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
default:
|
|
131
|
+
{
|
|
132
|
+
queryInvalid(`unsupported operator ${sanitizeIdentifier(String(node.op))}`, collection.name);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
export function validateSort(collection, sort) {
|
|
137
|
+
const seen = new Set();
|
|
138
|
+
for (const key of sort) {
|
|
139
|
+
validateField(collection, key.field);
|
|
140
|
+
if (seen.has(key.field)) {
|
|
141
|
+
queryInvalid(`duplicate sort field ${sanitizeIdentifier(key.field)}`, collection.name);
|
|
142
|
+
}
|
|
143
|
+
seen.add(key.field);
|
|
144
|
+
if (key.direction && key.direction !== 'asc' && key.direction !== 'desc') {
|
|
145
|
+
queryInvalid('sort direction must be asc or desc', collection.name);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
export function validatePageSize(size) {
|
|
150
|
+
if (!Number.isInteger(size) || size < 1 || size > Budgets.MAX_PAGE_SIZE) {
|
|
151
|
+
raise(DiagnosticCodes.PAGE_SIZE_INVALID, {
|
|
152
|
+
message: 'page size out of range',
|
|
153
|
+
detail: {
|
|
154
|
+
limit: Budgets.MAX_PAGE_SIZE
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
export function validateQuery(collection, query) {
|
|
160
|
+
if (!query) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (query.filter) {
|
|
164
|
+
validateFilter(collection, query.filter);
|
|
165
|
+
}
|
|
166
|
+
if (query.sort) {
|
|
167
|
+
validateSort(collection, query.sort);
|
|
168
|
+
}
|
|
169
|
+
if (query.page) {
|
|
170
|
+
validatePageSize(query.page.size);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Budgets","DiagnosticCodes","raise","sanitizeIdentifier","fieldOf","queryInvalid","message","collection","QUERY_INVALID","detail","ORDERED_OPERATORS","Set","typeMatches","type","value","validateField","field","declared","name","validateFilter","node","op","Array","isArray","nodes","length","child","has","String","validateSort","sort","seen","key","add","direction","validatePageSize","size","Number","isInteger","MAX_PAGE_SIZE","PAGE_SIZE_INVALID","limit","validateQuery","query","filter","page"],"sourceRoot":"../../../src","sources":["query/validate.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,QAAQ,uBAAoB;AAC5C,SAASC,eAAe,QAAQ,uBAAoB;AAGpD,SAASC,KAAK,QAAQ,0BAAuB;AAC7C,SAASC,kBAAkB,QAAQ,0BAAuB;AAC1D,SAASC,OAAO,QAAQ,sBAAmB;AAE3C,SAASC,YAAYA,CAACC,OAAe,EAAEC,UAAkB,EAAS;EACjE;EACAL,KAAK,CAACD,eAAe,CAACO,aAAa,EAAE;IAAEF,OAAO;IAAEG,MAAM,EAAE;MAAEF;IAAW;EAAE,CAAC,CAAC;AAC1E;AAEA,MAAMG,iBAAiB,GAAG,IAAIC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;AAExE,SAASC,WAAWA,CAACC,IAAe,EAAEC,KAAkB,EAAW;EAClE,IAAIA,KAAK,KAAK,IAAI,EAAE;IACnB,OAAO,IAAI;EACZ;EACA,QAAQD,IAAI;IACX,KAAK,QAAQ;MACZ,OAAO,OAAOC,KAAK,KAAK,QAAQ;IACjC,KAAK,QAAQ;IACb,KAAK,WAAW;MACf,OAAO,OAAOA,KAAK,KAAK,QAAQ;IACjC,KAAK,SAAS;MACb,OAAO,OAAOA,KAAK,KAAK,SAAS;IAClC;MACC,OAAO,KAAK;EACd;AACD;AAEA,SAASC,aAAaA,CAACR,UAA4B,EAAES,KAAa,EAA8B;EAC/F,MAAMC,QAAQ,GAAGb,OAAO,CAACG,UAAU,EAAES,KAAK,CAAC;EAC3C,IAAI,CAACC,QAAQ,EAAE;IACd;IACA;IACAZ,YAAY,CACX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;MACxClC,OAAO,EAAE,wBAAwB;MACjCG,MAAM,EAAE;QAAEgC,KAAK,EAAEzC,OAAO,CAACuC;MAAc;IACxC,CAAC,CAAC;EACH;AACD;AAEA,OAAO,SAASG,aAAaA,CAACnC,UAA4B,EAAEoC,KAAwB,EAAQ;EAC3F,IAAI,CAACA,KAAK,EAAE;IACX;EACD;EACA,IAAIA,KAAK,CAACC,MAAM,EAAE;IACjBzB,cAAc,CAACZ,UAAU,EAAEoC,KAAK,CAACC,MAAM,CAAC;EACzC;EACA,IAAID,KAAK,CAACb,IAAI,EAAE;IACfD,YAAY,CAACtB,UAAU,EAAEoC,KAAK,CAACb,IAAI,CAAC;EACrC;EACA,IAAIa,KAAK,CAACE,IAAI,EAAE;IACfV,gBAAgB,CAACQ,KAAK,CAACE,IAAI,CAACT,IAAI,CAAC;EAClC;AACD","ignoreList":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Schema lookup helpers shared by both adapters.
|
|
5
|
+
*
|
|
6
|
+
* Declaring a field makes it queryable — it does not restrict what a record
|
|
7
|
+
* may contain. `isQueryable` is the single answer to "may a filter or sort
|
|
8
|
+
* reference this?", so both adapters reject the same field names (FR-034).
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export function indexSchemas(collections) {
|
|
12
|
+
return new Map(collections.map(collection => [collection.name, collection]));
|
|
13
|
+
}
|
|
14
|
+
export function fieldOf(collection, name) {
|
|
15
|
+
return collection.fields?.find(field => field.name === name);
|
|
16
|
+
}
|
|
17
|
+
export function isQueryable(collection, name) {
|
|
18
|
+
return fieldOf(collection, name) !== undefined;
|
|
19
|
+
}
|
|
20
|
+
export function hasSoftDelete(collection) {
|
|
21
|
+
return collection.softDelete === true;
|
|
22
|
+
}
|
|
23
|
+
export function hasTimestamps(collection) {
|
|
24
|
+
return collection.timestamps === true;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Column name for a projected queryable field. Prefixed to avoid colliding
|
|
28
|
+
* with the reserved columns (`id`, `payload`, `created_at`, ...). */
|
|
29
|
+
export function projectedColumn(field) {
|
|
30
|
+
return `f_${field}`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Table name for a collection, prefixed for the same reason. */
|
|
34
|
+
export function collectionTable(name) {
|
|
35
|
+
return `c_${name}`;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=declare.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["indexSchemas","collections","Map","map","collection","name","fieldOf","fields","find","field","isQueryable","undefined","hasSoftDelete","softDelete","hasTimestamps","timestamps","projectedColumn","collectionTable"],"sourceRoot":"../../../src","sources":["schema/declare.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,OAAO,SAASA,YAAYA,CAACC,WAA+B,EAAe;EAC1E,OAAO,IAAIC,GAAG,CAACD,WAAW,CAACE,GAAG,CAACC,UAAU,IAAI,CAACA,UAAU,CAACC,IAAI,EAAED,UAAU,CAAC,CAAC,CAAC;AAC7E;AAEA,OAAO,SAASE,OAAOA,CAACF,UAA4B,EAAEC,IAAY,EAAgC;EACjG,OAAOD,UAAU,CAACG,MAAM,EAAEC,IAAI,CAACC,KAAK,IAAIA,KAAK,CAACJ,IAAI,KAAKA,IAAI,CAAC;AAC7D;AAEA,OAAO,SAASK,WAAWA,CAACN,UAA4B,EAAEC,IAAY,EAAW;EAChF,OAAOC,OAAO,CAACF,UAAU,EAAEC,IAAI,CAAC,KAAKM,SAAS;AAC/C;AAEA,OAAO,SAASC,aAAaA,CAACR,UAA4B,EAAW;EACpE,OAAOA,UAAU,CAACS,UAAU,KAAK,IAAI;AACtC;AAEA,OAAO,SAASC,aAAaA,CAACV,UAA4B,EAAW;EACpE,OAAOA,UAAU,CAACW,UAAU,KAAK,IAAI;AACtC;;AAEA;AACA;AACA,OAAO,SAASC,eAAeA,CAACP,KAAa,EAAU;EACtD,OAAO,KAAKA,KAAK,EAAE;AACpB;;AAEA;AACA,OAAO,SAASQ,eAAeA,CAACZ,IAAY,EAAU;EACrD,OAAO,KAAKA,IAAI,EAAE;AACnB","ignoreList":[]}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Configuration validation.
|
|
5
|
+
*
|
|
6
|
+
* Runs to completion before any write and before any migration executes
|
|
7
|
+
* (FR-006, FR-053). Order matters: scope first, then collections, then the
|
|
8
|
+
* migration chain — so a consumer fixes the outermost problem first rather
|
|
9
|
+
* than chasing a downstream symptom.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { Budgets } from "../contract/config.js";
|
|
13
|
+
import { DiagnosticCodes } from "../contract/errors.js";
|
|
14
|
+
import { raise } from "../diagnostics/errors.js";
|
|
15
|
+
import { validateMigrationChain } from "../migration/validate-chain.js";
|
|
16
|
+
import { validateDescriptor } from "../scope/validate.js";
|
|
17
|
+
const IDENTIFIER = /^[A-Za-z][A-Za-z0-9_]{0,62}$/;
|
|
18
|
+
function configInvalid(message, detail) {
|
|
19
|
+
raise(DiagnosticCodes.CONFIG_INVALID, {
|
|
20
|
+
message,
|
|
21
|
+
detail
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function validateCollection(collection, seen) {
|
|
25
|
+
if (!IDENTIFIER.test(collection.name)) {
|
|
26
|
+
configInvalid('collection name is not a valid identifier', {
|
|
27
|
+
collection: collection.name
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
if (seen.has(collection.name)) {
|
|
31
|
+
configInvalid('duplicate collection name', {
|
|
32
|
+
collection: collection.name
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
seen.add(collection.name);
|
|
36
|
+
const fieldNames = new Set();
|
|
37
|
+
for (const field of collection.fields ?? []) {
|
|
38
|
+
if (!IDENTIFIER.test(field.name)) {
|
|
39
|
+
configInvalid('field name is not a valid identifier', {
|
|
40
|
+
collection: collection.name
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (fieldNames.has(field.name)) {
|
|
44
|
+
configInvalid('duplicate field name', {
|
|
45
|
+
collection: collection.name
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
fieldNames.add(field.name);
|
|
49
|
+
}
|
|
50
|
+
const indexNames = new Set();
|
|
51
|
+
for (const index of collection.indexes ?? []) {
|
|
52
|
+
if (!IDENTIFIER.test(index.name)) {
|
|
53
|
+
configInvalid('index name is not a valid identifier', {
|
|
54
|
+
collection: collection.name
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (indexNames.has(index.name)) {
|
|
58
|
+
configInvalid('duplicate index name', {
|
|
59
|
+
collection: collection.name
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
indexNames.add(index.name);
|
|
63
|
+
if (!Array.isArray(index.fields) || index.fields.length === 0) {
|
|
64
|
+
configInvalid('index declares no fields', {
|
|
65
|
+
collection: collection.name
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
for (const field of index.fields) {
|
|
69
|
+
if (!fieldNames.has(field)) {
|
|
70
|
+
// The whole point of declaring fields is that the package can
|
|
71
|
+
// tell a typo from a deliberate choice. Silently creating an
|
|
72
|
+
// index over a column that will never exist would turn a config
|
|
73
|
+
// bug into a mysterious full scan at runtime.
|
|
74
|
+
configInvalid('index references an undeclared field', {
|
|
75
|
+
collection: collection.name
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export function validateConfig(config) {
|
|
82
|
+
if (!config || typeof config !== 'object') {
|
|
83
|
+
configInvalid('database config is required');
|
|
84
|
+
}
|
|
85
|
+
if (typeof config.name !== 'string' || !IDENTIFIER.test(config.name)) {
|
|
86
|
+
configInvalid('database name is not a valid identifier');
|
|
87
|
+
}
|
|
88
|
+
validateDescriptor(config.scope);
|
|
89
|
+
if (!Array.isArray(config.collections) || config.collections.length === 0) {
|
|
90
|
+
configInvalid('at least one collection must be declared');
|
|
91
|
+
}
|
|
92
|
+
if (config.collections.length > Budgets.MAX_COLLECTIONS_PER_DATABASE) {
|
|
93
|
+
configInvalid('collection count exceeds the budget', {
|
|
94
|
+
count: config.collections.length,
|
|
95
|
+
limit: Budgets.MAX_COLLECTIONS_PER_DATABASE
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
const seen = new Set();
|
|
99
|
+
for (const collection of config.collections) {
|
|
100
|
+
validateCollection(collection, seen);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// The one definition of a valid chain, shared with the executor (LDB-12).
|
|
104
|
+
validateMigrationChain(config);
|
|
105
|
+
if (config.encryption && config.encryption.enabled) {
|
|
106
|
+
if (typeof config.encryption.keyProvider?.getKey !== 'function') {
|
|
107
|
+
configInvalid('encryption is enabled but no key provider was supplied');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=validate-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Budgets","DiagnosticCodes","raise","validateMigrationChain","validateDescriptor","IDENTIFIER","configInvalid","message","detail","CONFIG_INVALID","validateCollection","collection","seen","test","name","has","add","fieldNames","Set","field","fields","indexNames","index","indexes","Array","isArray","length","validateConfig","config","scope","collections","MAX_COLLECTIONS_PER_DATABASE","count","limit","encryption","enabled","keyProvider","getKey"],"sourceRoot":"../../../src","sources":["schema/validate-config.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,QAA6B,uBAAoB;AACjE,SAASC,eAAe,QAAQ,uBAAoB;AAEpD,SAASC,KAAK,QAAQ,0BAAuB;AAC7C,SAASC,sBAAsB,QAAQ,gCAA6B;AACpE,SAASC,kBAAkB,QAAQ,sBAAmB;AAEtD,MAAMC,UAAU,GAAG,8BAA8B;AAEjD,SAASC,aAAaA,CAACC,OAAe,EAAE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AAC,EAAE;IAC1EpB,aAAa,CAAC,0CAA0C,CAAC;EAC1D;EACA,IAAIsB,MAAM,CAACE,WAAW,CAACJ,MAAM,GAAG1B,OAAO,CAAC+B,4BAA4B,EAAE;IACrEzB,aAAa,CAAC,qCAAqC,EAAE;MACpD0B,KAAK,EAAEJ,MAAM,CAACE,WAAW,CAACJ,MAAM;MAChCO,KAAK,EAAEjC,OAAO,CAAC+B;IAChB,CAAC,CAAC;EACH;EAEA,MAAMnB,IAAI,GAAG,IAAIM,GAAG,CAAS,CAAC;EAC9B,KAAK,MAAMP,UAAU,IAAIiB,MAAM,CAACE,WAAW,EAAE;IAC5CpB,kBAAkB,CAACC,UAAU,EAAEC,IAAI,CAAC;EACrC;;EAEA;EACAT,sBAAsB,CAACyB,MAAM,CAAC;EAE9B,IAAIA,MAAM,CAACM,UAAU,IAAIN,MAAM,CAACM,UAAU,CAACC,OAAO,EAAE;IACnD,IAAI,OAAOP,MAAM,CAACM,UAAU,CAACE,WAAW,EAAEC,MAAM,KAAK,UAAU,EAAE;MAChE/B,aAAa,CAAC,wDAAwD,CAAC;IACxE;EACD;AACD","ignoreList":[]}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Scope key derivation.
|
|
5
|
+
*
|
|
6
|
+
* The directory a scope lives in is named by the SHA-256 digest of its
|
|
7
|
+
* canonical descriptor, never by the components themselves. FR-014 requires
|
|
8
|
+
* scope components be treated as sensitive, and a directory named after an
|
|
9
|
+
* email address puts that address in plaintext on disk — visible even when
|
|
10
|
+
* the database itself is encrypted, and carried into any crash report that
|
|
11
|
+
* includes a file path.
|
|
12
|
+
*
|
|
13
|
+
* Hashing also removes filesystem charset and length limits from the problem,
|
|
14
|
+
* which is what lets validation reject rather than sanitize (research.md R2).
|
|
15
|
+
*
|
|
16
|
+
* Implemented in pure TypeScript rather than over a native crypto peer so the
|
|
17
|
+
* scope layer stays importable from anywhere in the package, including the
|
|
18
|
+
* in-memory adapter running under Jest.
|
|
19
|
+
*
|
|
20
|
+
* Verified against Node's own SHA-256 in scope-resolution.test.ts — a wrong
|
|
21
|
+
* digest would silently merge or split scopes, so it is checked against a
|
|
22
|
+
* reference implementation rather than against a snapshot of this one.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/* eslint-disable no-bitwise -- SHA-256 is defined in terms of bitwise operations. */
|
|
26
|
+
|
|
27
|
+
const K = new Uint32Array([0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2]);
|
|
28
|
+
function rotr(value, bits) {
|
|
29
|
+
return value >>> bits | value << 32 - bits;
|
|
30
|
+
}
|
|
31
|
+
function utf8Bytes(input) {
|
|
32
|
+
const out = [];
|
|
33
|
+
for (let i = 0; i < input.length; i += 1) {
|
|
34
|
+
let codePoint = input.codePointAt(i);
|
|
35
|
+
if (codePoint > 0xffff) {
|
|
36
|
+
i += 1;
|
|
37
|
+
}
|
|
38
|
+
if (codePoint < 0x80) {
|
|
39
|
+
out.push(codePoint);
|
|
40
|
+
} else if (codePoint < 0x800) {
|
|
41
|
+
out.push(0xc0 | codePoint >> 6, 0x80 | codePoint & 0x3f);
|
|
42
|
+
} else if (codePoint < 0x10000) {
|
|
43
|
+
out.push(0xe0 | codePoint >> 12, 0x80 | codePoint >> 6 & 0x3f, 0x80 | codePoint & 0x3f);
|
|
44
|
+
} else {
|
|
45
|
+
out.push(0xf0 | codePoint >> 18, 0x80 | codePoint >> 12 & 0x3f, 0x80 | codePoint >> 6 & 0x3f, 0x80 | codePoint & 0x3f);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return Uint8Array.from(out);
|
|
49
|
+
}
|
|
50
|
+
export function utf8ByteLength(input) {
|
|
51
|
+
return utf8Bytes(input).length;
|
|
52
|
+
}
|
|
53
|
+
export function sha256Hex(input) {
|
|
54
|
+
const bytes = utf8Bytes(input);
|
|
55
|
+
const bitLength = bytes.length * 8;
|
|
56
|
+
const paddedLength = (bytes.length + 9 >> 6) + 1 << 6;
|
|
57
|
+
const padded = new Uint8Array(paddedLength);
|
|
58
|
+
padded.set(bytes);
|
|
59
|
+
padded[bytes.length] = 0x80;
|
|
60
|
+
const view = new DataView(padded.buffer);
|
|
61
|
+
view.setUint32(paddedLength - 8, Math.floor(bitLength / 0x100000000), false);
|
|
62
|
+
view.setUint32(paddedLength - 4, bitLength >>> 0, false);
|
|
63
|
+
const h = new Uint32Array([0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19]);
|
|
64
|
+
const w = new Uint32Array(64);
|
|
65
|
+
for (let offset = 0; offset < paddedLength; offset += 64) {
|
|
66
|
+
for (let i = 0; i < 16; i += 1) {
|
|
67
|
+
w[i] = view.getUint32(offset + i * 4, false);
|
|
68
|
+
}
|
|
69
|
+
for (let i = 16; i < 64; i += 1) {
|
|
70
|
+
const s0 = rotr(w[i - 15], 7) ^ rotr(w[i - 15], 18) ^ w[i - 15] >>> 3;
|
|
71
|
+
const s1 = rotr(w[i - 2], 17) ^ rotr(w[i - 2], 19) ^ w[i - 2] >>> 10;
|
|
72
|
+
w[i] = w[i - 16] + s0 + w[i - 7] + s1 >>> 0;
|
|
73
|
+
}
|
|
74
|
+
let [a, b, c, d, e, f, g, hh] = [h[0], h[1], h[2], h[3], h[4], h[5], h[6], h[7]];
|
|
75
|
+
for (let i = 0; i < 64; i += 1) {
|
|
76
|
+
const S1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
|
|
77
|
+
const ch = e & f ^ ~e & g;
|
|
78
|
+
const temp1 = hh + S1 + ch + K[i] + w[i] >>> 0;
|
|
79
|
+
const S0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);
|
|
80
|
+
const maj = a & b ^ a & c ^ b & c;
|
|
81
|
+
const temp2 = S0 + maj >>> 0;
|
|
82
|
+
hh = g;
|
|
83
|
+
g = f;
|
|
84
|
+
f = e;
|
|
85
|
+
e = d + temp1 >>> 0;
|
|
86
|
+
d = c;
|
|
87
|
+
c = b;
|
|
88
|
+
b = a;
|
|
89
|
+
a = temp1 + temp2 >>> 0;
|
|
90
|
+
}
|
|
91
|
+
h[0] = h[0] + a >>> 0;
|
|
92
|
+
h[1] = h[1] + b >>> 0;
|
|
93
|
+
h[2] = h[2] + c >>> 0;
|
|
94
|
+
h[3] = h[3] + d >>> 0;
|
|
95
|
+
h[4] = h[4] + e >>> 0;
|
|
96
|
+
h[5] = h[5] + f >>> 0;
|
|
97
|
+
h[6] = h[6] + g >>> 0;
|
|
98
|
+
h[7] = h[7] + hh >>> 0;
|
|
99
|
+
}
|
|
100
|
+
return Array.from(h, value => value.toString(16).padStart(8, '0')).join('');
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["K","Uint32Array","rotr","value","bits","utf8Bytes","input","out","i","length","codePoint","codePointAt","push","Uint8Array","from","utf8ByteLength","sha256Hex","bytes","bitLength","paddedLength","padded","set","view","DataView","buffer","setUint32","Math","floor","h","w","offset","getUint32","s0","s1","a","b","c","d","e","f","g","hh","S1","ch","temp1","S0","maj","temp2","Array","toString","padStart","join"],"sourceRoot":"../../../src","sources":["scope/hash.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,MAAMA,CAAC,GAAG,IAAIC,WAAW,CAAC,CACzB,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAC9F,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAC9F,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAC9F,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAC9F,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAC9F,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAC9F,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAC9F,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,CAC9F,CAAC;AAEF,SAAS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AC,GAAIA,CAAC,CAAC,CAAC,CAAC,GAAIS,CAAC,KAAM,CAAC;IACxBT,CAAC,CAAC,CAAC,CAAC,GAAIA,CAAC,CAAC,CAAC,CAAC,GAAIU,CAAC,KAAM,CAAC;IACxBV,CAAC,CAAC,CAAC,CAAC,GAAIA,CAAC,CAAC,CAAC,CAAC,GAAIW,CAAC,KAAM,CAAC;IACxBX,CAAC,CAAC,CAAC,CAAC,GAAIA,CAAC,CAAC,CAAC,CAAC,GAAIY,CAAC,KAAM,CAAC;IACxBZ,CAAC,CAAC,CAAC,CAAC,GAAIA,CAAC,CAAC,CAAC,CAAC,GAAIa,EAAE,KAAM,CAAC;EAC1B;EAEA,OAAOO,KAAK,CAAClC,IAAI,CAACc,CAAC,EAAEzB,KAAK,IAAIA,KAAK,CAAC8C,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAACC,IAAI,CAAC,EAAE,CAAC;AAC5E","ignoreList":[]}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Scope descriptor normalization.
|
|
5
|
+
*
|
|
6
|
+
* The package normalizes and validates; it never repairs. A component it
|
|
7
|
+
* cannot represent safely is an error (FR-013), because silently sanitizing
|
|
8
|
+
* one is how two different descriptors end up sharing a directory — which
|
|
9
|
+
* would be a cross-scope leak dressed up as a convenience.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Separates components in the canonical form.
|
|
14
|
+
*
|
|
15
|
+
* NUL rather than a printable character: a component containing the separator
|
|
16
|
+
* could forge another descriptor's canonical string, and every printable
|
|
17
|
+
* candidate occurs in legitimate identity data. Tenant names contain spaces,
|
|
18
|
+
* identifiers contain colons and slashes, emails contain "@" and ".". NUL
|
|
19
|
+
* occurs in none of them, so reserving it costs consumers nothing.
|
|
20
|
+
*/
|
|
21
|
+
export const COMPONENT_SEPARATOR = '\u0000';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Control characters are rejected wholesale rather than only the separator.
|
|
25
|
+
* They have no place in an identity component, and they would be trouble in a
|
|
26
|
+
* log line or a diagnostic even where they could not forge a canonical
|
|
27
|
+
* string.
|
|
28
|
+
*/
|
|
29
|
+
// eslint-disable-next-line no-control-regex
|
|
30
|
+
export const CONTROL_CHARACTER = /[\u0000-\u001f\u007f]/;
|
|
31
|
+
export const MAX_COMPONENT_BYTES = 512;
|
|
32
|
+
|
|
33
|
+
/** Fixed order, so the canonical form is stable across callers. */
|
|
34
|
+
export const COMPONENT_ORDER = ['kind', 'id', 'tenant', 'app', 'environment', 'namespace'];
|
|
35
|
+
export const SCOPE_KINDS = ['guest', 'identity', 'tenant', 'workspace', 'custom'];
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* NFC, trimmed, case preserved.
|
|
39
|
+
*
|
|
40
|
+
* Case is preserved deliberately: the package does not know whether a
|
|
41
|
+
* consumer's identity system is case-sensitive, and folding case would merge
|
|
42
|
+
* two scopes the app considers distinct.
|
|
43
|
+
*/
|
|
44
|
+
export function normalizeComponent(value) {
|
|
45
|
+
return value.normalize('NFC').trim();
|
|
46
|
+
}
|
|
47
|
+
/** Normalize without validating. Callers must validate first. */
|
|
48
|
+
export function normalizeDescriptor(descriptor) {
|
|
49
|
+
const components = {};
|
|
50
|
+
const parts = [];
|
|
51
|
+
for (const key of COMPONENT_ORDER) {
|
|
52
|
+
const raw = descriptor[key];
|
|
53
|
+
if (typeof raw !== 'string' || raw.length === 0) {
|
|
54
|
+
parts.push('');
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const normalized = normalizeComponent(raw);
|
|
58
|
+
components[key] = normalized;
|
|
59
|
+
parts.push(normalized);
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
kind: descriptor.kind,
|
|
63
|
+
components,
|
|
64
|
+
canonical: parts.join(COMPONENT_SEPARATOR)
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=normalize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["COMPONENT_SEPARATOR","CONTROL_CHARACTER","MAX_COMPONENT_BYTES","COMPONENT_ORDER","SCOPE_KINDS","normalizeComponent","value","normalize","trim","normalizeDescriptor","descriptor","components","parts","key","raw","length","push","normalized","kind","canonical","join"],"sourceRoot":"../../../src","sources":["scope/normalize.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,mBAAmB,GAAG,QAAQ;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,iBAAiB,GAAG,uBAAuB;AAExD,OAAO,MAAMC,mBAAmB,GAAG,GAAG;;AAEtC;AACA,OAAO,MAAMC,eAAe,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,EAAE,WAAW,CAAU;AAEnG,OAAO,MAAMC,WAAiC,GAAG,CAChD,OAAO,EACP,UAAU,EACV,QAAQ,EACR,WAAW,EACX,QAAQ,CACR;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAACC,KAAa,EAAU;EACzD,OAAOA,KAAK,CAACC,SAAS,CAAC,KAAK,CAAC,CAACC,IAAI,CAAC,CAAC;AACrC;AAQA;AACA,OAAO,SAASC,mBAAmBA,CAACC,UAA2B,EAAmB;EACjF,MAAMC,UAAkC,GAAG,CAAC,CAAC;EAC7C,MAAMC,KAAe,GAAG,EAAE;EAE1B,KAAK,MAAMC,GAAG,IAAIV,eAAe,EAAE;IAClC,MAAMW,GAAG,GAAGJ,UAAU,CAACG,GAAG,CAA0B;IACpD,IAAI,OAAOC,GAAG,KAAK,QAAQ,IAAIA,GAAG,CAACC,MAAM,KAAK,CAAC,EAAE;MAChDH,KAAK,CAACI,IAAI,CAAC,EAAE,CAAC;MACd;IACD;IACA,MAAMC,UAAU,GAAGZ,kBAAkB,CAACS,GAAG,CAAC;IAC1CH,UAAU,CAACE,GAAG,CAAC,GAAGI,UAAU;IAC5BL,KAAK,CAACI,IAAI,CAACC,UAAU,CAAC;EACvB;EAEA,OAAO;IACNC,IAAI,EAAER,UAAU,CAACQ,IAAI;IACrBP,UAAU;IACVQ,SAAS,EAAEP,KAAK,CAACQ,IAAI,CAACpB,mBAAmB;EAC1C,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Scope validation and resolution.
|
|
5
|
+
*
|
|
6
|
+
* Validate, never repair (FR-013). The package never invents, derives, or
|
|
7
|
+
* defaults an identity of its own (FR-008).
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { DiagnosticCodes } from "../contract/errors.js";
|
|
11
|
+
import { raise } from "../diagnostics/errors.js";
|
|
12
|
+
import { sha256Hex, utf8ByteLength } from "./hash.js";
|
|
13
|
+
import { COMPONENT_ORDER, CONTROL_CHARACTER, MAX_COMPONENT_BYTES, SCOPE_KINDS, normalizeComponent, normalizeDescriptor } from "./normalize.js";
|
|
14
|
+
function invalid(reason) {
|
|
15
|
+
// The reason names the *component*, never its value — naming the value
|
|
16
|
+
// would put a scope component into an error, which FR-014 forbids.
|
|
17
|
+
raise(DiagnosticCodes.INVALID_SCOPE, {
|
|
18
|
+
message: reason
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function validateComponent(key, raw) {
|
|
22
|
+
if (raw === undefined || raw === null) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (typeof raw !== 'string') {
|
|
26
|
+
invalid(`scope component ${key} must be a string`);
|
|
27
|
+
}
|
|
28
|
+
const normalized = normalizeComponent(raw);
|
|
29
|
+
if (normalized.length === 0) {
|
|
30
|
+
invalid(`scope component ${key} is empty after normalization`);
|
|
31
|
+
}
|
|
32
|
+
if (CONTROL_CHARACTER.test(normalized)) {
|
|
33
|
+
invalid(`scope component ${key} contains a control character`);
|
|
34
|
+
}
|
|
35
|
+
if (utf8ByteLength(normalized) > MAX_COMPONENT_BYTES) {
|
|
36
|
+
invalid(`scope component ${key} exceeds the maximum length`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export function validateDescriptor(descriptor) {
|
|
40
|
+
if (!descriptor || typeof descriptor !== 'object') {
|
|
41
|
+
invalid('scope descriptor is required');
|
|
42
|
+
}
|
|
43
|
+
if (!SCOPE_KINDS.includes(descriptor.kind)) {
|
|
44
|
+
invalid('scope kind is not recognised');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Guest is the one kind with no identity, by design: an anonymous session
|
|
48
|
+
// still gets its own isolated scope rather than sharing a default.
|
|
49
|
+
if (descriptor.kind !== 'guest') {
|
|
50
|
+
const id = descriptor.id;
|
|
51
|
+
if (typeof id !== 'string' || normalizeComponent(id).length === 0) {
|
|
52
|
+
invalid('scope id is required for this kind');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
for (const key of COMPONENT_ORDER) {
|
|
56
|
+
if (key === 'kind') {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
validateComponent(key, descriptor[key]);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Deterministic: identical descriptors always resolve to the same scope, and
|
|
65
|
+
* descriptors differing in any component always resolve to different ones
|
|
66
|
+
* (FR-010).
|
|
67
|
+
*/
|
|
68
|
+
export function resolveScope(descriptor) {
|
|
69
|
+
validateDescriptor(descriptor);
|
|
70
|
+
const normalized = normalizeDescriptor(descriptor);
|
|
71
|
+
return {
|
|
72
|
+
key: sha256Hex(normalized.canonical),
|
|
73
|
+
kind: descriptor.kind
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DiagnosticCodes","raise","sha256Hex","utf8ByteLength","COMPONENT_ORDER","CONTROL_CHARACTER","MAX_COMPONENT_BYTES","SCOPE_KINDS","normalizeComponent","normalizeDescriptor","invalid","reason","INVALID_SCOPE","message","validateComponent","key","raw","undefined","normalized","length","test","validateDescriptor","descriptor","includes","kind","id","resolveScope","canonical"],"sourceRoot":"../../../src","sources":["scope/validate.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,eAAe,QAAQ,uBAAoB;AAEpD,SAASC,KAAK,QAAQ,0BAAuB;AAC7C,SAASC,SAAS,EAAEC,cAAc,QAAQ,WAAQ;AAClD,SACCC,eAAe,EACfC,iBAAiB,EACjBC,mBAAmB,EACnBC,WAAW,EACXC,kBAAkB,EAClBC,mBAAmB,QACb,gBAAa;AAEpB,SAASC,OAAOA,CAACC,MAAc,EAAS;EACvC;EACA;EACAV,KAAK,CAACD,eAAe,CAACY,aAAa,EAAE;IAAEC,OAAO,EAAEF;EAAO,CAAC,CAAC;AAC1D;AAEA,SAASG,iBAAiBA,CAACC,GAAW,EAAEC,GAAY,EAAQ;EAC3D,IAAIA,GAAG,KAAKC,SAAS,IAAID,GAAG,KAAK,IAAI,EAAE;IACtC;EACD;EACA,IAAI,OAAOA,GAAG,KAAK,QAAQ,EAAE;IAC5BN,OAAO,CAAC,mBAAmBK,GAAG,mBAAmB,CAAC;EACnD;EACA,MAAMG,UAAU,GAAGV,kBAAkB,CAACQ,GAAG,CAAC;EAC1C,IAAIE,UAAU,CAACC,MAAM,KAAK,CAAC,EAAE;IAC5BT,OAAO,CAAC,mBAAmBK,GAAG,+BAA+B,CAAC;EAC/D;EACA,IAAIV,iBAAiB,CAACe,IAAI,CAACF,UAAU,CAAC,EAAE;IACvCR,OAAO,CAAC,mBAAmBK,GAAG,+BAA+B,CAAC;EAC/D;EACA,IAAIZ,cAAc,CAACe,UAAU,CAAC,GAAGZ,mBAAmB,EAAE;IACrDI,OAAO,CAAC,mBAAmBK,GAAG,6BAA6B,CAAC;EAC7D;AACD;AAEA,OAAO,SAASM,kBAAkBA,CAACC,UAA8C,EAAQ;EACxF,IAAI,CAACA,UAAU,IAAI,OAAOA,UAAU,KAAK,QAAQ,EAAE;IAClDZ,OAAO,CAAC,8BAA8B,CAAC;EACxC;EACA,IAAI,CAACH,WAAW,CAACgB,QAAQ,CAACD,UAAU,CAACE,IAAI,CAAC,EAAE;IAC3Cd,OAAO,CAAC,8BAA8B,CAAC;EACxC;;EAEA;EACA;EACA,IAAIY,UAAU,CAACE,IAAI,KAAK,OAAO,EAAE;IAChC,MAAMC,EAAE,GAAGH,UAAU,CAACG,EAAE;IACxB,IAAI,OAAOA,EAAE,KAAK,QAAQ,IAAIjB,kBAAkB,CAACiB,EAAE,CAAC,CAACN,MAAM,KAAK,CAAC,EAAE;MAClET,OAAO,CAAC,oCAAoC,CAAC;IAC9C;EACD;EAEA,KAAK,MAAMK,GAAG,IAAIX,eAAe,EAAE;IAClC,IAAIW,GAAG,KAAK,MAAM,EAAE;MACnB;IACD;IACAD,iBAAiB,CAACC,GAAG,EAAEO,UAAU,CAACP,GAAG,CAA0B,CAAC;EACjE;AACD;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASW,YAAYA,CAACJ,UAA2B,EAAiB;EACxED,kBAAkB,CAACC,UAAU,CAAC;EAC9B,MAAMJ,UAAU,GAAGT,mBAAmB,CAACa,UAAU,CAAC;EAClD,OAAO;IACNP,GAAG,EAAEb,SAAS,CAACgB,UAAU,CAACS,SAAS,CAAC;IACpCH,IAAI,EAAEF,UAAU,CAACE;EAClB,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The on-device adapter.
|
|
5
|
+
*
|
|
6
|
+
* Deliberately a seam rather than an implementation. Everything it composes
|
|
7
|
+
* lives in `adapter/`, `migration/`, `artifacts/`, and this directory, so the
|
|
8
|
+
* in-memory adapter can be held to the same contract by the same conformance
|
|
9
|
+
* suite (FR-092) without either one being the "real" version the other
|
|
10
|
+
* approximates.
|
|
11
|
+
*
|
|
12
|
+
* Reached only through the lazy require in `adapter/index.ts`, so a consumer
|
|
13
|
+
* that runs the in-memory adapter in tests never loads the native peers.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { deleteDatabase, deleteScopeData, resetScope } from "../adapter/deletion.js";
|
|
17
|
+
import { openSqliteDatabase } from "../adapter/lifecycle.js";
|
|
18
|
+
export function createSqliteAdapter(options = {}) {
|
|
19
|
+
return {
|
|
20
|
+
name: 'sqlite',
|
|
21
|
+
open: config => openSqliteDatabase(config, options),
|
|
22
|
+
deleteScopeData,
|
|
23
|
+
deleteDatabase,
|
|
24
|
+
resetScope
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["deleteDatabase","deleteScopeData","resetScope","openSqliteDatabase","createSqliteAdapter","options","name","open","config"],"sourceRoot":"../../../src","sources":["sqlite/adapter.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,cAAc,EAAEC,eAAe,EAAEC,UAAU,QAAQ,wBAAqB;AACjF,SAASC,kBAAkB,QAA0B,yBAAsB;AAE3E,OAAO,SAASC,mBAAmBA,CAACC,OAAoB,GAAG,CAAC,CAAC,EAAkB;EAC9E,OAAO;IACNC,IAAI,EAAE,QAAQ;IACdC,IAAI,EAAEC,MAAM,IAAIL,kBAAkB,CAACK,MAAM,EAAEH,OAAO,CAAC;IACnDJ,eAAe;IACfD,cAAc;IACdE;EACD,CAAC;AACF","ignoreList":[]}
|