@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,231 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage Schema Descriptor Schema
|
|
3
|
+
*
|
|
4
|
+
* Defines a multi-table schema with relations for complex modules.
|
|
5
|
+
* Used for modules that need multiple related tables with foreign keys.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const sessionSchemaDescriptor: StorageSchemaDescriptor = {
|
|
10
|
+
* kind: 'storage/schema',
|
|
11
|
+
* id: 'session',
|
|
12
|
+
* name: 'Session Storage Schema',
|
|
13
|
+
* description: 'Complete session storage with multiple related tables',
|
|
14
|
+
* tables: {
|
|
15
|
+
* sessions: {
|
|
16
|
+
* schema: SessionSchema,
|
|
17
|
+
* primaryKey: 'id',
|
|
18
|
+
* indexes: [{ fields: ['status'] }]
|
|
19
|
+
* },
|
|
20
|
+
* todos: {
|
|
21
|
+
* schema: TodoSchema,
|
|
22
|
+
* primaryKey: 'id',
|
|
23
|
+
* relations: {
|
|
24
|
+
* session: { type: 'belongs_to', target: 'sessions', foreignKey: 'sessionId' }
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
* },
|
|
28
|
+
* migrations: () => import('./migrations').then(m => m.SESSION_MIGRATIONS),
|
|
29
|
+
* allowedAdapters: ['storage.localdb'],
|
|
30
|
+
* dbName: 'sessions.db'
|
|
31
|
+
* };
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
import * as z from 'zod/v4';
|
|
35
|
+
/**
|
|
36
|
+
* Table definition within a schema
|
|
37
|
+
*/
|
|
38
|
+
export declare const StorageTableDefinitionSchema: z.ZodObject<{
|
|
39
|
+
schema: z.ZodUnknown;
|
|
40
|
+
primaryKey: z.ZodDefault<z.ZodString>;
|
|
41
|
+
relations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
42
|
+
type: z.ZodEnum<{
|
|
43
|
+
belongs_to: "belongs_to";
|
|
44
|
+
has_one: "has_one";
|
|
45
|
+
has_many: "has_many";
|
|
46
|
+
many_to_many: "many_to_many";
|
|
47
|
+
}>;
|
|
48
|
+
target: z.ZodString;
|
|
49
|
+
foreignKey: z.ZodOptional<z.ZodString>;
|
|
50
|
+
foreignKeyTarget: z.ZodOptional<z.ZodString>;
|
|
51
|
+
through: z.ZodOptional<z.ZodString>;
|
|
52
|
+
optional: z.ZodDefault<z.ZodBoolean>;
|
|
53
|
+
cascadeDelete: z.ZodDefault<z.ZodBoolean>;
|
|
54
|
+
as: z.ZodOptional<z.ZodString>;
|
|
55
|
+
}, z.core.$strip>>>;
|
|
56
|
+
indexes: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
57
|
+
name: z.ZodOptional<z.ZodString>;
|
|
58
|
+
fields: z.ZodArray<z.ZodString>;
|
|
59
|
+
unique: z.ZodDefault<z.ZodBoolean>;
|
|
60
|
+
type: z.ZodOptional<z.ZodString>;
|
|
61
|
+
where: z.ZodOptional<z.ZodString>;
|
|
62
|
+
}, z.core.$strip>>>;
|
|
63
|
+
timestamps: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
64
|
+
createdAt: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>;
|
|
65
|
+
updatedAt: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>;
|
|
66
|
+
}, z.core.$strip>]>>;
|
|
67
|
+
autoId: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
68
|
+
field: z.ZodOptional<z.ZodString>;
|
|
69
|
+
strategy: z.ZodOptional<z.ZodEnum<{
|
|
70
|
+
custom: "custom";
|
|
71
|
+
uuid: "uuid";
|
|
72
|
+
nanoid: "nanoid";
|
|
73
|
+
}>>;
|
|
74
|
+
generator: z.ZodOptional<z.ZodUnknown>;
|
|
75
|
+
}, z.core.$strip>]>>;
|
|
76
|
+
softDelete: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>;
|
|
77
|
+
fieldConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
78
|
+
autoIncrement: z.ZodOptional<z.ZodBoolean>;
|
|
79
|
+
generator: z.ZodOptional<z.ZodUnknown>;
|
|
80
|
+
type: z.ZodOptional<z.ZodString>;
|
|
81
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
82
|
+
}, z.core.$strip>>>;
|
|
83
|
+
versioning: z.ZodDefault<z.ZodBoolean>;
|
|
84
|
+
audit: z.ZodDefault<z.ZodBoolean>;
|
|
85
|
+
changeTracking: z.ZodDefault<z.ZodBoolean>;
|
|
86
|
+
validate: z.ZodOptional<z.ZodUnknown>;
|
|
87
|
+
beforeCreate: z.ZodOptional<z.ZodUnknown>;
|
|
88
|
+
afterCreate: z.ZodOptional<z.ZodUnknown>;
|
|
89
|
+
beforeUpdate: z.ZodOptional<z.ZodUnknown>;
|
|
90
|
+
afterUpdate: z.ZodOptional<z.ZodUnknown>;
|
|
91
|
+
beforeDelete: z.ZodOptional<z.ZodUnknown>;
|
|
92
|
+
afterDelete: z.ZodOptional<z.ZodUnknown>;
|
|
93
|
+
}, z.core.$strip>;
|
|
94
|
+
/**
|
|
95
|
+
* Migration source - can be inline or lazy-loaded
|
|
96
|
+
*/
|
|
97
|
+
export declare const MigrationSourceSchema: z.ZodUnion<readonly [z.ZodArray<z.ZodObject<{
|
|
98
|
+
version: z.ZodNumber;
|
|
99
|
+
name: z.ZodOptional<z.ZodString>;
|
|
100
|
+
up: z.ZodUnion<readonly [z.ZodString, z.ZodUnknown]>;
|
|
101
|
+
down: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodUnknown]>>;
|
|
102
|
+
}, z.core.$strip>>, z.ZodUnknown, z.ZodString]>;
|
|
103
|
+
/**
|
|
104
|
+
* Storage schema descriptor schema
|
|
105
|
+
*/
|
|
106
|
+
export declare const StorageSchemaDescriptorSchema: z.ZodObject<{
|
|
107
|
+
id: z.ZodString;
|
|
108
|
+
hardware: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
109
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
110
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
111
|
+
requiredContext: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
112
|
+
optionalContext: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
113
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
114
|
+
kind: z.ZodLiteral<"storage/schema">;
|
|
115
|
+
name: z.ZodString;
|
|
116
|
+
description: z.ZodOptional<z.ZodString>;
|
|
117
|
+
tables: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
118
|
+
schema: z.ZodUnknown;
|
|
119
|
+
primaryKey: z.ZodDefault<z.ZodString>;
|
|
120
|
+
relations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
121
|
+
type: z.ZodEnum<{
|
|
122
|
+
belongs_to: "belongs_to";
|
|
123
|
+
has_one: "has_one";
|
|
124
|
+
has_many: "has_many";
|
|
125
|
+
many_to_many: "many_to_many";
|
|
126
|
+
}>;
|
|
127
|
+
target: z.ZodString;
|
|
128
|
+
foreignKey: z.ZodOptional<z.ZodString>;
|
|
129
|
+
foreignKeyTarget: z.ZodOptional<z.ZodString>;
|
|
130
|
+
through: z.ZodOptional<z.ZodString>;
|
|
131
|
+
optional: z.ZodDefault<z.ZodBoolean>;
|
|
132
|
+
cascadeDelete: z.ZodDefault<z.ZodBoolean>;
|
|
133
|
+
as: z.ZodOptional<z.ZodString>;
|
|
134
|
+
}, z.core.$strip>>>;
|
|
135
|
+
indexes: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
136
|
+
name: z.ZodOptional<z.ZodString>;
|
|
137
|
+
fields: z.ZodArray<z.ZodString>;
|
|
138
|
+
unique: z.ZodDefault<z.ZodBoolean>;
|
|
139
|
+
type: z.ZodOptional<z.ZodString>;
|
|
140
|
+
where: z.ZodOptional<z.ZodString>;
|
|
141
|
+
}, z.core.$strip>>>;
|
|
142
|
+
timestamps: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
143
|
+
createdAt: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>;
|
|
144
|
+
updatedAt: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>;
|
|
145
|
+
}, z.core.$strip>]>>;
|
|
146
|
+
autoId: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
147
|
+
field: z.ZodOptional<z.ZodString>;
|
|
148
|
+
strategy: z.ZodOptional<z.ZodEnum<{
|
|
149
|
+
custom: "custom";
|
|
150
|
+
uuid: "uuid";
|
|
151
|
+
nanoid: "nanoid";
|
|
152
|
+
}>>;
|
|
153
|
+
generator: z.ZodOptional<z.ZodUnknown>;
|
|
154
|
+
}, z.core.$strip>]>>;
|
|
155
|
+
softDelete: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>;
|
|
156
|
+
fieldConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
157
|
+
autoIncrement: z.ZodOptional<z.ZodBoolean>;
|
|
158
|
+
generator: z.ZodOptional<z.ZodUnknown>;
|
|
159
|
+
type: z.ZodOptional<z.ZodString>;
|
|
160
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
161
|
+
}, z.core.$strip>>>;
|
|
162
|
+
versioning: z.ZodDefault<z.ZodBoolean>;
|
|
163
|
+
audit: z.ZodDefault<z.ZodBoolean>;
|
|
164
|
+
changeTracking: z.ZodDefault<z.ZodBoolean>;
|
|
165
|
+
validate: z.ZodOptional<z.ZodUnknown>;
|
|
166
|
+
beforeCreate: z.ZodOptional<z.ZodUnknown>;
|
|
167
|
+
afterCreate: z.ZodOptional<z.ZodUnknown>;
|
|
168
|
+
beforeUpdate: z.ZodOptional<z.ZodUnknown>;
|
|
169
|
+
afterUpdate: z.ZodOptional<z.ZodUnknown>;
|
|
170
|
+
beforeDelete: z.ZodOptional<z.ZodUnknown>;
|
|
171
|
+
afterDelete: z.ZodOptional<z.ZodUnknown>;
|
|
172
|
+
}, z.core.$strip>>;
|
|
173
|
+
migrations: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodObject<{
|
|
174
|
+
version: z.ZodNumber;
|
|
175
|
+
name: z.ZodOptional<z.ZodString>;
|
|
176
|
+
up: z.ZodUnion<readonly [z.ZodString, z.ZodUnknown]>;
|
|
177
|
+
down: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodUnknown]>>;
|
|
178
|
+
}, z.core.$strip>>, z.ZodUnknown, z.ZodString]>>;
|
|
179
|
+
migrationKey: z.ZodOptional<z.ZodString>;
|
|
180
|
+
version: z.ZodDefault<z.ZodNumber>;
|
|
181
|
+
allowedAdapters: z.ZodArray<z.ZodString>;
|
|
182
|
+
defaultAdapter: z.ZodOptional<z.ZodString>;
|
|
183
|
+
adapterConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
184
|
+
scope: z.ZodDefault<z.ZodEnum<{
|
|
185
|
+
global: "global";
|
|
186
|
+
project: "project";
|
|
187
|
+
local: "local";
|
|
188
|
+
auto: "auto";
|
|
189
|
+
}>>;
|
|
190
|
+
dbName: z.ZodOptional<z.ZodString>;
|
|
191
|
+
dbSchema: z.ZodOptional<z.ZodString>;
|
|
192
|
+
basePath: z.ZodOptional<z.ZodString>;
|
|
193
|
+
foreignKeys: z.ZodDefault<z.ZodBoolean>;
|
|
194
|
+
cascadeDelete: z.ZodDefault<z.ZodBoolean>;
|
|
195
|
+
transactions: z.ZodDefault<z.ZodBoolean>;
|
|
196
|
+
pooling: z.ZodDefault<z.ZodBoolean>;
|
|
197
|
+
poolSize: z.ZodDefault<z.ZodNumber>;
|
|
198
|
+
sync: z.ZodDefault<z.ZodBoolean>;
|
|
199
|
+
syncConfig: z.ZodOptional<z.ZodObject<{
|
|
200
|
+
direction: z.ZodDefault<z.ZodEnum<{
|
|
201
|
+
bidirectional: "bidirectional";
|
|
202
|
+
"to-cloud": "to-cloud";
|
|
203
|
+
"from-cloud": "from-cloud";
|
|
204
|
+
}>>;
|
|
205
|
+
conflictResolution: z.ZodDefault<z.ZodEnum<{
|
|
206
|
+
custom: "custom";
|
|
207
|
+
timestamp: "timestamp";
|
|
208
|
+
"server-wins": "server-wins";
|
|
209
|
+
"client-wins": "client-wins";
|
|
210
|
+
}>>;
|
|
211
|
+
conflictResolver: z.ZodOptional<z.ZodUnknown>;
|
|
212
|
+
interval: z.ZodDefault<z.ZodNumber>;
|
|
213
|
+
excludeTables: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
214
|
+
}, z.core.$strip>>;
|
|
215
|
+
backup: z.ZodDefault<z.ZodBoolean>;
|
|
216
|
+
backupConfig: z.ZodOptional<z.ZodObject<{
|
|
217
|
+
interval: z.ZodDefault<z.ZodNumber>;
|
|
218
|
+
maxBackups: z.ZodDefault<z.ZodNumber>;
|
|
219
|
+
location: z.ZodOptional<z.ZodString>;
|
|
220
|
+
excludeTables: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
221
|
+
}, z.core.$strip>>;
|
|
222
|
+
internal: z.ZodDefault<z.ZodBoolean>;
|
|
223
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
224
|
+
tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
225
|
+
author: z.ZodOptional<z.ZodString>;
|
|
226
|
+
versionHistoryUrl: z.ZodOptional<z.ZodString>;
|
|
227
|
+
}, z.core.$strip>;
|
|
228
|
+
export type StorageTableDefinition = z.infer<typeof StorageTableDefinitionSchema>;
|
|
229
|
+
export type MigrationSource = z.infer<typeof MigrationSourceSchema>;
|
|
230
|
+
export type StorageSchemaDescriptor = z.infer<typeof StorageSchemaDescriptorSchema>;
|
|
231
|
+
//# sourceMappingURL=descriptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptor.d.ts","sourceRoot":"","sources":["../../../src/schemas/schema/descriptor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAU5B;;GAEG;AACH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuEvC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;+CAOhC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwIxC,CAAC;AAIH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAClF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACpE,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage Schema Descriptor Schema
|
|
3
|
+
*
|
|
4
|
+
* Defines a multi-table schema with relations for complex modules.
|
|
5
|
+
* Used for modules that need multiple related tables with foreign keys.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const sessionSchemaDescriptor: StorageSchemaDescriptor = {
|
|
10
|
+
* kind: 'storage/schema',
|
|
11
|
+
* id: 'session',
|
|
12
|
+
* name: 'Session Storage Schema',
|
|
13
|
+
* description: 'Complete session storage with multiple related tables',
|
|
14
|
+
* tables: {
|
|
15
|
+
* sessions: {
|
|
16
|
+
* schema: SessionSchema,
|
|
17
|
+
* primaryKey: 'id',
|
|
18
|
+
* indexes: [{ fields: ['status'] }]
|
|
19
|
+
* },
|
|
20
|
+
* todos: {
|
|
21
|
+
* schema: TodoSchema,
|
|
22
|
+
* primaryKey: 'id',
|
|
23
|
+
* relations: {
|
|
24
|
+
* session: { type: 'belongs_to', target: 'sessions', foreignKey: 'sessionId' }
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
* },
|
|
28
|
+
* migrations: () => import('./migrations').then(m => m.SESSION_MIGRATIONS),
|
|
29
|
+
* allowedAdapters: ['storage.localdb'],
|
|
30
|
+
* dbName: 'sessions.db'
|
|
31
|
+
* };
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
import * as z from 'zod/v4';
|
|
35
|
+
import { RuntimeDescriptorSchema } from '@vibesdotdev/runtime/schemas/descriptor';
|
|
36
|
+
import { StorageScopeSchema } from '../manifest-descriptor.js';
|
|
37
|
+
import { StorageRelationSchema, StorageIndexSchema, StorageMigrationSchema, StorageFieldConfigSchema } from '../record/descriptor.js';
|
|
38
|
+
/**
|
|
39
|
+
* Table definition within a schema
|
|
40
|
+
*/
|
|
41
|
+
export const StorageTableDefinitionSchema = z.object({
|
|
42
|
+
/** Zod schema for the table data (stored as unknown, validated at runtime) */
|
|
43
|
+
schema: z.unknown(),
|
|
44
|
+
/** Primary key field name (default: 'id') */
|
|
45
|
+
primaryKey: z.string().default('id'),
|
|
46
|
+
/** Relations to other tables in this schema */
|
|
47
|
+
relations: z.record(z.string(), StorageRelationSchema).optional(),
|
|
48
|
+
/** Database indexes for this table */
|
|
49
|
+
indexes: z.array(StorageIndexSchema).default([]),
|
|
50
|
+
/** Auto-manage timestamps (createdAt, updatedAt) */
|
|
51
|
+
timestamps: z
|
|
52
|
+
.union([
|
|
53
|
+
z.boolean(),
|
|
54
|
+
z.object({
|
|
55
|
+
createdAt: z.union([z.boolean(), z.string()]).optional(),
|
|
56
|
+
updatedAt: z.union([z.boolean(), z.string()]).optional()
|
|
57
|
+
})
|
|
58
|
+
])
|
|
59
|
+
.default(true),
|
|
60
|
+
/** Auto-generate IDs */
|
|
61
|
+
autoId: z
|
|
62
|
+
.union([
|
|
63
|
+
z.boolean(),
|
|
64
|
+
z.object({
|
|
65
|
+
field: z.string().optional(),
|
|
66
|
+
strategy: z.enum(['uuid', 'nanoid', 'custom']).optional(),
|
|
67
|
+
generator: z.optional(z.unknown())
|
|
68
|
+
})
|
|
69
|
+
])
|
|
70
|
+
.default(true),
|
|
71
|
+
/** Soft delete field (e.g., 'deletedAt') */
|
|
72
|
+
softDelete: z.union([z.boolean(), z.string()]).optional(),
|
|
73
|
+
/** Field-specific configurations */
|
|
74
|
+
fieldConfig: z.record(z.string(), StorageFieldConfigSchema).optional(),
|
|
75
|
+
/** Enable record versioning for optimistic locking */
|
|
76
|
+
versioning: z.boolean().default(false),
|
|
77
|
+
/** Enable audit trail (createdBy, updatedBy) */
|
|
78
|
+
audit: z.boolean().default(false),
|
|
79
|
+
/** Enable change tracking for sync */
|
|
80
|
+
changeTracking: z.boolean().default(false),
|
|
81
|
+
/** Custom validation function */
|
|
82
|
+
validate: z.optional(z.unknown()),
|
|
83
|
+
/** Before create hook */
|
|
84
|
+
beforeCreate: z.optional(z.unknown()),
|
|
85
|
+
/** After create hook */
|
|
86
|
+
afterCreate: z.optional(z.unknown()),
|
|
87
|
+
/** Before update hook */
|
|
88
|
+
beforeUpdate: z.optional(z.unknown()),
|
|
89
|
+
/** After update hook */
|
|
90
|
+
afterUpdate: z.optional(z.unknown()),
|
|
91
|
+
/** Before delete hook */
|
|
92
|
+
beforeDelete: z.optional(z.unknown()),
|
|
93
|
+
/** After delete hook */
|
|
94
|
+
afterDelete: z.optional(z.unknown())
|
|
95
|
+
});
|
|
96
|
+
/**
|
|
97
|
+
* Migration source - can be inline or lazy-loaded
|
|
98
|
+
*/
|
|
99
|
+
export const MigrationSourceSchema = z.union([
|
|
100
|
+
// Inline migrations array
|
|
101
|
+
z.array(StorageMigrationSchema),
|
|
102
|
+
// Lazy-loaded migrations (function that returns promise)
|
|
103
|
+
z.unknown(),
|
|
104
|
+
// Module import path
|
|
105
|
+
z.string()
|
|
106
|
+
]);
|
|
107
|
+
/**
|
|
108
|
+
* Storage schema descriptor schema
|
|
109
|
+
*/
|
|
110
|
+
export const StorageSchemaDescriptorSchema = RuntimeDescriptorSchema.extend({
|
|
111
|
+
kind: z.literal('storage/schema'),
|
|
112
|
+
// SCHEMA DEFINITION
|
|
113
|
+
/** Human-readable name */
|
|
114
|
+
name: z.string().min(1),
|
|
115
|
+
/** Human-readable description */
|
|
116
|
+
description: z.string().optional(),
|
|
117
|
+
/** Table definitions (key is table name) */
|
|
118
|
+
tables: z
|
|
119
|
+
.record(z.string(), StorageTableDefinitionSchema)
|
|
120
|
+
.refine((tables) => Object.keys(tables).length > 0, {
|
|
121
|
+
message: 'Schema must have at least one table'
|
|
122
|
+
}),
|
|
123
|
+
// MIGRATIONS
|
|
124
|
+
/** Inline or lazy-loaded migrations for this schema */
|
|
125
|
+
migrations: MigrationSourceSchema.optional(),
|
|
126
|
+
/** Migration key for external migrations (e.g., 'session') */
|
|
127
|
+
migrationKey: z.string().optional(),
|
|
128
|
+
/** Current schema version (default: 1) */
|
|
129
|
+
version: z.number().int().positive().default(1),
|
|
130
|
+
// ADAPTER SELECTION
|
|
131
|
+
/** Allowed adapter IDs (e.g., ['storage.localdb', 'storage.drizzle']) */
|
|
132
|
+
allowedAdapters: z.array(z.string()).min(1),
|
|
133
|
+
/** Default adapter to use when not specified */
|
|
134
|
+
defaultAdapter: z.string().optional(),
|
|
135
|
+
/** Adapter-specific configuration */
|
|
136
|
+
adapterConfig: z.record(z.string(), z.unknown()).optional(),
|
|
137
|
+
// SCOPE & STORAGE
|
|
138
|
+
/** Storage scope for path resolution */
|
|
139
|
+
scope: StorageScopeSchema.default('project'),
|
|
140
|
+
/** Custom database name (overrides default) */
|
|
141
|
+
dbName: z.string().optional(),
|
|
142
|
+
/** Database schema name (for Postgres) */
|
|
143
|
+
dbSchema: z.string().optional(),
|
|
144
|
+
/** Custom base path for database */
|
|
145
|
+
basePath: z.string().optional(),
|
|
146
|
+
// SCHEMA FEATURES
|
|
147
|
+
/** Enable foreign key constraints */
|
|
148
|
+
foreignKeys: z.boolean().default(true),
|
|
149
|
+
/** Enable cascade delete for relations with cascadeDelete=true */
|
|
150
|
+
cascadeDelete: z.boolean().default(true),
|
|
151
|
+
/** Enable transactions for multi-table operations */
|
|
152
|
+
transactions: z.boolean().default(true),
|
|
153
|
+
/** Enable database connection pooling */
|
|
154
|
+
pooling: z.boolean().default(true),
|
|
155
|
+
/** Pool size (if pooling enabled) */
|
|
156
|
+
poolSize: z.number().int().positive().default(5),
|
|
157
|
+
// SYNC & REPLICATION
|
|
158
|
+
/** Enable sync between runtimes */
|
|
159
|
+
sync: z.boolean().default(false),
|
|
160
|
+
/** Sync configuration */
|
|
161
|
+
syncConfig: z
|
|
162
|
+
.object({
|
|
163
|
+
/** Sync direction */
|
|
164
|
+
direction: z.enum(['bidirectional', 'to-cloud', 'from-cloud']).default('bidirectional'),
|
|
165
|
+
/** Conflict resolution strategy */
|
|
166
|
+
conflictResolution: z
|
|
167
|
+
.enum(['server-wins', 'client-wins', 'timestamp', 'custom'])
|
|
168
|
+
.default('timestamp'),
|
|
169
|
+
/** Custom conflict resolver */
|
|
170
|
+
conflictResolver: z.optional(z.unknown()),
|
|
171
|
+
/** Sync interval in milliseconds */
|
|
172
|
+
interval: z.number().int().positive().default(60000),
|
|
173
|
+
/** Tables to exclude from sync */
|
|
174
|
+
excludeTables: z.array(z.string()).optional()
|
|
175
|
+
})
|
|
176
|
+
.optional(),
|
|
177
|
+
// BACKUP & RESTORE
|
|
178
|
+
/** Enable automatic backups */
|
|
179
|
+
backup: z.boolean().default(false),
|
|
180
|
+
/** Backup configuration */
|
|
181
|
+
backupConfig: z
|
|
182
|
+
.object({
|
|
183
|
+
/** Backup interval in milliseconds */
|
|
184
|
+
interval: z.number().int().positive().default(86400000), // 24 hours
|
|
185
|
+
/** Maximum number of backups to keep */
|
|
186
|
+
maxBackups: z.number().int().positive().default(7),
|
|
187
|
+
/** Backup location */
|
|
188
|
+
location: z.string().optional(),
|
|
189
|
+
/** Tables to exclude from backup */
|
|
190
|
+
excludeTables: z.array(z.string()).optional()
|
|
191
|
+
})
|
|
192
|
+
.optional(),
|
|
193
|
+
// METADATA
|
|
194
|
+
/** Whether this schema is internal (not user-editable) */
|
|
195
|
+
internal: z.boolean().default(false),
|
|
196
|
+
/** Schema namespace (e.g., 'session') */
|
|
197
|
+
namespace: z.string().optional(),
|
|
198
|
+
/** Tags for categorization */
|
|
199
|
+
tags: z.array(z.string()).default([]),
|
|
200
|
+
/** Schema author/maintainer */
|
|
201
|
+
author: z.string().optional(),
|
|
202
|
+
/** Schema version history URL */
|
|
203
|
+
versionHistoryUrl: z.string().optional()
|
|
204
|
+
});
|
|
205
|
+
//# sourceMappingURL=descriptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptor.js","sourceRoot":"","sources":["../../../src/schemas/schema/descriptor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAClF,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EACN,q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AC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;KAC7C,CAAC;SACD,QAAQ,EAAE;IAEZ,WAAW;IAEX,0DAA0D;IAC1D,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IAEpC,yCAAyC;IACzC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAEhC,8BAA8B;IAC9B,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IAErC,+BAA+B;IAC/B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAE7B,iCAAiC;IACjC,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACxC,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage Schema Exports
|
|
3
|
+
*
|
|
4
|
+
* Exports all types and schemas for storage/schema descriptors.
|
|
5
|
+
*/
|
|
6
|
+
export { StorageSchemaDescriptorSchema, StorageTableDefinitionSchema, MigrationSourceSchema, type StorageSchemaDescriptor, type StorageTableDefinition, type MigrationSource } from './descriptor';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/schemas/schema/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACN,6BAA6B,EAC7B,4BAA4B,EAC5B,qBAAqB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/schemas/schema/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACN,6BAA6B,EAC7B,4BAA4B,EAC5B,qBAAqB,EAIrB,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage Sync-Bridge Descriptor Schema
|
|
3
|
+
*
|
|
4
|
+
* Declares a bidirectional sync bridge between a runtime kind (local descriptors)
|
|
5
|
+
* and a cloud CRUD API. Replaces hand-rolled per-module sync services with a
|
|
6
|
+
* declarative descriptor that the generic sync executor can process.
|
|
7
|
+
*
|
|
8
|
+
* The bridge maps local runtime descriptors ↔ remote API records, handling
|
|
9
|
+
* ID transformation, ownership filtering, secret stripping, and conflict resolution.
|
|
10
|
+
*/
|
|
11
|
+
import * as z from 'zod/v4';
|
|
12
|
+
export declare const SyncDirectionSchema: z.ZodEnum<{
|
|
13
|
+
bidirectional: "bidirectional";
|
|
14
|
+
"push-only": "push-only";
|
|
15
|
+
"pull-only": "pull-only";
|
|
16
|
+
}>;
|
|
17
|
+
export type SyncDirection = z.infer<typeof SyncDirectionSchema>;
|
|
18
|
+
export declare const ConflictStrategySchema: z.ZodEnum<{
|
|
19
|
+
"local-wins": "local-wins";
|
|
20
|
+
"remote-wins": "remote-wins";
|
|
21
|
+
manual: "manual";
|
|
22
|
+
newest: "newest";
|
|
23
|
+
}>;
|
|
24
|
+
export type ConflictStrategy = z.infer<typeof ConflictStrategySchema>;
|
|
25
|
+
export declare const OwnershipFilterSchema: z.ZodEnum<{
|
|
26
|
+
all: "all";
|
|
27
|
+
"user-only": "user-only";
|
|
28
|
+
"system-only": "system-only";
|
|
29
|
+
}>;
|
|
30
|
+
export type OwnershipFilter = z.infer<typeof OwnershipFilterSchema>;
|
|
31
|
+
/**
|
|
32
|
+
* Schema for a sync-bridge descriptor.
|
|
33
|
+
*
|
|
34
|
+
* Extends RuntimeDescriptor with source/target/sync configuration.
|
|
35
|
+
*/
|
|
36
|
+
export declare const SyncBridgeDescriptorSchema: z.ZodObject<{
|
|
37
|
+
id: z.ZodString;
|
|
38
|
+
name: z.ZodOptional<z.ZodString>;
|
|
39
|
+
description: z.ZodOptional<z.ZodString>;
|
|
40
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
41
|
+
hardware: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
42
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
43
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
requiredContext: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
45
|
+
optionalContext: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
46
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
47
|
+
kind: z.ZodLiteral<"storage/sync-bridge">;
|
|
48
|
+
source: z.ZodObject<{
|
|
49
|
+
runtimeKind: z.ZodString;
|
|
50
|
+
versionField: z.ZodOptional<z.ZodString>;
|
|
51
|
+
sourceTypeField: z.ZodOptional<z.ZodString>;
|
|
52
|
+
}, z.core.$strip>;
|
|
53
|
+
target: z.ZodObject<{
|
|
54
|
+
apiPath: z.ZodString;
|
|
55
|
+
entityPath: z.ZodOptional<z.ZodString>;
|
|
56
|
+
listField: z.ZodOptional<z.ZodString>;
|
|
57
|
+
totalField: z.ZodOptional<z.ZodString>;
|
|
58
|
+
includeDeleted: z.ZodOptional<z.ZodBoolean>;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
sync: z.ZodDefault<z.ZodObject<{
|
|
61
|
+
direction: z.ZodDefault<z.ZodEnum<{
|
|
62
|
+
bidirectional: "bidirectional";
|
|
63
|
+
"push-only": "push-only";
|
|
64
|
+
"pull-only": "pull-only";
|
|
65
|
+
}>>;
|
|
66
|
+
ownershipFilter: z.ZodDefault<z.ZodEnum<{
|
|
67
|
+
all: "all";
|
|
68
|
+
"user-only": "user-only";
|
|
69
|
+
"system-only": "system-only";
|
|
70
|
+
}>>;
|
|
71
|
+
conflictStrategy: z.ZodDefault<z.ZodEnum<{
|
|
72
|
+
"local-wins": "local-wins";
|
|
73
|
+
"remote-wins": "remote-wins";
|
|
74
|
+
manual: "manual";
|
|
75
|
+
newest: "newest";
|
|
76
|
+
}>>;
|
|
77
|
+
sensitiveFields: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
78
|
+
idField: z.ZodDefault<z.ZodString>;
|
|
79
|
+
}, z.core.$strip>>;
|
|
80
|
+
}, z.core.$loose>;
|
|
81
|
+
export type SyncBridgeDescriptor = z.infer<typeof SyncBridgeDescriptorSchema> & {
|
|
82
|
+
/**
|
|
83
|
+
* Transform a local runtime descriptor into the shape the API expects.
|
|
84
|
+
* Called before pushing to cloud.
|
|
85
|
+
*/
|
|
86
|
+
toRemote?: (descriptor: Record<string, unknown>) => Record<string, unknown>;
|
|
87
|
+
/**
|
|
88
|
+
* Transform an API response record into a local runtime descriptor shape.
|
|
89
|
+
* Called after pulling from cloud.
|
|
90
|
+
*/
|
|
91
|
+
fromRemote?: (record: Record<string, unknown>) => Record<string, unknown>;
|
|
92
|
+
/**
|
|
93
|
+
* Optional: Ensure remote prerequisites exist before pushing an entity.
|
|
94
|
+
* Useful when the remote API expects related resources (for example, a
|
|
95
|
+
* knowledge base) to exist before an item can be upserted.
|
|
96
|
+
*/
|
|
97
|
+
beforePush?: (descriptor: Record<string, unknown>, context: {
|
|
98
|
+
apiEndpoint: string;
|
|
99
|
+
apiToken?: string;
|
|
100
|
+
fetch: (input: string, init?: RequestInit) => Promise<Response>;
|
|
101
|
+
}) => Promise<void>;
|
|
102
|
+
deleteRemote?: (descriptor: Record<string, unknown>, context: {
|
|
103
|
+
apiEndpoint: string;
|
|
104
|
+
apiToken?: string;
|
|
105
|
+
fetch: (input: string, init?: RequestInit) => Promise<Response>;
|
|
106
|
+
}) => Promise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* Optional: Custom collection function. Defaults to runtime.query(source.runtimeKind).descriptors()
|
|
109
|
+
*/
|
|
110
|
+
collect?: () => Promise<Record<string, unknown>[]> | Record<string, unknown>[];
|
|
111
|
+
/**
|
|
112
|
+
* Optional: Storage manifest ID for persisting pulled items.
|
|
113
|
+
* When set, pulled items are merged into this storage manifest (localdb/json).
|
|
114
|
+
* When omitted, pulled items are only registered with the runtime (descriptor-only bridges).
|
|
115
|
+
*/
|
|
116
|
+
storageManifestId?: string;
|
|
117
|
+
/**
|
|
118
|
+
* Optional: Custom write function for pulled items.
|
|
119
|
+
* Called when a remote-only item needs to be persisted locally.
|
|
120
|
+
* When omitted and storageManifestId is set, uses StorageManifest.load/save.
|
|
121
|
+
*/
|
|
122
|
+
writePulled?: (items: Record<string, unknown>[]) => Promise<void>;
|
|
123
|
+
};
|
|
124
|
+
//# sourceMappingURL=sync-bridge-descriptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-bridge-descriptor.d.ts","sourceRoot":"","sources":["../../src/schemas/sync-bridge-descriptor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAG5B,eAAO,MAAM,mBAAmB;;;;EAAsD,CAAC;AACvF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,eAAO,MAAM,sBAAsB;;;;;EAA4D,CAAC;AAChG,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,eAAO,MAAM,qBAAqB;;;;EAA8C,CAAC;AACjF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE;;;;GAIG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0DvB,CAAC;AAEjB,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,GAAG;IAC/E;;;OAGG;IACH,Q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