@aotter/mantle 0.1.4 → 0.2.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -306
- package/dist/admin/consent.d.ts +17 -0
- package/dist/admin/consent.d.ts.map +1 -0
- package/dist/admin/consent.js +17 -0
- package/dist/admin/consent.js.map +1 -0
- package/dist/admin/createAdminSurface.d.ts +22 -0
- package/dist/admin/createAdminSurface.d.ts.map +1 -0
- package/dist/admin/createAdminSurface.js +589 -0
- package/dist/admin/createAdminSurface.js.map +1 -0
- package/dist/admin/developerConsole.d.ts +264 -0
- package/dist/admin/developerConsole.d.ts.map +1 -0
- package/dist/admin/developerConsole.js +136 -0
- package/dist/admin/developerConsole.js.map +1 -0
- package/dist/admin/identity.d.ts +62 -0
- package/dist/admin/identity.d.ts.map +1 -0
- package/dist/admin/identity.js +7 -0
- package/dist/admin/identity.js.map +1 -0
- package/dist/admin/index.d.ts +4 -0
- package/dist/admin/index.d.ts.map +1 -0
- package/dist/admin/index.js +4 -0
- package/dist/admin/index.js.map +1 -0
- package/dist/admin/procedureFlow.d.ts +25 -0
- package/dist/admin/procedureFlow.d.ts.map +1 -0
- package/dist/admin/procedureFlow.js +154 -0
- package/dist/admin/procedureFlow.js.map +1 -0
- package/dist/auth/ConsoleEmailSender.d.ts +15 -0
- package/dist/auth/ConsoleEmailSender.d.ts.map +1 -0
- package/dist/auth/ConsoleEmailSender.js +19 -0
- package/dist/auth/ConsoleEmailSender.js.map +1 -0
- package/dist/auth/appleClientSecret.d.ts +75 -0
- package/dist/auth/appleClientSecret.d.ts.map +1 -0
- package/dist/auth/appleClientSecret.js +116 -0
- package/dist/auth/appleClientSecret.js.map +1 -0
- package/dist/auth/buildAuth.d.ts +4565 -0
- package/dist/auth/buildAuth.d.ts.map +1 -0
- package/dist/auth/buildAuth.js +307 -0
- package/dist/auth/buildAuth.js.map +1 -0
- package/dist/auth/callerResolver.d.ts +48 -0
- package/dist/auth/callerResolver.d.ts.map +1 -0
- package/dist/auth/callerResolver.js +49 -0
- package/dist/auth/callerResolver.js.map +1 -0
- package/dist/auth/createAuthRoutes.d.ts +22 -0
- package/dist/auth/createAuthRoutes.d.ts.map +1 -0
- package/dist/auth/createAuthRoutes.js +128 -0
- package/dist/auth/createAuthRoutes.js.map +1 -0
- package/dist/auth/createMantleAuth.d.ts +3 -0
- package/dist/auth/createMantleAuth.d.ts.map +1 -0
- package/dist/auth/createMantleAuth.js +483 -0
- package/dist/auth/createMantleAuth.js.map +1 -0
- package/dist/auth/db.d.ts +17 -0
- package/dist/auth/db.d.ts.map +1 -0
- package/dist/auth/db.js +24 -0
- package/dist/auth/db.js.map +1 -0
- package/dist/auth/emailTemplates.d.ts +7 -0
- package/dist/auth/emailTemplates.d.ts.map +1 -0
- package/dist/auth/emailTemplates.js +27 -0
- package/dist/auth/emailTemplates.js.map +1 -0
- package/dist/auth/index.d.ts +9 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +7 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/methods.d.ts +717 -0
- package/dist/auth/methods.d.ts.map +1 -0
- package/dist/auth/methods.js +321 -0
- package/dist/auth/methods.js.map +1 -0
- package/dist/auth/oauthTokens.d.ts +24 -0
- package/dist/auth/oauthTokens.d.ts.map +1 -0
- package/dist/auth/oauthTokens.js +146 -0
- package/dist/auth/oauthTokens.js.map +1 -0
- package/dist/auth/setupIncomplete.d.ts +16 -0
- package/dist/auth/setupIncomplete.d.ts.map +1 -0
- package/dist/auth/setupIncomplete.js +50 -0
- package/dist/auth/setupIncomplete.js.map +1 -0
- package/dist/auth/types.d.ts +440 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +10 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/bun/index.d.ts +65 -0
- package/dist/bun/index.d.ts.map +1 -0
- package/dist/bun/index.js +130 -0
- package/dist/bun/index.js.map +1 -0
- package/dist/cli/emitModule.d.ts +7 -0
- package/dist/cli/emitModule.d.ts.map +1 -0
- package/dist/cli/emitModule.js +127 -0
- package/dist/cli/emitModule.js.map +1 -0
- package/dist/cli/generate.d.ts +4 -16
- package/dist/cli/generate.d.ts.map +1 -1
- package/dist/cli/generate.js +332 -165
- package/dist/cli/generate.js.map +1 -1
- package/dist/cli/main.d.ts +1 -1
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +15 -71
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/preset.d.ts +18 -0
- package/dist/cli/preset.d.ts.map +1 -0
- package/dist/cli/preset.js +352 -0
- package/dist/cli/preset.js.map +1 -0
- package/dist/cloudflare/index.d.ts +21 -0
- package/dist/cloudflare/index.d.ts.map +1 -0
- package/dist/cloudflare/index.js +14 -0
- package/dist/cloudflare/index.js.map +1 -0
- package/dist/cloudflare/r2Media.d.ts +43 -0
- package/dist/cloudflare/r2Media.d.ts.map +1 -0
- package/dist/cloudflare/r2Media.js +69 -0
- package/dist/cloudflare/r2Media.js.map +1 -0
- package/dist/core/caller.d.ts +35 -0
- package/dist/core/caller.d.ts.map +1 -0
- package/dist/core/caller.js +3 -0
- package/dist/core/caller.js.map +1 -0
- package/dist/core/createMantle.d.ts +22 -0
- package/dist/core/createMantle.d.ts.map +1 -0
- package/dist/core/createMantle.js +117 -0
- package/dist/core/createMantle.js.map +1 -0
- package/dist/core/dialect.d.ts +41 -0
- package/dist/core/dialect.d.ts.map +1 -0
- package/dist/core/dialect.js +7 -0
- package/dist/core/dialect.js.map +1 -0
- package/dist/core/driver.d.ts +17 -0
- package/dist/core/driver.d.ts.map +1 -0
- package/dist/core/driver.js +2 -0
- package/dist/core/driver.js.map +1 -0
- package/dist/core/email.d.ts +17 -0
- package/dist/core/email.d.ts.map +1 -0
- package/dist/core/email.js +2 -0
- package/dist/core/email.js.map +1 -0
- package/dist/core/index.d.ts +16 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +16 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/invocation.d.ts +66 -0
- package/dist/core/invocation.d.ts.map +1 -0
- package/dist/core/invocation.js +3 -0
- package/dist/core/invocation.js.map +1 -0
- package/dist/core/runtime/auth.d.ts +9 -0
- package/dist/core/runtime/auth.d.ts.map +1 -0
- package/dist/core/runtime/auth.js +39 -0
- package/dist/core/runtime/auth.js.map +1 -0
- package/dist/core/runtime/createRuntime.d.ts +23 -0
- package/dist/core/runtime/createRuntime.d.ts.map +1 -0
- package/dist/core/runtime/createRuntime.js +214 -0
- package/dist/core/runtime/createRuntime.js.map +1 -0
- package/dist/core/runtime/verifyPlan.d.ts +34 -0
- package/dist/core/runtime/verifyPlan.d.ts.map +1 -0
- package/dist/core/runtime/verifyPlan.js +301 -0
- package/dist/core/runtime/verifyPlan.js.map +1 -0
- package/dist/core/service.d.ts +45 -0
- package/dist/core/service.d.ts.map +1 -0
- package/dist/core/service.js +2 -0
- package/dist/core/service.js.map +1 -0
- package/dist/core/site.d.ts +117 -0
- package/dist/core/site.d.ts.map +1 -0
- package/dist/core/site.js +2 -0
- package/dist/core/site.js.map +1 -0
- package/dist/core/siteConfig.d.ts +5 -0
- package/dist/core/siteConfig.d.ts.map +1 -0
- package/dist/core/siteConfig.js +24 -0
- package/dist/core/siteConfig.js.map +1 -0
- package/dist/core/sql/allowlist.d.ts +65 -0
- package/dist/core/sql/allowlist.d.ts.map +1 -0
- package/dist/core/sql/allowlist.js +705 -0
- package/dist/core/sql/allowlist.js.map +1 -0
- package/dist/core/sql/ast.d.ts +24 -0
- package/dist/core/sql/ast.d.ts.map +1 -0
- package/dist/core/sql/ast.js +32 -0
- package/dist/core/sql/ast.js.map +1 -0
- package/dist/core/sql/compile.d.ts +50 -0
- package/dist/core/sql/compile.d.ts.map +1 -0
- package/dist/core/sql/compile.js +48 -0
- package/dist/core/sql/compile.js.map +1 -0
- package/dist/core/sql/policy.d.ts +121 -0
- package/dist/core/sql/policy.d.ts.map +1 -0
- package/dist/core/sql/policy.js +379 -0
- package/dist/core/sql/policy.js.map +1 -0
- package/dist/core/sql/positions.d.ts +30 -0
- package/dist/core/sql/positions.d.ts.map +1 -0
- package/dist/core/sql/positions.js +22 -0
- package/dist/core/sql/positions.js.map +1 -0
- package/dist/core/sql/run.d.ts +76 -0
- package/dist/core/sql/run.d.ts.map +1 -0
- package/dist/core/sql/run.js +267 -0
- package/dist/core/sql/run.js.map +1 -0
- package/dist/core/store/createStore.d.ts +49 -0
- package/dist/core/store/createStore.d.ts.map +1 -0
- package/dist/core/store/createStore.js +227 -0
- package/dist/core/store/createStore.js.map +1 -0
- package/dist/core/store/cursor.d.ts +4 -0
- package/dist/core/store/cursor.d.ts.map +1 -0
- package/dist/core/store/cursor.js +22 -0
- package/dist/core/store/cursor.js.map +1 -0
- package/dist/core/store/json.d.ts +80 -0
- package/dist/core/store/json.d.ts.map +1 -0
- package/dist/core/store/json.js +342 -0
- package/dist/core/store/json.js.map +1 -0
- package/dist/core/store.d.ts +160 -0
- package/dist/core/store.d.ts.map +1 -0
- package/dist/core/store.js +2 -0
- package/dist/core/store.js.map +1 -0
- package/dist/core/wire.d.ts +20 -0
- package/dist/core/wire.d.ts.map +1 -0
- package/dist/core/wire.js +84 -0
- package/dist/core/wire.js.map +1 -0
- package/dist/core/withCaller.d.ts +16 -0
- package/dist/core/withCaller.d.ts.map +1 -0
- package/dist/core/withCaller.js +29 -0
- package/dist/core/withCaller.js.map +1 -0
- package/dist/d1/adapter.d.ts +12 -0
- package/dist/d1/adapter.d.ts.map +1 -0
- package/dist/d1/adapter.js +23 -0
- package/dist/d1/adapter.js.map +1 -0
- package/dist/d1/codec.d.ts +14 -0
- package/dist/d1/codec.d.ts.map +1 -0
- package/dist/d1/codec.js +136 -0
- package/dist/d1/codec.js.map +1 -0
- package/dist/d1/compile/index.d.ts +9 -0
- package/dist/d1/compile/index.d.ts.map +1 -0
- package/dist/d1/compile/index.js +9 -0
- package/dist/d1/compile/index.js.map +1 -0
- package/dist/d1/dialect.d.ts +4 -0
- package/dist/d1/dialect.d.ts.map +1 -0
- package/dist/d1/dialect.js +13 -0
- package/dist/d1/dialect.js.map +1 -0
- package/dist/d1/executor.d.ts +13 -0
- package/dist/d1/executor.d.ts.map +1 -0
- package/dist/d1/executor.js +91 -0
- package/dist/d1/executor.js.map +1 -0
- package/dist/d1/index.d.ts +6 -0
- package/dist/d1/index.d.ts.map +1 -0
- package/dist/d1/index.js +6 -0
- package/dist/d1/index.js.map +1 -0
- package/dist/d1/lower.d.ts +8 -0
- package/dist/d1/lower.d.ts.map +1 -0
- package/dist/d1/lower.js +167 -0
- package/dist/d1/lower.js.map +1 -0
- package/dist/d1/media.d.ts +5 -0
- package/dist/d1/media.d.ts.map +1 -0
- package/dist/d1/media.js +157 -0
- package/dist/d1/media.js.map +1 -0
- package/dist/d1/migrations.d.ts +12 -0
- package/dist/d1/migrations.d.ts.map +1 -0
- package/dist/d1/migrations.js +111 -0
- package/dist/d1/migrations.js.map +1 -0
- package/dist/d1/print.d.ts +28 -0
- package/dist/d1/print.d.ts.map +1 -0
- package/dist/d1/print.js +54 -0
- package/dist/d1/print.js.map +1 -0
- package/dist/d1/site.d.ts +17 -0
- package/dist/d1/site.d.ts.map +1 -0
- package/dist/d1/site.js +63 -0
- package/dist/d1/site.js.map +1 -0
- package/dist/d1/storage.d.ts +34 -0
- package/dist/d1/storage.d.ts.map +1 -0
- package/dist/d1/storage.js +288 -0
- package/dist/d1/storage.js.map +1 -0
- package/dist/d1/tz.d.ts +21 -0
- package/dist/d1/tz.d.ts.map +1 -0
- package/dist/d1/tz.js +54 -0
- package/dist/d1/tz.js.map +1 -0
- package/dist/d1/validator.d.ts +10 -0
- package/dist/d1/validator.d.ts.map +1 -0
- package/dist/d1/validator.js +33 -0
- package/dist/d1/validator.js.map +1 -0
- package/dist/mcp/apps.d.ts +43 -0
- package/dist/mcp/apps.d.ts.map +1 -0
- package/dist/mcp/apps.js +57 -0
- package/dist/mcp/apps.js.map +1 -0
- package/dist/mcp/catalog.d.ts +55 -0
- package/dist/mcp/catalog.d.ts.map +1 -0
- package/dist/mcp/catalog.js +81 -0
- package/dist/mcp/catalog.js.map +1 -0
- package/dist/mcp/createMcpSurface.d.ts +34 -0
- package/dist/mcp/createMcpSurface.d.ts.map +1 -0
- package/dist/mcp/createMcpSurface.js +150 -0
- package/dist/mcp/createMcpSurface.js.map +1 -0
- package/dist/mcp/index.d.ts +4 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +4 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/postgres/adapter.d.ts +20 -0
- package/dist/postgres/adapter.d.ts.map +1 -0
- package/dist/postgres/adapter.js +44 -0
- package/dist/postgres/adapter.js.map +1 -0
- package/dist/postgres/codec.d.ts +13 -0
- package/dist/postgres/codec.d.ts.map +1 -0
- package/dist/postgres/codec.js +110 -0
- package/dist/postgres/codec.js.map +1 -0
- package/dist/postgres/compile/index.d.ts +9 -0
- package/dist/postgres/compile/index.d.ts.map +1 -0
- package/dist/postgres/compile/index.js +9 -0
- package/dist/postgres/compile/index.js.map +1 -0
- package/dist/postgres/driver.d.ts +92 -0
- package/dist/postgres/driver.d.ts.map +1 -0
- package/dist/postgres/driver.js +110 -0
- package/dist/postgres/driver.js.map +1 -0
- package/dist/postgres/executor.d.ts +20 -0
- package/dist/postgres/executor.d.ts.map +1 -0
- package/dist/postgres/executor.js +69 -0
- package/dist/postgres/executor.js.map +1 -0
- package/dist/postgres/index.d.ts +7 -0
- package/dist/postgres/index.d.ts.map +1 -0
- package/dist/postgres/index.js +7 -0
- package/dist/postgres/index.js.map +1 -0
- package/dist/postgres/lower.d.ts +6 -0
- package/dist/postgres/lower.d.ts.map +1 -0
- package/dist/postgres/lower.js +157 -0
- package/dist/postgres/lower.js.map +1 -0
- package/dist/postgres/print.d.ts +11 -0
- package/dist/postgres/print.d.ts.map +1 -0
- package/dist/postgres/print.js +121 -0
- package/dist/postgres/print.js.map +1 -0
- package/dist/postgres/storage.d.ts +19 -0
- package/dist/postgres/storage.d.ts.map +1 -0
- package/dist/postgres/storage.js +201 -0
- package/dist/postgres/storage.js.map +1 -0
- package/dist/postgres/textRows.d.ts +10 -0
- package/dist/postgres/textRows.d.ts.map +1 -0
- package/dist/postgres/textRows.js +44 -0
- package/dist/postgres/textRows.js.map +1 -0
- package/dist/postgres/validator.d.ts +12 -0
- package/dist/postgres/validator.d.ts.map +1 -0
- package/dist/postgres/validator.js +46 -0
- package/dist/postgres/validator.js.map +1 -0
- package/dist/spec/domain/index.d.ts +3 -0
- package/dist/spec/domain/index.d.ts.map +1 -0
- package/dist/spec/domain/index.js +3 -0
- package/dist/spec/domain/index.js.map +1 -0
- package/dist/spec/domain/model/ContentState.d.ts +8 -0
- package/dist/spec/domain/model/ContentState.d.ts.map +1 -0
- package/dist/spec/domain/model/ContentState.js +7 -0
- package/dist/spec/domain/model/ContentState.js.map +1 -0
- package/dist/spec/domain/model/Entry.d.ts +29 -0
- package/dist/spec/domain/model/Entry.d.ts.map +1 -0
- package/dist/spec/domain/model/Entry.js +16 -0
- package/dist/spec/domain/model/Entry.js.map +1 -0
- package/dist/spec/domain/model/Locale.d.ts +30 -0
- package/dist/spec/domain/model/Locale.d.ts.map +1 -0
- package/dist/spec/domain/model/Locale.js +33 -0
- package/dist/spec/domain/model/Locale.js.map +1 -0
- package/dist/spec/domain/model/ManifestGrammar.d.ts +452 -0
- package/dist/spec/domain/model/ManifestGrammar.d.ts.map +1 -0
- package/dist/spec/domain/model/ManifestGrammar.js +149 -0
- package/dist/spec/domain/model/ManifestGrammar.js.map +1 -0
- package/dist/spec/domain/model/MediaMimeAccept.d.ts +55 -0
- package/dist/spec/domain/model/MediaMimeAccept.d.ts.map +1 -0
- package/dist/spec/domain/model/MediaMimeAccept.js +90 -0
- package/dist/spec/domain/model/MediaMimeAccept.js.map +1 -0
- package/dist/spec/domain/model/RuntimePlan.d.ts +94 -0
- package/dist/spec/domain/model/RuntimePlan.d.ts.map +1 -0
- package/dist/spec/domain/model/RuntimePlan.js +4 -0
- package/dist/spec/domain/model/RuntimePlan.js.map +1 -0
- package/dist/spec/domain/model/SiteConfig.d.ts +173 -0
- package/dist/spec/domain/model/SiteConfig.d.ts.map +1 -0
- package/dist/spec/domain/model/SiteConfig.js +13 -0
- package/dist/spec/domain/model/SiteConfig.js.map +1 -0
- package/dist/spec/domain/model/SqlIr.d.ts +96 -0
- package/dist/spec/domain/model/SqlIr.d.ts.map +1 -0
- package/dist/spec/domain/model/SqlIr.js +95 -0
- package/dist/spec/domain/model/SqlIr.js.map +1 -0
- package/dist/spec/domain/model/index.d.ts +14 -0
- package/dist/spec/domain/model/index.d.ts.map +1 -0
- package/dist/spec/domain/model/index.js +14 -0
- package/dist/spec/domain/model/index.js.map +1 -0
- package/dist/spec/domain/service/CloudflareCron.d.ts +2 -0
- package/dist/spec/domain/service/CloudflareCron.d.ts.map +1 -0
- package/dist/spec/domain/service/CloudflareCron.js +63 -0
- package/dist/spec/domain/service/CloudflareCron.js.map +1 -0
- package/dist/spec/domain/service/CrossSchemaChecker.d.ts +34 -0
- package/dist/spec/domain/service/CrossSchemaChecker.d.ts.map +1 -0
- package/dist/spec/domain/service/CrossSchemaChecker.js +114 -0
- package/dist/spec/domain/service/CrossSchemaChecker.js.map +1 -0
- package/dist/spec/domain/service/EntryDataValidator.d.ts +56 -0
- package/dist/spec/domain/service/EntryDataValidator.d.ts.map +1 -0
- package/dist/spec/domain/service/EntryDataValidator.js +88 -0
- package/dist/spec/domain/service/EntryDataValidator.js.map +1 -0
- package/dist/spec/domain/service/JsonSchemaToZod.d.ts +29 -0
- package/dist/spec/domain/service/JsonSchemaToZod.d.ts.map +1 -0
- package/dist/spec/domain/service/JsonSchemaToZod.js +156 -0
- package/dist/spec/domain/service/JsonSchemaToZod.js.map +1 -0
- package/dist/spec/domain/service/LifecycleStateMachine.d.ts +75 -0
- package/dist/spec/domain/service/LifecycleStateMachine.d.ts.map +1 -0
- package/dist/spec/domain/service/LifecycleStateMachine.js +76 -0
- package/dist/spec/domain/service/LifecycleStateMachine.js.map +1 -0
- package/dist/spec/domain/service/LocaleCanonicalizer.d.ts +29 -0
- package/dist/spec/domain/service/LocaleCanonicalizer.d.ts.map +1 -0
- package/dist/spec/domain/service/LocaleCanonicalizer.js +96 -0
- package/dist/spec/domain/service/LocaleCanonicalizer.js.map +1 -0
- package/dist/spec/domain/service/ManifestFieldChecks.d.ts +60 -0
- package/dist/spec/domain/service/ManifestFieldChecks.d.ts.map +1 -0
- package/dist/spec/domain/service/ManifestFieldChecks.js +116 -0
- package/dist/spec/domain/service/ManifestFieldChecks.js.map +1 -0
- package/dist/spec/domain/service/ManifestGraphValidator.d.ts +15 -0
- package/dist/spec/domain/service/ManifestGraphValidator.d.ts.map +1 -0
- package/dist/spec/domain/service/ManifestGraphValidator.js +225 -0
- package/dist/spec/domain/service/ManifestGraphValidator.js.map +1 -0
- package/dist/spec/domain/service/ManifestLinker.d.ts +45 -0
- package/dist/spec/domain/service/ManifestLinker.d.ts.map +1 -0
- package/dist/spec/domain/service/ManifestLinker.js +92 -0
- package/dist/spec/domain/service/ManifestLinker.js.map +1 -0
- package/dist/spec/domain/service/ManifestLocaleTrimmer.d.ts +16 -0
- package/dist/spec/domain/service/ManifestLocaleTrimmer.d.ts.map +1 -0
- package/dist/spec/domain/service/ManifestLocaleTrimmer.js +76 -0
- package/dist/spec/domain/service/ManifestLocaleTrimmer.js.map +1 -0
- package/dist/spec/domain/service/ManifestParser.d.ts +49 -0
- package/dist/spec/domain/service/ManifestParser.d.ts.map +1 -0
- package/dist/spec/domain/service/ManifestParser.js +203 -0
- package/dist/spec/domain/service/ManifestParser.js.map +1 -0
- package/dist/spec/domain/service/ManifestPartition.d.ts +9 -0
- package/dist/spec/domain/service/ManifestPartition.d.ts.map +1 -0
- package/dist/spec/domain/service/ManifestPartition.js +19 -0
- package/dist/spec/domain/service/ManifestPartition.js.map +1 -0
- package/dist/spec/domain/service/ManifestPathDiagnoser.d.ts +33 -0
- package/dist/spec/domain/service/ManifestPathDiagnoser.d.ts.map +1 -0
- package/dist/spec/domain/service/ManifestPathDiagnoser.js +43 -0
- package/dist/spec/domain/service/ManifestPathDiagnoser.js.map +1 -0
- package/dist/spec/domain/service/ManifestSourceSpans.d.ts +10 -0
- package/dist/spec/domain/service/ManifestSourceSpans.d.ts.map +1 -0
- package/dist/spec/domain/service/ManifestSourceSpans.js +76 -0
- package/dist/spec/domain/service/ManifestSourceSpans.js.map +1 -0
- package/dist/spec/domain/service/McpToolNaming.d.ts +25 -0
- package/dist/spec/domain/service/McpToolNaming.d.ts.map +1 -0
- package/dist/spec/domain/service/McpToolNaming.js +50 -0
- package/dist/spec/domain/service/McpToolNaming.js.map +1 -0
- package/dist/spec/domain/service/PlanFingerprint.d.ts +4 -0
- package/dist/spec/domain/service/PlanFingerprint.d.ts.map +1 -0
- package/dist/spec/domain/service/PlanFingerprint.js +14 -0
- package/dist/spec/domain/service/PlanFingerprint.js.map +1 -0
- package/dist/spec/domain/service/ProcedureViewSpecChecks.d.ts +4 -0
- package/dist/spec/domain/service/ProcedureViewSpecChecks.d.ts.map +1 -0
- package/dist/spec/domain/service/ProcedureViewSpecChecks.js +211 -0
- package/dist/spec/domain/service/ProcedureViewSpecChecks.js.map +1 -0
- package/dist/spec/domain/service/SchemaAdminUiChecker.d.ts +42 -0
- package/dist/spec/domain/service/SchemaAdminUiChecker.d.ts.map +1 -0
- package/dist/spec/domain/service/SchemaAdminUiChecker.js +289 -0
- package/dist/spec/domain/service/SchemaAdminUiChecker.js.map +1 -0
- package/dist/spec/domain/service/SchemaIndexChecker.d.ts +33 -0
- package/dist/spec/domain/service/SchemaIndexChecker.d.ts.map +1 -0
- package/dist/spec/domain/service/SchemaIndexChecker.js +256 -0
- package/dist/spec/domain/service/SchemaIndexChecker.js.map +1 -0
- package/dist/spec/domain/service/SchemaSearchChecker.d.ts +11 -0
- package/dist/spec/domain/service/SchemaSearchChecker.d.ts.map +1 -0
- package/dist/spec/domain/service/SchemaSearchChecker.js +78 -0
- package/dist/spec/domain/service/SchemaSearchChecker.js.map +1 -0
- package/dist/spec/domain/service/SchemaSpecChecks.d.ts +31 -0
- package/dist/spec/domain/service/SchemaSpecChecks.d.ts.map +1 -0
- package/dist/spec/domain/service/SchemaSpecChecks.js +445 -0
- package/dist/spec/domain/service/SchemaSpecChecks.js.map +1 -0
- package/dist/spec/domain/service/SiteDefaultsValidator.d.ts +39 -0
- package/dist/spec/domain/service/SiteDefaultsValidator.d.ts.map +1 -0
- package/dist/spec/domain/service/SiteDefaultsValidator.js +194 -0
- package/dist/spec/domain/service/SiteDefaultsValidator.js.map +1 -0
- package/dist/spec/domain/service/SqlClassify.d.ts +19 -0
- package/dist/spec/domain/service/SqlClassify.d.ts.map +1 -0
- package/dist/spec/domain/service/SqlClassify.js +42 -0
- package/dist/spec/domain/service/SqlClassify.js.map +1 -0
- package/dist/spec/domain/service/SqlRefusal.d.ts +16 -0
- package/dist/spec/domain/service/SqlRefusal.d.ts.map +1 -0
- package/dist/spec/domain/service/SqlRefusal.js +20 -0
- package/dist/spec/domain/service/SqlRefusal.js.map +1 -0
- package/dist/spec/domain/service/SqlTypes.d.ts +40 -0
- package/dist/spec/domain/service/SqlTypes.d.ts.map +1 -0
- package/dist/spec/domain/service/SqlTypes.js +110 -0
- package/dist/spec/domain/service/SqlTypes.js.map +1 -0
- package/dist/spec/domain/service/StaffRoleHierarchy.d.ts +3 -0
- package/dist/spec/domain/service/StaffRoleHierarchy.d.ts.map +1 -0
- package/dist/spec/domain/service/StaffRoleHierarchy.js +19 -0
- package/dist/spec/domain/service/StaffRoleHierarchy.js.map +1 -0
- package/dist/spec/domain/service/TriggerGraphChecks.d.ts +16 -0
- package/dist/spec/domain/service/TriggerGraphChecks.d.ts.map +1 -0
- package/dist/spec/domain/service/TriggerGraphChecks.js +337 -0
- package/dist/spec/domain/service/TriggerGraphChecks.js.map +1 -0
- package/dist/spec/domain/service/TriggerSpecChecks.d.ts +4 -0
- package/dist/spec/domain/service/TriggerSpecChecks.d.ts.map +1 -0
- package/dist/spec/domain/service/TriggerSpecChecks.js +89 -0
- package/dist/spec/domain/service/TriggerSpecChecks.js.map +1 -0
- package/dist/spec/domain/service/ValidatedAdminUiProjection.d.ts +11 -0
- package/dist/spec/domain/service/ValidatedAdminUiProjection.d.ts.map +1 -0
- package/dist/spec/domain/service/ValidatedAdminUiProjection.js +26 -0
- package/dist/spec/domain/service/ValidatedAdminUiProjection.js.map +1 -0
- package/dist/spec/domain/service/ViewAdminUiChecker.d.ts +14 -0
- package/dist/spec/domain/service/ViewAdminUiChecker.d.ts.map +1 -0
- package/dist/spec/domain/service/ViewAdminUiChecker.js +53 -0
- package/dist/spec/domain/service/ViewAdminUiChecker.js.map +1 -0
- package/dist/spec/domain/service/index.d.ts +24 -0
- package/dist/spec/domain/service/index.d.ts.map +1 -0
- package/dist/spec/domain/service/index.js +24 -0
- package/dist/spec/domain/service/index.js.map +1 -0
- package/dist/spec/index.d.ts +10 -0
- package/dist/spec/index.d.ts.map +1 -0
- package/dist/spec/index.js +12 -0
- package/dist/spec/index.js.map +1 -0
- package/dist/spec/infrastructure/cli/parseArgsError.d.ts +16 -0
- package/dist/spec/infrastructure/cli/parseArgsError.d.ts.map +1 -0
- package/dist/spec/infrastructure/cli/parseArgsError.js +34 -0
- package/dist/spec/infrastructure/cli/parseArgsError.js.map +1 -0
- package/dist/spec/infrastructure/index.d.ts +2 -0
- package/dist/spec/infrastructure/index.d.ts.map +1 -0
- package/dist/spec/infrastructure/index.js +2 -0
- package/dist/spec/infrastructure/index.js.map +1 -0
- package/dist/spec/infrastructure/sql/PgQueryParser.d.ts +18 -0
- package/dist/spec/infrastructure/sql/PgQueryParser.d.ts.map +1 -0
- package/dist/spec/infrastructure/sql/PgQueryParser.js +17 -0
- package/dist/spec/infrastructure/sql/PgQueryParser.js.map +1 -0
- package/dist/spec/infrastructure/sql/compilePlan.d.ts +37 -0
- package/dist/spec/infrastructure/sql/compilePlan.d.ts.map +1 -0
- package/dist/spec/infrastructure/sql/compilePlan.js +282 -0
- package/dist/spec/infrastructure/sql/compilePlan.js.map +1 -0
- package/dist/spec/infrastructure/sql/compileSql.d.ts +35 -0
- package/dist/spec/infrastructure/sql/compileSql.d.ts.map +1 -0
- package/dist/spec/infrastructure/sql/compileSql.js +92 -0
- package/dist/spec/infrastructure/sql/compileSql.js.map +1 -0
- package/dist/spec/infrastructure/sql/frontEnd.d.ts +8 -0
- package/dist/spec/infrastructure/sql/frontEnd.d.ts.map +1 -0
- package/dist/spec/infrastructure/sql/frontEnd.js +100 -0
- package/dist/spec/infrastructure/sql/frontEnd.js.map +1 -0
- package/dist/spec/infrastructure/sql/index.d.ts +4 -0
- package/dist/spec/infrastructure/sql/index.d.ts.map +1 -0
- package/dist/spec/infrastructure/sql/index.js +4 -0
- package/dist/spec/infrastructure/sql/index.js.map +1 -0
- package/dist/spec/kernel/diagnostic.d.ts +137 -0
- package/dist/spec/kernel/diagnostic.d.ts.map +1 -0
- package/dist/spec/kernel/diagnostic.js +296 -0
- package/dist/spec/kernel/diagnostic.js.map +1 -0
- package/dist/spec/kernel/index.d.ts +8 -0
- package/dist/spec/kernel/index.d.ts.map +1 -0
- package/dist/spec/kernel/index.js +8 -0
- package/dist/spec/kernel/index.js.map +1 -0
- package/dist/spec/usecase/EmitTypes.d.ts +22 -0
- package/dist/spec/usecase/EmitTypes.d.ts.map +1 -0
- package/dist/spec/usecase/EmitTypes.js +182 -0
- package/dist/spec/usecase/EmitTypes.js.map +1 -0
- package/dist/spec/usecase/ValidateManifestsUseCase.d.ts +8 -0
- package/dist/spec/usecase/ValidateManifestsUseCase.d.ts.map +1 -0
- package/dist/spec/usecase/ValidateManifestsUseCase.js +101 -0
- package/dist/spec/usecase/ValidateManifestsUseCase.js.map +1 -0
- package/dist/spec/usecase/dto/ValidateManifestsRequest.d.ts +27 -0
- package/dist/spec/usecase/dto/ValidateManifestsRequest.d.ts.map +1 -0
- package/dist/spec/usecase/dto/ValidateManifestsRequest.js +2 -0
- package/dist/spec/usecase/dto/ValidateManifestsRequest.js.map +1 -0
- package/dist/spec/usecase/dto/ValidateManifestsResponse.d.ts +14 -0
- package/dist/spec/usecase/dto/ValidateManifestsResponse.d.ts.map +1 -0
- package/dist/spec/usecase/dto/ValidateManifestsResponse.js +2 -0
- package/dist/spec/usecase/dto/ValidateManifestsResponse.js.map +1 -0
- package/dist/spec/usecase/dto/index.d.ts +3 -0
- package/dist/spec/usecase/dto/index.d.ts.map +1 -0
- package/dist/spec/usecase/dto/index.js +3 -0
- package/dist/spec/usecase/dto/index.js.map +1 -0
- package/dist/spec/usecase/index.d.ts +10 -0
- package/dist/spec/usecase/index.d.ts.map +1 -0
- package/dist/spec/usecase/index.js +10 -0
- package/dist/spec/usecase/index.js.map +1 -0
- package/dist/testing/cases/before-hook.d.ts +4 -0
- package/dist/testing/cases/before-hook.d.ts.map +1 -0
- package/dist/testing/cases/before-hook.js +71 -0
- package/dist/testing/cases/before-hook.js.map +1 -0
- package/dist/testing/cases/corpus.d.ts +12 -0
- package/dist/testing/cases/corpus.d.ts.map +1 -0
- package/dist/testing/cases/corpus.js +91 -0
- package/dist/testing/cases/corpus.js.map +1 -0
- package/dist/testing/cases/policy.d.ts +74 -0
- package/dist/testing/cases/policy.d.ts.map +1 -0
- package/dist/testing/cases/policy.js +142 -0
- package/dist/testing/cases/policy.js.map +1 -0
- package/dist/testing/cases/printer.d.ts +4 -0
- package/dist/testing/cases/printer.d.ts.map +1 -0
- package/dist/testing/cases/printer.js +32 -0
- package/dist/testing/cases/printer.js.map +1 -0
- package/dist/testing/cases/report-view.d.ts +5 -0
- package/dist/testing/cases/report-view.d.ts.map +1 -0
- package/dist/testing/cases/report-view.js +33 -0
- package/dist/testing/cases/report-view.js.map +1 -0
- package/dist/testing/cases/requisition.d.ts +4 -0
- package/dist/testing/cases/requisition.d.ts.map +1 -0
- package/dist/testing/cases/requisition.js +38 -0
- package/dist/testing/cases/requisition.js.map +1 -0
- package/dist/testing/cases/search-places.d.ts +4 -0
- package/dist/testing/cases/search-places.d.ts.map +1 -0
- package/dist/testing/cases/search-places.js +60 -0
- package/dist/testing/cases/search-places.js.map +1 -0
- package/dist/testing/cases/stock.d.ts +4 -0
- package/dist/testing/cases/stock.d.ts.map +1 -0
- package/dist/testing/cases/stock.js +35 -0
- package/dist/testing/cases/stock.js.map +1 -0
- package/dist/testing/cases/store.d.ts +4 -0
- package/dist/testing/cases/store.d.ts.map +1 -0
- package/dist/testing/cases/store.js +100 -0
- package/dist/testing/cases/store.js.map +1 -0
- package/dist/testing/harness.d.ts +94 -0
- package/dist/testing/harness.d.ts.map +1 -0
- package/dist/testing/harness.js +168 -0
- package/dist/testing/harness.js.map +1 -0
- package/dist/testing/index.d.ts +37 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +43 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/report.d.ts +15 -0
- package/dist/testing/report.d.ts.map +1 -0
- package/dist/testing/report.js +22 -0
- package/dist/testing/report.js.map +1 -0
- package/dist/web/createRestSurface.d.ts +7 -0
- package/dist/web/createRestSurface.d.ts.map +1 -0
- package/dist/web/createRestSurface.js +39 -0
- package/dist/web/createRestSurface.js.map +1 -0
- package/dist/web/index.d.ts +2 -0
- package/dist/web/index.d.ts.map +1 -0
- package/dist/web/index.js +2 -0
- package/dist/web/index.js.map +1 -0
- package/docs/adr/0008-structured-diagnostic-shape.md +2 -2
- package/docs/adr/0011-adapter-port-spec.md +2 -2
- package/docs/adr/0014-auth-better-auth-and-multi-tenant-mcp.md +21 -2
- package/docs/adr/0019-sealed-manifest-runtime-pipeline.md +5 -1
- package/docs/adr/0021-retire-starter-scaffolding.md +1 -1
- package/docs/adr/0022-caller-observed-version-occ.md +1 -1
- package/docs/adr/0024-manifest-native-schema-tables.md +2 -2
- package/docs/adr/0026-progressive-generate.md +36 -0
- package/docs/adr/0027-scheduled-procedure-triggers.md +31 -0
- package/docs/adr/0028-schema-ttl-expiry.md +33 -0
- package/docs/adr/0029-mcp-apps-interaction-contracts.md +324 -0
- package/docs/adr/0030-store.md +40 -0
- package/docs/adr/0031-host-cloud-core-contract.md +25 -0
- package/docs/adr/0032-store-centric-core-and-service-contract.md +361 -0
- package/docs/adr/0033-storage-converges-to-the-plan.md +92 -0
- package/docs/adr/0034-store-is-authored-as-sql.md +192 -0
- package/docs/adr/0035-sql-dialects.md +154 -0
- package/docs/adr/0036-host-and-dialect.md +65 -0
- package/docs/adr/0037-postgresql-is-the-reference-dialect.md +124 -0
- package/docs/adr/0038-bun-native-host.md +63 -0
- package/docs/adr/README.md +26 -8
- package/docs/adr/adr-lite-861-admin-webmcp.md +6 -0
- package/docs/adr/adr-lite-909-admin-ui-kit.md +1 -1
- package/docs/examples/README.md +16 -18
- package/docs/examples/commerce-inventory.md +481 -0
- package/docs/examples/commerce.md +254 -0
- package/docs/examples/guarded-api.md +238 -0
- package/docs/examples/intake-hooks.md +237 -0
- package/docs/examples/intake.md +127 -0
- package/docs/examples/legal-documents.md +218 -0
- package/docs/examples/procurement.md +215 -0
- package/docs/examples/publication.md +211 -0
- package/docs/examples/reference-service/.dev.vars.example +4 -0
- package/docs/examples/reference-service/.mantle/generated/mantle.ts +174 -0
- package/docs/examples/reference-service/.mantle/generated/plan.json +1936 -0
- package/docs/examples/reference-service/README.md +33 -0
- package/docs/examples/reference-service/manifests/catalog.yaml +103 -0
- package/docs/examples/reference-service/manifests/orders.yaml +120 -0
- package/docs/examples/reference-service/mantle.config.json +1 -0
- package/docs/examples/reference-service/package.json +27 -0
- package/docs/examples/reference-service/smoke.mjs +156 -0
- package/docs/examples/reference-service/src/handlers.ts +36 -0
- package/docs/examples/reference-service/src/index.ts +33 -0
- package/docs/examples/reference-service/src/service.ts +78 -0
- package/docs/examples/{host-minimal-worker → reference-service}/tsconfig.json +7 -2
- package/docs/examples/reference-service/wrangler.jsonc +26 -0
- package/docs/examples/reservation.md +142 -0
- package/docs/handbook/cloudflare/authentication.md +96 -299
- package/docs/handbook/cloudflare/chatgpt-sites.md +104 -15
- package/docs/handbook/cloudflare/deploy-and-operate.md +77 -71
- package/docs/handbook/cloudflare/media-r2.md +64 -187
- package/docs/handbook/cloudflare/service-entry.md +138 -0
- package/docs/handbook/concepts/authorization.md +104 -94
- package/docs/handbook/concepts/four-atoms.md +68 -144
- package/docs/handbook/concepts/lifecycle-and-locales.md +62 -114
- package/docs/handbook/concepts/mcp-and-agents.md +112 -117
- package/docs/handbook/concepts/procedures-and-triggers.md +126 -181
- package/docs/handbook/concepts/runtime-and-adapters.md +177 -156
- package/docs/handbook/concepts/views.md +97 -173
- package/docs/handbook/examples/hub.md +17 -6
- package/docs/handbook/guides/admin-ui.md +101 -96
- package/docs/handbook/guides/agent-setup.md +56 -71
- package/docs/handbook/guides/typed-queries.md +105 -111
- package/docs/handbook/navigation.json +8 -32
- package/docs/handbook/reference/authorization.md +52 -271
- package/docs/handbook/reference/diagnostics.md +69 -173
- package/docs/handbook/reference/features.md +48 -50
- package/docs/handbook/reference/manifest.md +56 -116
- package/docs/handbook/reference/procedure.md +92 -229
- package/docs/handbook/reference/schema.md +156 -215
- package/docs/handbook/reference/site-config.md +58 -211
- package/docs/handbook/reference/surface.md +69 -181
- package/docs/handbook/reference/trigger.md +73 -162
- package/docs/handbook/reference/view.md +140 -241
- package/docs/handbook/releases/index.md +58 -22
- package/docs/handbook/start/overview.md +59 -48
- package/docs/handbook/start/project-and-cli.md +127 -116
- package/docs/handbook/start/quickstart-worker.md +102 -151
- package/docs/skills/develop/SKILL.md +114 -232
- package/docs/skills/develop/mcp-app.md +79 -0
- package/docs/skills/integrate/SKILL.md +96 -0
- package/docs/skills/media-gc/SKILL.md +21 -10
- package/docs/skills/provision/SKILL.md +68 -162
- package/docs/skills/update/SKILL.md +33 -34
- package/docs/upgrade-0.1-to-0.2.md +211 -0
- package/package.json +87 -105
- 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/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/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/agent-prompts.md +0 -102
- 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/meta/_journal.json +0 -1
- 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 -9
- package/docs/examples/host-chatgpt-sites/src/chatgpt-auth.ts +0 -63
- 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/wrangler.jsonc +0 -22
- package/docs/handbook/chatgpt-sites/equipment-checkout.md +0 -231
- package/docs/handbook/chatgpt-sites/host-reference.md +0 -113
- package/docs/handbook/chatgpt-sites/index.md +0 -123
- package/docs/handbook/cloudflare/bindings.md +0 -298
- package/docs/handbook/cloudflare/conventional-worker.md +0 -162
- 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 -50
- 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/README.md +0 -125
- package/skills/develop/SKILL.md +0 -250
- package/skills/install/SKILL.md +0 -149
- 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
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: A guest checkout that re-prices on the server, reserves stock atomically in Store, expires unpaid orders on a schedule and settles from a verified payment callback.
|
|
3
|
+
---
|
|
4
|
+
# Commerce inventory: reservations, expiry and settlement
|
|
5
|
+
|
|
6
|
+
[Examples hub](./README.md) · Without stock or payments, this is [Commerce catalog and orders](./commerce.md).
|
|
7
|
+
|
|
8
|
+
The most involved pattern here. Staff publish a catalog. A guest's order is
|
|
9
|
+
re-priced on the server and reserves stock; payment arrives later from a
|
|
10
|
+
provider callback, never from the browser; an unpaid order is released after
|
|
11
|
+
fifteen minutes. Every stock change writes an audit row in the same atomic
|
|
12
|
+
write.
|
|
13
|
+
|
|
14
|
+
## Problem
|
|
15
|
+
|
|
16
|
+
Stock must never go negative, two guests must never buy the last unit, and an
|
|
17
|
+
order, its reservation and its audit rows must change together or not at all.
|
|
18
|
+
Staff adjust stock, fulfil paid orders and read a picking list.
|
|
19
|
+
|
|
20
|
+
In 0.1.x this needed a Durable Object as the stock authority and a Queue for
|
|
21
|
+
expiry. In 0.2.0 Store is enough: a `write` applies all its operations or none,
|
|
22
|
+
`checks` refuse a negative count in the database, and an optimistic lock on
|
|
23
|
+
each inventory row turns a race into a `CONFLICT` the client retries.
|
|
24
|
+
|
|
25
|
+
## Manifest
|
|
26
|
+
|
|
27
|
+
```yaml
|
|
28
|
+
apiVersion: cms.mantle.aotter.net/v2
|
|
29
|
+
kind: Schema
|
|
30
|
+
metadata: { name: products }
|
|
31
|
+
spec:
|
|
32
|
+
title: Products
|
|
33
|
+
lifecycle: publishing
|
|
34
|
+
uniqueIndexes: [[slug]]
|
|
35
|
+
schema:
|
|
36
|
+
type: object
|
|
37
|
+
additionalProperties: false
|
|
38
|
+
required: [slug, title, priceMinor, currency]
|
|
39
|
+
properties:
|
|
40
|
+
slug: { type: string, maxLength: 120, pattern: "^[a-z0-9-]+$" }
|
|
41
|
+
title: { type: string, minLength: 1, maxLength: 160 }
|
|
42
|
+
summary: { type: string, maxLength: 500 }
|
|
43
|
+
priceMinor: { type: integer, minimum: 0, x-mcp-hint: money-minor }
|
|
44
|
+
currency: { type: string, pattern: "^[A-Z]{3}$" }
|
|
45
|
+
---
|
|
46
|
+
apiVersion: cms.mantle.aotter.net/v2
|
|
47
|
+
kind: Schema
|
|
48
|
+
metadata: { name: inventory }
|
|
49
|
+
spec:
|
|
50
|
+
title: Inventory
|
|
51
|
+
description: Stock per product. Only the declared Procedures change it.
|
|
52
|
+
lifecycle: operational
|
|
53
|
+
checks: ["available >= 0", "reserved >= 0"]
|
|
54
|
+
uniqueIndexes: [[productSlug]]
|
|
55
|
+
uiSchema:
|
|
56
|
+
list: { primaryField: productSlug, columns: [available, reserved] }
|
|
57
|
+
schema:
|
|
58
|
+
type: object
|
|
59
|
+
readOnly: true
|
|
60
|
+
required: [productSlug, available, reserved]
|
|
61
|
+
properties:
|
|
62
|
+
productSlug: { type: string, x-mantle-ref: { schema: products, field: slug } }
|
|
63
|
+
available: { type: integer }
|
|
64
|
+
reserved: { type: integer }
|
|
65
|
+
---
|
|
66
|
+
apiVersion: cms.mantle.aotter.net/v2
|
|
67
|
+
kind: Schema
|
|
68
|
+
metadata: { name: inventory-movements }
|
|
69
|
+
spec:
|
|
70
|
+
title: Inventory movements
|
|
71
|
+
description: Append-only audit trail, written in the same write as each stock change.
|
|
72
|
+
lifecycle: operational
|
|
73
|
+
uniqueIndexes: [[movementKey]]
|
|
74
|
+
indexes: [[productSlug], [orderToken]]
|
|
75
|
+
schema:
|
|
76
|
+
type: object
|
|
77
|
+
readOnly: true
|
|
78
|
+
required: [movementKey, productSlug, kind, availableDelta, reservedDelta]
|
|
79
|
+
properties:
|
|
80
|
+
movementKey: { type: string }
|
|
81
|
+
productSlug: { type: string }
|
|
82
|
+
orderToken: { type: string }
|
|
83
|
+
kind: { type: string, enum: [adjust, reserve, sale, release] }
|
|
84
|
+
availableDelta: { type: integer }
|
|
85
|
+
reservedDelta: { type: integer }
|
|
86
|
+
note: { type: string }
|
|
87
|
+
---
|
|
88
|
+
apiVersion: cms.mantle.aotter.net/v2
|
|
89
|
+
kind: Schema
|
|
90
|
+
metadata: { name: orders }
|
|
91
|
+
spec:
|
|
92
|
+
title: Orders
|
|
93
|
+
description: Guest orders, written only by the declared Procedures.
|
|
94
|
+
lifecycle: operational
|
|
95
|
+
uniqueIndexes: [[orderToken]]
|
|
96
|
+
indexes: [[orderStatus, expiresAt]]
|
|
97
|
+
searchableFields: [orderToken, customerName, customerEmail]
|
|
98
|
+
uiSchema:
|
|
99
|
+
list: { primaryField: orderToken, columns: [orderStatus, customerEmail, totalMinor] }
|
|
100
|
+
schema:
|
|
101
|
+
type: object
|
|
102
|
+
readOnly: true
|
|
103
|
+
required: [orderToken, orderStatus, currency, totalMinor, customerName, customerEmail, shippingAddress, items, expiresAt]
|
|
104
|
+
properties:
|
|
105
|
+
orderToken: { type: string }
|
|
106
|
+
orderStatus: { type: string, enum: [pending_payment, paid, fulfilled, cancelled] }
|
|
107
|
+
currency: { type: string, pattern: "^[A-Z]{3}$" }
|
|
108
|
+
totalMinor: { type: integer, minimum: 0, x-mcp-hint: money-minor }
|
|
109
|
+
customerName: { type: string, minLength: 1, maxLength: 120 }
|
|
110
|
+
customerEmail: { type: string, format: email }
|
|
111
|
+
shippingAddress: { type: string, minLength: 1, maxLength: 500 }
|
|
112
|
+
items:
|
|
113
|
+
type: array
|
|
114
|
+
items:
|
|
115
|
+
type: object
|
|
116
|
+
required: [productSlug, title, quantity, unitPriceMinor]
|
|
117
|
+
properties:
|
|
118
|
+
productSlug: { type: string }
|
|
119
|
+
title: { type: string }
|
|
120
|
+
quantity: { type: integer, minimum: 1 }
|
|
121
|
+
unitPriceMinor: { type: integer, minimum: 0 }
|
|
122
|
+
expiresAt: { type: string, format: date-time }
|
|
123
|
+
trackingNumber: { type: string }
|
|
124
|
+
---
|
|
125
|
+
apiVersion: cms.mantle.aotter.net/v2
|
|
126
|
+
kind: View
|
|
127
|
+
metadata: { name: public-products }
|
|
128
|
+
spec:
|
|
129
|
+
surface: public
|
|
130
|
+
description: The published catalog with what is in stock.
|
|
131
|
+
sql: |
|
|
132
|
+
SELECT p.id, p.slug, p.title, p.summary, p.priceMinor, p.currency, coalesce(i.available, 0) AS available
|
|
133
|
+
FROM products p LEFT JOIN inventory i ON i.productSlug = p.slug
|
|
134
|
+
ORDER BY p.slug LIMIT 100
|
|
135
|
+
---
|
|
136
|
+
# Internal: no surface lists it. The expiry handler reads it; SQL compares the times.
|
|
137
|
+
apiVersion: cms.mantle.aotter.net/v2
|
|
138
|
+
kind: View
|
|
139
|
+
metadata: { name: expired-orders }
|
|
140
|
+
spec:
|
|
141
|
+
surface: internal
|
|
142
|
+
sql: |
|
|
143
|
+
SELECT id, version, orderToken, items FROM orders
|
|
144
|
+
WHERE orderStatus = 'pending_payment' AND expiresAt < now()
|
|
145
|
+
ORDER BY expiresAt LIMIT 100
|
|
146
|
+
---
|
|
147
|
+
apiVersion: cms.mantle.aotter.net/v2
|
|
148
|
+
kind: View
|
|
149
|
+
metadata: { name: picking-list }
|
|
150
|
+
spec:
|
|
151
|
+
title: Picking list
|
|
152
|
+
surface: staff
|
|
153
|
+
requires: { auth: { all: [{ ctx.staff: [owner, editor] }] } }
|
|
154
|
+
sql: |
|
|
155
|
+
SELECT o.orderToken, o.customerName, o.shippingAddress,
|
|
156
|
+
item.value ->> 'productSlug' AS "productSlug",
|
|
157
|
+
item.value ->> 'title' AS "productTitle",
|
|
158
|
+
item.value ->> 'quantity' AS quantity
|
|
159
|
+
FROM orders o, json_each(o.items) item
|
|
160
|
+
WHERE o.orderStatus = 'paid'
|
|
161
|
+
ORDER BY o.created_at LIMIT 200
|
|
162
|
+
---
|
|
163
|
+
apiVersion: cms.mantle.aotter.net/v2
|
|
164
|
+
kind: Procedure
|
|
165
|
+
metadata: { name: place-order }
|
|
166
|
+
spec:
|
|
167
|
+
title: Place order
|
|
168
|
+
description: Price a cart from the published catalog, reserve its stock and return a token to pay within fifteen minutes.
|
|
169
|
+
input:
|
|
170
|
+
type: object
|
|
171
|
+
additionalProperties: false
|
|
172
|
+
required: [customerName, customerEmail, shippingAddress, items]
|
|
173
|
+
properties:
|
|
174
|
+
customerName: { type: string, minLength: 1, maxLength: 120 }
|
|
175
|
+
customerEmail: { type: string, format: email }
|
|
176
|
+
shippingAddress: { type: string, minLength: 1, maxLength: 500 }
|
|
177
|
+
items:
|
|
178
|
+
type: array
|
|
179
|
+
minItems: 1
|
|
180
|
+
maxItems: 20
|
|
181
|
+
items:
|
|
182
|
+
type: object
|
|
183
|
+
additionalProperties: false
|
|
184
|
+
required: [productSlug, quantity]
|
|
185
|
+
properties:
|
|
186
|
+
productSlug: { type: string, maxLength: 120, pattern: "^[a-z0-9-]+$" }
|
|
187
|
+
quantity: { type: integer, minimum: 1, maximum: 99 }
|
|
188
|
+
output:
|
|
189
|
+
type: object
|
|
190
|
+
required: [orderToken, expiresAt, totalMinor, currency]
|
|
191
|
+
properties:
|
|
192
|
+
orderToken: { type: string }
|
|
193
|
+
expiresAt: { type: string }
|
|
194
|
+
totalMinor: { type: integer }
|
|
195
|
+
currency: { type: string }
|
|
196
|
+
handler: { ref: placeOrder }
|
|
197
|
+
---
|
|
198
|
+
# No Trigger: only the service's verified payment callback calls it, as the system caller.
|
|
199
|
+
apiVersion: cms.mantle.aotter.net/v2
|
|
200
|
+
kind: Procedure
|
|
201
|
+
metadata: { name: settle-order }
|
|
202
|
+
spec:
|
|
203
|
+
input:
|
|
204
|
+
type: object
|
|
205
|
+
additionalProperties: false
|
|
206
|
+
required: [orderToken]
|
|
207
|
+
properties:
|
|
208
|
+
orderToken: { type: string }
|
|
209
|
+
output:
|
|
210
|
+
type: object
|
|
211
|
+
required: [outcome]
|
|
212
|
+
properties:
|
|
213
|
+
outcome: { type: string, enum: [paid, already_paid, expired, missing] }
|
|
214
|
+
handler: { ref: settleOrder }
|
|
215
|
+
---
|
|
216
|
+
apiVersion: cms.mantle.aotter.net/v2
|
|
217
|
+
kind: Procedure
|
|
218
|
+
metadata: { name: release-expired-orders }
|
|
219
|
+
spec:
|
|
220
|
+
input: { type: object }
|
|
221
|
+
output:
|
|
222
|
+
type: object
|
|
223
|
+
properties:
|
|
224
|
+
released: { type: integer }
|
|
225
|
+
handler: { ref: releaseExpiredOrders }
|
|
226
|
+
---
|
|
227
|
+
# SQL is enough when a write needs no read first. The movement row comes first: a replayed operationId
|
|
228
|
+
# fails its unique index, so the whole write is refused and the stock is not changed twice.
|
|
229
|
+
apiVersion: cms.mantle.aotter.net/v2
|
|
230
|
+
kind: Procedure
|
|
231
|
+
metadata: { name: adjust-inventory }
|
|
232
|
+
spec:
|
|
233
|
+
title: Adjust inventory
|
|
234
|
+
description: Add or remove available stock for one product, with a reason. Reuse the operationId on retry.
|
|
235
|
+
requires: { auth: { all: [{ ctx.staff: [owner] }] } }
|
|
236
|
+
input:
|
|
237
|
+
type: object
|
|
238
|
+
additionalProperties: false
|
|
239
|
+
required: [operationId, productSlug, delta, reason]
|
|
240
|
+
properties:
|
|
241
|
+
operationId: { type: string, format: uuid, x-mcp-hint: idempotency-key }
|
|
242
|
+
productSlug: { type: string, maxLength: 120, pattern: "^[a-z0-9-]+$", x-mantle-ref: { schema: products, field: slug } }
|
|
243
|
+
delta: { type: integer, minimum: -100000, maximum: 100000 }
|
|
244
|
+
reason: { type: string, minLength: 1, maxLength: 500 }
|
|
245
|
+
uiSchema:
|
|
246
|
+
fields:
|
|
247
|
+
reason: { widget: textarea }
|
|
248
|
+
output: { type: object }
|
|
249
|
+
handler:
|
|
250
|
+
sql: |
|
|
251
|
+
INSERT INTO "inventory-movements" (movementKey, productSlug, kind, availableDelta, reservedDelta, note)
|
|
252
|
+
VALUES (input.operationId, input.productSlug, 'adjust', input.delta, 0, input.reason);
|
|
253
|
+
INSERT INTO inventory (productSlug, available, reserved) VALUES (input.productSlug, input.delta, 0)
|
|
254
|
+
ON CONFLICT (productSlug) DO UPDATE SET available = inventory.available + EXCLUDED.available
|
|
255
|
+
RETURNING productSlug AS "productSlug", available, reserved
|
|
256
|
+
---
|
|
257
|
+
apiVersion: cms.mantle.aotter.net/v2
|
|
258
|
+
kind: Procedure
|
|
259
|
+
metadata: { name: fulfill-order }
|
|
260
|
+
spec:
|
|
261
|
+
title: Fulfill order
|
|
262
|
+
description: Mark a paid order fulfilled, with an optional tracking number.
|
|
263
|
+
requires: { auth: { all: [{ ctx.staff: [owner, editor] }] } }
|
|
264
|
+
input:
|
|
265
|
+
type: object
|
|
266
|
+
additionalProperties: false
|
|
267
|
+
required: [id, expectedVersion]
|
|
268
|
+
properties:
|
|
269
|
+
id: { type: string, x-mantle-ref: orders }
|
|
270
|
+
expectedVersion: { type: integer, minimum: 1 }
|
|
271
|
+
trackingNumber: { type: string, maxLength: 120 }
|
|
272
|
+
output: { type: object }
|
|
273
|
+
handler:
|
|
274
|
+
sql: |
|
|
275
|
+
UPDATE orders SET orderStatus = 'fulfilled', trackingNumber = COALESCE(input.trackingNumber, trackingNumber)
|
|
276
|
+
WHERE id = input.id AND version = input.expectedVersion AND orderStatus = 'paid'
|
|
277
|
+
RETURNING id, version
|
|
278
|
+
---
|
|
279
|
+
apiVersion: cms.mantle.aotter.net/v2
|
|
280
|
+
kind: Trigger
|
|
281
|
+
metadata: { name: place-order-http }
|
|
282
|
+
spec:
|
|
283
|
+
source: { kind: http, method: POST, path: /api/commerce/orders }
|
|
284
|
+
target: { procedure: place-order }
|
|
285
|
+
---
|
|
286
|
+
apiVersion: cms.mantle.aotter.net/v2
|
|
287
|
+
kind: Trigger
|
|
288
|
+
metadata: { name: adjust-inventory-mcp }
|
|
289
|
+
spec:
|
|
290
|
+
source: { kind: mcp, surface: staff }
|
|
291
|
+
target: { procedure: adjust-inventory }
|
|
292
|
+
---
|
|
293
|
+
apiVersion: cms.mantle.aotter.net/v2
|
|
294
|
+
kind: Trigger
|
|
295
|
+
metadata: { name: fulfill-order-mcp }
|
|
296
|
+
spec:
|
|
297
|
+
source: { kind: mcp, surface: staff }
|
|
298
|
+
target: { procedure: fulfill-order }
|
|
299
|
+
---
|
|
300
|
+
# POSIX cron, UTC: every five minutes.
|
|
301
|
+
apiVersion: cms.mantle.aotter.net/v2
|
|
302
|
+
kind: Trigger
|
|
303
|
+
metadata: { name: release-expired-orders }
|
|
304
|
+
spec:
|
|
305
|
+
source: { kind: schedule, cron: "*/5 * * * *" }
|
|
306
|
+
target: { procedure: release-expired-orders }
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
Points worth noticing:
|
|
310
|
+
|
|
311
|
+
- **Root `readOnly: true`** on `orders`, `inventory` and `inventory-movements`
|
|
312
|
+
keeps Admin from offering generic edits. Only the declared Procedures change
|
|
313
|
+
them.
|
|
314
|
+
- **`checks` are the last line.** The handlers compute new counts from rows
|
|
315
|
+
they read under a lock, so a race is a `CONFLICT`; the checks make a negative
|
|
316
|
+
count impossible whatever writes the row.
|
|
317
|
+
- **`settle-order` and `release-expired-orders` have no HTTP or MCP Trigger.**
|
|
318
|
+
The schedule runs the second as the system caller, and only the service's own
|
|
319
|
+
callback route invokes the first. A system caller satisfies no
|
|
320
|
+
`requires.auth` predicate, so both declare none.
|
|
321
|
+
- **`expired-orders` is `internal`:** callable only through
|
|
322
|
+
`ctx.store.view` or `runtime.store`. SQL compares `expiresAt` with `now()`.
|
|
323
|
+
- **`picking-list`** unnests order lines with `json_each`, the one comma join
|
|
324
|
+
the dialect allows.
|
|
325
|
+
|
|
326
|
+
## Handlers
|
|
327
|
+
|
|
328
|
+
```ts
|
|
329
|
+
// src/handlers.ts
|
|
330
|
+
import { DiagnosticError, runtimeDiagnostic } from "@aotter/mantle";
|
|
331
|
+
import type { MantleHandlers } from "../.mantle/generated/mantle.js";
|
|
332
|
+
import type { Env } from "./service.js";
|
|
333
|
+
|
|
334
|
+
const CHECKOUT_TTL_MS = 15 * 60 * 1000;
|
|
335
|
+
type Line = { readonly productSlug: string; readonly quantity: number };
|
|
336
|
+
type Ctx = Parameters<MantleHandlers<Env>["placeOrder"]>[1];
|
|
337
|
+
type Op = Parameters<Ctx["store"]["write"]>[0][number];
|
|
338
|
+
|
|
339
|
+
const fail = (code: "CONFLICT" | "INPUT_VALIDATION_FAILED", path: string, message: string): never => {
|
|
340
|
+
throw new DiagnosticError(runtimeDiagnostic({ code, severity: "error", path, message }));
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
/** One locked update per product, plus its audit row: every count comes from a row read here, so a race is a CONFLICT. */
|
|
344
|
+
async function stockOps(ctx: Ctx, lines: readonly Line[], kind: "reserve" | "sale" | "release", orderToken: string): Promise<Op[]> {
|
|
345
|
+
const qty = new Map<string, number>();
|
|
346
|
+
for (const l of lines) qty.set(l.productSlug, (qty.get(l.productSlug) ?? 0) + l.quantity);
|
|
347
|
+
const { rows } = await ctx.store.select({ from: "inventory", where: { productSlug: { in: [...qty.keys()] } } });
|
|
348
|
+
const ops: Op[] = [];
|
|
349
|
+
for (const [slug, q] of qty) {
|
|
350
|
+
const row = rows.find((r) => r.productSlug === slug) ?? fail("INPUT_VALIDATION_FAILED", "/items", `no stock record for ${slug}`);
|
|
351
|
+
const [availableDelta, reservedDelta] = kind === "reserve" ? [-q, q] : kind === "sale" ? [0, -q] : [q, -q];
|
|
352
|
+
ops.push(
|
|
353
|
+
{ update: "inventory", set: { available: Number(row.available) + availableDelta, reserved: Number(row.reserved) + reservedDelta }, where: { id: String(row.id) }, lock: Number(row.version) },
|
|
354
|
+
{ insert: "inventory-movements", values: { movementKey: `${orderToken}:${kind}:${slug}`, productSlug: slug, orderToken, kind, availableDelta, reservedDelta } },
|
|
355
|
+
);
|
|
356
|
+
}
|
|
357
|
+
return ops;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export const handlers: MantleHandlers<Env> = {
|
|
361
|
+
placeOrder: async (input, ctx) => {
|
|
362
|
+
// re-price from published products only; a draft or unknown slug is refused
|
|
363
|
+
const slugs = [...new Set(input.items.map((l) => l.productSlug))];
|
|
364
|
+
const { rows: products } = await ctx.store.select({ from: "products", where: { slug: { in: slugs }, status: "published" } });
|
|
365
|
+
const lines = input.items.map((l) => {
|
|
366
|
+
const p = products.find((r) => r.slug === l.productSlug) ?? fail("INPUT_VALIDATION_FAILED", "/items", `${l.productSlug} is not for sale`);
|
|
367
|
+
return { productSlug: l.productSlug, title: String(p.title), quantity: l.quantity, unitPriceMinor: Number(p.priceMinor), currency: String(p.currency) };
|
|
368
|
+
});
|
|
369
|
+
const currency = lines[0]!.currency;
|
|
370
|
+
if (lines.some((l) => l.currency !== currency)) fail("INPUT_VALIDATION_FAILED", "/items", "one order has one currency");
|
|
371
|
+
const totalMinor = lines.reduce((sum, l) => sum + l.unitPriceMinor * l.quantity, 0);
|
|
372
|
+
const orderToken = ctx.store.id();
|
|
373
|
+
const expiresAt = new Date(Date.now() + CHECKOUT_TTL_MS).toISOString();
|
|
374
|
+
// the order, the reservation and its audit rows: all or nothing. Too little stock fails a check; a race fails a lock.
|
|
375
|
+
await ctx.store.write([
|
|
376
|
+
{ insert: "orders", values: {
|
|
377
|
+
orderToken, orderStatus: "pending_payment", currency, totalMinor, expiresAt,
|
|
378
|
+
customerName: input.customerName, customerEmail: input.customerEmail, shippingAddress: input.shippingAddress,
|
|
379
|
+
items: lines.map(({ currency: _c, ...line }) => line),
|
|
380
|
+
} },
|
|
381
|
+
...(await stockOps(ctx, lines, "reserve", orderToken)),
|
|
382
|
+
]);
|
|
383
|
+
return { orderToken, expiresAt, totalMinor, currency };
|
|
384
|
+
},
|
|
385
|
+
|
|
386
|
+
settleOrder: async ({ orderToken }, ctx) => {
|
|
387
|
+
const [order] = (await ctx.store.select({ from: "orders", where: { orderToken } })).rows;
|
|
388
|
+
if (!order) return { outcome: "missing" };
|
|
389
|
+
if (order.orderStatus !== "pending_payment") return { outcome: order.orderStatus === "cancelled" ? "expired" : "already_paid" };
|
|
390
|
+
const lines = order.items as unknown as Line[];
|
|
391
|
+
// a payment that lands after the deadline releases the stock instead of selling it; the provider refunds
|
|
392
|
+
const late = Date.parse(String(order.expiresAt)) <= Date.now();
|
|
393
|
+
await ctx.store.write([
|
|
394
|
+
{ update: "orders", set: { orderStatus: late ? "cancelled" : "paid" }, where: { id: String(order.id) }, lock: Number(order.version) },
|
|
395
|
+
...(await stockOps(ctx, lines, late ? "release" : "sale", orderToken)),
|
|
396
|
+
]);
|
|
397
|
+
return { outcome: late ? "expired" : "paid" };
|
|
398
|
+
},
|
|
399
|
+
|
|
400
|
+
// runs as the system caller every five minutes; one write per order, so one CONFLICT never blocks the rest
|
|
401
|
+
releaseExpiredOrders: async (_input, ctx) => {
|
|
402
|
+
const { rows } = await ctx.store.view("expired-orders");
|
|
403
|
+
let released = 0;
|
|
404
|
+
for (const order of rows) {
|
|
405
|
+
try {
|
|
406
|
+
await ctx.store.write([
|
|
407
|
+
{ update: "orders", set: { orderStatus: "cancelled" }, where: { id: String(order.id) }, lock: Number(order.version) },
|
|
408
|
+
...(await stockOps(ctx, order.items as unknown as Line[], "release", String(order.orderToken))),
|
|
409
|
+
]);
|
|
410
|
+
released++;
|
|
411
|
+
} catch (error) {
|
|
412
|
+
// a payment settled it first, or a stock row changed: the next run reads it again
|
|
413
|
+
if (!(error instanceof DiagnosticError && error.diagnostic.code === "CONFLICT")) throw error;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
return { released };
|
|
417
|
+
},
|
|
418
|
+
};
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
## The payment callback
|
|
422
|
+
|
|
423
|
+
A provider signs its callback over the raw body, so it is verified in the
|
|
424
|
+
service's own `fetch`, before any surface. Only a verified event reaches
|
|
425
|
+
`settle-order`, as the system caller. In `src/service.ts`:
|
|
426
|
+
|
|
427
|
+
```ts
|
|
428
|
+
import { systemCaller } from "@aotter/mantle";
|
|
429
|
+
|
|
430
|
+
// inside the function the service's fetch returns, before the auth routes:
|
|
431
|
+
if (pathname === "/payments/callback" && request.method === "POST") {
|
|
432
|
+
const raw = await request.text();
|
|
433
|
+
const event = await verifyProviderEvent(raw, request.headers.get("x-provider-signature"), env.PAYMENT_WEBHOOK_SECRET);
|
|
434
|
+
if (!event) return new Response("invalid signature", { status: 400 });
|
|
435
|
+
if (event.type !== "payment.succeeded") return new Response("ignored");
|
|
436
|
+
await runtime.invokeProcedure({
|
|
437
|
+
procedure: "settle-order",
|
|
438
|
+
input: { orderToken: event.orderToken },
|
|
439
|
+
caller: systemCaller("payment-callback"),
|
|
440
|
+
cause: { kind: "internal", id: event.id }, // the provider's event id: stable across its retries
|
|
441
|
+
});
|
|
442
|
+
return new Response("OK"); // paid, already_paid, expired and missing are all final for the provider
|
|
443
|
+
}
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
`verifyProviderEvent` is the provider SDK's signature check, with
|
|
447
|
+
`PAYMENT_WEBHOOK_SECRET` as a Worker secret. A thrown `CONFLICT` (a
|
|
448
|
+
concurrent expiry) answers 500 here, so the provider retries and the next
|
|
449
|
+
attempt reads the settled state.
|
|
450
|
+
|
|
451
|
+
## Try it
|
|
452
|
+
|
|
453
|
+
```sh
|
|
454
|
+
curl -sS -X POST http://127.0.0.1:8787/api/commerce/orders \
|
|
455
|
+
-H 'content-type: application/json' \
|
|
456
|
+
-d '{"customerName":"Ada","customerEmail":"ada@example.test","shippingAddress":"1 Shell Lane","items":[{"productSlug":"notebook","quantity":2}]}'
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
The answer carries `orderToken`, `expiresAt`, and the total from the
|
|
460
|
+
published price. An unknown or unpublished product is HTTP 400. Ordering more
|
|
461
|
+
than is available fails the `available >= 0` check, also HTTP 400 (`CHECK
|
|
462
|
+
inventory: available >= 0`), and writes nothing. Two guests racing for one
|
|
463
|
+
row: one succeeds, the other gets `CONFLICT` and retries.
|
|
464
|
+
|
|
465
|
+
Staff, on `/mcp/staff`: `adjust_inventory` (Admin generates the
|
|
466
|
+
`operationId`), `fulfill_order` and `picking_list`. Fire the schedule locally
|
|
467
|
+
with `curl 'http://127.0.0.1:8787/__scheduled?cron=*/5+*+*+*+*'` under
|
|
468
|
+
`wrangler dev --test-scheduled`.
|
|
469
|
+
|
|
470
|
+
## What this leaves out
|
|
471
|
+
|
|
472
|
+
- **Refunds.** A late payment releases stock; refunding it is the provider's
|
|
473
|
+
API, from a `ref` handler.
|
|
474
|
+
- **Guest cancellation.** It would be one more Procedure shaped like
|
|
475
|
+
`settleOrder` with `"release"`, authorized by the order token.
|
|
476
|
+
- **More than 100 expired orders per run.** The next run takes the rest.
|
|
477
|
+
|
|
478
|
+
## Source
|
|
479
|
+
|
|
480
|
+
- [Writes: Procedures, Triggers and hooks](../handbook/concepts/procedures-and-triggers.md): atomic writes, locks, schedules
|
|
481
|
+
- [The service and its entry](../handbook/cloudflare/service-entry.md): a route before the surfaces
|