@hyperscale0/hsx 2.0.3 → 2.0.5

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 (48) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/src/cli.d.ts +1 -1
  3. package/dist/src/cli.d.ts.map +1 -1
  4. package/dist/src/cli.js +6 -2
  5. package/dist/src/cli.js.map +1 -1
  6. package/dist/src/diagnostics.d.ts.map +1 -1
  7. package/dist/src/diagnostics.js +9 -0
  8. package/dist/src/diagnostics.js.map +1 -1
  9. package/dist/src/std-bundle.js +1 -1
  10. package/dist/src/std-bundle.js.map +1 -1
  11. package/dist/src/typecheck.d.ts.map +1 -1
  12. package/dist/src/typecheck.js +126 -5
  13. package/dist/src/typecheck.js.map +1 -1
  14. package/dist/src/version.d.ts +1 -1
  15. package/dist/src/version.js +1 -1
  16. package/docs/llms-full.txt +10 -2
  17. package/docs/llms.txt +2 -2
  18. package/docs/reference/cli.md +2 -2
  19. package/docs/reference/diagnostics.md +9 -1
  20. package/docs/reference/grammar.md +1 -1
  21. package/docs/reference/std/advance.md +1 -1
  22. package/docs/reference/std/cancellable_booking.md +1 -1
  23. package/docs/reference/std/captured_payment.md +1 -1
  24. package/docs/reference/std/conditional_disbursement.md +1 -1
  25. package/docs/reference/std/credit_facility.md +1 -1
  26. package/docs/reference/std/held_payment.md +1 -1
  27. package/docs/reference/std/instant_transfer.md +1 -1
  28. package/docs/reference/std/metered.md +1 -1
  29. package/docs/reference/std/pooled_split.md +1 -1
  30. package/docs/reference/std/premium_forward.md +1 -1
  31. package/docs/reference/std/reconciled_payout.md +1 -1
  32. package/docs/reference/std/recurring_collection.md +1 -1
  33. package/docs/reference/std/rotating_pool.md +1 -1
  34. package/docs/reference/std/scheduled.md +1 -1
  35. package/docs/reference/std/security_deposit.md +1 -1
  36. package/docs/reference/std/settlement_batch.md +1 -1
  37. package/docs/reference/std/swap.md +1 -1
  38. package/docs/reference/std/threshold_pool.md +1 -1
  39. package/docs/reference/std/weighted_distribution.md +1 -1
  40. package/docs/reference/types.md +1 -1
  41. package/docs/reference/udl-output.md +1 -1
  42. package/package.json +3 -3
  43. package/src/cli.ts +8 -5
  44. package/src/diagnostics.ts +9 -0
  45. package/src/std-bundle.ts +1 -1
  46. package/src/typecheck.ts +170 -5
  47. package/src/version.ts +1 -1
  48. package/std/money_flows/held_payment.hsx +23 -10
@@ -39,6 +39,7 @@ module std.money_flows.held_payment
39
39
  // - `cancel_charge_bps`: Optional cancellation charge in basis points. Declaring it gives the settlement a
40
40
  // quoted cancellation: `quote_cancellation` prices the charge and the refund and freezes both,
41
41
  // `cancel` pays the refund to the payer, and `retain_cancellation_charge` pays the charge to the payee.
42
+ // A zero charge keeps the flow with a zero fee.
42
43
  // - `cancel_offer_life`: ISO 8601 duration a cancellation quote stays open, required with `cancel_charge_bps`.
43
44
  //
44
45
  // ### Decision ports
@@ -70,6 +71,8 @@ export instrument held_payment<C>(payer: party, payee: party, amount: money<C>,
70
71
  let(payee_fee): get(fees, payee);
71
72
  let(payer_fee_kind): kind(payer_fee);
72
73
  let(payee_fee_kind): kind(payee_fee);
74
+ let(has_cancel_quote): if_eq(kind(cancel_charge_bps), "boolean", false, true);
75
+ let(has_charge): if_eq(cancel_charge_bps, 0, false, true);
73
76
  when_eq(payee_fee_kind, binding) {
74
77
  when(on_cancel) {
75
78
  unsupported {
@@ -79,7 +82,7 @@ export instrument held_payment<C>(payer: party, payee: party, amount: money<C>,
79
82
  }
80
83
  }
81
84
  }
82
- when(cancel_charge_bps) {
85
+ when(has_cancel_quote) {
83
86
  when(on_cancel) {
84
87
  unsupported {
85
88
  code: HSX1110;
@@ -110,10 +113,10 @@ export instrument held_payment<C>(payer: party, payee: party, amount: money<C>,
110
113
  }
111
114
  }
112
115
  when(cancel_offer_life) {
113
- when_not(cancel_charge_bps) {
116
+ when_not(has_cancel_quote) {
114
117
  unsupported {
115
118
  code: HSX1110;
116
- message: "cancel_offer_life needs a nonzero cancel_charge_bps to quote";
119
+ message: "cancel_offer_life needs cancel_charge_bps to quote";
117
120
  fix: "declare the cancellation charge in basis points, or drop cancel_offer_life";
118
121
  }
119
122
  }
@@ -202,7 +205,7 @@ export instrument held_payment<C>(payer: party, payee: party, amount: money<C>,
202
205
  when_not(cancel_splits) {
203
206
  states created funded disputed released;
204
207
  when(on_cancel) { states cancelled; }
205
- when(cancel_charge_bps) { states cancellation_quoted cancelled settled; }
208
+ when(has_cancel_quote) { states cancellation_quoted cancelled settled; }
206
209
  states abandoned;
207
210
  }
208
211
  when(cancel_splits) { states created funding_1 funded disputed releasing_1 released cancelling_1 cancelled abandoned; }
@@ -219,14 +222,14 @@ export instrument held_payment<C>(payer: party, payee: party, amount: money<C>,
219
222
  when_not(payee_fee) {
220
223
  when_not(cancel_splits) {
221
224
  on fund_piece_1: created -> funded;
222
- when_not(cancel_charge_bps) {
225
+ when_not(has_cancel_quote) {
223
226
  on [release_name]: funded -> released;
224
227
  when(release_deadline) { on release_on_deadline: funded -> released; }
225
228
  }
226
- when(cancel_charge_bps) {
229
+ when(has_cancel_quote) {
227
230
  on [release_name]: funded | cancellation_quoted -> released;
228
231
  when(release_deadline) { on release_on_deadline: funded | cancellation_quoted -> released; }
229
- on quote_cancellation: funded -> cancellation_quoted;
232
+ on quote_cancellation: funded | cancellation_quoted -> cancellation_quoted;
230
233
  on cancel: cancellation_quoted -> cancelled;
231
234
  on retain_cancellation_charge: cancelled -> settled;
232
235
  }
@@ -275,7 +278,12 @@ export instrument held_payment<C>(payer: party, payee: party, amount: money<C>,
275
278
  on unfund_piece_1: funding_1 | abandoning_1 -> abandoned;
276
279
  }
277
280
  }
278
- on dispute: funded -> disputed;
281
+ when_not(has_cancel_quote) {
282
+ on dispute: funded -> disputed;
283
+ }
284
+ when(has_cancel_quote) {
285
+ on dispute: funded | cancellation_quoted -> disputed;
286
+ }
279
287
  on resume: disputed -> funded;
280
288
  on abandon: created -> abandoned;
281
289
  }
@@ -520,7 +528,7 @@ export instrument held_payment<C>(payer: party, payee: party, amount: money<C>,
520
528
  steps: [];
521
529
  }
522
530
  }
523
- when(cancel_charge_bps) {
531
+ when(has_cancel_quote) {
524
532
  action quote_cancellation {
525
533
  agent_description: concat("Price the cancellation and hold that price open. No money moves. The charge the ", words(payee), " keeps and the refund the ", words(payer), " gets back are worked out here and frozen for ", cancel_offer_life, ", after which a fresh call prices it again. Call cancel to spend the quote.");
526
534
  summary: "Price the cancellation and hold that price open";
@@ -554,7 +562,12 @@ export instrument held_payment<C>(payer: party, payee: party, amount: money<C>,
554
562
  let(metadata_phase): "metadata.phase";
555
563
  agent_description: concat("Pay the quoted cancellation charge out of escrow to the ", words(payee), ". This moves money and does not reverse. The settlement must already be cancelled, so the figure is the one the quote fixed and the escrow ends empty.");
556
564
  summary: concat("Pay the quoted cancellation charge to the ", words(payee));
557
- moves: [{ key: charge; operation: internal_transfer.create; bind: { amount: { from: instance; path: refs.cancellationChargeAmount; }; currency: { from: instance; path: fields.currency; }; destinationAccountId: { from: instance; path: concat("fields.", payee_account_field); }; [metadata_instrument]: { from: const; value: instrument; }; [metadata_instance]: { from: instance; path: instrumentInstanceId; }; [metadata_phase]: { from: const; value: retain_cancellation_charge; }; productId: { from: instance; path: productId; }; sourceAccountId: { from: instance; path: refs.escrowAccountId; }; }; capture: { retainCancellationChargeTransferId: transferId; }; }];
565
+ when(has_charge) {
566
+ moves: [{ key: charge; operation: internal_transfer.create; bind: { amount: { from: instance; path: refs.cancellationChargeAmount; }; currency: { from: instance; path: fields.currency; }; destinationAccountId: { from: instance; path: concat("fields.", payee_account_field); }; [metadata_instrument]: { from: const; value: instrument; }; [metadata_instance]: { from: instance; path: instrumentInstanceId; }; [metadata_phase]: { from: const; value: retain_cancellation_charge; }; productId: { from: instance; path: productId; }; sourceAccountId: { from: instance; path: refs.escrowAccountId; }; }; capture: { retainCancellationChargeTransferId: transferId; }; }];
567
+ }
568
+ when_not(has_charge) {
569
+ moves: [];
570
+ }
558
571
  steps: [];
559
572
  }
560
573
  }