@vibesdotdev/storage 0.0.1
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/README.md +75 -0
- package/SPEC.md +60 -0
- package/dist/adapters/index.d.ts +14 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +15 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/bridge/index.d.ts +3 -0
- package/dist/bridge/index.d.ts.map +1 -0
- package/dist/bridge/index.js +2 -0
- package/dist/bridge/index.js.map +1 -0
- package/dist/bridge/storage-kind-bridge.d.ts +27 -0
- package/dist/bridge/storage-kind-bridge.d.ts.map +1 -0
- package/dist/bridge/storage-kind-bridge.js +110 -0
- package/dist/bridge/storage-kind-bridge.js.map +1 -0
- package/dist/bridge/types.d.ts +45 -0
- package/dist/bridge/types.d.ts.map +1 -0
- package/dist/bridge/types.js +8 -0
- package/dist/bridge/types.js.map +1 -0
- package/dist/cli/commands/list/storage.list.cli-command.descriptor.d.ts +4 -0
- package/dist/cli/commands/list/storage.list.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/commands/list/storage.list.cli-command.descriptor.js +18 -0
- package/dist/cli/commands/list/storage.list.cli-command.descriptor.js.map +1 -0
- package/dist/cli/commands/list/storage.list.cli-command.impl.d.ts +11 -0
- package/dist/cli/commands/list/storage.list.cli-command.impl.d.ts.map +1 -0
- package/dist/cli/commands/list/storage.list.cli-command.impl.js +48 -0
- package/dist/cli/commands/list/storage.list.cli-command.impl.js.map +1 -0
- package/dist/cli/commands/sync/pull/storage.sync.pull.cli-command.descriptor.d.ts +4 -0
- package/dist/cli/commands/sync/pull/storage.sync.pull.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/commands/sync/pull/storage.sync.pull.cli-command.descriptor.js +26 -0
- package/dist/cli/commands/sync/pull/storage.sync.pull.cli-command.descriptor.js.map +1 -0
- package/dist/cli/commands/sync/pull/storage.sync.pull.cli-command.impl.d.ts +13 -0
- package/dist/cli/commands/sync/pull/storage.sync.pull.cli-command.impl.d.ts.map +1 -0
- package/dist/cli/commands/sync/pull/storage.sync.pull.cli-command.impl.js +136 -0
- package/dist/cli/commands/sync/pull/storage.sync.pull.cli-command.impl.js.map +1 -0
- package/dist/cli/commands/sync/push/storage.sync.push.cli-command.descriptor.d.ts +4 -0
- package/dist/cli/commands/sync/push/storage.sync.push.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/commands/sync/push/storage.sync.push.cli-command.descriptor.js +26 -0
- package/dist/cli/commands/sync/push/storage.sync.push.cli-command.descriptor.js.map +1 -0
- package/dist/cli/commands/sync/push/storage.sync.push.cli-command.impl.d.ts +13 -0
- package/dist/cli/commands/sync/push/storage.sync.push.cli-command.impl.d.ts.map +1 -0
- package/dist/cli/commands/sync/push/storage.sync.push.cli-command.impl.js +165 -0
- package/dist/cli/commands/sync/push/storage.sync.push.cli-command.impl.js.map +1 -0
- package/dist/cli/commands/sync/resolve/storage.sync.resolve.cli-command.descriptor.d.ts +4 -0
- package/dist/cli/commands/sync/resolve/storage.sync.resolve.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/commands/sync/resolve/storage.sync.resolve.cli-command.descriptor.js +20 -0
- package/dist/cli/commands/sync/resolve/storage.sync.resolve.cli-command.descriptor.js.map +1 -0
- package/dist/cli/commands/sync/resolve/storage.sync.resolve.cli-command.impl.d.ts +12 -0
- package/dist/cli/commands/sync/resolve/storage.sync.resolve.cli-command.impl.d.ts.map +1 -0
- package/dist/cli/commands/sync/resolve/storage.sync.resolve.cli-command.impl.js +95 -0
- package/dist/cli/commands/sync/resolve/storage.sync.resolve.cli-command.impl.js.map +1 -0
- package/dist/cli/commands/sync/status/storage.sync.status.cli-command.descriptor.d.ts +4 -0
- package/dist/cli/commands/sync/status/storage.sync.status.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/commands/sync/status/storage.sync.status.cli-command.descriptor.js +15 -0
- package/dist/cli/commands/sync/status/storage.sync.status.cli-command.descriptor.js.map +1 -0
- package/dist/cli/commands/sync/status/storage.sync.status.cli-command.impl.d.ts +13 -0
- package/dist/cli/commands/sync/status/storage.sync.status.cli-command.impl.d.ts.map +1 -0
- package/dist/cli/commands/sync/status/storage.sync.status.cli-command.impl.js +150 -0
- package/dist/cli/commands/sync/status/storage.sync.status.cli-command.impl.js.map +1 -0
- package/dist/cli/context.consumer.d.ts +26 -0
- package/dist/cli/context.consumer.d.ts.map +1 -0
- package/dist/cli/context.consumer.js +164 -0
- package/dist/cli/context.consumer.js.map +1 -0
- package/dist/cli/storage.cli-group.descriptor.d.ts +4 -0
- package/dist/cli/storage.cli-group.descriptor.d.ts.map +1 -0
- package/dist/cli/storage.cli-group.descriptor.js +11 -0
- package/dist/cli/storage.cli-group.descriptor.js.map +1 -0
- package/dist/cli/storage.sync.cli-group.descriptor.d.ts +4 -0
- package/dist/cli/storage.sync.cli-group.descriptor.d.ts.map +1 -0
- package/dist/cli/storage.sync.cli-group.descriptor.js +12 -0
- package/dist/cli/storage.sync.cli-group.descriptor.js.map +1 -0
- package/dist/cli/types.d.ts +26 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +11 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/client/index.d.ts +10 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +10 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/list-browsable-adapters.d.ts +31 -0
- package/dist/client/list-browsable-adapters.d.ts.map +1 -0
- package/dist/client/list-browsable-adapters.js +40 -0
- package/dist/client/list-browsable-adapters.js.map +1 -0
- package/dist/daemon/commands/sync.d.ts +23 -0
- package/dist/daemon/commands/sync.d.ts.map +1 -0
- package/dist/daemon/commands/sync.js +169 -0
- package/dist/daemon/commands/sync.js.map +1 -0
- package/dist/docs/adapters.docs.descriptor.d.ts +4 -0
- package/dist/docs/adapters.docs.descriptor.d.ts.map +1 -0
- package/dist/docs/adapters.docs.descriptor.js +223 -0
- package/dist/docs/adapters.docs.descriptor.js.map +1 -0
- package/dist/docs/manifests.docs.descriptor.d.ts +4 -0
- package/dist/docs/manifests.docs.descriptor.d.ts.map +1 -0
- package/dist/docs/manifests.docs.descriptor.js +316 -0
- package/dist/docs/manifests.docs.descriptor.js.map +1 -0
- package/dist/docs/records.docs.descriptor.d.ts +4 -0
- package/dist/docs/records.docs.descriptor.d.ts.map +1 -0
- package/dist/docs/records.docs.descriptor.js +269 -0
- package/dist/docs/records.docs.descriptor.js.map +1 -0
- package/dist/docs/sync.docs.descriptor.d.ts +4 -0
- package/dist/docs/sync.docs.descriptor.d.ts.map +1 -0
- package/dist/docs/sync.docs.descriptor.js +279 -0
- package/dist/docs/sync.docs.descriptor.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/adapter.d.ts +382 -0
- package/dist/interfaces/adapter.d.ts.map +1 -0
- package/dist/interfaces/adapter.js +11 -0
- package/dist/interfaces/adapter.js.map +1 -0
- package/dist/interfaces/document-store.d.ts +62 -0
- package/dist/interfaces/document-store.d.ts.map +1 -0
- package/dist/interfaces/document-store.js +8 -0
- package/dist/interfaces/document-store.js.map +1 -0
- package/dist/interfaces/index.d.ts +17 -0
- package/dist/interfaces/index.d.ts.map +1 -0
- package/dist/interfaces/index.js +24 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/interfaces/key-value.d.ts +95 -0
- package/dist/interfaces/key-value.d.ts.map +1 -0
- package/dist/interfaces/key-value.js +8 -0
- package/dist/interfaces/key-value.js.map +1 -0
- package/dist/interfaces/query-builder.d.ts +31 -0
- package/dist/interfaces/query-builder.d.ts.map +1 -0
- package/dist/interfaces/query-builder.js +11 -0
- package/dist/interfaces/query-builder.js.map +1 -0
- package/dist/interfaces/record/index.d.ts +7 -0
- package/dist/interfaces/record/index.d.ts.map +1 -0
- package/dist/interfaces/record/index.js +7 -0
- package/dist/interfaces/record/index.js.map +1 -0
- package/dist/interfaces/record/interface.d.ts +593 -0
- package/dist/interfaces/record/interface.d.ts.map +1 -0
- package/dist/interfaces/record/interface.js +49 -0
- package/dist/interfaces/record/interface.js.map +1 -0
- package/dist/interfaces/repository.d.ts +262 -0
- package/dist/interfaces/repository.d.ts.map +1 -0
- package/dist/interfaces/repository.js +8 -0
- package/dist/interfaces/repository.js.map +1 -0
- package/dist/interfaces/schema/index.d.ts +8 -0
- package/dist/interfaces/schema/index.d.ts.map +1 -0
- package/dist/interfaces/schema/index.js +10 -0
- package/dist/interfaces/schema/index.js.map +1 -0
- package/dist/interfaces/schema/schema-interface.d.ts +516 -0
- package/dist/interfaces/schema/schema-interface.d.ts.map +1 -0
- package/dist/interfaces/schema/schema-interface.js +31 -0
- package/dist/interfaces/schema/schema-interface.js.map +1 -0
- package/dist/interfaces/schema/table-interface.d.ts +250 -0
- package/dist/interfaces/schema/table-interface.d.ts.map +1 -0
- package/dist/interfaces/schema/table-interface.js +31 -0
- package/dist/interfaces/schema/table-interface.js.map +1 -0
- package/dist/interfaces/storage-consumer-fs.d.ts +40 -0
- package/dist/interfaces/storage-consumer-fs.d.ts.map +1 -0
- package/dist/interfaces/storage-consumer-fs.js +42 -0
- package/dist/interfaces/storage-consumer-fs.js.map +1 -0
- package/dist/manifest/base.d.ts +187 -0
- package/dist/manifest/base.d.ts.map +1 -0
- package/dist/manifest/base.js +516 -0
- package/dist/manifest/base.js.map +1 -0
- package/dist/manifest/cloud-sync.consumer.d.ts +7 -0
- package/dist/manifest/cloud-sync.consumer.d.ts.map +1 -0
- package/dist/manifest/cloud-sync.consumer.js +82 -0
- package/dist/manifest/cloud-sync.consumer.js.map +1 -0
- package/dist/manifest/index.d.ts +7 -0
- package/dist/manifest/index.d.ts.map +1 -0
- package/dist/manifest/index.js +7 -0
- package/dist/manifest/index.js.map +1 -0
- package/dist/manifest/source-policy.d.ts +8 -0
- package/dist/manifest/source-policy.d.ts.map +1 -0
- package/dist/manifest/source-policy.js +62 -0
- package/dist/manifest/source-policy.js.map +1 -0
- package/dist/paths.d.ts +6 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +152 -0
- package/dist/paths.js.map +1 -0
- package/dist/policy/context.d.ts +9 -0
- package/dist/policy/context.d.ts.map +1 -0
- package/dist/policy/context.js +29 -0
- package/dist/policy/context.js.map +1 -0
- package/dist/policy/index.d.ts +4 -0
- package/dist/policy/index.d.ts.map +1 -0
- package/dist/policy/index.js +4 -0
- package/dist/policy/index.js.map +1 -0
- package/dist/policy/overrides.d.ts +40 -0
- package/dist/policy/overrides.d.ts.map +1 -0
- package/dist/policy/overrides.js +37 -0
- package/dist/policy/overrides.js.map +1 -0
- package/dist/policy/persistence.d.ts +38 -0
- package/dist/policy/persistence.d.ts.map +1 -0
- package/dist/policy/persistence.js +65 -0
- package/dist/policy/persistence.js.map +1 -0
- package/dist/policy/types.d.ts +21 -0
- package/dist/policy/types.d.ts.map +1 -0
- package/dist/policy/types.js +7 -0
- package/dist/policy/types.js.map +1 -0
- package/dist/record/base.d.ts +186 -0
- package/dist/record/base.d.ts.map +1 -0
- package/dist/record/base.js +1437 -0
- package/dist/record/base.js.map +1 -0
- package/dist/record/events.d.ts +71 -0
- package/dist/record/events.d.ts.map +1 -0
- package/dist/record/events.js +52 -0
- package/dist/record/events.js.map +1 -0
- package/dist/record/extensions.d.ts +51 -0
- package/dist/record/extensions.d.ts.map +1 -0
- package/dist/record/extensions.js +222 -0
- package/dist/record/extensions.js.map +1 -0
- package/dist/record/index.d.ts +7 -0
- package/dist/record/index.d.ts.map +1 -0
- package/dist/record/index.js +7 -0
- package/dist/record/index.js.map +1 -0
- package/dist/resolver/storage-backed-resolver.d.ts +23 -0
- package/dist/resolver/storage-backed-resolver.d.ts.map +1 -0
- package/dist/resolver/storage-backed-resolver.js +187 -0
- package/dist/resolver/storage-backed-resolver.js.map +1 -0
- package/dist/schemas/adapter-descriptor.d.ts +108 -0
- package/dist/schemas/adapter-descriptor.d.ts.map +1 -0
- package/dist/schemas/adapter-descriptor.js +101 -0
- package/dist/schemas/adapter-descriptor.js.map +1 -0
- package/dist/schemas/index.d.ts +14 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +12 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/manifest-descriptor.d.ts +110 -0
- package/dist/schemas/manifest-descriptor.d.ts.map +1 -0
- package/dist/schemas/manifest-descriptor.js +114 -0
- package/dist/schemas/manifest-descriptor.js.map +1 -0
- package/dist/schemas/record/descriptor.d.ts +570 -0
- package/dist/schemas/record/descriptor.d.ts.map +1 -0
- package/dist/schemas/record/descriptor.js +389 -0
- package/dist/schemas/record/descriptor.js.map +1 -0
- package/dist/schemas/record/index.d.ts +8 -0
- package/dist/schemas/record/index.d.ts.map +1 -0
- package/dist/schemas/record/index.js +7 -0
- package/dist/schemas/record/index.js.map +1 -0
- package/dist/schemas/record/relation.d.ts +36 -0
- package/dist/schemas/record/relation.d.ts.map +1 -0
- package/dist/schemas/record/relation.js +37 -0
- package/dist/schemas/record/relation.js.map +1 -0
- package/dist/schemas/schema/descriptor.d.ts +231 -0
- package/dist/schemas/schema/descriptor.d.ts.map +1 -0
- package/dist/schemas/schema/descriptor.js +205 -0
- package/dist/schemas/schema/descriptor.js.map +1 -0
- package/dist/schemas/schema/index.d.ts +7 -0
- package/dist/schemas/schema/index.d.ts.map +1 -0
- package/dist/schemas/schema/index.js +7 -0
- package/dist/schemas/schema/index.js.map +1 -0
- package/dist/schemas/sync-bridge-descriptor.d.ts +124 -0
- package/dist/schemas/sync-bridge-descriptor.d.ts.map +1 -0
- package/dist/schemas/sync-bridge-descriptor.js +67 -0
- package/dist/schemas/sync-bridge-descriptor.js.map +1 -0
- package/dist/server/manifest-route.d.ts +92 -0
- package/dist/server/manifest-route.d.ts.map +1 -0
- package/dist/server/manifest-route.js +226 -0
- package/dist/server/manifest-route.js.map +1 -0
- package/dist/storage-policy.context.descriptor.d.ts +16 -0
- package/dist/storage-policy.context.descriptor.d.ts.map +1 -0
- package/dist/storage-policy.context.descriptor.js +16 -0
- package/dist/storage-policy.context.descriptor.js.map +1 -0
- package/dist/storage-policy.context.server.d.ts +14 -0
- package/dist/storage-policy.context.server.d.ts.map +1 -0
- package/dist/storage-policy.context.server.js +27 -0
- package/dist/storage-policy.context.server.js.map +1 -0
- package/dist/storage.plugin.d.ts +38 -0
- package/dist/storage.plugin.d.ts.map +1 -0
- package/dist/storage.plugin.js +204 -0
- package/dist/storage.plugin.js.map +1 -0
- package/dist/sync/cloud-pull.d.ts +15 -0
- package/dist/sync/cloud-pull.d.ts.map +1 -0
- package/dist/sync/cloud-pull.js +130 -0
- package/dist/sync/cloud-pull.js.map +1 -0
- package/dist/sync/cloud-record-crud-config.d.ts +19 -0
- package/dist/sync/cloud-record-crud-config.d.ts.map +1 -0
- package/dist/sync/cloud-record-crud-config.js +22 -0
- package/dist/sync/cloud-record-crud-config.js.map +1 -0
- package/dist/sync/record-sync-bridge.d.ts +5 -0
- package/dist/sync/record-sync-bridge.d.ts.map +1 -0
- package/dist/sync/record-sync-bridge.js +121 -0
- package/dist/sync/record-sync-bridge.js.map +1 -0
- package/dist/sync/resolve-sync-target.d.ts +23 -0
- package/dist/sync/resolve-sync-target.d.ts.map +1 -0
- package/dist/sync/resolve-sync-target.js +45 -0
- package/dist/sync/resolve-sync-target.js.map +1 -0
- package/dist/sync/schemas/cloud-pull.d.ts +25 -0
- package/dist/sync/schemas/cloud-pull.d.ts.map +1 -0
- package/dist/sync/schemas/cloud-pull.js +7 -0
- package/dist/sync/schemas/cloud-pull.js.map +1 -0
- package/dist/sync/schemas/index.d.ts +9 -0
- package/dist/sync/schemas/index.d.ts.map +1 -0
- package/dist/sync/schemas/index.js +9 -0
- package/dist/sync/schemas/index.js.map +1 -0
- package/dist/sync/schemas/sync-helpers.d.ts +17 -0
- package/dist/sync/schemas/sync-helpers.d.ts.map +1 -0
- package/dist/sync/schemas/sync-helpers.js +7 -0
- package/dist/sync/schemas/sync-helpers.js.map +1 -0
- package/dist/sync/schemas/sync-state.d.ts +65 -0
- package/dist/sync/schemas/sync-state.d.ts.map +1 -0
- package/dist/sync/schemas/sync-state.js +32 -0
- package/dist/sync/schemas/sync-state.js.map +1 -0
- package/dist/sync/sync-bridge.d.ts +80 -0
- package/dist/sync/sync-bridge.d.ts.map +1 -0
- package/dist/sync/sync-bridge.js +617 -0
- package/dist/sync/sync-bridge.js.map +1 -0
- package/dist/sync/sync-manifest.d.ts +20 -0
- package/dist/sync/sync-manifest.d.ts.map +1 -0
- package/dist/sync/sync-manifest.js +140 -0
- package/dist/sync/sync-manifest.js.map +1 -0
- package/dist/sync/sync-state.consumer.d.ts +23 -0
- package/dist/sync/sync-state.consumer.d.ts.map +1 -0
- package/dist/sync/sync-state.consumer.js +111 -0
- package/dist/sync/sync-state.consumer.js.map +1 -0
- package/dist/transform/index.d.ts +75 -0
- package/dist/transform/index.d.ts.map +1 -0
- package/dist/transform/index.js +81 -0
- package/dist/transform/index.js.map +1 -0
- package/dist/transform/transform-descriptor.d.ts +51 -0
- package/dist/transform/transform-descriptor.d.ts.map +1 -0
- package/dist/transform/transform-descriptor.js +30 -0
- package/dist/transform/transform-descriptor.js.map +1 -0
- package/dist/tui/storage-explorer.descriptor.d.ts +14 -0
- package/dist/tui/storage-explorer.descriptor.d.ts.map +1 -0
- package/dist/tui/storage-explorer.descriptor.js +29 -0
- package/dist/tui/storage-explorer.descriptor.js.map +1 -0
- package/dist/tui/storage-explorer.impl.consumer.d.ts +11 -0
- package/dist/tui/storage-explorer.impl.consumer.d.ts.map +1 -0
- package/dist/tui/storage-explorer.impl.consumer.js +13 -0
- package/dist/tui/storage-explorer.impl.consumer.js.map +1 -0
- package/dist/tui/storage-open.descriptor.d.ts +14 -0
- package/dist/tui/storage-open.descriptor.d.ts.map +1 -0
- package/dist/tui/storage-open.descriptor.js +28 -0
- package/dist/tui/storage-open.descriptor.js.map +1 -0
- package/dist/tui/storage-open.impl.consumer.d.ts +11 -0
- package/dist/tui/storage-open.impl.consumer.d.ts.map +1 -0
- package/dist/tui/storage-open.impl.consumer.js +13 -0
- package/dist/tui/storage-open.impl.consumer.js.map +1 -0
- package/dist/utils/error-context.d.ts +2 -0
- package/dist/utils/error-context.d.ts.map +1 -0
- package/dist/utils/error-context.js +17 -0
- package/dist/utils/error-context.js.map +1 -0
- package/package.json +241 -0
- package/src/adapters/index.ts +13 -0
- package/src/bridge/index.ts +2 -0
- package/src/bridge/storage-kind-bridge.ts +131 -0
- package/src/bridge/types.ts +46 -0
- package/src/cli/commands/list/storage.list.cli-command.descriptor.ts +20 -0
- package/src/cli/commands/list/storage.list.cli-command.impl.ts +72 -0
- package/src/cli/commands/sync/pull/storage.sync.pull.cli-command.descriptor.ts +28 -0
- package/src/cli/commands/sync/pull/storage.sync.pull.cli-command.impl.ts +171 -0
- package/src/cli/commands/sync/push/storage.sync.push.cli-command.descriptor.ts +28 -0
- package/src/cli/commands/sync/push/storage.sync.push.cli-command.impl.ts +213 -0
- package/src/cli/commands/sync/resolve/storage.sync.resolve.cli-command.descriptor.ts +22 -0
- package/src/cli/commands/sync/resolve/storage.sync.resolve.cli-command.impl.ts +129 -0
- package/src/cli/commands/sync/status/storage.sync.status.cli-command.descriptor.ts +17 -0
- package/src/cli/commands/sync/status/storage.sync.status.cli-command.impl.ts +192 -0
- package/src/cli/context.consumer.ts +195 -0
- package/src/cli/storage.cli-group.descriptor.ts +13 -0
- package/src/cli/storage.sync.cli-group.descriptor.ts +14 -0
- package/src/cli/types.ts +25 -0
- package/src/client/index.ts +10 -0
- package/src/client/list-browsable-adapters.ts +42 -0
- package/src/daemon/commands/sync.ts +225 -0
- package/src/docs/adapters.docs.descriptor.ts +225 -0
- package/src/docs/manifests.docs.descriptor.ts +318 -0
- package/src/docs/records.docs.descriptor.ts +271 -0
- package/src/docs/sync.docs.descriptor.ts +281 -0
- package/src/index.ts +109 -0
- package/src/interfaces/adapter.ts +451 -0
- package/src/interfaces/document-store.ts +74 -0
- package/src/interfaces/index.ts +117 -0
- package/src/interfaces/key-value.ts +112 -0
- package/src/interfaces/query-builder.ts +31 -0
- package/src/interfaces/record/index.ts +58 -0
- package/src/interfaces/record/interface.ts +723 -0
- package/src/interfaces/repository.ts +300 -0
- package/src/interfaces/schema/index.ts +37 -0
- package/src/interfaces/schema/schema-interface.ts +586 -0
- package/src/interfaces/schema/table-interface.ts +314 -0
- package/src/interfaces/storage-consumer-fs.ts +66 -0
- package/src/manifest/base.ts +594 -0
- package/src/manifest/cloud-sync.consumer.ts +120 -0
- package/src/manifest/index.ts +7 -0
- package/src/manifest/source-policy.ts +74 -0
- package/src/paths.ts +171 -0
- package/src/policy/context.ts +30 -0
- package/src/policy/index.ts +20 -0
- package/src/policy/overrides.ts +46 -0
- package/src/policy/persistence.ts +117 -0
- package/src/policy/types.ts +28 -0
- package/src/record/base.ts +1872 -0
- package/src/record/events.ts +56 -0
- package/src/record/extensions.ts +308 -0
- package/src/record/index.ts +7 -0
- package/src/resolver/storage-backed-resolver.ts +255 -0
- package/src/schemas/adapter-descriptor.ts +128 -0
- package/src/schemas/index.ts +104 -0
- package/src/schemas/manifest-descriptor.ts +143 -0
- package/src/schemas/record/descriptor.ts +621 -0
- package/src/schemas/record/index.ts +60 -0
- package/src/schemas/record/relation.ts +49 -0
- package/src/schemas/schema/descriptor.ts +278 -0
- package/src/schemas/schema/index.ts +14 -0
- package/src/schemas/sync-bridge-descriptor.ts +143 -0
- package/src/server/manifest-route.ts +319 -0
- package/src/storage-policy.context.descriptor.ts +17 -0
- package/src/storage-policy.context.server.ts +34 -0
- package/src/storage.plugin.ts +264 -0
- package/src/sync/cloud-pull.ts +202 -0
- package/src/sync/cloud-record-crud-config.ts +41 -0
- package/src/sync/record-sync-bridge.ts +183 -0
- package/src/sync/resolve-sync-target.ts +57 -0
- package/src/sync/schemas/cloud-pull.ts +26 -0
- package/src/sync/schemas/index.ts +18 -0
- package/src/sync/schemas/sync-helpers.ts +18 -0
- package/src/sync/schemas/sync-state.ts +41 -0
- package/src/sync/sync-bridge.ts +763 -0
- package/src/sync/sync-manifest.ts +212 -0
- package/src/sync/sync-state.consumer.ts +144 -0
- package/src/transform/index.ts +130 -0
- package/src/transform/transform-descriptor.ts +53 -0
- package/src/tui/storage-explorer.descriptor.ts +32 -0
- package/src/tui/storage-explorer.impl.consumer.ts +14 -0
- package/src/tui/storage-open.descriptor.ts +31 -0
- package/src/tui/storage-open.impl.consumer.ts +14 -0
- package/src/utils/error-context.ts +19 -0
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import type { DocsTopicDescriptor } from '@vibesdotdev/docs';
|
|
2
|
+
|
|
3
|
+
const descriptor: DocsTopicDescriptor = {
|
|
4
|
+
kind: 'docs/topic',
|
|
5
|
+
id: 'storage.manifests',
|
|
6
|
+
title: 'Storage Manifests',
|
|
7
|
+
summary: 'Manifest declarations, allowed adapters, and namespace organization',
|
|
8
|
+
body: {
|
|
9
|
+
type: 'markdown',
|
|
10
|
+
sourceType: 'raw',
|
|
11
|
+
source: `---
|
|
12
|
+
title: Storage Manifests
|
|
13
|
+
summary: Manifest declarations, allowed adapters, and namespace organization
|
|
14
|
+
tags: [storage, manifests, declarations, adapters, namespaces]
|
|
15
|
+
parent: storage
|
|
16
|
+
order: 4
|
|
17
|
+
surfaces: [cli, web, in-app]
|
|
18
|
+
hardware: [consumer, cloud]
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
# Storage Manifests
|
|
22
|
+
|
|
23
|
+
Manifests declare the structure and storage requirements for a data type. The \`storage/manifest\` runtime kind defines what data to store, which adapters are allowed, and how the data is organized.
|
|
24
|
+
|
|
25
|
+
## Manifest Structure
|
|
26
|
+
|
|
27
|
+
\`\`\`ts
|
|
28
|
+
interface StorageManifestDescriptor {
|
|
29
|
+
kind: 'storage/manifest';
|
|
30
|
+
id: string; // unique identifier
|
|
31
|
+
namespace: string; // organizational namespace
|
|
32
|
+
schema: ZodSchema; // data validation schema
|
|
33
|
+
allowedAdapters?: string[]; // allowed adapter IDs
|
|
34
|
+
adapterConfig?: {
|
|
35
|
+
[adapterId: string]: {
|
|
36
|
+
[key: string]: unknown;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
context?: {
|
|
40
|
+
hardware?: ('consumer' | 'cloud')[];
|
|
41
|
+
environment?: string[];
|
|
42
|
+
};
|
|
43
|
+
enabled?: boolean;
|
|
44
|
+
}
|
|
45
|
+
\`\`\`
|
|
46
|
+
|
|
47
|
+
## Defining a Manifest
|
|
48
|
+
|
|
49
|
+
### Basic Manifest
|
|
50
|
+
|
|
51
|
+
\`\`\`ts
|
|
52
|
+
import { z } from 'zod';
|
|
53
|
+
import type { StorageManifestDescriptor } from '@vibesdotdev/storage';
|
|
54
|
+
|
|
55
|
+
const settingsManifest: StorageManifestDescriptor = {
|
|
56
|
+
kind: 'storage/manifest',
|
|
57
|
+
id: 'app/settings',
|
|
58
|
+
namespace: 'app',
|
|
59
|
+
schema: z.object({
|
|
60
|
+
theme: z.enum(['light', 'dark', 'system']),
|
|
61
|
+
language: z.string().default('en'),
|
|
62
|
+
notifications: z.boolean().default(true),
|
|
63
|
+
autoSave: z.boolean().default(true)
|
|
64
|
+
})
|
|
65
|
+
};
|
|
66
|
+
\`\`\`
|
|
67
|
+
|
|
68
|
+
### Manifest with Adapter Constraints
|
|
69
|
+
|
|
70
|
+
\`\`\`ts
|
|
71
|
+
const userPreferencesManifest: StorageManifestDescriptor = {
|
|
72
|
+
kind: 'storage/manifest',
|
|
73
|
+
id: 'user/preferences',
|
|
74
|
+
namespace: 'user',
|
|
75
|
+
schema: z.object({
|
|
76
|
+
// ... schema fields
|
|
77
|
+
}),
|
|
78
|
+
allowedAdapters: [
|
|
79
|
+
'storage.adapter.libsql',
|
|
80
|
+
'storage.adapter.d1',
|
|
81
|
+
'storage.adapter.drizzle'
|
|
82
|
+
],
|
|
83
|
+
adapterConfig: {
|
|
84
|
+
'storage.cloud-api': {
|
|
85
|
+
endpoint: 'https://storage.vibes.dev/user/preferences'
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
\`\`\`
|
|
90
|
+
|
|
91
|
+
### Manifest with Context Rules
|
|
92
|
+
|
|
93
|
+
\`\`\`ts
|
|
94
|
+
const productionConfigManifest: StorageManifestDescriptor = {
|
|
95
|
+
kind: 'storage/manifest',
|
|
96
|
+
id: 'app/production-config',
|
|
97
|
+
namespace: 'app',
|
|
98
|
+
schema: z.object({
|
|
99
|
+
// ... schema fields
|
|
100
|
+
}),
|
|
101
|
+
context: {
|
|
102
|
+
hardware: ['cloud'],
|
|
103
|
+
environment: ['production']
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
\`\`\`
|
|
107
|
+
|
|
108
|
+
## Using StorageManifest Class
|
|
109
|
+
|
|
110
|
+
The \`StorageManifest\` class provides document operations:
|
|
111
|
+
|
|
112
|
+
\`\`\`ts
|
|
113
|
+
import { StorageManifest } from '@vibesdotdev/storage';
|
|
114
|
+
import { getVibesRuntime } from '@vibesdotdev/runtime';
|
|
115
|
+
|
|
116
|
+
const runtime = getVibesRuntime();
|
|
117
|
+
|
|
118
|
+
// Create manifest instance
|
|
119
|
+
const settings = new StorageManifest('app/settings');
|
|
120
|
+
|
|
121
|
+
// Load data
|
|
122
|
+
const data = await settings.load();
|
|
123
|
+
|
|
124
|
+
// Save data
|
|
125
|
+
await settings.save({
|
|
126
|
+
theme: 'dark',
|
|
127
|
+
language: 'en',
|
|
128
|
+
notifications: true
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// Check existence
|
|
132
|
+
const exists = await settings.exists();
|
|
133
|
+
|
|
134
|
+
// Delete data
|
|
135
|
+
await settings.delete();
|
|
136
|
+
\`\`\`
|
|
137
|
+
|
|
138
|
+
## Manifest Namespaces
|
|
139
|
+
|
|
140
|
+
Namespaces organize manifests hierarchically:
|
|
141
|
+
|
|
142
|
+
\`\`\`
|
|
143
|
+
app/settings
|
|
144
|
+
app/preferences
|
|
145
|
+
app/theme
|
|
146
|
+
user/profile
|
|
147
|
+
user/preferences
|
|
148
|
+
system/config
|
|
149
|
+
\`\`\`
|
|
150
|
+
|
|
151
|
+
**Namespace conventions:**
|
|
152
|
+
- \`app/*\` — Application-level configuration
|
|
153
|
+
- \`user/*\` — User-specific data
|
|
154
|
+
- \`system/*\` — System-wide configuration
|
|
155
|
+
- \`workspace/*\` — Workspace-shared data
|
|
156
|
+
|
|
157
|
+
## Adapter Configuration
|
|
158
|
+
|
|
159
|
+
Manifests can configure adapter-specific behavior:
|
|
160
|
+
|
|
161
|
+
### Cloud-API Endpoint
|
|
162
|
+
|
|
163
|
+
\`\`\`ts
|
|
164
|
+
{
|
|
165
|
+
adapterConfig: {
|
|
166
|
+
'storage.cloud-api': {
|
|
167
|
+
endpoint: 'https://storage.vibes.dev/app/settings',
|
|
168
|
+
auth: 'bearer-token'
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
\`\`\`
|
|
173
|
+
|
|
174
|
+
### Drizzle Table Name
|
|
175
|
+
|
|
176
|
+
\`\`\`ts
|
|
177
|
+
{
|
|
178
|
+
adapterConfig: {
|
|
179
|
+
'storage.adapter.drizzle': {
|
|
180
|
+
tableName: 'app_settings',
|
|
181
|
+
schemaName: 'public'
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
\`\`\`
|
|
186
|
+
|
|
187
|
+
### LibSQL Database Path
|
|
188
|
+
|
|
189
|
+
\`\`\`ts
|
|
190
|
+
{
|
|
191
|
+
adapterConfig: {
|
|
192
|
+
'storage.adapter.libsql': {
|
|
193
|
+
dbPath: './data/app.db',
|
|
194
|
+
authToken: 'optional-token'
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
\`\`\`
|
|
199
|
+
|
|
200
|
+
## Manifest Inheritance
|
|
201
|
+
|
|
202
|
+
Manifests can extend other manifests:
|
|
203
|
+
|
|
204
|
+
\`\`\`ts
|
|
205
|
+
const baseManifest: StorageManifestDescriptor = {
|
|
206
|
+
kind: 'storage/manifest',
|
|
207
|
+
id: 'app/base-settings',
|
|
208
|
+
namespace: 'app',
|
|
209
|
+
schema: z.object({
|
|
210
|
+
theme: z.enum(['light', 'dark']),
|
|
211
|
+
language: z.string()
|
|
212
|
+
})
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const extendedManifest: StorageManifestDescriptor = {
|
|
216
|
+
...baseManifest,
|
|
217
|
+
id: 'app/extended-settings',
|
|
218
|
+
schema: baseManifest.schema.extend({
|
|
219
|
+
notifications: z.boolean(),
|
|
220
|
+
autoSave: z.boolean()
|
|
221
|
+
})
|
|
222
|
+
};
|
|
223
|
+
\`\`\`
|
|
224
|
+
|
|
225
|
+
## Manifest Validation
|
|
226
|
+
|
|
227
|
+
Manifests validate data on load and save:
|
|
228
|
+
|
|
229
|
+
\`\`\`ts
|
|
230
|
+
try {
|
|
231
|
+
const settings = new StorageManifest('app/settings');
|
|
232
|
+
await settings.save({ theme: 'invalid' }); // fails validation
|
|
233
|
+
} catch (error) {
|
|
234
|
+
console.error(error); // ZodError with details
|
|
235
|
+
}
|
|
236
|
+
\`\`\`
|
|
237
|
+
|
|
238
|
+
## Manifest Migration
|
|
239
|
+
|
|
240
|
+
Update schemas while maintaining backward compatibility:
|
|
241
|
+
|
|
242
|
+
\`\`\`ts
|
|
243
|
+
const settingsManifestV2: StorageManifestDescriptor = {
|
|
244
|
+
kind: 'storage/manifest',
|
|
245
|
+
id: 'app/settings',
|
|
246
|
+
namespace: 'app',
|
|
247
|
+
schema: z.object({
|
|
248
|
+
theme: z.enum(['light', 'dark', 'system']),
|
|
249
|
+
language: z.string().default('en'),
|
|
250
|
+
// New field with default for migration
|
|
251
|
+
notifications: z.boolean().default(true)
|
|
252
|
+
}),
|
|
253
|
+
// Migration transform
|
|
254
|
+
transform: {
|
|
255
|
+
fromRow: (row) => ({
|
|
256
|
+
...row,
|
|
257
|
+
notifications: row.notifications ?? true
|
|
258
|
+
})
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
\`\`\`
|
|
262
|
+
|
|
263
|
+
## Listing Manifests
|
|
264
|
+
|
|
265
|
+
List all registered manifests:
|
|
266
|
+
|
|
267
|
+
\`\`\`bash
|
|
268
|
+
vibes storage list --kind manifest
|
|
269
|
+
\`\`\`
|
|
270
|
+
|
|
271
|
+
**Output:**
|
|
272
|
+
\`\`\`
|
|
273
|
+
ID Namespace Adapters
|
|
274
|
+
────────────────────────────────────────────────
|
|
275
|
+
app/settings app libsql, cloud-api
|
|
276
|
+
user/preferences user drizzle, cloud-api
|
|
277
|
+
system/config system d1
|
|
278
|
+
\`\`\`
|
|
279
|
+
|
|
280
|
+
## Manifest Discovery
|
|
281
|
+
|
|
282
|
+
Query manifests by namespace:
|
|
283
|
+
|
|
284
|
+
\`\`\`ts
|
|
285
|
+
const appManifests = runtime.query('storage/manifest')
|
|
286
|
+
.filter(d => d.namespace === 'app')
|
|
287
|
+
.descriptors();
|
|
288
|
+
|
|
289
|
+
const cloudManifests = runtime.query('storage/manifest')
|
|
290
|
+
.filter(d => d.context?.hardware?.includes('cloud'))
|
|
291
|
+
.descriptors();
|
|
292
|
+
\`\`\`
|
|
293
|
+
|
|
294
|
+
## Best Practices
|
|
295
|
+
|
|
296
|
+
1. **Use descriptive IDs** — \`app/settings\` not \`settings\`
|
|
297
|
+
2. **Namespace consistently** — Group related manifests
|
|
298
|
+
3. **Declare adapter constraints** — Be explicit about allowed adapters
|
|
299
|
+
4. **Version schemas** — Use transforms for migrations
|
|
300
|
+
5. **Test with multiple adapters** — Ensure adapter compatibility
|
|
301
|
+
|
|
302
|
+
:::card{title="See also"}
|
|
303
|
+
- [\`storage.adapters\`](storage.adapters) — Adapter implementations
|
|
304
|
+
- [\`storage.records\`](storage.records) — Record CRUD operations
|
|
305
|
+
- [\`storage.sync\`](storage.sync) — Cross-app synchronization
|
|
306
|
+
- [\`config.manifests\`](config.manifests) — Configuration manifests
|
|
307
|
+
:::
|
|
308
|
+
`
|
|
309
|
+
},
|
|
310
|
+
parent: 'storage',
|
|
311
|
+
order: 4,
|
|
312
|
+
tags: ['storage', 'manifests', 'declarations', 'adapters', 'namespaces'],
|
|
313
|
+
surfaces: ['cli', 'web', 'in-app'],
|
|
314
|
+
hardware: ['consumer', 'cloud'],
|
|
315
|
+
enabled: true
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
export default descriptor;
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import type { DocsTopicDescriptor } from '@vibesdotdev/docs';
|
|
2
|
+
|
|
3
|
+
const descriptor: DocsTopicDescriptor = {
|
|
4
|
+
kind: 'docs/topic',
|
|
5
|
+
id: 'storage.records',
|
|
6
|
+
title: 'Storage Records',
|
|
7
|
+
summary: 'Record CRUD operations, typing, validation, and transforms',
|
|
8
|
+
body: {
|
|
9
|
+
type: 'markdown',
|
|
10
|
+
sourceType: 'raw',
|
|
11
|
+
source: `---
|
|
12
|
+
title: Storage Records
|
|
13
|
+
summary: Record CRUD operations, typing, validation, and transforms
|
|
14
|
+
tags: [storage, records, crud, typing, validation]
|
|
15
|
+
parent: storage
|
|
16
|
+
order: 2
|
|
17
|
+
surfaces: [cli, web, in-app]
|
|
18
|
+
hardware: [consumer, cloud]
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
# Storage Records
|
|
22
|
+
|
|
23
|
+
Records provide type-safe CRUD operations for structured data. The \`storage/record\` runtime kind defines the interface for single-table operations with automatic validation and timestamps.
|
|
24
|
+
|
|
25
|
+
## Record Interface
|
|
26
|
+
|
|
27
|
+
\`\`\`ts
|
|
28
|
+
interface StorageRecordInterface<T extends Record<string, unknown>> {
|
|
29
|
+
// Create
|
|
30
|
+
insert(data: Omit<T, 'id' | 'createdAt' | 'updatedAt'>): Promise<T>;
|
|
31
|
+
|
|
32
|
+
// Read
|
|
33
|
+
find(id: string): Promise<T | null>;
|
|
34
|
+
findAll(query?: QueryFilter<T>): Promise<T[]>;
|
|
35
|
+
|
|
36
|
+
// Update
|
|
37
|
+
update(id: string, data: Partial<T>): Promise<T>;
|
|
38
|
+
|
|
39
|
+
// Delete
|
|
40
|
+
delete(id: string): Promise<void>;
|
|
41
|
+
|
|
42
|
+
// Lifecycle
|
|
43
|
+
dispose(): Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
\`\`\`
|
|
46
|
+
|
|
47
|
+
## Defining Record Types
|
|
48
|
+
|
|
49
|
+
Records are defined with Zod schemas:
|
|
50
|
+
|
|
51
|
+
\`\`\`ts
|
|
52
|
+
import { z } from 'zod';
|
|
53
|
+
import type { StorageRecordDescriptor } from '@vibesdotdev/storage';
|
|
54
|
+
|
|
55
|
+
const userRecord: StorageRecordDescriptor = {
|
|
56
|
+
kind: 'storage/record',
|
|
57
|
+
id: 'user',
|
|
58
|
+
namespace: 'app',
|
|
59
|
+
schema: z.object({
|
|
60
|
+
id: z.string().uuid(),
|
|
61
|
+
email: z.string().email(),
|
|
62
|
+
name: z.string().min(1),
|
|
63
|
+
role: z.enum(['admin', 'user', 'guest']),
|
|
64
|
+
createdAt: z.coerce.date(),
|
|
65
|
+
updatedAt: z.coerce.date()
|
|
66
|
+
})
|
|
67
|
+
};
|
|
68
|
+
\`\`\`
|
|
69
|
+
|
|
70
|
+
## Using Records
|
|
71
|
+
|
|
72
|
+
### Creating Records
|
|
73
|
+
|
|
74
|
+
\`\`\`ts
|
|
75
|
+
import { StorageRecord } from '@vibesdotdev/storage';
|
|
76
|
+
import { getVibesRuntime } from '@vibesdotdev/runtime';
|
|
77
|
+
|
|
78
|
+
const runtime = getVibesRuntime();
|
|
79
|
+
const userStore = new StorageRecord(userRecord, { runtime });
|
|
80
|
+
|
|
81
|
+
const user = await userStore.insert({
|
|
82
|
+
email: 'alice@example.com',
|
|
83
|
+
name: 'Alice',
|
|
84
|
+
role: 'user'
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
console.log(user);
|
|
88
|
+
// { id: 'uuid...', email: 'alice@example.com', name: 'Alice', role: 'user', ... }
|
|
89
|
+
\`\`\`
|
|
90
|
+
|
|
91
|
+
### Querying Records
|
|
92
|
+
|
|
93
|
+
\`\`\`ts
|
|
94
|
+
// Find by ID
|
|
95
|
+
const user = await userStore.find('user-id');
|
|
96
|
+
|
|
97
|
+
// Find all with filter
|
|
98
|
+
const users = await userStore.findAll({
|
|
99
|
+
where: { role: 'admin' },
|
|
100
|
+
orderBy: { field: 'createdAt', direction: 'desc' },
|
|
101
|
+
limit: 10
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// Find first match
|
|
105
|
+
const admin = await userStore.findAll({
|
|
106
|
+
where: { role: 'admin' },
|
|
107
|
+
limit: 1
|
|
108
|
+
}).then(results => results[0]);
|
|
109
|
+
\`\`\`
|
|
110
|
+
|
|
111
|
+
### Updating Records
|
|
112
|
+
|
|
113
|
+
\`\`\`ts
|
|
114
|
+
const updated = await userStore.update('user-id', {
|
|
115
|
+
name: 'Alice Updated'
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// updatedAt is automatically managed
|
|
119
|
+
console.log(updated.updatedAt); // new Date()
|
|
120
|
+
\`\`\`
|
|
121
|
+
|
|
122
|
+
### Deleting Records
|
|
123
|
+
|
|
124
|
+
\`\`\`ts
|
|
125
|
+
await userStore.delete('user-id');
|
|
126
|
+
|
|
127
|
+
// Verify deletion
|
|
128
|
+
const exists = await userStore.find('user-id');
|
|
129
|
+
console.log(exists); // null
|
|
130
|
+
\`\`\`
|
|
131
|
+
|
|
132
|
+
## Automatic Timestamps
|
|
133
|
+
|
|
134
|
+
Records automatically manage \`createdAt\` and \`updatedAt\` fields:
|
|
135
|
+
|
|
136
|
+
- \`createdAt\` — Set on insert, immutable
|
|
137
|
+
- \`updatedAt\` — Updated on every update operation
|
|
138
|
+
|
|
139
|
+
These fields are added automatically if not in your schema. To disable:
|
|
140
|
+
|
|
141
|
+
\`\`\`ts
|
|
142
|
+
const record: StorageRecordDescriptor = {
|
|
143
|
+
...
|
|
144
|
+
schema: z.object({
|
|
145
|
+
// your fields
|
|
146
|
+
}),
|
|
147
|
+
timestamps: false // disable automatic timestamps
|
|
148
|
+
};
|
|
149
|
+
\`\`\`
|
|
150
|
+
|
|
151
|
+
## Validation
|
|
152
|
+
|
|
153
|
+
Records validate data against the schema on every operation:
|
|
154
|
+
|
|
155
|
+
\`\`\`ts
|
|
156
|
+
try {
|
|
157
|
+
await userStore.insert({
|
|
158
|
+
email: 'not-an-email', // fails validation
|
|
159
|
+
name: 'Bob'
|
|
160
|
+
});
|
|
161
|
+
} catch (error) {
|
|
162
|
+
console.error(error); // ZodError with validation details
|
|
163
|
+
}
|
|
164
|
+
\`\`\`
|
|
165
|
+
|
|
166
|
+
## Record Transforms
|
|
167
|
+
|
|
168
|
+
Transforms convert between storage and application formats:
|
|
169
|
+
|
|
170
|
+
\`\`\`ts
|
|
171
|
+
import { defineStorageTransform } from '@vibesdotdev/storage';
|
|
172
|
+
|
|
173
|
+
const userTransform = defineStorageTransform({
|
|
174
|
+
id: 'user.transform',
|
|
175
|
+
fromRow: (row) => ({
|
|
176
|
+
...row,
|
|
177
|
+
displayName: row.name.toUpperCase()
|
|
178
|
+
}),
|
|
179
|
+
toRow: (data) => ({
|
|
180
|
+
...data,
|
|
181
|
+
name: data.displayName.toLowerCase()
|
|
182
|
+
})
|
|
183
|
+
});
|
|
184
|
+
\`\`\`
|
|
185
|
+
|
|
186
|
+
Apply transforms when creating the record store:
|
|
187
|
+
|
|
188
|
+
\`\`\`ts
|
|
189
|
+
const userStore = new StorageRecord(userRecord, {
|
|
190
|
+
runtime,
|
|
191
|
+
transform: userTransform
|
|
192
|
+
});
|
|
193
|
+
\`\`\`
|
|
194
|
+
|
|
195
|
+
## Relations
|
|
196
|
+
|
|
197
|
+
Records support relations to other records:
|
|
198
|
+
|
|
199
|
+
\`\`\`ts
|
|
200
|
+
const postRecord: StorageRecordDescriptor = {
|
|
201
|
+
kind: 'storage/record',
|
|
202
|
+
id: 'post',
|
|
203
|
+
namespace: 'app',
|
|
204
|
+
schema: z.object({
|
|
205
|
+
id: z.string(),
|
|
206
|
+
title: z.string(),
|
|
207
|
+
authorId: z.string().uuid(),
|
|
208
|
+
content: z.string()
|
|
209
|
+
}),
|
|
210
|
+
relations: {
|
|
211
|
+
author: {
|
|
212
|
+
type: 'one',
|
|
213
|
+
target: 'user',
|
|
214
|
+
foreignKey: 'authorId'
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
\`\`\`
|
|
219
|
+
|
|
220
|
+
## Record Events
|
|
221
|
+
|
|
222
|
+
Records emit lifecycle events:
|
|
223
|
+
|
|
224
|
+
\`\`\`ts
|
|
225
|
+
import { storageRecordEvents } from '@vibesdotdev/storage';
|
|
226
|
+
|
|
227
|
+
runtime.registerDescriptor('event', storageRecordEvents.onInsert);
|
|
228
|
+
runtime.registerDescriptor('event', storageRecordEvents.onUpdate);
|
|
229
|
+
runtime.registerDescriptor('event', storageRecordEvents.onDelete);
|
|
230
|
+
|
|
231
|
+
// Subscribe to events
|
|
232
|
+
runtime.on('storage/record:insert', (event) => {
|
|
233
|
+
console.log('Record inserted:', event.recordId);
|
|
234
|
+
});
|
|
235
|
+
\`\`\`
|
|
236
|
+
|
|
237
|
+
## Storage Policy
|
|
238
|
+
|
|
239
|
+
Records respect storage policies for access control:
|
|
240
|
+
|
|
241
|
+
\`\`\`ts
|
|
242
|
+
import { StoragePolicyContext } from '@vibesdotdev/storage';
|
|
243
|
+
|
|
244
|
+
const policyContext: StoragePolicyContext = {
|
|
245
|
+
userId: 'current-user',
|
|
246
|
+
roles: ['user'],
|
|
247
|
+
capabilities: ['storage:read', 'storage:write']
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
const userStore = new StorageRecord(userRecord, {
|
|
251
|
+
runtime,
|
|
252
|
+
context: { 'storage/policy': policyContext }
|
|
253
|
+
});
|
|
254
|
+
\`\`\`
|
|
255
|
+
|
|
256
|
+
:::card{title="See also"}
|
|
257
|
+
- [\`storage.adapters\`](storage.adapters) — Adapter implementations
|
|
258
|
+
- [\`storage.manifests\`](storage.manifests) — Manifest declarations
|
|
259
|
+
- [\`storage.sync\`](storage.sync) — Cross-app synchronization
|
|
260
|
+
:::
|
|
261
|
+
`
|
|
262
|
+
},
|
|
263
|
+
parent: 'storage',
|
|
264
|
+
order: 2,
|
|
265
|
+
tags: ['storage', 'records', 'crud', 'typing', 'validation'],
|
|
266
|
+
surfaces: ['cli', 'web', 'in-app'],
|
|
267
|
+
hardware: ['consumer', 'cloud'],
|
|
268
|
+
enabled: true
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
export default descriptor;
|