@hyperscale0/hsx 1.0.0-alpha.3 → 1.0.0-alpha.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.
- package/CHANGELOG.md +94 -2
- package/README.md +5 -5
- package/dist/src/archetypes.d.ts +17 -0
- package/dist/src/archetypes.d.ts.map +1 -0
- package/dist/src/archetypes.js +327 -0
- package/dist/src/archetypes.js.map +1 -0
- package/dist/src/ast.d.ts +2 -3
- package/dist/src/ast.d.ts.map +1 -1
- package/dist/src/check.d.ts +1 -0
- package/dist/src/check.d.ts.map +1 -1
- package/dist/src/check.js +805 -109
- package/dist/src/check.js.map +1 -1
- package/dist/src/entry-overrides.d.ts +44 -0
- package/dist/src/entry-overrides.d.ts.map +1 -0
- package/dist/src/entry-overrides.js +139 -0
- package/dist/src/entry-overrides.js.map +1 -0
- package/dist/src/index.d.ts +2 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/lex.d.ts +1 -0
- package/dist/src/lex.d.ts.map +1 -1
- package/dist/src/lex.js +1 -1
- package/dist/src/lex.js.map +1 -1
- package/dist/src/lower.d.ts +57 -4
- package/dist/src/lower.d.ts.map +1 -1
- package/dist/src/lower.js +2581 -100
- package/dist/src/lower.js.map +1 -1
- package/dist/src/model.d.ts +167 -7
- package/dist/src/model.d.ts.map +1 -1
- package/dist/src/model.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
- package/spec/hsx-ir.schema.json +407 -9
- package/src/archetypes.ts +340 -0
- package/src/ast.ts +2 -3
- package/src/check.ts +1363 -124
- package/src/entry-overrides.ts +213 -0
- package/src/index.ts +7 -12
- package/src/lex.ts +1 -1
- package/src/lower.ts +2914 -127
- package/src/model.ts +187 -8
- package/src/version.ts +1 -1
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Settlement declarations shared by checking and lowering. A local event cap
|
|
3
|
+
* limits one settlement before the whole-program budget applies.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export const SETTLEMENT_ARCHETYPES = [
|
|
7
|
+
"advance",
|
|
8
|
+
"captured_payment",
|
|
9
|
+
"conditional_disbursement",
|
|
10
|
+
"credit_facility",
|
|
11
|
+
"deposit",
|
|
12
|
+
"funding_round",
|
|
13
|
+
"held_payment",
|
|
14
|
+
"instant_transfer",
|
|
15
|
+
"metered",
|
|
16
|
+
"pooled_split",
|
|
17
|
+
"premium_forward",
|
|
18
|
+
"recurring_collection",
|
|
19
|
+
"rotating_pool",
|
|
20
|
+
"scheduled",
|
|
21
|
+
"settlement_batch",
|
|
22
|
+
"swap",
|
|
23
|
+
"weighted_distribution",
|
|
24
|
+
] as const;
|
|
25
|
+
|
|
26
|
+
export type ArchetypeName = (typeof SETTLEMENT_ARCHETYPES)[number];
|
|
27
|
+
|
|
28
|
+
interface ArchetypeDefinition {
|
|
29
|
+
readonly eventCap: number;
|
|
30
|
+
readonly keys: readonly string[];
|
|
31
|
+
readonly maxRates?: number;
|
|
32
|
+
readonly maxRecipients?: number;
|
|
33
|
+
readonly referenceableExits: readonly string[];
|
|
34
|
+
readonly required: readonly string[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const ARCHETYPE_DEFINITIONS: Record<ArchetypeName, ArchetypeDefinition> =
|
|
38
|
+
{
|
|
39
|
+
advance: {
|
|
40
|
+
eventCap: 2,
|
|
41
|
+
keys: [
|
|
42
|
+
"against",
|
|
43
|
+
"amount",
|
|
44
|
+
"count",
|
|
45
|
+
"every",
|
|
46
|
+
"fee",
|
|
47
|
+
"first_due",
|
|
48
|
+
"funder",
|
|
49
|
+
"to",
|
|
50
|
+
],
|
|
51
|
+
referenceableExits: [],
|
|
52
|
+
// The repayment source is one of two shapes, so the advance checker states
|
|
53
|
+
// that requirement instead of listing either shape's keys as required.
|
|
54
|
+
required: ["funder", "to", "amount"],
|
|
55
|
+
},
|
|
56
|
+
captured_payment: {
|
|
57
|
+
eventCap: 4,
|
|
58
|
+
keys: [
|
|
59
|
+
"amount",
|
|
60
|
+
"capture_mode",
|
|
61
|
+
"correction",
|
|
62
|
+
"correction_mode",
|
|
63
|
+
"external_reversal",
|
|
64
|
+
"fees",
|
|
65
|
+
"negative_position",
|
|
66
|
+
"payee",
|
|
67
|
+
"payer",
|
|
68
|
+
"reserve_until",
|
|
69
|
+
"timeout",
|
|
70
|
+
],
|
|
71
|
+
referenceableExits: [],
|
|
72
|
+
required: [
|
|
73
|
+
"payer",
|
|
74
|
+
"payee",
|
|
75
|
+
"amount",
|
|
76
|
+
"capture_mode",
|
|
77
|
+
"reserve_until",
|
|
78
|
+
"correction",
|
|
79
|
+
"external_reversal",
|
|
80
|
+
"correction_mode",
|
|
81
|
+
"negative_position",
|
|
82
|
+
"timeout",
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
conditional_disbursement: {
|
|
86
|
+
eventCap: 1,
|
|
87
|
+
keys: [
|
|
88
|
+
"amount",
|
|
89
|
+
"cap",
|
|
90
|
+
"decision",
|
|
91
|
+
"destination",
|
|
92
|
+
"recovery_policy",
|
|
93
|
+
"reopen_policy",
|
|
94
|
+
"source",
|
|
95
|
+
],
|
|
96
|
+
referenceableExits: [],
|
|
97
|
+
required: [
|
|
98
|
+
"source",
|
|
99
|
+
"destination",
|
|
100
|
+
"cap",
|
|
101
|
+
"amount",
|
|
102
|
+
"decision",
|
|
103
|
+
"reopen_policy",
|
|
104
|
+
"recovery_policy",
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
credit_facility: {
|
|
108
|
+
eventCap: 1,
|
|
109
|
+
keys: [
|
|
110
|
+
"availability_policy",
|
|
111
|
+
"borrower",
|
|
112
|
+
"close_policy",
|
|
113
|
+
"draw_destination",
|
|
114
|
+
"expires_at",
|
|
115
|
+
"expiry_policy",
|
|
116
|
+
"lender",
|
|
117
|
+
"limit",
|
|
118
|
+
"obligation",
|
|
119
|
+
],
|
|
120
|
+
referenceableExits: [],
|
|
121
|
+
required: [
|
|
122
|
+
"lender",
|
|
123
|
+
"borrower",
|
|
124
|
+
"draw_destination",
|
|
125
|
+
"limit",
|
|
126
|
+
"expires_at",
|
|
127
|
+
"obligation",
|
|
128
|
+
"availability_policy",
|
|
129
|
+
"expiry_policy",
|
|
130
|
+
"close_policy",
|
|
131
|
+
],
|
|
132
|
+
},
|
|
133
|
+
deposit: {
|
|
134
|
+
eventCap: 1,
|
|
135
|
+
keys: ["amount", "claim", "holder", "payer", "return"],
|
|
136
|
+
referenceableExits: [],
|
|
137
|
+
required: ["payer", "holder", "amount", "claim", "return"],
|
|
138
|
+
},
|
|
139
|
+
funding_round: {
|
|
140
|
+
eventCap: 4,
|
|
141
|
+
keys: [
|
|
142
|
+
"beneficiary",
|
|
143
|
+
"cancel_policy",
|
|
144
|
+
"close_by",
|
|
145
|
+
"close_policy",
|
|
146
|
+
"commitment",
|
|
147
|
+
"contributor",
|
|
148
|
+
"fail_policy",
|
|
149
|
+
"max_contributors",
|
|
150
|
+
"overfund_policy",
|
|
151
|
+
"target",
|
|
152
|
+
],
|
|
153
|
+
referenceableExits: [],
|
|
154
|
+
required: [
|
|
155
|
+
"contributor",
|
|
156
|
+
"beneficiary",
|
|
157
|
+
"target",
|
|
158
|
+
"commitment",
|
|
159
|
+
"max_contributors",
|
|
160
|
+
"close_by",
|
|
161
|
+
"close_policy",
|
|
162
|
+
"overfund_policy",
|
|
163
|
+
"cancel_policy",
|
|
164
|
+
"fail_policy",
|
|
165
|
+
],
|
|
166
|
+
},
|
|
167
|
+
held_payment: {
|
|
168
|
+
eventCap: 7,
|
|
169
|
+
keys: ["amount", "fees", "on_cancel", "payer", "payee", "release"],
|
|
170
|
+
referenceableExits: ["release"],
|
|
171
|
+
required: ["payer", "payee", "amount", "release"],
|
|
172
|
+
},
|
|
173
|
+
instant_transfer: {
|
|
174
|
+
eventCap: 3,
|
|
175
|
+
keys: ["amount", "fees", "payer", "payee"],
|
|
176
|
+
referenceableExits: [],
|
|
177
|
+
required: ["payer", "payee", "amount"],
|
|
178
|
+
},
|
|
179
|
+
metered: {
|
|
180
|
+
eventCap: 14,
|
|
181
|
+
keys: ["close_by", "payer", "payee", "rates"],
|
|
182
|
+
maxRates: 14,
|
|
183
|
+
referenceableExits: [],
|
|
184
|
+
required: ["payer", "payee", "rates", "close_by"],
|
|
185
|
+
},
|
|
186
|
+
pooled_split: {
|
|
187
|
+
eventCap: 14,
|
|
188
|
+
keys: ["amount", "payer", "payout_due", "split"],
|
|
189
|
+
maxRecipients: 7,
|
|
190
|
+
referenceableExits: [],
|
|
191
|
+
required: ["payer", "amount", "split", "payout_due"],
|
|
192
|
+
},
|
|
193
|
+
premium_forward: {
|
|
194
|
+
eventCap: 6,
|
|
195
|
+
keys: [
|
|
196
|
+
"amount",
|
|
197
|
+
"bind",
|
|
198
|
+
"carrier",
|
|
199
|
+
"commission",
|
|
200
|
+
"endorsement",
|
|
201
|
+
"endorsement_policy",
|
|
202
|
+
"lapse_policy",
|
|
203
|
+
"on_cancel",
|
|
204
|
+
"payer",
|
|
205
|
+
"policy_ref",
|
|
206
|
+
"renewal_due",
|
|
207
|
+
"renewal_policy",
|
|
208
|
+
],
|
|
209
|
+
referenceableExits: [],
|
|
210
|
+
required: ["payer", "carrier", "amount", "bind"],
|
|
211
|
+
},
|
|
212
|
+
recurring_collection: {
|
|
213
|
+
eventCap: 0,
|
|
214
|
+
keys: [
|
|
215
|
+
"attempt_policy",
|
|
216
|
+
"failure_policy",
|
|
217
|
+
"mandate",
|
|
218
|
+
"obligation",
|
|
219
|
+
"period_idempotency",
|
|
220
|
+
"retry_policy",
|
|
221
|
+
],
|
|
222
|
+
referenceableExits: [],
|
|
223
|
+
required: [
|
|
224
|
+
"obligation",
|
|
225
|
+
"mandate",
|
|
226
|
+
"attempt_policy",
|
|
227
|
+
"period_idempotency",
|
|
228
|
+
"retry_policy",
|
|
229
|
+
"failure_policy",
|
|
230
|
+
],
|
|
231
|
+
},
|
|
232
|
+
rotating_pool: {
|
|
233
|
+
eventCap: 3,
|
|
234
|
+
keys: [
|
|
235
|
+
"contribution",
|
|
236
|
+
"count",
|
|
237
|
+
"default_policy",
|
|
238
|
+
"every",
|
|
239
|
+
"exit_policy",
|
|
240
|
+
"first_due",
|
|
241
|
+
"guarantee_policy",
|
|
242
|
+
"guarantor",
|
|
243
|
+
"members",
|
|
244
|
+
"payout_order",
|
|
245
|
+
],
|
|
246
|
+
referenceableExits: [],
|
|
247
|
+
required: [
|
|
248
|
+
"members",
|
|
249
|
+
"contribution",
|
|
250
|
+
"count",
|
|
251
|
+
"every",
|
|
252
|
+
"first_due",
|
|
253
|
+
"payout_order",
|
|
254
|
+
"default_policy",
|
|
255
|
+
"guarantee_policy",
|
|
256
|
+
"exit_policy",
|
|
257
|
+
],
|
|
258
|
+
},
|
|
259
|
+
scheduled: {
|
|
260
|
+
eventCap: 3,
|
|
261
|
+
keys: [
|
|
262
|
+
"advance_to",
|
|
263
|
+
"amount",
|
|
264
|
+
"count",
|
|
265
|
+
"debtor",
|
|
266
|
+
"delinquency_policy",
|
|
267
|
+
"every",
|
|
268
|
+
"first_due",
|
|
269
|
+
"mode",
|
|
270
|
+
"partial_payment",
|
|
271
|
+
"payer",
|
|
272
|
+
"payee",
|
|
273
|
+
"refund_policy",
|
|
274
|
+
"repayment_matching",
|
|
275
|
+
"reschedule_policy",
|
|
276
|
+
],
|
|
277
|
+
referenceableExits: ["obligation"],
|
|
278
|
+
required: ["payer", "payee", "amount", "count", "every", "first_due"],
|
|
279
|
+
},
|
|
280
|
+
settlement_batch: {
|
|
281
|
+
eventCap: 1,
|
|
282
|
+
keys: [
|
|
283
|
+
"close_trigger",
|
|
284
|
+
"external_reversal_offsets",
|
|
285
|
+
"fee_entries",
|
|
286
|
+
"negative_position",
|
|
287
|
+
"payout_destination",
|
|
288
|
+
"payout_acknowledgement",
|
|
289
|
+
"payout_beneficiary_ref",
|
|
290
|
+
"settlement_account",
|
|
291
|
+
"source_capture_refs",
|
|
292
|
+
],
|
|
293
|
+
referenceableExits: [],
|
|
294
|
+
required: [
|
|
295
|
+
"settlement_account",
|
|
296
|
+
"source_capture_refs",
|
|
297
|
+
"fee_entries",
|
|
298
|
+
"external_reversal_offsets",
|
|
299
|
+
"close_trigger",
|
|
300
|
+
"payout_destination",
|
|
301
|
+
"negative_position",
|
|
302
|
+
"payout_acknowledgement",
|
|
303
|
+
"payout_beneficiary_ref",
|
|
304
|
+
],
|
|
305
|
+
},
|
|
306
|
+
swap: {
|
|
307
|
+
eventCap: 10,
|
|
308
|
+
keys: ["amounts", "between", "dispute", "fees", "release"],
|
|
309
|
+
referenceableExits: [],
|
|
310
|
+
required: ["between", "amounts", "release"],
|
|
311
|
+
},
|
|
312
|
+
weighted_distribution: {
|
|
313
|
+
eventCap: 1,
|
|
314
|
+
keys: [
|
|
315
|
+
"amount",
|
|
316
|
+
"correction_policy",
|
|
317
|
+
"max_recipients",
|
|
318
|
+
"recipient",
|
|
319
|
+
"record_at",
|
|
320
|
+
"rounding_policy",
|
|
321
|
+
"snapshot",
|
|
322
|
+
"source",
|
|
323
|
+
"weight",
|
|
324
|
+
"withholding_policy",
|
|
325
|
+
],
|
|
326
|
+
referenceableExits: [],
|
|
327
|
+
required: [
|
|
328
|
+
"source",
|
|
329
|
+
"recipient",
|
|
330
|
+
"amount",
|
|
331
|
+
"weight",
|
|
332
|
+
"max_recipients",
|
|
333
|
+
"record_at",
|
|
334
|
+
"snapshot",
|
|
335
|
+
"rounding_policy",
|
|
336
|
+
"withholding_policy",
|
|
337
|
+
"correction_policy",
|
|
338
|
+
],
|
|
339
|
+
},
|
|
340
|
+
};
|
package/src/ast.ts
CHANGED
|
@@ -125,9 +125,8 @@ export interface PortRefExpr {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
/**
|
|
128
|
-
* `retention.release`, one settlement naming another settlement's
|
|
129
|
-
*
|
|
130
|
-
* check time, never by a caller at runtime.
|
|
128
|
+
* `retention.release`, one settlement naming another settlement's declared
|
|
129
|
+
* referenceable exit. The checker resolves it wholly before lowering.
|
|
131
130
|
*/
|
|
132
131
|
export interface SettlementRefExpr {
|
|
133
132
|
readonly kind: "settlement_ref";
|