Kaizen
Browse modulesPricingpricing/sharedTypes

Type Alias: PricingScopeMapping<TContext = `unknown`>

type PricingScopeMapping<TContext = unknown> = unknown extends TContext ? Record<string, Record<string, string>> : { [K in keyof TContext]?: Record<string, (TContext[K] extends (infer U)[] ? PathsOf<U> : PathsOf<TContext[K]>) & string> };

Defined in: shared/pricing/scope-mapping.ts:33

Scope mapping for the pricing domain, authored as a two-level map of section → scope_type → path where the path is rooted at the section (not at the full context). The flat Record<scope_type, fullPath> the engine ultimately sees is built by buildEngineScopeMapping, which prefixes each section's paths via a section-prefix map.

Generic on TContext so each section's paths are type-checked against the corresponding sub-shape (with array sections unwrapped to the element type). With the unparameterised default (unknown), the value type stays plain Record<string, Record<string, string>> for callers that want to author mappings without binding to a specific context.

Authoring guidance:

  • Inner paths are rooted at the section. For an array section like line_items, paths are rooted at one element — no line_items.*. prefix.
  • If a path resolves to an array leaf you want to scope on, end the path with .* so each element becomes its own scope value; flattenContext filters non-string leaves out, so a path that resolves to an array directly is silently dropped (see the discount_codes.* entry below).
  • The future partitionPricingResult step reads the line_items section directly to re-resolve scopes per individual line item, so keep line_items paths rooted at one item.

Type Parameters

Type ParameterDefault type
TContextunknown

On this page