@aotter/mantle 0.1.5-alpha.1 → 0.2.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +166 -298
- package/dist/auth/adapter.d.ts +32 -0
- package/dist/auth/adapter.js +288 -0
- package/dist/auth/admin.d.ts +3 -0
- package/dist/auth/admin.js +21 -0
- package/dist/auth/caller.d.ts +86 -0
- package/dist/auth/caller.js +155 -0
- package/dist/auth/hardening.d.ts +24 -0
- package/dist/auth/hardening.js +40 -0
- package/dist/auth/identity.d.ts +121 -0
- package/dist/auth/identity.js +203 -0
- package/dist/auth/oauth.d.ts +63 -0
- package/dist/auth/oauth.js +217 -0
- package/dist/auth/resource-seeds.js +10 -0
- package/dist/auth/routes.d.ts +32 -0
- package/dist/auth/routes.js +226 -0
- package/dist/build/compiler.d.ts +721 -0
- package/dist/build/compiler.js +7029 -0
- package/dist/build/spec/domain/model/ManifestGrammar.d.ts +439 -0
- package/dist/build/spec/domain/model/RuntimePlan.d.ts +168 -0
- package/dist/build/spec/domain/model/SqlIr.d.ts +129 -0
- package/dist/build/spec/domain/model/UserFields.d.ts +21 -0
- package/dist/build/spec/domain/service/PlanFingerprint.d.ts +7 -0
- package/dist/build/spec/kernel/diagnostic.d.ts +108 -0
- package/dist/bun/assets.d.ts +2 -0
- package/dist/bun/assets.js +24 -0
- package/dist/domain/adminOrder.js +24 -0
- package/dist/domain/columns.js +57 -0
- package/dist/domain/describe/chunk-ZVXBGP7Y.js +424 -0
- package/dist/domain/describe/index.d.ts +58 -0
- package/dist/domain/describe/index.js +115 -0
- package/dist/domain/describe/target-hash.d.ts +8 -0
- package/dist/domain/describe/target-hash.js +12 -0
- package/dist/domain/describe/targets.d.ts +40 -0
- package/dist/domain/entry.js +33 -0
- package/dist/domain/generated-tools.js +19 -0
- package/dist/domain/generation.d.ts +16 -0
- package/dist/domain/generation.js +1 -0
- package/dist/domain/input.js +17 -0
- package/dist/domain/model.js +1 -0
- package/dist/domain/paging.js +230 -0
- package/dist/domain/recipes.js +24 -0
- package/dist/domain/userReferences.js +5 -0
- package/dist/domain/wireScalars.js +47 -0
- package/dist/infrastructure/adminEntries.js +153 -0
- package/dist/infrastructure/adminPaging.js +72 -0
- package/dist/infrastructure/artifacts.js +71 -0
- package/dist/infrastructure/authSchema.js +83 -0
- package/dist/infrastructure/bundle.js +188 -0
- package/dist/infrastructure/cli.js +118 -0
- package/dist/infrastructure/generate.d.ts +12 -0
- package/dist/infrastructure/generate.js +189 -0
- package/dist/infrastructure/generateAuth.d.ts +8 -0
- package/dist/infrastructure/generateAuth.js +74 -0
- package/dist/infrastructure/help.js +60 -0
- package/dist/infrastructure/init.js +54 -0
- package/dist/infrastructure/inputs.js +41 -0
- package/dist/infrastructure/mounts.js +25 -0
- package/dist/infrastructure/wrangler.js +109 -0
- package/dist/kernel/authorization.d.ts +4 -0
- package/dist/kernel/authorization.js +16 -0
- package/dist/kernel/binds.d.ts +60 -0
- package/dist/kernel/binds.js +49 -0
- package/dist/kernel/caller-identity.d.ts +24 -0
- package/dist/kernel/caller-identity.js +22 -0
- package/dist/kernel/contract-error.d.ts +12 -0
- package/dist/kernel/contract-error.js +14 -0
- package/dist/kernel/contracts.d.ts +143 -0
- package/dist/kernel/contracts.js +97 -0
- package/dist/kernel/cron.d.ts +1 -0
- package/dist/kernel/cron.js +58 -0
- package/dist/kernel/dialect/common.d.ts +38 -0
- package/dist/kernel/dialect/common.js +6 -0
- package/dist/kernel/dialect/postgres.d.ts +16 -0
- package/dist/kernel/dialect/postgres.js +18 -0
- package/dist/kernel/dialect/sqlite.d.ts +20 -0
- package/dist/kernel/dialect/sqlite.js +34 -0
- package/dist/kernel/drain.d.ts +5 -0
- package/dist/kernel/drain.js +35 -0
- package/dist/kernel/driver/bun-sqlite.d.ts +19 -0
- package/dist/kernel/driver/bun-sqlite.js +77 -0
- package/dist/kernel/driver/d1.d.ts +24 -0
- package/dist/kernel/driver/d1.js +22 -0
- package/dist/kernel/driver/postgres.d.ts +25 -0
- package/dist/kernel/driver/postgres.js +99 -0
- package/dist/kernel/driver/transaction-context.d.ts +10 -0
- package/dist/kernel/driver/transaction-context.js +29 -0
- package/dist/kernel/email.d.ts +28 -0
- package/dist/kernel/email.js +38 -0
- package/dist/kernel/host-access.d.ts +10 -0
- package/dist/kernel/host-access.js +65 -0
- package/dist/kernel/host-caller.d.ts +39 -0
- package/dist/kernel/host-caller.js +56 -0
- package/dist/kernel/json-body.d.ts +4 -0
- package/dist/kernel/json-body.js +44 -0
- package/dist/kernel/mcp-apps.d.ts +69 -0
- package/dist/kernel/mcp-apps.js +40 -0
- package/dist/kernel/mcp-call.d.ts +5 -0
- package/dist/kernel/mcp-call.js +25 -0
- package/dist/kernel/mcp-handler.js +371 -0
- package/dist/kernel/mcp.d.ts +110 -0
- package/dist/kernel/mcp.js +50 -0
- package/dist/kernel/media.d.ts +27 -0
- package/dist/kernel/media.js +216 -0
- package/dist/kernel/paging.d.ts +55 -0
- package/dist/kernel/paging.js +95 -0
- package/dist/kernel/publishing.d.ts +4 -0
- package/dist/kernel/publishing.js +16 -0
- package/dist/kernel/r2-media.d.ts +42 -0
- package/dist/kernel/r2-media.js +78 -0
- package/dist/kernel/rest-dispatch.js +38 -0
- package/dist/kernel/rest-router.js +64 -0
- package/dist/kernel/rest.d.ts +58 -0
- package/dist/kernel/rest.js +41 -0
- package/dist/kernel/scalars.d.ts +6 -0
- package/dist/kernel/scalars.js +44 -0
- package/dist/kernel/search.js +5 -0
- package/dist/kernel/site-types.d.ts +146 -0
- package/dist/kernel/site-types.js +1 -0
- package/dist/kernel/site.d.ts +39 -0
- package/dist/kernel/site.js +32 -0
- package/dist/kernel/store.d.ts +175 -0
- package/dist/kernel/store.js +269 -0
- package/dist/kernel/surface.d.ts +10 -0
- package/dist/kernel/surface.js +19 -0
- package/dist/kernel/sweep.d.ts +17 -0
- package/dist/kernel/sweep.js +27 -0
- package/dist/kernel/translations.d.ts +1 -0
- package/dist/kernel/translations.js +13 -0
- package/dist/kernel/user-caller.d.ts +31 -0
- package/dist/kernel/user-caller.js +67 -0
- package/dist/kernel/user-field-name.js +3 -0
- package/dist/kernel/user-fields.d.ts +35 -0
- package/dist/kernel/user-fields.js +81 -0
- package/dist/kernel/validation.d.ts +15 -0
- package/dist/kernel/validation.js +54 -0
- package/dist/kernel/web-gateway.js +68 -0
- package/dist/kernel/web-head.js +15 -0
- package/dist/kernel/web-index.js +40 -0
- package/dist/kernel/web-response.js +8 -0
- package/dist/kernel/web.d.ts +77 -0
- package/dist/kernel/web.js +124 -0
- package/dist/kernel/where.js +27 -0
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.js +1 -0
- package/dist/usecase/adminBindings.js +143 -0
- package/dist/usecase/adminClient.js +87 -0
- package/dist/usecase/adminDescriptors.js +107 -0
- package/dist/usecase/generate.js +166 -0
- package/dist/usecase/handlers.js +21 -0
- package/dist/usecase/mcp-media.js +17 -0
- package/dist/usecase/mcp.js +100 -0
- package/dist/usecase/paging.js +71 -0
- package/dist/usecase/publishing.js +63 -0
- package/dist/usecase/refusals.js +27 -0
- package/dist/usecase/rest.js +54 -0
- package/dist/usecase/search.js +7 -0
- package/dist/usecase/site.js +39 -0
- package/dist/usecase/stores.js +64 -0
- package/dist/usecase/tool-version.js +9 -0
- package/dist/usecase/translations.js +78 -0
- package/dist/usecase/ttl.js +20 -0
- package/dist/usecase/validation.js +241 -0
- package/dist/usecase/web.js +23 -0
- package/docs/examples/README.md +39 -18
- package/docs/examples/app-shell/.dev.vars.example +4 -0
- package/docs/examples/app-shell/README.md +121 -0
- package/docs/examples/app-shell/accept.mjs +91 -0
- package/docs/examples/app-shell/gitignore +7 -0
- package/docs/examples/app-shell/package.json +43 -0
- package/docs/examples/app-shell/pnpm-workspace.yaml +8 -0
- package/docs/examples/app-shell/smoke-kit.mjs +168 -0
- package/docs/examples/app-shell/src/auth.ts +58 -0
- package/docs/examples/app-shell/src/handlers.ts +5 -0
- package/docs/examples/app-shell/src/index.ts +4 -0
- package/docs/examples/app-shell/src/routes.ts +14 -0
- package/docs/examples/app-shell/src/schedule.ts +8 -0
- package/docs/examples/app-shell/src/service.ts +70 -0
- package/docs/examples/app-shell/src/sign-in.ts +41 -0
- package/docs/examples/app-shell/src/signup.ts +8 -0
- package/docs/examples/app-shell/tsconfig.json +26 -0
- package/docs/examples/app-shell/worker-configuration.d.ts +22 -0
- package/docs/examples/app-shell/wrangler.jsonc +62 -0
- package/docs/examples/club-events/README.md +65 -0
- package/docs/examples/club-events/manifests/club-events.yaml +247 -0
- package/docs/examples/club-events/smoke.mjs +127 -0
- package/docs/examples/club-events/src/handlers.ts +25 -0
- package/docs/examples/club-events/src/signup.ts +9 -0
- package/docs/examples/generated-web/README.md +78 -0
- package/docs/examples/generated-web/posts.yaml +38 -0
- package/docs/examples/generated-web/seed.sql +6 -0
- package/docs/examples/generated-web/src/worker.ts +43 -0
- package/docs/examples/generated-web/tsconfig.json +8 -0
- package/docs/examples/generated-web/wrangler.jsonc +8 -0
- package/docs/examples/purchasing/.dev.vars.example +6 -0
- package/docs/examples/purchasing/README.md +99 -0
- package/docs/examples/purchasing/manifests/purchasing.yaml +374 -0
- package/docs/examples/purchasing/seed.sql +4 -0
- package/docs/examples/purchasing/smoke.mjs +191 -0
- package/docs/examples/purchasing/src/admin.tsx +13 -0
- package/docs/examples/purchasing/src/handlers.ts +33 -0
- package/docs/examples/purchasing/src/notify.ts +29 -0
- package/docs/examples/purchasing/src/requests-page.ts +57 -0
- package/docs/examples/purchasing/src/routes.ts +53 -0
- package/docs/examples/purchasing/src/schedule.ts +31 -0
- package/docs/examples/purchasing/src/signup.ts +5 -0
- package/docs/examples/purchasing/src/supplier.ts +32 -0
- package/docs/examples/purchasing/wrangler.jsonc +69 -0
- package/docs/examples/recipes/README.md +60 -0
- package/docs/examples/recipes/manifests/recipes.yaml +75 -0
- package/docs/examples/recipes/smoke.mjs +102 -0
- package/docs/examples/recipes/src/media.ts +13 -0
- package/docs/examples/recipes/src/pages.ts +99 -0
- package/docs/examples/recipes/src/routes.ts +71 -0
- package/docs/examples/recipes/src/site-config.ts +12 -0
- package/docs/examples/recipes/wrangler.jsonc +74 -0
- package/docs/handbook/cloudflare/authentication.md +180 -322
- package/docs/handbook/cloudflare/chatgpt-sites.md +5 -23
- package/docs/handbook/cloudflare/deploy-and-operate.md +55 -77
- package/docs/handbook/cloudflare/media-r2.md +61 -205
- package/docs/handbook/cloudflare/service-entry.md +239 -0
- package/docs/handbook/concepts/authorization.md +10 -107
- package/docs/handbook/concepts/four-atoms.md +9 -168
- package/docs/handbook/concepts/lifecycle-and-locales.md +9 -132
- package/docs/handbook/concepts/mcp-and-agents.md +24 -121
- package/docs/handbook/concepts/procedures-and-triggers.md +5 -217
- package/docs/handbook/concepts/runtime-and-adapters.md +15 -169
- package/docs/handbook/concepts/views.md +10 -185
- package/docs/handbook/examples/hub.md +3 -8
- package/docs/handbook/guides/adapter-guide.md +11 -0
- package/docs/handbook/guides/admin-ui.md +115 -133
- package/docs/handbook/guides/agent-setup.md +64 -74
- package/docs/handbook/guides/agent-workflow-acceptance.md +232 -0
- package/docs/handbook/guides/email.md +86 -0
- package/docs/handbook/guides/local-testing.md +40 -0
- package/docs/handbook/guides/mcp-apps.md +560 -0
- package/docs/handbook/guides/native-admin.md +566 -0
- package/docs/handbook/guides/native-execution.md +133 -0
- package/docs/handbook/guides/oauth.md +219 -0
- package/docs/handbook/guides/postgres-adapters.md +56 -0
- package/docs/handbook/guides/public-pages.md +87 -0
- package/docs/handbook/guides/size-and-startup.md +9 -0
- package/docs/handbook/guides/sql-patterns.md +266 -0
- package/docs/handbook/guides/typed-queries.md +211 -107
- package/docs/handbook/navigation.json +176 -55
- package/docs/handbook/reference/admin-descriptors.md +53 -0
- package/docs/handbook/reference/authorization.md +39 -266
- package/docs/handbook/reference/describe.md +56 -0
- package/docs/handbook/reference/diagnostics.md +19 -186
- package/docs/handbook/reference/features.md +45 -55
- package/docs/handbook/reference/manifest.md +6 -129
- package/docs/handbook/reference/procedure.md +11 -303
- package/docs/handbook/reference/schema.md +64 -240
- package/docs/handbook/reference/site-config.md +5 -218
- package/docs/handbook/reference/sql.md +64 -0
- package/docs/handbook/reference/surface.md +392 -201
- package/docs/handbook/reference/trigger.md +56 -192
- package/docs/handbook/reference/view.md +24 -243
- package/docs/handbook/releases/index.md +244 -77
- package/docs/handbook/start/agents.md +45 -0
- package/docs/handbook/start/overview.md +9 -48
- package/docs/handbook/start/project-and-cli.md +51 -104
- package/docs/handbook/start/quickstart-worker.md +43 -178
- package/docs/skills/develop/SKILL.md +79 -249
- package/docs/skills/integrate/SKILL.md +39 -50
- package/docs/skills/media-gc/SKILL.md +34 -10
- package/docs/skills/provision/SKILL.md +36 -186
- package/docs/skills/update/SKILL.md +23 -38
- package/docs/source/scripts/postgres-adapter.ts +101 -0
- package/docs/upgrade-0.1-to-0.2.md +227 -0
- package/package.json +120 -131
- package/skills/README.md +48 -108
- package/skills/mantle/SKILL.md +76 -0
- package/dist/admin-ui.d.ts +0 -2
- package/dist/admin-ui.d.ts.map +0 -1
- package/dist/admin-ui.js +0 -2
- package/dist/admin-ui.js.map +0 -1
- package/dist/admin.d.ts +0 -2
- package/dist/admin.d.ts.map +0 -1
- package/dist/admin.js +0 -2
- package/dist/admin.js.map +0 -1
- package/dist/auth.d.ts +0 -2
- package/dist/auth.d.ts.map +0 -1
- package/dist/auth.js +0 -2
- package/dist/auth.js.map +0 -1
- package/dist/bun.d.ts +0 -2
- package/dist/bun.d.ts.map +0 -1
- package/dist/bun.js +0 -2
- package/dist/bun.js.map +0 -1
- package/dist/cli/generate-cloudflare.d.ts +0 -7
- package/dist/cli/generate-cloudflare.d.ts.map +0 -1
- package/dist/cli/generate-cloudflare.js +0 -123
- package/dist/cli/generate-cloudflare.js.map +0 -1
- package/dist/cli/generate-project.d.ts +0 -25
- package/dist/cli/generate-project.d.ts.map +0 -1
- package/dist/cli/generate-project.js +0 -282
- package/dist/cli/generate-project.js.map +0 -1
- package/dist/cli/generate-sites.d.ts +0 -8
- package/dist/cli/generate-sites.d.ts.map +0 -1
- package/dist/cli/generate-sites.js +0 -273
- package/dist/cli/generate-sites.js.map +0 -1
- package/dist/cli/generate.d.ts +0 -20
- package/dist/cli/generate.d.ts.map +0 -1
- package/dist/cli/generate.js +0 -299
- package/dist/cli/generate.js.map +0 -1
- package/dist/cli/harness.d.ts +0 -3
- package/dist/cli/harness.d.ts.map +0 -1
- package/dist/cli/harness.js +0 -214
- package/dist/cli/harness.js.map +0 -1
- package/dist/cli/main.d.ts +0 -3
- package/dist/cli/main.d.ts.map +0 -1
- package/dist/cli/main.js +0 -77
- package/dist/cli/main.js.map +0 -1
- package/dist/cli/skills.d.ts +0 -3
- package/dist/cli/skills.d.ts.map +0 -1
- package/dist/cli/skills.js +0 -128
- package/dist/cli/skills.js.map +0 -1
- package/dist/cloudflare.d.ts +0 -2
- package/dist/cloudflare.d.ts.map +0 -1
- package/dist/cloudflare.js +0 -2
- package/dist/cloudflare.js.map +0 -1
- package/dist/codegen/emitMantleModule.d.ts +0 -22
- package/dist/codegen/emitMantleModule.d.ts.map +0 -1
- package/dist/codegen/emitMantleModule.js +0 -291
- package/dist/codegen/emitMantleModule.js.map +0 -1
- package/dist/codegen.d.ts +0 -2
- package/dist/codegen.d.ts.map +0 -1
- package/dist/codegen.js +0 -2
- package/dist/codegen.js.map +0 -1
- package/dist/runtime-testing.d.ts +0 -2
- package/dist/runtime-testing.d.ts.map +0 -1
- package/dist/runtime-testing.js +0 -2
- package/dist/runtime-testing.js.map +0 -1
- package/dist/runtime.d.ts +0 -2
- package/dist/runtime.d.ts.map +0 -1
- package/dist/runtime.js +0 -2
- package/dist/runtime.js.map +0 -1
- package/dist/spec.d.ts +0 -2
- package/dist/spec.d.ts.map +0 -1
- package/dist/spec.js +0 -2
- package/dist/spec.js.map +0 -1
- package/dist/vercel-libsql.d.ts +0 -2
- package/dist/vercel-libsql.d.ts.map +0 -1
- package/dist/vercel-libsql.js +0 -2
- package/dist/vercel-libsql.js.map +0 -1
- package/dist/vercel.d.ts +0 -2
- package/dist/vercel.d.ts.map +0 -1
- package/dist/vercel.js +0 -2
- package/dist/vercel.js.map +0 -1
- package/dist/web.d.ts +0 -2
- package/dist/web.d.ts.map +0 -1
- package/dist/web.js +0 -2
- package/dist/web.js.map +0 -1
- package/docs/adapter-guide.md +0 -222
- package/docs/adr/0001-four-atom-manifest-model.md +0 -440
- package/docs/adr/0002-closed-enums-for-bindings.md +0 -253
- package/docs/adr/0007-ai-as-primary-author.md +0 -473
- package/docs/adr/0008-structured-diagnostic-shape.md +0 -338
- package/docs/adr/0009-consumer-supplied-manifests.md +0 -149
- package/docs/adr/0010-locale-and-translates.md +0 -453
- package/docs/adr/0011-adapter-port-spec.md +0 -281
- package/docs/adr/0012-views-as-public-rest.md +0 -161
- package/docs/adr/0013-agent-provisioned-consumer-projects.md +0 -154
- package/docs/adr/0014-auth-better-auth-and-multi-tenant-mcp.md +0 -900
- package/docs/adr/0016-site-semantic-layer.md +0 -70
- package/docs/adr/0017-media-multi-variant-agent-side-optimization.md +0 -181
- package/docs/adr/0018-core-starters-repository-boundary.md +0 -179
- package/docs/adr/0019-sealed-manifest-runtime-pipeline.md +0 -240
- package/docs/adr/0020-builtin-handler-contracts-and-matched-upsert.md +0 -199
- package/docs/adr/0021-retire-starter-scaffolding.md +0 -30
- package/docs/adr/0022-caller-observed-version-occ.md +0 -212
- package/docs/adr/0023-port-failure-contract.md +0 -69
- package/docs/adr/0024-manifest-native-schema-tables.md +0 -264
- package/docs/adr/0025-reserved-native-columns-and-published-only-public-views.md +0 -105
- package/docs/adr/0026-progressive-generate.md +0 -36
- package/docs/adr/0027-scheduled-procedure-triggers.md +0 -31
- package/docs/adr/0028-schema-ttl-expiry.md +0 -33
- package/docs/adr/README.md +0 -81
- package/docs/adr/adr-lite-803-request-diagnostics.md +0 -38
- package/docs/adr/adr-lite-808-route-readiness.md +0 -47
- package/docs/adr/adr-lite-809-bounded-public-content.md +0 -71
- package/docs/adr/adr-lite-812-native-parity.md +0 -150
- package/docs/adr/adr-lite-823-home-statistics.md +0 -64
- package/docs/adr/adr-lite-842-mcp-authoring.md +0 -30
- package/docs/adr/adr-lite-845-frontend-client.md +0 -38
- package/docs/adr/adr-lite-861-admin-webmcp.md +0 -42
- package/docs/adr/adr-lite-909-admin-ui-kit.md +0 -37
- package/docs/agent-prompts.md +0 -64
- package/docs/api-mcp-authorization.md +0 -5
- package/docs/assets/mantle-admin-developer.png +0 -0
- package/docs/assets/mantle-admin-operations.png +0 -0
- package/docs/assets/mantle-hero.jpg +0 -0
- package/docs/auth-hosting-model.md +0 -166
- package/docs/cloudflare-low-level-composition.md +0 -5
- package/docs/consumer-onboarding-audit.md +0 -65
- package/docs/deferred-lifecycle-queues.md +0 -5
- package/docs/design-atoms.md +0 -16
- package/docs/design-references/editorial-blog-2026-05-05.md +0 -218
- package/docs/direct-authoring.md +0 -5
- package/docs/examples/builtin-commerce.md +0 -269
- package/docs/examples/builtin-intake.md +0 -143
- package/docs/examples/builtin-legal-documents.md +0 -189
- package/docs/examples/builtin-procurement.md +0 -241
- package/docs/examples/builtin-publication.md +0 -241
- package/docs/examples/builtin-reservation.md +0 -149
- package/docs/examples/cf-primitives-commerce-inventory.md +0 -809
- package/docs/examples/cf-primitives-guarded-api.md +0 -429
- package/docs/examples/cf-primitives-intake-hooks.md +0 -319
- package/docs/examples/host-chatgpt-sites/.openai/hosting.json +0 -1
- package/docs/examples/host-chatgpt-sites/README.md +0 -70
- package/docs/examples/host-chatgpt-sites/drizzle/0000_sites_users.sql +0 -8
- package/docs/examples/host-chatgpt-sites/drizzle/0001_mantle.sql +0 -294
- package/docs/examples/host-chatgpt-sites/drizzle/0002_article_cover.sql +0 -5
- package/docs/examples/host-chatgpt-sites/drizzle/0003_store_instance_id.sql +0 -1
- package/docs/examples/host-chatgpt-sites/drizzle/0004_mantle.sql +0 -10
- package/docs/examples/host-chatgpt-sites/drizzle/0005_mantle.sql +0 -24
- package/docs/examples/host-chatgpt-sites/drizzle/meta/_journal.json +0 -1
- package/docs/examples/host-chatgpt-sites/drizzle/meta/mantle-state.json +0 -60
- package/docs/examples/host-chatgpt-sites/manifests/site.yaml +0 -27
- package/docs/examples/host-chatgpt-sites/package.json +0 -1
- package/docs/examples/host-chatgpt-sites/public/site.css +0 -1
- package/docs/examples/host-chatgpt-sites/scripts/build.mjs +0 -13
- package/docs/examples/host-chatgpt-sites/scripts/check.mjs +0 -101
- package/docs/examples/host-chatgpt-sites/scripts/migration.mjs +0 -43
- package/docs/examples/host-chatgpt-sites/src/chatgpt-auth.ts +0 -66
- package/docs/examples/host-chatgpt-sites/src/index.ts +0 -46
- package/docs/examples/host-chatgpt-sites/src/mcp.ts +0 -49
- package/docs/examples/host-chatgpt-sites/src/media.ts +0 -109
- package/docs/examples/host-chatgpt-sites/src/r2-lab.ts +0 -38
- package/docs/examples/host-chatgpt-sites/src/storage-fingerprint.json +0 -1
- package/docs/examples/host-chatgpt-sites/src/web.ts +0 -35
- package/docs/examples/host-chatgpt-sites/tsconfig.json +0 -1
- package/docs/examples/host-chatgpt-sites/wrangler.jsonc +0 -10
- package/docs/examples/host-local-admin-otp/.dev.vars.example +0 -3
- package/docs/examples/host-local-admin-otp/README.md +0 -80
- package/docs/examples/host-local-admin-otp/ensure-dev-vars.mjs +0 -5
- package/docs/examples/host-local-admin-otp/manifests/site.yaml +0 -25
- package/docs/examples/host-local-admin-otp/package.json +0 -29
- package/docs/examples/host-local-admin-otp/public/.gitkeep +0 -1
- package/docs/examples/host-local-admin-otp/smoke.mjs +0 -141
- package/docs/examples/host-local-admin-otp/src/index.ts +0 -54
- package/docs/examples/host-local-admin-otp/tsconfig.json +0 -17
- package/docs/examples/host-local-admin-otp/wrangler.jsonc +0 -23
- package/docs/examples/host-minimal-worker/README.md +0 -41
- package/docs/examples/host-minimal-worker/manifests/site.yaml +0 -25
- package/docs/examples/host-minimal-worker/package.json +0 -26
- package/docs/examples/host-minimal-worker/smoke.mjs +0 -23
- package/docs/examples/host-minimal-worker/src/index.ts +0 -4
- package/docs/examples/host-minimal-worker/tsconfig.json +0 -17
- package/docs/examples/host-minimal-worker/wrangler.jsonc +0 -22
- package/docs/handbook/chatgpt-sites/equipment-checkout.md +0 -231
- package/docs/handbook/chatgpt-sites/generated-app.md +0 -84
- package/docs/handbook/chatgpt-sites/host-reference.md +0 -113
- package/docs/handbook/chatgpt-sites/index.md +0 -133
- package/docs/handbook/cloudflare/bindings.md +0 -291
- package/docs/handbook/cloudflare/conventional-worker.md +0 -166
- package/docs/handbook/cloudflare/deferred-hooks-queues.md +0 -170
- package/docs/handbook/cloudflare/low-level-composition.md +0 -169
- package/docs/handbook/cloudflare/public-web.md +0 -144
- package/docs/handbook/cloudflare/site-chrome.md +0 -75
- package/docs/handbook/examples/commerce-transaction.md +0 -11
- package/docs/handbook/examples/commerce.md +0 -11
- package/docs/handbook/examples/guarded-api.md +0 -10
- package/docs/handbook/examples/intake-form.md +0 -12
- package/docs/handbook/examples/intake-hooks.md +0 -11
- package/docs/handbook/examples/legal-documents.md +0 -10
- package/docs/handbook/examples/procurement-approvals.md +0 -10
- package/docs/handbook/examples/publication.md +0 -10
- package/docs/handbook/examples/reservation.md +0 -10
- package/docs/handbook/start/quickstart-admin.md +0 -52
- package/docs/labels.md +0 -71
- package/docs/media-uploads.md +0 -5
- package/docs/migration-0.1.2.md +0 -13
- package/docs/performance-harness.md +0 -228
- package/docs/release-process.md +0 -244
- package/docs/schema-indexes.md +0 -5
- package/docs/sealed-pipeline-ownership.md +0 -101
- package/docs/skills/plugin/SKILL.md +0 -132
- package/docs/skills/theme/SKILL.md +0 -77
- package/docs/spec-only-host-adoption.md +0 -157
- package/docs/transaction-patterns.md +0 -5
- package/skills/develop/SKILL.md +0 -258
- package/skills/install/SKILL.md +0 -112
- package/skills/integrate/SKILL.md +0 -60
- package/skills/media-gc/SKILL.md +0 -85
- package/skills/plugin/SKILL.md +0 -132
- package/skills/provision/SKILL.md +0 -194
- package/skills/theme/SKILL.md +0 -77
- package/skills/update/SKILL.md +0 -51
- package/templates/chatgpt-sites/auth.ts +0 -66
- package/templates/chatgpt-sites/build.mjs +0 -14
- package/templates/chatgpt-sites/env.ts +0 -1
- package/templates/chatgpt-sites/mcp.ts +0 -48
- package/templates/chatgpt-sites/public-mcp.ts +0 -29
- package/templates/chatgpt-sites/smoke-local.mjs +0 -20
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Store SQL and its IR (ADR-0034). The IR is libpg-query's parse tree for the
|
|
3
|
+
* supported subset, with source locations stripped and every relation tagged
|
|
4
|
+
* `table` or `cte`. Mantle designs no node types, so nodes are typed loosely on
|
|
5
|
+
* purpose: the dialect's allowlist (`src/core/sql/allowlist.ts`), not a TypeScript type, constrains
|
|
6
|
+
* them.
|
|
7
|
+
*
|
|
8
|
+
* Pure types and constants only. Nothing here imports the parser.
|
|
9
|
+
*/
|
|
10
|
+
import type { DiagnosticCode } from "../../kernel/diagnostic.js";
|
|
11
|
+
import type { UserScope } from "./UserFields.js";
|
|
12
|
+
export type SqlNode = Record<string, any>;
|
|
13
|
+
/** The PostgreSQL grammar version a plan records (libpg-query 18: PG 18.0.4). */
|
|
14
|
+
export declare const PG_GRAMMAR = 180004;
|
|
15
|
+
/** The `SQL_*` codes of the diagnostic kernel; each is described in docs/handbook/reference/diagnostics.md. */
|
|
16
|
+
export type SqlDiagnosticCode = Extract<DiagnosticCode, `SQL_${string}` | `USER_FIELD_${string}` | "USER_REF_SCOPE_ONLY" | "AUTH_ROLE_REMOVED">;
|
|
17
|
+
export interface SqlSchemaDef {
|
|
18
|
+
/** Translation reads share their parent's current visibility on this field. */
|
|
19
|
+
readonly translates?: {
|
|
20
|
+
readonly parent: string;
|
|
21
|
+
readonly on: string;
|
|
22
|
+
};
|
|
23
|
+
/** column that holds the owner; every read and write is filtered on it */
|
|
24
|
+
readonly scope?: string;
|
|
25
|
+
/** AND-joined value terms of the row template, beside the owner column `scope`. */
|
|
26
|
+
readonly userScopes?: readonly UserScope[];
|
|
27
|
+
/** a declared timestamptz field the author writes; a row is invisible once it is `ttlSeconds` old (a NULL never expires) */
|
|
28
|
+
readonly ttl?: string;
|
|
29
|
+
readonly ttlSeconds?: number;
|
|
30
|
+
/** lifecycle `publishing`: a public caller sees only published rows */
|
|
31
|
+
readonly publishing?: boolean;
|
|
32
|
+
/** declared fields and their Mantle types: text integer real bool json timestamptz date numeric(p,s) geo */
|
|
33
|
+
readonly fields: Readonly<Record<string, string>>;
|
|
34
|
+
/** lower-cased column -> the name the JSON Schema declares (the plan has it; `notNullColumns` reads it with `schema`) */
|
|
35
|
+
readonly names?: Readonly<Record<string, string>>;
|
|
36
|
+
/** the Schema's JSON Schema, of which storage reads only what is required and nullable */
|
|
37
|
+
readonly schema?: {
|
|
38
|
+
readonly required?: readonly string[];
|
|
39
|
+
readonly properties?: Readonly<Record<string, {
|
|
40
|
+
readonly type?: unknown;
|
|
41
|
+
readonly nullable?: boolean;
|
|
42
|
+
readonly enum?: readonly unknown[];
|
|
43
|
+
readonly oneOf?: readonly {
|
|
44
|
+
readonly const?: unknown;
|
|
45
|
+
}[];
|
|
46
|
+
}>>;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* What the allowlist reads off every Schema of a context: computed from `schemas` (`schemaColumns`), once per plan by a caller that
|
|
51
|
+
* checks many programs against one plan, or per program when absent.
|
|
52
|
+
*/
|
|
53
|
+
export interface SchemaColumns {
|
|
54
|
+
/** every declared column name (a geo field also as its `_lat` and `_lng` columns) */
|
|
55
|
+
readonly known: ReadonlySet<string>;
|
|
56
|
+
/** the scope columns, folded */
|
|
57
|
+
readonly scopes: ReadonlySet<string>;
|
|
58
|
+
/** column name -> its type, when every Schema that declares it agrees */
|
|
59
|
+
readonly types: ReadonlyMap<string, string>;
|
|
60
|
+
}
|
|
61
|
+
export interface SqlContext {
|
|
62
|
+
readonly schemas: Readonly<Record<string, SqlSchemaDef>>;
|
|
63
|
+
/** `schemaColumns(schemas)`, precomputed; must be of these `schemas` */
|
|
64
|
+
readonly columns?: SchemaColumns;
|
|
65
|
+
/** declared input properties and their Mantle types */
|
|
66
|
+
readonly inputs: Readonly<Record<string, string>>;
|
|
67
|
+
readonly kind: "view" | "procedure";
|
|
68
|
+
/** a public View: a caller sees published rows only, even across a join */
|
|
69
|
+
readonly public?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* The Views a FROM may name (ADR-0037 decision 3), by name with `-` as `_`: an internal View's validated tagged SELECT, which the
|
|
72
|
+
* compiler expands as D1 CTE dependencies or native FROM subqueries, or why that View cannot be read. Compile side only.
|
|
73
|
+
*/
|
|
74
|
+
readonly views?: Readonly<Record<string, {
|
|
75
|
+
readonly select?: SqlNode;
|
|
76
|
+
readonly refusal?: string;
|
|
77
|
+
}>>;
|
|
78
|
+
}
|
|
79
|
+
/** A refusal of Store SQL. `line` and `column` are 1-based; `token` is the source text there. */
|
|
80
|
+
export interface SqlDiagnostic {
|
|
81
|
+
readonly code: SqlDiagnosticCode;
|
|
82
|
+
readonly message: string;
|
|
83
|
+
readonly offset?: number;
|
|
84
|
+
readonly line?: number;
|
|
85
|
+
readonly column?: number;
|
|
86
|
+
readonly token?: string;
|
|
87
|
+
}
|
|
88
|
+
/** What the plan carries for one SQL source: the grammar it was parsed by, and the IR statements. */
|
|
89
|
+
export interface SqlPlan {
|
|
90
|
+
readonly grammar: number;
|
|
91
|
+
readonly stmts: readonly SqlNode[];
|
|
92
|
+
}
|
|
93
|
+
/** Shared-cache eligibility of validated, expanded View IR; source text is display metadata, not execution. */
|
|
94
|
+
export declare function viewCacheProblem(stmts: readonly SqlNode[], schemas: Readonly<Record<string, SqlSchemaDef>>): string | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* The columns storage creates for a Schema, each with its type: the native ones, the scope field, `status` on a publishing Schema,
|
|
97
|
+
* and each field (a geo field as its `_lat` and `_lng` columns). `created_at`/`updated_at` are typed per dialect, so `native`.
|
|
98
|
+
*/
|
|
99
|
+
export declare function storageColumns(s: {
|
|
100
|
+
readonly fields?: Readonly<Record<string, string>>;
|
|
101
|
+
readonly scope?: string;
|
|
102
|
+
readonly publishing?: boolean;
|
|
103
|
+
}): Map<string, string>;
|
|
104
|
+
/** The aggregate functions either dialect's SQL may call: outside a window and without GROUP BY, one makes a select return one row even over none. */
|
|
105
|
+
export declare const AGGREGATES: ReadonlySet<string>;
|
|
106
|
+
/** The native columns storage declares NOT NULL (`status` only on a publishing Schema, the only one that has it); `author_id` is nullable. */
|
|
107
|
+
export declare const NATIVE_NOT_NULL: ReadonlySet<string>;
|
|
108
|
+
/** Each native field a manifest names (in an index, say) -> its storage column, which SQL names. */
|
|
109
|
+
export declare const NATIVE_COLUMNS: Readonly<Record<string, string>>;
|
|
110
|
+
/**
|
|
111
|
+
* The columns an `operational` Schema's database refuses NULL in beyond the native ones: each field its JSON Schema requires and
|
|
112
|
+
* does not allow null (a geo field as its two columns). A `publishing` Schema has none: its drafts may be incomplete. This is the one
|
|
113
|
+
* rule; the initial storage SQL of both dialects and the generated Store's `orderBy` type read it.
|
|
114
|
+
*/
|
|
115
|
+
export declare function notNullColumns(s: SqlSchemaDef): Set<string>;
|
|
116
|
+
/** A field whose name is a column storage creates for something else (`_rid`, or another geo field's `_lat`/`_lng`), or undefined. */
|
|
117
|
+
export declare function storageColumnClash(fields: Readonly<Record<string, string>>): string | undefined;
|
|
118
|
+
/** The functions a Schema check may call, by their bare name: each takes one argument of a type SQLite and PostgreSQL both accept. */
|
|
119
|
+
export declare const CHECK_FUNCTIONS: ReadonlyMap<string, {
|
|
120
|
+
readonly takes: readonly string[];
|
|
121
|
+
readonly returns: "text" | "integer" | "argument";
|
|
122
|
+
}>;
|
|
123
|
+
/**
|
|
124
|
+
* Why a Schema check cannot run in the table's DDL as written, or undefined. Storage prints a check unlowered into a trigger or
|
|
125
|
+
* CHECK constraint, so it names only `columns` (`storageColumns` of its own Schema, unqualified) through operators and
|
|
126
|
+
* `CHECK_FUNCTIONS`: no subquery, no cast, and nothing the runtime binds per request (`auth.uid()`, `now()`) or a dialect spells
|
|
127
|
+
* its own way. Operand types beyond the functions' arguments are the database's to check at boot.
|
|
128
|
+
*/
|
|
129
|
+
export declare function checkShapeProblem(v: unknown, columns: ReadonlyMap<string, string>): string | undefined;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface UserFieldSpec {
|
|
2
|
+
readonly type: "string" | "number";
|
|
3
|
+
readonly integer?: true;
|
|
4
|
+
readonly multiple: boolean;
|
|
5
|
+
readonly enum?: readonly (string | number)[];
|
|
6
|
+
}
|
|
7
|
+
/** One value term of a row template: `column IN auth.user('field')`. */
|
|
8
|
+
export interface UserScope {
|
|
9
|
+
readonly column: string;
|
|
10
|
+
readonly field: string;
|
|
11
|
+
readonly type: "string" | "number";
|
|
12
|
+
}
|
|
13
|
+
export interface RowTemplate {
|
|
14
|
+
readonly owner?: string;
|
|
15
|
+
readonly terms: readonly {
|
|
16
|
+
readonly column: string;
|
|
17
|
+
readonly field: string;
|
|
18
|
+
}[];
|
|
19
|
+
}
|
|
20
|
+
/** AND-joined `column = auth.uid()` or `column IN auth.user('field')` terms only. */
|
|
21
|
+
export declare function parseRowTemplate(text: unknown): RowTemplate | string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RuntimePlan } from "../model/RuntimePlan.js";
|
|
2
|
+
/** JSON with sorted keys, so equal plans serialize to equal text whatever built them. */
|
|
3
|
+
export declare function canonical(v: unknown): string;
|
|
4
|
+
/** 32-bit FNV-1a (hex): a short deterministic name, not a security boundary. */
|
|
5
|
+
export declare const fnv: (s: string) => string;
|
|
6
|
+
/** SHA-256 (hex) of the plan without its own fingerprint: it crosses a trust boundary, so it is cryptographic (ADR-0032 decision 10). */
|
|
7
|
+
export declare function planFingerprint(plan: Omit<RuntimePlan, "fingerprint">): Promise<string>;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured diagnostic shape — see ADR-0008. Used uniformly across
|
|
3
|
+
* static validation, boot-time, and runtime feedback. The public `test`
|
|
4
|
+
* phase remains reserved for consumer-authored test diagnostics; Core's
|
|
5
|
+
* shipped performance harnesses emit purpose-shaped reports instead.
|
|
6
|
+
*
|
|
7
|
+
* Codes are unprefixed UPPER_SNAKE strings; the `phase` field
|
|
8
|
+
* disambiguates which loop emitted each diagnostic. The same `code`
|
|
9
|
+
* may appear in multiple phases when it names the same root cause —
|
|
10
|
+
* AI consumers can group by code OR filter by phase.
|
|
11
|
+
*
|
|
12
|
+
* `candidates` is security-sensitive at runtime; `redactForWire`
|
|
13
|
+
* strips it before HTTP egress.
|
|
14
|
+
*/
|
|
15
|
+
export type Phase = "validate" | "test" | "boot" | "runtime";
|
|
16
|
+
/**
|
|
17
|
+
* Closed catalog of diagnostic codes the SDK emits across all phases.
|
|
18
|
+
* Per ADR-0008, spec **defines** the catalog; runtime / cli / adapters
|
|
19
|
+
* **emit** them. Codes in the cross-phase and runtime-only sections
|
|
20
|
+
* below are not raised by spec source — they live here because the
|
|
21
|
+
* catalog is the public contract, not the union of what spec happens
|
|
22
|
+
* to throw today. Adding a new code is a grammar-revise event
|
|
23
|
+
* (ADR-0001).
|
|
24
|
+
*
|
|
25
|
+
* Single source of truth: the const array drives `DiagnosticCode`
|
|
26
|
+
* (type), so adding a code is one edit.
|
|
27
|
+
*/
|
|
28
|
+
export declare const DIAGNOSTIC_CODES: readonly ["AUTH_ROLE_REMOVED", "USER_FIELD_VALUES_UNENUMERATED", "USER_FIELD_INVALID", "USER_FIELD_CONFLICT", "USER_FIELD_POSITION", "USER_REF_SCOPE_ONLY", "USER_SCOPE_PUBLIC_ANON_EMPTY", "RESOURCE_EXHAUSTED", "RESOURCE_UNAVAILABLE", "RATE_LIMITED", "OUTCOME_UNKNOWN", "PARTIAL_FAILURE", "PRECONDITION_FAILED", "INVALID_MANIFEST_ENVELOPE", "DUPLICATE_NAME", "VIEW_INPUT_INVALID_SHAPE", "VIEW_INPUT_RESERVED_NAME", "VIEW_CACHE_INVALID", "VIEW_UI_INVALID", "REQUIRED_FIELD_UNKNOWN", "INVALID_PATTERN", "JSON_SCHEMA_UNSUPPORTED", "JSON_SCHEMA_REF_INVALID", "JSON_SCHEMA_LIMIT_EXCEEDED", "AUTH_PREDICATE_NOT_IN_ENUM", "GUARD_PROCEDURE_UNKNOWN", "GUARD_SELF_REFERENCE", "GUARD_PROCEDURE_NOT_REF", "GUARD_CHAIN_NOT_ALLOWED", "SCHEMA_INDEX_INVALID", "SCHEMA_INDEX_FIELD_UNKNOWN", "UNIQUE_INDEX_FIELD_UNKNOWN", "SCHEMA_SEARCH_INVALID", "SCHEMA_SEARCH_FIELD_UNKNOWN", "SCHEMA_TTL_INVALID", "SCHEMA_UI_INVALID", "SCHEMA_NAME_CASE_COLLISION", "SCHEMA_READER_NAME_COLLISION", "FIELD_NAME_CASE_COLLISION", "MANIFEST_ROOT_NOT_FOUND", "MANIFEST_READ_FAILED", "GENERATE_FEATURE_DEPENDENCY_MISSING", "SQL_SYNTAX", "SQL_UNSUPPORTED", "SQL_FUNCTION", "SQL_RELATION", "SQL_COLUMN", "SQL_WRITE", "SQL_SHAPE", "SQL_TYPE", "FIXTURE_SCHEMA_VIOLATION", "HANDLER_NOT_REGISTERED", "HANDLER_NOT_DECLARED", "PLAN_FINGERPRINT_MISMATCH", "SCHEDULE_NOT_WIRED", "STORAGE_CHANGE_BLOCKED", "STORAGE_TABLE_NOT_OWNED", "INVOCATION_DEPTH_EXCEEDED", "TRIGGER_TARGET_PROCEDURE_UNKNOWN", "SCHEDULE_INPUT_INVALID", "SCHEDULE_AUTH_INVALID", "TRIGGER_PATH_COLLISION", "TRIGGER_PATH_INVALID", "MCP_TOOL_NAME_COLLISION", "MCP_TOOL_DESCRIPTION_MISSING", "MCP_TOOL_INPUT_UNION_AMBIGUOUS", "MCP_TOOL_INPUT_UNBOUNDED", "MANTLE_REF_INVALID", "PROCEDURE_TARGET_INVALID", "PROCEDURE_NOT_FOUND", "NOT_FOUND", "METHOD_NOT_ALLOWED", "LIFECYCLE_SCHEMA_UNKNOWN", "LIFECYCLE_HOOK_REJECTED", "LIFECYCLE_TARGET_NOT_REF", "SCHEMA_LOCALIZED_REQUIRES_SITE_LOCALES", "TRANSLATES_PARENT_UNKNOWN", "TRANSLATES_REQUIRES_LOCALIZED", "TRANSLATES_REQUIRES_CONTENT_FIELD", "TRANSLATES_FIELD_NOT_IN_PARENT", "TRANSLATES_FIELD_NOT_IN_CHILD", "TRANSLATES_PARENT_IS_LOCALIZED", "SCHEMA_TTL_TRANSLATION_UNSUPPORTED", "INPUT_VALIDATION_FAILED", "UNAUTHENTICATED", "AUTH_DENIED", "ENTITLEMENT_REQUIRED", "CONFLICT", "DISPATCHER_NOT_BUILT", "INTERNAL_ERROR", "OUTPUT_VALIDATION_FAILED", "INVALID_LOCALE", "MEDIA_NOT_CONFIGURED", "SITE_NOT_CONFIGURED", "MEDIA_UPLOAD_EXPIRED", "MEDIA_OBJECT_NOT_FOUND", "MEDIA_MIME_REJECTED", "MEDIA_SIZE_EXCEEDED", "MEDIA_SVG_REJECTED", "MEDIA_CHECKSUM_MISMATCH", "MEDIA_PURPOSE_REJECTED", "MEDIA_VARIANTS_INCOMPLETE", "MEDIA_VARIANT_SIZE_EXCEEDED", "MEDIA_VARIANTS_SUSPICIOUS_SIZE", "MEDIA_ASSET_NOT_FOUND"];
|
|
29
|
+
export type DiagnosticCode = (typeof DIAGNOSTIC_CODES)[number];
|
|
30
|
+
export interface SourcePosition {
|
|
31
|
+
readonly line: number;
|
|
32
|
+
readonly column: number;
|
|
33
|
+
readonly offset: number;
|
|
34
|
+
}
|
|
35
|
+
export interface SourceSpan {
|
|
36
|
+
readonly start: SourcePosition;
|
|
37
|
+
readonly end: SourcePosition;
|
|
38
|
+
}
|
|
39
|
+
/** Authored location retained independently from a rendered diagnostic path. */
|
|
40
|
+
export interface SourceLocation {
|
|
41
|
+
readonly sourceId: string;
|
|
42
|
+
readonly documentIndex: number;
|
|
43
|
+
/** JSON Pointer inside the YAML document. */
|
|
44
|
+
readonly path: string;
|
|
45
|
+
readonly span?: SourceSpan;
|
|
46
|
+
}
|
|
47
|
+
export interface Diagnostic {
|
|
48
|
+
readonly code: DiagnosticCode;
|
|
49
|
+
readonly phase: Phase;
|
|
50
|
+
readonly severity: "error" | "warning";
|
|
51
|
+
readonly path: string;
|
|
52
|
+
readonly source?: SourceLocation;
|
|
53
|
+
readonly value?: unknown;
|
|
54
|
+
readonly expected?: string;
|
|
55
|
+
readonly candidates?: readonly string[];
|
|
56
|
+
readonly suggestion?: string;
|
|
57
|
+
readonly message: string;
|
|
58
|
+
/** Safe effect/retry facts supplied by a port; never provider payloads. */
|
|
59
|
+
readonly failure?: {
|
|
60
|
+
readonly outcome: "not-applied" | "partial" | "unknown";
|
|
61
|
+
readonly retry: "never" | "after-change" | "safe" | "reconcile";
|
|
62
|
+
readonly resource?: string;
|
|
63
|
+
};
|
|
64
|
+
/** Why a `CONFLICT` write failed (ADR-0032 decision 1); `opIndex` names the statement in the batch (ADR-0034). */
|
|
65
|
+
readonly conflict?: {
|
|
66
|
+
readonly opIndex?: number;
|
|
67
|
+
readonly reason: "lock" | "expect" | "unique";
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Build a Diagnostic with a derived default `message`. Call sites may supply
|
|
72
|
+
* contextual prose, but the structured fields remain authoritative.
|
|
73
|
+
*/
|
|
74
|
+
export declare function makeDiagnostic(input: Omit<Diagnostic, "message"> & {
|
|
75
|
+
message?: string;
|
|
76
|
+
}): Diagnostic;
|
|
77
|
+
/** Phase-stamping helpers — equivalent to `makeDiagnostic({...input, phase})`
|
|
78
|
+
* but read cleaner at call sites. `phase: "test"` has no Core helper because
|
|
79
|
+
* the shipped performance harnesses emit purpose-shaped reports; the phase
|
|
80
|
+
* remains part of the public Diagnostic contract for consumer tests. */
|
|
81
|
+
export declare const validateDiagnostic: (input: PhaselessInput) => Diagnostic;
|
|
82
|
+
export declare const bootDiagnostic: (input: PhaselessInput) => Diagnostic;
|
|
83
|
+
export declare const runtimeDiagnostic: (input: PhaselessInput) => Diagnostic;
|
|
84
|
+
type PhaselessInput = Omit<Diagnostic, "phase" | "message"> & {
|
|
85
|
+
message?: string;
|
|
86
|
+
};
|
|
87
|
+
declare const BRAND: unique symbol;
|
|
88
|
+
/**
|
|
89
|
+
* Throwable carrier for one or more Diagnostics. Layers that surface
|
|
90
|
+
* an error across a transport boundary (HTTP handler, MCP tool call,
|
|
91
|
+
* render pipeline) throw this so the boundary catch can detect a
|
|
92
|
+
* structured payload and emit it on the wire instead of falling back
|
|
93
|
+
* to the INTERNAL_ERROR envelope reserved for genuinely unexpected
|
|
94
|
+
* throws.
|
|
95
|
+
*/
|
|
96
|
+
export declare class DiagnosticError extends Error {
|
|
97
|
+
/**
|
|
98
|
+
* A handler bundled with its own copy of this class (a closed-module artifact) still throws a DiagnosticError: `instanceof`
|
|
99
|
+
* matches the brand, not the class identity, so the runtime keeps its code instead of reporting INTERNAL_ERROR.
|
|
100
|
+
*/
|
|
101
|
+
static [Symbol.hasInstance](value: unknown): boolean;
|
|
102
|
+
readonly [BRAND] = true;
|
|
103
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
104
|
+
constructor(diagnostic: Diagnostic | readonly Diagnostic[], options?: ErrorOptions);
|
|
105
|
+
/** First diagnostic — convenience for single-diagnostic call sites. */
|
|
106
|
+
get diagnostic(): Diagnostic;
|
|
107
|
+
}
|
|
108
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Bun owns files; no SQLite, runtime or compiler import enters this optional host reader. */
|
|
2
|
+
import { realpath, stat } from "node:fs/promises";
|
|
3
|
+
import { resolve, sep } from "node:path";
|
|
4
|
+
/** Native file response, or null for missing or invalid paths. */
|
|
5
|
+
export function bunAdminAssets(root) {
|
|
6
|
+
const base = resolve(root);
|
|
7
|
+
return async (path) => {
|
|
8
|
+
try {
|
|
9
|
+
path = decodeURIComponent(path);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
if (/[\u0000-\u001f\\]/.test(path))
|
|
15
|
+
return null;
|
|
16
|
+
const target = resolve(base, `.${path}`);
|
|
17
|
+
if (!target.startsWith(`${base}${sep}`))
|
|
18
|
+
return null;
|
|
19
|
+
const physical = await realpath(target).catch(() => "");
|
|
20
|
+
if (!physical || !physical.startsWith(`${await realpath(base)}${sep}`) || !(await stat(physical)).isFile())
|
|
21
|
+
return null;
|
|
22
|
+
return new Response(Bun.file(physical));
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Selected Admin orders mirror the existing UI's indexed, required fields and native controls. */
|
|
2
|
+
import { adminIndexColumns, NATIVE_NOT_NULL, notNullColumns } from "../build/compiler.js";
|
|
3
|
+
import { dialect as sqlite } from "../kernel/dialect/sqlite.js";
|
|
4
|
+
import { dialect as postgres } from "../kernel/dialect/postgres.js";
|
|
5
|
+
import { declaredType } from "./columns.js";
|
|
6
|
+
export function adminOrder(schema) {
|
|
7
|
+
const notNull = notNullColumns(schema);
|
|
8
|
+
const fields = adminIndexColumns(schema);
|
|
9
|
+
return Object.fromEntries(["id", "updated_at", ...(schema.publishing ? ["status"] : []), ...fields].flatMap(f => {
|
|
10
|
+
const type = declaredType(schema.fields, f) ?? "text";
|
|
11
|
+
const kind = type === "text" ? "text" : type === "bool" ? "bool" : type === "int4" ? "int4" : ["integer", "int8"].includes(type) ? "int" : ["real", "float8"].includes(type) ? "float" : type === "date" ? "date" : type === "timestamptz" ? "timestamp" : undefined;
|
|
12
|
+
return kind ? [[f, [kind, !NATIVE_NOT_NULL.has(f) && !notNull.has(f)]]] : [];
|
|
13
|
+
}));
|
|
14
|
+
}
|
|
15
|
+
/** Deployment-only indexes; no request attempts to converge storage. */
|
|
16
|
+
export function adminIndexes(schemas, isSqlite) {
|
|
17
|
+
const d = isSqlite ? sqlite : postgres;
|
|
18
|
+
return Object.values(schemas).flatMap(s => ["created_at", "updated_at", ...(s.publishing ? ["status"] : [])].flatMap(field => [[], ...(s.scope ? [[s.scope]] : [])].flatMap(prefix => {
|
|
19
|
+
const columns = [...prefix, field, "id"];
|
|
20
|
+
if ([...(s.indexes ?? []), ...(s.unique ?? [])].some(i => columns.every((c, n) => i[n] === c)))
|
|
21
|
+
return [];
|
|
22
|
+
return [`CREATE INDEX ${d.ident(`_mantle_admin_${s.name}_${prefix.length ? "scoped_" : ""}${field}`)} ON ${d.ident(s.name)} (${columns.map(d.ident).join(", ")})`];
|
|
23
|
+
})));
|
|
24
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/** What a column's Mantle type means to generated code, in one place: Views, Stores and wire forms all read it here. */
|
|
2
|
+
import { jsonOutputs, viewOutputs } from "../build/compiler.js";
|
|
3
|
+
/** A column's declared type, including the system version and timestamps. @internal */
|
|
4
|
+
/** A JSON Schema `readOnly` property is server-maintained (counters, totals): Admin's generic writes never set it. */
|
|
5
|
+
export const serverOwned = (schema, column) => Object.entries(schema.properties ?? {}).some(([name, property]) => name.toLowerCase() === column && property?.readOnly === true);
|
|
6
|
+
export const declaredType = (fields, column) => fields[column] ?? (column === "version" ? "integer" : column === "created_at" || column === "updated_at" || column === "published_at" ? "timestamptz" : undefined);
|
|
7
|
+
/** A computed output that is a JSON document by construction (json_group_array, json_set, jsonb_agg, …) is typed `json`. */
|
|
8
|
+
const computedJson = (plan, view, key) => jsonOutputs(plan.views[view]).has(key);
|
|
9
|
+
/** Compiler-owned schema type metadata, including aggregates that inherit a field's presentation type and computed JSON documents. @internal */
|
|
10
|
+
export function outputType(plan, view, key) {
|
|
11
|
+
const columns = plan.views[view]?.columns;
|
|
12
|
+
const field = columns && Object.hasOwn(columns, key) ? columns[key] : undefined;
|
|
13
|
+
const schema = field && plan.schemas[field.schema];
|
|
14
|
+
return schema ? declaredType(schema.fields, field.field) : computedJson(plan, view, key) ? "json" : undefined;
|
|
15
|
+
}
|
|
16
|
+
/** Transport lineage excludes other expressions/aggregates; existing temporal SQL formatting is retained. */
|
|
17
|
+
export function boundaryType(plan, view, key) {
|
|
18
|
+
const field = viewOutputs(plan.views[view], plan.schemas, new Map(), false, false).columns[key];
|
|
19
|
+
const type = outputType(plan, view, key);
|
|
20
|
+
return field || type === "date" || type === "timestamptz" || computedJson(plan, view, key) ? type : undefined;
|
|
21
|
+
}
|
|
22
|
+
/** Declared output lineage and computed JSON documents; other computed columns retain their native values. */
|
|
23
|
+
export function outputConversions(plan, view, target) {
|
|
24
|
+
const postgres = target.endsWith("postgres");
|
|
25
|
+
const columns = viewOutputs(plan.views[view], plan.schemas, new Map(), false, false).columns;
|
|
26
|
+
return [...Object.keys(columns), ...jsonOutputs(plan.views[view])].flatMap(key => {
|
|
27
|
+
const type = outputType(plan, view, key);
|
|
28
|
+
return conversion(key, type, !postgres);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/** Shared static conversion recipe for Views and Admin collections. */
|
|
32
|
+
export function conversion(key, type, sqlite) {
|
|
33
|
+
return type && ["integer", "int8", "int4"].includes(type) ? [[key, "int"]]
|
|
34
|
+
: sqlite && (type === "json" || type === "bool") ? [[key, type]] : [];
|
|
35
|
+
}
|
|
36
|
+
/** Client-visible declared output type, identical on every target. */
|
|
37
|
+
export function wireType(type, notNull = false) {
|
|
38
|
+
const value = !type ? "unknown" : ["integer", "int8", "int4"].includes(type) ? "number | string"
|
|
39
|
+
: scalarType(type);
|
|
40
|
+
return value === "unknown" || notNull ? value : `${value} | null`;
|
|
41
|
+
}
|
|
42
|
+
const scalarType = (type) => type === "bool" ? "boolean" : ["integer", "int4", "int8", "real", "float8"].includes(type) ? "number" : type === "json" ? "unknown" : type === "geo" ? "{lat:number;lng:number}" : "string";
|
|
43
|
+
/**
|
|
44
|
+
* The driver-native value a column of this type comes back as, `| null` unless `notNull`; declared timestamps and dates arrive as the
|
|
45
|
+
* SQL's wire-form text. A column with no declared type (a computed output) is `unknown`, which already includes null. @internal
|
|
46
|
+
*/
|
|
47
|
+
export function nativeType(type, sqlite, notNull = false) {
|
|
48
|
+
const native = !type ? "unknown" : ["date", "timestamptz"].includes(type) ? "string" : sqlite
|
|
49
|
+
? type === "bool" ? "number" : type === "json" ? "string" : scalarType(type)
|
|
50
|
+
: ["integer", "int8"].includes(type) ? "number | string | bigint" : scalarType(type);
|
|
51
|
+
return notNull || native === "unknown" ? native : `${native} | null`;
|
|
52
|
+
}
|
|
53
|
+
/** The value a caller of the typed Store passes for a column of this type. JSON is an object or array (the Store tells it by its JS type, so a bare string would be bound as text). @internal */
|
|
54
|
+
export const inputType = (type) => type === "timestamptz" ? "string | Date" : type === "json" ? "object" : scalarType(type);
|
|
55
|
+
/** Wrap only a selected transport page. */
|
|
56
|
+
export const boundaryPage = (page, fields) => fields.length
|
|
57
|
+
? `(db, caller, input, paging) => ${page}(db, caller, input, paging).then(page => ({ ...page, rows: wireRows(page.rows, ${JSON.stringify(fields)}) }))` : page;
|