@aotter/mantle 0.2.0 → 0.2.1-alpha.2

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.
Files changed (89) hide show
  1. package/README.md +6 -2
  2. package/dist/build/compiler.d.ts +6 -6
  3. package/dist/build/compiler.js +6 -3
  4. package/dist/build/spec/domain/model/ManifestGrammar.d.ts +39 -1
  5. package/dist/build/spec/domain/model/RuntimePlan.d.ts +16 -3
  6. package/dist/build/spec/domain/model/SqlIr.d.ts +30 -0
  7. package/dist/build/spec/kernel/diagnostic.d.ts +1 -1
  8. package/dist/domain/describe/chunk-CW7X5Q5T.js +1 -0
  9. package/dist/domain/describe/index.d.ts +1 -0
  10. package/dist/domain/describe/index.js +1 -1
  11. package/dist/domain/describe/match.d.ts +19 -0
  12. package/dist/domain/describe/public.d.ts +3 -0
  13. package/dist/domain/describe/public.js +1 -0
  14. package/dist/infrastructure/adminEntries.js +19 -3
  15. package/dist/infrastructure/bundle.js +43 -8
  16. package/dist/infrastructure/cli.js +1 -1
  17. package/dist/infrastructure/generate.js +17 -3
  18. package/dist/kernel/binds.d.ts +18 -3
  19. package/dist/kernel/binds.js +1 -1
  20. package/dist/kernel/contracts.d.ts +7 -0
  21. package/dist/kernel/contracts.js +9 -0
  22. package/dist/kernel/driver/bun-sqlite.js +3 -3
  23. package/dist/kernel/driver/d1.d.ts +1 -1
  24. package/dist/kernel/driver/d1.js +6 -3
  25. package/dist/kernel/driver/postgres.d.ts +2 -1
  26. package/dist/kernel/driver/postgres.js +11 -6
  27. package/dist/kernel/mcp-apps.d.ts +3 -2
  28. package/dist/kernel/mcp-apps.js +7 -2
  29. package/dist/kernel/mcp-handler.js +22 -9
  30. package/dist/kernel/mcp.d.ts +18 -0
  31. package/dist/kernel/mcp.js +1 -0
  32. package/dist/kernel/rest-router.js +3 -5
  33. package/dist/kernel/rest.d.ts +2 -1
  34. package/dist/kernel/rest.js +1 -0
  35. package/dist/kernel/route-pattern.d.ts +26 -0
  36. package/dist/kernel/route-pattern.js +34 -0
  37. package/dist/kernel/store.d.ts +15 -1
  38. package/dist/kernel/store.js +51 -18
  39. package/dist/usecase/adminBindings.js +2 -2
  40. package/dist/usecase/adminClient.js +4 -1
  41. package/dist/usecase/generate.js +7 -5
  42. package/dist/usecase/handlers.js +1 -1
  43. package/dist/usecase/publishing.js +20 -7
  44. package/dist/usecase/rest.js +5 -5
  45. package/dist/usecase/stores.js +8 -3
  46. package/docs/examples/README.md +1 -1
  47. package/docs/examples/app-shell/README.md +58 -10
  48. package/docs/examples/app-shell/package.json +6 -6
  49. package/docs/examples/club-events/manifests/club-events.yaml +2 -0
  50. package/docs/examples/generated-web/seed.sql +5 -4
  51. package/docs/examples/purchasing/manifests/purchasing.yaml +3 -0
  52. package/docs/handbook/cloudflare/media-r2.md +6 -3
  53. package/docs/handbook/cloudflare/service-entry.md +2 -0
  54. package/docs/handbook/concepts/lifecycle-and-locales.md +21 -1
  55. package/docs/handbook/examples/hub.md +1 -1
  56. package/docs/handbook/guides/admin-ui.md +1 -1
  57. package/docs/handbook/guides/agent-setup.md +13 -8
  58. package/docs/handbook/guides/agent-workflow-acceptance.md +129 -19
  59. package/docs/handbook/guides/local-testing.md +50 -5
  60. package/docs/handbook/guides/mcp-apps.md +40 -0
  61. package/docs/handbook/guides/native-admin.md +218 -11
  62. package/docs/handbook/guides/native-execution.md +5 -4
  63. package/docs/handbook/guides/revisions.md +584 -0
  64. package/docs/handbook/guides/size-and-startup.md +140 -0
  65. package/docs/handbook/guides/sql-patterns.md +47 -1
  66. package/docs/handbook/guides/typed-queries.md +8 -3
  67. package/docs/handbook/navigation.json +4 -0
  68. package/docs/handbook/reference/authorization.md +2 -0
  69. package/docs/handbook/reference/describe.md +56 -4
  70. package/docs/handbook/reference/diagnostics.md +12 -3
  71. package/docs/handbook/reference/procedure.md +4 -4
  72. package/docs/handbook/reference/schema.md +71 -7
  73. package/docs/handbook/reference/sql.md +2 -1
  74. package/docs/handbook/reference/surface.md +13 -2
  75. package/docs/handbook/reference/trigger.md +12 -0
  76. package/docs/handbook/releases/index.md +75 -1
  77. package/docs/handbook/start/agents.md +6 -2
  78. package/docs/handbook/start/project-and-cli.md +4 -0
  79. package/docs/handbook/start/quickstart-worker.md +1 -1
  80. package/docs/skills/develop/SKILL.md +15 -3
  81. package/docs/skills/integrate/SKILL.md +3 -1
  82. package/docs/skills/performance/SKILL.md +169 -0
  83. package/docs/skills/update/SKILL.md +9 -5
  84. package/docs/upgrade-0.1-to-0.2.md +151 -39
  85. package/package.json +10 -11
  86. package/skills/README.md +6 -2
  87. package/skills/mantle/SKILL.md +19 -5
  88. package/dist/domain/describe/chunk-SGMRVDGE.js +0 -1
  89. package/dist/domain/describe/target-hash.js +0 -1
package/README.md CHANGED
@@ -159,8 +159,12 @@ Writes are lazy thenables: await `collection.insert/update/delete(...)` to execu
159
159
  or pass unused Writes from the same Store to `store.batch([...])` for atomic results in input order;
160
160
  a stale lock, excluded row or unique clash rolls back the whole batch with `CONFLICT`.
161
161
  A batch step cannot use a previous step's result. D1 supports only batch.
162
- On bun:sqlite and PostgreSQL, `store.transaction(async tx => { ... })` binds `collection`, `views`
163
- and `procedures` to one transaction: resolve commits, throw rolls back; nested transactions and `tx.batch` are refused.
162
+ On bun:sqlite and PostgreSQL, `store.transaction(async tx => { ... })` binds `collection`, `batch`, `views`
163
+ and `procedures` to one transaction: resolve commits, throw rolls back; nested transactions are refused.
164
+ `tx.batch` and a ref handler's `ctx.store.batch` join that same transaction, without a savepoint or another BEGIN.
165
+ A rejected batch makes the whole outer transaction rollback-only: even if the callback catches the error and returns,
166
+ its transaction rejects with the first batch failure and rolls back every write. This includes batch validation errors.
167
+ Ref handlers can use `ctx.store.batch` on every target, including D1, without creating another Store.
164
168
  PostgreSQL defaults to serializable; `{ isolation: "read committed" }` selects another level. There is no automatic retry.
165
169
  SQLite uses BEGIN IMMEDIATE and queues all Store/generated driver calls on the same Database until COMMIT/ROLLBACK;
166
170
  Inside a transaction callback the outer Store or handle passed to a Mantle driver throws `INPUT_VALIDATION_FAILED`; use `tx`.
@@ -1,13 +1,13 @@
1
- import { SqlNode, SqlSchemaDef, SqlDiagnostic, SqlContext, SqlPlan, checkShapeProblem, CHECK_FUNCTIONS, storageColumnClash, notNullColumns, NATIVE_COLUMNS, NATIVE_NOT_NULL, AGGREGATES, storageColumns, viewCacheProblem, SqlDiagnosticCode, SchemaColumns, PG_GRAMMAR } from "./spec/domain/model/SqlIr.js";
2
- export { SqlNode, SqlSchemaDef, SqlDiagnostic, SqlContext, SqlPlan, checkShapeProblem, CHECK_FUNCTIONS, storageColumnClash, notNullColumns, NATIVE_COLUMNS, NATIVE_NOT_NULL, AGGREGATES, storageColumns, viewCacheProblem, SqlDiagnosticCode, SchemaColumns, PG_GRAMMAR };
1
+ import { SqlNode, SqlSchemaDef, SqlDiagnostic, SqlContext, SqlPlan, lockIndexProblem, lockShapeProblem, checkShapeProblem, CHECK_FUNCTIONS, storageColumnClash, notNullColumns, NATIVE_COLUMNS, NATIVE_NOT_NULL, AGGREGATES, storageColumns, viewCacheProblem, SqlDiagnosticCode, SchemaColumns, SqlLock, PG_GRAMMAR } from "./spec/domain/model/SqlIr.js";
2
+ export { SqlNode, SqlSchemaDef, SqlDiagnostic, SqlContext, SqlPlan, lockIndexProblem, lockShapeProblem, checkShapeProblem, CHECK_FUNCTIONS, storageColumnClash, notNullColumns, NATIVE_COLUMNS, NATIVE_NOT_NULL, AGGREGATES, storageColumns, viewCacheProblem, SqlDiagnosticCode, SchemaColumns, SqlLock, PG_GRAMMAR };
3
3
  import { RuntimePlan, PlanRestrict, NATIVE_OUTPUT_TYPES, PlanLowered, PlanTrigger, PlanProcedure, PlanView, PlanSchema, RUNTIME_PLAN_VERSION, LoweredStatement, LoweredView, LoweredMode, LoweredPage } from "./spec/domain/model/RuntimePlan.js";
4
4
  export { RuntimePlan, PlanRestrict, NATIVE_OUTPUT_TYPES, PlanLowered, PlanTrigger, PlanProcedure, PlanView, PlanSchema, RUNTIME_PLAN_VERSION, LoweredStatement, LoweredView, LoweredMode, LoweredPage };
5
- import { UserFieldSpec, UserScope, RowTemplate, parseRowTemplate } from "./spec/domain/model/UserFields.js";
6
- export { UserFieldSpec, UserScope, RowTemplate, parseRowTemplate };
7
- import { ProcedureMcpAnnotations, JsonSchema, AuthorizationRequirements, RESERVED_PROCEDURE_INPUT_NAMES, INPUT_RULE_KEYWORDS, EXPECTED_VERSION_PROPERTY, RESERVED_ENTRY_COLUMNS, TriggerManifest, ProcedureManifest, ViewManifest, SchemaManifest, Manifest, HttpMethod, McpTriggerSurface, McpTriggerSource, MCP_TRIGGER_SURFACES, LifecycleHook, LifecycleTriggerSource, LIFECYCLE_HOOKS, HttpTriggerSource, ScheduleTriggerSource, TriggerSource, TriggerManifestSpec, AdminRole, isAdminRole, CtxAuthScopePredicate, CtxAuthPredicate, CtxUserPredicate, AuthPredicate, HandlerSqlBinding, HandlerRefBinding, HandlerBinding, PROCEDURE_MCP_ANNOTATION_KEYS, PROCEDURE_TARGET_KEYS, ProcedureTarget, LocalizedText, ProcedureManifestSpec, VIEW_INPUT_RESERVED, ViewCachePolicy, ViewSurface, ViewManifestSpec, VIEW_SURFACES, LifecycleMode, TranslatesBinding, SchemaManifestSpec, ManifestMetadata, ApiVersion, ManifestKind, resolveLocalizedText, isLocalizedText, MANTLE_BIND_KEYWORD, MCP_HINT_KEYWORD, MantleRefTarget, resolveMantleRef, enumOptions, MANTLE_REF_KEYWORD, MediaMcpHint, isMediaMcpHint, API_VERSION } from "./spec/domain/model/ManifestGrammar.js";
8
- export { ProcedureMcpAnnotations, JsonSchema, AuthorizationRequirements, RESERVED_PROCEDURE_INPUT_NAMES, INPUT_RULE_KEYWORDS, EXPECTED_VERSION_PROPERTY, RESERVED_ENTRY_COLUMNS, TriggerManifest, ProcedureManifest, ViewManifest, SchemaManifest, Manifest, HttpMethod, McpTriggerSurface, McpTriggerSource, MCP_TRIGGER_SURFACES, LifecycleHook, LifecycleTriggerSource, LIFECYCLE_HOOKS, HttpTriggerSource, ScheduleTriggerSource, TriggerSource, TriggerManifestSpec, AdminRole, isAdminRole, CtxAuthScopePredicate, CtxAuthPredicate, CtxUserPredicate, AuthPredicate, HandlerSqlBinding, HandlerRefBinding, HandlerBinding, PROCEDURE_MCP_ANNOTATION_KEYS, PROCEDURE_TARGET_KEYS, ProcedureTarget, LocalizedText, ProcedureManifestSpec, VIEW_INPUT_RESERVED, ViewCachePolicy, ViewSurface, ViewManifestSpec, VIEW_SURFACES, LifecycleMode, TranslatesBinding, SchemaManifestSpec, ManifestMetadata, ApiVersion, ManifestKind, resolveLocalizedText, isLocalizedText, MANTLE_BIND_KEYWORD, MCP_HINT_KEYWORD, MantleRefTarget, resolveMantleRef, enumOptions, MANTLE_REF_KEYWORD, MediaMcpHint, isMediaMcpHint, API_VERSION };
5
+ import { AuthorizationRequirements, ProcedureMcpAnnotations, JsonSchema, TriggerSource, HandlerStep, ProcedureTarget, LocalizedText, RESERVED_PROCEDURE_INPUT_NAMES, INPUT_RULE_KEYWORDS, EXPECTED_VERSION_PROPERTY, RESERVED_ENTRY_COLUMNS, TriggerManifest, ProcedureManifest, ViewManifest, SchemaManifest, Manifest, HttpMethod, McpTriggerSurface, McpTriggerSource, MCP_TRIGGER_SURFACES, LifecycleHook, LifecycleTriggerSource, LIFECYCLE_HOOKS, HttpTriggerSource, ScheduleTriggerSource, TriggerManifestSpec, AdminRole, isAdminRole, CtxAuthScopePredicate, CtxAuthPredicate, CtxUserPredicate, AuthPredicate, stepProgram, HANDLER_STEP_KEYS, HandlerSqlBinding, HandlerRefBinding, HandlerBinding, PROCEDURE_MCP_ANNOTATION_KEYS, PROCEDURE_TARGET_KEYS, ProcedureManifestSpec, VIEW_INPUT_RESERVED, ViewCachePolicy, ViewSurface, ViewManifestSpec, VIEW_SURFACES, LifecycleMode, TranslatesBinding, LockVerb, SchemaLock, LOCK_VERBS, SchemaManifestSpec, ManifestMetadata, ApiVersion, ManifestKind, resolveLocalizedText, isLocalizedText, MANTLE_BIND_KEYWORD, MCP_HINT_KEYWORD, MantleRefTarget, resolveMantleRef, enumOptions, MANTLE_REF_KEYWORD, MediaMcpHint, isMediaMcpHint, API_VERSION } from "./spec/domain/model/ManifestGrammar.js";
6
+ export { AuthorizationRequirements, ProcedureMcpAnnotations, JsonSchema, TriggerSource, HandlerStep, ProcedureTarget, LocalizedText, RESERVED_PROCEDURE_INPUT_NAMES, INPUT_RULE_KEYWORDS, EXPECTED_VERSION_PROPERTY, RESERVED_ENTRY_COLUMNS, TriggerManifest, ProcedureManifest, ViewManifest, SchemaManifest, Manifest, HttpMethod, McpTriggerSurface, McpTriggerSource, MCP_TRIGGER_SURFACES, LifecycleHook, LifecycleTriggerSource, LIFECYCLE_HOOKS, HttpTriggerSource, ScheduleTriggerSource, TriggerManifestSpec, AdminRole, isAdminRole, CtxAuthScopePredicate, CtxAuthPredicate, CtxUserPredicate, AuthPredicate, stepProgram, HANDLER_STEP_KEYS, HandlerSqlBinding, HandlerRefBinding, HandlerBinding, PROCEDURE_MCP_ANNOTATION_KEYS, PROCEDURE_TARGET_KEYS, ProcedureManifestSpec, VIEW_INPUT_RESERVED, ViewCachePolicy, ViewSurface, ViewManifestSpec, VIEW_SURFACES, LifecycleMode, TranslatesBinding, LockVerb, SchemaLock, LOCK_VERBS, SchemaManifestSpec, ManifestMetadata, ApiVersion, ManifestKind, resolveLocalizedText, isLocalizedText, MANTLE_BIND_KEYWORD, MCP_HINT_KEYWORD, MantleRefTarget, resolveMantleRef, enumOptions, MANTLE_REF_KEYWORD, MediaMcpHint, isMediaMcpHint, API_VERSION };
9
7
  import { Diagnostic, DiagnosticError, runtimeDiagnostic, bootDiagnostic, validateDiagnostic, makeDiagnostic, SourceLocation, Phase, DiagnosticCode, SourceSpan, SourcePosition, DIAGNOSTIC_CODES } from "./spec/kernel/diagnostic.js";
10
8
  export { Diagnostic, DiagnosticError, runtimeDiagnostic, bootDiagnostic, validateDiagnostic, makeDiagnostic, SourceLocation, Phase, DiagnosticCode, SourceSpan, SourcePosition, DIAGNOSTIC_CODES };
9
+ import { UserScope, RowTemplate, parseRowTemplate, UserFieldSpec } from "./spec/domain/model/UserFields.js";
10
+ export { UserScope, RowTemplate, parseRowTemplate, UserFieldSpec };
11
11
  import { planFingerprint, fnv, canonical } from "./spec/domain/service/PlanFingerprint.js";
12
12
  export { planFingerprint, fnv, canonical };
13
13
  export interface SiteDefaults {