@hyperscale0/hsx 2.4.1 → 3.0.1
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 +4 -406
- package/README.md +3 -92
- package/dist/src/ast.d.ts +99 -310
- package/dist/src/ast.d.ts.map +1 -1
- package/dist/src/ast.js +16 -69
- package/dist/src/ast.js.map +1 -1
- package/dist/src/cli.d.ts +6 -19
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +77 -315
- package/dist/src/cli.js.map +1 -1
- package/dist/src/compile.d.ts +23 -73
- package/dist/src/compile.d.ts.map +1 -1
- package/dist/src/compile.js +1113 -148
- package/dist/src/compile.js.map +1 -1
- package/dist/src/cost.d.ts +8 -77
- package/dist/src/cost.d.ts.map +1 -1
- package/dist/src/cost.js +13 -422
- package/dist/src/cost.js.map +1 -1
- package/dist/src/format.d.ts +8 -7
- package/dist/src/format.d.ts.map +1 -1
- package/dist/src/format.js +9 -175
- package/dist/src/format.js.map +1 -1
- package/dist/src/headers.d.ts +35 -0
- package/dist/src/headers.d.ts.map +1 -0
- package/dist/src/headers.js +108 -0
- package/dist/src/headers.js.map +1 -0
- package/dist/src/index.d.ts +6 -12
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -9
- package/dist/src/index.js.map +1 -1
- package/dist/src/lex.d.ts +8 -28
- package/dist/src/lex.d.ts.map +1 -1
- package/dist/src/lex.js +88 -146
- package/dist/src/lex.js.map +1 -1
- package/dist/src/parse.d.ts +4 -17
- package/dist/src/parse.d.ts.map +1 -1
- package/dist/src/parse.js +402 -1040
- package/dist/src/parse.js.map +1 -1
- package/dist/src/std-bundle.d.ts.map +1 -1
- package/dist/src/std-bundle.js +12 -20
- package/dist/src/std-bundle.js.map +1 -1
- package/dist/src/std-library.d.ts +1 -1
- package/dist/src/std-library.d.ts.map +1 -1
- package/dist/src/std-library.js +1 -5
- package/dist/src/std-library.js.map +1 -1
- package/dist/src/tunables.d.ts +7 -0
- package/dist/src/tunables.d.ts.map +1 -0
- package/dist/src/tunables.js +26 -0
- package/dist/src/tunables.js.map +1 -0
- package/dist/src/version.d.ts +2 -4
- package/dist/src/version.d.ts.map +1 -1
- package/dist/src/version.js +2 -4
- package/dist/src/version.js.map +1 -1
- package/docs/README.md +179 -41
- package/docs/headers.md +44 -0
- package/examples/cost-table.json +99 -751
- package/examples/library.hsx +59 -0
- package/package.json +9 -17
- package/src/ast.ts +82 -441
- package/src/cli.ts +78 -362
- package/src/compile.ts +1535 -247
- package/src/cost.ts +28 -671
- package/src/format.ts +12 -256
- package/src/headers.ts +126 -0
- package/src/index.ts +7 -39
- package/src/lex.ts +99 -195
- package/src/parse.ts +403 -1209
- package/src/std-bundle.ts +12 -20
- package/src/std-library.ts +2 -7
- package/src/tunables.ts +31 -0
- package/src/version.ts +2 -5
- package/std/approvals.hsx +17 -0
- package/std/cards.hsx +63 -0
- package/std/collections.hsx +31 -0
- package/std/escrow.hsx +43 -0
- package/std/financing.hsx +372 -0
- package/std/insurance.hsx +59 -0
- package/std/lending.hsx +115 -0
- package/std/marketplace.hsx +24 -0
- package/std/money.hsx +195 -0
- package/std/savings.hsx +44 -0
- package/std/travel.hsx +98 -0
- package/std/wallet.hsx +41 -0
- package/dist/src/diagnostics.d.ts +0 -13
- package/dist/src/diagnostics.d.ts.map +0 -1
- package/dist/src/diagnostics.js +0 -587
- package/dist/src/diagnostics.js.map +0 -1
- package/dist/src/emit.d.ts +0 -51
- package/dist/src/emit.d.ts.map +0 -1
- package/dist/src/emit.js +0 -192
- package/dist/src/emit.js.map +0 -1
- package/dist/src/entry-overrides.d.ts +0 -58
- package/dist/src/entry-overrides.d.ts.map +0 -1
- package/dist/src/entry-overrides.js +0 -284
- package/dist/src/entry-overrides.js.map +0 -1
- package/dist/src/ir.d.ts +0 -73
- package/dist/src/ir.d.ts.map +0 -1
- package/dist/src/ir.js +0 -15
- package/dist/src/ir.js.map +0 -1
- package/dist/src/limits.d.ts +0 -23
- package/dist/src/limits.d.ts.map +0 -1
- package/dist/src/limits.js +0 -23
- package/dist/src/limits.js.map +0 -1
- package/dist/src/lsp/server.d.ts +0 -32
- package/dist/src/lsp/server.d.ts.map +0 -1
- package/dist/src/lsp/server.js +0 -391
- package/dist/src/lsp/server.js.map +0 -1
- package/dist/src/modules.d.ts +0 -38
- package/dist/src/modules.d.ts.map +0 -1
- package/dist/src/modules.js +0 -372
- package/dist/src/modules.js.map +0 -1
- package/dist/src/typecheck.d.ts +0 -8
- package/dist/src/typecheck.d.ts.map +0 -1
- package/dist/src/typecheck.js +0 -4160
- package/dist/src/typecheck.js.map +0 -1
- package/docs/guide/01-first-program.md +0 -24
- package/docs/guide/02-money.md +0 -25
- package/docs/guide/03-instruments.md +0 -93
- package/docs/guide/04-lifecycles.md +0 -40
- package/docs/guide/05-fees-and-splits.md +0 -45
- package/docs/guide/06-schedules.md +0 -26
- package/docs/guide/07-composition.md +0 -52
- package/docs/guide/08-writing-a-module.md +0 -85
- package/docs/guide/09-cost.md +0 -24
- package/docs/guide/10-diagnostics.md +0 -27
- package/docs/llms-full.txt +0 -3684
- package/docs/llms.txt +0 -44
- package/docs/piece-plans.md +0 -120
- package/docs/playground.md +0 -55
- package/docs/reference/cli.md +0 -36
- package/docs/reference/diagnostics.md +0 -901
- package/docs/reference/grammar.md +0 -38
- package/docs/reference/std/advance.md +0 -112
- package/docs/reference/std/cancellable_booking.md +0 -159
- package/docs/reference/std/captured_payment.md +0 -115
- package/docs/reference/std/conditional_disbursement.md +0 -101
- package/docs/reference/std/credit_facility.md +0 -108
- package/docs/reference/std/held_payment.md +0 -173
- package/docs/reference/std/instant_transfer.md +0 -97
- package/docs/reference/std/metered.md +0 -89
- package/docs/reference/std/pooled_split.md +0 -95
- package/docs/reference/std/premium_forward.md +0 -119
- package/docs/reference/std/reconciled_payout.md +0 -103
- package/docs/reference/std/rotating_pool.md +0 -130
- package/docs/reference/std/scheduled.md +0 -136
- package/docs/reference/std/security_deposit.md +0 -138
- package/docs/reference/std/settlement_batch.md +0 -123
- package/docs/reference/std/swap.md +0 -133
- package/docs/reference/std/threshold_pool.md +0 -138
- package/docs/reference/std/weighted_distribution.md +0 -135
- package/docs/reference/types.md +0 -61
- package/docs/reference/udl-output.md +0 -13
- package/examples/01-first-program/README.md +0 -45
- package/examples/01-first-program/tip-jar.hsx +0 -17
- package/examples/02-imports-and-modules/README.md +0 -96
- package/examples/02-imports-and-modules/photo-booth.hsx +0 -37
- package/examples/03-diagnostics/README.md +0 -68
- package/examples/03-diagnostics/corner-shop-fixed.hsx +0 -22
- package/examples/03-diagnostics/corner-shop.hsx +0 -19
- package/examples/04-complete-product/README.md +0 -84
- package/examples/04-complete-product/study-hall.hsx +0 -67
- package/examples/05-authored-instrument/README.md +0 -5
- package/examples/05-authored-instrument/payment.hsx +0 -37
- package/examples/05-watch-club/README.md +0 -6
- package/examples/05-watch-club/watch-club.hsx +0 -123
- package/examples/README.md +0 -48
- package/examples/advance/README.md +0 -3
- package/examples/advance/advance.hsx +0 -13
- package/examples/advance/advance.udl +0 -367
- package/examples/cancellable_booking/README.md +0 -3
- package/examples/cancellable_booking/cancellable_booking.hsx +0 -14
- package/examples/cancellable_booking/cancellable_booking.udl +0 -413
- package/examples/captured_payment/README.md +0 -3
- package/examples/captured_payment/captured_payment.hsx +0 -17
- package/examples/captured_payment/captured_payment.udl +0 -686
- package/examples/conditional_disbursement/README.md +0 -3
- package/examples/conditional_disbursement/conditional_disbursement.hsx +0 -15
- package/examples/conditional_disbursement/conditional_disbursement.udl +0 -418
- package/examples/credit_facility/README.md +0 -3
- package/examples/credit_facility/credit_facility.hsx +0 -24
- package/examples/credit_facility/credit_facility.udl +0 -1396
- package/examples/held_payment/README.md +0 -3
- package/examples/held_payment/held_payment.hsx +0 -13
- package/examples/held_payment/held_payment.udl +0 -569
- package/examples/instant_transfer/README.md +0 -3
- package/examples/instant_transfer/instant_transfer.hsx +0 -16
- package/examples/instant_transfer/instant_transfer.udl +0 -376
- package/examples/metered/README.md +0 -3
- package/examples/metered/metered.hsx +0 -13
- package/examples/metered/metered.udl +0 -253
- package/examples/pooled_split/README.md +0 -3
- package/examples/pooled_split/pooled_split.hsx +0 -15
- package/examples/pooled_split/pooled_split.udl +0 -432
- package/examples/premium_forward/README.md +0 -3
- package/examples/premium_forward/premium_forward.hsx +0 -19
- package/examples/premium_forward/premium_forward.udl +0 -604
- package/examples/reconciled_payout/README.md +0 -3
- package/examples/reconciled_payout/reconciled_payout.hsx +0 -13
- package/examples/reconciled_payout/reconciled_payout.udl +0 -312
- package/examples/rotating_pool/README.md +0 -3
- package/examples/rotating_pool/rotating_pool.hsx +0 -18
- package/examples/rotating_pool/rotating_pool.udl +0 -4370
- package/examples/scheduled/README.md +0 -3
- package/examples/scheduled/scheduled.hsx +0 -12
- package/examples/scheduled/scheduled.udl +0 -355
- package/examples/security_deposit/README.md +0 -3
- package/examples/security_deposit/security_deposit.hsx +0 -21
- package/examples/security_deposit/security_deposit.udl +0 -320
- package/examples/settlement_batch/README.md +0 -3
- package/examples/settlement_batch/settlement_batch.hsx +0 -19
- package/examples/settlement_batch/settlement_batch.udl +0 -757
- package/examples/swap/README.md +0 -3
- package/examples/swap/swap.hsx +0 -19
- package/examples/swap/swap.udl +0 -892
- package/examples/threshold_pool/README.md +0 -3
- package/examples/threshold_pool/threshold_pool.hsx +0 -16
- package/examples/threshold_pool/threshold_pool.udl +0 -680
- package/examples/weighted_distribution/README.md +0 -3
- package/examples/weighted_distribution/weighted_distribution.hsx +0 -20
- package/examples/weighted_distribution/weighted_distribution.udl +0 -348
- package/skills/hsx/SKILL.md +0 -449
- package/src/diagnostics.ts +0 -620
- package/src/emit.ts +0 -282
- package/src/entry-overrides.ts +0 -428
- package/src/ir.ts +0 -113
- package/src/limits.ts +0 -22
- package/src/lsp/server.ts +0 -460
- package/src/modules.ts +0 -452
- package/src/typecheck.ts +0 -5515
- package/std/SEMANTICS.md +0 -44
- package/std/money_flows/advance.hsx +0 -235
- package/std/money_flows/cancellable_booking.hsx +0 -402
- package/std/money_flows/captured_payment.hsx +0 -220
- package/std/money_flows/conditional_disbursement.hsx +0 -226
- package/std/money_flows/credit_facility.hsx +0 -214
- package/std/money_flows/held_payment.hsx +0 -812
- package/std/money_flows/index.hsx +0 -4
- package/std/money_flows/instant_transfer.hsx +0 -231
- package/std/money_flows/metered.hsx +0 -104
- package/std/money_flows/pooled_split.hsx +0 -109
- package/std/money_flows/premium_forward.hsx +0 -307
- package/std/money_flows/reconciled_payout.hsx +0 -119
- package/std/money_flows/rotating_pool.hsx +0 -305
- package/std/money_flows/scheduled.hsx +0 -599
- package/std/money_flows/security_deposit.hsx +0 -248
- package/std/money_flows/settlement_batch.hsx +0 -173
- package/std/money_flows/swap.hsx +0 -1192
- package/std/money_flows/threshold_pool.hsx +0 -307
- package/std/money_flows/weighted_distribution.hsx +0 -237
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"std-bundle.js","sourceRoot":"","sources":["../../src/std-bundle.ts"],"names":[],"mappings":"AAAA,oEAAoE;AAEpE,MAAM,CAAC,MAAM,iBAAiB,GAAgC,IAAI,GAAG,CAAiB;IACpF,CAAC,
|
|
1
|
+
{"version":3,"file":"std-bundle.js","sourceRoot":"","sources":["../../src/std-bundle.ts"],"names":[],"mappings":"AAAA,oEAAoE;AAEpE,MAAM,CAAC,MAAM,iBAAiB,GAAgC,IAAI,GAAG,CAAiB;IACpF,CAAC,eAAe,EAAE,u8BAAu8B,CAAC;IAC19B,CAAC,WAAW,EAAE,i5GAAi5G,CAAC;IACh6G,CAAC,iBAAiB,EAAE,suEAAsuE,CAAC;IAC3vE,CAAC,YAAY,EAAE,66DAA66D,CAAC;IAC77D,CAAC,eAAe,EAAE,82gCAA82gC,CAAC;IACj4gC,CAAC,eAAe,EAAE,ojGAAojG,CAAC;IACvkG,CAAC,aAAa,EAAE,ohPAAohP,CAAC;IACriP,CAAC,iBAAiB,EAAE,ujCAAujC,CAAC;IAC5kC,CAAC,WAAW,EAAE,2tWAA2tW,CAAC;IAC1uW,CAAC,aAAa,EAAE,qmGAAqmG,CAAC;IACtnG,CAAC,YAAY,EAAE,0zLAA0zL,CAAC;IAC10L,CAAC,YAAY,EAAE,w1DAAw1D,CAAC;CACz2D,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"std-library.d.ts","sourceRoot":"","sources":["../../src/std-library.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"std-library.d.ts","sourceRoot":"","sources":["../../src/std-library.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CAC5C;AACD,eAAO,MAAM,sBAAsB,EAAE,eAEpC,CAAC"}
|
package/dist/src/std-library.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { BUNDLED_STD_FILES } from "./std-bundle.js";
|
|
2
2
|
export const bundledStandardLibrary = {
|
|
3
|
-
source(
|
|
4
|
-
if (specifier !== "std/money_flows")
|
|
5
|
-
return undefined;
|
|
6
|
-
return BUNDLED_STD_FILES.get(`money_flows/${name}.hsx`);
|
|
7
|
-
},
|
|
3
|
+
source: (header) => BUNDLED_STD_FILES.get(`${header}.hsx`),
|
|
8
4
|
};
|
|
9
5
|
//# sourceMappingURL=std-library.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"std-library.js","sourceRoot":"","sources":["../../src/std-library.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"std-library.js","sourceRoot":"","sources":["../../src/std-library.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAIpD,MAAM,CAAC,MAAM,sBAAsB,GAAoB;IACrD,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG,MAAM,MAAM,CAAC;CAC3D,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Expr } from "./ast.ts";
|
|
2
|
+
/** Bounds use UDL units: minor units, basis points and milliseconds. */
|
|
3
|
+
export declare function tunableBounds(type: Expr): {
|
|
4
|
+
minimum: number | string;
|
|
5
|
+
maximum: number | string;
|
|
6
|
+
} | undefined;
|
|
7
|
+
//# sourceMappingURL=tunables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tunables.d.ts","sourceRoot":"","sources":["../../src/tunables.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC,wEAAwE;AACxE,wBAAgB,aAAa,CAC3B,IAAI,EAAE,IAAI,GACT;IAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,GAAG,SAAS,CAyBpE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Bounds use UDL units: minor units, basis points and milliseconds. */
|
|
2
|
+
export function tunableBounds(type) {
|
|
3
|
+
const name = type.kind === "call" || type.kind === "type"
|
|
4
|
+
? type.name
|
|
5
|
+
: type.kind === "name"
|
|
6
|
+
? type.value
|
|
7
|
+
: "";
|
|
8
|
+
if (name === "money")
|
|
9
|
+
return { minimum: "0", maximum: "999999999999999999" };
|
|
10
|
+
if (name === "percent")
|
|
11
|
+
return { minimum: 0, maximum: 10000 };
|
|
12
|
+
if (name === "duration")
|
|
13
|
+
return { minimum: 1, maximum: Number.MAX_SAFE_INTEGER };
|
|
14
|
+
if (name !== "integer")
|
|
15
|
+
return;
|
|
16
|
+
if (type.kind === "call") {
|
|
17
|
+
const numbers = type.args.map((arg) => arg.kind === "number" ? Number(arg.value) : NaN);
|
|
18
|
+
if (numbers.length !== 2 ||
|
|
19
|
+
numbers.some((value) => !Number.isSafeInteger(value)) ||
|
|
20
|
+
numbers[0] > numbers[1])
|
|
21
|
+
throw new Error("integer tunable needs a minimum and maximum");
|
|
22
|
+
return { minimum: numbers[0], maximum: numbers[1] };
|
|
23
|
+
}
|
|
24
|
+
return { minimum: 0, maximum: Number.MAX_SAFE_INTEGER };
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=tunables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tunables.js","sourceRoot":"","sources":["../../src/tunables.ts"],"names":[],"mappings":"AAEA,wEAAwE;AACxE,MAAM,UAAU,aAAa,CAC3B,IAAU;IAEV,MAAM,IAAI,GACR,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM;QAC1C,CAAC,CAAC,IAAI,CAAC,IAAI;QACX,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM;YACpB,CAAC,CAAC,IAAI,CAAC,KAAK;YACZ,CAAC,CAAC,EAAE,CAAC;IACX,IAAI,IAAI,KAAK,OAAO;QAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAC7E,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC9D,IAAI,IAAI,KAAK,UAAU;QACrB,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,gBAAgB,EAAE,CAAC;IAC1D,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO;IAC/B,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QACzB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CACpC,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAChD,CAAC;QACF,IACE,OAAO,CAAC,MAAM,KAAK,CAAC;YACpB,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YACrD,OAAO,CAAC,CAAC,CAAE,GAAG,OAAO,CAAC,CAAC,CAAE;YAEzB,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACjE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAE,EAAE,CAAC;IACxD,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,gBAAgB,EAAE,CAAC;AAC1D,CAAC"}
|
package/dist/src/version.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
3
|
-
/** Canonical UDL contract version emitted by this compiler. */
|
|
4
|
-
export declare const HSX_TARGET_UDL_VERSION = 1;
|
|
1
|
+
export declare const HSX_VERSION = "3.0.1";
|
|
2
|
+
export declare const HSX_TARGET_UDL_VERSION = 3;
|
|
5
3
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,UAAU,CAAC;AACnC,eAAO,MAAM,sBAAsB,IAAI,CAAC"}
|
package/dist/src/version.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export const
|
|
3
|
-
/** Canonical UDL contract version emitted by this compiler. */
|
|
4
|
-
export const HSX_TARGET_UDL_VERSION = 1;
|
|
1
|
+
export const HSX_VERSION = "3.0.1";
|
|
2
|
+
export const HSX_TARGET_UDL_VERSION = 3;
|
|
5
3
|
//# sourceMappingURL=version.js.map
|
package/dist/src/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC;AACnC,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC"}
|
package/docs/README.md
CHANGED
|
@@ -1,41 +1,179 @@
|
|
|
1
|
-
# HSX
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
`
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
1
|
+
# HSX 3
|
|
2
|
+
|
|
3
|
+
A program declares parties and objects from headers. Currency defaults to SAR.
|
|
4
|
+
A party binds its account and optional role at admission. A program never carries
|
|
5
|
+
account ids, reference filters, credentials or bank beneficiary ids.
|
|
6
|
+
|
|
7
|
+
```hsx
|
|
8
|
+
program shop "Shop"
|
|
9
|
+
use marketplace
|
|
10
|
+
use escrow
|
|
11
|
+
party buyer: person
|
|
12
|
+
party seller: business
|
|
13
|
+
listing = marketplace.listing { seller: seller }
|
|
14
|
+
order = marketplace.order { listing: listing, buyer: buyer }
|
|
15
|
+
sale = escrow.hold {
|
|
16
|
+
payer: buyer, payee: seller, for: order, accept_within: 48h
|
|
17
|
+
fee { seller: 1% cap 750 SAR, tax: 15% }
|
|
18
|
+
dispute { refund_after: return_verified }
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The header defines the available policies. The company chooses percentages, amounts, durations,
|
|
23
|
+
parties and typed references. `funds: sale` links the stored records through the
|
|
24
|
+
library's declared reference type. References can name a child, such as
|
|
25
|
+
`receipt: plan.settlement`. A header tunable declared `ref<T>[]` accepts one object or a list of up to 16
|
|
26
|
+
objects of type T. `on: [plan_3, plan_6]` creates one late-charge or collections
|
|
27
|
+
policy. Its references can point into either plan; selections can span both.
|
|
28
|
+
A plain `ref<T>` accepts one object only.
|
|
29
|
+
Imports are `use header`; there are no file imports, macros or executable strings.
|
|
30
|
+
|
|
31
|
+
Amounts use `750 SAR`; percentages use `2.5%`; durations use `48h`, `3d`, or `1w`.
|
|
32
|
+
Dates use `2026-11-28` or a timestamp with an explicit offset. Money has at most two
|
|
33
|
+
decimal places and percentages at most two. The compiler uses integer minor units
|
|
34
|
+
and basis points. Fee and tax calculations round down. Split percentages sum to
|
|
35
|
+
100%; the last declared recipient receives the rounding remainder. Finite
|
|
36
|
+
schedules use positions 1 through n and put the division remainder in position 1.
|
|
37
|
+
Tax binds `programTax`. Fees default to `programOperator`. Fine, recovery and
|
|
38
|
+
residual destinations are party tunables. Unused `programFines` and `programCosts`
|
|
39
|
+
bindings are omitted.
|
|
40
|
+
|
|
41
|
+
Every action is public with a generated camelCase name: `createSale`,
|
|
42
|
+
`acceptSale`. `expose sale.accept as acceptDelivery` renames it;
|
|
43
|
+
`hide sale.refund` removes it from the public API. Visibility grants no authority.
|
|
44
|
+
Parent and clock actions still require their executor principal. Exposure paths
|
|
45
|
+
can name children: `hide plan.payment.refund`.
|
|
46
|
+
|
|
47
|
+
Accounts use cash or claim books. A move stays in one book. `account of buyer`
|
|
48
|
+
aliases the default cash account; `account of self` provisions an owned account.
|
|
49
|
+
`account(lender, cash, "capital")` binds a named account.
|
|
50
|
+
`account(buyer, claim, contra, "debt")` declares the borrower's claim contra account.
|
|
51
|
+
`account(seller, cash, external, "bank")` binds the executor-managed bank destination.
|
|
52
|
+
Outstanding debt is an account balance. The library pairs cash repayment with
|
|
53
|
+
claim reduction and represents receipts as immutable child records. Cash and loss
|
|
54
|
+
shares round down; the declared residual account receives leftover minor units.
|
|
55
|
+
|
|
56
|
+
The four transfer instructions are create, reserve, post and void under
|
|
57
|
+
`internal_transfer`. A captured transfer exposes reserved, posted, settled,
|
|
58
|
+
reversed or voided status. Voided means a released reservation. Settled means
|
|
59
|
+
provider confirmation, not an internal account balance change.
|
|
60
|
+
|
|
61
|
+
For a new record type, declare `instrument name { fields { ... } lifecycle { ... }
|
|
62
|
+
action create { ... } }`. Fields are `money`, `account of buyer`, `ref<order>`,
|
|
63
|
+
`date`, `duration`, `text`, `integer`, `percent`, `boolean`, `enum(a, b)` or
|
|
64
|
+
`list(date, 12)`. `?` makes a field optional; `= value` fixes a constant or a typed
|
|
65
|
+
calculation. Actions declare `input { reason: text }`. Headers and expert records
|
|
66
|
+
write ordered requirements and moves as expressions:
|
|
67
|
+
|
|
68
|
+
```hsx
|
|
69
|
+
requires self.payer == self.order.buyer
|
|
70
|
+
requires self.order in [placed]
|
|
71
|
+
requires approval by underwriter
|
|
72
|
+
moves self.price from payer to self.held
|
|
73
|
+
moves self.price from self.held to payee fee fee
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Comparisons accept `==`, `!=`, `<`, `<=`, `>` and `>=`. A path beginning with
|
|
77
|
+
`self`, `input` or `party` is a field operand; a quoted string, amount or number is
|
|
78
|
+
a literal. `requires unique "order" on [self.order]` fixes an identity namespace.
|
|
79
|
+
`requires count of { instrument: child, reference: "parent", anchor: self.id,
|
|
80
|
+
states: [pending], limit: 12 } == 12` checks a typed selection; `sum "amount" of`
|
|
81
|
+
uses the same selection syntax. `invariants` accepts these requirement expressions.
|
|
82
|
+
`requires hours self.now between 8 and 20 timezone "Asia/Riyadh"` checks local hours.
|
|
83
|
+
`requires evidence self.payer family registry check ownership result verified
|
|
84
|
+
maxAge 1d` requires a recent completed provider check.
|
|
85
|
+
|
|
86
|
+
`moves reserve amount from payer to payee capture receipt` reserves a transfer;
|
|
87
|
+
`moves post self.receipt` posts it and `moves void self.receipt` releases it.
|
|
88
|
+
`moves amount from payer shares shares` expands a declared split. Optional `fee`,
|
|
89
|
+
`capture` and `key` modifiers follow a move in that order. Repeated clauses keep
|
|
90
|
+
their declaration order. The JSON-like clause form remains accepted and lowers
|
|
91
|
+
to the same [UDL clauses](../../udl/spec/README.md).
|
|
92
|
+
They cannot add kernel instructions. `at(list, position)` reads a dated list;
|
|
93
|
+
`aggregate(selection, "amount")` sums selected money; `ratio(amount, weight, total)`
|
|
94
|
+
floors a weighted share. `records` declares child types. `invoke` can create a child
|
|
95
|
+
with typed input in the same transaction.
|
|
96
|
+
|
|
97
|
+
An `approval` tunable binds a party and emits a decision record for each gated
|
|
98
|
+
action, including child actions. `approval: underwriter` needs no separate object.
|
|
99
|
+
Generated records are named `<object>_<action>_decision`; child names retain their
|
|
100
|
+
object prefix. `requires approval by approver for approve is declined` reuses the
|
|
101
|
+
approve decision for a declined branch. Decisions keep the target action's typed
|
|
102
|
+
material input and expiry. `approvals.decision` remains available to attach an
|
|
103
|
+
explicit decision to an action without a library approval tunable. A decision
|
|
104
|
+
alone does not add a requirement to that action. Approval declarations with
|
|
105
|
+
`input: "material"` infer immutable material fields from the target action's input.
|
|
106
|
+
The compiler removes branches excluded by fixed enum tunables. An invalid program reports its source line
|
|
107
|
+
and a correction. No artifact is returned with diagnostics.
|
|
108
|
+
|
|
109
|
+
## Financing policies
|
|
110
|
+
|
|
111
|
+
`financing.installments` keeps principal and fixed flat profit as claims from
|
|
112
|
+
activation. The company chooses where funding goes and when profit becomes earned.
|
|
113
|
+
All choices use accounts, calculations and moves in the same two books.
|
|
114
|
+
|
|
115
|
+
| Tunable | Default | Selected behavior |
|
|
116
|
+
| ---------------------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
117
|
+
| `disburse_to` | `funds` | `funds` pays down payment and principal into the hold and confirms it. `borrower` credits principal to the borrower's balance. |
|
|
118
|
+
| `profit_earned` | `on_payment` | `on_payment` collects unearned profit on payment. `by_schedule` moves unearned claims to earned claims at each slice's date. `at_disbursement` makes that move at activation. Cash arrives only on payment. |
|
|
119
|
+
| `apply` | `fines_profit_principal` | Collect assessed fines by overdue date, then evidenced costs, then each slice in position order, profit before principal. `principal_profit` collects each slice in position order, principal before profit. `pro_rata` uses the slice's fixed principal:profit ratio, caps each side by its collectible balance, and assigns the remainder without stranding cash. |
|
|
120
|
+
| `payoff_rebate` | `100%` | Reverse this share of unearned profit to borrower debt. Collect the remainder and all earned profit with outstanding principal. |
|
|
121
|
+
| `late_charge.fines_to` | `programOperator` | Receive fine cash and fund its refunds. |
|
|
122
|
+
| `late_charge.costs_to` | `programOperator` | Receive evidenced recovery cash and fund its refunds. |
|
|
123
|
+
| `collections.case.fee` | `20%` | After payment succeeds, transfer this share of the payment amount from plan capital to the agency. |
|
|
124
|
+
| `lending.distribution.residual_to` | `programOperator` | Receive the cash remainder and own the claim loss remainder after weighted distribution. |
|
|
125
|
+
|
|
126
|
+
Each slice owns separate unearned and earned claim accounts. Scheduled recognition
|
|
127
|
+
uses a dated child record so a partial payment cannot disable the maturity clock.
|
|
128
|
+
A normal payment collects only earned profit for the schedule and disbursement
|
|
129
|
+
choices; payoff can also collect non-rebated unearned profit. Partial fines and
|
|
130
|
+
costs stay assessed until their receivable reaches zero. Immutable receipts let
|
|
131
|
+
a refund restore only what that payment collected. The plan's payment receipt
|
|
132
|
+
records actual principal and profit after all ordered collections finish.
|
|
133
|
+
Write-off moves principal and earned profit claims to loss and reverses unearned
|
|
134
|
+
profit to debt. There is no provision policy or write-off tunable.
|
|
135
|
+
|
|
136
|
+
## Header branches and bounds
|
|
137
|
+
|
|
138
|
+
A header may select action clauses at compile time:
|
|
139
|
+
|
|
140
|
+
```hsx
|
|
141
|
+
when disburse_to is borrower {
|
|
142
|
+
moves self.principal from self.capital to self.borrower
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
`when <enum tunable> is <value>` accepts requirements, calculations, moves and
|
|
147
|
+
invocations, including nested branches. The compiler emits only the selected
|
|
148
|
+
clauses and preserves their order within each UDL phase. Lifecycle and actor
|
|
149
|
+
clauses stay outside branches. Calculations and requirements run before moves;
|
|
150
|
+
invocations run after moves. A collections fee therefore uses an internal action
|
|
151
|
+
invoked after payment. Clock and parent actions have no public API name.
|
|
152
|
+
|
|
153
|
+
`integer(1, 366)` declares an inclusive tunable bound. The compiler-owned manifest
|
|
154
|
+
publishes enum values, numeric minima and maxima, and cross-tunable constraints.
|
|
155
|
+
Bounds use minor units for money, basis points for percentages and milliseconds
|
|
156
|
+
for durations. Money spans 0 through 999999999999999999 minor units; percentages
|
|
157
|
+
span 0 through 10000 basis points. Durations start at 1 millisecond. Integers
|
|
158
|
+
default to 0 through 9007199254740991 unless their declaration narrows the range. For example, `constraints { contact_from: less_than(contact_until) }`
|
|
159
|
+
requires a valid hours interval. `at_most` and `greater_than` are also supported.
|
|
160
|
+
A refusal names the tunable. Empty `all(type)` selections lower to zero aggregates
|
|
161
|
+
or no invocations, so a plan does not require a late-charge object.
|
|
162
|
+
|
|
163
|
+
The permutation spec builds a dependency-closed program per object. It takes each
|
|
164
|
+
enum value and the minimum, default or example value, and a large numeric value.
|
|
165
|
+
It uses the full product through 512 cases and pair coverage above that. Invalid
|
|
166
|
+
bound combinations must refuse with a named diagnostic. Valid cases must produce
|
|
167
|
+
valid UDL and retain public names on every caller action. This proves compilation,
|
|
168
|
+
not executed balances or bank settlement.
|
|
169
|
+
|
|
170
|
+
Build with `hsx build company.hsx --out company.udl.json`; check with
|
|
171
|
+
`hsx check company.hsx`; print instruction counts with `hsx cost company.hsx`.
|
|
172
|
+
Print the compiler-owned object manifest with `hsx headers --json`.
|
|
173
|
+
The compiler API is `compile(source)`. A valid result contains `artifacts.document`,
|
|
174
|
+
`costManifest` and source origins. Instruction counts are not bank tariffs or a
|
|
175
|
+
promise of provider execution cost.
|
|
176
|
+
|
|
177
|
+
The [header inventory](headers.md) is generated from the declarations. The
|
|
178
|
+
[executable inventory](../examples/library.hsx) exercises every public object.
|
|
179
|
+
The [playground](../playground/index.html) compiles locally in the browser.
|
package/docs/headers.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Header inventory
|
|
2
|
+
|
|
3
|
+
Each company selects library policies through typed tunables.
|
|
4
|
+
`ref<T>[]` accepts one reference or up to 16 references as one policy. `approval` accepts a party and generates the required decision records.
|
|
5
|
+
|
|
6
|
+
| Object | Tunables |
|
|
7
|
+
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
8
|
+
| money.transfer | `payer: party`, `payee: party`, `amount: money = runtime` |
|
|
9
|
+
| money.hold | `payer: party`, `payee: party`, `amount: money = runtime` |
|
|
10
|
+
| money.split | `payer: party`, `amount: money = runtime`, `shares: split = { programOperator: 100% }` |
|
|
11
|
+
| money.schedule | `payer: party`, `payee: party`, `amount: money = runtime`, `count: integer(1, 366) = 12` |
|
|
12
|
+
| money.pool | `payer: party`, `payee: party`, `target: money`, `closes: date` |
|
|
13
|
+
| money.swap | `first: party`, `second: party`, `first_amount: money`, `second_amount: money`, `expires: date` |
|
|
14
|
+
| money.deposit | `payer: party`, `payee: party`, `amount: money`, `expires: date`, `approval: approval` |
|
|
15
|
+
| money.payout | `payer: party`, `payee: party`, `amount: money = runtime`, `reconcile_within: duration = 3d` |
|
|
16
|
+
| money.metered | `payer: party`, `payee: party`, `unit_price: money`, `units: integer = 1`, `fee: fee = { seller: 0% }` |
|
|
17
|
+
| money.batch | `payer: party`, `payee: party`, `closes: date`, `approval: approval`, `reconcile_within: duration = 3d` |
|
|
18
|
+
| marketplace.listing | `seller: party` |
|
|
19
|
+
| marketplace.order | `listing: ref<marketplace.listing>`, `buyer: party` |
|
|
20
|
+
| escrow.hold | `payer: party`, `payee: party`, `for: ref<marketplace.order>`, `accept_within: duration = 48h`, `fee: fee = { seller: 0%, tax: 0% }`, `dispute: policy = { refund_after: return_verified }` |
|
|
21
|
+
| wallet.balance | `holder: party`, `spend_limit: money = 100000 SAR` |
|
|
22
|
+
| wallet.spend | `wallet: ref<wallet.balance>`, `payee: party` |
|
|
23
|
+
| financing.installments | `months: integer(1, 366)`, `profit: percent`, `disburse_to: enum(funds, borrower) = funds`, `profit_earned: enum(on_payment, by_schedule, at_disbursement) = on_payment`, `apply: enum(fines_profit_principal, principal_profit, pro_rata) = fines_profit_principal`, `payoff_rebate: percent = 100%`, `down_payment: percent = 0%`, `funds: ref`, `approval: approval`, `borrower: party = party(person)`, `capital: party = programOperator`, `profit_to: party = programOperator`, `limits: ref<financing.limits> = object(financing.limits)` |
|
|
24
|
+
| financing.late_charge | `on: ref<financing.installments>[]`, `grace: duration = 3d`, `fine: money = 50 SAR`, `cap: money = 25 SAR`, `fines_to: party = programOperator`, `costs_to: party = programOperator`, `approval: approval = programOperator`, `borrower: party = party(person)` |
|
|
25
|
+
| financing.limits | `per_borrower: money`, `portfolio: money`, `borrower: party = party(person)`, `active_plans: integer = 1` |
|
|
26
|
+
| financing.credit_line | `borrower: party`, `lender: party`, `limit: money`, `expires: date` |
|
|
27
|
+
| financing.advance | `line: ref<financing.credit_line>`, `amount: money = runtime` |
|
|
28
|
+
| lending.round | `borrower: party`, `capital: party`, `plan: ref<financing.installments> = object(financing.installments)`, `months: integer(1, 366) = 3`, `profit: percent = 3%`, `minimum_ticket: money = 100 SAR`, `investor_cap: percent = 20%`, `commitments: ref<lending.commitment> = object(lending.commitment)` |
|
|
29
|
+
| lending.commitment | `round: ref<lending.round>`, `wallet: ref<wallet.balance>`, `investor: party = party(person)` |
|
|
30
|
+
| lending.distribution | `round: ref<lending.round>`, `receipt: ref`, `commitments: ref<lending.commitment> = object(lending.commitment)`, `mode: enum(cash, loss) = cash`, `residual_to: party = programOperator`, `fee: percent = 1%`, `tax: percent = 15%` |
|
|
31
|
+
| insurance.cover | `holder: party`, `insurer: party`, `commission: percent = 0%`, `covers: ref`, `premium: money = runtime` |
|
|
32
|
+
| insurance.claim | `cover: ref<insurance.cover>`, `approved_by: approval` |
|
|
33
|
+
| approvals.decision | `for: ref`, `approved_by: party`, `action: text = "approve"` |
|
|
34
|
+
| collections.case | `on: ref<financing.installments>[]`, `agency: approval`, `overdue: duration = 3d`, `fee: percent = 20%` |
|
|
35
|
+
| collections.contact | `case: ref<collections.case>[]`, `agency: party`, `max_contacts: integer = 10`, `window: duration = 30d`, `contact_from: integer(0, 23) = 8`, `contact_until: integer(1, 23) = 20`, `timezone: text = "Asia/Riyadh"`; contact_from less_than contact_until |
|
|
36
|
+
| travel.package | `price: money`, `supplier_cost: money`, `departure: date`; supplier_cost at_most price |
|
|
37
|
+
| travel.booking | `package: ref<travel.package>`, `buyer: party`, `supplier: approval`, `cover: ref<insurance.cover>`, `deposit: percent = 30%`, `balance_before: duration = 14d`, `confirm_within: duration = 24h`, `tax: percent = 15%`, `early_before: duration = 30d`, `middle_before: duration = 15d`, `middle_penalty: percent = 10%`, `late_penalty: percent = 30%`; early_before greater_than middle_before |
|
|
38
|
+
| cards.cardholder | `holder: party` |
|
|
39
|
+
| cards.card | `holder: ref<cards.cardholder>`, `spend_limit: money` |
|
|
40
|
+
| cards.authorization | `card: ref<cards.card>`, `merchant: party`, `approval: approval` |
|
|
41
|
+
| cards.transaction | `authorization: ref<cards.authorization>` |
|
|
42
|
+
| cards.dispute | `transaction: ref<cards.transaction>`, `approved_by: approval`, `within: duration = 90d` |
|
|
43
|
+
| savings.circle | `contribution: money`, `members: integer(1, 366)`, `starts: date`, `memberships: ref<savings.membership> = object(savings.membership)` |
|
|
44
|
+
| savings.membership | `circle: ref<savings.circle>`, `member: party` |
|