UNPKG

business-as-code

Version:

Primitives for expressing business logic and processes as code

27 lines 1.08 kB
/** * OutcomeContract — definition-of-done + escrow + release condition. * Distinct from OutputContract (technical schema; lives in services-as-software). * * The predicate is evaluated against the runtime state of a Service invocation; * when it passes, escrow releases funds to the seller. */ /** * Resolve the headline {@link Money} amount on an {@link OutcomeContract}, * lazily computing from `tiers[selectedTierId]` for the * {@link OutcomeContractWithTiers} variant. * * Returns `undefined` for the tiers variant when no tier has been selected * yet (e.g. pre-invocation, at declaration / publish time). */ export function resolveOutcomeAmount(contract) { if (contract.tiers !== undefined) { if (contract.selectedTierId === undefined) return undefined; const tier = contract.tiers.find((t) => t.id === contract.selectedTierId); if (!tier) return undefined; return { amount: tier.amount, currency: tier.currency ?? 'USD' }; } return contract.amount; } //# sourceMappingURL=outcome-contract.js.map