@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
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Schema Manifest Example
|
|
2
|
+
|
|
3
|
+
## What This Teaches
|
|
4
|
+
|
|
5
|
+
Use this when an app wants committed schema metadata for admin, CMS, or form-building screens. It demonstrates `outputs.schemaManifest` and `schemaManifest.customizeField()`.
|
|
6
|
+
|
|
7
|
+
## Files To Inspect
|
|
8
|
+
|
|
9
|
+
- [db/projects.schema.jsonc](./db/projects.schema.jsonc): relation, enum, defaults, and descriptions.
|
|
10
|
+
- [db/users.schema.jsonc](./db/users.schema.jsonc): field descriptions and a `bio` field customized for markdown.
|
|
11
|
+
- [db.config.mjs](./db.config.mjs): writes `src/generated/db.schema.json` and customizes UI hints.
|
|
12
|
+
- [src/generated/db.schema.json](./src/generated/db.schema.json): committed manifest output after sync.
|
|
13
|
+
|
|
14
|
+
## Run It
|
|
15
|
+
|
|
16
|
+
From the repository root, use the repo-internal CLI path:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm run db -- sync --cwd ./examples/schema-manifest
|
|
20
|
+
npm run db -- schema manifest --cwd ./examples/schema-manifest --out ./src/generated/db.schema.json
|
|
21
|
+
npm run db -- serve --cwd ./examples/schema-manifest
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Expected Result
|
|
25
|
+
|
|
26
|
+
`sync` writes both generated TypeScript types and a committed schema manifest. In the manifest, `projects.status` uses `segmented-control`, and `users.bio` uses `markdown`.
|
|
27
|
+
|
|
28
|
+
## REST Request To Try
|
|
29
|
+
|
|
30
|
+
Leave `serve` running and run this from another terminal:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
curl 'http://127.0.0.1:7331/db/projects.json?expand=owner&select=id,name,status,owner.name'
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Features To Notice
|
|
37
|
+
|
|
38
|
+
- [Schema manifest output](../../docs/generated-files.md#schema-manifest-output)
|
|
39
|
+
- [Field UI metadata](../../docs/server-and-viewer.md#custom-viewer-manifest)
|
|
40
|
+
- [Relationship expansion](../../docs/server-and-viewer.md#relationship-expansion)
|
|
41
|
+
- [Fixture-like `.json` REST routes](../../docs/server-and-viewer.md#fixture-like-json-routes)
|
|
42
|
+
|
|
43
|
+
## Cleanup
|
|
44
|
+
|
|
45
|
+
Generated `.db/` output is ignored by git. The files under `src/generated/` are intentionally committed for this example.
|
|
46
|
+
|
|
47
|
+
## More Docs
|
|
48
|
+
|
|
49
|
+
- [Generated Files](../../docs/generated-files.md)
|
|
50
|
+
- [Configuration](../../docs/configuration.md)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"kind": "collection",
|
|
3
|
+
"idField": "id",
|
|
4
|
+
"description": "Projects used to demonstrate generated form metadata.",
|
|
5
|
+
"fields": {
|
|
6
|
+
"id": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"required": true,
|
|
9
|
+
"description": "Stable project id."
|
|
10
|
+
},
|
|
11
|
+
"name": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"required": true,
|
|
14
|
+
"description": "Project display name."
|
|
15
|
+
},
|
|
16
|
+
"ownerId": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"required": true,
|
|
19
|
+
"description": "Owner user id.",
|
|
20
|
+
"relation": {
|
|
21
|
+
"name": "owner",
|
|
22
|
+
"to": "users",
|
|
23
|
+
"toField": "id",
|
|
24
|
+
"cardinality": "one"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"status": {
|
|
28
|
+
"type": "enum",
|
|
29
|
+
"values": ["planned", "active", "paused", "done"],
|
|
30
|
+
"default": "planned",
|
|
31
|
+
"description": "Workflow status for local admin forms."
|
|
32
|
+
},
|
|
33
|
+
"notes": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
"maxLength": 500,
|
|
36
|
+
"description": "Internal project notes."
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"seed": [
|
|
40
|
+
{
|
|
41
|
+
"id": "proj_1",
|
|
42
|
+
"name": "Local admin prototype",
|
|
43
|
+
"ownerId": "u_1",
|
|
44
|
+
"status": "active",
|
|
45
|
+
"notes": "Uses generated manifest metadata to choose form controls."
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"kind": "collection",
|
|
3
|
+
"idField": "id",
|
|
4
|
+
"description": "People who can own local projects.",
|
|
5
|
+
"fields": {
|
|
6
|
+
"id": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"required": true,
|
|
9
|
+
"description": "Stable user id."
|
|
10
|
+
},
|
|
11
|
+
"name": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"required": true,
|
|
14
|
+
"description": "Display name."
|
|
15
|
+
},
|
|
16
|
+
"email": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"required": true,
|
|
19
|
+
"unique": true,
|
|
20
|
+
"description": "Email shown in admin forms."
|
|
21
|
+
},
|
|
22
|
+
"bio": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"description": "Markdown biography for profile previews."
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"seed": [
|
|
28
|
+
{
|
|
29
|
+
"id": "u_1",
|
|
30
|
+
"name": "Ada Lovelace",
|
|
31
|
+
"email": "ada@example.com",
|
|
32
|
+
"bio": "First programmer notes for local demos."
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { defineConfig } from '@async/db/config';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
dbDir: './db',
|
|
6
|
+
outputs: {
|
|
7
|
+
stateDir: './.db',
|
|
8
|
+
types: './.db/types/index.d.ts',
|
|
9
|
+
committedTypes: './src/generated/db.types.d.ts',
|
|
10
|
+
schemaManifest: './src/generated/db.schema.json',
|
|
11
|
+
},
|
|
12
|
+
types: {
|
|
13
|
+
enabled: true,
|
|
14
|
+
emitComments: true,
|
|
15
|
+
},
|
|
16
|
+
schemaManifest: {
|
|
17
|
+
customizeField({ resourceName, fieldName, defaultManifest }) {
|
|
18
|
+
if (resourceName === 'projects' && fieldName === 'status') {
|
|
19
|
+
return {
|
|
20
|
+
...defaultManifest,
|
|
21
|
+
ui: {
|
|
22
|
+
...defaultManifest.ui,
|
|
23
|
+
component: 'segmented-control',
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (resourceName === 'users' && fieldName === 'bio') {
|
|
29
|
+
return {
|
|
30
|
+
...defaultManifest,
|
|
31
|
+
ui: {
|
|
32
|
+
...defaultManifest.ui,
|
|
33
|
+
component: 'markdown',
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return defaultManifest;
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
});
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"collections": {
|
|
4
|
+
"projects": {
|
|
5
|
+
"kind": "collection",
|
|
6
|
+
"name": "projects",
|
|
7
|
+
"fields": {
|
|
8
|
+
"id": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"required": true,
|
|
11
|
+
"nullable": false,
|
|
12
|
+
"description": "Stable project id.",
|
|
13
|
+
"ui": {
|
|
14
|
+
"label": "Id",
|
|
15
|
+
"component": "text",
|
|
16
|
+
"readonly": true
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"name": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"required": true,
|
|
22
|
+
"nullable": false,
|
|
23
|
+
"description": "Project display name.",
|
|
24
|
+
"ui": {
|
|
25
|
+
"label": "Name",
|
|
26
|
+
"component": "text"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"ownerId": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"required": true,
|
|
32
|
+
"nullable": false,
|
|
33
|
+
"description": "Owner user id.",
|
|
34
|
+
"relation": {
|
|
35
|
+
"name": "owner",
|
|
36
|
+
"to": "users",
|
|
37
|
+
"toField": "id",
|
|
38
|
+
"cardinality": "one"
|
|
39
|
+
},
|
|
40
|
+
"ui": {
|
|
41
|
+
"label": "Owner Id",
|
|
42
|
+
"component": "relationSelect",
|
|
43
|
+
"optionsFrom": "users"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"status": {
|
|
47
|
+
"type": "enum",
|
|
48
|
+
"required": false,
|
|
49
|
+
"nullable": false,
|
|
50
|
+
"description": "Workflow status for local admin forms.",
|
|
51
|
+
"default": "planned",
|
|
52
|
+
"values": [
|
|
53
|
+
"planned",
|
|
54
|
+
"active",
|
|
55
|
+
"paused",
|
|
56
|
+
"done"
|
|
57
|
+
],
|
|
58
|
+
"ui": {
|
|
59
|
+
"label": "Status",
|
|
60
|
+
"component": "segmented-control"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"notes": {
|
|
64
|
+
"type": "string",
|
|
65
|
+
"required": false,
|
|
66
|
+
"nullable": false,
|
|
67
|
+
"description": "Internal project notes.",
|
|
68
|
+
"maxLength": 500,
|
|
69
|
+
"ui": {
|
|
70
|
+
"label": "Notes",
|
|
71
|
+
"component": "textarea"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"description": "Projects used to demonstrate generated form metadata.",
|
|
76
|
+
"idField": "id"
|
|
77
|
+
},
|
|
78
|
+
"users": {
|
|
79
|
+
"kind": "collection",
|
|
80
|
+
"name": "users",
|
|
81
|
+
"fields": {
|
|
82
|
+
"id": {
|
|
83
|
+
"type": "string",
|
|
84
|
+
"required": true,
|
|
85
|
+
"nullable": false,
|
|
86
|
+
"description": "Stable user id.",
|
|
87
|
+
"ui": {
|
|
88
|
+
"label": "Id",
|
|
89
|
+
"component": "text",
|
|
90
|
+
"readonly": true
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"name": {
|
|
94
|
+
"type": "string",
|
|
95
|
+
"required": true,
|
|
96
|
+
"nullable": false,
|
|
97
|
+
"description": "Display name.",
|
|
98
|
+
"ui": {
|
|
99
|
+
"label": "Name",
|
|
100
|
+
"component": "text"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
"email": {
|
|
104
|
+
"type": "string",
|
|
105
|
+
"required": true,
|
|
106
|
+
"nullable": false,
|
|
107
|
+
"description": "Email shown in admin forms.",
|
|
108
|
+
"unique": true,
|
|
109
|
+
"ui": {
|
|
110
|
+
"label": "Email",
|
|
111
|
+
"component": "email"
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"bio": {
|
|
115
|
+
"type": "string",
|
|
116
|
+
"required": false,
|
|
117
|
+
"nullable": false,
|
|
118
|
+
"description": "Markdown biography for profile previews.",
|
|
119
|
+
"ui": {
|
|
120
|
+
"label": "Bio",
|
|
121
|
+
"component": "markdown"
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"description": "People who can own local projects.",
|
|
126
|
+
"idField": "id"
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"documents": {}
|
|
130
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// This file is generated by db. Do not edit by hand.
|
|
3
|
+
|
|
4
|
+
export type ProjectStatus =
|
|
5
|
+
| "planned"
|
|
6
|
+
| "active"
|
|
7
|
+
| "paused"
|
|
8
|
+
| "done";
|
|
9
|
+
|
|
10
|
+
/** Projects used to demonstrate generated form metadata. */
|
|
11
|
+
export type Project = {
|
|
12
|
+
/** Stable project id. */
|
|
13
|
+
id: string;
|
|
14
|
+
/** Project display name. */
|
|
15
|
+
name: string;
|
|
16
|
+
/** Owner user id. */
|
|
17
|
+
ownerId: string;
|
|
18
|
+
/** Workflow status for local admin forms. */
|
|
19
|
+
status?: ProjectStatus;
|
|
20
|
+
/** Internal project notes. */
|
|
21
|
+
notes?: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/** People who can own local projects. */
|
|
25
|
+
export type User = {
|
|
26
|
+
/** Stable user id. */
|
|
27
|
+
id: string;
|
|
28
|
+
/** Display name. */
|
|
29
|
+
name: string;
|
|
30
|
+
/** Email shown in admin forms. */
|
|
31
|
+
email: string;
|
|
32
|
+
/** Markdown biography for profile previews. */
|
|
33
|
+
bio?: string;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type DbCollections = {
|
|
37
|
+
projects: Project;
|
|
38
|
+
users: User;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type DbDocuments = {
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export type DbTypes = {
|
|
45
|
+
collections: DbCollections;
|
|
46
|
+
documents: DbDocuments;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export type DbCollectionName = keyof DbCollections;
|
|
50
|
+
export type DbDocumentName = keyof DbDocuments;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Schema UI Example
|
|
2
|
+
|
|
3
|
+
## What This Teaches
|
|
4
|
+
|
|
5
|
+
Use this when you want to see how committed schema JSON can drive a tiny admin or CMS UI. It reads `src/generated/db.schema.json` and maps each field's `ui.component` to simple view and editor HTML.
|
|
6
|
+
|
|
7
|
+
The demo composes **SSR CMS routes ahead of the stock db handler**, so the same port serves **`/` SSR**, **`/__db`**, REST, and GraphQL.
|
|
8
|
+
|
|
9
|
+
## Files To Inspect
|
|
10
|
+
|
|
11
|
+
- [db/pages.schema.jsonc](./db/pages.schema.jsonc): CMS page schema with enum, relation, summary, and markdown body fields.
|
|
12
|
+
- [db/users.schema.jsonc](./db/users.schema.jsonc): author records used by the relation picker metadata.
|
|
13
|
+
- [db.config.mjs](./db.config.mjs): writes the schema manifest and customizes CMS UI hints.
|
|
14
|
+
- [src/render-admin.mjs](./src/render-admin.mjs): static string-template preview (`/templates`) and CLI output for scaffolding comparisons.
|
|
15
|
+
- [src/cms-ssr.mjs](./src/cms-ssr.mjs): SSR view/editor snippets filled with real record values and resolved relations.
|
|
16
|
+
- [src/schema-ui-ssr-handler.mjs](./src/schema-ui-ssr-handler.mjs): SSR routing layer (middleware-style); hands off other paths to db.
|
|
17
|
+
- [src/start-schema-ui-server.mjs](./src/start-schema-ui-server.mjs): wires SSR handler + `createDbRequestHandler` + file watching.
|
|
18
|
+
- [serve.mjs](./serve.mjs): CLI entry; same stack as the examples launcher hook.
|
|
19
|
+
- [serve-example.mjs](./serve-example.mjs): **`npm run examples`** hook — exports `createExampleRuntime` so `scripts/example-launcher.js` can mount this example without hard-coding it.
|
|
20
|
+
- [src/generated/db.schema.json](./src/generated/db.schema.json): committed manifest input after sync.
|
|
21
|
+
|
|
22
|
+
## Run It
|
|
23
|
+
|
|
24
|
+
From the repository root:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
node ./examples/schema-ui/serve.mjs
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Open **http://127.0.0.1:7342/** — CMS home with links into each collection. The built-in viewer is **http://127.0.0.1:7342/__db**.
|
|
31
|
+
|
|
32
|
+
### From the repo examples index
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm run examples
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Pick **Schema UI** on the index page; it uses **`serve-example.mjs`** automatically and starts only after you open it (see `scripts/example-launcher.js`).
|
|
39
|
+
|
|
40
|
+
Routes:
|
|
41
|
+
|
|
42
|
+
| Path | Purpose |
|
|
43
|
+
| --- | --- |
|
|
44
|
+
| `/` | Home: collections and record counts |
|
|
45
|
+
| `/cms/pages` | List pages from the mirror |
|
|
46
|
+
| `/cms/pages/page_home` | SSR detail: resolved author link, markdown body text, filled editor controls |
|
|
47
|
+
| `/templates` | Static component templates only (no database rows), matching the CLI renderer |
|
|
48
|
+
| `/__db`, `/graphql`, `/db/pages.json`, … | Stock db viewer, GraphQL, and REST on the same origin |
|
|
49
|
+
|
|
50
|
+
URLs are printed when the server starts.
|
|
51
|
+
|
|
52
|
+
Options:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
node ./examples/schema-ui/serve.mjs --port 8080 --host 127.0.0.1
|
|
56
|
+
node ./examples/schema-ui/serve.mjs --no-sync
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
`--no-sync` skips fixture sync on startup (faster restart). Use it only after you have already synced once so `.db/state` exists.
|
|
60
|
+
|
|
61
|
+
### Print Static Templates To A File
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
npm run db -- sync --cwd ./examples/schema-ui
|
|
65
|
+
node ./examples/schema-ui/src/render-admin.mjs > /tmp/db-schema-ui.html
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Expected Result
|
|
69
|
+
|
|
70
|
+
SSR pages show **live field values**: titles, markdown bodies escaped into `<article>`, relation links to `/cms/users/:id`, radios reflecting enum status, and selects populated from related rows.
|
|
71
|
+
|
|
72
|
+
The standalone **`render-admin.mjs`** output still demonstrates placeholder-driven templates for comparison.
|
|
73
|
+
|
|
74
|
+
## REST Request To Try
|
|
75
|
+
|
|
76
|
+
With **`serve.mjs`** or **`npm run examples`** (same stack), REST is already on the demo port:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
curl 'http://127.0.0.1:7342/db/pages.json?expand=author&select=id,title,status,author.name'
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Or run the CLI server alone:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npm run db -- serve --cwd ./examples/schema-ui
|
|
86
|
+
curl 'http://127.0.0.1:7331/db/pages.json?expand=author&select=id,title,status,author.name'
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Features To Notice
|
|
90
|
+
|
|
91
|
+
- [Schema manifest output](../../docs/generated-files.md#schema-manifest-output)
|
|
92
|
+
- [Custom viewer manifest](../../docs/server-and-viewer.md#custom-viewer-manifest)
|
|
93
|
+
- [Relationship expansion](../../docs/server-and-viewer.md#relationship-expansion)
|
|
94
|
+
- [Fixture-like `.json` REST routes](../../docs/server-and-viewer.md#fixture-like-json-routes)
|
|
95
|
+
|
|
96
|
+
## Cleanup
|
|
97
|
+
|
|
98
|
+
Generated `.db/` output is ignored by git. The files under `src/generated/` are intentionally committed for this example.
|
|
99
|
+
|
|
100
|
+
## More Docs
|
|
101
|
+
|
|
102
|
+
- [Generated Files](../../docs/generated-files.md)
|
|
103
|
+
- [Configuration](../../docs/configuration.md)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"kind": "collection",
|
|
3
|
+
"idField": "id",
|
|
4
|
+
"description": "CMS pages rendered by a tiny schema-driven UI example.",
|
|
5
|
+
"fields": {
|
|
6
|
+
"id": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"required": true,
|
|
9
|
+
"description": "Stable page id."
|
|
10
|
+
},
|
|
11
|
+
"title": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"required": true,
|
|
14
|
+
"description": "Page title shown in the CMS list."
|
|
15
|
+
},
|
|
16
|
+
"status": {
|
|
17
|
+
"type": "enum",
|
|
18
|
+
"values": ["draft", "review", "published"],
|
|
19
|
+
"default": "draft",
|
|
20
|
+
"description": "Publication state."
|
|
21
|
+
},
|
|
22
|
+
"authorId": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"required": true,
|
|
25
|
+
"description": "Page author.",
|
|
26
|
+
"relation": {
|
|
27
|
+
"name": "author",
|
|
28
|
+
"to": "users",
|
|
29
|
+
"toField": "id",
|
|
30
|
+
"cardinality": "one"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"summary": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
"maxLength": 160,
|
|
36
|
+
"description": "Short page summary."
|
|
37
|
+
},
|
|
38
|
+
"bodyMarkdown": {
|
|
39
|
+
"type": "string",
|
|
40
|
+
"description": "Markdown body content."
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"seed": [
|
|
44
|
+
{
|
|
45
|
+
"id": "page_home",
|
|
46
|
+
"title": "Home",
|
|
47
|
+
"status": "draft",
|
|
48
|
+
"authorId": "u_1",
|
|
49
|
+
"summary": "A small page record used by the schema UI example.",
|
|
50
|
+
"bodyMarkdown": "# Welcome\n\nThis body is edited with a markdown template."
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"kind": "collection",
|
|
3
|
+
"idField": "id",
|
|
4
|
+
"description": "Authors that can own CMS pages.",
|
|
5
|
+
"fields": {
|
|
6
|
+
"id": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"required": true,
|
|
9
|
+
"description": "Stable author id."
|
|
10
|
+
},
|
|
11
|
+
"name": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"required": true,
|
|
14
|
+
"description": "Author display name."
|
|
15
|
+
},
|
|
16
|
+
"email": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"required": true,
|
|
19
|
+
"unique": true,
|
|
20
|
+
"description": "Author email address."
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"seed": [
|
|
24
|
+
{
|
|
25
|
+
"id": "u_1",
|
|
26
|
+
"name": "Ada Lovelace",
|
|
27
|
+
"email": "ada@example.com"
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { defineConfig, mergeManifest } from '@async/db/config';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
dbDir: './db',
|
|
6
|
+
outputs: {
|
|
7
|
+
stateDir: './.db',
|
|
8
|
+
types: './.db/types/index.d.ts',
|
|
9
|
+
committedTypes: './src/generated/db.types.d.ts',
|
|
10
|
+
schemaManifest: './src/generated/db.schema.json',
|
|
11
|
+
},
|
|
12
|
+
types: {
|
|
13
|
+
enabled: true,
|
|
14
|
+
emitComments: true,
|
|
15
|
+
},
|
|
16
|
+
schemaManifest: {
|
|
17
|
+
customizeResource({ resourceName, defaultManifest }) {
|
|
18
|
+
if (resourceName !== 'pages') {
|
|
19
|
+
return defaultManifest;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return mergeManifest(defaultManifest, {
|
|
23
|
+
editor: {
|
|
24
|
+
title: 'Pages',
|
|
25
|
+
description: 'CMS pages edited from generated schema metadata.',
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
customizeField({ resourceName, fieldName, defaultManifest }) {
|
|
31
|
+
if (resourceName !== 'pages') {
|
|
32
|
+
return defaultManifest;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (fieldName === 'bodyMarkdown') {
|
|
36
|
+
return mergeManifest(defaultManifest, {
|
|
37
|
+
ui: {
|
|
38
|
+
label: 'Body',
|
|
39
|
+
component: 'markdown',
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (fieldName === 'status') {
|
|
45
|
+
return mergeManifest(defaultManifest, {
|
|
46
|
+
ui: {
|
|
47
|
+
component: 'segmented-control',
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return defaultManifest;
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
});
|