@hyperscale0/hsx 2.4.1 → 3.0.0

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 (249) hide show
  1. package/CHANGELOG.md +2 -408
  2. package/README.md +3 -92
  3. package/dist/src/ast.d.ts +99 -310
  4. package/dist/src/ast.d.ts.map +1 -1
  5. package/dist/src/ast.js +16 -69
  6. package/dist/src/ast.js.map +1 -1
  7. package/dist/src/cli.d.ts +6 -19
  8. package/dist/src/cli.d.ts.map +1 -1
  9. package/dist/src/cli.js +76 -315
  10. package/dist/src/cli.js.map +1 -1
  11. package/dist/src/compile.d.ts +23 -73
  12. package/dist/src/compile.d.ts.map +1 -1
  13. package/dist/src/compile.js +1113 -148
  14. package/dist/src/compile.js.map +1 -1
  15. package/dist/src/cost.d.ts +8 -77
  16. package/dist/src/cost.d.ts.map +1 -1
  17. package/dist/src/cost.js +13 -422
  18. package/dist/src/cost.js.map +1 -1
  19. package/dist/src/format.d.ts +8 -7
  20. package/dist/src/format.d.ts.map +1 -1
  21. package/dist/src/format.js +9 -175
  22. package/dist/src/format.js.map +1 -1
  23. package/dist/src/headers.d.ts +35 -0
  24. package/dist/src/headers.d.ts.map +1 -0
  25. package/dist/src/headers.js +108 -0
  26. package/dist/src/headers.js.map +1 -0
  27. package/dist/src/index.d.ts +6 -12
  28. package/dist/src/index.d.ts.map +1 -1
  29. package/dist/src/index.js +4 -9
  30. package/dist/src/index.js.map +1 -1
  31. package/dist/src/lex.d.ts +8 -28
  32. package/dist/src/lex.d.ts.map +1 -1
  33. package/dist/src/lex.js +88 -146
  34. package/dist/src/lex.js.map +1 -1
  35. package/dist/src/parse.d.ts +4 -17
  36. package/dist/src/parse.d.ts.map +1 -1
  37. package/dist/src/parse.js +402 -1040
  38. package/dist/src/parse.js.map +1 -1
  39. package/dist/src/std-bundle.d.ts.map +1 -1
  40. package/dist/src/std-bundle.js +12 -20
  41. package/dist/src/std-bundle.js.map +1 -1
  42. package/dist/src/std-library.d.ts +1 -1
  43. package/dist/src/std-library.d.ts.map +1 -1
  44. package/dist/src/std-library.js +1 -5
  45. package/dist/src/std-library.js.map +1 -1
  46. package/dist/src/tunables.d.ts +7 -0
  47. package/dist/src/tunables.d.ts.map +1 -0
  48. package/dist/src/tunables.js +26 -0
  49. package/dist/src/tunables.js.map +1 -0
  50. package/dist/src/version.d.ts +2 -4
  51. package/dist/src/version.d.ts.map +1 -1
  52. package/dist/src/version.js +2 -4
  53. package/dist/src/version.js.map +1 -1
  54. package/docs/README.md +179 -41
  55. package/docs/headers.md +44 -0
  56. package/examples/cost-table.json +99 -751
  57. package/examples/library.hsx +59 -0
  58. package/package.json +9 -17
  59. package/src/ast.ts +82 -441
  60. package/src/cli.ts +77 -362
  61. package/src/compile.ts +1535 -247
  62. package/src/cost.ts +28 -671
  63. package/src/format.ts +12 -256
  64. package/src/headers.ts +126 -0
  65. package/src/index.ts +7 -39
  66. package/src/lex.ts +99 -195
  67. package/src/parse.ts +403 -1209
  68. package/src/std-bundle.ts +12 -20
  69. package/src/std-library.ts +2 -7
  70. package/src/tunables.ts +31 -0
  71. package/src/version.ts +2 -5
  72. package/std/approvals.hsx +17 -0
  73. package/std/cards.hsx +63 -0
  74. package/std/collections.hsx +31 -0
  75. package/std/escrow.hsx +43 -0
  76. package/std/financing.hsx +372 -0
  77. package/std/insurance.hsx +59 -0
  78. package/std/lending.hsx +115 -0
  79. package/std/marketplace.hsx +24 -0
  80. package/std/money.hsx +195 -0
  81. package/std/savings.hsx +44 -0
  82. package/std/travel.hsx +98 -0
  83. package/std/wallet.hsx +41 -0
  84. package/dist/src/diagnostics.d.ts +0 -13
  85. package/dist/src/diagnostics.d.ts.map +0 -1
  86. package/dist/src/diagnostics.js +0 -587
  87. package/dist/src/diagnostics.js.map +0 -1
  88. package/dist/src/emit.d.ts +0 -51
  89. package/dist/src/emit.d.ts.map +0 -1
  90. package/dist/src/emit.js +0 -192
  91. package/dist/src/emit.js.map +0 -1
  92. package/dist/src/entry-overrides.d.ts +0 -58
  93. package/dist/src/entry-overrides.d.ts.map +0 -1
  94. package/dist/src/entry-overrides.js +0 -284
  95. package/dist/src/entry-overrides.js.map +0 -1
  96. package/dist/src/ir.d.ts +0 -73
  97. package/dist/src/ir.d.ts.map +0 -1
  98. package/dist/src/ir.js +0 -15
  99. package/dist/src/ir.js.map +0 -1
  100. package/dist/src/limits.d.ts +0 -23
  101. package/dist/src/limits.d.ts.map +0 -1
  102. package/dist/src/limits.js +0 -23
  103. package/dist/src/limits.js.map +0 -1
  104. package/dist/src/lsp/server.d.ts +0 -32
  105. package/dist/src/lsp/server.d.ts.map +0 -1
  106. package/dist/src/lsp/server.js +0 -391
  107. package/dist/src/lsp/server.js.map +0 -1
  108. package/dist/src/modules.d.ts +0 -38
  109. package/dist/src/modules.d.ts.map +0 -1
  110. package/dist/src/modules.js +0 -372
  111. package/dist/src/modules.js.map +0 -1
  112. package/dist/src/typecheck.d.ts +0 -8
  113. package/dist/src/typecheck.d.ts.map +0 -1
  114. package/dist/src/typecheck.js +0 -4160
  115. package/dist/src/typecheck.js.map +0 -1
  116. package/docs/guide/01-first-program.md +0 -24
  117. package/docs/guide/02-money.md +0 -25
  118. package/docs/guide/03-instruments.md +0 -93
  119. package/docs/guide/04-lifecycles.md +0 -40
  120. package/docs/guide/05-fees-and-splits.md +0 -45
  121. package/docs/guide/06-schedules.md +0 -26
  122. package/docs/guide/07-composition.md +0 -52
  123. package/docs/guide/08-writing-a-module.md +0 -85
  124. package/docs/guide/09-cost.md +0 -24
  125. package/docs/guide/10-diagnostics.md +0 -27
  126. package/docs/llms-full.txt +0 -3684
  127. package/docs/llms.txt +0 -44
  128. package/docs/piece-plans.md +0 -120
  129. package/docs/playground.md +0 -55
  130. package/docs/reference/cli.md +0 -36
  131. package/docs/reference/diagnostics.md +0 -901
  132. package/docs/reference/grammar.md +0 -38
  133. package/docs/reference/std/advance.md +0 -112
  134. package/docs/reference/std/cancellable_booking.md +0 -159
  135. package/docs/reference/std/captured_payment.md +0 -115
  136. package/docs/reference/std/conditional_disbursement.md +0 -101
  137. package/docs/reference/std/credit_facility.md +0 -108
  138. package/docs/reference/std/held_payment.md +0 -173
  139. package/docs/reference/std/instant_transfer.md +0 -97
  140. package/docs/reference/std/metered.md +0 -89
  141. package/docs/reference/std/pooled_split.md +0 -95
  142. package/docs/reference/std/premium_forward.md +0 -119
  143. package/docs/reference/std/reconciled_payout.md +0 -103
  144. package/docs/reference/std/rotating_pool.md +0 -130
  145. package/docs/reference/std/scheduled.md +0 -136
  146. package/docs/reference/std/security_deposit.md +0 -138
  147. package/docs/reference/std/settlement_batch.md +0 -123
  148. package/docs/reference/std/swap.md +0 -133
  149. package/docs/reference/std/threshold_pool.md +0 -138
  150. package/docs/reference/std/weighted_distribution.md +0 -135
  151. package/docs/reference/types.md +0 -61
  152. package/docs/reference/udl-output.md +0 -13
  153. package/examples/01-first-program/README.md +0 -45
  154. package/examples/01-first-program/tip-jar.hsx +0 -17
  155. package/examples/02-imports-and-modules/README.md +0 -96
  156. package/examples/02-imports-and-modules/photo-booth.hsx +0 -37
  157. package/examples/03-diagnostics/README.md +0 -68
  158. package/examples/03-diagnostics/corner-shop-fixed.hsx +0 -22
  159. package/examples/03-diagnostics/corner-shop.hsx +0 -19
  160. package/examples/04-complete-product/README.md +0 -84
  161. package/examples/04-complete-product/study-hall.hsx +0 -67
  162. package/examples/05-authored-instrument/README.md +0 -5
  163. package/examples/05-authored-instrument/payment.hsx +0 -37
  164. package/examples/05-watch-club/README.md +0 -6
  165. package/examples/05-watch-club/watch-club.hsx +0 -123
  166. package/examples/README.md +0 -48
  167. package/examples/advance/README.md +0 -3
  168. package/examples/advance/advance.hsx +0 -13
  169. package/examples/advance/advance.udl +0 -367
  170. package/examples/cancellable_booking/README.md +0 -3
  171. package/examples/cancellable_booking/cancellable_booking.hsx +0 -14
  172. package/examples/cancellable_booking/cancellable_booking.udl +0 -413
  173. package/examples/captured_payment/README.md +0 -3
  174. package/examples/captured_payment/captured_payment.hsx +0 -17
  175. package/examples/captured_payment/captured_payment.udl +0 -686
  176. package/examples/conditional_disbursement/README.md +0 -3
  177. package/examples/conditional_disbursement/conditional_disbursement.hsx +0 -15
  178. package/examples/conditional_disbursement/conditional_disbursement.udl +0 -418
  179. package/examples/credit_facility/README.md +0 -3
  180. package/examples/credit_facility/credit_facility.hsx +0 -24
  181. package/examples/credit_facility/credit_facility.udl +0 -1396
  182. package/examples/held_payment/README.md +0 -3
  183. package/examples/held_payment/held_payment.hsx +0 -13
  184. package/examples/held_payment/held_payment.udl +0 -569
  185. package/examples/instant_transfer/README.md +0 -3
  186. package/examples/instant_transfer/instant_transfer.hsx +0 -16
  187. package/examples/instant_transfer/instant_transfer.udl +0 -376
  188. package/examples/metered/README.md +0 -3
  189. package/examples/metered/metered.hsx +0 -13
  190. package/examples/metered/metered.udl +0 -253
  191. package/examples/pooled_split/README.md +0 -3
  192. package/examples/pooled_split/pooled_split.hsx +0 -15
  193. package/examples/pooled_split/pooled_split.udl +0 -432
  194. package/examples/premium_forward/README.md +0 -3
  195. package/examples/premium_forward/premium_forward.hsx +0 -19
  196. package/examples/premium_forward/premium_forward.udl +0 -604
  197. package/examples/reconciled_payout/README.md +0 -3
  198. package/examples/reconciled_payout/reconciled_payout.hsx +0 -13
  199. package/examples/reconciled_payout/reconciled_payout.udl +0 -312
  200. package/examples/rotating_pool/README.md +0 -3
  201. package/examples/rotating_pool/rotating_pool.hsx +0 -18
  202. package/examples/rotating_pool/rotating_pool.udl +0 -4370
  203. package/examples/scheduled/README.md +0 -3
  204. package/examples/scheduled/scheduled.hsx +0 -12
  205. package/examples/scheduled/scheduled.udl +0 -355
  206. package/examples/security_deposit/README.md +0 -3
  207. package/examples/security_deposit/security_deposit.hsx +0 -21
  208. package/examples/security_deposit/security_deposit.udl +0 -320
  209. package/examples/settlement_batch/README.md +0 -3
  210. package/examples/settlement_batch/settlement_batch.hsx +0 -19
  211. package/examples/settlement_batch/settlement_batch.udl +0 -757
  212. package/examples/swap/README.md +0 -3
  213. package/examples/swap/swap.hsx +0 -19
  214. package/examples/swap/swap.udl +0 -892
  215. package/examples/threshold_pool/README.md +0 -3
  216. package/examples/threshold_pool/threshold_pool.hsx +0 -16
  217. package/examples/threshold_pool/threshold_pool.udl +0 -680
  218. package/examples/weighted_distribution/README.md +0 -3
  219. package/examples/weighted_distribution/weighted_distribution.hsx +0 -20
  220. package/examples/weighted_distribution/weighted_distribution.udl +0 -348
  221. package/skills/hsx/SKILL.md +0 -449
  222. package/src/diagnostics.ts +0 -620
  223. package/src/emit.ts +0 -282
  224. package/src/entry-overrides.ts +0 -428
  225. package/src/ir.ts +0 -113
  226. package/src/limits.ts +0 -22
  227. package/src/lsp/server.ts +0 -460
  228. package/src/modules.ts +0 -452
  229. package/src/typecheck.ts +0 -5515
  230. package/std/SEMANTICS.md +0 -44
  231. package/std/money_flows/advance.hsx +0 -235
  232. package/std/money_flows/cancellable_booking.hsx +0 -402
  233. package/std/money_flows/captured_payment.hsx +0 -220
  234. package/std/money_flows/conditional_disbursement.hsx +0 -226
  235. package/std/money_flows/credit_facility.hsx +0 -214
  236. package/std/money_flows/held_payment.hsx +0 -812
  237. package/std/money_flows/index.hsx +0 -4
  238. package/std/money_flows/instant_transfer.hsx +0 -231
  239. package/std/money_flows/metered.hsx +0 -104
  240. package/std/money_flows/pooled_split.hsx +0 -109
  241. package/std/money_flows/premium_forward.hsx +0 -307
  242. package/std/money_flows/reconciled_payout.hsx +0 -119
  243. package/std/money_flows/rotating_pool.hsx +0 -305
  244. package/std/money_flows/scheduled.hsx +0 -599
  245. package/std/money_flows/security_deposit.hsx +0 -248
  246. package/std/money_flows/settlement_batch.hsx +0 -173
  247. package/std/money_flows/swap.hsx +0 -1192
  248. package/std/money_flows/threshold_pool.hsx +0 -307
  249. package/std/money_flows/weighted_distribution.hsx +0 -237
@@ -1,376 +0,0 @@
1
- {
2
- "instruments": [
3
- {
4
- "actionOrder": [
5
- "create",
6
- "pay_piece_1",
7
- "pay_piece_2",
8
- "collect_service_fee"
9
- ],
10
- "actions": {
11
- "collect_service_fee": {
12
- "agentDescription": "Finish the payment and collect the service fee the customer owes on top of the amount. Both pieces must already be paid. When the product charges no payer fee this only closes the payment out.",
13
- "effects": {
14
- "moves": [
15
- {
16
- "signature": "moves.transfer.internal",
17
- "source": "moves[0]"
18
- }
19
- ]
20
- },
21
- "moves": [
22
- {
23
- "bind": {
24
- "amount": {
25
- "from": "instance",
26
- "path": "fields.checkoutFee"
27
- },
28
- "currency": {
29
- "from": "const",
30
- "value": "SAR"
31
- },
32
- "destinationAccountId": {
33
- "from": "instance",
34
- "path": "fields.platformAccountId"
35
- },
36
- "metadata.instrumentId": {
37
- "from": "const",
38
- "value": "transfer"
39
- },
40
- "metadata.instrumentInstanceId": {
41
- "from": "instance",
42
- "path": "instrumentInstanceId"
43
- },
44
- "metadata.phase": {
45
- "from": "const",
46
- "value": "collect_service_fee"
47
- },
48
- "productId": {
49
- "from": "instance",
50
- "path": "productId"
51
- },
52
- "sourceAccountId": {
53
- "from": "instance",
54
- "path": "fields.customerAccountId"
55
- }
56
- },
57
- "capture": {
58
- "collectServiceFeeTransferTransferId": "transferId"
59
- },
60
- "key": "transfer",
61
- "operation": "internal_transfer.create"
62
- }
63
- ],
64
- "publicAction": "collectServiceFeeTransfer",
65
- "steps": [],
66
- "summary": "Collect the payer-side service fee"
67
- },
68
- "create": {
69
- "agentDescription": "Open the payment row before anything moves. The caller supplies the transferAmount, the currency, and both party accounts. Fee and derived pieces are computed from the transferAmount, callers never supply them. Call pay piece 1 to move the money.",
70
- "moves": [],
71
- "publicAction": "createTransfer",
72
- "steps": [],
73
- "summary": "Create a transfer payment"
74
- },
75
- "pay_piece_1": {
76
- "agentDescription": "Move the first piece from the customer to the merchant. The payment must be created. This moves the whole amount unless the product carves a payee fee, in which case it moves the net share and pay piece 2 takes the fee.",
77
- "effects": {
78
- "moves": [
79
- {
80
- "signature": "moves.transfer.internal",
81
- "source": "moves[0]"
82
- }
83
- ]
84
- },
85
- "moves": [
86
- {
87
- "bind": {
88
- "amount": {
89
- "from": "instance",
90
- "path": "fields.netOfCarvedFeeAmount"
91
- },
92
- "currency": {
93
- "from": "const",
94
- "value": "SAR"
95
- },
96
- "destinationAccountId": {
97
- "from": "instance",
98
- "path": "fields.merchantAccountId"
99
- },
100
- "metadata.instrumentId": {
101
- "from": "const",
102
- "value": "transfer"
103
- },
104
- "metadata.instrumentInstanceId": {
105
- "from": "instance",
106
- "path": "instrumentInstanceId"
107
- },
108
- "metadata.phase": {
109
- "from": "const",
110
- "value": "pay_piece_1"
111
- },
112
- "productId": {
113
- "from": "instance",
114
- "path": "productId"
115
- },
116
- "sourceAccountId": {
117
- "from": "instance",
118
- "path": "fields.customerAccountId"
119
- }
120
- },
121
- "capture": {
122
- "payPiece1TransferTransferId": "transferId"
123
- },
124
- "key": "transfer",
125
- "operation": "internal_transfer.create"
126
- }
127
- ],
128
- "publicAction": "payPiece1Transfer",
129
- "sandboxFailurePoint": "funding",
130
- "steps": [],
131
- "summary": "Pay piece 1 of the amount through"
132
- },
133
- "pay_piece_2": {
134
- "agentDescription": "Move the carved platform fee out of the amount. Call this after pay piece 1. When the product carves no merchant fee this only steps the payment forward and moves nothing.",
135
- "effects": {
136
- "moves": [
137
- {
138
- "signature": "moves.transfer.internal",
139
- "source": "moves[0]"
140
- }
141
- ]
142
- },
143
- "moves": [
144
- {
145
- "bind": {
146
- "amount": {
147
- "from": "instance",
148
- "path": "fields.carvedFeeAmount"
149
- },
150
- "currency": {
151
- "from": "const",
152
- "value": "SAR"
153
- },
154
- "destinationAccountId": {
155
- "from": "instance",
156
- "path": "fields.platformAccountId"
157
- },
158
- "metadata.instrumentId": {
159
- "from": "const",
160
- "value": "transfer"
161
- },
162
- "metadata.instrumentInstanceId": {
163
- "from": "instance",
164
- "path": "instrumentInstanceId"
165
- },
166
- "metadata.phase": {
167
- "from": "const",
168
- "value": "pay_piece_2"
169
- },
170
- "productId": {
171
- "from": "instance",
172
- "path": "productId"
173
- },
174
- "sourceAccountId": {
175
- "from": "instance",
176
- "path": "fields.customerAccountId"
177
- }
178
- },
179
- "capture": {
180
- "payPiece2TransferTransferId": "transferId"
181
- },
182
- "key": "transfer",
183
- "operation": "internal_transfer.create"
184
- }
185
- ],
186
- "publicAction": "payPiece2Transfer",
187
- "steps": [],
188
- "summary": "Pay piece 2 of the amount through"
189
- }
190
- },
191
- "agentDescription": "Reach for instant transfer when the customer pays the merchant straight through with no custody step. The money leaves and lands in one call. Pick deposit when the money must be held first, and captured payment when the payee takes it in slices.",
192
- "description": "Instant transfer: the customer pays transferAmount straight through to the merchant, no custody",
193
- "feeRules": [
194
- {
195
- "amountField": "checkoutFee",
196
- "baseField": "transferAmount",
197
- "bearerField": "customerAccountId",
198
- "position": "on_top",
199
- "rule": {
200
- "currencyField": "currency",
201
- "field": "checkoutFee",
202
- "kind": "exact"
203
- }
204
- },
205
- {
206
- "amountField": "carvedFeeAmount",
207
- "baseField": "transferAmount",
208
- "bearerField": "merchantAccountId",
209
- "position": "carved",
210
- "rule": {
211
- "kind": "tiered",
212
- "tiers": [
213
- {
214
- "fromInclusive": "0",
215
- "rule": {
216
- "bps": 100,
217
- "kind": "bps"
218
- },
219
- "toExclusive": "10000"
220
- },
221
- {
222
- "fromInclusive": "10000",
223
- "rule": {
224
- "currencyField": "currency",
225
- "field": "highValueFee",
226
- "kind": "exact"
227
- }
228
- }
229
- ]
230
- }
231
- }
232
- ],
233
- "fields": {
234
- "carvedFeeAmount": {
235
- "description": "The carved platform fee selected from transferAmount",
236
- "pattern": "^[1-9][0-9]{0,17}$",
237
- "type": "string",
238
- "x-hyperscale-currency": "SAR"
239
- },
240
- "checkoutFee": {
241
- "description": "Immutable exact customer fee in SAR minor units",
242
- "pattern": "^[1-9][0-9]{0,17}$",
243
- "type": "string",
244
- "x-hyperscale-currency": "SAR"
245
- },
246
- "currency": {
247
- "description": "ISO 4217 currency code",
248
- "maxLength": 3,
249
- "minLength": 3,
250
- "pattern": "^[A-Z]{3}$",
251
- "type": "string"
252
- },
253
- "customerAccountId": {
254
- "description": "The customer account",
255
- "pattern": "^acct_(sandbox|live)_[a-z0-9]{8,64}$",
256
- "type": "string",
257
- "x-hyperscale-reference-filter": {
258
- "column": "role",
259
- "values": [
260
- "customer_balance"
261
- ]
262
- }
263
- },
264
- "highValueFee": {
265
- "description": "Immutable exact merchant fee in SAR minor units",
266
- "pattern": "^[1-9][0-9]{0,17}$",
267
- "type": "string",
268
- "x-hyperscale-currency": "SAR"
269
- },
270
- "merchantAccountId": {
271
- "description": "The merchant account",
272
- "pattern": "^acct_(sandbox|live)_[a-z0-9]{8,64}$",
273
- "type": "string",
274
- "x-hyperscale-reference-filter": {
275
- "column": "role",
276
- "values": [
277
- "customer_balance"
278
- ]
279
- }
280
- },
281
- "netOfCarvedFeeAmount": {
282
- "description": "The remainder of transferAmount after the carved platform fee",
283
- "pattern": "^[1-9][0-9]{0,17}$",
284
- "type": "string",
285
- "x-hyperscale-currency": "SAR"
286
- },
287
- "platformAccountId": {
288
- "description": "The product fee collection account",
289
- "pattern": "^acct_(sandbox|live)_[a-z0-9]{8,64}$",
290
- "type": "string",
291
- "x-hyperscale-fee-collection-port": true,
292
- "x-hyperscale-reference-filter": {
293
- "column": "role",
294
- "values": [
295
- "customer_balance",
296
- "product_revenue"
297
- ]
298
- }
299
- },
300
- "transferAmount": {
301
- "description": "The gross amount in SAR minor units; the piece fields below partition it exactly",
302
- "pattern": "^[1-9][0-9]{0,17}$",
303
- "type": "string",
304
- "x-hyperscale-currency": "SAR"
305
- }
306
- },
307
- "id": "transfer",
308
- "idPrefix": "tran",
309
- "lifecycle": {
310
- "initial": "created",
311
- "states": [
312
- "created",
313
- "paying_1",
314
- "paying_2",
315
- "paid"
316
- ],
317
- "transitions": {
318
- "collect_service_fee": {
319
- "from": [
320
- "paying_2"
321
- ],
322
- "to": "paid"
323
- },
324
- "pay_piece_1": {
325
- "from": [
326
- "created"
327
- ],
328
- "to": "paying_1"
329
- },
330
- "pay_piece_2": {
331
- "from": [
332
- "paying_1"
333
- ],
334
- "to": "paying_2"
335
- }
336
- }
337
- },
338
- "parties": {
339
- "beneficiary": "merchantAccountId",
340
- "payer": "customerAccountId"
341
- },
342
- "partitions": [
343
- {
344
- "pieceFields": [
345
- "netOfCarvedFeeAmount",
346
- "carvedFeeAmount"
347
- ],
348
- "totalField": "transferAmount"
349
- }
350
- ],
351
- "required": [
352
- "customerAccountId",
353
- "merchantAccountId",
354
- "platformAccountId",
355
- "transferAmount",
356
- "netOfCarvedFeeAmount",
357
- "checkoutFee",
358
- "highValueFee",
359
- "currency"
360
- ],
361
- "summary": "Instant payment from customer to merchant",
362
- "templateBinding": {
363
- "id": "instant_transfer",
364
- "parameters": {
365
- "derivedAmount": false
366
- }
367
- },
368
- "title": "Transfer"
369
- }
370
- ],
371
- "product": "instant_transfer_example",
372
- "subjects": [],
373
- "title": "Instant transfer example",
374
- "udl": 1,
375
- "version": 1
376
- }
@@ -1,3 +0,0 @@
1
- # metered
2
-
3
- This example applies the `metered` standard-library module. Its sibling UDL file pins the canonical compiler output byte for byte. The company and parties are invented.
@@ -1,13 +0,0 @@
1
- program metered_example "Metered example"
2
- import { metered } from "std/money_flows"
3
- party customer: business
4
- party provider: business
5
- settlement usage = metered {
6
- payer: customer
7
- payee: provider
8
- close_by: periodEnd
9
- rates {
10
- api_call: callRate: money(SAR)
11
- storage_gib: storageRate: money(SAR)
12
- }
13
- }
@@ -1,253 +0,0 @@
1
- {
2
- "instruments": [
3
- {
4
- "actionOrder": [
5
- "create",
6
- "charge_api_call",
7
- "charge_storage_gib",
8
- "close_period"
9
- ],
10
- "actions": {
11
- "charge_api_call": {
12
- "agentDescription": "Charge one metered api call at the committed price. The period must still be open, so charge before periodEnd. The transfer posts from the customer to the provider at once and there is no reversal action.",
13
- "effects": {
14
- "moves": [
15
- {
16
- "signature": "moves.transfer.internal",
17
- "source": "moves[0]"
18
- }
19
- ]
20
- },
21
- "moves": [
22
- {
23
- "bind": {
24
- "amount": {
25
- "from": "instance",
26
- "path": "fields.callRate"
27
- },
28
- "currency": {
29
- "from": "const",
30
- "value": "SAR"
31
- },
32
- "destinationAccountId": {
33
- "from": "instance",
34
- "path": "fields.providerAccountId"
35
- },
36
- "metadata.instrumentId": {
37
- "from": "const",
38
- "value": "usage"
39
- },
40
- "metadata.instrumentInstanceId": {
41
- "from": "instance",
42
- "path": "instrumentInstanceId"
43
- },
44
- "metadata.phase": {
45
- "from": "const",
46
- "value": "charge_api_call"
47
- },
48
- "productId": {
49
- "from": "instance",
50
- "path": "productId"
51
- },
52
- "sourceAccountId": {
53
- "from": "instance",
54
- "path": "fields.customerAccountId"
55
- }
56
- },
57
- "capture": {
58
- "chargeApiCallTransferTransferId": "transferId"
59
- },
60
- "key": "transfer",
61
- "operation": "internal_transfer.create"
62
- }
63
- ],
64
- "publicAction": "chargeApiCallUsage",
65
- "steps": [],
66
- "summary": "Charge one metered api call; the emission is the transfer itself"
67
- },
68
- "charge_storage_gib": {
69
- "agentDescription": "Charge one metered storage gib at the committed price. The period must still be open, so charge before periodEnd. The transfer posts from the customer to the provider at once and there is no reversal action.",
70
- "effects": {
71
- "moves": [
72
- {
73
- "signature": "moves.transfer.internal",
74
- "source": "moves[0]"
75
- }
76
- ]
77
- },
78
- "moves": [
79
- {
80
- "bind": {
81
- "amount": {
82
- "from": "instance",
83
- "path": "fields.storageRate"
84
- },
85
- "currency": {
86
- "from": "const",
87
- "value": "SAR"
88
- },
89
- "destinationAccountId": {
90
- "from": "instance",
91
- "path": "fields.providerAccountId"
92
- },
93
- "metadata.instrumentId": {
94
- "from": "const",
95
- "value": "usage"
96
- },
97
- "metadata.instrumentInstanceId": {
98
- "from": "instance",
99
- "path": "instrumentInstanceId"
100
- },
101
- "metadata.phase": {
102
- "from": "const",
103
- "value": "charge_storage_gib"
104
- },
105
- "productId": {
106
- "from": "instance",
107
- "path": "productId"
108
- },
109
- "sourceAccountId": {
110
- "from": "instance",
111
- "path": "fields.customerAccountId"
112
- }
113
- },
114
- "capture": {
115
- "chargeStorageGibTransferTransferId": "transferId"
116
- },
117
- "key": "transfer",
118
- "operation": "internal_transfer.create"
119
- }
120
- ],
121
- "publicAction": "chargeStorageGibUsage",
122
- "steps": [],
123
- "summary": "Charge one metered storage gib; the emission is the transfer itself"
124
- },
125
- "close_period": {
126
- "due": {
127
- "field": "periodEnd"
128
- },
129
- "effects": {
130
- "schedules": [
131
- {
132
- "signature": "schedules.due",
133
- "source": "due"
134
- }
135
- ]
136
- },
137
- "moves": [],
138
- "steps": [],
139
- "summary": "Close the metering period; no further usage can be charged"
140
- },
141
- "create": {
142
- "agentDescription": "Open the metering period with its committed rate card. The caller supplies the periodEnd anchor and every per-unit price. The prices are fixed here and no later charge can change them. No money moves.",
143
- "moves": [],
144
- "publicAction": "createUsage",
145
- "steps": [],
146
- "summary": "Open a usage period with its committed rate card"
147
- }
148
- },
149
- "agentDescription": "Reach for metered when the customer is billed per unit at a rate card fixed when the period opens, and the period closes on periodEnd. Every charge is its own transfer. Pick scheduled for a flat repeating amount and instant transfer for a one-off payment.",
150
- "description": "Metered usage: the customer is charged per unit at the committed rate card until the period closes on its stored end date",
151
- "fields": {
152
- "callRate": {
153
- "description": "Per-unit price of api call in SAR minor units, committed at period open",
154
- "pattern": "^[1-9][0-9]{0,17}$",
155
- "type": "string",
156
- "x-hyperscale-currency": "SAR"
157
- },
158
- "currency": {
159
- "description": "ISO 4217 currency code",
160
- "maxLength": 3,
161
- "minLength": 3,
162
- "pattern": "^[A-Z]{3}$",
163
- "type": "string"
164
- },
165
- "customerAccountId": {
166
- "description": "The customer account",
167
- "pattern": "^acct_(sandbox|live)_[a-z0-9]{8,64}$",
168
- "type": "string",
169
- "x-hyperscale-reference-filter": {
170
- "column": "role",
171
- "values": [
172
- "customer_balance"
173
- ]
174
- }
175
- },
176
- "periodEnd": {
177
- "description": "End of this metering period; the close makes further charges unreachable",
178
- "format": "hyperscale-date-time",
179
- "type": "string"
180
- },
181
- "providerAccountId": {
182
- "description": "The provider account",
183
- "pattern": "^acct_(sandbox|live)_[a-z0-9]{8,64}$",
184
- "type": "string",
185
- "x-hyperscale-reference-filter": {
186
- "column": "role",
187
- "values": [
188
- "customer_balance"
189
- ]
190
- }
191
- },
192
- "storageRate": {
193
- "description": "Per-unit price of storage gib in SAR minor units, committed at period open",
194
- "pattern": "^[1-9][0-9]{0,17}$",
195
- "type": "string",
196
- "x-hyperscale-currency": "SAR"
197
- }
198
- },
199
- "id": "usage",
200
- "idPrefix": "usag",
201
- "lifecycle": {
202
- "initial": "open",
203
- "states": [
204
- "open",
205
- "closed"
206
- ],
207
- "transitions": {
208
- "charge_api_call": {
209
- "from": [
210
- "open"
211
- ],
212
- "to": "open"
213
- },
214
- "charge_storage_gib": {
215
- "from": [
216
- "open"
217
- ],
218
- "to": "open"
219
- },
220
- "close_period": {
221
- "from": [
222
- "open"
223
- ],
224
- "to": "closed"
225
- }
226
- }
227
- },
228
- "parties": {
229
- "beneficiary": "providerAccountId",
230
- "payer": "customerAccountId"
231
- },
232
- "required": [
233
- "customerAccountId",
234
- "providerAccountId",
235
- "periodEnd",
236
- "callRate",
237
- "storageRate",
238
- "currency"
239
- ],
240
- "summary": "Metered charges from customer on a committed rate card",
241
- "templateBinding": {
242
- "id": "metered",
243
- "parameters": {}
244
- },
245
- "title": "Usage"
246
- }
247
- ],
248
- "product": "metered_example",
249
- "subjects": [],
250
- "title": "Metered example",
251
- "udl": 1,
252
- "version": 1
253
- }
@@ -1,3 +0,0 @@
1
- # pooled_split
2
-
3
- This example applies the `pooled_split` standard-library module. Its sibling UDL file pins the canonical compiler output byte for byte. The company and parties are invented.
@@ -1,15 +0,0 @@
1
- program pooled_split_example "Pooled split example"
2
- import { pooled_split } from "std/money_flows"
3
- party payer: business
4
- party first_recipient: business
5
- party second_recipient: business
6
- settlement pool = pooled_split {
7
- payer: payer
8
- amount: poolAmount: money(SAR)
9
- payout_due: payoutDueAt
10
- split {
11
- first_recipient: 60%
12
- second_recipient: 40%
13
- remainder_to: first_recipient
14
- }
15
- }