@async/db 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +167 -0
- package/README.md +431 -0
- package/SPEC.md +1429 -0
- package/db.config.example.mjs +128 -0
- package/dist/cli/args.d.ts +8 -0
- package/dist/cli/args.js +16 -0
- package/dist/cli/commands/create.d.ts +3 -0
- package/dist/cli/commands/create.js +13 -0
- package/dist/cli/commands/doctor.d.ts +3 -0
- package/dist/cli/commands/doctor.js +31 -0
- package/dist/cli/commands/generate.d.ts +6 -0
- package/dist/cli/commands/generate.js +24 -0
- package/dist/cli/commands/operations.d.ts +12 -0
- package/dist/cli/commands/operations.js +61 -0
- package/dist/cli/commands/schema.d.ts +11 -0
- package/dist/cli/commands/schema.js +1086 -0
- package/dist/cli/commands/serve.d.ts +9 -0
- package/dist/cli/commands/serve.js +18 -0
- package/dist/cli/commands/sync.d.ts +3 -0
- package/dist/cli/commands/sync.js +11 -0
- package/dist/cli/commands/types.d.ts +7 -0
- package/dist/cli/commands/types.js +37 -0
- package/dist/cli/commands/viewer.d.ts +6 -0
- package/dist/cli/commands/viewer.js +29 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +108 -0
- package/dist/cli/output.d.ts +25 -0
- package/dist/cli/output.js +149 -0
- package/dist/cli/schema-prompt.d.ts +20 -0
- package/dist/cli/schema-prompt.js +66 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +3 -0
- package/dist/client-cache.d.ts +105 -0
- package/dist/client-cache.js +916 -0
- package/dist/client.d.ts +64 -0
- package/dist/client.js +405 -0
- package/dist/config-public.d.ts +1 -0
- package/dist/config-public.js +1 -0
- package/dist/config.d.ts +54 -0
- package/dist/config.js +2 -0
- package/dist/csv.d.ts +1 -0
- package/dist/csv.js +1 -0
- package/dist/db.d.ts +3 -0
- package/dist/db.js +3 -0
- package/dist/doctor.d.ts +1 -0
- package/dist/doctor.js +1 -0
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +1 -0
- package/dist/features/config/defaults.d.ts +98 -0
- package/dist/features/config/defaults.js +95 -0
- package/dist/features/config/load.d.ts +11 -0
- package/dist/features/config/load.js +265 -0
- package/dist/features/config/public.d.ts +17 -0
- package/dist/features/config/public.js +75 -0
- package/dist/features/doctor/duplicate-ids.d.ts +18 -0
- package/dist/features/doctor/duplicate-ids.js +79 -0
- package/dist/features/doctor/field-consistency.d.ts +17 -0
- package/dist/features/doctor/field-consistency.js +48 -0
- package/dist/features/doctor/index.d.ts +39 -0
- package/dist/features/doctor/index.js +177 -0
- package/dist/features/doctor/relations.d.ts +22 -0
- package/dist/features/doctor/relations.js +90 -0
- package/dist/features/doctor/schema-guidance.d.ts +35 -0
- package/dist/features/doctor/schema-guidance.js +184 -0
- package/dist/features/generate/registry.d.ts +14 -0
- package/dist/features/generate/registry.js +37 -0
- package/dist/features/http/registry.d.ts +46 -0
- package/dist/features/http/registry.js +86 -0
- package/dist/features/operations/index.d.ts +49 -0
- package/dist/features/operations/index.js +199 -0
- package/dist/features/operations/maps.d.ts +1 -0
- package/dist/features/operations/maps.js +10 -0
- package/dist/features/operations/readiness.d.ts +30 -0
- package/dist/features/operations/readiness.js +228 -0
- package/dist/features/operations/runtime.d.ts +57 -0
- package/dist/features/operations/runtime.js +288 -0
- package/dist/features/runtime/collection.d.ts +51 -0
- package/dist/features/runtime/collection.js +198 -0
- package/dist/features/runtime/db.d.ts +152 -0
- package/dist/features/runtime/db.js +824 -0
- package/dist/features/runtime/document.d.ts +43 -0
- package/dist/features/runtime/document.js +111 -0
- package/dist/features/runtime/fanout.d.ts +24 -0
- package/dist/features/runtime/fanout.js +77 -0
- package/dist/features/runtime/json-pointer.d.ts +5 -0
- package/dist/features/runtime/json-pointer.js +49 -0
- package/dist/features/runtime/scope-state.d.ts +44 -0
- package/dist/features/runtime/scope-state.js +185 -0
- package/dist/features/runtime/state.d.ts +1 -0
- package/dist/features/runtime/state.js +1 -0
- package/dist/features/schema/api.d.ts +107 -0
- package/dist/features/schema/api.js +460 -0
- package/dist/features/schema/builders.d.ts +86 -0
- package/dist/features/schema/builders.js +110 -0
- package/dist/features/schema/fields.d.ts +38 -0
- package/dist/features/schema/fields.js +296 -0
- package/dist/features/schema/generated.d.ts +29 -0
- package/dist/features/schema/generated.js +32 -0
- package/dist/features/schema/locator.d.ts +16 -0
- package/dist/features/schema/locator.js +135 -0
- package/dist/features/schema/manifest.d.ts +91 -0
- package/dist/features/schema/manifest.js +384 -0
- package/dist/features/schema/metadata.d.ts +30 -0
- package/dist/features/schema/metadata.js +75 -0
- package/dist/features/schema/project.d.ts +46 -0
- package/dist/features/schema/project.js +442 -0
- package/dist/features/schema/relations.d.ts +38 -0
- package/dist/features/schema/relations.js +109 -0
- package/dist/features/schema/resolvers.d.ts +36 -0
- package/dist/features/schema/resolvers.js +111 -0
- package/dist/features/schema/resource.d.ts +75 -0
- package/dist/features/schema/resource.js +253 -0
- package/dist/features/schema/source-definitions.d.ts +21 -0
- package/dist/features/schema/source-definitions.js +29 -0
- package/dist/features/schema/sources.d.ts +83 -0
- package/dist/features/schema/sources.js +689 -0
- package/dist/features/schema/standard-schema.d.ts +57 -0
- package/dist/features/schema/standard-schema.js +232 -0
- package/dist/features/schema/validation.d.ts +69 -0
- package/dist/features/schema/validation.js +434 -0
- package/dist/features/storage/events.d.ts +12 -0
- package/dist/features/storage/events.js +30 -0
- package/dist/features/storage/json.d.ts +112 -0
- package/dist/features/storage/json.js +239 -0
- package/dist/features/storage/memory.d.ts +30 -0
- package/dist/features/storage/memory.js +44 -0
- package/dist/features/storage/resource-json.d.ts +31 -0
- package/dist/features/storage/resource-json.js +76 -0
- package/dist/features/storage/runtime.d.ts +37 -0
- package/dist/features/storage/runtime.js +184 -0
- package/dist/features/storage/source-metadata.d.ts +20 -0
- package/dist/features/storage/source-metadata.js +25 -0
- package/dist/features/storage/source.d.ts +37 -0
- package/dist/features/storage/source.js +60 -0
- package/dist/features/storage/static.d.ts +29 -0
- package/dist/features/storage/static.js +42 -0
- package/dist/features/sync/defaults.d.ts +21 -0
- package/dist/features/sync/defaults.js +21 -0
- package/dist/features/sync/index.d.ts +35 -0
- package/dist/features/sync/index.js +85 -0
- package/dist/features/sync/mirror-state.d.ts +14 -0
- package/dist/features/sync/mirror-state.js +4 -0
- package/dist/features/sync/runtime-dirs.d.ts +5 -0
- package/dist/features/sync/runtime-dirs.js +9 -0
- package/dist/features/sync/source-writes.d.ts +15 -0
- package/dist/features/sync/source-writes.js +27 -0
- package/dist/features/sync/synthetic-seed.d.ts +26 -0
- package/dist/features/sync/synthetic-seed.js +83 -0
- package/dist/features/viewer/manifest.d.ts +148 -0
- package/dist/features/viewer/manifest.js +165 -0
- package/dist/fs-utils.d.ts +1 -0
- package/dist/fs-utils.js +1 -0
- package/dist/generate/hono/app.d.ts +6 -0
- package/dist/generate/hono/app.js +51 -0
- package/dist/generate/hono/graphql.d.ts +7 -0
- package/dist/generate/hono/graphql.js +53 -0
- package/dist/generate/hono/index.d.ts +55 -0
- package/dist/generate/hono/index.js +140 -0
- package/dist/generate/hono/package.d.ts +6 -0
- package/dist/generate/hono/package.js +44 -0
- package/dist/generate/hono/readme.d.ts +13 -0
- package/dist/generate/hono/readme.js +28 -0
- package/dist/generate/hono/repository.d.ts +1 -0
- package/dist/generate/hono/repository.js +27 -0
- package/dist/generate/hono/rest.d.ts +1 -0
- package/dist/generate/hono/rest.js +38 -0
- package/dist/generate/hono/schema.d.ts +13 -0
- package/dist/generate/hono/schema.js +18 -0
- package/dist/generate/hono/sqlite.d.ts +20 -0
- package/dist/generate/hono/sqlite.js +266 -0
- package/dist/generate/hono/validators.d.ts +1 -0
- package/dist/generate/hono/validators.js +141 -0
- package/dist/generate/hono.d.ts +1 -0
- package/dist/generate/hono.js +1 -0
- package/dist/graphql/execute.d.ts +14 -0
- package/dist/graphql/execute.js +719 -0
- package/dist/graphql/http.d.ts +15 -0
- package/dist/graphql/http.js +29 -0
- package/dist/graphql/index.d.ts +3 -0
- package/dist/graphql/index.js +3 -0
- package/dist/graphql/parser.d.ts +54 -0
- package/dist/graphql/parser.js +433 -0
- package/dist/hono.d.ts +77 -0
- package/dist/hono.js +1 -0
- package/dist/index.d.ts +1065 -0
- package/dist/index.js +14 -0
- package/dist/integrations/hono.d.ts +136 -0
- package/dist/integrations/hono.js +508 -0
- package/dist/integrations/kv.d.ts +69 -0
- package/dist/integrations/kv.js +69 -0
- package/dist/integrations/postgres.d.ts +52 -0
- package/dist/integrations/postgres.js +113 -0
- package/dist/integrations/sqlite.d.ts +112 -0
- package/dist/integrations/sqlite.js +489 -0
- package/dist/integrations/vite.d.ts +45 -0
- package/dist/integrations/vite.js +111 -0
- package/dist/json.d.ts +48 -0
- package/dist/json.js +1 -0
- package/dist/jsonc.d.ts +1 -0
- package/dist/jsonc.js +1 -0
- package/dist/kv.d.ts +24 -0
- package/dist/kv.js +1 -0
- package/dist/mock.d.ts +1 -0
- package/dist/mock.js +1 -0
- package/dist/names.d.ts +1 -0
- package/dist/names.js +1 -0
- package/dist/operations.d.ts +3 -0
- package/dist/operations.js +3 -0
- package/dist/postgres.d.ts +24 -0
- package/dist/postgres.js +1 -0
- package/dist/redis.d.ts +14 -0
- package/dist/redis.js +1 -0
- package/dist/rest/formats.d.ts +80 -0
- package/dist/rest/formats.js +318 -0
- package/dist/rest/handler.d.ts +111 -0
- package/dist/rest/handler.js +833 -0
- package/dist/rest/shape.d.ts +33 -0
- package/dist/rest/shape.js +218 -0
- package/dist/schema-builders.d.ts +1 -0
- package/dist/schema-builders.js +1 -0
- package/dist/schema-manifest.d.ts +1 -0
- package/dist/schema-manifest.js +1 -0
- package/dist/schema.d.ts +193 -0
- package/dist/schema.js +6 -0
- package/dist/server.d.ts +116 -0
- package/dist/server.js +601 -0
- package/dist/shared/csv.d.ts +8 -0
- package/dist/shared/csv.js +149 -0
- package/dist/shared/errors.d.ts +40 -0
- package/dist/shared/errors.js +55 -0
- package/dist/shared/fs-utils.d.ts +4 -0
- package/dist/shared/fs-utils.js +30 -0
- package/dist/shared/jsonc.d.ts +2 -0
- package/dist/shared/jsonc.js +99 -0
- package/dist/shared/mock.d.ts +40 -0
- package/dist/shared/mock.js +83 -0
- package/dist/shared/names.d.ts +28 -0
- package/dist/shared/names.js +127 -0
- package/dist/shared/operations.d.ts +32 -0
- package/dist/shared/operations.js +302 -0
- package/dist/sqlite.d.ts +24 -0
- package/dist/sqlite.js +1 -0
- package/dist/state.d.ts +1 -0
- package/dist/state.js +1 -0
- package/dist/sync.d.ts +1 -0
- package/dist/sync.js +1 -0
- package/dist/tracing.d.ts +95 -0
- package/dist/tracing.js +260 -0
- package/dist/types.d.ts +51 -0
- package/dist/types.js +285 -0
- package/dist/viewer-manifest.d.ts +1 -0
- package/dist/viewer-manifest.js +1 -0
- package/dist/vite.d.ts +59 -0
- package/dist/vite.js +1 -0
- package/dist/web/json-viewer.d.ts +5 -0
- package/dist/web/json-viewer.js +176 -0
- package/dist/web/viewer.d.ts +12 -0
- package/dist/web/viewer.js +1015 -0
- package/docs/README.md +42 -0
- package/docs/architecture.md +112 -0
- package/docs/ci-and-release.md +177 -0
- package/docs/cms-storage-patterns.md +108 -0
- package/docs/concepts.md +141 -0
- package/docs/configuration.md +552 -0
- package/docs/fixtures-and-schemas.md +527 -0
- package/docs/fork-branch-workflows.md +108 -0
- package/docs/generated-files.md +174 -0
- package/docs/getting-started.md +165 -0
- package/docs/integrations.md +206 -0
- package/docs/json-production.md +120 -0
- package/docs/package-api.md +418 -0
- package/docs/prototype-to-production.md +378 -0
- package/docs/server-and-viewer.md +466 -0
- package/docs/store-graduation.md +120 -0
- package/docs/typescript-schema-sources.md +79 -0
- package/examples/advanced/README.md +55 -0
- package/examples/advanced/db/projects.schema.jsonc +44 -0
- package/examples/advanced/db/settings.jsonc +9 -0
- package/examples/advanced/db/users.json +23 -0
- package/examples/advanced/db/users.schema.mjs +31 -0
- package/examples/advanced/db.config.mjs +18 -0
- package/examples/advanced/example.json +5 -0
- package/examples/advanced/src/generated/db.types.d.ts +64 -0
- package/examples/basic/README.md +95 -0
- package/examples/basic/db/operations/get-user.jsonc +8 -0
- package/examples/basic/db/settings.json +7 -0
- package/examples/basic/db/users.schema.jsonc +36 -0
- package/examples/basic/db.config.mjs +68 -0
- package/examples/basic/example.json +5 -0
- package/examples/basic/src/generated/db.types.d.ts +39 -0
- package/examples/cms-json-publish/README.md +21 -0
- package/examples/cms-json-publish/db/navigation.json +7 -0
- package/examples/cms-json-publish/db/pages.json +18 -0
- package/examples/cms-json-publish/example.json +5 -0
- package/examples/cms-json-publish/src/cms.mjs +104 -0
- package/examples/computed-fields/README.md +93 -0
- package/examples/computed-fields/db/orders.schema.mjs +62 -0
- package/examples/computed-fields/db/posts.schema.mjs +59 -0
- package/examples/computed-fields/db/products.schema.mjs +39 -0
- package/examples/computed-fields/db/users.schema.mjs +43 -0
- package/examples/computed-fields/db.config.mjs +15 -0
- package/examples/computed-fields/example.json +5 -0
- package/examples/computed-fields/src/generated/db.types.d.ts +81 -0
- package/examples/content-collections/README.md +91 -0
- package/examples/content-collections/db/authors.json +12 -0
- package/examples/content-collections/db/authors.schema.mjs +20 -0
- package/examples/content-collections/db/blog/draft-roadmap.mdx +12 -0
- package/examples/content-collections/db/blog/index.schema.mjs +61 -0
- package/examples/content-collections/db/blog/launch-notes.mdx +15 -0
- package/examples/content-collections/db/docs/index.schema.mjs +32 -0
- package/examples/content-collections/db/docs/intro.mdx +11 -0
- package/examples/content-collections/db/docs/schema-workflow.mdx +10 -0
- package/examples/content-collections/db/site.schema.jsonc +21 -0
- package/examples/content-collections/db.config.mjs +26 -0
- package/examples/content-collections/example.json +5 -0
- package/examples/content-collections/src/content-preview.mjs +66 -0
- package/examples/content-collections/src/generated/db.types.d.ts +81 -0
- package/examples/csv/README.md +52 -0
- package/examples/csv/db/customers.csv +4 -0
- package/examples/csv/db.config.mjs +13 -0
- package/examples/csv/example.json +5 -0
- package/examples/data-first/README.md +54 -0
- package/examples/data-first/db/posts.json +16 -0
- package/examples/data-first/db/settings.json +8 -0
- package/examples/data-first/db/users.json +14 -0
- package/examples/data-first/db.config.mjs +13 -0
- package/examples/data-first/example.json +5 -0
- package/examples/diagnostics/README.md +55 -0
- package/examples/diagnostics/db/projects.schema.jsonc +27 -0
- package/examples/diagnostics/db/users.json +9 -0
- package/examples/diagnostics/db/users.schema.jsonc +23 -0
- package/examples/diagnostics/db.config.mjs +16 -0
- package/examples/diagnostics/example.json +5 -0
- package/examples/free-plan-upgrade/README.md +22 -0
- package/examples/free-plan-upgrade/db/appSettings.json +4 -0
- package/examples/free-plan-upgrade/db/projects.json +7 -0
- package/examples/free-plan-upgrade/example.json +5 -0
- package/examples/free-plan-upgrade/src/upgrade-tenant-to-paid.mjs +105 -0
- package/examples/hono-auth/README.md +74 -0
- package/examples/hono-auth/db/pages.schema.jsonc +44 -0
- package/examples/hono-auth/db/users.schema.jsonc +42 -0
- package/examples/hono-auth/db.config.mjs +17 -0
- package/examples/hono-auth/example.json +5 -0
- package/examples/hono-auth/package.json +14 -0
- package/examples/hono-auth/src/app.mjs +79 -0
- package/examples/hono-auth/src/server.mjs +13 -0
- package/examples/production-json/README.md +102 -0
- package/examples/production-json/db/appSettings.schema.jsonc +41 -0
- package/examples/production-json/db/featureFlags.schema.jsonc +84 -0
- package/examples/production-json/db/operations/get-control-plane.jsonc +6 -0
- package/examples/production-json/db/operations/get-feature-flag.jsonc +9 -0
- package/examples/production-json/db/operations/list-feature-flags.jsonc +8 -0
- package/examples/production-json/db/operations/read-public-settings.jsonc +8 -0
- package/examples/production-json/db.config.mjs +33 -0
- package/examples/production-json/example.json +5 -0
- package/examples/production-json/src/client-demo.mjs +28 -0
- package/examples/production-json/src/generated/db.types.d.ts +60 -0
- package/examples/relations/README.md +56 -0
- package/examples/relations/db/posts.schema.jsonc +46 -0
- package/examples/relations/db/users.schema.jsonc +34 -0
- package/examples/relations/db.config.mjs +13 -0
- package/examples/relations/example.json +5 -0
- package/examples/rest-client/README.md +54 -0
- package/examples/rest-client/db/settings.json +5 -0
- package/examples/rest-client/db/users.schema.jsonc +42 -0
- package/examples/rest-client/db.config.mjs +13 -0
- package/examples/rest-client/example.json +5 -0
- package/examples/rest-client/src/client-demo.mjs +24 -0
- package/examples/schema-first/README.md +55 -0
- package/examples/schema-first/db/auditEvents.schema.jsonc +24 -0
- package/examples/schema-first/db/settings.schema.jsonc +29 -0
- package/examples/schema-first/db/users.schema.jsonc +36 -0
- package/examples/schema-first/db.config.mjs +15 -0
- package/examples/schema-first/example.json +5 -0
- package/examples/schema-first/src/generated/db.types.d.ts +47 -0
- package/examples/schema-manifest/README.md +50 -0
- package/examples/schema-manifest/db/projects.schema.jsonc +48 -0
- package/examples/schema-manifest/db/users.schema.jsonc +35 -0
- package/examples/schema-manifest/db.config.mjs +41 -0
- package/examples/schema-manifest/example.json +5 -0
- package/examples/schema-manifest/src/generated/db.schema.json +130 -0
- package/examples/schema-manifest/src/generated/db.types.d.ts +50 -0
- package/examples/schema-ui/README.md +103 -0
- package/examples/schema-ui/db/pages.schema.jsonc +53 -0
- package/examples/schema-ui/db/users.schema.jsonc +30 -0
- package/examples/schema-ui/db.config.mjs +55 -0
- package/examples/schema-ui/example.json +5 -0
- package/examples/schema-ui/src/cms-ssr.mjs +276 -0
- package/examples/schema-ui/src/generated/db.schema.json +133 -0
- package/examples/schema-ui/src/generated/db.types.d.ts +46 -0
- package/examples/schema-ui/src/render-admin.mjs +175 -0
- package/examples/schema-ui/src/schema-ui-ssr-handler.mjs +149 -0
- package/examples/schema-ui/src/start-schema-ui-server.mjs +140 -0
- package/examples/standard-schema/README.md +55 -0
- package/examples/standard-schema/db/settings.schema.mjs +22 -0
- package/examples/standard-schema/db/users.schema.mjs +72 -0
- package/examples/standard-schema/example.json +5 -0
- package/package.json +108 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.2.0](https://github.com/async-framework/async-db/releases/tag/v0.2.0) - 2026-06-01
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Added first-class `@async/db/json` production helpers, diagnostics, and JSON store examples for file-suitable app resources.
|
|
8
|
+
- Added logical fork, branch, snapshot, routing, and migration primitives for tenant isolation, preview branches, debug copies, and store graduation workflows.
|
|
9
|
+
- Added production JSON guidance and examples for feature flags, settings, CMS publishing, free-plan upgrades, debug snapshots, policy sandboxes, prompt experiments, and mixed JSON/database resources.
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- Replaced the unused legacy fixture-folder fork model with explicit fork and branch lifecycle APIs.
|
|
14
|
+
- Moved fork and branch classification into user-owned metadata instead of a separate `kind` field.
|
|
15
|
+
- Tightened lifecycle behavior so scoped fork/branch access requires created registry entries.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- Fixed CI and release workflows so they install pinned pnpm dependencies before running package checks.
|
|
20
|
+
|
|
21
|
+
## [0.1.0](https://github.com/async-framework/async-db/releases/tag/v0.1.0) - 2026-05-28
|
|
22
|
+
|
|
23
|
+
First public release of `@async/db`.
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
|
|
27
|
+
- Data-first JSON, JSONC, and CSV fixture loading from `db/`, with schema inference, generated TypeScript types, and a writable `.db/state` runtime mirror.
|
|
28
|
+
- `async-db` CLI commands for sync, type generation, schema inspection, schema validation, doctor checks, local serving, viewer manifests, operations contracts, and Hono/SQLite starter generation.
|
|
29
|
+
- Package APIs for opening databases, loading schema metadata, validating schema-backed writes, serving dependency-free REST and GraphQL routes, and calling local APIs through the HTTP client.
|
|
30
|
+
- Optional Vite, Hono, SQLite, Postgres, KV, and Redis-style integration surfaces without mandatory runtime dependencies.
|
|
31
|
+
- Built-in local viewer at `/__db`, viewer manifests, REST format negotiation, request tracing, CSV import, registered operations, and opt-in browser cache support.
|
|
32
|
+
- Runnable examples for data-first fixtures, schema-backed fixtures, REST clients, relations, schema manifests, schema UI, Hono auth, content collections, computed fields, CSV, diagnostics, and Standard Schema validators.
|
|
33
|
+
- Release automation for future version bumps, changelog updates, GitHub releases, and npm publishing.
|
|
34
|
+
|
|
35
|
+
### Notes
|
|
36
|
+
|
|
37
|
+
- `@async/db` is local development and test infrastructure. Do not expose `async-db serve` as a production database or auth boundary.
|
|
38
|
+
- The first npm package is published under the scoped package name `@async/db`; the CLI binary remains `async-db`.
|
|
39
|
+
|
|
40
|
+
Dates are commit dates from the git history. Changelog-only maintenance commits
|
|
41
|
+
are omitted. Commit links point at the canonical GitHub repository:
|
|
42
|
+
<https://github.com/async-framework/async-db>.
|
|
43
|
+
|
|
44
|
+
## Pre-Release Feature History
|
|
45
|
+
|
|
46
|
+
### Project Foundation
|
|
47
|
+
|
|
48
|
+
- 2026-05-07 - Created the dependency-light Node.js ESM package with JSON/JSONC fixture loading, schema helpers, runtime mirror sync, generated TypeScript types, a CLI, and the basic example project. Commit [4ee9630](https://github.com/async-framework/async-db/commit/4ee9630d84739f738eb8d6add2deb311ad725303).
|
|
49
|
+
- 2026-05-07 - Added CI, Dependabot, repository agent guidance, and the package check script. Commit [1d9600c](https://github.com/async-framework/async-db/commit/1d9600cec0ea4a994436ce315e7ab9bb553bf9ce).
|
|
50
|
+
- 2026-05-07 - Clarified the basic README instructions for `db/users.json`. Commit [836aade](https://github.com/async-framework/async-db/commit/836aade4dae66119983d06545fe003b5b549f2fb).
|
|
51
|
+
- 2026-05-20 - Rebranded the project from `jsondb` to `@async/db`, including the package name, `async-db` CLI, `db.config.mjs`, `.db` runtime output, `/__db` dev-tool routes, generated file names, docs, examples, tests, and public API wording. Commit [6b8b37b](https://github.com/async-framework/async-db/commit/6b8b37bd6affcc3207f1e3915c7632207638ef90).
|
|
52
|
+
|
|
53
|
+
### Runtime API, REST, and Server
|
|
54
|
+
|
|
55
|
+
- 2026-05-07 - Added the REST runtime, GraphQL runtime, GraphQL parser, HTTP handlers, and protocol tests. Commit [d24dd9a](https://github.com/async-framework/async-db/commit/d24dd9adb0a33e85d29dc921b9c055bfc644c31c).
|
|
56
|
+
- 2026-05-07 - Added structured `DbError` handling for clearer API and server failures. Commit [f25659e](https://github.com/async-framework/async-db/commit/f25659e66ff19f2fd0a32653784fbeef9994dad9).
|
|
57
|
+
- 2026-05-07 - Added schema-backed validation, request body limits, and safer batching behavior. Commit [af60a9c](https://github.com/async-framework/async-db/commit/af60a9c4a98514aef1f56cb70530db7d15777dbf).
|
|
58
|
+
- 2026-05-11 - Renamed the package-facing API to `db` and added an embeddable request handler for mounting db into other servers. Commit [0b7f9d5](https://github.com/async-framework/async-db/commit/0b7f9d51519f9f14fb8e9d97abb90a5ea062a96a).
|
|
59
|
+
- 2026-05-14 - Added pluggable runtimes, runtime write events, an HTTP feature registry, and a `/__db/log` server-sent event stream. Commit [69337fa](https://github.com/async-framework/async-db/commit/69337fa347fa20f6186f5afd70d95fb766c561ea).
|
|
60
|
+
- 2026-05-14 - Added the `source` runtime for reading and writing source-backed JSON fixtures, with source metadata hydration and dot-folder ignoring. Commit [80ecfff](https://github.com/async-framework/async-db/commit/80ecfffcd8c969902f9552e0b421ff8adc9c7e96).
|
|
61
|
+
- 2026-05-14 - Avoided redundant disk writes by skipping unchanged output, preserving generated metadata, and centralizing source metadata updates. Commits [9ec39b1](https://github.com/async-framework/async-db/commit/9ec39b11e0a93de72e6b62d3187a379aaccc4ede) and [c14e799](https://github.com/async-framework/async-db/commit/c14e79933091f54a4ce98d9a7eb9e6c10ffd8085).
|
|
62
|
+
- 2026-05-14 - Added `DbCollection.exists()` to the package API and SQLite adapter. Commit [9586d5f](https://github.com/async-framework/async-db/commit/9586d5f2e1fc6211fe9cb2b2ba9b8f5e7bcfaabe).
|
|
63
|
+
- 2026-05-19 - Replaced runtime mode config with store-based resource binding, named stores, custom store wrappers, per-store write queues, `sqliteStore()`, `Db.close()`, legacy config migration diagnostics, store doctor checks, and source writeback through the `sourceFile` store. Commit [4f77e1e](https://github.com/async-framework/async-db/commit/4f77e1e93e4336938fc3d005923d9967f9dfac03).
|
|
64
|
+
- 2026-05-19 - Added `server.apiBase` for scoping built-in dev-tool routes while preserving root REST resources and `/graphql`, including client, Vite, mock, batch path, and fork route support. Commit [caa9f99](https://github.com/async-framework/async-db/commit/caa9f9970e48515fcd22f2ca80a98a557c8e1291).
|
|
65
|
+
- 2026-05-20 - Added `rest.enabled` and `graphql.enabled` toggles so apps can disable generated REST resource routes, REST batching, or the GraphQL endpoint while keeping viewer, schema, manifest, import, events, and other dev-tool routes available, with structured disabled-feature errors and discovery/manifest capability reporting. Commit [4698795](https://github.com/async-framework/async-db/commit/469879538d79635b79052a231043b2f8c12d123f).
|
|
66
|
+
- 2026-05-20 - Added registered operations with stable hashes, manifest and ref output, `async-db operations build`, `buildOperationManifest()`, `hashOperation()`, `client.operation()` / `client.query()`, `POST /__db/operations/:ref`, `operations.enabled`, route exposure policies, and REST/GraphQL operation execution by name or hash. Commits [b6b0d83](https://github.com/async-framework/async-db/commit/b6b0d83a818cc1a6aee6fc240a4df85d78e579c9) and [639dfa1](https://github.com/async-framework/async-db/commit/639dfa197e60541323df3de87fcd93edea1580d7).
|
|
67
|
+
- 2026-05-20 - Added opt-in request tracing with `x-async-db-request-id`, route/resource/operation metadata, safe query-key capture, phase timings, slow-request labeling, runtime log events, concise console output, and standalone, Vite, and Hono trace overrides without recording request bodies, response bodies, cookies, or authorization headers. Commit [ed9b643](https://github.com/async-framework/async-db/commit/ed9b643584d067967d1a4afdbe2329787090fadf).
|
|
68
|
+
- 2026-05-20 - Added a deterministic operations contract workflow with `async-db operations contract`, `--out` and `--check` support, first-class server registry versus client-safe refs handling, runtime operation maps, Hono operation mounting, and updated operation tooling/docs for prototype-to-production REST flows. Commit [d73312d](https://github.com/async-framework/async-db/commit/d73312df380685087aa408fd735650b88918eaa9).
|
|
69
|
+
- 2026-05-20 - Required a resolvable operations setup before `server.expose.rest: 'registered-only'` can start, with early server failures, `OPERATIONS_STRICT_MODE_WITHOUT_OPERATIONS` diagnostics, doctor guidance, robust empty/missing operation source handling, and exported registry/source-loading helpers. Commit [53cc09a](https://github.com/async-framework/async-db/commit/53cc09af6c4f7664876b285fb5ac4853cb1147ca).
|
|
70
|
+
- 2026-05-24 - Added the schema-first package API with `loadDbSchema({ from })`, schema validators, direct field resolver binding through delegated resolver context, metadata-only schema loading, and `openDb({ schema })` runtime reuse. Commit [209d2a0](https://github.com/async-framework/async-db/commit/209d2a083b40a88c0e4ed61901099fb39f3285c5).
|
|
71
|
+
|
|
72
|
+
### Client, Viewer, Examples, and Mocking
|
|
73
|
+
|
|
74
|
+
- 2026-05-07 - Added the HTTP client, automatic and direct batching, example projects, built-in viewer, and mock behavior tests. Commit [d8373b1](https://github.com/async-framework/async-db/commit/d8373b16bf3b7d7aa7f1155b406b7082809c672c).
|
|
75
|
+
- 2026-05-07 - Added live reload, generated collection ids, source diagnostics, and viewer updates for broken source files. Commit [7e4cce7](https://github.com/async-framework/async-db/commit/7e4cce7d9abc57cb68464add8aac0c8da5b14e2a).
|
|
76
|
+
- 2026-05-14 - Expanded the example catalog with metadata, richer READMEs, relations, REST client, and schema-manifest examples, plus a metadata-driven examples index. Commit [0b4d31e](https://github.com/async-framework/async-db/commit/0b4d31e9329121a4e6c419451774e908360a021f).
|
|
77
|
+
- 2026-05-14 - Added the Hono auth example showing bearer-token auth, permission checks, lifecycle hooks, and write normalization. Commit [bbad836](https://github.com/async-framework/async-db/commit/bbad8360b4524e43f6ddddbef823cb6693a41248).
|
|
78
|
+
- 2026-05-19 - Added the schema-ui example with committed schema metadata, SSR admin rendering, per-example serve hooks, and the reusable example launcher. Commit [b633a28](https://github.com/async-framework/async-db/commit/b633a28152542ed926f6ca571edeb739753be444).
|
|
79
|
+
- 2026-05-19 - Added viewer manifests, `db viewer manifest`, `viewerManifestOutFile`, `server.viewerLinks`, manifest rendering, and committed viewer manifest sync output. Commit [9ffa49b](https://github.com/async-framework/async-db/commit/9ffa49bfbf9bf4c78854c3b6a93d9f4250e4f34d).
|
|
80
|
+
- 2026-05-20 - Added an opt-in normalized client cache with manifest indexing, REST and GraphQL read dedupe, read/write/event policies, watch subscriptions, storage snapshots, EventSource invalidation/refetch handling, Vite virtual-client cache configuration, and `createIndexedDbCacheStorage()` for persisted browser cache snapshots. Commit [7556eef](https://github.com/async-framework/async-db/commit/7556eef46f1d6cfb9a7b8c81fcf743ae96e8a176).
|
|
81
|
+
- 2026-05-24 - Added dependency-free content collections and computed-fields examples covering folder-backed MDX records, config-owned static stores, generated types, app-owned previews, and multiple computed resolver patterns. Commit [209d2a0](https://github.com/async-framework/async-db/commit/209d2a083b40a88c0e4ed61901099fb39f3285c5).
|
|
82
|
+
|
|
83
|
+
### CSV Fixtures and Import
|
|
84
|
+
|
|
85
|
+
- 2026-05-07 - Added CSV fixture loading, CSV examples, viewer CSV import, and CSV-backed sync support. Commit [6312e0b](https://github.com/async-framework/async-db/commit/6312e0bb4cccddbb2f264367dbfb6c5677dc9acb).
|
|
86
|
+
- 2026-05-11 - Added CSV array coercion for schema-backed CSV fixtures, including semicolon-delimited and JSON array string cells. Commit [28bf08b](https://github.com/async-framework/async-db/commit/28bf08b2d3fa014180c0d6128159f358340e12c1).
|
|
87
|
+
|
|
88
|
+
### Schema Sources, Types, and Validation
|
|
89
|
+
|
|
90
|
+
- 2026-05-07 - Added `.schema.json` support and synthetic seed generation for schema-first resources. Commit [03a5da9](https://github.com/async-framework/async-db/commit/03a5da95394177b3e7f714d0fd1abb2c103f84a9).
|
|
91
|
+
- 2026-05-11 - Added nullable fields, datetime fields, schema builder updates, and generated type support for those field shapes. Commit [28bf08b](https://github.com/async-framework/async-db/commit/28bf08b2d3fa014180c0d6128159f358340e12c1).
|
|
92
|
+
- 2026-05-11 - Added field constraints and unique-field validation across sync, package API writes, REST writes, GraphQL mutations, and schema validation. Commit [d38aa6b](https://github.com/async-framework/async-db/commit/d38aa6b3cc92018feb1818a34803c5bc8805cb21).
|
|
93
|
+
- 2026-05-14 - Added recursive nested fixture discovery, basename-derived resource names, recursive source watching, and nested schema-manifest context. Commit [27b3125](https://github.com/async-framework/async-db/commit/27b3125047906b90a156594e5be29e88ff37f1ba).
|
|
94
|
+
- 2026-05-14 - Added the custom source readers pipeline for user-defined formats, built-in reader normalization, source hashes, and structured reader diagnostics. Commit [53604b9](https://github.com/async-framework/async-db/commit/53604b93e162b4063655cdd49834ed6295cb5991).
|
|
95
|
+
- 2026-05-14 - Added `async-db schema infer`, doctor guidance for adding or removing schemas, and discriminated object variants in inference, validation, manifests, and generated TypeScript types. Commits [9586d5f](https://github.com/async-framework/async-db/commit/9586d5f2e1fc6211fe9cb2b2ba9b8f5e7bcfaabe) and [0d9bf62](https://github.com/async-framework/async-db/commit/0d9bf62efc1259ea51fe043725d9a0b134b5ad38).
|
|
96
|
+
- 2026-05-14 - Added `async-db schema bundle` / `unbundle` for moving inline seeds between schema and data fixtures, with mixed-mode warnings, safe output handling, overwrite controls, empty-seed support, and `--cwd`-relative output paths. Commits [f57a9cc](https://github.com/async-framework/async-db/commit/f57a9ccb0d28d285ce208367b4291efa3aed2806), [c0cb2fa](https://github.com/async-framework/async-db/commit/c0cb2fa2cf099dd51bf0f98358cb6fd288a28ae0), [e9618ec](https://github.com/async-framework/async-db/commit/e9618ecb5e7e45e0c75f960edec96441043801f1), and [353c861](https://github.com/async-framework/async-db/commit/353c861d085b7a58edf33ef379103a866aeb9f39).
|
|
97
|
+
- 2026-05-20 - Limited schema defaults to creates and safe additive runtime hydration; runtime updates, patches, document puts, SQLite writes, and generated Hono SQLite writes now preserve omitted fields instead of backfilling defaults. Commit [4698795](https://github.com/async-framework/async-db/commit/469879538d79635b79052a231043b2f8c12d123f).
|
|
98
|
+
- 2026-05-20 - Added `field.computed(...)` read-only schema fields with resolver and `resolveMany` fanout support, manifest/type metadata, REST and GraphQL selection-time projection, and validation that rejects computed field writes through package APIs, REST, GraphQL, and registered operations. Commit [b6b0d83](https://github.com/async-framework/async-db/commit/b6b0d83a818cc1a6aee6fc240a4df85d78e579c9).
|
|
99
|
+
- 2026-05-24 - Added the root `db.schema.mjs` registry, folder `index.schema.mjs` collection markers, `files(pattern, { read })` content sources, aggregate `schema bundle --all` / `unbundle --all`, interactive target prompts, schema-only root bundling with seed splitting, source-glob rebasing, inline resolver wrapper generation, and structured bundle/unbundle diagnostics. Commit [209d2a0](https://github.com/async-framework/async-db/commit/209d2a083b40a88c0e4ed61901099fb39f3285c5).
|
|
100
|
+
|
|
101
|
+
### Configuration
|
|
102
|
+
|
|
103
|
+
- 2026-05-11 - Added configurable fixture directories with `dbDir`, while preserving `sourceDir` compatibility. Commit [d5371c8](https://github.com/async-framework/async-db/commit/d5371c824d061e0bde11e8d9549dae7cc6709e9f).
|
|
104
|
+
- 2026-05-11 - Added `defineConfig`, config typings, the example config file, and expanded README configuration guidance. Commit [15f559b](https://github.com/async-framework/async-db/commit/15f559b42ba319c3d4ebf166ced04c73737eaadb).
|
|
105
|
+
- 2026-05-20 - Added unified `outputs` configuration for generated state, generated types, committed types, schema manifests, viewer manifests, operation registries, operation refs, and Hono starter output, replacing scattered committed-output options across docs, examples, fork config, and tests. Commit [d73312d](https://github.com/async-framework/async-db/commit/d73312df380685087aa408fd735650b88918eaa9).
|
|
106
|
+
|
|
107
|
+
### REST Shaping and Relations
|
|
108
|
+
|
|
109
|
+
- 2026-05-11 - Added REST response shaping with `select`, `offset`, and `limit`; added explicit depth-1 to-one relation metadata and `expand` support. Commit [d9f7c70](https://github.com/async-framework/async-db/commit/d9f7c7026d943a78ddf64688173e3c00089c6287).
|
|
110
|
+
- 2026-05-14 - Added REST response formats, fixture-based resource naming strategies, custom resource naming hooks, and duplicate-resource diagnostics. Commit [0c95b52](https://github.com/async-framework/async-db/commit/0c95b5237d3d4530f6f5cdf534df1358943cc1dc).
|
|
111
|
+
- 2026-05-14 - Added canonical resource alias resolution and collision diagnostics across CLI commands, runtime APIs, REST, SQLite, generated starters, schema loading, and the viewer. Commit [b7089b1](https://github.com/async-framework/async-db/commit/b7089b13d3cbca060d5b51fb04ccd8a89a87ad70).
|
|
112
|
+
- 2026-05-19 - Added a REST format registry with JSON/HTML/Markdown renderers, Accept negotiation, manifest-aware formatting, and richer viewer JSON rendering. Commit [9ffa49b](https://github.com/async-framework/async-db/commit/9ffa49bfbf9bf4c78854c3b6a93d9f4250e4f34d).
|
|
113
|
+
- 2026-05-20 - Documented and updated examples for fixture-like `/db/*.json` REST routes, including `db/<fixture>.json` to `GET /db/<fixture>.json` mapping, `?id=` guidance, extensionless route semantics, and rest-client demo paths. Commit [dca5ba0](https://github.com/async-framework/async-db/commit/dca5ba0a9de4c0ad356ef299f858e848c82fc48c).
|
|
114
|
+
|
|
115
|
+
### GraphQL
|
|
116
|
+
|
|
117
|
+
- 2026-05-11 - Added GraphQL `operationName` selection, named fragments, inline fragments, `@include`, `@skip`, `__typename`, and minimal `__schema` / `__type` introspection. Commit [f196625](https://github.com/async-framework/async-db/commit/f196625f2eb6c57d03565b35b0bdb7cafcb26efb).
|
|
118
|
+
- 2026-05-20 - Added shared required-`id` argument validation for single-record queries and update/delete mutations, plus expanded public GraphQL result and error typings. Commit [4698795](https://github.com/async-framework/async-db/commit/469879538d79635b79052a231043b2f8c12d123f).
|
|
119
|
+
- 2026-05-20 - Added registered GraphQL operation templates and server execution by name or hash while respecting `graphql.enabled`, with client `query()` support for GraphQL template objects. Commit [639dfa1](https://github.com/async-framework/async-db/commit/639dfa197e60541323df3de87fcd93edea1580d7).
|
|
120
|
+
|
|
121
|
+
### Doctor and Fixture Diagnostics
|
|
122
|
+
|
|
123
|
+
- 2026-05-11 - Added `async-db doctor` / `async-db check`, JSON output, strict mode, fixture diagnostics, relation suggestions, and fork health checks. Commit [22cb816](https://github.com/async-framework/async-db/commit/22cb8168daaa8779893e175ea23906e12a8f41fc).
|
|
124
|
+
- 2026-05-11 - Documented the `doctor` CLI health check behavior in the product spec. Commit [bf29064](https://github.com/async-framework/async-db/commit/bf2906458c944b18fa4a57f6de02ef9aacb3f153).
|
|
125
|
+
- 2026-05-11 - Added the shape-layer MVP with the Vite plugin, REST shaping, relation support, and doctor work. Commit [bea5776](https://github.com/async-framework/async-db/commit/bea5776816b6e20f65750e331e3b6330b59c7e51).
|
|
126
|
+
|
|
127
|
+
### Vite Integration
|
|
128
|
+
|
|
129
|
+
- 2026-05-11 - Added the dependency-light Vite dev-server plugin, scoped `/__db` routes, optional root REST routes, and the `virtual:db/client` module. Commit [d9f7c70](https://github.com/async-framework/async-db/commit/d9f7c7026d943a78ddf64688173e3c00089c6287).
|
|
130
|
+
- 2026-05-14 - Documented Vite watch behavior, generated artifact ignores, and guidance for avoiding unnecessary reloads while keeping runtime imports visible. Commit [8e0c2a3](https://github.com/async-framework/async-db/commit/8e0c2a3d9a35a64fa7676b3071a512d519e78dcf).
|
|
131
|
+
|
|
132
|
+
### Database Forks
|
|
133
|
+
|
|
134
|
+
- 2026-05-11 - Added configured database forks with separate fixture folders, fork-scoped runtime state, fork-aware clients, fork-scoped HTTP routes, Vite helpers, and diagnostics. Commit [1873c67](https://github.com/async-framework/async-db/commit/1873c6724b93137fbf736fb8f2310444dfe4b088).
|
|
135
|
+
|
|
136
|
+
### Schema Manifest
|
|
137
|
+
|
|
138
|
+
- 2026-05-11 - Added committed schema manifest generation for model-driven admin/CMS UIs, including `schemaOutFile`, `async-db schema manifest`, manifest render helpers, field UI hints, and customization hooks. Commit [7a2e819](https://github.com/async-framework/async-db/commit/7a2e8197ec0d5f0dc391e17ed429693e80147d10).
|
|
139
|
+
- 2026-05-11 - Landed the schema manifest work through PR #5. Commit [11a2d8d](https://github.com/async-framework/async-db/commit/11a2d8d31c97844d59d2ea7088fcd1ea0b40b686).
|
|
140
|
+
- 2026-05-14 - Added `customizeResource`, `mergeManifest`-based field and resource customization, resource naming support, and non-serializable customization diagnostics. Commit [0c95b52](https://github.com/async-framework/async-db/commit/0c95b5237d3d4530f6f5cdf534df1358943cc1dc).
|
|
141
|
+
|
|
142
|
+
### Hono and SQLite Graduation Path
|
|
143
|
+
|
|
144
|
+
- 2026-05-07 - Added the Hono and SQLite starter generator, optional Hono integration, optional SQLite adapter, generation CLI, and related tests. Commit [4e4770e](https://github.com/async-framework/async-db/commit/4e4770e71eb376a524562c2a739c2a41bc40b9ac).
|
|
145
|
+
- 2026-05-14 - Reused the opened Hono database promise in `dbContext` so middleware calls share one opened database instance. Commit [434c7b6](https://github.com/async-framework/async-db/commit/434c7b6be48320ff6d495f116a21a210d22b8f8b).
|
|
146
|
+
- 2026-05-14 - Added `registerDbRoutes` for Hono with route prefixes, resource include/exclude controls, method filters, global hooks, per-resource hooks, and short-circuiting. Commits [9586d5f](https://github.com/async-framework/async-db/commit/9586d5f2e1fc6211fe9cb2b2ba9b8f5e7bcfaabe) and [0d9bf62](https://github.com/async-framework/async-db/commit/0d9bf62efc1259ea51fe043725d9a0b134b5ad38).
|
|
147
|
+
- 2026-05-14 - Added Hono REST lifecycle hooks with `beforeRequest` and write-only `beforeWrite` handling, including hook ordering and short-circuit support. Commit [bbad836](https://github.com/async-framework/async-db/commit/bbad8360b4524e43f6ddddbef823cb6693a41248).
|
|
148
|
+
|
|
149
|
+
### External Stores
|
|
150
|
+
|
|
151
|
+
- 2026-05-20 - Added optional Postgres, generic KV, and Redis-named runtime store helpers using injected clients, with resource JSON envelope utilities, hydration and migration behavior, queued writes, close handling, alternate `get`/`set` adapter hooks, package exports, typings, and tests. Commit [639dfa1](https://github.com/async-framework/async-db/commit/639dfa197e60541323df3de87fcd93edea1580d7).
|
|
152
|
+
|
|
153
|
+
### Maintenance
|
|
154
|
+
|
|
155
|
+
- 2026-05-07 - Ignored the temporary folder in git. Commit [ad4e52a](https://github.com/async-framework/async-db/commit/ad4e52aac9ba2dc39eb320ec4262d660dfb7f2c3).
|
|
156
|
+
- 2026-05-11 - Bumped `actions/setup-node` from v4 to v6. Commit [d4b23e4](https://github.com/async-framework/async-db/commit/d4b23e4dd614c9367e4dbb512755124384fb5918).
|
|
157
|
+
- 2026-05-11 - Bumped `actions/checkout` from v4 to v6. Commit [7dffcc0](https://github.com/async-framework/async-db/commit/7dffcc0c70d5173fddf07ac23737a22dcabb9e49).
|
|
158
|
+
- 2026-05-14 - Split the monolithic test suite into focused test files for CLI, config, doctor, package, runtime, schema, sync, and examples coverage. Commit [e8e4e8e](https://github.com/async-framework/async-db/commit/e8e4e8e208b90707e664a9717a474b7cc8bec4fd).
|
|
159
|
+
- 2026-05-14 - Extracted schema logic into feature modules for fields, generated metadata, project loading, relations, resources, sources, and validation. Commit [4503af8](https://github.com/async-framework/async-db/commit/4503af8a19b6f6e1296347a90183c4eb93eef8c6).
|
|
160
|
+
- 2026-05-14 - Modularized the CLI, runtime, config, doctor, sync, integration, and generator code into feature and shared namespaces while preserving compatibility exports. Commit [d7de49b](https://github.com/async-framework/async-db/commit/d7de49b66fa3f59e8dcaf4905edd73920cbc80a4).
|
|
161
|
+
- 2026-05-14 - Added the May 14 source-reader, runtime, REST formatting, resource naming, schema-manifest, and modularization work together. Commit [58ac729](https://github.com/async-framework/async-db/commit/58ac729c7edf56da65512f2bd2e7181f1d7ff7f3).
|
|
162
|
+
- 2026-05-14 - Added architecture documentation, README and agent-guide cross-references, package globs for example metadata/source files, and command-specific CLI help handling. Commit [0b4d31e](https://github.com/async-framework/async-db/commit/0b4d31e9329121a4e6c419451774e908360a021f).
|
|
163
|
+
- 2026-05-14 - Printed subcommand help before loading project config, with focused help for `types`, `schema`, `doctor`, `serve`, and `generate`. Commit [0ba1c13](https://github.com/async-framework/async-db/commit/0ba1c13e9e3a4b4d35e5618fc94a7db3acfdfb9c).
|
|
164
|
+
- 2026-05-14 - Added redundant-write avoidance and generated metadata preservation together. Commit [d15b30c](https://github.com/async-framework/async-db/commit/d15b30c938ee216e9765ca6ef8fecafa664d6e32).
|
|
165
|
+
- 2026-05-19 - Restructured project documentation into a task-focused `docs/` handbook and expanded README coverage for schema metadata, GraphQL, file maps, examples, generated files, configuration, server/viewer behavior, package APIs, integrations, CI, and release guidance. Commits [8cce7d8](https://github.com/async-framework/async-db/commit/8cce7d80f856acb58aa2f64ec933c9dde42fe61d), [14d2a53](https://github.com/async-framework/async-db/commit/14d2a53b384ce4904c2d7869996497b4b63f9a9d), and [e5f104d](https://github.com/async-framework/async-db/commit/e5f104df1cd8263bae0912542be17fd21a28b29b).
|
|
166
|
+
- 2026-05-20 - Ignored generated `.jsondb/` output and removed generated example runtime artifacts, state snapshots, schema outputs, and generated type copies from `examples/*/.jsondb`. Commit [d54356d](https://github.com/async-framework/async-db/commit/d54356d61e44c242427a1e314a05177e70e803fb).
|
|
167
|
+
- 2026-05-20 - Pinned `actions/checkout` and `actions/setup-node` in CI to exact commit SHAs while keeping version comments, making GitHub Actions runs deterministic instead of relying on floating action tags. Commit [4bde6b5](https://github.com/async-framework/async-db/commit/4bde6b5a214e33584ce721df65fa89f1ccd63bc4).
|
package/README.md
ADDED
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
# @async/db
|
|
2
|
+
|
|
3
|
+
`@async/db` gives frontend teams a gradual path from mock JSON to production data contracts. You can keep easy fixture files where they work, use the first-party JSON file database for small low-write resources, and move other resources to SQLite, Postgres, or custom stores as they get serious. The app keeps talking to one data layer while persistence changes behind each resource.
|
|
4
|
+
|
|
5
|
+
Use it to:
|
|
6
|
+
|
|
7
|
+
- Start from editable JSON, JSONC, or CSV fixtures in `db/`.
|
|
8
|
+
- Infer schema contracts and generate TypeScript types from fixtures and schemas.
|
|
9
|
+
- Serve local REST routes and a lightweight viewer while the backend contract is still forming.
|
|
10
|
+
- Upgrade persistence per resource without rewriting frontend data access.
|
|
11
|
+
- Keep static fixtures, the first-party JSON file database, SQLite, Postgres, KV/Redis-like stores, and custom stores behind the same app-facing resource model.
|
|
12
|
+
- Emit schema metadata for admin, CMS, or form-building screens.
|
|
13
|
+
|
|
14
|
+
`@async/db` is not a universal key/value driver layer; storage is one boundary inside the fixture-to-contract workflow.
|
|
15
|
+
|
|
16
|
+
## File Map
|
|
17
|
+
|
|
18
|
+
| Files | Purpose |
|
|
19
|
+
| --- | --- |
|
|
20
|
+
| `db/*.json`, `db/*.jsonc`, `db/*.csv` | Fixture data |
|
|
21
|
+
| `db/*.schema.json`, `db/*.schema.jsonc`, `db/*.schema.js` | Optional stricter schema contracts |
|
|
22
|
+
| `db.schema.js` | Optional root schema registry for all resources |
|
|
23
|
+
| `db/<resource>/index.schema.js` | Folder-backed content collection marker |
|
|
24
|
+
| `.db/state/*` | Generated writable JSON store state |
|
|
25
|
+
| `.db/schema.generated.json`, `.db/types/index.d.ts` | Generated metadata and types |
|
|
26
|
+
|
|
27
|
+
## Quick Summary
|
|
28
|
+
|
|
29
|
+
Most projects can start with the defaults:
|
|
30
|
+
|
|
31
|
+
1. Put fixtures in `db/`.
|
|
32
|
+
2. Run `async-db sync` to generate schema metadata, TypeScript types, and runtime state.
|
|
33
|
+
3. Run `async-db serve` to start the local API and viewer.
|
|
34
|
+
4. Open `http://127.0.0.1:7331/__db`.
|
|
35
|
+
5. Call REST routes like `GET /db/users.json` and `POST /db/users`.
|
|
36
|
+
6. Add per-resource schemas or `db.schema.js` only when the fixture shape needs a clearer contract.
|
|
37
|
+
|
|
38
|
+
The default server is REST-first. GraphQL is available at `/graphql`, but you do not need it for the core workflow.
|
|
39
|
+
|
|
40
|
+
## Examples
|
|
41
|
+
|
|
42
|
+
Start with [`examples/basic`](./examples/basic) for the shortest schema-backed workflow.
|
|
43
|
+
|
|
44
|
+
Other useful paths:
|
|
45
|
+
|
|
46
|
+
- [`examples/data-first`](./examples/data-first): plain fixtures before schemas exist.
|
|
47
|
+
- [`examples/content-collections`](./examples/content-collections): docs and blog folders as static content collections.
|
|
48
|
+
- [`examples/computed-fields`](./examples/computed-fields): computed field patterns across several schema-backed models.
|
|
49
|
+
- [`examples/production-json`](./examples/production-json): feature flags and settings in the JSON store behind registered operations.
|
|
50
|
+
- [`examples/rest-client`](./examples/rest-client): calling @async/db from app or test code.
|
|
51
|
+
- [`examples/schema-manifest`](./examples/schema-manifest): schema metadata for admin/CMS UI.
|
|
52
|
+
- [`examples/standard-schema`](./examples/standard-schema): Standard Schema validators with Async DB metadata overlays.
|
|
53
|
+
- [`examples/hono-auth`](./examples/hono-auth): optional Hono auth and write hooks.
|
|
54
|
+
|
|
55
|
+
See [Which Example Should I Start With?](#which-example-should-i-start-with) for the full examples map.
|
|
56
|
+
|
|
57
|
+
## Install
|
|
58
|
+
|
|
59
|
+
Install the published package in the app or package that will use it:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
npm install @async/db
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Add package scripts for the CLI commands you want to run often:
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"scripts": {
|
|
70
|
+
"db": "async-db",
|
|
71
|
+
"db:sync": "async-db sync",
|
|
72
|
+
"db:serve": "async-db serve",
|
|
73
|
+
"db:types": "async-db types"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
If you need an unreleased fix, pin a reviewed GitHub commit or release tag instead of the moving default branch:
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"devDependencies": {
|
|
83
|
+
"@async/db": "github:async-framework/async-db#<reviewed-commit-sha-or-tag>"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
The package import name is `@async/db`; helpers are available from `@async/db/config`, `@async/db/schema`, `@async/db/client`, and `@async/db/json`. The root package exports runtime helpers such as `openDb()` and schema contract helpers such as `loadDbSchema()`.
|
|
89
|
+
|
|
90
|
+
## Five-Minute Start
|
|
91
|
+
|
|
92
|
+
Create a fixture:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
mkdir -p db
|
|
96
|
+
cat > db/users.json <<'JSON'
|
|
97
|
+
[
|
|
98
|
+
{
|
|
99
|
+
"id": "u_1",
|
|
100
|
+
"name": "Ada Lovelace",
|
|
101
|
+
"email": "ada@example.com"
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
JSON
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Sync generated metadata, types, and runtime state:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
npm run db:sync
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Start the local API and viewer in terminal 1:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
npm run db:serve
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Open the viewer:
|
|
120
|
+
|
|
121
|
+
```txt
|
|
122
|
+
http://127.0.0.1:7331/__db
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Call the REST API from terminal 2:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
curl http://127.0.0.1:7331/db/users.json
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Create a local record:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
curl -X POST http://127.0.0.1:7331/db/users \
|
|
135
|
+
-H 'content-type: application/json' \
|
|
136
|
+
-d '{"id":"u_2","name":"Grace Hopper","email":"grace@example.com"}'
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
The default sync output is generated:
|
|
140
|
+
|
|
141
|
+
```txt
|
|
142
|
+
.db/schema.generated.json
|
|
143
|
+
.db/types/index.d.ts
|
|
144
|
+
.db/state/users.json
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
`serve` syncs on startup, watches the fixture folder, refreshes valid resources when files change, and surfaces file-specific diagnostics in the viewer without breaking unrelated resources.
|
|
148
|
+
|
|
149
|
+
See [docs/getting-started.md](./docs/getting-started.md) for the expanded walkthrough.
|
|
150
|
+
|
|
151
|
+
## Operational Contract
|
|
152
|
+
|
|
153
|
+
| Behavior | Default |
|
|
154
|
+
| --- | --- |
|
|
155
|
+
| Source fixtures | Read from `./db` recursively. |
|
|
156
|
+
| App data routes | Exposed under `/db` by default, such as `GET /db/users.json`. |
|
|
157
|
+
| Runtime writes | Go to the default JSON store under `.db/state`. |
|
|
158
|
+
| Source writes | Only happen for resources bound to the `sourceFile` store, and only for supported writebacks such as generated ids in plain `.json` collections. |
|
|
159
|
+
| Optional stores | SQLite, Postgres, generic KV, and Redis-like stores plug into the same runtime store boundary without adding mandatory database client dependencies. |
|
|
160
|
+
| Generated output | `.db/` is runtime output and normally stays uncommitted. |
|
|
161
|
+
| Schema contract API | `loadDbSchema({ from })` loads metadata only by default; `openDb({ schema })` opens the runtime database from the same schema locator. |
|
|
162
|
+
| Local server | Binds to `127.0.0.1:7331` by default and exposes writable local development endpoints. |
|
|
163
|
+
| Trusted code | `.schema.js`, `db.config.mjs`, source readers, and manifest hooks execute as local project code. |
|
|
164
|
+
| Mock latency | Responses include a small `30-100ms` delay by default so loading states are visible. |
|
|
165
|
+
|
|
166
|
+
The built-in JSON store is production-appropriate only for file-suitable resources: app settings, feature flags, content, templates, plan definitions, policy rules, seed data, and other small low-write data that can safely live with a single writer. Keep high-write user data, chat/messages, analytics/events, ledgers, inventory counters, multi-writer data, and compliance-heavy transactional records in SQLite, Postgres, or another app-owned store.
|
|
167
|
+
|
|
168
|
+
@async/db is not an auth layer, an ORM, a hosted database service, or a broad JSON Schema compatibility project. For production-facing APIs, put app traffic behind registered operations, app-owned auth/authorization, rate limits, and observability. See [Production JSON Database](./docs/json-production.md), [Resource Graduation And Mixed Stores](./docs/store-graduation.md), and [Prototype To Production REST Guide](./docs/prototype-to-production.md).
|
|
169
|
+
|
|
170
|
+
## Add Schema When It Pays For It
|
|
171
|
+
|
|
172
|
+
Data-first fixtures are enough until the shape matters. Inspect what @async/db infers:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
npm run db -- schema infer
|
|
176
|
+
npm run db -- schema infer users
|
|
177
|
+
npm run db -- schema infer users --out db/users.schema.jsonc
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Add `db/users.schema.json`, `db/users.schema.jsonc`, or `db/users.schema.js` when you need stricter behavior:
|
|
181
|
+
|
|
182
|
+
```json
|
|
183
|
+
{
|
|
184
|
+
"kind": "collection",
|
|
185
|
+
"idField": "id",
|
|
186
|
+
"fields": {
|
|
187
|
+
"id": { "type": "string", "required": true },
|
|
188
|
+
"name": { "type": "string", "required": true },
|
|
189
|
+
"email": {
|
|
190
|
+
"type": "string",
|
|
191
|
+
"required": true,
|
|
192
|
+
"unique": true,
|
|
193
|
+
"description": "Email address used for local sign-in."
|
|
194
|
+
},
|
|
195
|
+
"role": {
|
|
196
|
+
"type": "enum",
|
|
197
|
+
"values": ["admin", "user"],
|
|
198
|
+
"default": "user"
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Then validate:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
npm run db -- schema validate
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
In mixed mode, schema files define the contract and data files provide seed records. Unknown fields warn by default; configure `schema.unknownFields: 'error'` when drift should fail.
|
|
211
|
+
|
|
212
|
+
Schema defaults fill omitted fields on create and safe additive runtime hydration. Updates, patches, and document puts preserve omitted fields; include a field in the write body when you want to change it.
|
|
213
|
+
|
|
214
|
+
Executable `.schema.js` files can also accept Standard Schema-compatible validators:
|
|
215
|
+
|
|
216
|
+
```js
|
|
217
|
+
import { collection, field } from '@async/db/schema';
|
|
218
|
+
|
|
219
|
+
export default collection({
|
|
220
|
+
validator: UserSchema,
|
|
221
|
+
fields: {
|
|
222
|
+
email: field.string({ required: true, unique: true }),
|
|
223
|
+
displayName: field.computed(field.string(), ({ record }) => record.email),
|
|
224
|
+
},
|
|
225
|
+
});
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
The validator owns runtime parsing through `~standard.validate`; Async DB overlays keep generated metadata, relations, defaults, and computed resolvers. Async validators run in package, REST, and GraphQL writes. Sync schema helpers throw `DB_SCHEMA_ASYNC_VALIDATOR_REQUIRED` when the validator returns a Promise; use `validateAsync()` or `assertAsync()` for that path.
|
|
229
|
+
|
|
230
|
+
See [docs/concepts.md](./docs/concepts.md) and [docs/fixtures-and-schemas.md](./docs/fixtures-and-schemas.md).
|
|
231
|
+
|
|
232
|
+
## Validate Or Resolve From Schema
|
|
233
|
+
|
|
234
|
+
Use `loadDbSchema({ from })` when server code wants schema validation or field
|
|
235
|
+
resolver access without opening stores:
|
|
236
|
+
|
|
237
|
+
```ts
|
|
238
|
+
import { loadDbSchema, openDb } from '@async/db';
|
|
239
|
+
|
|
240
|
+
const schema = await loadDbSchema({ from: './db.schema.js' });
|
|
241
|
+
const input = schema.validator('users', { unknownFields: 'strip' }).assert(await request.json());
|
|
242
|
+
|
|
243
|
+
const userResolvers = schema.resolver('users', {
|
|
244
|
+
value: input,
|
|
245
|
+
context: { locale: 'en-US', nameFormatter },
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
const fullName = await userResolvers.fullName();
|
|
249
|
+
const db = await openDb({ schema });
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Validators reject computed and read-only fields. Resolver functions receive a
|
|
253
|
+
delegated `this` context with `this.get(name)`, so app-provided context can
|
|
254
|
+
override internal values while `this._internal` still exposes the original
|
|
255
|
+
runtime view.
|
|
256
|
+
|
|
257
|
+
## Admin/CMS Schema Metadata
|
|
258
|
+
|
|
259
|
+
Schemas can also drive local admin, CMS, custom data viewers, and form-building screens. Use `GET /__db/manifest.json` at runtime when a UI runs beside `async-db serve`, or configure `outputs.viewerManifest` when app code needs a committed JSON artifact with the same viewer metadata. Browser requests can open `GET /__db/manifest.html`; AI clients can use `GET /__db/manifest.md`; `GET /__db/manifest` lets the `Accept` header choose among registered response formats.
|
|
260
|
+
|
|
261
|
+
Use `outputs.schemaManifest` when an app only needs the smaller model metadata file without server route links, diagnostics, or viewer capabilities.
|
|
262
|
+
|
|
263
|
+
```js
|
|
264
|
+
import { defineConfig, mergeManifest } from '@async/db/config';
|
|
265
|
+
|
|
266
|
+
export default defineConfig({
|
|
267
|
+
outputs: {
|
|
268
|
+
schemaManifest: './src/generated/db.schema.json',
|
|
269
|
+
viewerManifest: './src/generated/db.viewer.json',
|
|
270
|
+
},
|
|
271
|
+
|
|
272
|
+
server: {
|
|
273
|
+
viewerLinks: [
|
|
274
|
+
{ label: 'App Data Viewer', href: 'http://127.0.0.1:5173/db' },
|
|
275
|
+
],
|
|
276
|
+
},
|
|
277
|
+
|
|
278
|
+
schemaManifest: {
|
|
279
|
+
customizeResource({ file, defaultManifest }) {
|
|
280
|
+
// Group fields by source folder so an admin shell can show CMS records
|
|
281
|
+
// separately from operational data without hard-coding that in the UI.
|
|
282
|
+
return mergeManifest(defaultManifest, {
|
|
283
|
+
editor: {
|
|
284
|
+
group: file?.startsWith('db/cms/') ? 'CMS' : 'Data',
|
|
285
|
+
},
|
|
286
|
+
});
|
|
287
|
+
},
|
|
288
|
+
|
|
289
|
+
customizeField({ fieldName, path, defaultManifest }) {
|
|
290
|
+
if (fieldName.endsWith('Markdown')) {
|
|
291
|
+
// Markdown body fields need a richer editor than a plain text input,
|
|
292
|
+
// but the fixture record should still stay normal JSON data.
|
|
293
|
+
return mergeManifest(defaultManifest, {
|
|
294
|
+
ui: { component: 'markdown' },
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (path === 'blocks.chartId') {
|
|
299
|
+
// Relation ids stay as strings in fixtures, while the generated
|
|
300
|
+
// manifest tells the admin UI to render a picker backed by charts.
|
|
301
|
+
return mergeManifest(defaultManifest, {
|
|
302
|
+
ui: {
|
|
303
|
+
component: 'relation-select',
|
|
304
|
+
relationTo: 'charts',
|
|
305
|
+
},
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return defaultManifest;
|
|
310
|
+
},
|
|
311
|
+
},
|
|
312
|
+
});
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
The generated manifest is metadata output; schema defaults and validation still come from the schema contract. Actual records stay on REST or GraphQL routes, so a custom viewer fetches `manifest.json` for fields and route links, then calls the listed resource routes for rows. `server.viewerLinks` exposes custom viewer URLs in root discovery and the shared manifest.
|
|
316
|
+
|
|
317
|
+
See [docs/generated-files.md](./docs/generated-files.md) and [examples/schema-manifest](./examples/schema-manifest).
|
|
318
|
+
|
|
319
|
+
## Common Commands
|
|
320
|
+
|
|
321
|
+
With the `db` script from the install snippet:
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
npm run db -- sync
|
|
325
|
+
npm run db -- types
|
|
326
|
+
npm run db -- types --watch
|
|
327
|
+
npm run db -- types --out ./src/generated/db.types.d.ts
|
|
328
|
+
npm run db -- schema
|
|
329
|
+
npm run db -- schema users
|
|
330
|
+
npm run db -- schema infer users
|
|
331
|
+
npm run db -- schema validate
|
|
332
|
+
npm run db -- doctor
|
|
333
|
+
npm run db -- check --strict
|
|
334
|
+
npm run db -- create users '{"id":"u_2","name":"Grace Hopper","email":"grace@example.com"}'
|
|
335
|
+
npm run db -- serve
|
|
336
|
+
npm run db -- generate hono
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
With pnpm and the same `"db": "async-db"` script:
|
|
340
|
+
|
|
341
|
+
```bash
|
|
342
|
+
pnpm db sync
|
|
343
|
+
pnpm db schema validate
|
|
344
|
+
pnpm db serve
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
See [docs/package-api.md](./docs/package-api.md) for CLI and package export details.
|
|
348
|
+
|
|
349
|
+
## REST, GraphQL, And Viewer
|
|
350
|
+
|
|
351
|
+
The local server exposes REST routes for collections and singleton documents, plus a focused GraphQL endpoint at `/graphql` for apps that prefer GraphQL. REST remains the default path because it pairs directly with the viewer and local fixture workflow.
|
|
352
|
+
Set `rest.enabled: false` when an app wants schema, manifest, viewer, import, events, and GraphQL routes without generated REST resource routes or REST batching.
|
|
353
|
+
Set `graphql.enabled: false` when an app wants REST and dev-tool routes without a GraphQL endpoint.
|
|
354
|
+
|
|
355
|
+
```txt
|
|
356
|
+
GET /db/users.json
|
|
357
|
+
GET /db/users/:id.json
|
|
358
|
+
POST /db/users
|
|
359
|
+
PATCH /db/users/:id
|
|
360
|
+
DELETE /db/users/:id
|
|
361
|
+
|
|
362
|
+
GET /db/settings.json
|
|
363
|
+
PUT /db/settings
|
|
364
|
+
PATCH /db/settings
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
Use `select`, `offset`, and `limit` when a prototype only needs part of a collection:
|
|
368
|
+
|
|
369
|
+
```bash
|
|
370
|
+
curl 'http://127.0.0.1:7331/db/users.json?select=id,name&offset=0&limit=20'
|
|
371
|
+
curl 'http://127.0.0.1:7331/db/users.json?id=u_1&select=id,name'
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
The `?id=` shortcut is only for explicit JSON routes. Extensionless REST routes
|
|
375
|
+
use normal record URLs such as `/db/users/u_1`.
|
|
376
|
+
|
|
377
|
+
The `.json` route is a fixture-like URL for the synced runtime resource:
|
|
378
|
+
`db/users.json` maps to `GET /db/users.json`, while local writes still go to
|
|
379
|
+
the selected runtime store. See [Fixture-Like `.json` Routes](./docs/server-and-viewer.md#fixture-like-json-routes).
|
|
380
|
+
|
|
381
|
+
The viewer at `/__db` lets you inspect resources, import CSV files into the configured fixture folder, view generated schema metadata, read GraphQL SDL/operation references, and try REST requests without writing client code first.
|
|
382
|
+
|
|
383
|
+
The built-in viewer and custom viewer UIs use the same JSON manifest at `/__db/manifest.json`. `/__db/manifest.html` opens a formatted JSON viewer, `/__db/manifest.md` returns an AI-friendly Markdown wrapper, and `/__db/manifest` chooses from registered media types in `Accept`. Apps can use `api.formats` from the manifest to discover supported extensions and build their own viewer UI against REST or GraphQL records.
|
|
384
|
+
|
|
385
|
+
See [docs/server-and-viewer.md](./docs/server-and-viewer.md). When local
|
|
386
|
+
`/db/*` routes are ready to become `/api/db/*` or `/api/*` production API
|
|
387
|
+
routes, see the
|
|
388
|
+
[Prototype To Production REST Guide](./docs/prototype-to-production.md).
|
|
389
|
+
|
|
390
|
+
## Which Example Should I Start With?
|
|
391
|
+
|
|
392
|
+
The examples are a learning path. Run any example with `npm run db -- sync --cwd ./examples/<name>` and `npm run db -- serve --cwd ./examples/<name>`, or run `npm run examples` to open one lazy examples index. The examples index binds to `127.0.0.1` by default; use `npm run examples -- --tailscale-serve` when you want Tailscale Serve to proxy that local port over HTTPS for devices in your tailnet.
|
|
393
|
+
|
|
394
|
+
| If you want to learn... | Start with | What it shows |
|
|
395
|
+
| --- | --- | --- |
|
|
396
|
+
| The shortest schema-backed workflow | [`examples/basic`](./examples/basic) | Sync, viewer, REST create, committed generated types |
|
|
397
|
+
| Plain data before schemas exist | [`examples/data-first`](./examples/data-first) | Inferred collections, documents, routes, and types |
|
|
398
|
+
| Docs and blog folders as content collections | [`examples/content-collections`](./examples/content-collections) | `index.schema.mjs`, `files(..., { read })`, raw MDX bodies, config-owned static stores, computed fields |
|
|
399
|
+
| Different computed field patterns | [`examples/computed-fields`](./examples/computed-fields) | Shorthand resolvers, `resolveMany`, formatting, and runtime-context lookups |
|
|
400
|
+
| Contract-first resources | [`examples/schema-first`](./examples/schema-first) | Schema-only resources, empty seed records, committed types |
|
|
401
|
+
| Calling @async/db from app or test code | [`examples/rest-client`](./examples/rest-client) | `createDbClient`, direct REST calls, REST batching |
|
|
402
|
+
| Related local records | [`examples/relations`](./examples/relations) | Relation metadata, `expand`, and nested `select` |
|
|
403
|
+
| CSV as the source of truth | [`examples/csv`](./examples/csv) | CSV inference, source hashes, mirror refreshes |
|
|
404
|
+
| Admin/CMS-style field metadata | [`examples/schema-manifest`](./examples/schema-manifest) | `outputs.schemaManifest` and manifest customization |
|
|
405
|
+
| Schema JSON to simple CMS UI templates | [`examples/schema-ui`](./examples/schema-ui) | `serve.mjs` SSR view/editor HTML from manifest + mirror (`node ./examples/schema-ui/serve.mjs`); `/templates` route keeps static placeholders |
|
|
406
|
+
| Standard Schema validators | [`examples/standard-schema`](./examples/standard-schema) | Dependency-free Standard Schema validation, `field.meta(...)` overlays, async write validation, computed fields, and conservative type fallback |
|
|
407
|
+
| Diagnostics for schema/data drift | [`examples/diagnostics`](./examples/diagnostics) | Warnings surfaced without breaking unrelated resources |
|
|
408
|
+
| Production-suitable JSON control data | [`examples/production-json`](./examples/production-json) | Feature flags, app settings, explicit schemas, and registered operation refs |
|
|
409
|
+
| Several advanced features together | [`examples/advanced`](./examples/advanced) | `.schema.mjs`, mixed mode, defaults, nested objects |
|
|
410
|
+
| Hono auth and write hooks | [`examples/hono-auth`](./examples/hono-auth) | Optional Hono integration with auth lifecycle hooks |
|
|
411
|
+
|
|
412
|
+
Each example README is the runnable authority for that example.
|
|
413
|
+
|
|
414
|
+
## Docs Map
|
|
415
|
+
|
|
416
|
+
| Task | Read |
|
|
417
|
+
| --- | --- |
|
|
418
|
+
| Start a project | [docs/getting-started.md](./docs/getting-started.md) |
|
|
419
|
+
| Understand the model | [docs/concepts.md](./docs/concepts.md) |
|
|
420
|
+
| Author fixtures and schemas | [docs/fixtures-and-schemas.md](./docs/fixtures-and-schemas.md) |
|
|
421
|
+
| Manage generated output | [docs/generated-files.md](./docs/generated-files.md) |
|
|
422
|
+
| Configure @async/db | [docs/configuration.md](./docs/configuration.md) |
|
|
423
|
+
| Use JSON in production safely | [docs/json-production.md](./docs/json-production.md) |
|
|
424
|
+
| Serve local data and use REST/GraphQL/viewer | [docs/server-and-viewer.md](./docs/server-and-viewer.md) |
|
|
425
|
+
| Graduate REST prototypes to production API routes | [docs/prototype-to-production.md](./docs/prototype-to-production.md) |
|
|
426
|
+
| Use the package API, CLI, or exports | [docs/package-api.md](./docs/package-api.md) |
|
|
427
|
+
| Integrate with Vite, Hono, or SQLite | [docs/integrations.md](./docs/integrations.md) |
|
|
428
|
+
| Understand implementation boundaries | [docs/architecture.md](./docs/architecture.md) |
|
|
429
|
+
| Work on the repo or publish releases | [CONTRIBUTING.md](./CONTRIBUTING.md) |
|
|
430
|
+
|
|
431
|
+
For the full product behavior and acceptance model, see [SPEC.md](./SPEC.md).
|