@happyvertical/smrt-core 0.56.0 → 0.56.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 (114) hide show
  1. package/AGENTS.md +6 -0
  2. package/agents/browser-entry.md +5 -0
  3. package/agents/generators.md +61 -0
  4. package/agents/object-runtime.md +17 -0
  5. package/dist/browser.d.ts +2 -0
  6. package/dist/browser.d.ts.map +1 -1
  7. package/dist/browser.js +3 -1
  8. package/dist/cookbook/engine/commands.d.ts.map +1 -1
  9. package/dist/cookbook/engine/commands.js +12 -0
  10. package/dist/cookbook/engine/commands.js.map +1 -1
  11. package/dist/cookbook/engine/defaults.d.ts.map +1 -1
  12. package/dist/cookbook/engine/defaults.js +8 -0
  13. package/dist/cookbook/engine/defaults.js.map +1 -1
  14. package/dist/cookbook/engine/document.d.ts +4 -0
  15. package/dist/cookbook/engine/document.d.ts.map +1 -1
  16. package/dist/cookbook/engine/document.js +11 -3
  17. package/dist/cookbook/engine/document.js.map +1 -1
  18. package/dist/cookbook/engine/engine.d.ts.map +1 -1
  19. package/dist/cookbook/engine/engine.js +3 -1
  20. package/dist/cookbook/engine/engine.js.map +1 -1
  21. package/dist/cookbook/engine/schemas.d.ts.map +1 -1
  22. package/dist/cookbook/engine/schemas.js +8 -0
  23. package/dist/cookbook/engine/schemas.js.map +1 -1
  24. package/dist/cookbook/engine/types.d.ts +5 -1
  25. package/dist/cookbook/engine/types.d.ts.map +1 -1
  26. package/dist/cookbook/engine/types.js.map +1 -1
  27. package/dist/generators/index.d.ts +1 -0
  28. package/dist/generators/index.d.ts.map +1 -1
  29. package/dist/generators/index.js +2 -1
  30. package/dist/generators/mcp-runtime-template.d.ts +3 -0
  31. package/dist/generators/mcp-runtime-template.d.ts.map +1 -1
  32. package/dist/generators/mcp-runtime-template.js +30 -4
  33. package/dist/generators/mcp-runtime-template.js.map +1 -1
  34. package/dist/generators/mcp.d.ts +5 -0
  35. package/dist/generators/mcp.d.ts.map +1 -1
  36. package/dist/generators/mcp.js +78 -7
  37. package/dist/generators/mcp.js.map +1 -1
  38. package/dist/generators.js +2 -1
  39. package/dist/index.d.ts +1 -0
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +3 -1
  42. package/dist/interceptors.d.ts +7 -0
  43. package/dist/interceptors.d.ts.map +1 -1
  44. package/dist/interceptors.js +15 -1
  45. package/dist/interceptors.js.map +1 -1
  46. package/dist/manifest/browser-capability.generated.d.ts.map +1 -1
  47. package/dist/manifest/browser-capability.generated.js +47 -5
  48. package/dist/manifest/browser-capability.generated.js.map +1 -1
  49. package/dist/manifest/index.js +1 -1
  50. package/dist/manifest/manifest-loader.d.ts.map +1 -1
  51. package/dist/manifest/manifest-loader.js +1 -2
  52. package/dist/manifest/manifest-loader.js.map +1 -1
  53. package/dist/manifest/static-manifest.js +1 -1
  54. package/dist/manifest/static-manifest.js.map +1 -1
  55. package/dist/manifest/store.js +1 -1
  56. package/dist/manifest.json +1 -1
  57. package/dist/mcp-serializer.d.ts +38 -0
  58. package/dist/mcp-serializer.d.ts.map +1 -0
  59. package/dist/mcp-serializer.js +60 -0
  60. package/dist/mcp-serializer.js.map +1 -0
  61. package/dist/object.d.ts +1 -0
  62. package/dist/object.d.ts.map +1 -1
  63. package/dist/object.js +44 -13
  64. package/dist/object.js.map +1 -1
  65. package/dist/registry/collection-exposure.d.ts +99 -0
  66. package/dist/registry/collection-exposure.d.ts.map +1 -0
  67. package/dist/registry/collection-exposure.js +135 -0
  68. package/dist/registry/collection-exposure.js.map +1 -0
  69. package/dist/registry/types.d.ts +13 -0
  70. package/dist/registry/types.d.ts.map +1 -1
  71. package/dist/registry.d.ts +8 -1
  72. package/dist/registry.d.ts.map +1 -1
  73. package/dist/registry.js +76 -3
  74. package/dist/registry.js.map +1 -1
  75. package/dist/scanner/manifest-generator.d.ts +14 -0
  76. package/dist/scanner/manifest-generator.d.ts.map +1 -1
  77. package/dist/scanner/manifest-generator.js +66 -13
  78. package/dist/scanner/manifest-generator.js.map +1 -1
  79. package/dist/smrt-knowledge.json +13 -11
  80. package/dist/utils/import-project-vite.js +1 -1
  81. package/dist/utils/import-workspace-module.js +1 -1
  82. package/dist/utils/sha256.js +2 -2
  83. package/dist/vite-plugin/dev-plane-route.js +1 -1
  84. package/dist/vite-plugin/import-build-aware.js +1 -1
  85. package/dist/vite-plugin/index.js +2 -2
  86. package/dist/vite-plugin/resources-route.js +1 -1
  87. package/dist/vite-plugin/sveltekit-generator.d.ts.map +1 -1
  88. package/dist/vite-plugin/sveltekit-generator.js +5 -1
  89. package/dist/vite-plugin/sveltekit-generator.js.map +1 -1
  90. package/package.json +16 -10
  91. package/dist/node_modules/.pnpm/@noble_hashes@2.4.0/node_modules/@noble/hashes/_md.js +0 -169
  92. package/dist/node_modules/.pnpm/@noble_hashes@2.4.0/node_modules/@noble/hashes/_md.js.map +0 -1
  93. package/dist/node_modules/.pnpm/@noble_hashes@2.4.0/node_modules/@noble/hashes/_u64.js +0 -13
  94. package/dist/node_modules/.pnpm/@noble_hashes@2.4.0/node_modules/@noble/hashes/_u64.js.map +0 -1
  95. package/dist/node_modules/.pnpm/@noble_hashes@2.4.0/node_modules/@noble/hashes/sha2.js +0 -198
  96. package/dist/node_modules/.pnpm/@noble_hashes@2.4.0/node_modules/@noble/hashes/sha2.js.map +0 -1
  97. package/dist/node_modules/.pnpm/@noble_hashes@2.4.0/node_modules/@noble/hashes/utils.js +0 -243
  98. package/dist/node_modules/.pnpm/@noble_hashes@2.4.0/node_modules/@noble/hashes/utils.js.map +0 -1
  99. package/dist/node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js +0 -51
  100. package/dist/node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js.map +0 -1
  101. package/dist/node_modules/.pnpm/brace-expansion@5.0.11/node_modules/brace-expansion/dist/esm/index.js +0 -202
  102. package/dist/node_modules/.pnpm/brace-expansion@5.0.11/node_modules/brace-expansion/dist/esm/index.js.map +0 -1
  103. package/dist/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/assert-valid-pattern.js +0 -10
  104. package/dist/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/assert-valid-pattern.js.map +0 -1
  105. package/dist/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/ast.js +0 -514
  106. package/dist/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/ast.js.map +0 -1
  107. package/dist/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/brace-expressions.js +0 -124
  108. package/dist/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/brace-expressions.js.map +0 -1
  109. package/dist/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/escape.js +0 -21
  110. package/dist/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/escape.js.map +0 -1
  111. package/dist/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/index.js +0 -629
  112. package/dist/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/index.js.map +0 -1
  113. package/dist/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/unescape.js +0 -28
  114. package/dist/node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/unescape.js.map +0 -1
package/AGENTS.md CHANGED
@@ -60,6 +60,9 @@ and repository rules.
60
60
  key adopts: a slug `getSlug()` derived from `name`/`title`/`label` moves to
61
61
  a free `-2`, `-3`, … slug and INSERTs. See `agents/schema-paths.md`
62
62
  ("Tenant OWNERSHIP").
63
+ - Owning `CollectionInterceptor.writeGuard` predicates must reach final writes,
64
+ including natural-key adoption and deletes; zero matched rows fail closed.
65
+ See [object runtime](agents/object-runtime.md).
63
66
  - Persisted saves use `id` and loaded `updated_at`; new saves use natural keys.
64
67
  Preserve revision compare-and-swap ordering through public `save()`,
65
68
  `claimRevision()`, and transaction APIs. Embedded saves, deletes, and complete
@@ -128,6 +131,9 @@ and repository rules.
128
131
  collections (including `SmrtReportCollection`) never claim one. Consumer
129
132
  gates: `registry/__tests__/issue-3110-*.test.ts`, `issue-3109-*.test.ts`,
130
133
  `packages/bundle-gate/src/__tests__/consumer-same-name.spec.ts`.
134
+ - A collection class never publishes more than its model: unset surfaces
135
+ inherit the model's, and the build rejects a collection that opens a CRUD
136
+ write its model closes. See `agents/generators.md` (Collection exposure).
131
137
  - API custom-action eligibility has ONE resolver, `resolveApiMethodExposure()`
132
138
  in `generators/custom-action.ts`: both SvelteKit route emitters,
133
139
  `resolveApiActionSet`, and `knowledge.ts` read it, and a new consumer must too
@@ -14,6 +14,11 @@ it:
14
14
  `PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH` to use another Chromium. CI runs it in
15
15
  the workbench browser job.
16
16
 
17
+ `@noble/hashes`, `import-meta-resolve` and `minimatch` remain external runtime dependencies in the preserve-modules
18
+ package build. Bundling it under `dist/node_modules` leaves dangling imports
19
+ when npm excludes that directory from tarballs. The packed MCP consumer tests
20
+ the installed relative-import closure and real SHA-256 execution with normal and CI prepack paths (#4008).
21
+
17
22
  ## How a Node-only dependency stays out
18
23
 
19
24
  Never import it statically from a module the browser graph reaches. Pick one:
@@ -42,6 +42,43 @@ identifier, or annotation changes cannot alter persisted row hydration.
42
42
 
43
43
  Per-field web emission (#2046): `buildWebFieldDefinitions` carries `description` (from `@field({ description })`) and sanitized `ui` hints (from `@field({ ui: { basic, group, order, locked } })`, read off the manifest `_meta.ui` bag through per-key type guards) into each emitted field definition, and `buildWebToolDescriptors` threads the same `description` into browser MCP tool schemas. `sensitive`/`transient` fields are excluded from emission entirely, so their descriptions never ship. Both keys are conditional, so hint-less schemas emit byte-identical definitions (and hashes) as before; adding a description/ui hint changes the manifest hash — deliberate over-invalidation, harmless per the #1764 contract.
44
44
 
45
+ ## MCP `get` serializers
46
+
47
+ A model may add an async serializer only to its standard generated MCP `get`
48
+ tool. Configure a module specifier and named export under `mcp.serializers.get`:
49
+
50
+ ```ts
51
+ @smrt({
52
+ mcp: {
53
+ serializers: {
54
+ get: {
55
+ importPath: '@scope/package',
56
+ exportName: 'serializeThingMcpGet',
57
+ },
58
+ },
59
+ },
60
+ })
61
+ ```
62
+
63
+ The named export receives `(item, options: PublicJsonOptions)` and returns the
64
+ get result (or a promise for it). Bare package specifiers resolve with ESM
65
+ conditions from the declaring model's loaded module, so the serializer's owning
66
+ package is an application dependency rather than a dependency of core or a
67
+ generic dispatcher. This anchor is independent of `process.cwd()`. Relative
68
+ references retain ordinary dynamic-import behavior. The MCP runtime imports
69
+ and caches the named module, then calls the serializer after normal
70
+ authentication, tenant-scoped lookup, and read access have admitted and loaded
71
+ the item. A missing or non-function export makes that `get` call fail. The hook
72
+ replaces only the standard `get` result; generated `list`, writes, deletes, and
73
+ custom actions keep their existing contracts.
74
+
75
+ The serializer owns its public projection. Start with
76
+ `item.toPublicJSON(options)`, and project each related model with that model's
77
+ `toPublicJSON(options)` before adding it. The final transport pass cannot make
78
+ arbitrary plain aliases permission-safe: returning a DTO does not cause fields
79
+ inside it to be filtered by model policy. Do not use `toJSON()` or spread model
80
+ instances into a serializer result.
81
+
45
82
  ## Generated MCP server output language
46
83
 
47
84
  `MCPGenerator` builds every file as TypeScript, so the requested `outputPath`
@@ -185,6 +222,30 @@ rather than asserting the collision.
185
222
  `smrt doctor` prints the whole surface — model tools, intents, playbooks — from
186
223
  these artifacts alone, with no application running.
187
224
 
225
+ ## Collection exposure
226
+
227
+ A collection class is registered as a resource of its own, so every transport
228
+ generates operations for it (`<name>collection_create` MCP tools,
229
+ `<name>collection:create` CLI commands, routes for its public methods). It may
230
+ never publish more than its model. `registry/collection-exposure.ts` holds the
231
+ rule; the manifest generator applies it (`mergeInheritedFields`) and
232
+ `ObjectRegistry.getConfig()` applies it again at runtime, so a manifest built
233
+ before the rule is held to it too. For each of `api`/`mcp`/`cli` the collection
234
+ leaves unset, it inherits the model's: `false` stays `false`; an `include`
235
+ list keeps only its CRUD verbs (the other names are the model's instance
236
+ methods, so the collection's own methods stay closed); an `exclude` list is
237
+ copied; an open model leaves the collection open. A `sensitive: true` model's
238
+ collection gets read-only MCP unless it configures `mcp` itself. The CLI treats
239
+ a collection's `include` as the complete allowlist, as MCP and REST do.
240
+
241
+ A collection opens its own methods by listing them in its own `@smrt()`. A
242
+ collection decorator's config is merged over its model's at runtime, so repeat
243
+ the model's CRUD verbs (and storage keys) there. The build fails with
244
+ `CONFIG_COLLECTION_EXPOSURE` when a collection's own surface opens an MCP or
245
+ CLI CRUD write its model closes. Gates: `registry/__tests__/collection-exposure.test.ts`,
246
+ `packages/cli/src/__tests__/collection-exposure.test.ts`, and the cross-package
247
+ `packages/bundle-gate/src/__tests__/collection-exposure.spec.ts`.
248
+
188
249
  ## Custom-action contract
189
250
 
190
251
  `resolveCustomActionMetadata()` is the common discovery and invocation contract
@@ -197,3 +197,20 @@ instances and never use this path to overwrite a loaded revision.
197
197
  - **Runtime-only** — attached to the prototype, invisible to the build-time manifest, so it never leaks into the REST/CLI/MCP surface.
198
198
 
199
199
  When the target declares multiple FKs back to the parent, annotate `@oneToMany(Target, { foreignKey: '<inverseField>' })`; `loadRelatedMany` and the eager `include:` loader both honor it (else first-match).
200
+
201
+ ## Mandatory persisted write predicates
202
+
203
+ `CollectionInterceptor.writeGuard` supplies trusted column predicates that callers
204
+ cannot override through patches or save options. Core conjoins these with CAS
205
+ conditions at the final mutation. Guarded new rows insert without unconditional
206
+ upsert fallback; existing natural-key targets update conditionally, with zero rows
207
+ failing closed. Embedded adapter checks execute inside the shared write queue;
208
+ PostgreSQL uses the final SQL predicate. Guarded policies disable bulk shortcuts
209
+ unless explicitly compatible. Preserve this enforcement in save, claimRevision,
210
+ delete and natural-key adoption paths, including transaction-bound executors.
211
+
212
+ Mandatory write guards preserve natural-key identity: only the row found and
213
+ owner-checked by the natural-key lookup can be adopted for a conditional update.
214
+ An unmatched natural key uses INSERT, even if its explicit primary key names an
215
+ existing row. Duplicate IDs therefore fail without changing foreign/global rows,
216
+ including NULL-bearing natural keys on PostgreSQL.
package/dist/browser.d.ts CHANGED
@@ -61,6 +61,7 @@ export { createFilesystemAdapter, type FilesystemAdapterFactory, registerFilesys
61
61
  export { createGeneratedCollectionAccess, type GeneratedCollectionAccess, type GeneratedCollectionRuntime, } from "./generated-collection-access.js";
62
62
  export { type ApiMethodExposure, type ApiMethodRejectionCode, buildCustomActionInputSchema, buildCustomActionInvocationArgs, CRUD_OPERATIONS, type CustomActionFailure, type CustomActionMetadata, type CustomActionScope, classifyMethodWireability, classifyParameterWireability, coerceCustomActionArgument, createClassNamePredicate, createManifestClassNamePredicate, customActionParameterInputName, declaredTypeAcceptsDate, declaresRuntimeRestRoute, declaresRuntimeRestRouteShape, type EffectiveActionMetadata, type ExposableMethod, isCrudOperation, isCrudToolAction, type MethodDecoratorConfig, normalizeCustomActionFailure, queryStringDecoderFor, type ResolveApiMethodExposureOptions, type ResolveCustomActionMetadataOptions, type ResolvedCustomActionMetadata, readMethodDecoratorConfig, resolveApiMethodExposure, resolveCustomActionMetadata, resolveDeclaredScopeMismatch, resolveEffectiveActionMetadata, SMRT_CUSTOM_ACTION_ERROR_METADATA_KEY, type ToolEffect, toCustomActionBoolean, toCustomActionDate, toCustomActionNumber, type WireabilityOptions, type WireabilityVerdict, type WireableParameter, } from "./generators/custom-action.js";
63
63
  export { runWithTenantGate, setTenantEntryPointRunner, type TenantEntryPointRunner, type TenantGateOptions, } from "./generators/tenant-gate.js";
64
+ export { fieldTypeToJsonSchema, type ToolFieldMeta, type ToolJsonSchema, } from "./generators/tool-schema.js";
64
65
  export { normalizeTypedHttpError, type TypedHttpFailure, } from "./generators/typed-http-error.js";
65
66
  export { type HierarchyView, SmrtHierarchical } from "./hierarchical.js";
66
67
  export * from "./interceptors.js";
@@ -81,6 +82,7 @@ export { deriveRecipeDemo, effectiveRecipeDemo, hasBrowserOption, isMockableProv
81
82
  export { buildConnectSection, buildGlossary, type ConnectSection, type ConnectSurface, createRecipeHelp, extractFieldRefs, findField, type GlossaryEntry, type HelpBlock, type HelpField, type HelpModel, helpToMarkdown, type Inline, parseHelp, type RecipeHelp, type RenderedHelp, type RenderHelpOptions, renderHelp, resolveHelp, validateHelp, } from "./recipe-help.js";
82
83
  export * from "./registry.js";
83
84
  export { smrt as smrtRegistry } from "./registry.js";
85
+ export { type CollectionWriteEscalation, type CrudVerb, exposedCrudVerbs, findCollectionWriteEscalations, inheritCollectionExposure, inheritedCollectionSurface, } from "./registry/collection-exposure.js";
84
86
  export type { RuntimeRegistrationOverride } from "./registry/runtime-overrides.js";
85
87
  export { POSTGRES_REVISION_GUARD_EXPRESSION, postgresRevisionCandidates, postgresRevisionCondition, } from "./revision-guard.js";
86
88
  export { createSmrtClient } from "./runtime/client.js";
@@ -1 +1 @@
1
- {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAGH,cAAc,qBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EACL,gBAAgB,EAChB,KAAK,WAAW,EAChB,KAAK,2BAA2B,EAChC,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,KAAK,cAAc,EACnB,gBAAgB,GACjB,MAAM,cAAW,CAAC;AAGnB,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,YAAY,EACZ,aAAa,EACb,cAAc,EACd,4BAA4B,EAC5B,iBAAiB,EACjB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,qBAAqB,EACrB,eAAe,EACf,qBAAqB,EACrB,KAAK,iBAAiB,EACtB,eAAe,EACf,eAAe,EACf,2BAA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AC;AACjC,YAAY,EACV,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,iBAAiB,GAClB,MAAM,mBAAgB,CAAC;AAExB,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAe,CAAC;AAEpD,cAAc,kBAAe,CAAC;AAG9B,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,kBAAe,CAAC;AAG/D,OAAO,EACL,0BAA0B,EAC1B,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,yBAAsB,CAAC;AAE9B,OAAO,EACL,KAAK,EACL,cAAc,EACd,OAAO,EACP,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,EACL,KAAK,MAAM,EACX,KAAK,cAAc,EACnB,SAAS,EACT,aAAa,EACb,SAAS,GACV,MAAM,iBAAc,CAAC;AAGtB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAgB,CAAC;AAE7C,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,YAAY,EACZ,2BAA2B,EAC3B,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,MAAM,EACN,KAAK,mBAAmB,EACxB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,4BAAyB,CAAC;AAOjC,OAAO,EACL,KAAK,wBAAwB,EAC7B,+BAA+B,GAChC,MAAM,2BAA2B,CAAC;AAEnC,cAAc,kBAAkB,CAAC"}
package/dist/browser.js CHANGED
@@ -45,6 +45,7 @@ import { ContentHasher } from "./embeddings/hash.js";
45
45
  import { POSTGRES_REVISION_GUARD_EXPRESSION, postgresRevisionCandidates, postgresRevisionCondition } from "./revision-guard.js";
46
46
  import { executeToolCall, executeToolCalls, formatToolResults, validateToolCall } from "./tools/tool-executor.js";
47
47
  import { SmrtObject } from "./object.js";
48
+ import { exposedCrudVerbs, findCollectionWriteEscalations, inheritCollectionExposure, inheritedCollectionSurface } from "./registry/collection-exposure.js";
48
49
  import { isDatabaseInterface, resolveDatabase } from "./database.js";
49
50
  import { ObjectRegistry, smrt } from "./registry.js";
50
51
  import { auditChanges, auditSnapshot, getActiveAuditOptions, isAudited, requireAuditOptions, writeAudit } from "./audit.js";
@@ -65,6 +66,7 @@ import { convertTypeToJsonSchema, generateToolFromMethod, generateToolManifest,
65
66
  import { CRUD_OPERATIONS, SMRT_CUSTOM_ACTION_ERROR_METADATA_KEY, buildCustomActionInputSchema, buildCustomActionInvocationArgs, classifyMethodWireability, classifyParameterWireability, coerceCustomActionArgument, createClassNamePredicate, createManifestClassNamePredicate, customActionParameterInputName, declaredTypeAcceptsDate, declaresRuntimeRestRoute, declaresRuntimeRestRouteShape, isCrudOperation, isCrudToolAction, normalizeCustomActionFailure, queryStringDecoderFor, readMethodDecoratorConfig, resolveApiMethodExposure, resolveCustomActionMetadata, resolveDeclaredScopeMismatch, resolveEffectiveActionMetadata, toCustomActionBoolean, toCustomActionDate, toCustomActionNumber } from "./generators/custom-action.js";
66
67
  import { DEFAULT_DISPLAY_LABEL_FIELDS, FIELD_UI_FORMATS, FIELD_UI_FORMAT_TYPES, FIELD_UI_WIDGETS, FIELD_UI_WIDGET_TYPES, RELATIONSHIP_ROLES, describeDisplayLabel, displayLabelFieldProblem, findSelectorFor, isFieldUIFormat, isFieldUIWidget, isRelationshipRole, resolveDisplayLabelField } from "./ui-metadata.js";
67
68
  import { runWithTenantGate, setTenantEntryPointRunner } from "./generators/tenant-gate.js";
69
+ import { fieldTypeToJsonSchema } from "./generators/tool-schema.js";
68
70
  import { MAX_SYNC_APPLY_BATCH_SIZE, SYNC_APPLY_ROUTE_SEGMENTS, SYNC_APPLY_UUID_PATTERN, applySyncWritablePolicy, isStaleWrite, parseSyncApplyBatch, payloadMatchesRow, processSyncApplyBatch, validateSyncApplyItem } from "./sync/apply.js";
69
71
  import { resolveOperationPermissionAlias } from "./operation-permission.js";
70
72
  import { normalizeTypedHttpError } from "./generators/typed-http-error.js";
@@ -87,4 +89,4 @@ import { DIAGNOSTICS_DEFAULT_LIMIT, SYSTEM_DIAGNOSTICS_TABLES, readDispatchHealt
87
89
  import { DEFAULT_RETENTION_POLICY, clearRetentionTasks, getRetentionTasks, pruneAiUsage, pruneExpiredContexts, pruneRunOnceClaims, registerRetentionTask, runRetentionSweep, unregisterRetentionTask } from "./system/retention.js";
88
90
  import "./system/browser.js";
89
91
  import "./tools/index.js";
90
- export { AIError, AiUsageCollector, AiUsagePersistenceHandler, CACHE_INVALIDATION_CHANNEL, CHANGE_FEED_CREDENTIAL_TABLES, CHANGE_FEED_INTERCEPTOR_NAME, CHANGE_FEED_TABLE, CHANGE_SIGNAL_CHANNEL, CRUD_OPERATIONS, ConfigurationError, ContentHasher, CosineSimilarity, DEFAULT_AI_COST_RATES, DEFAULT_CHANGES_LIMIT, DEFAULT_DATA_QUERY_PAGE_LIMIT, DEFAULT_DATA_QUERY_RESULT_BYTES, DEFAULT_DISPLAY_LABEL_FIELDS, DEFAULT_EMBEDDING_CONFIG, DEFAULT_FACET_LIMIT, DEFAULT_LEARNING_CONFIG, DEFAULT_LIST_LIMIT, DEFAULT_LIST_ORDER_BY, DEFAULT_POSTGRES_TIMEOUTS, DEFAULT_RETENTION_POLICY, DIAGNOSTICS_DEFAULT_LIMIT, DataQueryValidationError, DatabaseError, Dispatch, DispatchBus, DispatchCollection, DispatchSubscription, DispatchSubscriptionCollection, EmbeddingProvider, EmbeddingStorage, EmbeddingUnavailableError, ErrorUtils, FIELD_UI_FORMATS, FIELD_UI_FORMAT_TYPES, FIELD_UI_WIDGETS, FIELD_UI_WIDGET_TYPES, FilesystemError, GlobalInterceptors, IN_LIST_CHUNK_SIZE, LearningMemory, LiveSchemaParityError, MAX_CHANGES_LIMIT, MAX_DATA_QUERY_CURSOR_LENGTH, MAX_DATA_QUERY_FACETS, MAX_DATA_QUERY_FILTERS, MAX_DATA_QUERY_FILTER_DEPTH, MAX_DATA_QUERY_IN_VALUES, MAX_DATA_QUERY_OFFSET, MAX_DATA_QUERY_PAGE_LIMIT, MAX_DATA_QUERY_REQUEST_BYTES, MAX_DATA_QUERY_RESULT_BYTES, MAX_DATA_QUERY_WARNINGS, MAX_FACET_FIELDS, MAX_FACET_LIMIT, MAX_LIST_LIMIT, MAX_STI_READ_SCOPE_TYPES, MAX_SYNC_APPLY_BATCH_SIZE, MOCK_PROVIDER_OPTION, MetricsAdapter, NetworkError, ObjectRegistry, POSTGRES_REVISION_GUARD_EXPRESSION, POSTGRES_TIMEOUT_ENV_VARS, PubSubAdapter, QueryBoundsError, QueryOrderByError, RECIPE_DEMO_MODES, RELATIONSHIP_ROLES, RunOnceClaimError, RuntimeError, SMRT_COLLECTION_BASE_NAMES, SMRT_CUSTOM_ACTION_ERROR_METADATA_KEY, SMRT_SCHEMA_VERSION, SYNC_APPLY_ROUTE_SEGMENTS, SYNC_APPLY_UUID_PATTERN, SYSTEM_DIAGNOSTICS_TABLES, SYSTEM_TABLE_NAMES, SchemaComparer, SignalBus, SignalSanitizer, SmrtClass, SmrtCollection, SmrtError, SmrtHierarchical, SmrtJunction, SmrtJunctionBase, SmrtObject, SmrtPolymorphicAssociation, SmrtRecipe, TenantIsolationError, ValidationError, ValidationReport, ValidationUtils, appendChange, appendChanges, applyOneToManyChildAccessors, applyPendingDecoratorRegistrations, applyPostgresPermissions, applyPostgresRuntimeTimeouts, applySyncWritablePolicy, assertFiniteUnitInterval, assertPostgresSystemTimestampsCurrent, assertScopedPackageName, auditChanges, auditSnapshot, broadcastCacheInvalidation, buildCascadePlan, buildConnectSection, buildCustomActionInputSchema, buildCustomActionInvocationArgs, buildDefaultListOrderBy, buildGlossary, bumpChangeFeed, canonicalizeDataQuery, cascadeReferencesTo, checkLiveSchemaParity, childAccessorName, chunkArray, classifyDatabaseError, classifyDialectMessage, classifyMethodWireability, classifyParameterWireability, clearRetentionTasks, clone, coerceCustomActionArgument, collectForeignKeyOrphanCounts, config, convertTypeToJsonSchema, createClassNamePredicate, createDataQueryFingerprint, createDispatchBus, createFilesystemAdapter, createGeneratedCollectionAccess, createInterceptorContext, createManifestClassNamePredicate, createQualifiedName, createRecipeHelp, createSmrtClient, crossPackageRef, customActionParameterInputName, declareChangeFeedSensitiveTable, declaredTypeAcceptsDate, declaresRuntimeRestRoute, declaresRuntimeRestRouteShape, deriveRecipeDemo, describeDisplayLabel, detectEngine, displayLabelFieldProblem, drainChangeFeed, effectiveRecipeDemo, ensureBootstrapSystemTableCompatibility, ensureCacheInvalidationListener, ensureChangeFeedTable, ensureDeferredSystemTableCompatibility, ensureDispatchSubscriptionsSystemTableCompatibility, ensureDispatchSystemTableCompatibility, ensureJobEventsSystemTableCompatibility, ensureJobsSystemTableCompatibility, ensureLegacySystemTableCompatibility, ensureSystemTables, estimateAiUsageCost, executeCollectionReadPlan, executeDecision, executeToolCall, executeToolCalls, extractFieldRefs, field, filterVisibleChangeFeedEntries, findField, findSelectorFor, foreignKey, formatToolResults, generateDDLForEngine, generateSchemaDiff, generateToolFromMethod, generateToolManifest, getActiveAuditOptions, getAdapterInfo, getAuthorizedChangesSince, getAuthorizedTenantScopedChangesSince, getCacheGeneration, getChangeFeedSensitiveTables, getChangesSince, getClassConfigResolvers, getClassName, getConfigResolver, getDatabaseEngine, getPackageFromQualifiedName, getRetentionTasks, getSQLFromDiff, getSystemTableShapes, getTableVersion, getTenantScopedChangesSince, hasActionableChanges, hasBrowserOption, hasChangeFeedEntryVisibilityHook, hasChangeFeedTableAuthorizerHook, helpToMarkdown, importOptionalDependency, invalidateCollectionCache, isAbortedTransactionError, isAdvisoryOnlyChange, isAudited, isChangeFeedDenyAll, isChangeFeedEntryVisible, isChangeFeedSensitiveTable, isCrudOperation, isCrudToolAction, isDatabaseInterface, isDeterministicDatabaseError, isEmbeddedDatabase, isFieldUIFormat, isFieldUIWidget, isFrameworkBaseClass, isFromPackage, isLazyConfigSentinel, isManualOrAdvisoryChange, isMockableProvider, isNotNullViolationError, isPostgresDatabase, isQualifiedName, isRelationshipRole, isScopedPackageName, isSensitiveConnectionParam, isServerProvider, isSmrtCollectionExtendsName, isStaleWrite, isTenantScopedClassResolved, isTransientDatabaseError, isType, isUniqueViolationError, isValid, listConfigResolvers, manyToMany, meta, method, migratePostgresSystemTimestamps, normalizeCustomActionFailure, normalizeDataQueryRequest, normalizeDataQueryResult, normalizeDataQuerySchema, normalizeOnDelete, normalizeTypedHttpError, oneToMany, parse, parseHelp, parseQualifiedName, parseSyncApplyBatch, payloadMatchesRow, planForeignKeyCreation, planPostgresPermissions, planPostgresSystemTimestampMigrations, postgresRevisionCandidates, postgresRevisionCondition, processSyncApplyBatch, pruneAiUsage, pruneChangeFeed, pruneExpiredContexts, pruneRunOnceClaims, qualifiedNamesEqual, queryStringDecoderFor, readDispatchHealth, readJobHealth, readMethodDecoratorConfig, readMigrationStatus, readRecentChanges, readRegistryDrift, readScheduleHealth, readSystemDiagnostics, redactDatabaseUrl, redactDatabaseUrlsInText, registerChangeFeedWriter, registerCompatibleFieldDecorator, registerCompatibleMethodDecorator, registerConfigResolver, registerFilesystemAdapterFactory, registerOptionalDependency, registerRetentionTask, renderHelp, requireAuditOptions, resetChangeFeedWarnings, resetChangeSignals, resetCollectionCache, resetConfigResolvers, resetVerifiedTables, resolveApiMethodExposure, resolveAuthorizedChangeFeedTables, resolveCustomActionMetadata, resolveDatabase, resolveDbCacheKey, resolveDeclaredScopeMismatch, resolveDispatchTenantId, resolveDispatchTenantScope, resolveDisplayLabelField, resolveEffectiveActionMetadata, resolveGetStringFilter, resolveHelp, resolveLazyConfig, resolveListLimit, resolveListOffset, resolveOperationPermissionAlias, resolvePostgresTimeouts, runCascadeDelete, runRetentionSweep, runWithTenantGate, safeParse, safeStringify, setChangeFeedAuthorizer, setChangeFeedEntryVisibility, setDispatchTenantResolver, setTenantEntryPointRunner, setTenantScopedClassResolver, shouldIncludeMethod, smrt, smrt as smrtRegistry, stopCacheInvalidationListeners, stopChangeSignalListeners, stringify, subscribeToChangeSignals, tableExists, toCustomActionBoolean, toCustomActionDate, toCustomActionNumber, toSnakeCase, unregisterChangeFeedWriter, unregisterConfigResolver, unregisterRetentionTask, usesEmbeddedRevisionFallback, validateHelp, validatePostgresPermissionContract, validateSyncApplyItem, validateToolCall, withAuditContext, withEmbeddedWriteQueue, withEmbeddedWriteTransaction, writeAudit };
92
+ export { AIError, AiUsageCollector, AiUsagePersistenceHandler, CACHE_INVALIDATION_CHANNEL, CHANGE_FEED_CREDENTIAL_TABLES, CHANGE_FEED_INTERCEPTOR_NAME, CHANGE_FEED_TABLE, CHANGE_SIGNAL_CHANNEL, CRUD_OPERATIONS, ConfigurationError, ContentHasher, CosineSimilarity, DEFAULT_AI_COST_RATES, DEFAULT_CHANGES_LIMIT, DEFAULT_DATA_QUERY_PAGE_LIMIT, DEFAULT_DATA_QUERY_RESULT_BYTES, DEFAULT_DISPLAY_LABEL_FIELDS, DEFAULT_EMBEDDING_CONFIG, DEFAULT_FACET_LIMIT, DEFAULT_LEARNING_CONFIG, DEFAULT_LIST_LIMIT, DEFAULT_LIST_ORDER_BY, DEFAULT_POSTGRES_TIMEOUTS, DEFAULT_RETENTION_POLICY, DIAGNOSTICS_DEFAULT_LIMIT, DataQueryValidationError, DatabaseError, Dispatch, DispatchBus, DispatchCollection, DispatchSubscription, DispatchSubscriptionCollection, EmbeddingProvider, EmbeddingStorage, EmbeddingUnavailableError, ErrorUtils, FIELD_UI_FORMATS, FIELD_UI_FORMAT_TYPES, FIELD_UI_WIDGETS, FIELD_UI_WIDGET_TYPES, FilesystemError, GlobalInterceptors, IN_LIST_CHUNK_SIZE, LearningMemory, LiveSchemaParityError, MAX_CHANGES_LIMIT, MAX_DATA_QUERY_CURSOR_LENGTH, MAX_DATA_QUERY_FACETS, MAX_DATA_QUERY_FILTERS, MAX_DATA_QUERY_FILTER_DEPTH, MAX_DATA_QUERY_IN_VALUES, MAX_DATA_QUERY_OFFSET, MAX_DATA_QUERY_PAGE_LIMIT, MAX_DATA_QUERY_REQUEST_BYTES, MAX_DATA_QUERY_RESULT_BYTES, MAX_DATA_QUERY_WARNINGS, MAX_FACET_FIELDS, MAX_FACET_LIMIT, MAX_LIST_LIMIT, MAX_STI_READ_SCOPE_TYPES, MAX_SYNC_APPLY_BATCH_SIZE, MOCK_PROVIDER_OPTION, MetricsAdapter, NetworkError, ObjectRegistry, POSTGRES_REVISION_GUARD_EXPRESSION, POSTGRES_TIMEOUT_ENV_VARS, PubSubAdapter, QueryBoundsError, QueryOrderByError, RECIPE_DEMO_MODES, RELATIONSHIP_ROLES, RunOnceClaimError, RuntimeError, SMRT_COLLECTION_BASE_NAMES, SMRT_CUSTOM_ACTION_ERROR_METADATA_KEY, SMRT_SCHEMA_VERSION, SYNC_APPLY_ROUTE_SEGMENTS, SYNC_APPLY_UUID_PATTERN, SYSTEM_DIAGNOSTICS_TABLES, SYSTEM_TABLE_NAMES, SchemaComparer, SignalBus, SignalSanitizer, SmrtClass, SmrtCollection, SmrtError, SmrtHierarchical, SmrtJunction, SmrtJunctionBase, SmrtObject, SmrtPolymorphicAssociation, SmrtRecipe, TenantIsolationError, ValidationError, ValidationReport, ValidationUtils, appendChange, appendChanges, applyOneToManyChildAccessors, applyPendingDecoratorRegistrations, applyPostgresPermissions, applyPostgresRuntimeTimeouts, applySyncWritablePolicy, assertFiniteUnitInterval, assertPostgresSystemTimestampsCurrent, assertScopedPackageName, auditChanges, auditSnapshot, broadcastCacheInvalidation, buildCascadePlan, buildConnectSection, buildCustomActionInputSchema, buildCustomActionInvocationArgs, buildDefaultListOrderBy, buildGlossary, bumpChangeFeed, canonicalizeDataQuery, cascadeReferencesTo, checkLiveSchemaParity, childAccessorName, chunkArray, classifyDatabaseError, classifyDialectMessage, classifyMethodWireability, classifyParameterWireability, clearRetentionTasks, clone, coerceCustomActionArgument, collectForeignKeyOrphanCounts, config, convertTypeToJsonSchema, createClassNamePredicate, createDataQueryFingerprint, createDispatchBus, createFilesystemAdapter, createGeneratedCollectionAccess, createInterceptorContext, createManifestClassNamePredicate, createQualifiedName, createRecipeHelp, createSmrtClient, crossPackageRef, customActionParameterInputName, declareChangeFeedSensitiveTable, declaredTypeAcceptsDate, declaresRuntimeRestRoute, declaresRuntimeRestRouteShape, deriveRecipeDemo, describeDisplayLabel, detectEngine, displayLabelFieldProblem, drainChangeFeed, effectiveRecipeDemo, ensureBootstrapSystemTableCompatibility, ensureCacheInvalidationListener, ensureChangeFeedTable, ensureDeferredSystemTableCompatibility, ensureDispatchSubscriptionsSystemTableCompatibility, ensureDispatchSystemTableCompatibility, ensureJobEventsSystemTableCompatibility, ensureJobsSystemTableCompatibility, ensureLegacySystemTableCompatibility, ensureSystemTables, estimateAiUsageCost, executeCollectionReadPlan, executeDecision, executeToolCall, executeToolCalls, exposedCrudVerbs, extractFieldRefs, field, fieldTypeToJsonSchema, filterVisibleChangeFeedEntries, findCollectionWriteEscalations, findField, findSelectorFor, foreignKey, formatToolResults, generateDDLForEngine, generateSchemaDiff, generateToolFromMethod, generateToolManifest, getActiveAuditOptions, getAdapterInfo, getAuthorizedChangesSince, getAuthorizedTenantScopedChangesSince, getCacheGeneration, getChangeFeedSensitiveTables, getChangesSince, getClassConfigResolvers, getClassName, getConfigResolver, getDatabaseEngine, getPackageFromQualifiedName, getRetentionTasks, getSQLFromDiff, getSystemTableShapes, getTableVersion, getTenantScopedChangesSince, hasActionableChanges, hasBrowserOption, hasChangeFeedEntryVisibilityHook, hasChangeFeedTableAuthorizerHook, helpToMarkdown, importOptionalDependency, inheritCollectionExposure, inheritedCollectionSurface, invalidateCollectionCache, isAbortedTransactionError, isAdvisoryOnlyChange, isAudited, isChangeFeedDenyAll, isChangeFeedEntryVisible, isChangeFeedSensitiveTable, isCrudOperation, isCrudToolAction, isDatabaseInterface, isDeterministicDatabaseError, isEmbeddedDatabase, isFieldUIFormat, isFieldUIWidget, isFrameworkBaseClass, isFromPackage, isLazyConfigSentinel, isManualOrAdvisoryChange, isMockableProvider, isNotNullViolationError, isPostgresDatabase, isQualifiedName, isRelationshipRole, isScopedPackageName, isSensitiveConnectionParam, isServerProvider, isSmrtCollectionExtendsName, isStaleWrite, isTenantScopedClassResolved, isTransientDatabaseError, isType, isUniqueViolationError, isValid, listConfigResolvers, manyToMany, meta, method, migratePostgresSystemTimestamps, normalizeCustomActionFailure, normalizeDataQueryRequest, normalizeDataQueryResult, normalizeDataQuerySchema, normalizeOnDelete, normalizeTypedHttpError, oneToMany, parse, parseHelp, parseQualifiedName, parseSyncApplyBatch, payloadMatchesRow, planForeignKeyCreation, planPostgresPermissions, planPostgresSystemTimestampMigrations, postgresRevisionCandidates, postgresRevisionCondition, processSyncApplyBatch, pruneAiUsage, pruneChangeFeed, pruneExpiredContexts, pruneRunOnceClaims, qualifiedNamesEqual, queryStringDecoderFor, readDispatchHealth, readJobHealth, readMethodDecoratorConfig, readMigrationStatus, readRecentChanges, readRegistryDrift, readScheduleHealth, readSystemDiagnostics, redactDatabaseUrl, redactDatabaseUrlsInText, registerChangeFeedWriter, registerCompatibleFieldDecorator, registerCompatibleMethodDecorator, registerConfigResolver, registerFilesystemAdapterFactory, registerOptionalDependency, registerRetentionTask, renderHelp, requireAuditOptions, resetChangeFeedWarnings, resetChangeSignals, resetCollectionCache, resetConfigResolvers, resetVerifiedTables, resolveApiMethodExposure, resolveAuthorizedChangeFeedTables, resolveCustomActionMetadata, resolveDatabase, resolveDbCacheKey, resolveDeclaredScopeMismatch, resolveDispatchTenantId, resolveDispatchTenantScope, resolveDisplayLabelField, resolveEffectiveActionMetadata, resolveGetStringFilter, resolveHelp, resolveLazyConfig, resolveListLimit, resolveListOffset, resolveOperationPermissionAlias, resolvePostgresTimeouts, runCascadeDelete, runRetentionSweep, runWithTenantGate, safeParse, safeStringify, setChangeFeedAuthorizer, setChangeFeedEntryVisibility, setDispatchTenantResolver, setTenantEntryPointRunner, setTenantScopedClassResolver, shouldIncludeMethod, smrt, smrt as smrtRegistry, stopCacheInvalidationListeners, stopChangeSignalListeners, stringify, subscribeToChangeSignals, tableExists, toCustomActionBoolean, toCustomActionDate, toCustomActionNumber, toSnakeCase, unregisterChangeFeedWriter, unregisterConfigResolver, unregisterRetentionTask, usesEmbeddedRevisionFallback, validateHelp, validatePostgresPermissionContract, validateSyncApplyItem, validateToolCall, withAuditContext, withEmbeddedWriteQueue, withEmbeddedWriteTransaction, writeAudit };
@@ -1 +1 @@
1
- {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../src/cookbook/engine/commands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAqB,MAAM,2BAA2B,CAAC;AA6B7E,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,aAAa,EAEb,aAAa,EAEd,MAAM,YAAY,CAAC;AAEpB,uFAAuF;AACvF,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,QAAQ,CAAC;IACd,0DAA0D;IAC1D,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,MAAM,MAAM,OAAO,GACf;IACE,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,SAAS,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB,GACD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,YAAY,CAAA;CAAE,CAAC;AAEvC,eAAO,MAAM,IAAI,GACf,MAAM,gBAAgB,EACtB,SAAS,MAAM,EACf,QAAO;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAO,KAC/D,OAA8D,CAAC;AAalE,4DAA4D;AAC5D,wBAAgB,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAQpD;AAED,eAAO,MAAM,iBAAiB,GAAI,KAAK,QAAQ,KAAG,MACb,CAAC;AAEtC;;;;;GAKG;A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M,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAO,KAC/D,OAA8D,CAAC;AAalE,4DAA4D;AAC5D,wBAAgB,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAQpD;AAED,eAAO,MAAM,iBAAiB,GAAI,KAAK,QAAQ,KAAG,MACb,CAAC;AAEtC;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,QAAQ,GAAG,QAAQ,CAUrE;AAED,wBAAgB,WAAW,CACzB,OAAO,EAAE,aAAa,EACtB,EAAE,EAAE,MAAM,GAAG,IAAI,GAChB,MAAM,GAAG,SAAS,CAEpB;AAkbD,2FAA2F;AAC3F,wBAAgB,OAAO,CAAC,CAAC,SAAS,WAAW,EAC3C,OAAO,EAAE,aAAa,EACtB,KAAK,EAAE,SAAS,EAChB,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,GACtB,OAAO,CAIT"}
@@ -156,6 +156,18 @@ var handlers = {
156
156
  parts.push(`terms ${terms}`);
157
157
  }
158
158
  }
159
+ if (input.pricesIncludeTax !== void 0) {
160
+ if (input.pricesIncludeTax !== before.pricesIncludeTax) {
161
+ next.pricesIncludeTax = input.pricesIncludeTax;
162
+ parts.push(input.pricesIncludeTax ? "prices include tax" : "prices exclude tax");
163
+ }
164
+ }
165
+ if (input.taxRounding !== void 0) {
166
+ if (input.taxRounding !== before.taxRounding) {
167
+ next.taxRounding = input.taxRounding;
168
+ parts.push(`${input.taxRounding} tax rounding`);
169
+ }
170
+ }
159
171
  if (!parts.length) return done(state);
160
172
  const text = parts.join(", ");
161
173
  return done(withDoc(state, writeSettings(catalog, state.doc, next)), `${text[0].toUpperCase()}${text.slice(1)}.`);
@@ -1 +1 @@
1
- {"version":3,"file":"commands.js","names":[],"sources":["../../../src/cookbook/engine/commands.ts"],"sourcesContent":["import type { Cookbook, CookbookPolicyRow } from '@happyvertical/smrt-types';\nimport { validateCookbook } from '../validate.js';\nimport {\n type AppSettings,\n canonical,\n clone,\n coveredModels,\n describeTheme,\n diagnose,\n isEmptyCookbook,\n mergeChanges,\n prune,\n readSettings,\n withFeaturesChanged,\n withRecipesAdded,\n withRecipesRemoved,\n withRequirements,\n withThemePatch,\n writeSettings,\n} from './document.js';\nimport {\n buildNav,\n findModel,\n humanize,\n modelLabel,\n withHidden,\n withItemRenamed,\n withSectionRenamed,\n} from './nav.js';\nimport type {\n CommandError,\n CommandErrorCode,\n CommandInputs,\n CommandName,\n EngineCatalog,\n ExportData,\n RecipeChanges,\n ValidateData,\n} from './types.js';\n\n/** What the engine holds besides its counters: the document and where it came from. */\nexport interface PlanState {\n doc: Cookbook;\n /** The library cookbook the plan was last set up from. */\n applied: string | null;\n}\n\nexport type Outcome =\n | {\n ok: true;\n state: PlanState;\n summary: string;\n changes?: RecipeChanges;\n data?: unknown;\n warnings?: string[];\n }\n | { ok: false; error: CommandError };\n\nexport const fail = (\n code: CommandErrorCode,\n message: string,\n extra: { path?: string; details?: Record<string, unknown> } = {},\n): Outcome => ({ ok: false, error: { code, message, ...extra } });\n\nconst done = (\n state: PlanState,\n summary = '',\n extra: Partial<Extract<Outcome, { ok: true }>> = {},\n): Outcome => ({ ok: true, state, summary, ...extra });\n\nconst REPLACE_NEEDED =\n 'This replaces the recipes, options, menu and look. Send replace: true to confirm.';\n\nconst list = (values: readonly string[]) => values.join(', ');\n\n/** The file name an export gets: a slug of the app name. */\nexport function exportFileName(name?: string): string {\n const slug = (name ?? '')\n .normalize('NFD')\n .replace(/\\p{M}/gu, '')\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '');\n return `${slug || 'my-app'}.cookbook.json`;\n}\n\nexport const serializeCookbook = (doc: Cookbook): string =>\n `${JSON.stringify(doc, null, 2)}\\n`;\n\n/**\n * A document from outside (a library entry, an import, a restored state) as\n * the engine holds it: requirements included, options pruned to what is\n * covered. Recipe and feature ids the catalog lacks stay, reported as\n * `unavailable`, so a round trip loses nothing.\n */\nexport function adopt(catalog: EngineCatalog, doc: Cookbook): Cookbook {\n const byId = new Map(catalog.recipes.map((r) => [r.id, r]));\n const known = doc.recipes.filter((id) => byId.has(id));\n const unknown = doc.recipes.filter((id) => !byId.has(id));\n return canonical(\n prune(catalog, {\n ...clone(doc),\n recipes: [...withRequirements(known, byId), ...unknown],\n }),\n );\n}\n\nexport function libraryName(\n catalog: EngineCatalog,\n id: string | null,\n): string | undefined {\n return id ? catalog.cookbooks?.find((c) => c.id === id)?.name : undefined;\n}\n\nconst describeChange = (catalog: EngineCatalog, changes: RecipeChanges) => {\n const label = (id: string) =>\n catalog.recipes.find((r) => r.id === id)?.label ?? id;\n return [\n changes.added.length ? `Added ${list(changes.added.map(label))}.` : '',\n changes.removed.length\n ? `Removed ${list(changes.removed.map(label))}.`\n : '',\n changes.kept.length\n ? `Kept ${list(changes.kept.map(label))} (needed).`\n : '',\n ]\n .filter(Boolean)\n .join(' ');\n};\n\nconst describeFeatures = (catalog: EngineCatalog, changes: RecipeChanges) =>\n [\n changes.added.length\n ? `Added ${list(changes.added.map((id) => modelLabel(catalog, id)))}.`\n : '',\n changes.removed.length\n ? `Removed ${list(changes.removed.map((id) => modelLabel(catalog, id)))}.`\n : '',\n ]\n .filter(Boolean)\n .join(' ');\n\nconst percent = (fraction: number) => `${Number((fraction * 100).toFixed(4))}%`;\n\ntype Handler<N extends CommandName> = (\n catalog: EngineCatalog,\n state: PlanState,\n input: CommandInputs[N],\n) => Outcome;\n\nconst withDoc = (state: PlanState, doc: Cookbook): PlanState => ({\n ...state,\n doc: canonical(doc),\n});\n\nfunction navOf(catalog: EngineCatalog, doc: Cookbook) {\n const sections = buildNav(catalog, doc);\n return {\n sections,\n section: (id: string) => sections.find((s) => s.id === id),\n item: (id: string) =>\n sections.flatMap((s) => s.items).find((i) => i.id === id),\n };\n}\n\nconst setLayout = (doc: Cookbook, layout: Cookbook['layout']): Cookbook => {\n const next = { ...doc };\n if (layout) next.layout = layout;\n else delete next.layout;\n return next;\n};\n\nconst handlers: { [N in CommandName]?: Handler<N> } = {\n add_recipes(catalog, state, { ids }) {\n const missing = ids.filter(\n (id) => !catalog.recipes.some((r) => r.id === id),\n );\n if (missing.length) {\n return fail('not_found', `No such recipe: ${list(missing)}.`, {\n path: 'input.ids',\n });\n }\n const { doc, changes } = withRecipesAdded(catalog, state.doc, ids);\n return done(withDoc(state, doc), describeChange(catalog, changes), {\n changes,\n });\n },\n remove_recipes(catalog, state, { ids }) {\n const { doc, changes } = withRecipesRemoved(catalog, state.doc, ids);\n return done(withDoc(state, doc), describeChange(catalog, changes), {\n changes,\n });\n },\n add_features(catalog, state, { ids }) {\n const missing = ids.filter((id) => !findModel(catalog, id)?.exposed);\n if (missing.length) {\n return fail('not_found', `No such model to add: ${list(missing)}.`, {\n path: 'input.ids',\n });\n }\n const { doc, changes } = withFeaturesChanged(catalog, state.doc, ids, true);\n return done(withDoc(state, doc), describeFeatures(catalog, changes), {\n changes,\n });\n },\n remove_features(catalog, state, { ids }) {\n const { doc, changes } = withFeaturesChanged(\n catalog,\n state.doc,\n ids,\n false,\n );\n return done(withDoc(state, doc), describeFeatures(catalog, changes), {\n changes,\n });\n },\n add_cookbook(catalog, state, { id }) {\n const book = catalog.cookbooks?.find((c) => c.id === id);\n if (!book)\n return fail('not_found', `No cookbook \"${id}\".`, { path: 'input.id' });\n const recipes = withRecipesAdded(catalog, state.doc, book.document.recipes);\n const features = withFeaturesChanged(\n catalog,\n recipes.doc,\n book.document.features.filter((f) => findModel(catalog, f)?.exposed),\n true,\n );\n const changes = mergeChanges(recipes.changes, features.changes);\n return done(\n withDoc(state, features.doc),\n changes.added.length ? `Added the ${book.name} cookbook.` : '',\n { changes },\n );\n },\n remove_cookbook(catalog, state, { id }) {\n const book = catalog.cookbooks?.find((c) => c.id === id);\n if (!book)\n return fail('not_found', `No cookbook \"${id}\".`, { path: 'input.id' });\n const recipes = withRecipesRemoved(\n catalog,\n state.doc,\n book.document.recipes,\n );\n const features = withFeaturesChanged(\n catalog,\n recipes.doc,\n book.document.features,\n false,\n );\n const changes = mergeChanges(recipes.changes, features.changes);\n return done(\n withDoc(state, features.doc),\n [\n describeChange(catalog, recipes.changes),\n describeFeatures(catalog, features.changes),\n ]\n .filter(Boolean)\n .join(' '),\n { changes },\n );\n },\n apply_cookbook(catalog, state, { id, replace }) {\n const book = catalog.cookbooks?.find((c) => c.id === id);\n if (!book)\n return fail('not_found', `No cookbook \"${id}\".`, { path: 'input.id' });\n if (!replace && !isEmptyCookbook(state.doc)) {\n return fail('confirmation_required', REPLACE_NEEDED);\n }\n return done(\n { doc: adopt(catalog, book.document), applied: id },\n `${book.name} set up.`,\n );\n },\n import_cookbook(catalog, state, { document, replace }) {\n const checked = validateCookbook(document);\n if (!checked.ok) {\n return fail('invalid_input', checked.errors[0] ?? 'Not a cookbook.', {\n path: 'input.document',\n details: { errors: checked.errors },\n });\n }\n if (!replace && !isEmptyCookbook(state.doc)) {\n return fail('confirmation_required', REPLACE_NEEDED);\n }\n const n = checked.cookbook.recipes.length;\n return done(\n { doc: adopt(catalog, checked.cookbook), applied: null },\n `Imported ${n} ${n === 1 ? 'recipe' : 'recipes'}.`,\n checked.warnings.length ? { warnings: checked.warnings } : {},\n );\n },\n set_settings(catalog, state, input) {\n const before = readSettings(catalog, state.doc);\n const next: AppSettings = { ...before };\n const parts: string[] = [];\n if (input.currency !== undefined) {\n const code = input.currency.trim().toUpperCase();\n if (catalog.currencies && !catalog.currencies.includes(code)) {\n return fail('invalid_input', `${code} is not a known currency.`, {\n path: 'input.currency',\n });\n }\n if (!/^[A-Z]{3}$/.test(code)) {\n return fail('invalid_input', 'currency must be a three-letter code.', {\n path: 'input.currency',\n });\n }\n if (code !== before.currency) {\n next.currency = code;\n parts.push(`currency ${code}`);\n }\n }\n if (input.taxRate !== undefined) {\n const fraction = Number((input.taxRate / 100).toFixed(6));\n if (fraction !== before.taxRate) {\n next.taxRate = fraction;\n parts.push(`tax ${percent(fraction)}`);\n }\n }\n if (input.paymentTerms !== undefined) {\n const terms = [...input.paymentTerms]\n .map((ch) =>\n ch.charCodeAt(0) < 32 || ch.charCodeAt(0) === 127 ? ' ' : ch,\n )\n .join('')\n .trim();\n if (!terms) {\n return fail('invalid_input', 'paymentTerms must not be empty.', {\n path: 'input.paymentTerms',\n });\n }\n if (terms !== before.paymentTerms) {\n next.paymentTerms = terms;\n parts.push(`terms ${terms}`);\n }\n }\n if (!parts.length) return done(state);\n const text = parts.join(', ');\n return done(\n withDoc(state, writeSettings(catalog, state.doc, next)),\n `${text[0].toUpperCase()}${text.slice(1)}.`,\n );\n },\n set_policy(catalog, state, input) {\n const model = findModel(catalog, input.model);\n if (!model)\n return fail('not_found', `No such model: ${input.model}.`, {\n path: 'input.model',\n });\n if (model.fields) {\n const field = model.fields.find((f) => f.name === input.field);\n if (!field || field.system) {\n return fail('not_found', `${model.name} has no field ${input.field}.`, {\n path: 'input.field',\n });\n }\n }\n if (!coveredModels(catalog, state.doc).has(model.id)) {\n return fail(\n 'not_found',\n `${humanize(model.name)} is not in the app yet; add its recipe or feature first.`,\n { path: 'input.model' },\n );\n }\n const locked = state.doc.recipes.some(\n (id) =>\n catalog.recipes.find((r) => r.id === id)?.options?.[model.id]?.fields?.[\n input.field\n ]?.locked,\n );\n if (locked)\n return fail('failed', `${input.field} is locked by its recipe.`, {\n path: 'input.field',\n });\n const rows = state.doc.policies.map((row) => ({ ...row }));\n const existing = rows.find(\n (r) => r.objectRef === model.id && r.fieldName === input.field,\n );\n const row: CookbookPolicyRow = existing ?? {\n objectRef: model.id,\n fieldName: input.field,\n scopeType: 'app',\n };\n const before = JSON.stringify(row);\n for (const key of ['visibility', 'label', 'help'] as const) {\n const value = input[key];\n if (value === undefined) continue;\n if (value === null) delete row[key];\n else (row as unknown as Record<string, unknown>)[key] = value;\n }\n if (input.defaultValue !== undefined) {\n if (input.defaultValue === null) delete row.defaultValue;\n else {\n const encoded = JSON.stringify(input.defaultValue);\n if (encoded === undefined) {\n return fail('invalid_input', 'defaultValue is not a JSON value.', {\n path: 'input.defaultValue',\n });\n }\n row.defaultValue = encoded;\n }\n }\n // A row with only its identity says nothing: it is removed, not stored.\n const empty = Object.keys(row).length <= 3;\n if (JSON.stringify(row) === before || (empty && !existing))\n return done(state);\n const rest = rows.filter((r) => r !== existing);\n return done(\n withDoc(state, { ...state.doc, policies: empty ? rest : [...rest, row] }),\n `Updated ${humanize(model.name)} ${input.field}.`,\n );\n },\n set_theme(_catalog, state, input) {\n const doc = withThemePatch(state.doc, input);\n if (\n JSON.stringify(canonical(doc).theme ?? null) ===\n JSON.stringify(state.doc.theme ?? null)\n ) {\n return done(state);\n }\n return done(\n withDoc(state, doc),\n `Theme: ${describeTheme(canonical(doc).theme)}.`,\n );\n },\n reset_theme(_catalog, state) {\n if (!state.doc.theme) return done(state);\n const doc = { ...state.doc };\n delete doc.theme;\n return done(withDoc(state, doc), 'Theme: default.');\n },\n set_name(_catalog, state, input) {\n const doc = { ...state.doc };\n for (const key of ['name', 'description'] as const) {\n const value = input[key];\n if (value === undefined) continue;\n const clean = value?.trim();\n if (clean) doc[key] = clean;\n else delete doc[key];\n }\n if (JSON.stringify(canonical(doc)) === JSON.stringify(state.doc))\n return done(state);\n return done(\n withDoc(state, doc),\n input.name\n ? `Named the app ${input.name.trim()}.`\n : 'Updated the app details.',\n );\n },\n rename_section(catalog, state, { id, label }) {\n const section = navOf(catalog, state.doc).section(id);\n if (!section)\n return fail('not_found', `No menu section \"${id}\".`, {\n path: 'input.id',\n });\n const layout = withSectionRenamed(state.doc.layout, section, label);\n return JSON.stringify(layout ?? null) ===\n JSON.stringify(state.doc.layout ?? null)\n ? done(state)\n : done(\n withDoc(state, setLayout(state.doc, layout)),\n `Renamed the section to ${label.trim()}.`,\n );\n },\n rename_item(catalog, state, { id, label }) {\n const item = navOf(catalog, state.doc).item(id);\n if (!item)\n return fail('not_found', `No menu entry \"${id}\".`, { path: 'input.id' });\n const layout = withItemRenamed(state.doc.layout, item, label);\n return JSON.stringify(layout ?? null) ===\n JSON.stringify(state.doc.layout ?? null)\n ? done(state)\n : done(\n withDoc(state, setLayout(state.doc, layout)),\n label\n ? `Renamed the entry to ${label.trim()}.`\n : 'Entry name restored.',\n );\n },\n hide(catalog, state, { id }) {\n const nav = navOf(catalog, state.doc);\n const target = nav.section(id) ?? nav.item(id);\n if (!target)\n return fail('not_found', `No menu section or entry \"${id}\".`, {\n path: 'input.id',\n });\n if (state.doc.layout?.hidden?.includes(id)) return done(state);\n return done(\n withDoc(\n state,\n setLayout(state.doc, withHidden(state.doc.layout, id, true)),\n ),\n 'Hidden.',\n );\n },\n show(catalog, state, { id }) {\n const nav = navOf(catalog, state.doc);\n if (!nav.section(id) && !nav.item(id)) {\n return fail('not_found', `No menu section or entry \"${id}\".`, {\n path: 'input.id',\n });\n }\n if (!state.doc.layout?.hidden?.includes(id)) return done(state);\n return done(\n withDoc(\n state,\n setLayout(state.doc, withHidden(state.doc.layout, id, false)),\n ),\n 'Shown.',\n );\n },\n validate(catalog, state) {\n const diagnostics = diagnose(catalog, state.doc);\n const data: ValidateData = {\n ok: !diagnostics.some((d) => d.severity === 'error'),\n diagnostics,\n };\n return done(state, '', { data });\n },\n export_cookbook(catalog, state, { name }) {\n const fileName = exportFileName(\n name ?? state.doc.name ?? libraryName(catalog, state.applied),\n );\n const data: ExportData = {\n fileName,\n text: serializeCookbook(state.doc),\n cookbook: clone(state.doc),\n };\n return done(state, '', { data });\n },\n};\n\n/** Run one validated command over a state. Pure: returns the next state, never mutates. */\nexport function execute<N extends CommandName>(\n catalog: EngineCatalog,\n state: PlanState,\n name: N,\n input: CommandInputs[N],\n): Outcome {\n const handler = handlers[name] as Handler<N> | undefined;\n if (!handler) return fail('unknown_command', `No command \"${name}\".`);\n return handler(catalog, state, input);\n}\n"],"mappings":";;;;AA0DA,IAAa,QACX,MACA,SACA,QAA8D,CAAC,OAClD;CAAE,IAAI;CAAO,OAAO;EAAE;EAAM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AG,OAAO,KAAK,KAAK;EAC9D,OAAO,KACL,QACE,OACA,UAAU,MAAM,KAAK,WAAW,MAAM,IAAI,QAAQ,IAAI,KAAK,CAAC,CAC9D,GACA,QACF;CACF;CACA,SAAS,SAAS,OAAO;EACvB,MAAM,cAAc,SAAS,SAAS,MAAM,GAAG;EAK/C,OAAO,KAAK,OAAO,IAAI,EAAE;GAHvB,IAAI,CAAC,YAAY,MAAM,MAAM,EAAE,aAAa,OAAO;GACnD;EAEuB,EAAK,CAAC;CACjC;CACA,gBAAgB,SAAS,OAAO,EAAE,QAAQ;EASxC,OAAO,KAAK,OAAO,IAAI,EAAE;GAJvB,UAJe,eACf,QAAQ,MAAM,IAAI,QAAQ,YAAY,SAAS,MAAM,OAAO,CAG5D;GACA,MAAM,kBAAkB,MAAM,GAAG;GACjC,UAAU,MAAM,MAAM,GAAG;EAEF,EAAK,CAAC;CACjC;AACF;;AAGA,SAAgB,QACd,SACA,OACA,MACA,OACS;CACT,MAAM,UAAU,SAAS;CACzB,IAAI,CAAC,SAAS,OAAO,KAAK,mBAAmB,eAAe,KAAK,GAAG;CACpE,OAAO,QAAQ,SAAS,OAAO,KAAK;AACtC"}
1
+ {"version":3,"file":"commands.js","names":[],"sources":["../../../src/cookbook/engine/commands.ts"],"sourcesContent":["import type { Cookbook, CookbookPolicyRow } from '@happyvertical/smrt-types';\nimport { validateCookbook } from '../validate.js';\nimport {\n type AppSettings,\n canonical,\n clone,\n coveredModels,\n describeTheme,\n diagnose,\n isEmptyCookbook,\n mergeChanges,\n prune,\n readSettings,\n withFeaturesChanged,\n withRecipesAdded,\n withRecipesRemoved,\n withRequirements,\n withThemePatch,\n writeSettings,\n} from './document.js';\nimport {\n buildNav,\n findModel,\n humanize,\n modelLabel,\n withHidden,\n withItemRenamed,\n withSectionRenamed,\n} from './nav.js';\nimport type {\n CommandError,\n CommandErrorCode,\n CommandInputs,\n CommandName,\n EngineCatalog,\n ExportData,\n RecipeChanges,\n ValidateData,\n} from './types.js';\n\n/** What the engine holds besides its counters: the document and where it came from. */\nexport interface PlanState {\n doc: Cookbook;\n /** The library cookbook the plan was last set up from. */\n applied: string | null;\n}\n\nexport type Outcome =\n | {\n ok: true;\n state: PlanState;\n summary: string;\n changes?: RecipeChanges;\n data?: unknown;\n warnings?: string[];\n }\n | { ok: false; error: CommandError };\n\nexport const fail = (\n code: CommandErrorCode,\n message: string,\n extra: { path?: string; details?: Record<string, unknown> } = {},\n): Outcome => ({ ok: false, error: { code, message, ...extra } });\n\nconst done = (\n state: PlanState,\n summary = '',\n extra: Partial<Extract<Outcome, { ok: true }>> = {},\n): Outcome => ({ ok: true, state, summary, ...extra });\n\nconst REPLACE_NEEDED =\n 'This replaces the recipes, options, menu and look. Send replace: true to confirm.';\n\nconst list = (values: readonly string[]) => values.join(', ');\n\n/** The file name an export gets: a slug of the app name. */\nexport function exportFileName(name?: string): string {\n const slug = (name ?? '')\n .normalize('NFD')\n .replace(/\\p{M}/gu, '')\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '');\n return `${slug || 'my-app'}.cookbook.json`;\n}\n\nexport const serializeCookbook = (doc: Cookbook): string =>\n `${JSON.stringify(doc, null, 2)}\\n`;\n\n/**\n * A document from outside (a library entry, an import, a restored state) as\n * the engine holds it: requirements included, options pruned to what is\n * covered. Recipe and feature ids the catalog lacks stay, reported as\n * `unavailable`, so a round trip loses nothing.\n */\nexport function adopt(catalog: EngineCatalog, doc: Cookbook): Cookbook {\n const byId = new Map(catalog.recipes.map((r) => [r.id, r]));\n const known = doc.recipes.filter((id) => byId.has(id));\n const unknown = doc.recipes.filter((id) => !byId.has(id));\n return canonical(\n prune(catalog, {\n ...clone(doc),\n recipes: [...withRequirements(known, byId), ...unknown],\n }),\n );\n}\n\nexport function libraryName(\n catalog: EngineCatalog,\n id: string | null,\n): string | undefined {\n return id ? catalog.cookbooks?.find((c) => c.id === id)?.name : undefined;\n}\n\nconst describeChange = (catalog: EngineCatalog, changes: RecipeChanges) => {\n const label = (id: string) =>\n catalog.recipes.find((r) => r.id === id)?.label ?? id;\n return [\n changes.added.length ? `Added ${list(changes.added.map(label))}.` : '',\n changes.removed.length\n ? `Removed ${list(changes.removed.map(label))}.`\n : '',\n changes.kept.length\n ? `Kept ${list(changes.kept.map(label))} (needed).`\n : '',\n ]\n .filter(Boolean)\n .join(' ');\n};\n\nconst describeFeatures = (catalog: EngineCatalog, changes: RecipeChanges) =>\n [\n changes.added.length\n ? `Added ${list(changes.added.map((id) => modelLabel(catalog, id)))}.`\n : '',\n changes.removed.length\n ? `Removed ${list(changes.removed.map((id) => modelLabel(catalog, id)))}.`\n : '',\n ]\n .filter(Boolean)\n .join(' ');\n\nconst percent = (fraction: number) => `${Number((fraction * 100).toFixed(4))}%`;\n\ntype Handler<N extends CommandName> = (\n catalog: EngineCatalog,\n state: PlanState,\n input: CommandInputs[N],\n) => Outcome;\n\nconst withDoc = (state: PlanState, doc: Cookbook): PlanState => ({\n ...state,\n doc: canonical(doc),\n});\n\nfunction navOf(catalog: EngineCatalog, doc: Cookbook) {\n const sections = buildNav(catalog, doc);\n return {\n sections,\n section: (id: string) => sections.find((s) => s.id === id),\n item: (id: string) =>\n sections.flatMap((s) => s.items).find((i) => i.id === id),\n };\n}\n\nconst setLayout = (doc: Cookbook, layout: Cookbook['layout']): Cookbook => {\n const next = { ...doc };\n if (layout) next.layout = layout;\n else delete next.layout;\n return next;\n};\n\nconst handlers: { [N in CommandName]?: Handler<N> } = {\n add_recipes(catalog, state, { ids }) {\n const missing = ids.filter(\n (id) => !catalog.recipes.some((r) => r.id === id),\n );\n if (missing.length) {\n return fail('not_found', `No such recipe: ${list(missing)}.`, {\n path: 'input.ids',\n });\n }\n const { doc, changes } = withRecipesAdded(catalog, state.doc, ids);\n return done(withDoc(state, doc), describeChange(catalog, changes), {\n changes,\n });\n },\n remove_recipes(catalog, state, { ids }) {\n const { doc, changes } = withRecipesRemoved(catalog, state.doc, ids);\n return done(withDoc(state, doc), describeChange(catalog, changes), {\n changes,\n });\n },\n add_features(catalog, state, { ids }) {\n const missing = ids.filter((id) => !findModel(catalog, id)?.exposed);\n if (missing.length) {\n return fail('not_found', `No such model to add: ${list(missing)}.`, {\n path: 'input.ids',\n });\n }\n const { doc, changes } = withFeaturesChanged(catalog, state.doc, ids, true);\n return done(withDoc(state, doc), describeFeatures(catalog, changes), {\n changes,\n });\n },\n remove_features(catalog, state, { ids }) {\n const { doc, changes } = withFeaturesChanged(\n catalog,\n state.doc,\n ids,\n false,\n );\n return done(withDoc(state, doc), describeFeatures(catalog, changes), {\n changes,\n });\n },\n add_cookbook(catalog, state, { id }) {\n const book = catalog.cookbooks?.find((c) => c.id === id);\n if (!book)\n return fail('not_found', `No cookbook \"${id}\".`, { path: 'input.id' });\n const recipes = withRecipesAdded(catalog, state.doc, book.document.recipes);\n const features = withFeaturesChanged(\n catalog,\n recipes.doc,\n book.document.features.filter((f) => findModel(catalog, f)?.exposed),\n true,\n );\n const changes = mergeChanges(recipes.changes, features.changes);\n return done(\n withDoc(state, features.doc),\n changes.added.length ? `Added the ${book.name} cookbook.` : '',\n { changes },\n );\n },\n remove_cookbook(catalog, state, { id }) {\n const book = catalog.cookbooks?.find((c) => c.id === id);\n if (!book)\n return fail('not_found', `No cookbook \"${id}\".`, { path: 'input.id' });\n const recipes = withRecipesRemoved(\n catalog,\n state.doc,\n book.document.recipes,\n );\n const features = withFeaturesChanged(\n catalog,\n recipes.doc,\n book.document.features,\n false,\n );\n const changes = mergeChanges(recipes.changes, features.changes);\n return done(\n withDoc(state, features.doc),\n [\n describeChange(catalog, recipes.changes),\n describeFeatures(catalog, features.changes),\n ]\n .filter(Boolean)\n .join(' '),\n { changes },\n );\n },\n apply_cookbook(catalog, state, { id, replace }) {\n const book = catalog.cookbooks?.find((c) => c.id === id);\n if (!book)\n return fail('not_found', `No cookbook \"${id}\".`, { path: 'input.id' });\n if (!replace && !isEmptyCookbook(state.doc)) {\n return fail('confirmation_required', REPLACE_NEEDED);\n }\n return done(\n { doc: adopt(catalog, book.document), applied: id },\n `${book.name} set up.`,\n );\n },\n import_cookbook(catalog, state, { document, replace }) {\n const checked = validateCookbook(document);\n if (!checked.ok) {\n return fail('invalid_input', checked.errors[0] ?? 'Not a cookbook.', {\n path: 'input.document',\n details: { errors: checked.errors },\n });\n }\n if (!replace && !isEmptyCookbook(state.doc)) {\n return fail('confirmation_required', REPLACE_NEEDED);\n }\n const n = checked.cookbook.recipes.length;\n return done(\n { doc: adopt(catalog, checked.cookbook), applied: null },\n `Imported ${n} ${n === 1 ? 'recipe' : 'recipes'}.`,\n checked.warnings.length ? { warnings: checked.warnings } : {},\n );\n },\n set_settings(catalog, state, input) {\n const before = readSettings(catalog, state.doc);\n const next: AppSettings = { ...before };\n const parts: string[] = [];\n if (input.currency !== undefined) {\n const code = input.currency.trim().toUpperCase();\n if (catalog.currencies && !catalog.currencies.includes(code)) {\n return fail('invalid_input', `${code} is not a known currency.`, {\n path: 'input.currency',\n });\n }\n if (!/^[A-Z]{3}$/.test(code)) {\n return fail('invalid_input', 'currency must be a three-letter code.', {\n path: 'input.currency',\n });\n }\n if (code !== before.currency) {\n next.currency = code;\n parts.push(`currency ${code}`);\n }\n }\n if (input.taxRate !== undefined) {\n const fraction = Number((input.taxRate / 100).toFixed(6));\n if (fraction !== before.taxRate) {\n next.taxRate = fraction;\n parts.push(`tax ${percent(fraction)}`);\n }\n }\n if (input.paymentTerms !== undefined) {\n const terms = [...input.paymentTerms]\n .map((ch) =>\n ch.charCodeAt(0) < 32 || ch.charCodeAt(0) === 127 ? ' ' : ch,\n )\n .join('')\n .trim();\n if (!terms) {\n return fail('invalid_input', 'paymentTerms must not be empty.', {\n path: 'input.paymentTerms',\n });\n }\n if (terms !== before.paymentTerms) {\n next.paymentTerms = terms;\n parts.push(`terms ${terms}`);\n }\n }\n if (input.pricesIncludeTax !== undefined) {\n if (input.pricesIncludeTax !== before.pricesIncludeTax) {\n next.pricesIncludeTax = input.pricesIncludeTax;\n parts.push(\n input.pricesIncludeTax ? 'prices include tax' : 'prices exclude tax',\n );\n }\n }\n if (input.taxRounding !== undefined) {\n if (input.taxRounding !== before.taxRounding) {\n next.taxRounding = input.taxRounding;\n parts.push(`${input.taxRounding} tax rounding`);\n }\n }\n if (!parts.length) return done(state);\n const text = parts.join(', ');\n return done(\n withDoc(state, writeSettings(catalog, state.doc, next)),\n `${text[0].toUpperCase()}${text.slice(1)}.`,\n );\n },\n set_policy(catalog, state, input) {\n const model = findModel(catalog, input.model);\n if (!model)\n return fail('not_found', `No such model: ${input.model}.`, {\n path: 'input.model',\n });\n if (model.fields) {\n const field = model.fields.find((f) => f.name === input.field);\n if (!field || field.system) {\n return fail('not_found', `${model.name} has no field ${input.field}.`, {\n path: 'input.field',\n });\n }\n }\n if (!coveredModels(catalog, state.doc).has(model.id)) {\n return fail(\n 'not_found',\n `${humanize(model.name)} is not in the app yet; add its recipe or feature first.`,\n { path: 'input.model' },\n );\n }\n const locked = state.doc.recipes.some(\n (id) =>\n catalog.recipes.find((r) => r.id === id)?.options?.[model.id]?.fields?.[\n input.field\n ]?.locked,\n );\n if (locked)\n return fail('failed', `${input.field} is locked by its recipe.`, {\n path: 'input.field',\n });\n const rows = state.doc.policies.map((row) => ({ ...row }));\n const existing = rows.find(\n (r) => r.objectRef === model.id && r.fieldName === input.field,\n );\n const row: CookbookPolicyRow = existing ?? {\n objectRef: model.id,\n fieldName: input.field,\n scopeType: 'app',\n };\n const before = JSON.stringify(row);\n for (const key of ['visibility', 'label', 'help'] as const) {\n const value = input[key];\n if (value === undefined) continue;\n if (value === null) delete row[key];\n else (row as unknown as Record<string, unknown>)[key] = value;\n }\n if (input.defaultValue !== undefined) {\n if (input.defaultValue === null) delete row.defaultValue;\n else {\n const encoded = JSON.stringify(input.defaultValue);\n if (encoded === undefined) {\n return fail('invalid_input', 'defaultValue is not a JSON value.', {\n path: 'input.defaultValue',\n });\n }\n row.defaultValue = encoded;\n }\n }\n // A row with only its identity says nothing: it is removed, not stored.\n const empty = Object.keys(row).length <= 3;\n if (JSON.stringify(row) === before || (empty && !existing))\n return done(state);\n const rest = rows.filter((r) => r !== existing);\n return done(\n withDoc(state, { ...state.doc, policies: empty ? rest : [...rest, row] }),\n `Updated ${humanize(model.name)} ${input.field}.`,\n );\n },\n set_theme(_catalog, state, input) {\n const doc = withThemePatch(state.doc, input);\n if (\n JSON.stringify(canonical(doc).theme ?? null) ===\n JSON.stringify(state.doc.theme ?? null)\n ) {\n return done(state);\n }\n return done(\n withDoc(state, doc),\n `Theme: ${describeTheme(canonical(doc).theme)}.`,\n );\n },\n reset_theme(_catalog, state) {\n if (!state.doc.theme) return done(state);\n const doc = { ...state.doc };\n delete doc.theme;\n return done(withDoc(state, doc), 'Theme: default.');\n },\n set_name(_catalog, state, input) {\n const doc = { ...state.doc };\n for (const key of ['name', 'description'] as const) {\n const value = input[key];\n if (value === undefined) continue;\n const clean = value?.trim();\n if (clean) doc[key] = clean;\n else delete doc[key];\n }\n if (JSON.stringify(canonical(doc)) === JSON.stringify(state.doc))\n return done(state);\n return done(\n withDoc(state, doc),\n input.name\n ? `Named the app ${input.name.trim()}.`\n : 'Updated the app details.',\n );\n },\n rename_section(catalog, state, { id, label }) {\n const section = navOf(catalog, state.doc).section(id);\n if (!section)\n return fail('not_found', `No menu section \"${id}\".`, {\n path: 'input.id',\n });\n const layout = withSectionRenamed(state.doc.layout, section, label);\n return JSON.stringify(layout ?? null) ===\n JSON.stringify(state.doc.layout ?? null)\n ? done(state)\n : done(\n withDoc(state, setLayout(state.doc, layout)),\n `Renamed the section to ${label.trim()}.`,\n );\n },\n rename_item(catalog, state, { id, label }) {\n const item = navOf(catalog, state.doc).item(id);\n if (!item)\n return fail('not_found', `No menu entry \"${id}\".`, { path: 'input.id' });\n const layout = withItemRenamed(state.doc.layout, item, label);\n return JSON.stringify(layout ?? null) ===\n JSON.stringify(state.doc.layout ?? null)\n ? done(state)\n : done(\n withDoc(state, setLayout(state.doc, layout)),\n label\n ? `Renamed the entry to ${label.trim()}.`\n : 'Entry name restored.',\n );\n },\n hide(catalog, state, { id }) {\n const nav = navOf(catalog, state.doc);\n const target = nav.section(id) ?? nav.item(id);\n if (!target)\n return fail('not_found', `No menu section or entry \"${id}\".`, {\n path: 'input.id',\n });\n if (state.doc.layout?.hidden?.includes(id)) return done(state);\n return done(\n withDoc(\n state,\n setLayout(state.doc, withHidden(state.doc.layout, id, true)),\n ),\n 'Hidden.',\n );\n },\n show(catalog, state, { id }) {\n const nav = navOf(catalog, state.doc);\n if (!nav.section(id) && !nav.item(id)) {\n return fail('not_found', `No menu section or entry \"${id}\".`, {\n path: 'input.id',\n });\n }\n if (!state.doc.layout?.hidden?.includes(id)) return done(state);\n return done(\n withDoc(\n state,\n setLayout(state.doc, withHidden(state.doc.layout, id, false)),\n ),\n 'Shown.',\n );\n },\n validate(catalog, state) {\n const diagnostics = diagnose(catalog, state.doc);\n const data: ValidateData = {\n ok: !diagnostics.some((d) => d.severity === 'error'),\n diagnostics,\n };\n return done(state, '', { data });\n },\n export_cookbook(catalog, state, { name }) {\n const fileName = exportFileName(\n name ?? state.doc.name ?? libraryName(catalog, state.applied),\n );\n const data: ExportData = {\n fileName,\n text: serializeCookbook(state.doc),\n cookbook: clone(state.doc),\n };\n return done(state, '', { data });\n },\n};\n\n/** Run one validated command over a state. Pure: returns the next state, never mutates. */\nexport function execute<N extends CommandName>(\n catalog: EngineCatalog,\n state: PlanState,\n name: N,\n input: CommandInputs[N],\n): Outcome {\n const handler = handlers[name] as Handler<N> | undefined;\n if (!handler) return fail('unknown_command', `No command \"${name}\".`);\n return handler(catalog, state, input);\n}\n"],"mappings":";;;;AA0DA,IAAa,QACX,MACA,SACA,QAA8D,CAAC,OAClD;CAAE,IAAI;CAAO,OAAO;EAAE;EAAM;EAAS,GAAG;CAAM;AAAE;AAE/D,IAAM,QACJ,OACA,UAAU,IACV,QAAiD,CAAC,OACrC;CAAE,IAAI;CAAM;CAAO;CAAS,GAAG;AAAM;AAEpD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C,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAInC,gEAAgE;AAChE,eAAO,MAAM,wBAAwB,EAAE,cAmBtC,CAAC"}
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../../src/cookbook/engine/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,qFAAqF;AACrF,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAMlD,CAAC;AACF,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAC7C,eAAO,MAAM,gBAAgB,WAAW,CAAC;AACzC,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAInC,gEAAgE;AAChE,eAAO,MAAM,wBAAwB,EAAE,cA2BtC,CAAC"}
@@ -29,6 +29,14 @@ var COMMERCE_SETTING_TARGETS = {
29
29
  model: `${C}${model}`,
30
30
  field: "taxRate"
31
31
  })),
32
+ pricesIncludeTax: ["Invoice", "Contract"].map((model) => ({
33
+ model: `${C}${model}`,
34
+ field: "lineAmountType"
35
+ })),
36
+ taxRounding: ["Invoice", "Contract"].map((model) => ({
37
+ model: `${C}${model}`,
38
+ field: "taxRoundingScope"
39
+ })),
32
40
  paymentTerms: [...[
33
41
  "Order",
34
42
  "WholesaleOrder",
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.js","names":[],"sources":["../../../src/cookbook/engine/defaults.ts"],"sourcesContent":["import type { SettingTargets } from './types.js';\n\n/** smrt-ui's built-in presets (kept as data so the engine imports no UI package). */\nexport const DEFAULT_THEME_PRESETS: readonly string[] = [\n 'material',\n 'glass',\n 'studio',\n 'smrt',\n 'happyvertical',\n];\nexport const DEFAULT_PRESET = 'smrt';\nexport const DEFAULT_COLOR_SCHEME = 'system';\nexport const DEFAULT_APP_NAME = 'my-app';\nexport const MAX_TERMS_LENGTH = 40;\n\nconst C = '@happyvertical/smrt-commerce:';\n\n/** The commerce fields the app settings are the defaults of. */\nexport const COMMERCE_SETTING_TARGETS: SettingTargets = {\n currency: [\n 'Order',\n 'PurchaseOrder',\n 'WholesaleOrder',\n 'Estimate',\n 'Invoice',\n 'Agreement',\n ].map((model) => ({ model: `${C}${model}`, field: 'currency' })),\n taxRate: ['InvoiceLineItem', 'ContractLineItem'].map((model) => ({\n model: `${C}${model}`,\n field: 'taxRate',\n })),\n paymentTerms: [\n ...['Order', 'WholesaleOrder', 'Estimate', 'Invoice', 'Agreement'].map(\n (model) => ({ model: `${C}${model}`, field: 'terms' }),\n ),\n { model: `${C}Customer`, field: 'paymentTerms' },\n ],\n};\n"],"mappings":";;AAGA,IAAa,wBAA2C;CACtD;CACA;CACA;CACA;CACA;AACF;AACA,IAAa,iBAAiB;AAC9B,IAAa,uBAAuB;AACpC,IAAa,mBAAmB;AAChC,IAAa,mBAAmB;AAEhC,IAAM,IAAI;;AAGV,IAAa,2BAA2C;CACtD,UAAU;EACR;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,WAAW;EAAE,OAAO,GAAG,IAAI;EAAS,OAAO;CAAW,EAAE;CAC/D,SAAS,CAAC,mBAAmB,kBAAkB,CAAC,CAAC,KAAK,WAAW;EAC/D,OAAO,GAAG,IAAI;EACd,OAAO;CACT,EAAE;CACF,cAAc,CACZ,GAAG;EAAC;EAAS;EAAkB;EAAY;EAAW;CAAW,CAAC,CAAC,KAChE,WAAW;EAAE,OAAO,GAAG,IAAI;EAAS,OAAO;CAAQ,EACtD,GACA;EAAE,OAAO,GAAG,EAAE;EAAW,OAAO;CAAe,CACjD;AACF"}
1
+ {"version":3,"file":"defaults.js","names":[],"sources":["../../../src/cookbook/engine/defaults.ts"],"sourcesContent":["import type { SettingTargets } from './types.js';\n\n/** smrt-ui's built-in presets (kept as data so the engine imports no UI package). */\nexport const DEFAULT_THEME_PRESETS: readonly string[] = [\n 'material',\n 'glass',\n 'studio',\n 'smrt',\n 'happyvertical',\n];\nexport const DEFAULT_PRESET = 'smrt';\nexport const DEFAULT_COLOR_SCHEME = 'system';\nexport const DEFAULT_APP_NAME = 'my-app';\nexport const MAX_TERMS_LENGTH = 40;\n\nconst C = '@happyvertical/smrt-commerce:';\n\n/** The commerce fields the app settings are the defaults of. */\nexport const COMMERCE_SETTING_TARGETS: SettingTargets = {\n currency: [\n 'Order',\n 'PurchaseOrder',\n 'WholesaleOrder',\n 'Estimate',\n 'Invoice',\n 'Agreement',\n ].map((model) => ({ model: `${C}${model}`, field: 'currency' })),\n taxRate: ['InvoiceLineItem', 'ContractLineItem'].map((model) => ({\n model: `${C}${model}`,\n field: 'taxRate',\n })),\n pricesIncludeTax: ['Invoice', 'Contract'].map((model) => ({\n model: `${C}${model}`,\n field: 'lineAmountType',\n })),\n taxRounding: ['Invoice', 'Contract'].map((model) => ({\n model: `${C}${model}`,\n field: 'taxRoundingScope',\n })),\n paymentTerms: [\n ...['Order', 'WholesaleOrder', 'Estimate', 'Invoice', 'Agreement'].map(\n (model) => ({ model: `${C}${model}`, field: 'terms' }),\n ),\n { model: `${C}Customer`, field: 'paymentTerms' },\n ],\n};\n"],"mappings":";;AAGA,IAAa,wBAA2C;CACtD;CACA;CACA;CACA;CACA;AACF;AACA,IAAa,iBAAiB;AAC9B,IAAa,uBAAuB;AACpC,IAAa,mBAAmB;AAChC,IAAa,mBAAmB;AAEhC,IAAM,IAAI;;AAGV,IAAa,2BAA2C;CACtD,UAAU;EACR;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,WAAW;EAAE,OAAO,GAAG,IAAI;EAAS,OAAO;CAAW,EAAE;CAC/D,SAAS,CAAC,mBAAmB,kBAAkB,CAAC,CAAC,KAAK,WAAW;EAC/D,OAAO,GAAG,IAAI;EACd,OAAO;CACT,EAAE;CACF,kBAAkB,CAAC,WAAW,UAAU,CAAC,CAAC,KAAK,WAAW;EACxD,OAAO,GAAG,IAAI;EACd,OAAO;CACT,EAAE;CACF,aAAa,CAAC,WAAW,UAAU,CAAC,CAAC,KAAK,WAAW;EACnD,OAAO,GAAG,IAAI;EACd,OAAO;CACT,EAAE;CACF,cAAc,CACZ,GAAG;EAAC;EAAS;EAAkB;EAAY;EAAW;CAAW,CAAC,CAAC,KAChE,WAAW;EAAE,OAAO,GAAG,IAAI;EAAS,OAAO;CAAQ,EACtD,GACA;EAAE,OAAO,GAAG,EAAE;EAAW,OAAO;CAAe,CACjD;AACF"}
@@ -36,6 +36,10 @@ export interface AppSettings {
36
36
  /** A fraction: 0.0825 is 8.25%. */
37
37
  taxRate: number;
38
38
  paymentTerms: string;
39
+ /** Whether new document prices are tax-inclusive. */
40
+ pricesIncludeTax: boolean;
41
+ /** Whether tax rounds per line or per document component. */
42
+ taxRounding: 'line' | 'document';
39
43
  }
40
44
  export declare const DEFAULT_SETTINGS: Readonly<AppSettings>;
41
45
  /** The app's settings: the first stored row of each, else the defaults. */
@@ -1 +1 @@
1
- {"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../../src/cookbook/engine/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EAER,aAAa,EACd,MAAM,2BAA2B,CAAC;AAanC,OAAO,KAAK,EACV,UAAU,EACV,aAAa,EACb,YAAY,EACZ,aAAa,EACb,cAAc,EACf,MAAM,YAAY,CAAC;AAOpB,eAAO,MAAM,KAAK,GAAI,CAAC,EAAE,OAAO,CAAC,KAAG,CACkB,CAAC;AAEvD,eAAO,MAAM,IAAI,GAAI,GAAG,OAAO,EAAE,GAAG,OAAO,KAAG,OACW,CAAC;AAE1D,eAAO,MAAM,aAAa,QAAO,QAM/B,CAAC;AAEH,4EAA4E;AAC5E,wBAAgB,eAAe,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAUtD;AAID;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,QAAQ,GAAG,QAAQ,CAsDjD;AAOD,wEAAwE;AACxE,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,QAAQ,CAAC,MAAM,C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C,OAAO,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACnC,QAAQ,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;CACtC,GACA,QAAQ,CA4BV;AAID;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,aAAa,EACtB,KAAK,EAAE,QAAQ,GACd,UAAU,EAAE,CA2Id"}
@@ -180,12 +180,16 @@ var mergeChanges = (a, b) => ({
180
180
  var DEFAULT_SETTINGS = {
181
181
  currency: "USD",
182
182
  taxRate: 0,
183
- paymentTerms: ""
183
+ paymentTerms: "",
184
+ pricesIncludeTax: false,
185
+ taxRounding: "line"
184
186
  };
185
187
  var SETTING_KEYS = [
186
188
  "currency",
187
189
  "taxRate",
188
- "paymentTerms"
190
+ "paymentTerms",
191
+ "pricesIncludeTax",
192
+ "taxRounding"
189
193
  ];
190
194
  function rowValue(row) {
191
195
  if (row?.defaultValue === void 0 || row.defaultValue === null) return void 0;
@@ -209,9 +213,13 @@ function readSettings(catalog, doc) {
209
213
  const currency = first("currency", "string");
210
214
  const taxRate = first("taxRate", "number");
211
215
  const paymentTerms = first("paymentTerms", "string");
216
+ const lineAmountType = first("pricesIncludeTax", "string");
217
+ const taxRounding = first("taxRounding", "string");
212
218
  if (typeof currency === "string") out.currency = currency;
213
219
  if (typeof taxRate === "number") out.taxRate = taxRate;
214
220
  if (typeof paymentTerms === "string") out.paymentTerms = paymentTerms;
221
+ if (lineAmountType === "inclusive" || lineAmountType === "exclusive") out.pricesIncludeTax = lineAmountType === "inclusive";
222
+ if (taxRounding === "line" || taxRounding === "document") out.taxRounding = taxRounding;
215
223
  return out;
216
224
  }
217
225
  var isUnset = (v) => v === void 0 || v === null || v === "";
@@ -234,7 +242,7 @@ function writeSettings(catalog, doc, settings) {
234
242
  let policies = doc.policies.map((row) => ({ ...row }));
235
243
  for (const key of SETTING_KEYS) {
236
244
  const raw = settings[key];
237
- const value = key === "paymentTerms" ? String(raw).trim() : key === "currency" ? String(raw).trim().toUpperCase() : raw;
245
+ const value = key === "paymentTerms" ? String(raw).trim() : key === "currency" ? String(raw).trim().toUpperCase() : key === "pricesIncludeTax" ? raw ? "inclusive" : "exclusive" : raw;
238
246
  for (const { model, field } of targets[key]) {
239
247
  const seed = seedDefault(catalog, doc, model, field);
240
248
  const wanted = !isUnset(value) && !(!isUnset(seed) && seed === value) && !(isUnset(seed) && key === "taxRate" && value === 0);