@vibesdotdev/storage 0.0.1 → 1.0.0-rc.3
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/LICENSE +18 -0
- package/README.md +87 -63
- package/dist/adapters/cloud-api/cloud-api.adapter.descriptor.d.ts +10 -0
- package/dist/adapters/cloud-api/cloud-api.adapter.descriptor.d.ts.map +1 -0
- package/dist/adapters/cloud-api/cloud-api.adapter.descriptor.js +40 -0
- package/dist/adapters/cloud-api/cloud-api.adapter.descriptor.js.map +1 -0
- package/dist/adapters/cloud-api/cloud-api.adapter.impl.d.ts +93 -0
- package/dist/adapters/cloud-api/cloud-api.adapter.impl.d.ts.map +1 -0
- package/dist/adapters/cloud-api/cloud-api.adapter.impl.js +437 -0
- package/dist/adapters/cloud-api/cloud-api.adapter.impl.js.map +1 -0
- package/dist/adapters/cloud-api/cloud-api.fetch-client.d.ts +59 -0
- package/dist/adapters/cloud-api/cloud-api.fetch-client.d.ts.map +1 -0
- package/dist/adapters/cloud-api/cloud-api.fetch-client.js +357 -0
- package/dist/adapters/cloud-api/cloud-api.fetch-client.js.map +1 -0
- package/dist/adapters/cloud-api/cloud-api.record.d.ts +85 -0
- package/dist/adapters/cloud-api/cloud-api.record.d.ts.map +1 -0
- package/dist/adapters/cloud-api/cloud-api.record.helpers.d.ts +71 -0
- package/dist/adapters/cloud-api/cloud-api.record.helpers.d.ts.map +1 -0
- package/dist/adapters/cloud-api/cloud-api.record.helpers.js +270 -0
- package/dist/adapters/cloud-api/cloud-api.record.helpers.js.map +1 -0
- package/dist/adapters/cloud-api/cloud-api.record.js +351 -0
- package/dist/adapters/cloud-api/cloud-api.record.js.map +1 -0
- package/dist/adapters/cloud-api/cloud-api.test-utils.d.ts +38 -0
- package/dist/adapters/cloud-api/cloud-api.test-utils.d.ts.map +1 -0
- package/dist/adapters/cloud-api/cloud-api.test-utils.js +139 -0
- package/dist/adapters/cloud-api/cloud-api.test-utils.js.map +1 -0
- package/dist/adapters/cloud-api/index.d.ts +10 -0
- package/dist/adapters/cloud-api/index.d.ts.map +1 -0
- package/dist/adapters/cloud-api/index.js +10 -0
- package/dist/adapters/cloud-api/index.js.map +1 -0
- package/dist/adapters/cloud-api/storage-adapter-cloud-api.plugin.d.ts +9 -0
- package/dist/adapters/cloud-api/storage-adapter-cloud-api.plugin.d.ts.map +1 -0
- package/dist/adapters/cloud-api/storage-adapter-cloud-api.plugin.js +21 -0
- package/dist/adapters/cloud-api/storage-adapter-cloud-api.plugin.js.map +1 -0
- package/dist/adapters/drizzle/batch-type-proof.d.ts +21 -0
- package/dist/adapters/drizzle/batch-type-proof.d.ts.map +1 -0
- package/dist/adapters/drizzle/batch-type-proof.js +2 -0
- package/dist/adapters/drizzle/batch-type-proof.js.map +1 -0
- package/dist/adapters/drizzle/canonical.adapter.descriptor.d.ts +4 -0
- package/dist/adapters/drizzle/canonical.adapter.descriptor.d.ts.map +1 -0
- package/dist/adapters/drizzle/canonical.adapter.descriptor.js +29 -0
- package/dist/adapters/drizzle/canonical.adapter.descriptor.js.map +1 -0
- package/dist/adapters/drizzle/contracts.d.ts +24 -0
- package/dist/adapters/drizzle/contracts.d.ts.map +1 -0
- package/dist/adapters/drizzle/contracts.js +5 -0
- package/dist/adapters/drizzle/contracts.js.map +1 -0
- package/dist/adapters/drizzle/docs/storage.adapters.drizzle.docs.descriptor.d.ts +4 -0
- package/dist/adapters/drizzle/docs/storage.adapters.drizzle.docs.descriptor.d.ts.map +1 -0
- package/dist/adapters/drizzle/docs/storage.adapters.drizzle.docs.descriptor.js +187 -0
- package/dist/adapters/drizzle/docs/storage.adapters.drizzle.docs.descriptor.js.map +1 -0
- package/dist/adapters/drizzle/drizzle-journal.migration-format.impl.d.ts +15 -0
- package/dist/adapters/drizzle/drizzle-journal.migration-format.impl.d.ts.map +1 -0
- package/dist/adapters/drizzle/drizzle-journal.migration-format.impl.js +59 -0
- package/dist/adapters/drizzle/drizzle-journal.migration-format.impl.js.map +1 -0
- package/dist/adapters/drizzle/drizzle-journal.migration-format.plugin.d.ts +5 -0
- package/dist/adapters/drizzle/drizzle-journal.migration-format.plugin.d.ts.map +1 -0
- package/dist/adapters/drizzle/drizzle-journal.migration-format.plugin.js +27 -0
- package/dist/adapters/drizzle/drizzle-journal.migration-format.plugin.js.map +1 -0
- package/dist/adapters/drizzle/drizzle.adapter.descriptor.d.ts +2 -0
- package/dist/adapters/drizzle/drizzle.adapter.descriptor.d.ts.map +1 -0
- package/dist/adapters/drizzle/drizzle.adapter.descriptor.js +3 -0
- package/dist/adapters/drizzle/drizzle.adapter.descriptor.js.map +1 -0
- package/dist/adapters/drizzle/drizzle.adapter.impl.d.ts +37 -0
- package/dist/adapters/drizzle/drizzle.adapter.impl.d.ts.map +1 -0
- package/dist/adapters/drizzle/drizzle.adapter.impl.js +1163 -0
- package/dist/adapters/drizzle/drizzle.adapter.impl.js.map +1 -0
- package/dist/adapters/drizzle/extensions.d.ts +5 -0
- package/dist/adapters/drizzle/extensions.d.ts.map +1 -0
- package/dist/adapters/drizzle/extensions.js +30 -0
- package/dist/adapters/drizzle/extensions.js.map +1 -0
- package/dist/adapters/drizzle/index.d.ts +12 -0
- package/dist/adapters/drizzle/index.d.ts.map +1 -0
- package/dist/adapters/drizzle/index.js +12 -0
- package/dist/adapters/drizzle/index.js.map +1 -0
- package/dist/adapters/drizzle/libsql-migrator.d.ts +23 -0
- package/dist/adapters/drizzle/libsql-migrator.d.ts.map +1 -0
- package/dist/adapters/drizzle/libsql-migrator.js +67 -0
- package/dist/adapters/drizzle/libsql-migrator.js.map +1 -0
- package/dist/adapters/drizzle/libsql.d.ts +15 -0
- package/dist/adapters/drizzle/libsql.d.ts.map +1 -0
- package/dist/adapters/drizzle/libsql.js +19 -0
- package/dist/adapters/drizzle/libsql.js.map +1 -0
- package/dist/adapters/drizzle/migration-files.d.ts +15 -0
- package/dist/adapters/drizzle/migration-files.d.ts.map +1 -0
- package/dist/adapters/drizzle/migration-files.js +54 -0
- package/dist/adapters/drizzle/migration-files.js.map +1 -0
- package/dist/adapters/drizzle/migration-statements.d.ts +7 -0
- package/dist/adapters/drizzle/migration-statements.d.ts.map +1 -0
- package/dist/adapters/drizzle/migration-statements.js +14 -0
- package/dist/adapters/drizzle/migration-statements.js.map +1 -0
- package/dist/adapters/drizzle/persistence-errors.d.ts +33 -0
- package/dist/adapters/drizzle/persistence-errors.d.ts.map +1 -0
- package/dist/adapters/drizzle/persistence-errors.js +75 -0
- package/dist/adapters/drizzle/persistence-errors.js.map +1 -0
- package/dist/adapters/drizzle/persistence-factory.d.ts +100 -0
- package/dist/adapters/drizzle/persistence-factory.d.ts.map +1 -0
- package/dist/adapters/drizzle/persistence-factory.js +391 -0
- package/dist/adapters/drizzle/persistence-factory.js.map +1 -0
- package/dist/adapters/drizzle/persistence.client.d.ts +73 -0
- package/dist/adapters/drizzle/persistence.client.d.ts.map +1 -0
- package/dist/adapters/drizzle/persistence.client.js +238 -0
- package/dist/adapters/drizzle/persistence.client.js.map +1 -0
- package/dist/adapters/drizzle/providers.d.ts +19 -0
- package/dist/adapters/drizzle/providers.d.ts.map +1 -0
- package/dist/adapters/drizzle/providers.js +62 -0
- package/dist/adapters/drizzle/providers.js.map +1 -0
- package/dist/adapters/drizzle/record-ddl.d.ts +13 -0
- package/dist/adapters/drizzle/record-ddl.d.ts.map +1 -0
- package/dist/adapters/drizzle/record-ddl.js +70 -0
- package/dist/adapters/drizzle/record-ddl.js.map +1 -0
- package/dist/adapters/drizzle/record-table.d.ts +59 -0
- package/dist/adapters/drizzle/record-table.d.ts.map +1 -0
- package/dist/adapters/drizzle/record-table.js +87 -0
- package/dist/adapters/drizzle/record-table.js.map +1 -0
- package/dist/adapters/drizzle/schemas/record-migration.d.ts +30 -0
- package/dist/adapters/drizzle/schemas/record-migration.d.ts.map +1 -0
- package/dist/adapters/drizzle/schemas/record-migration.js +12 -0
- package/dist/adapters/drizzle/schemas/record-migration.js.map +1 -0
- package/dist/adapters/drizzle/storage-adapter-drizzle.plugin.d.ts +26 -0
- package/dist/adapters/drizzle/storage-adapter-drizzle.plugin.d.ts.map +1 -0
- package/dist/adapters/drizzle/storage-adapter-drizzle.plugin.js +90 -0
- package/dist/adapters/drizzle/storage-adapter-drizzle.plugin.js.map +1 -0
- package/dist/adapters/drizzle/storage-drizzle-db.context.d.ts +53 -0
- package/dist/adapters/drizzle/storage-drizzle-db.context.d.ts.map +1 -0
- package/dist/adapters/drizzle/storage-drizzle-db.context.js +8 -0
- package/dist/adapters/drizzle/storage-drizzle-db.context.js.map +1 -0
- package/dist/adapters/drizzle/test.d.ts +60 -0
- package/dist/adapters/drizzle/test.d.ts.map +1 -0
- package/dist/adapters/drizzle/test.js +49 -0
- package/dist/adapters/drizzle/test.js.map +1 -0
- package/dist/adapters/drizzle/transforms.d.ts +42 -0
- package/dist/adapters/drizzle/transforms.d.ts.map +1 -0
- package/dist/adapters/drizzle/transforms.js +147 -0
- package/dist/adapters/drizzle/transforms.js.map +1 -0
- package/dist/adapters/filesystem/filesystem.adapter.descriptor.d.ts +13 -0
- package/dist/adapters/filesystem/filesystem.adapter.descriptor.d.ts.map +1 -0
- package/dist/adapters/filesystem/filesystem.adapter.descriptor.js +34 -0
- package/dist/adapters/filesystem/filesystem.adapter.descriptor.js.map +1 -0
- package/dist/adapters/filesystem/filesystem.adapter.impl.d.ts +57 -0
- package/dist/adapters/filesystem/filesystem.adapter.impl.d.ts.map +1 -0
- package/dist/adapters/filesystem/filesystem.adapter.impl.js +257 -0
- package/dist/adapters/filesystem/filesystem.adapter.impl.js.map +1 -0
- package/dist/adapters/filesystem/index.d.ts +10 -0
- package/dist/adapters/filesystem/index.d.ts.map +1 -0
- package/dist/adapters/filesystem/index.js +10 -0
- package/dist/adapters/filesystem/index.js.map +1 -0
- package/dist/adapters/filesystem/storage-adapter-filesystem.plugin.d.ts +11 -0
- package/dist/adapters/filesystem/storage-adapter-filesystem.plugin.d.ts.map +1 -0
- package/dist/adapters/filesystem/storage-adapter-filesystem.plugin.js +25 -0
- package/dist/adapters/filesystem/storage-adapter-filesystem.plugin.js.map +1 -0
- package/dist/adapters/fixture/fixture.adapter.descriptor.d.ts +14 -0
- package/dist/adapters/fixture/fixture.adapter.descriptor.d.ts.map +1 -0
- package/dist/adapters/fixture/fixture.adapter.descriptor.js +35 -0
- package/dist/adapters/fixture/fixture.adapter.descriptor.js.map +1 -0
- package/dist/adapters/fixture/fixture.adapter.impl.d.ts +41 -0
- package/dist/adapters/fixture/fixture.adapter.impl.d.ts.map +1 -0
- package/dist/adapters/fixture/fixture.adapter.impl.js +162 -0
- package/dist/adapters/fixture/fixture.adapter.impl.js.map +1 -0
- package/dist/adapters/fixture/index.d.ts +9 -0
- package/dist/adapters/fixture/index.d.ts.map +1 -0
- package/dist/adapters/fixture/index.js +9 -0
- package/dist/adapters/fixture/index.js.map +1 -0
- package/dist/adapters/fixture/storage-adapter-fixture.plugin.d.ts +10 -0
- package/dist/adapters/fixture/storage-adapter-fixture.plugin.d.ts.map +1 -0
- package/dist/adapters/fixture/storage-adapter-fixture.plugin.js +21 -0
- package/dist/adapters/fixture/storage-adapter-fixture.plugin.js.map +1 -0
- package/dist/adapters/idb/idb-backend.d.ts +33 -0
- package/dist/adapters/idb/idb-backend.d.ts.map +1 -0
- package/dist/adapters/idb/idb-backend.js +217 -0
- package/dist/adapters/idb/idb-backend.js.map +1 -0
- package/dist/adapters/idb/idb.adapter.descriptor.d.ts +14 -0
- package/dist/adapters/idb/idb.adapter.descriptor.d.ts.map +1 -0
- package/dist/adapters/idb/idb.adapter.descriptor.js +35 -0
- package/dist/adapters/idb/idb.adapter.descriptor.js.map +1 -0
- package/dist/adapters/idb/idb.adapter.impl.d.ts +56 -0
- package/dist/adapters/idb/idb.adapter.impl.d.ts.map +1 -0
- package/dist/adapters/idb/idb.adapter.impl.js +227 -0
- package/dist/adapters/idb/idb.adapter.impl.js.map +1 -0
- package/dist/adapters/idb/index.d.ts +10 -0
- package/dist/adapters/idb/index.d.ts.map +1 -0
- package/dist/adapters/idb/index.js +10 -0
- package/dist/adapters/idb/index.js.map +1 -0
- package/dist/adapters/idb/storage-adapter-idb.plugin.d.ts +11 -0
- package/dist/adapters/idb/storage-adapter-idb.plugin.d.ts.map +1 -0
- package/dist/adapters/idb/storage-adapter-idb.plugin.js +22 -0
- package/dist/adapters/idb/storage-adapter-idb.plugin.js.map +1 -0
- package/dist/adapters/json/filesystem-binding.d.ts +14 -0
- package/dist/adapters/json/filesystem-binding.d.ts.map +1 -0
- package/dist/adapters/json/filesystem-binding.js +7 -0
- package/dist/adapters/json/filesystem-binding.js.map +1 -0
- package/dist/adapters/json/index.d.ts +10 -0
- package/dist/adapters/json/index.d.ts.map +1 -0
- package/dist/adapters/json/index.js +10 -0
- package/dist/adapters/json/index.js.map +1 -0
- package/dist/adapters/json/json.adapter.descriptor.d.ts +10 -0
- package/dist/adapters/json/json.adapter.descriptor.d.ts.map +1 -0
- package/dist/adapters/json/json.adapter.descriptor.js +38 -0
- package/dist/adapters/json/json.adapter.descriptor.js.map +1 -0
- package/dist/adapters/json/json.adapter.impl.d.ts +59 -0
- package/dist/adapters/json/json.adapter.impl.d.ts.map +1 -0
- package/dist/adapters/json/json.adapter.impl.js +395 -0
- package/dist/adapters/json/json.adapter.impl.js.map +1 -0
- package/dist/adapters/json/storage-adapter-json.plugin.d.ts +9 -0
- package/dist/adapters/json/storage-adapter-json.plugin.d.ts.map +1 -0
- package/dist/adapters/json/storage-adapter-json.plugin.js +21 -0
- package/dist/adapters/json/storage-adapter-json.plugin.js.map +1 -0
- package/dist/adapters/localdb/index.d.ts +9 -0
- package/dist/adapters/localdb/index.d.ts.map +1 -0
- package/dist/adapters/localdb/index.js +9 -0
- package/dist/adapters/localdb/index.js.map +1 -0
- package/dist/adapters/localdb/localdb.adapter.descriptor.d.ts +10 -0
- package/dist/adapters/localdb/localdb.adapter.descriptor.d.ts.map +1 -0
- package/dist/adapters/localdb/localdb.adapter.descriptor.js +37 -0
- package/dist/adapters/localdb/localdb.adapter.descriptor.js.map +1 -0
- package/dist/adapters/localdb/localdb.adapter.impl.d.ts +237 -0
- package/dist/adapters/localdb/localdb.adapter.impl.d.ts.map +1 -0
- package/dist/adapters/localdb/localdb.adapter.impl.js +1370 -0
- package/dist/adapters/localdb/localdb.adapter.impl.js.map +1 -0
- package/dist/adapters/localdb/localdb.adapter.loader.consumer.d.ts +2 -0
- package/dist/adapters/localdb/localdb.adapter.loader.consumer.d.ts.map +1 -0
- package/dist/adapters/localdb/localdb.adapter.loader.consumer.js +2 -0
- package/dist/adapters/localdb/localdb.adapter.loader.consumer.js.map +1 -0
- package/dist/adapters/localdb/localdb.inputs.d.ts +3 -0
- package/dist/adapters/localdb/localdb.inputs.d.ts.map +1 -0
- package/dist/adapters/localdb/localdb.inputs.js +3 -0
- package/dist/adapters/localdb/localdb.inputs.js.map +1 -0
- package/dist/adapters/localdb/migration-failure.d.ts +3 -0
- package/dist/adapters/localdb/migration-failure.d.ts.map +1 -0
- package/dist/adapters/localdb/migration-failure.js +16 -0
- package/dist/adapters/localdb/migration-failure.js.map +1 -0
- package/dist/adapters/localdb/outcome.d.ts +13 -0
- package/dist/adapters/localdb/outcome.d.ts.map +1 -0
- package/dist/adapters/localdb/outcome.js +12 -0
- package/dist/adapters/localdb/outcome.js.map +1 -0
- package/dist/adapters/localdb/repository-query.d.ts +19 -0
- package/dist/adapters/localdb/repository-query.d.ts.map +1 -0
- package/dist/adapters/localdb/repository-query.js +127 -0
- package/dist/adapters/localdb/repository-query.js.map +1 -0
- package/dist/adapters/localdb/storage-adapter-localdb.plugin.d.ts +14 -0
- package/dist/adapters/localdb/storage-adapter-localdb.plugin.d.ts.map +1 -0
- package/dist/adapters/localdb/storage-adapter-localdb.plugin.js +30 -0
- package/dist/adapters/localdb/storage-adapter-localdb.plugin.js.map +1 -0
- package/dist/adapters/memory/index.d.ts +9 -0
- package/dist/adapters/memory/index.d.ts.map +1 -0
- package/dist/adapters/memory/index.js +9 -0
- package/dist/adapters/memory/index.js.map +1 -0
- package/dist/adapters/memory/memory-root-store.d.ts +20 -0
- package/dist/adapters/memory/memory-root-store.d.ts.map +1 -0
- package/dist/adapters/memory/memory-root-store.js +49 -0
- package/dist/adapters/memory/memory-root-store.js.map +1 -0
- package/dist/adapters/memory/memory.adapter.impl.d.ts +61 -0
- package/dist/adapters/memory/memory.adapter.impl.d.ts.map +1 -0
- package/dist/adapters/memory/memory.adapter.impl.js +718 -0
- package/dist/adapters/memory/memory.adapter.impl.js.map +1 -0
- package/dist/adapters/memory/memory.adapter.storage-adapter-memory.descriptor.d.ts +10 -0
- package/dist/adapters/memory/memory.adapter.storage-adapter-memory.descriptor.d.ts.map +1 -0
- package/dist/adapters/memory/memory.adapter.storage-adapter-memory.descriptor.js +37 -0
- package/dist/adapters/memory/memory.adapter.storage-adapter-memory.descriptor.js.map +1 -0
- package/dist/adapters/memory/storage-adapter-memory.plugin.d.ts +9 -0
- package/dist/adapters/memory/storage-adapter-memory.plugin.d.ts.map +1 -0
- package/dist/adapters/memory/storage-adapter-memory.plugin.js +44 -0
- package/dist/adapters/memory/storage-adapter-memory.plugin.js.map +1 -0
- package/dist/adapters/parse-adapter-input.d.ts +22 -0
- package/dist/adapters/parse-adapter-input.d.ts.map +1 -0
- package/dist/adapters/parse-adapter-input.js +36 -0
- package/dist/adapters/parse-adapter-input.js.map +1 -0
- package/dist/adapters/select-adapter.d.ts +36 -0
- package/dist/adapters/select-adapter.d.ts.map +1 -0
- package/dist/adapters/select-adapter.js +88 -0
- package/dist/adapters/select-adapter.js.map +1 -0
- package/dist/adapters/validate-for-persist.d.ts +21 -0
- package/dist/adapters/validate-for-persist.d.ts.map +1 -0
- package/dist/adapters/validate-for-persist.js +36 -0
- package/dist/adapters/validate-for-persist.js.map +1 -0
- package/dist/backup/backup.plugin.d.ts +276 -0
- package/dist/backup/backup.plugin.d.ts.map +1 -0
- package/dist/backup/backup.plugin.js +72 -0
- package/dist/backup/backup.plugin.js.map +1 -0
- package/dist/backup/channels/backup.channel.d.ts +21 -0
- package/dist/backup/channels/backup.channel.d.ts.map +1 -0
- package/dist/backup/channels/backup.channel.js +89 -0
- package/dist/backup/channels/backup.channel.js.map +1 -0
- package/dist/backup/config/storage.backup.config.descriptor.d.ts +57 -0
- package/dist/backup/config/storage.backup.config.descriptor.d.ts.map +1 -0
- package/dist/backup/config/storage.backup.config.descriptor.js +53 -0
- package/dist/backup/config/storage.backup.config.descriptor.js.map +1 -0
- package/dist/backup/core/hash.d.ts +8 -0
- package/dist/backup/core/hash.d.ts.map +1 -0
- package/dist/backup/core/hash.js +10 -0
- package/dist/backup/core/hash.js.map +1 -0
- package/dist/backup/core/homes.d.ts +13 -0
- package/dist/backup/core/homes.d.ts.map +1 -0
- package/dist/backup/core/homes.js +54 -0
- package/dist/backup/core/homes.js.map +1 -0
- package/dist/backup/core/index.d.ts +17 -0
- package/dist/backup/core/index.d.ts.map +1 -0
- package/dist/backup/core/index.js +12 -0
- package/dist/backup/core/index.js.map +1 -0
- package/dist/backup/core/io.d.ts +76 -0
- package/dist/backup/core/io.d.ts.map +1 -0
- package/dist/backup/core/io.js +177 -0
- package/dist/backup/core/io.js.map +1 -0
- package/dist/backup/core/paths.d.ts +50 -0
- package/dist/backup/core/paths.d.ts.map +1 -0
- package/dist/backup/core/paths.js +75 -0
- package/dist/backup/core/paths.js.map +1 -0
- package/dist/backup/core/readiness.d.ts +9 -0
- package/dist/backup/core/readiness.d.ts.map +1 -0
- package/dist/backup/core/readiness.js +104 -0
- package/dist/backup/core/readiness.js.map +1 -0
- package/dist/backup/core/recovery.d.ts +11 -0
- package/dist/backup/core/recovery.d.ts.map +1 -0
- package/dist/backup/core/recovery.js +75 -0
- package/dist/backup/core/recovery.js.map +1 -0
- package/dist/backup/core/registry.d.ts +13 -0
- package/dist/backup/core/registry.d.ts.map +1 -0
- package/dist/backup/core/registry.js +18 -0
- package/dist/backup/core/registry.js.map +1 -0
- package/dist/backup/core/restore.d.ts +36 -0
- package/dist/backup/core/restore.d.ts.map +1 -0
- package/dist/backup/core/restore.js +280 -0
- package/dist/backup/core/restore.js.map +1 -0
- package/dist/backup/core/rotate.d.ts +19 -0
- package/dist/backup/core/rotate.d.ts.map +1 -0
- package/dist/backup/core/rotate.js +153 -0
- package/dist/backup/core/rotate.js.map +1 -0
- package/dist/backup/core/rotation.d.ts +19 -0
- package/dist/backup/core/rotation.d.ts.map +1 -0
- package/dist/backup/core/rotation.js +100 -0
- package/dist/backup/core/rotation.js.map +1 -0
- package/dist/backup/core/snapshot.d.ts +45 -0
- package/dist/backup/core/snapshot.d.ts.map +1 -0
- package/dist/backup/core/snapshot.js +217 -0
- package/dist/backup/core/snapshot.js.map +1 -0
- package/dist/backup/docs/backup.disaster-recovery.docs.descriptor.d.ts +19 -0
- package/dist/backup/docs/backup.disaster-recovery.docs.descriptor.d.ts.map +1 -0
- package/dist/backup/docs/backup.disaster-recovery.docs.descriptor.js +42 -0
- package/dist/backup/docs/backup.disaster-recovery.docs.descriptor.js.map +1 -0
- package/dist/backup/index.d.ts +19 -0
- package/dist/backup/index.d.ts.map +1 -0
- package/dist/backup/index.js +16 -0
- package/dist/backup/index.js.map +1 -0
- package/dist/backup/jobs/backup.snapshot.descriptor.d.ts +95 -0
- package/dist/backup/jobs/backup.snapshot.descriptor.d.ts.map +1 -0
- package/dist/backup/jobs/backup.snapshot.descriptor.js +33 -0
- package/dist/backup/jobs/backup.snapshot.descriptor.js.map +1 -0
- package/dist/backup/jobs/backup.snapshot.impl.d.ts +59 -0
- package/dist/backup/jobs/backup.snapshot.impl.d.ts.map +1 -0
- package/dist/backup/jobs/backup.snapshot.impl.js +393 -0
- package/dist/backup/jobs/backup.snapshot.impl.js.map +1 -0
- package/dist/backup/jobs/backup.snapshot.schema.d.ts +3 -0
- package/dist/backup/jobs/backup.snapshot.schema.d.ts.map +1 -0
- package/dist/backup/jobs/backup.snapshot.schema.js +3 -0
- package/dist/backup/jobs/backup.snapshot.schema.js.map +1 -0
- package/dist/backup/kinds/backup-preflight.kind.d.ts +16 -0
- package/dist/backup/kinds/backup-preflight.kind.d.ts.map +1 -0
- package/dist/backup/kinds/backup-preflight.kind.js +27 -0
- package/dist/backup/kinds/backup-preflight.kind.js.map +1 -0
- package/dist/backup/kinds/backup-recovery-plan.kind.d.ts +11 -0
- package/dist/backup/kinds/backup-recovery-plan.kind.d.ts.map +1 -0
- package/dist/backup/kinds/backup-recovery-plan.kind.js +16 -0
- package/dist/backup/kinds/backup-recovery-plan.kind.js.map +1 -0
- package/dist/backup/kinds/backup-target.kind.d.ts +16 -0
- package/dist/backup/kinds/backup-target.kind.d.ts.map +1 -0
- package/dist/backup/kinds/backup-target.kind.js +21 -0
- package/dist/backup/kinds/backup-target.kind.js.map +1 -0
- package/dist/backup/schemas/core.d.ts +169 -0
- package/dist/backup/schemas/core.d.ts.map +1 -0
- package/dist/backup/schemas/core.js +117 -0
- package/dist/backup/schemas/core.js.map +1 -0
- package/dist/backup/schemas/disaster-recovery.d.ts +512 -0
- package/dist/backup/schemas/disaster-recovery.d.ts.map +1 -0
- package/dist/backup/schemas/disaster-recovery.js +410 -0
- package/dist/backup/schemas/disaster-recovery.js.map +1 -0
- package/dist/backup/schemas/index.d.ts +10 -0
- package/dist/backup/schemas/index.d.ts.map +1 -0
- package/dist/backup/schemas/index.js +10 -0
- package/dist/backup/schemas/index.js.map +1 -0
- package/dist/backup/schemas/job.d.ts +102 -0
- package/dist/backup/schemas/job.d.ts.map +1 -0
- package/dist/backup/schemas/job.js +47 -0
- package/dist/backup/schemas/job.js.map +1 -0
- package/dist/backup/schemas/preflight.d.ts +38 -0
- package/dist/backup/schemas/preflight.d.ts.map +1 -0
- package/dist/backup/schemas/preflight.js +21 -0
- package/dist/backup/schemas/preflight.js.map +1 -0
- package/dist/backup/schemas/snapshot.d.ts +110 -0
- package/dist/backup/schemas/snapshot.d.ts.map +1 -0
- package/dist/backup/schemas/snapshot.js +84 -0
- package/dist/backup/schemas/snapshot.js.map +1 -0
- package/dist/backup/schemas/target.d.ts +95 -0
- package/dist/backup/schemas/target.d.ts.map +1 -0
- package/dist/backup/schemas/target.js +105 -0
- package/dist/backup/schemas/target.js.map +1 -0
- package/dist/backup/storage/snapshot.record.descriptor.d.ts +10 -0
- package/dist/backup/storage/snapshot.record.descriptor.d.ts.map +1 -0
- package/dist/backup/storage/snapshot.record.descriptor.js +41 -0
- package/dist/backup/storage/snapshot.record.descriptor.js.map +1 -0
- package/dist/backup/targets/awareness-bus.target.descriptor.d.ts +10 -0
- package/dist/backup/targets/awareness-bus.target.descriptor.d.ts.map +1 -0
- package/dist/backup/targets/awareness-bus.target.descriptor.js +32 -0
- package/dist/backup/targets/awareness-bus.target.descriptor.js.map +1 -0
- package/dist/backup/targets/presence-identity.target.descriptor.d.ts +10 -0
- package/dist/backup/targets/presence-identity.target.descriptor.d.ts.map +1 -0
- package/dist/backup/targets/presence-identity.target.descriptor.js +40 -0
- package/dist/backup/targets/presence-identity.target.descriptor.js.map +1 -0
- package/dist/backup/targets/presence-inner.target.descriptor.d.ts +10 -0
- package/dist/backup/targets/presence-inner.target.descriptor.d.ts.map +1 -0
- package/dist/backup/targets/presence-inner.target.descriptor.js +36 -0
- package/dist/backup/targets/presence-inner.target.descriptor.js.map +1 -0
- package/dist/backup/targets/storage-records.target.descriptor.d.ts +16 -0
- package/dist/backup/targets/storage-records.target.descriptor.d.ts.map +1 -0
- package/dist/backup/targets/storage-records.target.descriptor.js +38 -0
- package/dist/backup/targets/storage-records.target.descriptor.js.map +1 -0
- package/dist/bridge/index.d.ts +2 -2
- package/dist/bridge/index.d.ts.map +1 -1
- package/dist/bridge/index.js +1 -1
- package/dist/bridge/index.js.map +1 -1
- package/dist/bridge/storage-kind-bridge.d.ts +13 -2
- package/dist/bridge/storage-kind-bridge.d.ts.map +1 -1
- package/dist/bridge/storage-kind-bridge.js +72 -69
- package/dist/bridge/storage-kind-bridge.js.map +1 -1
- package/dist/bridge/types.d.ts +4 -3
- package/dist/bridge/types.d.ts.map +1 -1
- package/dist/cli/backup/backup.cli-group.descriptor.d.ts +9 -0
- package/dist/cli/backup/backup.cli-group.descriptor.d.ts.map +1 -0
- package/dist/cli/backup/backup.cli-group.descriptor.js +16 -0
- package/dist/cli/backup/backup.cli-group.descriptor.js.map +1 -0
- package/dist/cli/backup/commands/backup.now.cli-command.descriptor.d.ts +4 -0
- package/dist/cli/backup/commands/backup.now.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/backup/commands/backup.now.cli-command.descriptor.js +24 -0
- package/dist/cli/backup/commands/backup.now.cli-command.descriptor.js.map +1 -0
- package/dist/cli/backup/commands/backup.now.cli-command.impl.d.ts +26 -0
- package/dist/cli/backup/commands/backup.now.cli-command.impl.d.ts.map +1 -0
- package/dist/cli/backup/commands/backup.now.cli-command.impl.js +61 -0
- package/dist/cli/backup/commands/backup.now.cli-command.impl.js.map +1 -0
- package/dist/cli/backup/commands/backup.restore.cli-command.descriptor.d.ts +4 -0
- package/dist/cli/backup/commands/backup.restore.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/backup/commands/backup.restore.cli-command.descriptor.js +24 -0
- package/dist/cli/backup/commands/backup.restore.cli-command.descriptor.js.map +1 -0
- package/dist/cli/backup/commands/backup.restore.cli-command.impl.d.ts +23 -0
- package/dist/cli/backup/commands/backup.restore.cli-command.impl.d.ts.map +1 -0
- package/dist/cli/backup/commands/backup.restore.cli-command.impl.js +50 -0
- package/dist/cli/backup/commands/backup.restore.cli-command.impl.js.map +1 -0
- package/dist/cli/backup/commands/backup.status.cli-command.descriptor.d.ts +4 -0
- package/dist/cli/backup/commands/backup.status.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/backup/commands/backup.status.cli-command.descriptor.js +19 -0
- package/dist/cli/backup/commands/backup.status.cli-command.descriptor.js.map +1 -0
- package/dist/cli/backup/commands/backup.status.cli-command.impl.d.ts +21 -0
- package/dist/cli/backup/commands/backup.status.cli-command.impl.d.ts.map +1 -0
- package/dist/cli/backup/commands/backup.status.cli-command.impl.js +76 -0
- package/dist/cli/backup/commands/backup.status.cli-command.impl.js.map +1 -0
- package/dist/cli/backup/commands/backup.verify.cli-command.descriptor.d.ts +4 -0
- package/dist/cli/backup/commands/backup.verify.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/backup/commands/backup.verify.cli-command.descriptor.js +20 -0
- package/dist/cli/backup/commands/backup.verify.cli-command.descriptor.js.map +1 -0
- package/dist/cli/backup/commands/backup.verify.cli-command.impl.d.ts +20 -0
- package/dist/cli/backup/commands/backup.verify.cli-command.impl.d.ts.map +1 -0
- package/dist/cli/backup/commands/backup.verify.cli-command.impl.js +48 -0
- package/dist/cli/backup/commands/backup.verify.cli-command.impl.js.map +1 -0
- package/dist/cli/backup/plugin.d.ts +5 -0
- package/dist/cli/backup/plugin.d.ts.map +1 -0
- package/dist/cli/backup/plugin.js +30 -0
- package/dist/cli/backup/plugin.js.map +1 -0
- package/dist/cli/commands/list/storage.list.cli-command.descriptor.d.ts +1 -1
- package/dist/cli/commands/list/storage.list.cli-command.descriptor.d.ts.map +1 -1
- package/dist/cli/commands/list/storage.list.cli-command.impl.d.ts +8 -1
- package/dist/cli/commands/list/storage.list.cli-command.impl.d.ts.map +1 -1
- package/dist/cli/commands/list/storage.list.cli-command.impl.js +17 -8
- package/dist/cli/commands/list/storage.list.cli-command.impl.js.map +1 -1
- package/dist/cli/commands/sync/pull/storage.sync.pull.cli-command.descriptor.d.ts +1 -1
- package/dist/cli/commands/sync/pull/storage.sync.pull.cli-command.descriptor.d.ts.map +1 -1
- package/dist/cli/commands/sync/pull/storage.sync.pull.cli-command.impl.d.ts +9 -1
- package/dist/cli/commands/sync/pull/storage.sync.pull.cli-command.impl.d.ts.map +1 -1
- package/dist/cli/commands/sync/pull/storage.sync.pull.cli-command.impl.js +110 -76
- package/dist/cli/commands/sync/pull/storage.sync.pull.cli-command.impl.js.map +1 -1
- package/dist/cli/commands/sync/push/storage.sync.push.cli-command.descriptor.d.ts +1 -1
- package/dist/cli/commands/sync/push/storage.sync.push.cli-command.descriptor.d.ts.map +1 -1
- package/dist/cli/commands/sync/push/storage.sync.push.cli-command.impl.d.ts +9 -1
- package/dist/cli/commands/sync/push/storage.sync.push.cli-command.impl.d.ts.map +1 -1
- package/dist/cli/commands/sync/push/storage.sync.push.cli-command.impl.js +131 -108
- package/dist/cli/commands/sync/push/storage.sync.push.cli-command.impl.js.map +1 -1
- package/dist/cli/commands/sync/resolve/storage.sync.resolve.cli-command.descriptor.d.ts +1 -1
- package/dist/cli/commands/sync/resolve/storage.sync.resolve.cli-command.descriptor.d.ts.map +1 -1
- package/dist/cli/commands/sync/resolve/storage.sync.resolve.cli-command.impl.d.ts +12 -1
- package/dist/cli/commands/sync/resolve/storage.sync.resolve.cli-command.impl.d.ts.map +1 -1
- package/dist/cli/commands/sync/resolve/storage.sync.resolve.cli-command.impl.js +34 -26
- package/dist/cli/commands/sync/resolve/storage.sync.resolve.cli-command.impl.js.map +1 -1
- package/dist/cli/commands/sync/status/storage.sync.status.cli-command.descriptor.d.ts +1 -1
- package/dist/cli/commands/sync/status/storage.sync.status.cli-command.descriptor.d.ts.map +1 -1
- package/dist/cli/commands/sync/status/storage.sync.status.cli-command.impl.d.ts +11 -1
- package/dist/cli/commands/sync/status/storage.sync.status.cli-command.impl.d.ts.map +1 -1
- package/dist/cli/commands/sync/status/storage.sync.status.cli-command.impl.js +89 -42
- package/dist/cli/commands/sync/status/storage.sync.status.cli-command.impl.js.map +1 -1
- package/dist/cli/commands/sync/sync-command-input.d.ts +20 -0
- package/dist/cli/commands/sync/sync-command-input.d.ts.map +1 -0
- package/dist/cli/commands/sync/sync-command-input.js +20 -0
- package/dist/cli/commands/sync/sync-command-input.js.map +1 -0
- package/dist/cli/gc/commands/gc.run.cli-command.descriptor.d.ts +4 -0
- package/dist/cli/gc/commands/gc.run.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/gc/commands/gc.run.cli-command.descriptor.js +20 -0
- package/dist/cli/gc/commands/gc.run.cli-command.descriptor.js.map +1 -0
- package/dist/cli/gc/commands/gc.run.cli-command.impl.d.ts +24 -0
- package/dist/cli/gc/commands/gc.run.cli-command.impl.d.ts.map +1 -0
- package/dist/cli/gc/commands/gc.run.cli-command.impl.js +104 -0
- package/dist/cli/gc/commands/gc.run.cli-command.impl.js.map +1 -0
- package/dist/cli/gc/commands/gc.status.cli-command.descriptor.d.ts +4 -0
- package/dist/cli/gc/commands/gc.status.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/gc/commands/gc.status.cli-command.descriptor.js +19 -0
- package/dist/cli/gc/commands/gc.status.cli-command.descriptor.js.map +1 -0
- package/dist/cli/gc/commands/gc.status.cli-command.impl.d.ts +21 -0
- package/dist/cli/gc/commands/gc.status.cli-command.impl.d.ts.map +1 -0
- package/dist/cli/gc/commands/gc.status.cli-command.impl.js +74 -0
- package/dist/cli/gc/commands/gc.status.cli-command.impl.js.map +1 -0
- package/dist/cli/gc/gc.cli-group.descriptor.d.ts +4 -0
- package/dist/cli/gc/gc.cli-group.descriptor.d.ts.map +1 -0
- package/dist/cli/gc/gc.cli-group.descriptor.js +11 -0
- package/dist/cli/gc/gc.cli-group.descriptor.js.map +1 -0
- package/dist/cli/gc/plugin.d.ts +5 -0
- package/dist/cli/gc/plugin.d.ts.map +1 -0
- package/dist/cli/gc/plugin.js +28 -0
- package/dist/cli/gc/plugin.js.map +1 -0
- package/dist/cli/plugin.d.ts +17 -0
- package/dist/cli/plugin.d.ts.map +1 -0
- package/dist/cli/plugin.js +51 -0
- package/dist/cli/plugin.js.map +1 -0
- package/dist/cli/storage.cli-group.descriptor.d.ts +1 -1
- package/dist/cli/storage.cli-group.descriptor.d.ts.map +1 -1
- package/dist/cli/storage.sync.cli-group.descriptor.d.ts +1 -1
- package/dist/cli/storage.sync.cli-group.descriptor.d.ts.map +1 -1
- package/dist/cli/types.d.ts +4 -20
- package/dist/cli/types.d.ts.map +1 -1
- package/dist/cli/types.js +3 -4
- package/dist/cli/types.js.map +1 -1
- package/dist/client/browse-adapter.d.ts +49 -0
- package/dist/client/browse-adapter.d.ts.map +1 -0
- package/dist/client/browse-adapter.js +99 -0
- package/dist/client/browse-adapter.js.map +1 -0
- package/dist/client/diagnose-adapter.d.ts +9 -0
- package/dist/client/diagnose-adapter.d.ts.map +1 -0
- package/dist/client/diagnose-adapter.js +9 -0
- package/dist/client/diagnose-adapter.js.map +1 -0
- package/dist/client/index.d.ts +7 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +5 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/list-browsable-adapters.d.ts +4 -3
- package/dist/client/list-browsable-adapters.d.ts.map +1 -1
- package/dist/client/list-browsable-adapters.js +3 -8
- package/dist/client/list-browsable-adapters.js.map +1 -1
- package/dist/client/object-adapter.d.ts +33 -0
- package/dist/client/object-adapter.d.ts.map +1 -0
- package/dist/client/object-adapter.js +45 -0
- package/dist/client/object-adapter.js.map +1 -0
- package/dist/client/storage-explorer-capability.d.ts +81 -0
- package/dist/client/storage-explorer-capability.d.ts.map +1 -0
- package/dist/client/storage-explorer-capability.impl.worker.d.ts +23 -0
- package/dist/client/storage-explorer-capability.impl.worker.d.ts.map +1 -0
- package/dist/client/storage-explorer-capability.impl.worker.js +124 -0
- package/dist/client/storage-explorer-capability.impl.worker.js.map +1 -0
- package/dist/client/storage-explorer-capability.js +125 -0
- package/dist/client/storage-explorer-capability.js.map +1 -0
- package/dist/client/storage-failure.d.ts +43 -0
- package/dist/client/storage-failure.d.ts.map +1 -0
- package/dist/client/storage-failure.js +100 -0
- package/dist/client/storage-failure.js.map +1 -0
- package/dist/daemon/commands/browse.d.ts +29 -0
- package/dist/daemon/commands/browse.d.ts.map +1 -0
- package/dist/daemon/commands/browse.js +91 -0
- package/dist/daemon/commands/browse.js.map +1 -0
- package/dist/daemon/commands/sync.d.ts +1 -1
- package/dist/daemon/commands/sync.d.ts.map +1 -1
- package/dist/daemon/commands/sync.js +60 -52
- package/dist/daemon/commands/sync.js.map +1 -1
- package/dist/docs/records.docs.descriptor.d.ts +1 -1
- package/dist/docs/records.docs.descriptor.d.ts.map +1 -1
- package/dist/docs/records.docs.descriptor.js +136 -151
- package/dist/docs/records.docs.descriptor.js.map +1 -1
- package/dist/docs/storage.adapters.docs.descriptor.d.ts +4 -0
- package/dist/docs/storage.adapters.docs.descriptor.d.ts.map +1 -0
- package/dist/docs/storage.adapters.docs.descriptor.js +175 -0
- package/dist/docs/storage.adapters.docs.descriptor.js.map +1 -0
- package/dist/docs/storage.browse.docs.descriptor.d.ts +4 -0
- package/dist/docs/storage.browse.docs.descriptor.d.ts.map +1 -0
- package/dist/docs/storage.browse.docs.descriptor.js +74 -0
- package/dist/docs/storage.browse.docs.descriptor.js.map +1 -0
- package/dist/docs/storage.docs.descriptor.d.ts +4 -0
- package/dist/docs/storage.docs.descriptor.d.ts.map +1 -0
- package/dist/docs/storage.docs.descriptor.js +51 -0
- package/dist/docs/storage.docs.descriptor.js.map +1 -0
- package/dist/docs/storage.manifests.docs.descriptor.d.ts +4 -0
- package/dist/docs/storage.manifests.docs.descriptor.d.ts.map +1 -0
- package/dist/docs/{manifests.docs.descriptor.js → storage.manifests.docs.descriptor.js} +69 -34
- package/dist/docs/storage.manifests.docs.descriptor.js.map +1 -0
- package/dist/docs/sync.docs.descriptor.d.ts +1 -1
- package/dist/docs/sync.docs.descriptor.d.ts.map +1 -1
- package/dist/docs/sync.docs.descriptor.js +140 -150
- package/dist/docs/sync.docs.descriptor.js.map +1 -1
- package/dist/docs/transform.docs.descriptor.d.ts +4 -0
- package/dist/docs/transform.docs.descriptor.d.ts.map +1 -0
- package/dist/docs/transform.docs.descriptor.js +134 -0
- package/dist/docs/transform.docs.descriptor.js.map +1 -0
- package/dist/host-files.d.ts +35 -0
- package/dist/host-files.d.ts.map +1 -0
- package/dist/host-files.js +60 -0
- package/dist/host-files.js.map +1 -0
- package/dist/index.d.ts +15 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/dist/interfaces/adapter.d.ts +166 -47
- package/dist/interfaces/adapter.d.ts.map +1 -1
- package/dist/interfaces/document-store.d.ts +41 -1
- package/dist/interfaces/document-store.d.ts.map +1 -1
- package/dist/interfaces/index.d.ts +8 -7
- package/dist/interfaces/index.d.ts.map +1 -1
- package/dist/interfaces/index.js +9 -7
- package/dist/interfaces/index.js.map +1 -1
- package/dist/interfaces/object-store.d.ts +54 -0
- package/dist/interfaces/object-store.d.ts.map +1 -0
- package/dist/interfaces/object-store.js +13 -0
- package/dist/interfaces/object-store.js.map +1 -0
- package/dist/interfaces/query-builder.d.ts +2 -30
- package/dist/interfaces/query-builder.d.ts.map +1 -1
- package/dist/interfaces/query-builder.js +0 -9
- package/dist/interfaces/query-builder.js.map +1 -1
- package/dist/interfaces/record/index.d.ts +1 -1
- package/dist/interfaces/record/index.d.ts.map +1 -1
- package/dist/interfaces/record/index.js +1 -1
- package/dist/interfaces/record/index.js.map +1 -1
- package/dist/interfaces/record/interface.d.ts +30 -9
- package/dist/interfaces/record/interface.d.ts.map +1 -1
- package/dist/interfaces/schema/index.d.ts +2 -2
- package/dist/interfaces/schema/index.d.ts.map +1 -1
- package/dist/interfaces/schema/index.js +2 -2
- package/dist/interfaces/schema/index.js.map +1 -1
- package/dist/interfaces/schema/schema-interface.d.ts +9 -8
- package/dist/interfaces/schema/schema-interface.d.ts.map +1 -1
- package/dist/interfaces/schema/table-interface.d.ts +4 -3
- package/dist/interfaces/schema/table-interface.d.ts.map +1 -1
- package/dist/interfaces/storage-consumer-fs.d.ts +25 -27
- package/dist/interfaces/storage-consumer-fs.d.ts.map +1 -1
- package/dist/interfaces/storage-consumer-fs.js +29 -30
- package/dist/interfaces/storage-consumer-fs.js.map +1 -1
- package/dist/manifest/base.d.ts +104 -22
- package/dist/manifest/base.d.ts.map +1 -1
- package/dist/manifest/base.js +393 -151
- package/dist/manifest/base.js.map +1 -1
- package/dist/manifest/cloud-sync.browser.d.ts +3 -0
- package/dist/manifest/cloud-sync.browser.d.ts.map +1 -0
- package/dist/manifest/cloud-sync.browser.js +3 -0
- package/dist/manifest/cloud-sync.browser.js.map +1 -0
- package/dist/manifest/cloud-sync.consumer.d.ts +2 -6
- package/dist/manifest/cloud-sync.consumer.d.ts.map +1 -1
- package/dist/manifest/cloud-sync.consumer.js +2 -81
- package/dist/manifest/cloud-sync.consumer.js.map +1 -1
- package/dist/manifest/cloud-sync.core.d.ts +30 -0
- package/dist/manifest/cloud-sync.core.d.ts.map +1 -0
- package/dist/manifest/cloud-sync.core.js +67 -0
- package/dist/manifest/cloud-sync.core.js.map +1 -0
- package/dist/manifest/cloud-sync.d.ts +3 -0
- package/dist/manifest/cloud-sync.d.ts.map +1 -0
- package/dist/manifest/cloud-sync.js +8 -0
- package/dist/manifest/cloud-sync.js.map +1 -0
- package/dist/manifest/index.d.ts +1 -1
- package/dist/manifest/index.d.ts.map +1 -1
- package/dist/manifest/index.js +1 -1
- package/dist/manifest/index.js.map +1 -1
- package/dist/manifest/source-policy.d.ts +21 -4
- package/dist/manifest/source-policy.d.ts.map +1 -1
- package/dist/manifest/source-policy.js +48 -50
- package/dist/manifest/source-policy.js.map +1 -1
- package/dist/migration-format/index.d.ts +3 -0
- package/dist/migration-format/index.d.ts.map +1 -0
- package/dist/migration-format/index.js +3 -0
- package/dist/migration-format/index.js.map +1 -0
- package/dist/migration-format/migration-format.kind.d.ts +5 -0
- package/dist/migration-format/migration-format.kind.d.ts.map +1 -0
- package/dist/migration-format/migration-format.kind.js +18 -0
- package/dist/migration-format/migration-format.kind.js.map +1 -0
- package/dist/path-format.d.ts +4 -0
- package/dist/path-format.d.ts.map +1 -0
- package/dist/path-format.js +71 -0
- package/dist/path-format.js.map +1 -0
- package/dist/path-policy.d.ts +28 -0
- package/dist/path-policy.d.ts.map +1 -0
- package/dist/path-policy.js +123 -0
- package/dist/path-policy.js.map +1 -0
- package/dist/paths.d.ts +14 -5
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +17 -150
- package/dist/paths.js.map +1 -1
- package/dist/policy/context.d.ts +3 -2
- package/dist/policy/context.d.ts.map +1 -1
- package/dist/policy/context.js +13 -16
- package/dist/policy/context.js.map +1 -1
- package/dist/policy/index.d.ts +3 -3
- package/dist/policy/index.d.ts.map +1 -1
- package/dist/policy/index.js +3 -3
- package/dist/policy/index.js.map +1 -1
- package/dist/policy/overrides.d.ts +5 -39
- package/dist/policy/overrides.d.ts.map +1 -1
- package/dist/policy/overrides.js +19 -24
- package/dist/policy/overrides.js.map +1 -1
- package/dist/policy/persistence.d.ts +2 -35
- package/dist/policy/persistence.d.ts.map +1 -1
- package/dist/policy/persistence.js +2 -12
- package/dist/policy/persistence.js.map +1 -1
- package/dist/policy/types.d.ts +5 -5
- package/dist/policy/types.d.ts.map +1 -1
- package/dist/record/array-fields.d.ts +15 -0
- package/dist/record/array-fields.d.ts.map +1 -0
- package/dist/record/array-fields.js +80 -0
- package/dist/record/array-fields.js.map +1 -0
- package/dist/record/atomic.d.ts +5 -0
- package/dist/record/atomic.d.ts.map +1 -0
- package/dist/record/atomic.js +10 -0
- package/dist/record/atomic.js.map +1 -0
- package/dist/record/base.d.ts +177 -39
- package/dist/record/base.d.ts.map +1 -1
- package/dist/record/base.js +1708 -525
- package/dist/record/base.js.map +1 -1
- package/dist/record/columns.d.ts +23 -0
- package/dist/record/columns.d.ts.map +1 -0
- package/dist/record/columns.js +161 -0
- package/dist/record/columns.js.map +1 -0
- package/dist/record/delivery.d.ts +57 -0
- package/dist/record/delivery.d.ts.map +1 -0
- package/dist/record/delivery.js +262 -0
- package/dist/record/delivery.js.map +1 -0
- package/dist/record/events.js +1 -1
- package/dist/record/events.js.map +1 -1
- package/dist/record/extensions.d.ts +17 -14
- package/dist/record/extensions.d.ts.map +1 -1
- package/dist/record/extensions.js +79 -53
- package/dist/record/extensions.js.map +1 -1
- package/dist/record/failure-condition.d.ts +14 -0
- package/dist/record/failure-condition.d.ts.map +1 -0
- package/dist/record/failure-condition.js +17 -0
- package/dist/record/failure-condition.js.map +1 -0
- package/dist/record/index.d.ts +5 -1
- package/dist/record/index.d.ts.map +1 -1
- package/dist/record/index.js +5 -1
- package/dist/record/index.js.map +1 -1
- package/dist/record/merge.d.ts +21 -0
- package/dist/record/merge.d.ts.map +1 -0
- package/dist/record/merge.js +147 -0
- package/dist/record/merge.js.map +1 -0
- package/dist/record/relations.d.ts +23 -0
- package/dist/record/relations.d.ts.map +1 -0
- package/dist/record/relations.js +164 -0
- package/dist/record/relations.js.map +1 -0
- package/dist/record/revision.d.ts +5 -0
- package/dist/record/revision.d.ts.map +1 -0
- package/dist/record/revision.js +11 -0
- package/dist/record/revision.js.map +1 -0
- package/dist/record/schema-coordination.client.d.ts +16 -0
- package/dist/record/schema-coordination.client.d.ts.map +1 -0
- package/dist/record/schema-coordination.client.js +59 -0
- package/dist/record/schema-coordination.client.js.map +1 -0
- package/dist/record/storage.record-delivery.reconcile.descriptor.d.ts +74 -0
- package/dist/record/storage.record-delivery.reconcile.descriptor.d.ts.map +1 -0
- package/dist/record/storage.record-delivery.reconcile.descriptor.js +54 -0
- package/dist/record/storage.record-delivery.reconcile.descriptor.js.map +1 -0
- package/dist/record/storage.record-delivery.reconcile.impl.d.ts +22 -0
- package/dist/record/storage.record-delivery.reconcile.impl.d.ts.map +1 -0
- package/dist/record/storage.record-delivery.reconcile.impl.js +52 -0
- package/dist/record/storage.record-delivery.reconcile.impl.js.map +1 -0
- package/dist/resolver/storage-backed-resolver.d.ts +12 -5
- package/dist/resolver/storage-backed-resolver.d.ts.map +1 -1
- package/dist/resolver/storage-backed-resolver.js +129 -48
- package/dist/resolver/storage-backed-resolver.js.map +1 -1
- package/dist/retention/capacity.d.ts +37 -0
- package/dist/retention/capacity.d.ts.map +1 -0
- package/dist/retention/capacity.js +71 -0
- package/dist/retention/capacity.js.map +1 -0
- package/dist/retention/catalog-chunks.d.ts +11 -0
- package/dist/retention/catalog-chunks.d.ts.map +1 -0
- package/dist/retention/catalog-chunks.js +62 -0
- package/dist/retention/catalog-chunks.js.map +1 -0
- package/dist/retention/reclaim.d.ts +59 -0
- package/dist/retention/reclaim.d.ts.map +1 -0
- package/dist/retention/reclaim.js +259 -0
- package/dist/retention/reclaim.js.map +1 -0
- package/dist/retention/roots.d.ts +141 -0
- package/dist/retention/roots.d.ts.map +1 -0
- package/dist/retention/roots.js +223 -0
- package/dist/retention/roots.js.map +1 -0
- package/dist/retention/scratch-custody.d.ts +40 -0
- package/dist/retention/scratch-custody.d.ts.map +1 -0
- package/dist/retention/scratch-custody.js +15 -0
- package/dist/retention/scratch-custody.js.map +1 -0
- package/dist/retention/startup-sweep.d.ts +57 -0
- package/dist/retention/startup-sweep.d.ts.map +1 -0
- package/dist/retention/startup-sweep.js +137 -0
- package/dist/retention/startup-sweep.js.map +1 -0
- package/dist/retention/storage.retention-sweep.descriptor.d.ts +82 -0
- package/dist/retention/storage.retention-sweep.descriptor.d.ts.map +1 -0
- package/dist/retention/storage.retention-sweep.descriptor.js +42 -0
- package/dist/retention/storage.retention-sweep.descriptor.js.map +1 -0
- package/dist/retention/storage.retention-sweep.impl.d.ts +22 -0
- package/dist/retention/storage.retention-sweep.impl.d.ts.map +1 -0
- package/dist/retention/storage.retention-sweep.impl.js +78 -0
- package/dist/retention/storage.retention-sweep.impl.js.map +1 -0
- package/dist/retention/storage.retention-sweep.schema.d.ts +3 -0
- package/dist/retention/storage.retention-sweep.schema.d.ts.map +1 -0
- package/dist/retention/storage.retention-sweep.schema.js +3 -0
- package/dist/retention/storage.retention-sweep.schema.js.map +1 -0
- package/dist/retention/sweep.d.ts +31 -0
- package/dist/retention/sweep.d.ts.map +1 -0
- package/dist/retention/sweep.js +190 -0
- package/dist/retention/sweep.js.map +1 -0
- package/dist/retention/tmp-scratch.d.ts +35 -0
- package/dist/retention/tmp-scratch.d.ts.map +1 -0
- package/dist/retention/tmp-scratch.js +149 -0
- package/dist/retention/tmp-scratch.js.map +1 -0
- package/dist/schemas/adapter-config.d.ts +42 -0
- package/dist/schemas/adapter-config.d.ts.map +1 -0
- package/dist/schemas/adapter-config.js +21 -0
- package/dist/schemas/adapter-config.js.map +1 -0
- package/dist/schemas/adapter-configuration-diagnostic.d.ts +35 -0
- package/dist/schemas/adapter-configuration-diagnostic.d.ts.map +1 -0
- package/dist/schemas/adapter-configuration-diagnostic.js +30 -0
- package/dist/schemas/adapter-configuration-diagnostic.js.map +1 -0
- package/dist/schemas/adapter-descriptor.d.ts +215 -5
- package/dist/schemas/adapter-descriptor.d.ts.map +1 -1
- package/dist/schemas/adapter-descriptor.js +158 -4
- package/dist/schemas/adapter-descriptor.js.map +1 -1
- package/dist/schemas/cloud-api.d.ts +99 -0
- package/dist/schemas/cloud-api.d.ts.map +1 -0
- package/dist/schemas/cloud-api.js +55 -0
- package/dist/schemas/cloud-api.js.map +1 -0
- package/dist/schemas/cloud-endpoints.d.ts +25 -0
- package/dist/schemas/cloud-endpoints.d.ts.map +1 -0
- package/dist/schemas/cloud-endpoints.js +38 -0
- package/dist/schemas/cloud-endpoints.js.map +1 -0
- package/dist/schemas/document-identity.d.ts +40 -0
- package/dist/schemas/document-identity.d.ts.map +1 -0
- package/dist/schemas/document-identity.js +21 -0
- package/dist/schemas/document-identity.js.map +1 -0
- package/dist/schemas/document-revision.d.ts +37 -0
- package/dist/schemas/document-revision.d.ts.map +1 -0
- package/dist/schemas/document-revision.js +14 -0
- package/dist/schemas/document-revision.js.map +1 -0
- package/dist/schemas/drizzle/config.d.ts +83 -0
- package/dist/schemas/drizzle/config.d.ts.map +1 -0
- package/dist/schemas/drizzle/config.js +55 -0
- package/dist/schemas/drizzle/config.js.map +1 -0
- package/dist/schemas/drizzle/connection.d.ts +41 -0
- package/dist/schemas/drizzle/connection.d.ts.map +1 -0
- package/dist/schemas/drizzle/connection.js +23 -0
- package/dist/schemas/drizzle/connection.js.map +1 -0
- package/dist/schemas/drizzle/journal-read.d.ts +11 -0
- package/dist/schemas/drizzle/journal-read.d.ts.map +1 -0
- package/dist/schemas/drizzle/journal-read.js +2 -0
- package/dist/schemas/drizzle/journal-read.js.map +1 -0
- package/dist/schemas/drizzle/persistence-config.d.ts +39 -0
- package/dist/schemas/drizzle/persistence-config.d.ts.map +1 -0
- package/dist/schemas/drizzle/persistence-config.js +71 -0
- package/dist/schemas/drizzle/persistence-config.js.map +1 -0
- package/dist/schemas/drizzle/persistence.d.ts +102 -0
- package/dist/schemas/drizzle/persistence.d.ts.map +1 -0
- package/dist/schemas/drizzle/persistence.js +28 -0
- package/dist/schemas/drizzle/persistence.js.map +1 -0
- package/dist/schemas/drizzle/ports.d.ts +39 -0
- package/dist/schemas/drizzle/ports.d.ts.map +1 -0
- package/dist/schemas/drizzle/ports.js +2 -0
- package/dist/schemas/drizzle/ports.js.map +1 -0
- package/dist/schemas/drizzle/providers.d.ts +64 -0
- package/dist/schemas/drizzle/providers.d.ts.map +1 -0
- package/dist/schemas/drizzle/providers.js +19 -0
- package/dist/schemas/drizzle/providers.js.map +1 -0
- package/dist/schemas/drizzle/raw-sql.d.ts +33 -0
- package/dist/schemas/drizzle/raw-sql.d.ts.map +1 -0
- package/dist/schemas/drizzle/raw-sql.js +34 -0
- package/dist/schemas/drizzle/raw-sql.js.map +1 -0
- package/dist/schemas/explorer/capability.d.ts +41 -0
- package/dist/schemas/explorer/capability.d.ts.map +1 -0
- package/dist/schemas/explorer/capability.js +14 -0
- package/dist/schemas/explorer/capability.js.map +1 -0
- package/dist/schemas/explorer/overview.d.ts +41 -0
- package/dist/schemas/explorer/overview.d.ts.map +1 -0
- package/dist/schemas/explorer/overview.js +45 -0
- package/dist/schemas/explorer/overview.js.map +1 -0
- package/dist/schemas/explorer/refs.d.ts +38 -0
- package/dist/schemas/explorer/refs.d.ts.map +1 -0
- package/dist/schemas/explorer/refs.js +21 -0
- package/dist/schemas/explorer/refs.js.map +1 -0
- package/dist/schemas/explorer/rpc.d.ts +211 -0
- package/dist/schemas/explorer/rpc.d.ts.map +1 -0
- package/dist/schemas/explorer/rpc.js +103 -0
- package/dist/schemas/explorer/rpc.js.map +1 -0
- package/dist/schemas/explorer/views.d.ts +99 -0
- package/dist/schemas/explorer/views.d.ts.map +1 -0
- package/dist/schemas/explorer/views.js +84 -0
- package/dist/schemas/explorer/views.js.map +1 -0
- package/dist/schemas/index.d.ts +16 -8
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +12 -4
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/localdb/inputs.d.ts +80 -0
- package/dist/schemas/localdb/inputs.d.ts.map +1 -0
- package/dist/schemas/localdb/inputs.js +99 -0
- package/dist/schemas/localdb/inputs.js.map +1 -0
- package/dist/schemas/localdb/query.d.ts +28 -0
- package/dist/schemas/localdb/query.d.ts.map +1 -0
- package/dist/schemas/localdb/query.js +27 -0
- package/dist/schemas/localdb/query.js.map +1 -0
- package/dist/schemas/manifest-descriptor.d.ts +15 -5
- package/dist/schemas/manifest-descriptor.d.ts.map +1 -1
- package/dist/schemas/manifest-descriptor.js +2 -2
- package/dist/schemas/manifest-descriptor.js.map +1 -1
- package/dist/schemas/memory-store.d.ts +8 -0
- package/dist/schemas/memory-store.d.ts.map +1 -0
- package/dist/schemas/memory-store.js +7 -0
- package/dist/schemas/memory-store.js.map +1 -0
- package/dist/schemas/migration-format.d.ts +50 -0
- package/dist/schemas/migration-format.d.ts.map +1 -0
- package/dist/schemas/migration-format.js +17 -0
- package/dist/schemas/migration-format.js.map +1 -0
- package/dist/schemas/policy/overrides.d.ts +41 -0
- package/dist/schemas/policy/overrides.d.ts.map +1 -0
- package/dist/schemas/policy/overrides.js +14 -0
- package/dist/schemas/policy/overrides.js.map +1 -0
- package/dist/schemas/policy/persistence.d.ts +62 -0
- package/dist/schemas/policy/persistence.d.ts.map +1 -0
- package/dist/schemas/policy/persistence.js +24 -0
- package/dist/schemas/policy/persistence.js.map +1 -0
- package/dist/schemas/record/atomic.d.ts +41 -0
- package/dist/schemas/record/atomic.d.ts.map +1 -0
- package/dist/schemas/record/atomic.js +12 -0
- package/dist/schemas/record/atomic.js.map +1 -0
- package/dist/schemas/record/batch.d.ts +53 -0
- package/dist/schemas/record/batch.d.ts.map +1 -0
- package/dist/schemas/record/batch.js +36 -0
- package/dist/schemas/record/batch.js.map +1 -0
- package/dist/schemas/record/columns.d.ts +44 -0
- package/dist/schemas/record/columns.d.ts.map +1 -0
- package/dist/schemas/record/columns.js +25 -0
- package/dist/schemas/record/columns.js.map +1 -0
- package/dist/schemas/record/delivery.d.ts +54 -0
- package/dist/schemas/record/delivery.d.ts.map +1 -0
- package/dist/schemas/record/delivery.js +23 -0
- package/dist/schemas/record/delivery.js.map +1 -0
- package/dist/schemas/record/descriptor.d.ts +153 -51
- package/dist/schemas/record/descriptor.d.ts.map +1 -1
- package/dist/schemas/record/descriptor.js +61 -11
- package/dist/schemas/record/descriptor.js.map +1 -1
- package/dist/schemas/record/index.d.ts +8 -2
- package/dist/schemas/record/index.d.ts.map +1 -1
- package/dist/schemas/record/index.js +5 -1
- package/dist/schemas/record/index.js.map +1 -1
- package/dist/schemas/record/query-values.d.ts +62 -0
- package/dist/schemas/record/query-values.d.ts.map +1 -0
- package/dist/schemas/record/query-values.js +33 -0
- package/dist/schemas/record/query-values.js.map +1 -0
- package/dist/schemas/record/relation.d.ts +1 -1
- package/dist/schemas/record/relation.d.ts.map +1 -1
- package/dist/schemas/record/relation.js +8 -4
- package/dist/schemas/record/relation.js.map +1 -1
- package/dist/schemas/record/revision.d.ts +92 -0
- package/dist/schemas/record/revision.d.ts.map +1 -0
- package/dist/schemas/record/revision.js +39 -0
- package/dist/schemas/record/revision.js.map +1 -0
- package/dist/schemas/retention/jobs.d.ts +103 -0
- package/dist/schemas/retention/jobs.d.ts.map +1 -0
- package/dist/schemas/retention/jobs.js +72 -0
- package/dist/schemas/retention/jobs.js.map +1 -0
- package/dist/schemas/retention/results.d.ts +153 -0
- package/dist/schemas/retention/results.d.ts.map +1 -0
- package/dist/schemas/retention/results.js +84 -0
- package/dist/schemas/retention/results.js.map +1 -0
- package/dist/schemas/schema/descriptor.d.ts +14 -4
- package/dist/schemas/schema/descriptor.d.ts.map +1 -1
- package/dist/schemas/schema/descriptor.js +3 -3
- package/dist/schemas/schema/descriptor.js.map +1 -1
- package/dist/schemas/schema/index.d.ts +1 -1
- package/dist/schemas/schema/index.d.ts.map +1 -1
- package/dist/schemas/schema/index.js +1 -1
- package/dist/schemas/schema/index.js.map +1 -1
- package/dist/schemas/storage-provider.d.ts +79 -0
- package/dist/schemas/storage-provider.d.ts.map +1 -0
- package/dist/schemas/storage-provider.js +54 -0
- package/dist/schemas/storage-provider.js.map +1 -0
- package/dist/schemas/storage-ref.d.ts +39 -0
- package/dist/schemas/storage-ref.d.ts.map +1 -0
- package/dist/schemas/storage-ref.js +64 -0
- package/dist/schemas/storage-ref.js.map +1 -0
- package/dist/schemas/sync/command.d.ts +15 -0
- package/dist/schemas/sync/command.d.ts.map +1 -0
- package/dist/schemas/sync/command.js +10 -0
- package/dist/schemas/sync/command.js.map +1 -0
- package/dist/schemas/sync/crud.d.ts +26 -0
- package/dist/schemas/sync/crud.d.ts.map +1 -0
- package/dist/schemas/sync/crud.js +16 -0
- package/dist/schemas/sync/crud.js.map +1 -0
- package/dist/schemas/sync/document.d.ts +4 -0
- package/dist/schemas/sync/document.d.ts.map +1 -0
- package/dist/schemas/sync/document.js +4 -0
- package/dist/schemas/sync/document.js.map +1 -0
- package/dist/schemas/sync/local-first.d.ts +26 -0
- package/dist/schemas/sync/local-first.d.ts.map +1 -0
- package/dist/schemas/sync/local-first.js +14 -0
- package/dist/schemas/sync/local-first.js.map +1 -0
- package/dist/schemas/sync/results.d.ts +61 -0
- package/dist/schemas/sync/results.d.ts.map +1 -0
- package/dist/schemas/sync/results.js +47 -0
- package/dist/schemas/sync/results.js.map +1 -0
- package/dist/schemas/sync-bridge-descriptor.d.ts +34 -15
- package/dist/schemas/sync-bridge-descriptor.d.ts.map +1 -1
- package/dist/schemas/sync-bridge-descriptor.js +9 -2
- package/dist/schemas/sync-bridge-descriptor.js.map +1 -1
- package/dist/schemas/sync-memory.d.ts +7 -0
- package/dist/schemas/sync-memory.d.ts.map +1 -0
- package/dist/schemas/sync-memory.js +4 -0
- package/dist/schemas/sync-memory.js.map +1 -0
- package/dist/schemas/tools/views.d.ts +83 -0
- package/dist/schemas/tools/views.d.ts.map +1 -0
- package/dist/schemas/tools/views.js +57 -0
- package/dist/schemas/tools/views.js.map +1 -0
- package/dist/schemas/tools/widgets.d.ts +41 -0
- package/dist/schemas/tools/widgets.d.ts.map +1 -0
- package/dist/schemas/tools/widgets.js +13 -0
- package/dist/schemas/tools/widgets.js.map +1 -0
- package/dist/schemas/transform.d.ts +32 -0
- package/dist/schemas/transform.d.ts.map +1 -0
- package/dist/schemas/transform.js +18 -0
- package/dist/schemas/transform.js.map +1 -0
- package/dist/schemas/zod-schema-value.d.ts +8 -0
- package/dist/schemas/zod-schema-value.d.ts.map +1 -0
- package/dist/schemas/zod-schema-value.js +8 -0
- package/dist/schemas/zod-schema-value.js.map +1 -0
- package/dist/server/manifest-route.d.ts +18 -10
- package/dist/server/manifest-route.d.ts.map +1 -1
- package/dist/server/manifest-route.js +88 -90
- package/dist/server/manifest-route.js.map +1 -1
- package/dist/storage-explorer.consumer.plugin.d.ts +10 -0
- package/dist/storage-explorer.consumer.plugin.d.ts.map +1 -0
- package/dist/storage-explorer.consumer.plugin.js +24 -0
- package/dist/storage-explorer.consumer.plugin.js.map +1 -0
- package/dist/storage-policy.context.descriptor.js +1 -1
- package/dist/storage-policy.context.descriptor.js.map +1 -1
- package/dist/storage-policy.context.server.d.ts +7 -9
- package/dist/storage-policy.context.server.d.ts.map +1 -1
- package/dist/storage-policy.context.server.js +7 -20
- package/dist/storage-policy.context.server.js.map +1 -1
- package/dist/storage.consumer.plugin.d.ts +3 -0
- package/dist/storage.consumer.plugin.d.ts.map +1 -0
- package/dist/storage.consumer.plugin.js +15 -0
- package/dist/storage.consumer.plugin.js.map +1 -0
- package/dist/storage.node.plugin.d.ts +3 -0
- package/dist/storage.node.plugin.d.ts.map +1 -0
- package/dist/storage.node.plugin.js +12 -0
- package/dist/storage.node.plugin.js.map +1 -0
- package/dist/storage.plugin.d.ts +10 -16
- package/dist/storage.plugin.d.ts.map +1 -1
- package/dist/storage.plugin.js +150 -91
- package/dist/storage.plugin.js.map +1 -1
- package/dist/svelte/components/ConnectStorageProviderDialog.svelte +345 -0
- package/dist/svelte/components/ConnectStorageProviderDialog.svelte.d.ts +17 -0
- package/dist/svelte/components/ConnectStorageProviderDialog.svelte.d.ts.map +1 -0
- package/dist/svelte/components/PlatformStorageExplorer.svelte +57 -0
- package/dist/svelte/components/PlatformStorageExplorer.svelte.d.ts +23 -0
- package/dist/svelte/components/PlatformStorageExplorer.svelte.d.ts.map +1 -0
- package/dist/svelte/components/StorageBrowser.svelte +436 -0
- package/dist/svelte/components/StorageBrowser.svelte.d.ts +51 -0
- package/dist/svelte/components/StorageBrowser.svelte.d.ts.map +1 -0
- package/dist/svelte/components/StorageBrowserPage.svelte +71 -0
- package/dist/svelte/components/StorageBrowserPage.svelte.d.ts +23 -0
- package/dist/svelte/components/StorageBrowserPage.svelte.d.ts.map +1 -0
- package/dist/svelte/components/StorageCollectionManager.svelte +193 -0
- package/dist/svelte/components/StorageCollectionManager.svelte.d.ts +14 -0
- package/dist/svelte/components/StorageCollectionManager.svelte.d.ts.map +1 -0
- package/dist/svelte/components/StorageDetailsPane.svelte +160 -0
- package/dist/svelte/components/StorageDetailsPane.svelte.d.ts +11 -0
- package/dist/svelte/components/StorageDetailsPane.svelte.d.ts.map +1 -0
- package/dist/svelte/components/StorageDropzone.svelte +76 -0
- package/dist/svelte/components/StorageDropzone.svelte.d.ts +9 -0
- package/dist/svelte/components/StorageDropzone.svelte.d.ts.map +1 -0
- package/dist/svelte/components/StorageExplorer.svelte +954 -0
- package/dist/svelte/components/StorageExplorer.svelte.d.ts +48 -0
- package/dist/svelte/components/StorageExplorer.svelte.d.ts.map +1 -0
- package/dist/svelte/components/StorageFileBrowser.svelte +201 -0
- package/dist/svelte/components/StorageFileBrowser.svelte.d.ts +18 -0
- package/dist/svelte/components/StorageFileBrowser.svelte.d.ts.map +1 -0
- package/dist/svelte/components/StorageFileCard.svelte +162 -0
- package/dist/svelte/components/StorageFileCard.svelte.d.ts +10 -0
- package/dist/svelte/components/StorageFileCard.svelte.d.ts.map +1 -0
- package/dist/svelte/components/StoragePathBar.svelte +104 -0
- package/dist/svelte/components/StoragePathBar.svelte.d.ts +19 -0
- package/dist/svelte/components/StoragePathBar.svelte.d.ts.map +1 -0
- package/dist/svelte/components/StorageProviderSelect.svelte +163 -0
- package/dist/svelte/components/StorageProviderSelect.svelte.d.ts +20 -0
- package/dist/svelte/components/StorageProviderSelect.svelte.d.ts.map +1 -0
- package/dist/svelte/components/StorageProviderSidebar.svelte +187 -0
- package/dist/svelte/components/StorageProviderSidebar.svelte.d.ts +30 -0
- package/dist/svelte/components/StorageProviderSidebar.svelte.d.ts.map +1 -0
- package/dist/svelte/components/StorageReadinessNotice.svelte +181 -0
- package/dist/svelte/components/StorageReadinessNotice.svelte.d.ts +32 -0
- package/dist/svelte/components/StorageReadinessNotice.svelte.d.ts.map +1 -0
- package/dist/svelte/components/StorageSearchBox.svelte +106 -0
- package/dist/svelte/components/StorageSearchBox.svelte.d.ts +19 -0
- package/dist/svelte/components/StorageSearchBox.svelte.d.ts.map +1 -0
- package/dist/svelte/components/StorageToolbar.svelte +160 -0
- package/dist/svelte/components/StorageToolbar.svelte.d.ts +26 -0
- package/dist/svelte/components/StorageToolbar.svelte.d.ts.map +1 -0
- package/dist/svelte/components/StorageUploadChip.svelte +116 -0
- package/dist/svelte/components/StorageUploadChip.svelte.d.ts +13 -0
- package/dist/svelte/components/StorageUploadChip.svelte.d.ts.map +1 -0
- package/dist/svelte/components/index.d.ts +14 -0
- package/dist/svelte/components/index.d.ts.map +1 -0
- package/dist/svelte/components/index.js +12 -0
- package/dist/svelte/components/storage-media.d.ts +14 -0
- package/dist/svelte/components/storage-media.d.ts.map +1 -0
- package/dist/svelte/components/storage-media.js +13 -0
- package/dist/svelte/index.d.ts +14 -0
- package/dist/svelte/index.d.ts.map +1 -0
- package/dist/svelte/index.js +13 -0
- package/dist/svelte/note-store-failure.d.ts +15 -0
- package/dist/svelte/note-store-failure.d.ts.map +1 -0
- package/dist/svelte/note-store-failure.js +21 -0
- package/dist/svelte/platform-storage-port.d.ts +86 -0
- package/dist/svelte/platform-storage-port.d.ts.map +1 -0
- package/dist/svelte/platform-storage-port.js +71 -0
- package/dist/svelte/storage-browse-runtime.d.ts +65 -0
- package/dist/svelte/storage-browse-runtime.d.ts.map +1 -0
- package/dist/svelte/storage-browse-runtime.js +68 -0
- package/dist/svelte/storage-connection.d.ts +23 -0
- package/dist/svelte/storage-connection.d.ts.map +1 -0
- package/dist/svelte/storage-connection.js +40 -0
- package/dist/svelte/storage-display.d.ts +6 -0
- package/dist/svelte/storage-display.d.ts.map +1 -0
- package/dist/svelte/storage-display.js +58 -0
- package/dist/svelte/storage-explorer-runtime.d.ts +120 -0
- package/dist/svelte/storage-explorer-runtime.d.ts.map +1 -0
- package/dist/svelte/storage-explorer-runtime.js +251 -0
- package/dist/svelte/storage-explorer.load.d.ts +22 -0
- package/dist/svelte/storage-explorer.load.d.ts.map +1 -0
- package/dist/svelte/storage-explorer.load.js +37 -0
- package/dist/svelte/storage-refs-runtime.d.ts +36 -0
- package/dist/svelte/storage-refs-runtime.d.ts.map +1 -0
- package/dist/svelte/storage-refs-runtime.js +47 -0
- package/dist/svelte/storage-runtime.d.ts +30 -0
- package/dist/svelte/storage-runtime.d.ts.map +1 -0
- package/dist/svelte/storage-runtime.js +39 -0
- package/dist/svelte/storage-svelte.plugin.d.ts +40 -0
- package/dist/svelte/storage-svelte.plugin.d.ts.map +1 -0
- package/dist/svelte/storage-svelte.plugin.js +50 -0
- package/dist/svelte/storage-upload-runtime.d.ts +8 -0
- package/dist/svelte/storage-upload-runtime.d.ts.map +1 -0
- package/dist/svelte/storage-upload-runtime.js +12 -0
- package/dist/svelte/stores/index.d.ts +4 -0
- package/dist/svelte/stores/index.d.ts.map +1 -0
- package/dist/svelte/stores/index.js +3 -0
- package/dist/svelte/stores/storage-browse.svelte.d.ts +70 -0
- package/dist/svelte/stores/storage-browse.svelte.d.ts.map +1 -0
- package/dist/svelte/stores/storage-browse.svelte.js +133 -0
- package/dist/svelte/stores/storage-providers.svelte.d.ts +32 -0
- package/dist/svelte/stores/storage-providers.svelte.d.ts.map +1 -0
- package/dist/svelte/stores/storage-providers.svelte.js +73 -0
- package/dist/svelte/stores/storage-refs.svelte.d.ts +57 -0
- package/dist/svelte/stores/storage-refs.svelte.d.ts.map +1 -0
- package/dist/svelte/stores/storage-refs.svelte.js +90 -0
- package/dist/svelte/styles.css +14 -0
- package/dist/svelte/test-assets.d.ts +8 -0
- package/dist/svelte/tool-widgets/StorageBrowseToolCard.svelte +109 -0
- package/dist/svelte/tool-widgets/StorageBrowseToolCard.svelte.d.ts +9 -0
- package/dist/svelte/tool-widgets/StorageBrowseToolCard.svelte.d.ts.map +1 -0
- package/dist/svelte/tool-widgets/StorageCopyToolCard.svelte +87 -0
- package/dist/svelte/tool-widgets/StorageCopyToolCard.svelte.d.ts +9 -0
- package/dist/svelte/tool-widgets/StorageCopyToolCard.svelte.d.ts.map +1 -0
- package/dist/svelte/tool-widgets/StorageSearchToolCard.svelte +94 -0
- package/dist/svelte/tool-widgets/StorageSearchToolCard.svelte.d.ts +9 -0
- package/dist/svelte/tool-widgets/StorageSearchToolCard.svelte.d.ts.map +1 -0
- package/dist/svelte/tool-widgets/format.d.ts +15 -0
- package/dist/svelte/tool-widgets/format.d.ts.map +1 -0
- package/dist/svelte/tool-widgets/format.js +32 -0
- package/dist/svelte/tool-widgets/index.d.ts +2 -0
- package/dist/svelte/tool-widgets/index.d.ts.map +1 -0
- package/dist/svelte/tool-widgets/index.js +12 -0
- package/dist/svelte/tool-widgets/runtime.d.ts +9 -0
- package/dist/svelte/tool-widgets/runtime.d.ts.map +1 -0
- package/dist/svelte/tool-widgets/runtime.js +42 -0
- package/dist/sync/cloud-document.d.ts +24 -0
- package/dist/sync/cloud-document.d.ts.map +1 -0
- package/dist/sync/cloud-document.js +47 -0
- package/dist/sync/cloud-document.js.map +1 -0
- package/dist/sync/cloud-pull.d.ts +9 -3
- package/dist/sync/cloud-pull.d.ts.map +1 -1
- package/dist/sync/cloud-pull.js +85 -86
- package/dist/sync/cloud-pull.js.map +1 -1
- package/dist/sync/cloud-record-crud-config.d.ts +7 -17
- package/dist/sync/cloud-record-crud-config.d.ts.map +1 -1
- package/dist/sync/cloud-record-crud-config.js +17 -9
- package/dist/sync/cloud-record-crud-config.js.map +1 -1
- package/dist/sync/local-first.d.ts +61 -0
- package/dist/sync/local-first.d.ts.map +1 -0
- package/dist/sync/local-first.js +121 -0
- package/dist/sync/local-first.js.map +1 -0
- package/dist/sync/record-sync-bridge.d.ts +35 -3
- package/dist/sync/record-sync-bridge.d.ts.map +1 -1
- package/dist/sync/record-sync-bridge.js +50 -46
- package/dist/sync/record-sync-bridge.js.map +1 -1
- package/dist/sync/resolve-sync-target.d.ts +16 -17
- package/dist/sync/resolve-sync-target.d.ts.map +1 -1
- package/dist/sync/resolve-sync-target.js +18 -43
- package/dist/sync/resolve-sync-target.js.map +1 -1
- package/dist/sync/runtime-sync-state.d.ts +18 -0
- package/dist/sync/runtime-sync-state.d.ts.map +1 -0
- package/dist/sync/runtime-sync-state.js +12 -0
- package/dist/sync/runtime-sync-state.js.map +1 -0
- package/dist/sync/schemas/cloud-pull.d.ts +9 -5
- package/dist/sync/schemas/cloud-pull.d.ts.map +1 -1
- package/dist/sync/schemas/index.d.ts +3 -3
- package/dist/sync/schemas/index.d.ts.map +1 -1
- package/dist/sync/schemas/index.js +3 -3
- package/dist/sync/schemas/index.js.map +1 -1
- package/dist/sync/schemas/sync-helpers.d.ts +4 -2
- package/dist/sync/schemas/sync-helpers.d.ts.map +1 -1
- package/dist/sync/schemas/sync-state.d.ts +7 -5
- package/dist/sync/schemas/sync-state.d.ts.map +1 -1
- package/dist/sync/schemas/sync-state.js +1 -0
- package/dist/sync/schemas/sync-state.js.map +1 -1
- package/dist/sync/sync-bridge.d.ts +39 -31
- package/dist/sync/sync-bridge.d.ts.map +1 -1
- package/dist/sync/sync-bridge.js +427 -196
- package/dist/sync/sync-bridge.js.map +1 -1
- package/dist/sync/sync-manifest.d.ts +7 -19
- package/dist/sync/sync-manifest.d.ts.map +1 -1
- package/dist/sync/sync-manifest.js +125 -84
- package/dist/sync/sync-manifest.js.map +1 -1
- package/dist/sync/sync-state.browser.d.ts +37 -0
- package/dist/sync/sync-state.browser.d.ts.map +1 -0
- package/dist/sync/sync-state.browser.js +136 -0
- package/dist/sync/sync-state.browser.js.map +1 -0
- package/dist/sync/sync-state.client.d.ts +71 -0
- package/dist/sync/sync-state.client.d.ts.map +1 -0
- package/dist/sync/sync-state.client.js +78 -0
- package/dist/sync/sync-state.client.js.map +1 -0
- package/dist/sync/sync-state.consumer.d.ts +44 -17
- package/dist/sync/sync-state.consumer.d.ts.map +1 -1
- package/dist/sync/sync-state.consumer.js +161 -87
- package/dist/sync/sync-state.consumer.js.map +1 -1
- package/dist/sync/sync-state.core.d.ts +40 -0
- package/dist/sync/sync-state.core.d.ts.map +1 -0
- package/dist/sync/sync-state.core.js +130 -0
- package/dist/sync/sync-state.core.js.map +1 -0
- package/dist/sync/sync-state.descriptor.d.ts +39 -0
- package/dist/sync/sync-state.descriptor.d.ts.map +1 -0
- package/dist/sync/sync-state.descriptor.js +23 -0
- package/dist/sync/sync-state.descriptor.js.map +1 -0
- package/dist/testing.d.ts +31 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +82 -0
- package/dist/testing.js.map +1 -0
- package/dist/tools/descriptors.d.ts +312 -0
- package/dist/tools/descriptors.d.ts.map +1 -0
- package/dist/tools/descriptors.js +98 -0
- package/dist/tools/descriptors.js.map +1 -0
- package/dist/tools/impl.d.ts +72 -0
- package/dist/tools/impl.d.ts.map +1 -0
- package/dist/tools/impl.js +572 -0
- package/dist/tools/impl.js.map +1 -0
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +3 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/schemas.d.ts +136 -0
- package/dist/tools/schemas.d.ts.map +1 -0
- package/dist/tools/schemas.js +113 -0
- package/dist/tools/schemas.js.map +1 -0
- package/dist/tools/widget-views.d.ts +9 -0
- package/dist/tools/widget-views.d.ts.map +1 -0
- package/dist/tools/widget-views.js +119 -0
- package/dist/tools/widget-views.js.map +1 -0
- package/dist/transform/index.d.ts +7 -18
- package/dist/transform/index.d.ts.map +1 -1
- package/dist/transform/index.js +16 -14
- package/dist/transform/index.js.map +1 -1
- package/dist/transform/transform-descriptor.d.ts +1 -21
- package/dist/transform/transform-descriptor.d.ts.map +1 -1
- package/dist/transform/transform-descriptor.js +1 -29
- package/dist/transform/transform-descriptor.js.map +1 -1
- package/dist/tui/plugin.d.ts +26 -0
- package/dist/tui/plugin.d.ts.map +1 -0
- package/dist/tui/plugin.js +107 -0
- package/dist/tui/plugin.js.map +1 -0
- package/dist/tui/storage-explorer.descriptor.d.ts +25 -4
- package/dist/tui/storage-explorer.descriptor.d.ts.map +1 -1
- package/dist/tui/storage-explorer.descriptor.js +7 -3
- package/dist/tui/storage-explorer.descriptor.js.map +1 -1
- package/dist/tui/storage-explorer.impl.consumer.d.ts +23 -6
- package/dist/tui/storage-explorer.impl.consumer.d.ts.map +1 -1
- package/dist/tui/storage-explorer.impl.consumer.js +231 -8
- package/dist/tui/storage-explorer.impl.consumer.js.map +1 -1
- package/dist/tui/storage-open.descriptor.d.ts +16 -3
- package/dist/tui/storage-open.descriptor.d.ts.map +1 -1
- package/dist/tui/storage-open.descriptor.js +5 -1
- package/dist/tui/storage-open.descriptor.js.map +1 -1
- package/dist/tui/storage-open.impl.consumer.d.ts +6 -1
- package/dist/tui/storage-open.impl.consumer.d.ts.map +1 -1
- package/dist/tui/storage-open.impl.consumer.js.map +1 -1
- package/dist/tui/storage-signed-out-ui.d.ts +21 -0
- package/dist/tui/storage-signed-out-ui.d.ts.map +1 -0
- package/dist/tui/storage-signed-out-ui.js +34 -0
- package/dist/tui/storage-signed-out-ui.js.map +1 -0
- package/dist/tui/storage.tui-state.descriptor.d.ts +61 -0
- package/dist/tui/storage.tui-state.descriptor.d.ts.map +1 -0
- package/dist/tui/storage.tui-state.descriptor.js +52 -0
- package/dist/tui/storage.tui-state.descriptor.js.map +1 -0
- package/dist/tui/storage.tui-state.impl.consumer.d.ts +29 -0
- package/dist/tui/storage.tui-state.impl.consumer.d.ts.map +1 -0
- package/dist/tui/storage.tui-state.impl.consumer.js +207 -0
- package/dist/tui/storage.tui-state.impl.consumer.js.map +1 -0
- package/dist/tui/storage.tui-state.key.d.ts +27 -0
- package/dist/tui/storage.tui-state.key.d.ts.map +1 -0
- package/dist/tui/storage.tui-state.key.js +12 -0
- package/dist/tui/storage.tui-state.key.js.map +1 -0
- package/dist/tui/tool-widgets/StorageBrowseToolWidget.impl.consumer.d.ts +14 -0
- package/dist/tui/tool-widgets/StorageBrowseToolWidget.impl.consumer.d.ts.map +1 -0
- package/dist/tui/tool-widgets/StorageBrowseToolWidget.impl.consumer.js +28 -0
- package/dist/tui/tool-widgets/StorageBrowseToolWidget.impl.consumer.js.map +1 -0
- package/dist/tui/tool-widgets/StorageCopyToolWidget.impl.consumer.d.ts +14 -0
- package/dist/tui/tool-widgets/StorageCopyToolWidget.impl.consumer.d.ts.map +1 -0
- package/dist/tui/tool-widgets/StorageCopyToolWidget.impl.consumer.js +21 -0
- package/dist/tui/tool-widgets/StorageCopyToolWidget.impl.consumer.js.map +1 -0
- package/dist/tui/tool-widgets/StorageSearchToolWidget.impl.consumer.d.ts +14 -0
- package/dist/tui/tool-widgets/StorageSearchToolWidget.impl.consumer.d.ts.map +1 -0
- package/dist/tui/tool-widgets/StorageSearchToolWidget.impl.consumer.js +22 -0
- package/dist/tui/tool-widgets/StorageSearchToolWidget.impl.consumer.js.map +1 -0
- package/dist/tui/tool-widgets/format.d.ts +19 -0
- package/dist/tui/tool-widgets/format.d.ts.map +1 -0
- package/dist/tui/tool-widgets/format.js +53 -0
- package/dist/tui/tool-widgets/format.js.map +1 -0
- package/dist/tui/tool-widgets/storage.browse.tool-widget.descriptor.d.ts +14 -0
- package/dist/tui/tool-widgets/storage.browse.tool-widget.descriptor.d.ts.map +1 -0
- package/dist/tui/tool-widgets/storage.browse.tool-widget.descriptor.js +14 -0
- package/dist/tui/tool-widgets/storage.browse.tool-widget.descriptor.js.map +1 -0
- package/dist/tui/tool-widgets/storage.copy.tool-widget.descriptor.d.ts +14 -0
- package/dist/tui/tool-widgets/storage.copy.tool-widget.descriptor.d.ts.map +1 -0
- package/dist/tui/tool-widgets/storage.copy.tool-widget.descriptor.js +14 -0
- package/dist/tui/tool-widgets/storage.copy.tool-widget.descriptor.js.map +1 -0
- package/dist/tui/tool-widgets/storage.search.tool-widget.descriptor.d.ts +14 -0
- package/dist/tui/tool-widgets/storage.search.tool-widget.descriptor.d.ts.map +1 -0
- package/dist/tui/tool-widgets/storage.search.tool-widget.descriptor.js +14 -0
- package/dist/tui/tool-widgets/storage.search.tool-widget.descriptor.js.map +1 -0
- package/dist/utils/caller-bearer.d.ts +13 -0
- package/dist/utils/caller-bearer.d.ts.map +1 -0
- package/dist/utils/caller-bearer.js +17 -0
- package/dist/utils/caller-bearer.js.map +1 -0
- package/dist/utils/error-context.d.ts +9 -1
- package/dist/utils/error-context.d.ts.map +1 -1
- package/dist/utils/error-context.js +7 -14
- package/dist/utils/error-context.js.map +1 -1
- package/dist/utils/failure-of.d.ts +20 -0
- package/dist/utils/failure-of.d.ts.map +1 -0
- package/dist/utils/failure-of.js +35 -0
- package/dist/utils/failure-of.js.map +1 -0
- package/dist/workers-port.d.ts +37 -0
- package/dist/workers-port.d.ts.map +1 -0
- package/dist/workers-port.js +60 -0
- package/dist/workers-port.js.map +1 -0
- package/package.json +644 -148
- package/SPEC.md +0 -60
- package/dist/adapters/index.d.ts +0 -14
- package/dist/adapters/index.d.ts.map +0 -1
- package/dist/adapters/index.js +0 -15
- package/dist/adapters/index.js.map +0 -1
- package/dist/cli/context.consumer.d.ts +0 -26
- package/dist/cli/context.consumer.d.ts.map +0 -1
- package/dist/cli/context.consumer.js +0 -164
- package/dist/cli/context.consumer.js.map +0 -1
- package/dist/docs/adapters.docs.descriptor.d.ts +0 -4
- package/dist/docs/adapters.docs.descriptor.d.ts.map +0 -1
- package/dist/docs/adapters.docs.descriptor.js +0 -223
- package/dist/docs/adapters.docs.descriptor.js.map +0 -1
- package/dist/docs/manifests.docs.descriptor.d.ts +0 -4
- package/dist/docs/manifests.docs.descriptor.d.ts.map +0 -1
- package/dist/docs/manifests.docs.descriptor.js.map +0 -1
- package/src/adapters/index.ts +0 -13
- package/src/bridge/index.ts +0 -2
- package/src/bridge/storage-kind-bridge.ts +0 -131
- package/src/bridge/types.ts +0 -46
- package/src/cli/commands/list/storage.list.cli-command.descriptor.ts +0 -20
- package/src/cli/commands/list/storage.list.cli-command.impl.ts +0 -72
- package/src/cli/commands/sync/pull/storage.sync.pull.cli-command.descriptor.ts +0 -28
- package/src/cli/commands/sync/pull/storage.sync.pull.cli-command.impl.ts +0 -171
- package/src/cli/commands/sync/push/storage.sync.push.cli-command.descriptor.ts +0 -28
- package/src/cli/commands/sync/push/storage.sync.push.cli-command.impl.ts +0 -213
- package/src/cli/commands/sync/resolve/storage.sync.resolve.cli-command.descriptor.ts +0 -22
- package/src/cli/commands/sync/resolve/storage.sync.resolve.cli-command.impl.ts +0 -129
- package/src/cli/commands/sync/status/storage.sync.status.cli-command.descriptor.ts +0 -17
- package/src/cli/commands/sync/status/storage.sync.status.cli-command.impl.ts +0 -192
- package/src/cli/context.consumer.ts +0 -195
- package/src/cli/storage.cli-group.descriptor.ts +0 -13
- package/src/cli/storage.sync.cli-group.descriptor.ts +0 -14
- package/src/cli/types.ts +0 -25
- package/src/client/index.ts +0 -10
- package/src/client/list-browsable-adapters.ts +0 -42
- package/src/daemon/commands/sync.ts +0 -225
- package/src/docs/adapters.docs.descriptor.ts +0 -225
- package/src/docs/manifests.docs.descriptor.ts +0 -318
- package/src/docs/records.docs.descriptor.ts +0 -271
- package/src/docs/sync.docs.descriptor.ts +0 -281
- package/src/index.ts +0 -109
- package/src/interfaces/adapter.ts +0 -451
- package/src/interfaces/document-store.ts +0 -74
- package/src/interfaces/index.ts +0 -117
- package/src/interfaces/key-value.ts +0 -112
- package/src/interfaces/query-builder.ts +0 -31
- package/src/interfaces/record/index.ts +0 -58
- package/src/interfaces/record/interface.ts +0 -723
- package/src/interfaces/repository.ts +0 -300
- package/src/interfaces/schema/index.ts +0 -37
- package/src/interfaces/schema/schema-interface.ts +0 -586
- package/src/interfaces/schema/table-interface.ts +0 -314
- package/src/interfaces/storage-consumer-fs.ts +0 -66
- package/src/manifest/base.ts +0 -594
- package/src/manifest/cloud-sync.consumer.ts +0 -120
- package/src/manifest/index.ts +0 -7
- package/src/manifest/source-policy.ts +0 -74
- package/src/paths.ts +0 -171
- package/src/policy/context.ts +0 -30
- package/src/policy/index.ts +0 -20
- package/src/policy/overrides.ts +0 -46
- package/src/policy/persistence.ts +0 -117
- package/src/policy/types.ts +0 -28
- package/src/record/base.ts +0 -1872
- package/src/record/events.ts +0 -56
- package/src/record/extensions.ts +0 -308
- package/src/record/index.ts +0 -7
- package/src/resolver/storage-backed-resolver.ts +0 -255
- package/src/schemas/adapter-descriptor.ts +0 -128
- package/src/schemas/index.ts +0 -104
- package/src/schemas/manifest-descriptor.ts +0 -143
- package/src/schemas/record/descriptor.ts +0 -621
- package/src/schemas/record/index.ts +0 -60
- package/src/schemas/record/relation.ts +0 -49
- package/src/schemas/schema/descriptor.ts +0 -278
- package/src/schemas/schema/index.ts +0 -14
- package/src/schemas/sync-bridge-descriptor.ts +0 -143
- package/src/server/manifest-route.ts +0 -319
- package/src/storage-policy.context.descriptor.ts +0 -17
- package/src/storage-policy.context.server.ts +0 -34
- package/src/storage.plugin.ts +0 -264
- package/src/sync/cloud-pull.ts +0 -202
- package/src/sync/cloud-record-crud-config.ts +0 -41
- package/src/sync/record-sync-bridge.ts +0 -183
- package/src/sync/resolve-sync-target.ts +0 -57
- package/src/sync/schemas/cloud-pull.ts +0 -26
- package/src/sync/schemas/index.ts +0 -18
- package/src/sync/schemas/sync-helpers.ts +0 -18
- package/src/sync/schemas/sync-state.ts +0 -41
- package/src/sync/sync-bridge.ts +0 -763
- package/src/sync/sync-manifest.ts +0 -212
- package/src/sync/sync-state.consumer.ts +0 -144
- package/src/transform/index.ts +0 -130
- package/src/transform/transform-descriptor.ts +0 -53
- package/src/tui/storage-explorer.descriptor.ts +0 -32
- package/src/tui/storage-explorer.impl.consumer.ts +0 -14
- package/src/tui/storage-open.descriptor.ts +0 -31
- package/src/tui/storage-open.impl.consumer.ts +0 -14
- package/src/utils/error-context.ts +0 -19
package/src/record/base.ts
DELETED
|
@@ -1,1872 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* StorageRecord Base Implementation
|
|
3
|
-
*
|
|
4
|
-
* Provides CRUD operations on a single table with relations.
|
|
5
|
-
* This is what gets resolved when you query for a storage/record descriptor.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```typescript
|
|
9
|
-
* const todos = new StorageRecord(todoDescriptor, adapter);
|
|
10
|
-
* await todos.initialize();
|
|
11
|
-
*
|
|
12
|
-
* const todo = await todos.create({
|
|
13
|
-
* sessionId: 'session-123',
|
|
14
|
-
* title: 'Implement storage',
|
|
15
|
-
* status: 'in_progress'
|
|
16
|
-
* });
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import type { z } from 'zod/v4';
|
|
21
|
-
import type { SqlDatabaseHandle } from '../interfaces/adapter';
|
|
22
|
-
import { getLogger } from '@vibesdotdev/logging';
|
|
23
|
-
import type { KindContext } from '@vibesdotdev/runtime/schemas/kind';
|
|
24
|
-
import { toErrorContext } from '../utils/error-context';
|
|
25
|
-
|
|
26
|
-
const logger = getLogger('storage:record');
|
|
27
|
-
import type { StorageRecordDescriptor, StorageRelation } from '../schemas/record';
|
|
28
|
-
import type {
|
|
29
|
-
StorageRecordInterface,
|
|
30
|
-
WhereFilter,
|
|
31
|
-
OrderBy,
|
|
32
|
-
IncludeRelations,
|
|
33
|
-
QueryOptions,
|
|
34
|
-
QueryResult,
|
|
35
|
-
CreateInput,
|
|
36
|
-
CreateManyOptions,
|
|
37
|
-
UpdateInput,
|
|
38
|
-
UpdateOptions,
|
|
39
|
-
UpdateResult,
|
|
40
|
-
DeleteOptions,
|
|
41
|
-
DeleteResult,
|
|
42
|
-
TransactionContext,
|
|
43
|
-
TransactionFn,
|
|
44
|
-
AggregationFunction,
|
|
45
|
-
AggregationOptions,
|
|
46
|
-
AggregationResult,
|
|
47
|
-
StreamOptions
|
|
48
|
-
} from '../interfaces/record';
|
|
49
|
-
import type { StorageAdapterInterface } from '../interfaces/adapter';
|
|
50
|
-
import type { StorageAdapterDescriptor } from '../schemas/adapter-descriptor';
|
|
51
|
-
import { resolveHomePath, resolveScopePathTemplate, resolveWorkspacePath } from '../paths';
|
|
52
|
-
import { getVibesRuntime } from '@vibesdotdev/runtime/api/runtime';
|
|
53
|
-
import { createTracer } from '@vibesdotdev/runtime/debug';
|
|
54
|
-
|
|
55
|
-
function resolveTimestampField(
|
|
56
|
-
timestamps: StorageRecordDescriptor['timestamps'],
|
|
57
|
-
field: 'createdAt' | 'updatedAt'
|
|
58
|
-
): string {
|
|
59
|
-
return typeof timestamps === 'object' && typeof timestamps?.[field] === 'string'
|
|
60
|
-
? timestamps[field]
|
|
61
|
-
: field;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function applyCreateTimestamps(
|
|
65
|
-
record: Record<string, unknown>,
|
|
66
|
-
timestamps: StorageRecordDescriptor['timestamps'],
|
|
67
|
-
now: string
|
|
68
|
-
): void {
|
|
69
|
-
if (!timestamps) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const createdAtField = resolveTimestampField(timestamps, 'createdAt');
|
|
74
|
-
const updatedAtField = resolveTimestampField(timestamps, 'updatedAt');
|
|
75
|
-
|
|
76
|
-
if (!record[createdAtField]) {
|
|
77
|
-
record[createdAtField] = now;
|
|
78
|
-
}
|
|
79
|
-
if (!record[updatedAtField]) {
|
|
80
|
-
record[updatedAtField] = now;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export function applyUpdateTimestamp(
|
|
85
|
-
record: Record<string, unknown>,
|
|
86
|
-
update: Record<string, unknown>,
|
|
87
|
-
timestamps: StorageRecordDescriptor['timestamps'],
|
|
88
|
-
now: string
|
|
89
|
-
): void {
|
|
90
|
-
if (!timestamps) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const updatedAtField = resolveTimestampField(timestamps, 'updatedAt');
|
|
95
|
-
if (!(updatedAtField in update)) {
|
|
96
|
-
record[updatedAtField] = now;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* StorageRecord Implementation
|
|
102
|
-
*
|
|
103
|
-
* Implements StorageRecordInterface for single-table CRUD operations.
|
|
104
|
-
* Works with SQLite via the localdb adapter.
|
|
105
|
-
*
|
|
106
|
-
* Uses runtime query API to resolve the appropriate adapter based on
|
|
107
|
-
* the descriptor's allowedAdapters and defaultAdapter settings.
|
|
108
|
-
*/
|
|
109
|
-
export class StorageRecord<T = unknown> implements StorageRecordInterface<
|
|
110
|
-
T,
|
|
111
|
-
Record<string, StorageRelation>
|
|
112
|
-
> {
|
|
113
|
-
readonly tableName: string;
|
|
114
|
-
readonly primaryKey: string;
|
|
115
|
-
readonly schema: z.ZodType<T>;
|
|
116
|
-
readonly relations: Record<string, StorageRelation>;
|
|
117
|
-
|
|
118
|
-
private descriptor: StorageRecordDescriptor;
|
|
119
|
-
private context: KindContext | Record<string, unknown>;
|
|
120
|
-
private adapterCache: StorageAdapterInterface | null = null;
|
|
121
|
-
private db: SqlDatabaseHandle | null = null;
|
|
122
|
-
private initialized = false;
|
|
123
|
-
|
|
124
|
-
private asMutableRecord(record: T): Record<string, unknown> {
|
|
125
|
-
return record as Record<string, unknown>;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
private readStringField(record: T, field: string): string | null {
|
|
129
|
-
const value = this.asMutableRecord(record)[field];
|
|
130
|
-
return typeof value === 'string' ? value : null;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
private readPrimaryKey(record: T): string {
|
|
134
|
-
const id = this.readStringField(record, this.primaryKey);
|
|
135
|
-
if (!id) {
|
|
136
|
-
throw new Error(`Record in ${this.tableName} is missing primary key '${this.primaryKey}'`);
|
|
137
|
-
}
|
|
138
|
-
return id;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Emit a lifecycle event via the runtime HookBus.
|
|
143
|
-
* Fire-and-forget: never blocks CRUD, silently catches errors.
|
|
144
|
-
*/
|
|
145
|
-
private emitLifecycle(phase: string, record: Record<string, unknown>): void {
|
|
146
|
-
try {
|
|
147
|
-
const runtime = getVibesRuntime();
|
|
148
|
-
const id = record[this.primaryKey] as string;
|
|
149
|
-
runtime.hooks('storage/record').emit(phase, {
|
|
150
|
-
recordId: id,
|
|
151
|
-
recordKind: this.descriptor.id,
|
|
152
|
-
tableName: this.tableName,
|
|
153
|
-
data: record
|
|
154
|
-
});
|
|
155
|
-
} catch {
|
|
156
|
-
// Runtime may not be bootstrapped in tests — never block CRUD
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
constructor(descriptor: StorageRecordDescriptor, context: KindContext | Record<string, unknown>) {
|
|
161
|
-
this.descriptor = descriptor;
|
|
162
|
-
this.context = context;
|
|
163
|
-
this.tableName = descriptor.tableName;
|
|
164
|
-
this.primaryKey = descriptor.primaryKey || 'id';
|
|
165
|
-
this.schema = descriptor.schema as z.ZodType<T>;
|
|
166
|
-
this.relations = descriptor.relations || {};
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Resolve the adapter for this record using runtime query API.
|
|
171
|
-
*
|
|
172
|
-
* Uses the record's allowed adapters list and current scope to
|
|
173
|
-
* select the best available adapter.
|
|
174
|
-
*/
|
|
175
|
-
private async getAdapter(): Promise<StorageAdapterInterface> {
|
|
176
|
-
if (this.adapterCache) {
|
|
177
|
-
return this.adapterCache;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const adapterTracer = createTracer(`adapter:${this.descriptor.id}`);
|
|
181
|
-
adapterTracer.start();
|
|
182
|
-
|
|
183
|
-
const runtime = getVibesRuntime();
|
|
184
|
-
let adapter: StorageAdapterInterface | null = null;
|
|
185
|
-
let adapterId: string = '';
|
|
186
|
-
|
|
187
|
-
if (
|
|
188
|
-
this.descriptor.defaultAdapter &&
|
|
189
|
-
this.descriptor.allowedAdapters.includes(this.descriptor.defaultAdapter)
|
|
190
|
-
) {
|
|
191
|
-
adapterId = this.descriptor.defaultAdapter;
|
|
192
|
-
adapter = await runtime
|
|
193
|
-
.query<StorageAdapterDescriptor, StorageAdapterInterface>('storage/adapter')
|
|
194
|
-
.withId(adapterId)
|
|
195
|
-
.enabled()
|
|
196
|
-
.resolve()
|
|
197
|
-
.catch(() => null);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
if (!adapter) {
|
|
201
|
-
for (const allowedId of this.descriptor.allowedAdapters) {
|
|
202
|
-
adapter = await runtime
|
|
203
|
-
.query<StorageAdapterDescriptor, StorageAdapterInterface>('storage/adapter')
|
|
204
|
-
.withId(allowedId)
|
|
205
|
-
.enabled()
|
|
206
|
-
.resolve()
|
|
207
|
-
.catch(() => null);
|
|
208
|
-
if (adapter) {
|
|
209
|
-
adapterId = allowedId;
|
|
210
|
-
break;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
if (!adapter || !adapterId) {
|
|
216
|
-
throw new Error(
|
|
217
|
-
`No available adapter for record '${this.descriptor.id}'. Checked: ${this.descriptor.allowedAdapters.join(', ')}`
|
|
218
|
-
);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
if (!adapter.isConfigured()) {
|
|
222
|
-
const config = this.getAdapterConfig(adapterId);
|
|
223
|
-
adapter.configure(config);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
this.adapterCache = adapter;
|
|
227
|
-
adapterTracer.end('resolved');
|
|
228
|
-
return adapter;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Get adapter configuration based on record scope.
|
|
233
|
-
*/
|
|
234
|
-
private getAdapterConfig(adapterId?: string): Record<string, unknown> {
|
|
235
|
-
const workspacePath = resolveWorkspacePath(this.context);
|
|
236
|
-
const config: Record<string, unknown> = {
|
|
237
|
-
basePath: this.getBasePath(workspacePath),
|
|
238
|
-
workspacePath
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
if (this.descriptor.adapterConfig) {
|
|
242
|
-
const selectedAdapterId =
|
|
243
|
-
adapterId || this.descriptor.defaultAdapter || this.descriptor.allowedAdapters[0];
|
|
244
|
-
const adapterSpecificConfig = this.descriptor.adapterConfig[selectedAdapterId];
|
|
245
|
-
if (adapterSpecificConfig && typeof adapterSpecificConfig === 'object') {
|
|
246
|
-
Object.assign(config, adapterSpecificConfig);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
return config;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Get base path for storage based on scope.
|
|
255
|
-
*
|
|
256
|
-
* Scope mapping:
|
|
257
|
-
* - global: ~/.vibes/ (user-level, shared across projects)
|
|
258
|
-
* - project: ./.vibes/ (project-level, within .vibes dir)
|
|
259
|
-
* - local: ./.vibes/ (alias for project)
|
|
260
|
-
* - auto: ./.vibes/ (defaults to project scope)
|
|
261
|
-
*/
|
|
262
|
-
private getBasePath(workspacePath = resolveWorkspacePath(this.context)): string {
|
|
263
|
-
const scope = this.descriptor.scope || 'project';
|
|
264
|
-
const homePath = resolveHomePath();
|
|
265
|
-
|
|
266
|
-
const descriptorWithScopePaths = this.descriptor as {
|
|
267
|
-
scopePaths?: Partial<Record<'global' | 'project' | 'local', string>>;
|
|
268
|
-
};
|
|
269
|
-
if (descriptorWithScopePaths.scopePaths) {
|
|
270
|
-
const customPath =
|
|
271
|
-
descriptorWithScopePaths.scopePaths[scope as 'global' | 'project' | 'local'];
|
|
272
|
-
if (customPath) {
|
|
273
|
-
return resolveScopePathTemplate(customPath, workspacePath);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
switch (scope) {
|
|
278
|
-
case 'global':
|
|
279
|
-
return `${homePath}/.vibes`;
|
|
280
|
-
case 'local':
|
|
281
|
-
case 'project':
|
|
282
|
-
case 'auto':
|
|
283
|
-
default:
|
|
284
|
-
return `${workspacePath}/.vibes`;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* Initialize the storage record
|
|
290
|
-
* - Creates table if it doesn't exist
|
|
291
|
-
* - Runs migrations
|
|
292
|
-
* - Creates indexes
|
|
293
|
-
*/
|
|
294
|
-
async initialize(): Promise<void> {
|
|
295
|
-
if (this.initialized) return;
|
|
296
|
-
|
|
297
|
-
// Get database connection from adapter
|
|
298
|
-
this.db = await this.getDatabase();
|
|
299
|
-
|
|
300
|
-
// Create table if using inline migrations
|
|
301
|
-
if (this.descriptor.migrations && this.descriptor.migrations.length > 0) {
|
|
302
|
-
await this.runMigrations();
|
|
303
|
-
// Inline migrations may create normalized column schemas.
|
|
304
|
-
// StorageRecord CRUD operations expect a `data` TEXT column for JSON storage.
|
|
305
|
-
// If the migrated table lacks a `data` column and is empty, recreate it
|
|
306
|
-
// with the minimal (primaryKey, data) schema that StorageRecord requires.
|
|
307
|
-
await this.ensureDataColumn();
|
|
308
|
-
} else if (this.descriptor.migrationKey) {
|
|
309
|
-
// Migrations should be pre-registered by the module
|
|
310
|
-
// The adapter will handle them
|
|
311
|
-
} else {
|
|
312
|
-
// Auto-create table based on schema
|
|
313
|
-
await this.createTableFromSchema();
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
// Create indexes
|
|
317
|
-
if (this.descriptor.indexes && this.descriptor.indexes.length > 0) {
|
|
318
|
-
await this.createIndexes();
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
this.initialized = true;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* Ensure the table has a `data` TEXT column required by StorageRecord CRUD operations.
|
|
326
|
-
*
|
|
327
|
-
* Inline migrations may create normalized column schemas that don't include a `data`
|
|
328
|
-
* column. StorageRecord's create/get/list/update/delete all use json_extract(data, ...)
|
|
329
|
-
* and INSERT INTO ... (primaryKey, data). If the table is empty and lacks `data`,
|
|
330
|
-
* it is safe to drop and recreate with the minimal (primaryKey, data) schema.
|
|
331
|
-
*/
|
|
332
|
-
private async ensureDataColumn(): Promise<void> {
|
|
333
|
-
if (!this.db) throw new Error('Database not initialized');
|
|
334
|
-
|
|
335
|
-
const cols = this.db.query<{ name: string }, []>(`PRAGMA table_info(${this.tableName})`).all();
|
|
336
|
-
|
|
337
|
-
if (cols.some((c) => c.name === 'data')) return;
|
|
338
|
-
|
|
339
|
-
// Table lacks a data column. Only recreate if it is empty (no data to lose).
|
|
340
|
-
const row = this.db
|
|
341
|
-
.query<{ n: number }, []>(`SELECT COUNT(*) as n FROM ${this.tableName}`)
|
|
342
|
-
.get();
|
|
343
|
-
|
|
344
|
-
if (!row || row.n > 0) {
|
|
345
|
-
logger.warn(
|
|
346
|
-
`[StorageRecord] Table '${this.tableName}' has no 'data' column and contains rows. ` +
|
|
347
|
-
`CRUD operations may fail. Consider adding a migration to add a 'data TEXT' column.`
|
|
348
|
-
);
|
|
349
|
-
return;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
// Safe to recreate: drop and replace with minimal schema
|
|
353
|
-
this.db.exec(`DROP TABLE IF EXISTS ${this.tableName}`);
|
|
354
|
-
this.db.exec(
|
|
355
|
-
`CREATE TABLE ${this.tableName} (${this.primaryKey} TEXT PRIMARY KEY, data TEXT NOT NULL)`
|
|
356
|
-
);
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* Get database connection from adapter.
|
|
361
|
-
* Uses the typed ensureReady() / getDatabaseConnection() interface.
|
|
362
|
-
*/
|
|
363
|
-
private async getDatabase(): Promise<SqlDatabaseHandle> {
|
|
364
|
-
const adapter = await this.getAdapter();
|
|
365
|
-
|
|
366
|
-
await adapter.ensureReady();
|
|
367
|
-
const db = adapter.getDatabaseConnection();
|
|
368
|
-
if (!db) {
|
|
369
|
-
throw new Error(
|
|
370
|
-
`Adapter '${adapter.id}' returned null from getDatabaseConnection() for record '${this.descriptor.id}'`
|
|
371
|
-
);
|
|
372
|
-
}
|
|
373
|
-
return db as SqlDatabaseHandle;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
* Create table from schema definition
|
|
378
|
-
*/
|
|
379
|
-
private async createTableFromSchema(): Promise<void> {
|
|
380
|
-
if (!this.db) throw new Error('Database not initialized');
|
|
381
|
-
|
|
382
|
-
// Build column definitions from schema
|
|
383
|
-
const columns = this.buildColumnDefinitions();
|
|
384
|
-
const columnDefs = Object.entries(columns)
|
|
385
|
-
.map(([name, def]) => `${name} ${def}`)
|
|
386
|
-
.join(',\n ');
|
|
387
|
-
|
|
388
|
-
const sql = `
|
|
389
|
-
CREATE TABLE IF NOT EXISTS ${this.tableName} (
|
|
390
|
-
${columnDefs}
|
|
391
|
-
)
|
|
392
|
-
`;
|
|
393
|
-
|
|
394
|
-
this.db.exec(sql);
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
/**
|
|
398
|
-
* Build column definitions from schema and descriptor
|
|
399
|
-
*/
|
|
400
|
-
private buildColumnDefinitions(): Record<string, string> {
|
|
401
|
-
const columns: Record<string, string> = {};
|
|
402
|
-
|
|
403
|
-
// Primary key
|
|
404
|
-
const pkType = this.descriptor.fieldConfig?.[this.primaryKey]?.type || 'TEXT';
|
|
405
|
-
columns[this.primaryKey] = `${pkType} PRIMARY KEY`;
|
|
406
|
-
|
|
407
|
-
// Auto-managed fields
|
|
408
|
-
if (this.descriptor.timestamps) {
|
|
409
|
-
const createdAt =
|
|
410
|
-
typeof this.descriptor.timestamps === 'object'
|
|
411
|
-
? this.descriptor.timestamps.createdAt
|
|
412
|
-
: 'createdAt';
|
|
413
|
-
const updatedAt =
|
|
414
|
-
typeof this.descriptor.timestamps === 'object'
|
|
415
|
-
? this.descriptor.timestamps.updatedAt
|
|
416
|
-
: 'updatedAt';
|
|
417
|
-
|
|
418
|
-
if (createdAt) {
|
|
419
|
-
const createdAtField = typeof createdAt === 'string' ? createdAt : 'createdAt';
|
|
420
|
-
columns[createdAtField] = 'TEXT DEFAULT CURRENT_TIMESTAMP';
|
|
421
|
-
}
|
|
422
|
-
if (updatedAt) {
|
|
423
|
-
const updatedAtField = typeof updatedAt === 'string' ? updatedAt : 'updatedAt';
|
|
424
|
-
columns[updatedAtField] = 'TEXT DEFAULT CURRENT_TIMESTAMP';
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
if (this.descriptor.softDelete) {
|
|
429
|
-
const deletedAtField =
|
|
430
|
-
typeof this.descriptor.softDelete === 'string' ? this.descriptor.softDelete : 'deletedAt';
|
|
431
|
-
columns[deletedAtField] = 'TEXT';
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
// Schema introspection is not yet wired; all non-meta fields live in a JSON `data` blob.
|
|
435
|
-
columns['data'] = 'TEXT';
|
|
436
|
-
|
|
437
|
-
return columns;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
/**
|
|
441
|
-
* Create indexes from descriptor
|
|
442
|
-
*/
|
|
443
|
-
private async createIndexes(): Promise<void> {
|
|
444
|
-
if (!this.db) throw new Error('Database not initialized');
|
|
445
|
-
|
|
446
|
-
// Detect whether the table uses JSON blob storage (has a 'data' column).
|
|
447
|
-
// ensureDataColumn() may have recreated the table as (primaryKey, data TEXT),
|
|
448
|
-
// so direct column references from the descriptor won't exist. Use json_extract
|
|
449
|
-
// expressions instead so indexes still function and unique constraints are enforced.
|
|
450
|
-
const tableInfo = this.db
|
|
451
|
-
.query<{ name: string }, []>(`PRAGMA table_info(${this.tableName})`)
|
|
452
|
-
.all();
|
|
453
|
-
const hasDataColumn = tableInfo.some((c) => c.name === 'data');
|
|
454
|
-
const toSnakeCase = (value: string): string =>
|
|
455
|
-
value
|
|
456
|
-
.replace(/([a-z0-9])([A-Z])/g, '$1_$2')
|
|
457
|
-
.replace(/-/g, '_')
|
|
458
|
-
.toLowerCase();
|
|
459
|
-
const escapeRegExp = (value: string): string => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
460
|
-
|
|
461
|
-
for (const index of this.descriptor.indexes || []) {
|
|
462
|
-
const indexName = index.name || `idx_${this.tableName}_${index.fields.join('_')}`;
|
|
463
|
-
const unique = index.unique ? 'UNIQUE' : '';
|
|
464
|
-
|
|
465
|
-
let fieldExpr: string;
|
|
466
|
-
let whereExpr = '';
|
|
467
|
-
|
|
468
|
-
if (hasDataColumn) {
|
|
469
|
-
// JSON blob mode: reference fields via json_extract so indexes work
|
|
470
|
-
fieldExpr = index.fields.map((f: string) => `json_extract(data, '$.${f}')`).join(', ');
|
|
471
|
-
if (index.where) {
|
|
472
|
-
// Replace field name references in the WHERE clause with json_extract.
|
|
473
|
-
// Some descriptors still use snake_case predicates (legacy migration SQL style).
|
|
474
|
-
let w = index.where;
|
|
475
|
-
for (const f of index.fields) {
|
|
476
|
-
// Dedupe aliases so identical camel/snake names don't double-replace,
|
|
477
|
-
// which would corrupt an already-substituted json_extract expression.
|
|
478
|
-
const aliases = [...new Set([f, toSnakeCase(f)])];
|
|
479
|
-
for (const alias of aliases) {
|
|
480
|
-
w = w.replace(
|
|
481
|
-
new RegExp(`\\b${escapeRegExp(alias)}\\b`, 'g'),
|
|
482
|
-
`json_extract(data, '$.${f}')`
|
|
483
|
-
);
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
whereExpr = `WHERE ${w}`;
|
|
487
|
-
}
|
|
488
|
-
} else {
|
|
489
|
-
// Normalized column mode: use direct column references
|
|
490
|
-
fieldExpr = index.fields.join(', ');
|
|
491
|
-
whereExpr = index.where ? `WHERE ${index.where}` : '';
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
const sql = `CREATE ${unique} INDEX IF NOT EXISTS ${indexName} ON ${this.tableName} (${fieldExpr}) ${whereExpr}`;
|
|
495
|
-
try {
|
|
496
|
-
this.db.query(sql).run();
|
|
497
|
-
} catch (error) {
|
|
498
|
-
if (index.unique) {
|
|
499
|
-
// Unique index failures must be fatal — they protect data integrity
|
|
500
|
-
throw error;
|
|
501
|
-
}
|
|
502
|
-
// Non-unique index creation can fail if descriptor field names don't match
|
|
503
|
-
// actual column names (e.g. camelCase vs snake_case mismatch). Log and continue.
|
|
504
|
-
logger.warn(
|
|
505
|
-
`[StorageRecord] Skipping index '${indexName}' on '${this.tableName}': ${error instanceof Error ? error.message : String(error)}`
|
|
506
|
-
);
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
/**
|
|
512
|
-
* Execute one or more SQL statements, splitting on `;` and running each
|
|
513
|
-
* via the prepared-statement path so bun:sqlite does not misinterpret `$`
|
|
514
|
-
* tokens inside string literals (e.g. json_extract paths).
|
|
515
|
-
*/
|
|
516
|
-
private execStatements(sql: string): void {
|
|
517
|
-
if (!this.db) throw new Error('Database not initialized');
|
|
518
|
-
for (const stmt of sql.split(';').map((s) => s.trim()).filter(Boolean)) {
|
|
519
|
-
this.db.query(stmt).run();
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
/**
|
|
524
|
-
* Run migrations from descriptor
|
|
525
|
-
*/
|
|
526
|
-
private async runMigrations(): Promise<void> {
|
|
527
|
-
if (!this.db) throw new Error('Database not initialized');
|
|
528
|
-
|
|
529
|
-
const migrations = this.descriptor.migrations || [];
|
|
530
|
-
|
|
531
|
-
// Create migrations tracking table if not exists
|
|
532
|
-
this.db.exec(`
|
|
533
|
-
CREATE TABLE IF NOT EXISTS _migrations_${this.tableName} (
|
|
534
|
-
version INTEGER PRIMARY KEY,
|
|
535
|
-
name TEXT,
|
|
536
|
-
applied_at TEXT DEFAULT CURRENT_TIMESTAMP
|
|
537
|
-
)
|
|
538
|
-
`);
|
|
539
|
-
|
|
540
|
-
// Get applied migrations
|
|
541
|
-
const applied = this.db
|
|
542
|
-
.query<{ version: number }, []>(`SELECT version FROM _migrations_${this.tableName}`)
|
|
543
|
-
.all()
|
|
544
|
-
.map((r) => r.version);
|
|
545
|
-
|
|
546
|
-
// Run pending migrations
|
|
547
|
-
for (const migration of migrations) {
|
|
548
|
-
if (applied.includes(migration.version)) continue;
|
|
549
|
-
|
|
550
|
-
try {
|
|
551
|
-
if (typeof migration.up === 'string') {
|
|
552
|
-
this.execStatements(migration.up);
|
|
553
|
-
} else if (typeof migration.up === 'function') {
|
|
554
|
-
await migration.up(this.db);
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
// Record migration
|
|
558
|
-
this.db
|
|
559
|
-
.query(`INSERT INTO _migrations_${this.tableName} (version, name) VALUES (?, ?)`)
|
|
560
|
-
.run(migration.version, migration.name || '');
|
|
561
|
-
|
|
562
|
-
logger.debug(
|
|
563
|
-
`[StorageRecord] Applied migration ${migration.version} for ${this.tableName}`
|
|
564
|
-
);
|
|
565
|
-
} catch (error) {
|
|
566
|
-
// A "no such table" failure typically means the consumer is
|
|
567
|
-
// querying before its initial seed has run (e.g. `knowledge
|
|
568
|
-
// status` before any knowledge base exists). The application
|
|
569
|
-
// layer catches the throw and renders empty state; demote the
|
|
570
|
-
// log so the spurious noise doesn't reach the user. Real
|
|
571
|
-
// migration failures still surface at warn level + the throw.
|
|
572
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
573
|
-
const isTableMissing = /no such table/i.test(message);
|
|
574
|
-
if (isTableMissing) {
|
|
575
|
-
logger.debug(
|
|
576
|
-
`[StorageRecord] Migration ${migration.version} skipped for ${this.tableName} (table not yet initialized)`
|
|
577
|
-
);
|
|
578
|
-
} else {
|
|
579
|
-
logger.error(
|
|
580
|
-
`[StorageRecord] Migration ${migration.version} failed for ${this.tableName}:`,
|
|
581
|
-
toErrorContext(error)
|
|
582
|
-
);
|
|
583
|
-
}
|
|
584
|
-
throw error;
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
// CREATE
|
|
590
|
-
|
|
591
|
-
async create(data: CreateInput<T>): Promise<T> {
|
|
592
|
-
await this.ensureInitialized();
|
|
593
|
-
|
|
594
|
-
// Prepare record
|
|
595
|
-
const record = { ...data } as Record<string, unknown>;
|
|
596
|
-
|
|
597
|
-
// Auto-generate ID (must happen before validation so the schema check passes)
|
|
598
|
-
if (this.descriptor.autoId) {
|
|
599
|
-
const idField =
|
|
600
|
-
typeof this.descriptor.autoId === 'object' && this.descriptor.autoId.field
|
|
601
|
-
? this.descriptor.autoId.field
|
|
602
|
-
: this.primaryKey;
|
|
603
|
-
|
|
604
|
-
if (!record[idField]) {
|
|
605
|
-
record[idField] = this.generateId();
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
// Auto-manage timestamps (before validation so timestamps are present)
|
|
610
|
-
if (this.descriptor.timestamps) {
|
|
611
|
-
const now = new Date().toISOString();
|
|
612
|
-
applyCreateTimestamps(record, this.descriptor.timestamps, now);
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
// Execute beforeCreate hook (may set additional required fields)
|
|
616
|
-
if (this.descriptor.beforeCreate) {
|
|
617
|
-
await (this.descriptor.beforeCreate as Function)(record);
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
// Validate after all auto-fields are populated
|
|
621
|
-
if (this.descriptor.validateOnWrite !== false) {
|
|
622
|
-
const validation = await this.validate(record);
|
|
623
|
-
if (!validation.success) {
|
|
624
|
-
throw new Error(`Validation failed: ${validation.errors?.message}`);
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
// Insert into database
|
|
629
|
-
const id = record[this.primaryKey];
|
|
630
|
-
const dataJson = JSON.stringify(record);
|
|
631
|
-
|
|
632
|
-
this.db!.query(`INSERT INTO ${this.tableName} (${this.primaryKey}, data) VALUES (?, ?)`).run(
|
|
633
|
-
id as string,
|
|
634
|
-
dataJson
|
|
635
|
-
);
|
|
636
|
-
|
|
637
|
-
// Execute afterCreate hook
|
|
638
|
-
if (this.descriptor.afterCreate) {
|
|
639
|
-
await (this.descriptor.afterCreate as Function)(record);
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
this.emitLifecycle('afterCreate', record);
|
|
643
|
-
|
|
644
|
-
return record as T;
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
async createMany(data: CreateInput<T>[], options?: CreateManyOptions): Promise<T[]> {
|
|
648
|
-
const results: T[] = [];
|
|
649
|
-
const batchSize = options?.batchSize || 100;
|
|
650
|
-
|
|
651
|
-
for (let i = 0; i < data.length; i += batchSize) {
|
|
652
|
-
const batch = data.slice(i, i + batchSize);
|
|
653
|
-
const created = await Promise.all(batch.map((item) => this.create(item)));
|
|
654
|
-
results.push(...created);
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
return results;
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
// READ
|
|
661
|
-
|
|
662
|
-
async get(
|
|
663
|
-
id: string,
|
|
664
|
-
options?: Pick<QueryOptions<T, string & keyof this['relations']>, 'include' | 'select'>
|
|
665
|
-
): Promise<T | null> {
|
|
666
|
-
await this.ensureInitialized();
|
|
667
|
-
|
|
668
|
-
const row = this.db!.query<{ data: string }, [string]>(
|
|
669
|
-
`SELECT data FROM ${this.tableName} WHERE ${this.primaryKey} = ?`
|
|
670
|
-
).get(id);
|
|
671
|
-
|
|
672
|
-
if (!row) return null;
|
|
673
|
-
|
|
674
|
-
const record = JSON.parse(row.data) as T;
|
|
675
|
-
|
|
676
|
-
// Load relations if requested
|
|
677
|
-
if (options?.include) {
|
|
678
|
-
await this.loadRelations(record, options.include as IncludeRelations);
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
// Validate on read if configured
|
|
682
|
-
if (this.descriptor.validateOnRead) {
|
|
683
|
-
const validation = await this.validate(record);
|
|
684
|
-
if (!validation.success) {
|
|
685
|
-
logger.warn(
|
|
686
|
-
`[StorageRecord] Validation failed on read:`,
|
|
687
|
-
toErrorContext(validation.errors)
|
|
688
|
-
);
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
return record;
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
async getOrThrow(
|
|
696
|
-
id: string,
|
|
697
|
-
options?: Pick<QueryOptions<T, string & keyof this['relations']>, 'include' | 'select'>
|
|
698
|
-
): Promise<T> {
|
|
699
|
-
const record = await this.get(id, options);
|
|
700
|
-
if (!record) {
|
|
701
|
-
throw new Error(`Record with ${this.primaryKey}=${id} not found in ${this.tableName}`);
|
|
702
|
-
}
|
|
703
|
-
return record;
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
async getMany(
|
|
707
|
-
ids: string[],
|
|
708
|
-
options?: Pick<QueryOptions<T, string & keyof this['relations']>, 'include' | 'select'>
|
|
709
|
-
): Promise<T[]> {
|
|
710
|
-
await this.ensureInitialized();
|
|
711
|
-
|
|
712
|
-
if (ids.length === 0) return [];
|
|
713
|
-
|
|
714
|
-
const placeholders = ids.map(() => '?').join(', ');
|
|
715
|
-
const rows = this.db!.query<{ data: string }, string[]>(
|
|
716
|
-
`SELECT data FROM ${this.tableName} WHERE ${this.primaryKey} IN (${placeholders})`
|
|
717
|
-
).all(...ids);
|
|
718
|
-
|
|
719
|
-
let records = rows.map((row) => JSON.parse(row.data) as T);
|
|
720
|
-
|
|
721
|
-
// Load relations if requested
|
|
722
|
-
if (options?.include) {
|
|
723
|
-
records = await Promise.all(
|
|
724
|
-
records.map((record) => this.loadRelations(record, options.include as IncludeRelations))
|
|
725
|
-
);
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
return records;
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
async list(options?: QueryOptions<T, string & keyof this['relations']>): Promise<QueryResult<T>> {
|
|
732
|
-
await this.ensureInitialized();
|
|
733
|
-
|
|
734
|
-
// Build query
|
|
735
|
-
let sql = `SELECT data FROM ${this.tableName}`;
|
|
736
|
-
const params: unknown[] = [];
|
|
737
|
-
|
|
738
|
-
// WHERE clause
|
|
739
|
-
let hasWhereConditions = false;
|
|
740
|
-
if (options?.where) {
|
|
741
|
-
const { clause, values } = this.buildWhereClause(options.where);
|
|
742
|
-
if (clause) {
|
|
743
|
-
sql += ` WHERE ${clause}`;
|
|
744
|
-
params.push(...values);
|
|
745
|
-
hasWhereConditions = true;
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
// Soft delete filter
|
|
750
|
-
if (this.descriptor.softDelete && !options?.includeDeleted) {
|
|
751
|
-
const deletedAtField =
|
|
752
|
-
typeof this.descriptor.softDelete === 'string' ? this.descriptor.softDelete : 'deletedAt';
|
|
753
|
-
sql += hasWhereConditions ? ` AND ` : ` WHERE `;
|
|
754
|
-
sql += `json_extract(data, '$.${deletedAtField}') IS NULL`;
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
// ORDER BY
|
|
758
|
-
if (options?.orderBy) {
|
|
759
|
-
sql += ` ORDER BY ${this.buildOrderBy(options.orderBy)}`;
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
// COUNT query for total
|
|
763
|
-
const countSql = sql.replace('SELECT data', 'SELECT COUNT(*) as count');
|
|
764
|
-
const countRow = this.db!.query<{ count: number }, any[]>(countSql).get(...params);
|
|
765
|
-
const total = countRow?.count || 0;
|
|
766
|
-
|
|
767
|
-
// LIMIT and OFFSET
|
|
768
|
-
if (options?.limit) {
|
|
769
|
-
sql += ` LIMIT ?`;
|
|
770
|
-
params.push(options.limit);
|
|
771
|
-
}
|
|
772
|
-
if (options?.offset) {
|
|
773
|
-
sql += ` OFFSET ?`;
|
|
774
|
-
params.push(options.offset);
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
// Execute query
|
|
778
|
-
const rows = this.db!.query<{ data: string }, any[]>(sql).all(...params);
|
|
779
|
-
let items = rows.map((row) => JSON.parse(row.data) as T);
|
|
780
|
-
|
|
781
|
-
// Load relations if requested
|
|
782
|
-
if (options?.include) {
|
|
783
|
-
items = await Promise.all(
|
|
784
|
-
items.map((item) => this.loadRelations(item, options.include as IncludeRelations))
|
|
785
|
-
);
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
return {
|
|
789
|
-
items,
|
|
790
|
-
total,
|
|
791
|
-
hasMore: options?.limit ? items.length === options.limit : false
|
|
792
|
-
};
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
async findFirst(options?: QueryOptions<T, string & keyof this['relations']>): Promise<T | null> {
|
|
796
|
-
const result = await this.list({ ...options, limit: 1 });
|
|
797
|
-
return result.items[0] || null;
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
async findFirstOrThrow(options?: QueryOptions<T, string & keyof this['relations']>): Promise<T> {
|
|
801
|
-
const record = await this.findFirst(options);
|
|
802
|
-
if (!record) {
|
|
803
|
-
throw new Error(`No record found in ${this.tableName} matching criteria`);
|
|
804
|
-
}
|
|
805
|
-
return record;
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
async exists(id: string): Promise<boolean> {
|
|
809
|
-
await this.ensureInitialized();
|
|
810
|
-
|
|
811
|
-
const row = this.db!.query<{ count: number }, [string]>(
|
|
812
|
-
`SELECT COUNT(*) as count FROM ${this.tableName} WHERE ${this.primaryKey} = ?`
|
|
813
|
-
).get(id);
|
|
814
|
-
|
|
815
|
-
return (row?.count || 0) > 0;
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
async count(where?: WhereFilter<T>): Promise<number> {
|
|
819
|
-
await this.ensureInitialized();
|
|
820
|
-
|
|
821
|
-
let sql = `SELECT COUNT(*) as count FROM ${this.tableName}`;
|
|
822
|
-
const params: unknown[] = [];
|
|
823
|
-
let hasWhereConditions = false;
|
|
824
|
-
|
|
825
|
-
if (where) {
|
|
826
|
-
const { clause, values } = this.buildWhereClause(where);
|
|
827
|
-
if (clause) {
|
|
828
|
-
sql += ` WHERE ${clause}`;
|
|
829
|
-
params.push(...values);
|
|
830
|
-
hasWhereConditions = true;
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
// Soft delete filter
|
|
835
|
-
if (this.descriptor.softDelete) {
|
|
836
|
-
const deletedAtField =
|
|
837
|
-
typeof this.descriptor.softDelete === 'string' ? this.descriptor.softDelete : 'deletedAt';
|
|
838
|
-
sql += hasWhereConditions ? ` AND ` : ` WHERE `;
|
|
839
|
-
sql += `json_extract(data, '$.${deletedAtField}') IS NULL`;
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
const row = this.db!.query<{ count: number }, any[]>(sql).get(...params);
|
|
843
|
-
return row?.count || 0;
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
// UPDATE
|
|
847
|
-
|
|
848
|
-
async update(id: string, data: UpdateInput<T>, _options?: UpdateOptions): Promise<T> {
|
|
849
|
-
await this.ensureInitialized();
|
|
850
|
-
|
|
851
|
-
// Get existing record
|
|
852
|
-
const existing = await this.get(id);
|
|
853
|
-
if (!existing) {
|
|
854
|
-
throw new Error(`Record with ${this.primaryKey}=${id} not found in ${this.tableName}`);
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
// Merge updates
|
|
858
|
-
const updated = { ...existing, ...data } as Record<string, unknown>;
|
|
859
|
-
|
|
860
|
-
// Auto-manage timestamps
|
|
861
|
-
if (this.descriptor.timestamps) {
|
|
862
|
-
applyUpdateTimestamp(
|
|
863
|
-
updated,
|
|
864
|
-
data as Record<string, unknown>,
|
|
865
|
-
this.descriptor.timestamps,
|
|
866
|
-
new Date().toISOString()
|
|
867
|
-
);
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
// Validate
|
|
871
|
-
if (this.descriptor.validateOnWrite !== false) {
|
|
872
|
-
const validation = await this.validate(updated);
|
|
873
|
-
if (!validation.success) {
|
|
874
|
-
throw new Error(`Validation failed: ${validation.errors?.message}`);
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
// Execute beforeUpdate hook
|
|
879
|
-
if (this.descriptor.beforeUpdate) {
|
|
880
|
-
await (this.descriptor.beforeUpdate as Function)(updated);
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
// Update in database
|
|
884
|
-
const dataJson = JSON.stringify(updated);
|
|
885
|
-
this.db!.query(`UPDATE ${this.tableName} SET data = ? WHERE ${this.primaryKey} = ?`).run(
|
|
886
|
-
dataJson,
|
|
887
|
-
id
|
|
888
|
-
);
|
|
889
|
-
|
|
890
|
-
// Execute afterUpdate hook
|
|
891
|
-
if (this.descriptor.afterUpdate) {
|
|
892
|
-
await (this.descriptor.afterUpdate as Function)(updated);
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
this.emitLifecycle('afterUpdate', updated);
|
|
896
|
-
|
|
897
|
-
return updated as T;
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
async updateMany(
|
|
901
|
-
where: WhereFilter<T>,
|
|
902
|
-
data: UpdateInput<T>,
|
|
903
|
-
options?: UpdateOptions
|
|
904
|
-
): Promise<UpdateResult> {
|
|
905
|
-
await this.ensureInitialized();
|
|
906
|
-
|
|
907
|
-
// Find matching records
|
|
908
|
-
const result = await this.list({ where, select: [this.primaryKey as keyof T] });
|
|
909
|
-
const ids = result.items.map((item) => this.readPrimaryKey(item));
|
|
910
|
-
|
|
911
|
-
// Update each record
|
|
912
|
-
let count = 0;
|
|
913
|
-
for (const id of ids) {
|
|
914
|
-
try {
|
|
915
|
-
await this.update(id, data, options);
|
|
916
|
-
count++;
|
|
917
|
-
} catch (error) {
|
|
918
|
-
logger.error(`[StorageRecord] Failed to update record ${id}:`, toErrorContext(error));
|
|
919
|
-
}
|
|
920
|
-
}
|
|
921
|
-
|
|
922
|
-
return { count, success: count > 0 };
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
async upsert(id: string, create: CreateInput<T>, update: UpdateInput<T>): Promise<T> {
|
|
926
|
-
const existing = await this.get(id);
|
|
927
|
-
if (existing) {
|
|
928
|
-
return this.update(id, update);
|
|
929
|
-
} else {
|
|
930
|
-
return this.create({ ...create, [this.primaryKey]: id } as CreateInput<T>);
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
// DELETE
|
|
935
|
-
|
|
936
|
-
async delete(id: string, options?: DeleteOptions): Promise<DeleteResult> {
|
|
937
|
-
await this.ensureInitialized();
|
|
938
|
-
|
|
939
|
-
// Check if exists
|
|
940
|
-
let existing = await this.get(id, { include: undefined });
|
|
941
|
-
if (!existing && this.descriptor.softDelete && options?.force) {
|
|
942
|
-
const row = this.db!.query<{ data: string }, [string]>(
|
|
943
|
-
`SELECT data FROM ${this.tableName} WHERE ${this.primaryKey} = ?`
|
|
944
|
-
).get(id);
|
|
945
|
-
existing = row ? (JSON.parse(row.data) as Awaited<T>) : null;
|
|
946
|
-
}
|
|
947
|
-
if (!existing) {
|
|
948
|
-
return { count: 0, success: false };
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
// Execute beforeDelete hook
|
|
952
|
-
if (this.descriptor.beforeDelete) {
|
|
953
|
-
await (this.descriptor.beforeDelete as Function)(existing);
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
// Soft delete or hard delete
|
|
957
|
-
if (this.descriptor.softDelete && !options?.force) {
|
|
958
|
-
const deletedAtField =
|
|
959
|
-
typeof this.descriptor.softDelete === 'string' ? this.descriptor.softDelete : 'deletedAt';
|
|
960
|
-
const deleted = {
|
|
961
|
-
...existing,
|
|
962
|
-
[deletedAtField]: new Date().toISOString()
|
|
963
|
-
} as Record<string, unknown>;
|
|
964
|
-
|
|
965
|
-
const dataJson = JSON.stringify(deleted);
|
|
966
|
-
this.db!.query(`UPDATE ${this.tableName} SET data = ? WHERE ${this.primaryKey} = ?`).run(
|
|
967
|
-
dataJson,
|
|
968
|
-
id
|
|
969
|
-
);
|
|
970
|
-
} else {
|
|
971
|
-
this.db!.query(`DELETE FROM ${this.tableName} WHERE ${this.primaryKey} = ?`).run(id);
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
// Execute afterDelete hook
|
|
975
|
-
if (this.descriptor.afterDelete) {
|
|
976
|
-
await (this.descriptor.afterDelete as Function)(existing);
|
|
977
|
-
}
|
|
978
|
-
|
|
979
|
-
this.emitLifecycle('afterDelete', existing as Record<string, unknown>);
|
|
980
|
-
|
|
981
|
-
return { count: 1, success: true };
|
|
982
|
-
}
|
|
983
|
-
|
|
984
|
-
async deleteMany(where: WhereFilter<T>, options?: DeleteOptions): Promise<DeleteResult> {
|
|
985
|
-
await this.ensureInitialized();
|
|
986
|
-
|
|
987
|
-
// Find matching records
|
|
988
|
-
const result = await this.list({ where, select: [this.primaryKey as keyof T] });
|
|
989
|
-
const ids = result.items.map((item) => this.readPrimaryKey(item));
|
|
990
|
-
|
|
991
|
-
// Delete each record
|
|
992
|
-
let count = 0;
|
|
993
|
-
for (const id of ids) {
|
|
994
|
-
try {
|
|
995
|
-
const deleteResult = await this.delete(id, options);
|
|
996
|
-
count += deleteResult.count;
|
|
997
|
-
} catch (error) {
|
|
998
|
-
logger.error(`[StorageRecord] Failed to delete record ${id}:`, toErrorContext(error));
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
return { count, success: count > 0 };
|
|
1003
|
-
}
|
|
1004
|
-
|
|
1005
|
-
async restore(id: string): Promise<T> {
|
|
1006
|
-
await this.ensureInitialized();
|
|
1007
|
-
|
|
1008
|
-
if (!this.descriptor.softDelete) {
|
|
1009
|
-
throw new Error(`Soft delete is not enabled for ${this.tableName}`);
|
|
1010
|
-
}
|
|
1011
|
-
|
|
1012
|
-
const deletedAtField =
|
|
1013
|
-
typeof this.descriptor.softDelete === 'string' ? this.descriptor.softDelete : 'deletedAt';
|
|
1014
|
-
|
|
1015
|
-
// Get record (including soft-deleted)
|
|
1016
|
-
const row = this.db!.query<{ data: string }, [string]>(
|
|
1017
|
-
`SELECT data FROM ${this.tableName} WHERE ${this.primaryKey} = ?`
|
|
1018
|
-
).get(id);
|
|
1019
|
-
|
|
1020
|
-
if (!row) {
|
|
1021
|
-
throw new Error(`Record with ${this.primaryKey}=${id} not found in ${this.tableName}`);
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1024
|
-
const record = JSON.parse(row.data) as Record<string, unknown>;
|
|
1025
|
-
|
|
1026
|
-
if (!record[deletedAtField]) {
|
|
1027
|
-
throw new Error(`Record ${id} is not soft-deleted`);
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
// Restore by clearing deletedAt
|
|
1031
|
-
delete record[deletedAtField];
|
|
1032
|
-
|
|
1033
|
-
// Update timestamp
|
|
1034
|
-
if (this.descriptor.timestamps) {
|
|
1035
|
-
const updatedAtField =
|
|
1036
|
-
typeof this.descriptor.timestamps === 'object' &&
|
|
1037
|
-
typeof this.descriptor.timestamps.updatedAt === 'string'
|
|
1038
|
-
? this.descriptor.timestamps.updatedAt
|
|
1039
|
-
: 'updatedAt';
|
|
1040
|
-
record[updatedAtField] = new Date().toISOString();
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1043
|
-
const dataJson = JSON.stringify(record);
|
|
1044
|
-
this.db!.query(`UPDATE ${this.tableName} SET data = ? WHERE ${this.primaryKey} = ?`).run(
|
|
1045
|
-
dataJson,
|
|
1046
|
-
id
|
|
1047
|
-
);
|
|
1048
|
-
|
|
1049
|
-
return record as T;
|
|
1050
|
-
}
|
|
1051
|
-
|
|
1052
|
-
// AGGREGATION
|
|
1053
|
-
|
|
1054
|
-
async aggregate(
|
|
1055
|
-
options: AggregationOptions<T> & { function: AggregationFunction }
|
|
1056
|
-
): Promise<AggregationResult[]> {
|
|
1057
|
-
await this.ensureInitialized();
|
|
1058
|
-
|
|
1059
|
-
const func = options.function;
|
|
1060
|
-
const field = options.field;
|
|
1061
|
-
|
|
1062
|
-
let sql = `SELECT `;
|
|
1063
|
-
|
|
1064
|
-
// Aggregation function
|
|
1065
|
-
if (func === 'count' && !field) {
|
|
1066
|
-
sql += `COUNT(*) as value`;
|
|
1067
|
-
} else if (field) {
|
|
1068
|
-
const fieldName = String(field);
|
|
1069
|
-
switch (func) {
|
|
1070
|
-
case 'count':
|
|
1071
|
-
sql += `COUNT(${fieldName}) as value`;
|
|
1072
|
-
break;
|
|
1073
|
-
case 'sum':
|
|
1074
|
-
sql += `SUM(CAST(json_extract(data, '$.${fieldName}') AS REAL)) as value`;
|
|
1075
|
-
break;
|
|
1076
|
-
case 'avg':
|
|
1077
|
-
sql += `AVG(CAST(json_extract(data, '$.${fieldName}') AS REAL)) as value`;
|
|
1078
|
-
break;
|
|
1079
|
-
case 'min':
|
|
1080
|
-
sql += `MIN(json_extract(data, '$.${fieldName}')) as value`;
|
|
1081
|
-
break;
|
|
1082
|
-
case 'max':
|
|
1083
|
-
sql += `MAX(json_extract(data, '$.${fieldName}')) as value`;
|
|
1084
|
-
break;
|
|
1085
|
-
}
|
|
1086
|
-
}
|
|
1087
|
-
|
|
1088
|
-
sql += ` FROM ${this.tableName}`;
|
|
1089
|
-
|
|
1090
|
-
// WHERE clause
|
|
1091
|
-
const params: unknown[] = [];
|
|
1092
|
-
if (options.where) {
|
|
1093
|
-
const { clause, values } = this.buildWhereClause(options.where);
|
|
1094
|
-
if (clause) {
|
|
1095
|
-
sql += ` WHERE ${clause}`;
|
|
1096
|
-
params.push(...values);
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
|
-
|
|
1100
|
-
// GROUP BY
|
|
1101
|
-
if (options.groupBy) {
|
|
1102
|
-
const groupByFields = Array.isArray(options.groupBy) ? options.groupBy : [options.groupBy];
|
|
1103
|
-
const groupByExpr = groupByFields
|
|
1104
|
-
.map((f) => `json_extract(data, '$.${String(f)}')`)
|
|
1105
|
-
.join(', ');
|
|
1106
|
-
sql += ` GROUP BY ${groupByExpr}`;
|
|
1107
|
-
}
|
|
1108
|
-
|
|
1109
|
-
const rows = this.db!.query<{ value: number }, any[]>(sql).all(...params);
|
|
1110
|
-
|
|
1111
|
-
return rows.map((row) => ({
|
|
1112
|
-
value: row.value || 0
|
|
1113
|
-
}));
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
// TRANSACTIONS
|
|
1117
|
-
|
|
1118
|
-
async transaction<U>(fn: TransactionFn<U>): Promise<U> {
|
|
1119
|
-
await this.ensureInitialized();
|
|
1120
|
-
|
|
1121
|
-
if (!this.db) {
|
|
1122
|
-
throw new Error('Database not initialized');
|
|
1123
|
-
}
|
|
1124
|
-
|
|
1125
|
-
// Begin transaction
|
|
1126
|
-
this.db.exec('BEGIN TRANSACTION');
|
|
1127
|
-
|
|
1128
|
-
const tx: TransactionContext = {
|
|
1129
|
-
id: `tx-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
|
1130
|
-
startTime: Date.now(),
|
|
1131
|
-
isActive: true
|
|
1132
|
-
};
|
|
1133
|
-
|
|
1134
|
-
try {
|
|
1135
|
-
const result = await fn(tx);
|
|
1136
|
-
|
|
1137
|
-
// Commit transaction
|
|
1138
|
-
this.db.exec('COMMIT');
|
|
1139
|
-
tx.isActive = false;
|
|
1140
|
-
|
|
1141
|
-
return result;
|
|
1142
|
-
} catch (error) {
|
|
1143
|
-
// Rollback transaction
|
|
1144
|
-
this.db.exec('ROLLBACK');
|
|
1145
|
-
tx.isActive = false;
|
|
1146
|
-
throw error;
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
// STREAMING
|
|
1151
|
-
|
|
1152
|
-
async *stream(options?: StreamOptions<T>): AsyncIterable<T> {
|
|
1153
|
-
await this.ensureInitialized();
|
|
1154
|
-
|
|
1155
|
-
const batchSize = options?.batchSize || 100;
|
|
1156
|
-
let offset = options?.offset || 0;
|
|
1157
|
-
|
|
1158
|
-
while (true) {
|
|
1159
|
-
// StreamOptions extends QueryOptions but adds batchSize/offset; both belong on QueryOptions
|
|
1160
|
-
// for the list() call below, but `batchSize` is stream-only — strip it before passing along.
|
|
1161
|
-
const { batchSize: _strip, ...listOptions } = (options ?? {}) as { batchSize?: number };
|
|
1162
|
-
const result = await this.list({
|
|
1163
|
-
...listOptions,
|
|
1164
|
-
limit: batchSize,
|
|
1165
|
-
offset
|
|
1166
|
-
});
|
|
1167
|
-
|
|
1168
|
-
if (result.items.length === 0) {
|
|
1169
|
-
break;
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
|
-
for (const item of result.items) {
|
|
1173
|
-
yield item;
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
|
-
offset += batchSize;
|
|
1177
|
-
|
|
1178
|
-
if (!result.hasMore) {
|
|
1179
|
-
break;
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
1182
|
-
}
|
|
1183
|
-
|
|
1184
|
-
// BATCH OPERATIONS
|
|
1185
|
-
|
|
1186
|
-
batch(
|
|
1187
|
-
operations: Array<{
|
|
1188
|
-
type: 'create' | 'update' | 'delete';
|
|
1189
|
-
data?: unknown;
|
|
1190
|
-
id?: string;
|
|
1191
|
-
}>
|
|
1192
|
-
): Promise<unknown[]> {
|
|
1193
|
-
return this.transaction(async () => {
|
|
1194
|
-
const results: unknown[] = [];
|
|
1195
|
-
|
|
1196
|
-
for (const op of operations) {
|
|
1197
|
-
let result: unknown;
|
|
1198
|
-
switch (op.type) {
|
|
1199
|
-
case 'create':
|
|
1200
|
-
result = await this.create(op.data as CreateInput<T>);
|
|
1201
|
-
break;
|
|
1202
|
-
case 'update':
|
|
1203
|
-
if (!op.id) throw new Error('ID required for update');
|
|
1204
|
-
result = await this.update(op.id, op.data as UpdateInput<T>);
|
|
1205
|
-
break;
|
|
1206
|
-
case 'delete':
|
|
1207
|
-
if (!op.id) throw new Error('ID required for delete');
|
|
1208
|
-
result = await this.delete(op.id);
|
|
1209
|
-
break;
|
|
1210
|
-
}
|
|
1211
|
-
results.push(result);
|
|
1212
|
-
}
|
|
1213
|
-
|
|
1214
|
-
return results;
|
|
1215
|
-
});
|
|
1216
|
-
}
|
|
1217
|
-
|
|
1218
|
-
// UTILITIES
|
|
1219
|
-
|
|
1220
|
-
async validate(data: unknown): Promise<{ success: boolean; data?: T; errors?: z.ZodError }> {
|
|
1221
|
-
try {
|
|
1222
|
-
const result = this.schema.parse(data);
|
|
1223
|
-
return { success: true, data: result };
|
|
1224
|
-
} catch (error) {
|
|
1225
|
-
if (error instanceof Error && 'issues' in error) {
|
|
1226
|
-
return { success: false, errors: error as z.ZodError };
|
|
1227
|
-
}
|
|
1228
|
-
return { success: false, errors: undefined };
|
|
1229
|
-
}
|
|
1230
|
-
}
|
|
1231
|
-
|
|
1232
|
-
getAdapterId(): string {
|
|
1233
|
-
if (this.adapterCache) {
|
|
1234
|
-
return this.adapterCache.id;
|
|
1235
|
-
}
|
|
1236
|
-
return this.descriptor.defaultAdapter || this.descriptor.allowedAdapters[0] || '';
|
|
1237
|
-
}
|
|
1238
|
-
|
|
1239
|
-
async close(): Promise<void> {
|
|
1240
|
-
// Database connection is managed by the adapter
|
|
1241
|
-
this.initialized = false;
|
|
1242
|
-
}
|
|
1243
|
-
|
|
1244
|
-
// PRIVATE HELPERS
|
|
1245
|
-
|
|
1246
|
-
private async ensureInitialized(): Promise<void> {
|
|
1247
|
-
if (!this.initialized) {
|
|
1248
|
-
await this.initialize();
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1252
|
-
private generateId(): string {
|
|
1253
|
-
const strategy =
|
|
1254
|
-
typeof this.descriptor.autoId === 'object' ? this.descriptor.autoId.strategy : 'uuid';
|
|
1255
|
-
|
|
1256
|
-
if (strategy === 'uuid') {
|
|
1257
|
-
return crypto.randomUUID();
|
|
1258
|
-
} else if (strategy === 'nanoid') {
|
|
1259
|
-
// Simple nanoid implementation
|
|
1260
|
-
const alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
|
1261
|
-
let id = '';
|
|
1262
|
-
for (let i = 0; i < 21; i++) {
|
|
1263
|
-
id += alphabet[Math.floor(Math.random() * alphabet.length)];
|
|
1264
|
-
}
|
|
1265
|
-
return id;
|
|
1266
|
-
} else if (strategy === 'custom' && typeof this.descriptor.autoId === 'object') {
|
|
1267
|
-
if (this.descriptor.autoId.generator) {
|
|
1268
|
-
return (this.descriptor.autoId.generator as Function)();
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
|
-
return crypto.randomUUID();
|
|
1273
|
-
}
|
|
1274
|
-
|
|
1275
|
-
private buildWhereClause(where: WhereFilter<T>): { clause: string; values: unknown[] } {
|
|
1276
|
-
const conditions: string[] = [];
|
|
1277
|
-
const values: unknown[] = [];
|
|
1278
|
-
|
|
1279
|
-
for (const [field, condition] of Object.entries(where)) {
|
|
1280
|
-
if (typeof condition === 'object' && condition !== null) {
|
|
1281
|
-
// Complex condition
|
|
1282
|
-
const cond = condition as Record<string, unknown>;
|
|
1283
|
-
|
|
1284
|
-
if ('eq' in cond) {
|
|
1285
|
-
conditions.push(`json_extract(data, '$.${field}') = ?`);
|
|
1286
|
-
values.push(cond.eq);
|
|
1287
|
-
}
|
|
1288
|
-
if ('ne' in cond) {
|
|
1289
|
-
conditions.push(`json_extract(data, '$.${field}') != ?`);
|
|
1290
|
-
values.push(cond.ne);
|
|
1291
|
-
}
|
|
1292
|
-
if ('gt' in cond) {
|
|
1293
|
-
conditions.push(`json_extract(data, '$.${field}') > ?`);
|
|
1294
|
-
values.push(cond.gt);
|
|
1295
|
-
}
|
|
1296
|
-
if ('gte' in cond) {
|
|
1297
|
-
conditions.push(`json_extract(data, '$.${field}') >= ?`);
|
|
1298
|
-
values.push(cond.gte);
|
|
1299
|
-
}
|
|
1300
|
-
if ('lt' in cond) {
|
|
1301
|
-
conditions.push(`json_extract(data, '$.${field}') < ?`);
|
|
1302
|
-
values.push(cond.lt);
|
|
1303
|
-
}
|
|
1304
|
-
if ('lte' in cond) {
|
|
1305
|
-
conditions.push(`json_extract(data, '$.${field}') <= ?`);
|
|
1306
|
-
values.push(cond.lte);
|
|
1307
|
-
}
|
|
1308
|
-
if ('in' in cond && Array.isArray(cond.in)) {
|
|
1309
|
-
const placeholders = cond.in.map(() => '?').join(', ');
|
|
1310
|
-
conditions.push(`json_extract(data, '$.${field}') IN (${placeholders})`);
|
|
1311
|
-
values.push(...cond.in);
|
|
1312
|
-
}
|
|
1313
|
-
if ('like' in cond) {
|
|
1314
|
-
conditions.push(`json_extract(data, '$.${field}') LIKE ?`);
|
|
1315
|
-
values.push(cond.like);
|
|
1316
|
-
}
|
|
1317
|
-
if ('isNull' in cond) {
|
|
1318
|
-
if (cond.isNull) {
|
|
1319
|
-
conditions.push(`json_extract(data, '$.${field}') IS NULL`);
|
|
1320
|
-
} else {
|
|
1321
|
-
conditions.push(`json_extract(data, '$.${field}') IS NOT NULL`);
|
|
1322
|
-
}
|
|
1323
|
-
}
|
|
1324
|
-
} else {
|
|
1325
|
-
// Simple equality
|
|
1326
|
-
conditions.push(`json_extract(data, '$.${field}') = ?`);
|
|
1327
|
-
values.push(condition);
|
|
1328
|
-
}
|
|
1329
|
-
}
|
|
1330
|
-
|
|
1331
|
-
return {
|
|
1332
|
-
clause: conditions.join(' AND '),
|
|
1333
|
-
values
|
|
1334
|
-
};
|
|
1335
|
-
}
|
|
1336
|
-
|
|
1337
|
-
private buildOrderBy(orderBy: OrderBy<T>): string {
|
|
1338
|
-
if (Array.isArray(orderBy)) {
|
|
1339
|
-
return orderBy
|
|
1340
|
-
.map((o) => `json_extract(data, '$.${String(o.field)}') ${o.direction}`)
|
|
1341
|
-
.join(', ');
|
|
1342
|
-
} else {
|
|
1343
|
-
const fields = Object.entries(orderBy).map(([field, direction]) => {
|
|
1344
|
-
return `json_extract(data, '$.${field}') ${direction}`;
|
|
1345
|
-
});
|
|
1346
|
-
return fields.join(', ');
|
|
1347
|
-
}
|
|
1348
|
-
}
|
|
1349
|
-
|
|
1350
|
-
private async loadRelations(record: T, include: IncludeRelations): Promise<T> {
|
|
1351
|
-
if (!include || Object.keys(this.relations).length === 0) {
|
|
1352
|
-
return record;
|
|
1353
|
-
}
|
|
1354
|
-
|
|
1355
|
-
const relationNames = Array.isArray(include) ? include : Object.keys(include);
|
|
1356
|
-
|
|
1357
|
-
for (const relationName of relationNames) {
|
|
1358
|
-
const relation = this.relations[relationName as string];
|
|
1359
|
-
if (!relation) continue;
|
|
1360
|
-
|
|
1361
|
-
const related = await this.loadRelation(record, relation);
|
|
1362
|
-
this.asMutableRecord(record)[relationName] = related;
|
|
1363
|
-
}
|
|
1364
|
-
|
|
1365
|
-
return record;
|
|
1366
|
-
}
|
|
1367
|
-
|
|
1368
|
-
private async loadRelation(record: T, relation: StorageRelation): Promise<unknown> {
|
|
1369
|
-
// For now, we'll implement basic relation loading
|
|
1370
|
-
// This would be enhanced with proper relation resolution
|
|
1371
|
-
|
|
1372
|
-
switch (relation.type) {
|
|
1373
|
-
case 'belongs_to': {
|
|
1374
|
-
const foreignKey = relation.foreignKey;
|
|
1375
|
-
if (!foreignKey) return null;
|
|
1376
|
-
const foreignId = this.readStringField(record, foreignKey);
|
|
1377
|
-
if (!foreignId) return null;
|
|
1378
|
-
|
|
1379
|
-
// Resolving belongs_to requires runtime access to the target storage; unimplemented.
|
|
1380
|
-
return null;
|
|
1381
|
-
}
|
|
1382
|
-
|
|
1383
|
-
case 'has_many': {
|
|
1384
|
-
// Resolving has_many requires runtime access to the target storage; unimplemented.
|
|
1385
|
-
return [];
|
|
1386
|
-
}
|
|
1387
|
-
|
|
1388
|
-
case 'has_one': {
|
|
1389
|
-
// Resolving has_one requires runtime access to the target storage; unimplemented.
|
|
1390
|
-
return null;
|
|
1391
|
-
}
|
|
1392
|
-
|
|
1393
|
-
case 'many_to_many': {
|
|
1394
|
-
// Implement many-to-many through junction table
|
|
1395
|
-
return await this.loadManyToManyRelation(record, relation);
|
|
1396
|
-
}
|
|
1397
|
-
|
|
1398
|
-
default:
|
|
1399
|
-
return null;
|
|
1400
|
-
}
|
|
1401
|
-
}
|
|
1402
|
-
|
|
1403
|
-
/**
|
|
1404
|
-
* Load many-to-many relation through junction table
|
|
1405
|
-
*/
|
|
1406
|
-
private async loadManyToManyRelation(record: T, relation: StorageRelation): Promise<unknown[]> {
|
|
1407
|
-
if (!relation.through) {
|
|
1408
|
-
logger.warn(`Many-to-many relation '${relation.as || 'unknown'}' has no 'through' property`);
|
|
1409
|
-
return [];
|
|
1410
|
-
}
|
|
1411
|
-
|
|
1412
|
-
try {
|
|
1413
|
-
const runtime = getVibesRuntime();
|
|
1414
|
-
if (!runtime) {
|
|
1415
|
-
logger.warn('Runtime not available for relation loading');
|
|
1416
|
-
return [];
|
|
1417
|
-
}
|
|
1418
|
-
|
|
1419
|
-
// Resolve the junction table storage interface
|
|
1420
|
-
const junctionStorage = await runtime
|
|
1421
|
-
.query<StorageRecordDescriptor, StorageRecordInterface<Record<string, unknown>>>(
|
|
1422
|
-
'storage/record'
|
|
1423
|
-
)
|
|
1424
|
-
.withId(relation.through)
|
|
1425
|
-
.enabled()
|
|
1426
|
-
.resolve()
|
|
1427
|
-
.catch((error: unknown) => {
|
|
1428
|
-
logger.warn(
|
|
1429
|
-
`Failed to resolve junction table '${relation.through}':`,
|
|
1430
|
-
toErrorContext(error)
|
|
1431
|
-
);
|
|
1432
|
-
return null;
|
|
1433
|
-
});
|
|
1434
|
-
if (!junctionStorage) {
|
|
1435
|
-
return [];
|
|
1436
|
-
}
|
|
1437
|
-
|
|
1438
|
-
// Resolve the target table storage interface
|
|
1439
|
-
const targetStorage = await runtime
|
|
1440
|
-
.query<StorageRecordDescriptor, StorageRecordInterface<Record<string, unknown>>>(
|
|
1441
|
-
'storage/record'
|
|
1442
|
-
)
|
|
1443
|
-
.withId(relation.target)
|
|
1444
|
-
.enabled()
|
|
1445
|
-
.resolve()
|
|
1446
|
-
.catch((error: unknown) => {
|
|
1447
|
-
logger.warn(
|
|
1448
|
-
`Failed to resolve target table '${relation.target}':`,
|
|
1449
|
-
toErrorContext(error)
|
|
1450
|
-
);
|
|
1451
|
-
return null;
|
|
1452
|
-
});
|
|
1453
|
-
if (!targetStorage) {
|
|
1454
|
-
return [];
|
|
1455
|
-
}
|
|
1456
|
-
|
|
1457
|
-
// Get the primary key for this record
|
|
1458
|
-
const thisPrimaryKey = this.readStringField(record, this.primaryKey);
|
|
1459
|
-
if (!thisPrimaryKey) {
|
|
1460
|
-
return [];
|
|
1461
|
-
}
|
|
1462
|
-
|
|
1463
|
-
const junctionTable = this.quoteIdentifier(junctionStorage.tableName);
|
|
1464
|
-
const thisFkColumn = await this.findJunctionForeignKeyColumn(
|
|
1465
|
-
junctionStorage,
|
|
1466
|
-
thisPrimaryKey,
|
|
1467
|
-
junctionTable
|
|
1468
|
-
);
|
|
1469
|
-
if (!thisFkColumn) {
|
|
1470
|
-
return [];
|
|
1471
|
-
}
|
|
1472
|
-
|
|
1473
|
-
// Query junction rows by this record id
|
|
1474
|
-
const junctionResults = await junctionStorage.raw<Record<string, unknown>>(
|
|
1475
|
-
`SELECT * FROM ${junctionTable} WHERE ${this.quoteIdentifier(thisFkColumn)} = ?`,
|
|
1476
|
-
thisPrimaryKey
|
|
1477
|
-
);
|
|
1478
|
-
if (junctionResults.length === 0) {
|
|
1479
|
-
return [];
|
|
1480
|
-
}
|
|
1481
|
-
|
|
1482
|
-
// Extract target foreign keys from junction results
|
|
1483
|
-
const targetIds = this.extractJunctionTargetIds(
|
|
1484
|
-
junctionResults,
|
|
1485
|
-
thisFkColumn,
|
|
1486
|
-
targetStorage.primaryKey
|
|
1487
|
-
);
|
|
1488
|
-
|
|
1489
|
-
if (targetIds.length === 0) {
|
|
1490
|
-
return [];
|
|
1491
|
-
}
|
|
1492
|
-
|
|
1493
|
-
return await targetStorage.getMany(targetIds);
|
|
1494
|
-
} catch (error) {
|
|
1495
|
-
logger.error(`Error loading many-to-many relation: ${error}`);
|
|
1496
|
-
return [];
|
|
1497
|
-
}
|
|
1498
|
-
}
|
|
1499
|
-
|
|
1500
|
-
/**
|
|
1501
|
-
* Find a junction table column that stores this record's primary key.
|
|
1502
|
-
*/
|
|
1503
|
-
private async findJunctionForeignKeyColumn(
|
|
1504
|
-
junctionStorage: StorageRecordInterface<Record<string, unknown>>,
|
|
1505
|
-
recordId: string,
|
|
1506
|
-
quotedJunctionTable: string
|
|
1507
|
-
): Promise<string | null> {
|
|
1508
|
-
let tableInfo: Array<{ name: string }>;
|
|
1509
|
-
try {
|
|
1510
|
-
tableInfo = await junctionStorage.raw<{ name: string }>(
|
|
1511
|
-
`PRAGMA table_info(${quotedJunctionTable})`
|
|
1512
|
-
);
|
|
1513
|
-
} catch {
|
|
1514
|
-
return null;
|
|
1515
|
-
}
|
|
1516
|
-
|
|
1517
|
-
const candidateColumns = tableInfo
|
|
1518
|
-
.map((column) => column.name)
|
|
1519
|
-
.filter((name) => this.isLikelyIdColumn(name))
|
|
1520
|
-
.filter((name) => name !== 'id' && name !== junctionStorage.primaryKey)
|
|
1521
|
-
.filter((name) => name !== 'data');
|
|
1522
|
-
|
|
1523
|
-
for (const column of candidateColumns) {
|
|
1524
|
-
const rows = await junctionStorage.raw<{ count: number }>(
|
|
1525
|
-
`SELECT COUNT(*) as count FROM ${quotedJunctionTable} WHERE ${this.quoteIdentifier(column)} = ?`,
|
|
1526
|
-
recordId
|
|
1527
|
-
);
|
|
1528
|
-
if ((rows[0]?.count ?? 0) > 0) {
|
|
1529
|
-
return column;
|
|
1530
|
-
}
|
|
1531
|
-
}
|
|
1532
|
-
|
|
1533
|
-
return null;
|
|
1534
|
-
}
|
|
1535
|
-
|
|
1536
|
-
/**
|
|
1537
|
-
* Extract target IDs from junction rows.
|
|
1538
|
-
*/
|
|
1539
|
-
private extractJunctionTargetIds(
|
|
1540
|
-
junctionRows: Array<Record<string, unknown>>,
|
|
1541
|
-
thisFkColumn: string,
|
|
1542
|
-
targetPrimaryKey: string
|
|
1543
|
-
): string[] {
|
|
1544
|
-
const targetIds = new Set<string>();
|
|
1545
|
-
|
|
1546
|
-
for (const row of junctionRows) {
|
|
1547
|
-
for (const [field, value] of Object.entries(row)) {
|
|
1548
|
-
if (field === thisFkColumn || field === targetPrimaryKey) {
|
|
1549
|
-
continue;
|
|
1550
|
-
}
|
|
1551
|
-
if (!this.isLikelyIdColumn(field) || typeof value !== 'string') {
|
|
1552
|
-
continue;
|
|
1553
|
-
}
|
|
1554
|
-
if (value.length > 0) {
|
|
1555
|
-
targetIds.add(value);
|
|
1556
|
-
}
|
|
1557
|
-
}
|
|
1558
|
-
}
|
|
1559
|
-
|
|
1560
|
-
return [...targetIds];
|
|
1561
|
-
}
|
|
1562
|
-
|
|
1563
|
-
/**
|
|
1564
|
-
* True when a field name is likely an identifier / foreign key field.
|
|
1565
|
-
*/
|
|
1566
|
-
private isLikelyIdColumn(name: string): boolean {
|
|
1567
|
-
const lower = name.toLowerCase();
|
|
1568
|
-
return (
|
|
1569
|
-
lower === 'id' ||
|
|
1570
|
-
lower === 'data' ||
|
|
1571
|
-
/(^|[._])id$/i.test(name) ||
|
|
1572
|
-
/_id$/.test(lower) ||
|
|
1573
|
-
/Id$/.test(name)
|
|
1574
|
-
);
|
|
1575
|
-
}
|
|
1576
|
-
|
|
1577
|
-
/**
|
|
1578
|
-
* Escape SQL identifier safely for query fragments.
|
|
1579
|
-
*/
|
|
1580
|
-
private quoteIdentifier(name: string): string {
|
|
1581
|
-
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) {
|
|
1582
|
-
throw new Error(`Invalid SQL identifier: ${name}`);
|
|
1583
|
-
}
|
|
1584
|
-
return `"${name}"`;
|
|
1585
|
-
}
|
|
1586
|
-
|
|
1587
|
-
// FULL-TEXT SEARCH
|
|
1588
|
-
|
|
1589
|
-
async search(
|
|
1590
|
-
query: string,
|
|
1591
|
-
options?: import('../interfaces/record').SearchOptions<T, string & keyof this['relations']>
|
|
1592
|
-
): Promise<import('../interfaces/record').SearchResult<T>> {
|
|
1593
|
-
await this.ensureInitialized();
|
|
1594
|
-
|
|
1595
|
-
if (!this.descriptor.fts) {
|
|
1596
|
-
throw new Error(`FTS is not configured for ${this.tableName}`);
|
|
1597
|
-
}
|
|
1598
|
-
|
|
1599
|
-
const ftsTable = this.descriptor.fts.tableName || `${this.tableName}_fts`;
|
|
1600
|
-
const ftsFields = this.descriptor.fts.fields;
|
|
1601
|
-
|
|
1602
|
-
// Split into words and AND them for multi-word queries.
|
|
1603
|
-
// Each word is quoted to escape FTS5 special characters.
|
|
1604
|
-
const words = query.split(/\s+/).filter((w) => w.length > 0);
|
|
1605
|
-
const ftsQuery =
|
|
1606
|
-
words.length <= 1
|
|
1607
|
-
? `"${query.replace(/"/g, '""')}"`
|
|
1608
|
-
: words.map((w) => `"${w.replace(/"/g, '""')}"`).join(' AND ');
|
|
1609
|
-
const params: unknown[] = [ftsQuery];
|
|
1610
|
-
|
|
1611
|
-
let sql = `
|
|
1612
|
-
SELECT
|
|
1613
|
-
${this.tableName}.${this.primaryKey},
|
|
1614
|
-
${this.tableName}.data,
|
|
1615
|
-
${ftsTable}.rank as _rank
|
|
1616
|
-
FROM ${this.tableName}
|
|
1617
|
-
JOIN ${ftsTable} ON ${ftsTable}.rowid = ${this.tableName}.rowid
|
|
1618
|
-
WHERE ${ftsTable} MATCH ?
|
|
1619
|
-
`;
|
|
1620
|
-
|
|
1621
|
-
if (options?.where) {
|
|
1622
|
-
const { clause, values } = this.buildWhereClause(options.where);
|
|
1623
|
-
if (clause) {
|
|
1624
|
-
sql += ` AND ${clause}`;
|
|
1625
|
-
params.push(...values);
|
|
1626
|
-
}
|
|
1627
|
-
}
|
|
1628
|
-
|
|
1629
|
-
if (options?.orderBy) {
|
|
1630
|
-
sql += ` ORDER BY ${this.buildOrderBy(options.orderBy)}`;
|
|
1631
|
-
} else if (options?.rankByRelevance !== false) {
|
|
1632
|
-
sql += ` ORDER BY _rank`;
|
|
1633
|
-
}
|
|
1634
|
-
|
|
1635
|
-
if (options?.limit) {
|
|
1636
|
-
sql += ` LIMIT ?`;
|
|
1637
|
-
params.push(options.limit);
|
|
1638
|
-
}
|
|
1639
|
-
if (options?.offset) {
|
|
1640
|
-
sql += ` OFFSET ?`;
|
|
1641
|
-
params.push(options.offset);
|
|
1642
|
-
}
|
|
1643
|
-
|
|
1644
|
-
const rows = this.db!.query<{ data: string; _rank: number }, any[]>(sql).all(...params);
|
|
1645
|
-
|
|
1646
|
-
const items: T[] = [];
|
|
1647
|
-
const scores: number[] = [];
|
|
1648
|
-
const highlights = new Map<string, string[]>();
|
|
1649
|
-
|
|
1650
|
-
for (const row of rows) {
|
|
1651
|
-
const record = JSON.parse(row.data) as T;
|
|
1652
|
-
items.push(record);
|
|
1653
|
-
scores.push(row._rank);
|
|
1654
|
-
|
|
1655
|
-
if (options?.highlight) {
|
|
1656
|
-
const prefix = options.highlightPrefix || '<mark>';
|
|
1657
|
-
const suffix = options.highlightSuffix || '</mark>';
|
|
1658
|
-
const id = this.readPrimaryKey(record);
|
|
1659
|
-
const fieldHighlights: string[] = [];
|
|
1660
|
-
|
|
1661
|
-
for (const field of ftsFields) {
|
|
1662
|
-
const highlightSql = `
|
|
1663
|
-
SELECT highlight(${ftsTable}, ?, ?, ?) as highlighted
|
|
1664
|
-
WHERE ${ftsTable} MATCH ? AND rowid = ?
|
|
1665
|
-
`;
|
|
1666
|
-
const fieldIndex = ftsFields.indexOf(field as string);
|
|
1667
|
-
const highlightRow = this.db!.query<{ highlighted: string }, any[]>(highlightSql).get(
|
|
1668
|
-
fieldIndex,
|
|
1669
|
-
prefix,
|
|
1670
|
-
suffix,
|
|
1671
|
-
ftsQuery,
|
|
1672
|
-
rows.indexOf(row) + 1
|
|
1673
|
-
);
|
|
1674
|
-
if (highlightRow?.highlighted) {
|
|
1675
|
-
fieldHighlights.push(highlightRow.highlighted);
|
|
1676
|
-
}
|
|
1677
|
-
}
|
|
1678
|
-
highlights.set(id, fieldHighlights);
|
|
1679
|
-
}
|
|
1680
|
-
|
|
1681
|
-
if (options?.minScore !== undefined && row._rank < options.minScore) {
|
|
1682
|
-
items.pop();
|
|
1683
|
-
scores.pop();
|
|
1684
|
-
}
|
|
1685
|
-
}
|
|
1686
|
-
|
|
1687
|
-
return {
|
|
1688
|
-
items,
|
|
1689
|
-
total: items.length,
|
|
1690
|
-
scores,
|
|
1691
|
-
highlights: highlights.size > 0 ? highlights : undefined,
|
|
1692
|
-
hasMore: options?.limit ? items.length === options.limit : false
|
|
1693
|
-
};
|
|
1694
|
-
}
|
|
1695
|
-
|
|
1696
|
-
// HIERARCHY
|
|
1697
|
-
|
|
1698
|
-
async getDescendants(
|
|
1699
|
-
id: string,
|
|
1700
|
-
options?: import('../interfaces/record').HierarchyOptions<T, string & keyof this['relations']>
|
|
1701
|
-
): Promise<import('../interfaces/record').QueryResult<T & { depth: number; path?: string[] }>> {
|
|
1702
|
-
await this.ensureInitialized();
|
|
1703
|
-
|
|
1704
|
-
if (!this.descriptor.hierarchy) {
|
|
1705
|
-
throw new Error(`Hierarchy is not configured for ${this.tableName}`);
|
|
1706
|
-
}
|
|
1707
|
-
|
|
1708
|
-
const parentField = this.descriptor.hierarchy.parentField;
|
|
1709
|
-
const maxDepth = options?.maxDepth || 1000;
|
|
1710
|
-
const includePath = options?.includePath !== false;
|
|
1711
|
-
|
|
1712
|
-
const sql = `
|
|
1713
|
-
WITH RECURSIVE hierarchy AS (
|
|
1714
|
-
SELECT
|
|
1715
|
-
*,
|
|
1716
|
-
0 as depth
|
|
1717
|
-
${includePath ? `, json_array(id) as path` : ''}
|
|
1718
|
-
FROM ${this.tableName}
|
|
1719
|
-
WHERE ${this.primaryKey} = ?
|
|
1720
|
-
|
|
1721
|
-
UNION ALL
|
|
1722
|
-
|
|
1723
|
-
SELECT
|
|
1724
|
-
t.*,
|
|
1725
|
-
h.depth + 1 as depth
|
|
1726
|
-
${includePath ? `, CASE WHEN h.depth = 0 THEN json_array(t.id) ELSE json_insert(h.path, '$[#]', t.id) END as path` : ''}
|
|
1727
|
-
FROM ${this.tableName} t
|
|
1728
|
-
INNER JOIN hierarchy h ON json_extract(t.data, '$.${parentField}') = h.${this.primaryKey}
|
|
1729
|
-
WHERE h.depth < ?
|
|
1730
|
-
)
|
|
1731
|
-
SELECT * FROM hierarchy ORDER BY depth, ${this.primaryKey}
|
|
1732
|
-
`;
|
|
1733
|
-
|
|
1734
|
-
const rows = this.db!.query<{ data: string; depth: number; path?: string }, [string, number]>(
|
|
1735
|
-
sql
|
|
1736
|
-
).all(id, maxDepth);
|
|
1737
|
-
|
|
1738
|
-
const items = rows.map((row) => {
|
|
1739
|
-
const record = JSON.parse(row.data) as T & { depth: number; path?: string[] };
|
|
1740
|
-
record.depth = row.depth;
|
|
1741
|
-
if (includePath && row.path) {
|
|
1742
|
-
record.path = JSON.parse(row.path);
|
|
1743
|
-
}
|
|
1744
|
-
return record;
|
|
1745
|
-
});
|
|
1746
|
-
|
|
1747
|
-
return {
|
|
1748
|
-
items,
|
|
1749
|
-
total: items.length,
|
|
1750
|
-
hasMore: false
|
|
1751
|
-
};
|
|
1752
|
-
}
|
|
1753
|
-
|
|
1754
|
-
async getAncestors(
|
|
1755
|
-
id: string,
|
|
1756
|
-
_options?: import('../interfaces/record').QueryOptions<T, string & keyof this['relations']>
|
|
1757
|
-
): Promise<T[]> {
|
|
1758
|
-
await this.ensureInitialized();
|
|
1759
|
-
|
|
1760
|
-
if (!this.descriptor.hierarchy) {
|
|
1761
|
-
throw new Error(`Hierarchy is not configured for ${this.tableName}`);
|
|
1762
|
-
}
|
|
1763
|
-
|
|
1764
|
-
const parentField = this.descriptor.hierarchy.parentField;
|
|
1765
|
-
|
|
1766
|
-
const sql = `
|
|
1767
|
-
WITH RECURSIVE ancestors AS (
|
|
1768
|
-
SELECT *, 0 as depth FROM ${this.tableName} WHERE ${this.primaryKey} = ?
|
|
1769
|
-
|
|
1770
|
-
UNION ALL
|
|
1771
|
-
|
|
1772
|
-
SELECT t.*, a.depth + 1 as depth
|
|
1773
|
-
FROM ${this.tableName} t
|
|
1774
|
-
INNER JOIN ancestors a ON json_extract(a.data, '$.${parentField}') = t.${this.primaryKey}
|
|
1775
|
-
)
|
|
1776
|
-
SELECT * FROM ancestors ORDER BY depth DESC
|
|
1777
|
-
`;
|
|
1778
|
-
|
|
1779
|
-
const rows = this.db!.query<{ data: string }, [string]>(sql).all(id);
|
|
1780
|
-
|
|
1781
|
-
return rows.map((row) => JSON.parse(row.data) as T);
|
|
1782
|
-
}
|
|
1783
|
-
|
|
1784
|
-
async getTree(
|
|
1785
|
-
options?: import('../interfaces/record').HierarchyOptions<T, string & keyof this['relations']>
|
|
1786
|
-
): Promise<import('../interfaces/record').TreeNode<T>[]> {
|
|
1787
|
-
await this.ensureInitialized();
|
|
1788
|
-
|
|
1789
|
-
if (!this.descriptor.hierarchy) {
|
|
1790
|
-
throw new Error(`Hierarchy is not configured for ${this.tableName}`);
|
|
1791
|
-
}
|
|
1792
|
-
|
|
1793
|
-
const parentField = this.descriptor.hierarchy.parentField;
|
|
1794
|
-
const maxDepth = options?.maxDepth || 1000;
|
|
1795
|
-
|
|
1796
|
-
const whereClause = options?.where
|
|
1797
|
-
? this.buildWhereClause(options.where)
|
|
1798
|
-
: { clause: `json_extract(data, '$.${parentField}') IS NULL`, values: [] };
|
|
1799
|
-
|
|
1800
|
-
const sql = `
|
|
1801
|
-
WITH RECURSIVE tree AS (
|
|
1802
|
-
SELECT
|
|
1803
|
-
*,
|
|
1804
|
-
0 as depth,
|
|
1805
|
-
json_array(id) as path
|
|
1806
|
-
FROM ${this.tableName}
|
|
1807
|
-
WHERE ${whereClause.clause}
|
|
1808
|
-
|
|
1809
|
-
UNION ALL
|
|
1810
|
-
|
|
1811
|
-
SELECT
|
|
1812
|
-
t.*,
|
|
1813
|
-
tree.depth + 1 as depth,
|
|
1814
|
-
json_insert(tree.path, '$[#]', t.id) as path
|
|
1815
|
-
FROM ${this.tableName} t
|
|
1816
|
-
INNER JOIN tree ON json_extract(t.data, '$.${parentField}') = tree.${this.primaryKey}
|
|
1817
|
-
WHERE tree.depth < ?
|
|
1818
|
-
)
|
|
1819
|
-
SELECT * FROM tree ORDER BY depth, ${this.primaryKey}
|
|
1820
|
-
`;
|
|
1821
|
-
|
|
1822
|
-
const rows = this.db!.query<{ data: string; depth: number; path: string }, any[]>(sql).all(
|
|
1823
|
-
...whereClause.values,
|
|
1824
|
-
maxDepth
|
|
1825
|
-
);
|
|
1826
|
-
|
|
1827
|
-
const nodeMap = new Map<string, import('../interfaces/record').TreeNode<T>>();
|
|
1828
|
-
const rootNodes: import('../interfaces/record').TreeNode<T>[] = [];
|
|
1829
|
-
|
|
1830
|
-
for (const row of rows) {
|
|
1831
|
-
const record = JSON.parse(row.data) as T;
|
|
1832
|
-
const recordId = this.readPrimaryKey(record);
|
|
1833
|
-
const parentId = this.readStringField(record, parentField);
|
|
1834
|
-
|
|
1835
|
-
const node: import('../interfaces/record').TreeNode<T> = {
|
|
1836
|
-
record,
|
|
1837
|
-
children: [],
|
|
1838
|
-
depth: row.depth,
|
|
1839
|
-
path: JSON.parse(row.path)
|
|
1840
|
-
};
|
|
1841
|
-
|
|
1842
|
-
nodeMap.set(recordId, node);
|
|
1843
|
-
|
|
1844
|
-
if (parentId && nodeMap.has(parentId)) {
|
|
1845
|
-
nodeMap.get(parentId)!.children.push(node);
|
|
1846
|
-
} else {
|
|
1847
|
-
rootNodes.push(node);
|
|
1848
|
-
}
|
|
1849
|
-
}
|
|
1850
|
-
|
|
1851
|
-
return rootNodes;
|
|
1852
|
-
}
|
|
1853
|
-
|
|
1854
|
-
// RAW QUERIES
|
|
1855
|
-
|
|
1856
|
-
async raw<R = unknown>(sql: string, ...params: unknown[]): Promise<R[]> {
|
|
1857
|
-
await this.ensureInitialized();
|
|
1858
|
-
return this.db!.query<R, any[]>(sql).all(...params);
|
|
1859
|
-
}
|
|
1860
|
-
|
|
1861
|
-
async queryRaw<R>(options: import('../interfaces/record').RawQueryOptions<R>): Promise<R[]> {
|
|
1862
|
-
await this.ensureInitialized();
|
|
1863
|
-
|
|
1864
|
-
const rows = this.db!.query<R, any[]>(options.sql).all(...(options.params || []));
|
|
1865
|
-
|
|
1866
|
-
if (options.schema) {
|
|
1867
|
-
return rows.map((row) => options.schema!.parse(row));
|
|
1868
|
-
}
|
|
1869
|
-
|
|
1870
|
-
return rows;
|
|
1871
|
-
}
|
|
1872
|
-
}
|