@hyperscale0/hsx 1.0.332 → 1.0.335
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/dist/src/attachment-economics.d.ts +16 -2
- package/dist/src/attachment-economics.d.ts.map +1 -1
- package/dist/src/attachment-economics.js +58 -2
- package/dist/src/attachment-economics.js.map +1 -1
- package/dist/src/catalog-program.d.ts +7 -0
- package/dist/src/catalog-program.d.ts.map +1 -0
- package/dist/src/catalog-program.js +66 -0
- package/dist/src/catalog-program.js.map +1 -0
- package/dist/src/cli.js +2 -2
- package/dist/src/cli.js.map +1 -1
- package/dist/src/compile.d.ts +5 -0
- package/dist/src/compile.d.ts.map +1 -1
- package/dist/src/compile.js +47 -5
- package/dist/src/compile.js.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/parse.js +13 -0
- package/dist/src/parse.js.map +1 -1
- package/dist/src/template-guide.d.ts +57 -0
- package/dist/src/template-guide.d.ts.map +1 -0
- package/dist/src/template-guide.js +435 -0
- package/dist/src/template-guide.js.map +1 -0
- package/docs/README.md +11 -1
- package/package.json +4 -4
- package/src/attachment-economics.ts +77 -2
- package/src/catalog-program.ts +65 -0
- package/src/cli.ts +2 -2
- package/src/compile.ts +73 -8
- package/src/index.ts +7 -0
- package/src/parse.ts +15 -0
- package/src/template-guide.ts +584 -0
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import { type AttachmentPartyBinding, type UdlDocument, type UdlInstrument } from "@hyperscale0/udl";
|
|
2
|
-
import type { Entry, Expr } from "./ast.ts";
|
|
2
|
+
import type { Diagnostic, Entry, Expr, InstrumentDecl } from "./ast.ts";
|
|
3
3
|
/** An attachment specializes its own instrument; imported definitions stay generic. */
|
|
4
|
-
export declare function applyAttachmentEconomics(document: UdlDocument, instrument: UdlInstrument, parties: Record<string, AttachmentPartyBinding>, declarations: Entry[], data: (expression: Expr) => unknown): void;
|
|
4
|
+
export declare function applyAttachmentEconomics(document: UdlDocument, instrument: UdlInstrument, parties: Record<string, AttachmentPartyBinding>, declarations: Entry[], data: (expression: Expr) => unknown, records?: readonly string[]): void;
|
|
5
|
+
/**
|
|
6
|
+
* A money move an attachment leaves without a purpose books as neither
|
|
7
|
+
* revenue nor a payout. The warning names the economics line to add; its
|
|
8
|
+
* purpose follows the bound parties: earning into the operator, a payout out
|
|
9
|
+
* of it, money passing through otherwise.
|
|
10
|
+
*/
|
|
11
|
+
export declare function purposeWarnings(document: UdlDocument, selectors: ReadonlyMap<string, {
|
|
12
|
+
prefix: string;
|
|
13
|
+
root: string;
|
|
14
|
+
}>, attaches: ReadonlyMap<string, {
|
|
15
|
+
entry: Entry;
|
|
16
|
+
name: string;
|
|
17
|
+
template: InstrumentDecl;
|
|
18
|
+
}>): Diagnostic[];
|
|
5
19
|
//# sourceMappingURL=attachment-economics.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment-economics.d.ts","sourceRoot":"","sources":["../../src/attachment-economics.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,sBAAsB,EAE3B,KAAK,WAAW,EAChB,KAAK,aAAa,EACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"attachment-economics.d.ts","sourceRoot":"","sources":["../../src/attachment-economics.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,sBAAsB,EAE3B,KAAK,WAAW,EAChB,KAAK,aAAa,EACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAGxE,uFAAuF;AACvF,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,WAAW,EACrB,UAAU,EAAE,aAAa,EACzB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,EAC/C,YAAY,EAAE,KAAK,EAAE,EACrB,IAAI,EAAE,CAAC,UAAU,EAAE,IAAI,KAAK,OAAO,EACnC,OAAO,GAAE,SAAS,MAAM,EAAO,GAC9B,IAAI,CAoFN;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,WAAW,EACrB,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,EAChE,QAAQ,EAAE,WAAW,CACnB,MAAM,EACN;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,cAAc,CAAA;CAAE,CACzD,GACA,UAAU,EAAE,CA2Dd"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { subjectPartyRoles, udlMoveSchema, } from "@hyperscale0/udl";
|
|
2
2
|
import { fail } from "./diagnostics.js";
|
|
3
3
|
/** An attachment specializes its own instrument; imported definitions stay generic. */
|
|
4
|
-
export function applyAttachmentEconomics(document, instrument, parties, declarations, data) {
|
|
4
|
+
export function applyAttachmentEconomics(document, instrument, parties, declarations, data, records = []) {
|
|
5
5
|
const selected = new Set();
|
|
6
6
|
for (const declaration of declarations) {
|
|
7
7
|
const selector = declaration.key.slice("economics ".length);
|
|
@@ -10,7 +10,7 @@ export function applyAttachmentEconomics(document, instrument, parties, declarat
|
|
|
10
10
|
? instrument.actions[actionName]
|
|
11
11
|
: undefined;
|
|
12
12
|
if (!action)
|
|
13
|
-
fail(declaration, `unknown economics action ${actionName}`, `choose ${instrument.actionOrder.join(", ")}, before its public alias`);
|
|
13
|
+
fail(declaration, `unknown economics action ${actionName}`, `choose ${instrument.actionOrder.join(", ")}, before its public alias${records.length ? `, or record.action for a record (${records.join(", ")})` : ""}`);
|
|
14
14
|
const move = moveKey
|
|
15
15
|
? action.moves.find((move) => move.key === moveKey)
|
|
16
16
|
: action.moves.length === 1
|
|
@@ -52,4 +52,60 @@ export function applyAttachmentEconomics(document, instrument, parties, declarat
|
|
|
52
52
|
move.economics = economics;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* A money move an attachment leaves without a purpose books as neither
|
|
57
|
+
* revenue nor a payout. The warning names the economics line to add; its
|
|
58
|
+
* purpose follows the bound parties: earning into the operator, a payout out
|
|
59
|
+
* of it, money passing through otherwise.
|
|
60
|
+
*/
|
|
61
|
+
export function purposeWarnings(document, selectors, attaches) {
|
|
62
|
+
const warnings = [];
|
|
63
|
+
const bindings = new Map(document.objects.flatMap((object) => object.attachments.map((item) => [item.instrument, item.parties])));
|
|
64
|
+
const party = (path) => /^party\.(\w+)$/.exec(path ?? "")?.[1];
|
|
65
|
+
const operator = (name) => name === "operator" || name === "programOperator";
|
|
66
|
+
for (const instrument of document.instruments) {
|
|
67
|
+
const selector = selectors.get(instrument.id);
|
|
68
|
+
const attach = selector && attaches.get(selector.root);
|
|
69
|
+
if (!selector || !attach)
|
|
70
|
+
continue;
|
|
71
|
+
const parties = bindings.get(instrument.id) ?? {};
|
|
72
|
+
const parameters = attach.template.parameters
|
|
73
|
+
.filter((row) => row.value.kind === "name" && row.value.value === "party")
|
|
74
|
+
.map((row) => row.key);
|
|
75
|
+
// The template's own parameter reads back in the founder's terms.
|
|
76
|
+
const parameter = (name) => parameters.find((key) => {
|
|
77
|
+
const binding = parties[key];
|
|
78
|
+
return (binding && ("role" in binding ? binding.role : binding.party) === name);
|
|
79
|
+
}) ?? name;
|
|
80
|
+
for (const actionName of instrument.actionOrder) {
|
|
81
|
+
const action = instrument.actions[actionName];
|
|
82
|
+
for (const move of action.moves) {
|
|
83
|
+
if (move.economics ||
|
|
84
|
+
(move.operation !== "internal_transfer.create" &&
|
|
85
|
+
move.operation !== "internal_transfer.reserve"))
|
|
86
|
+
continue;
|
|
87
|
+
const path = `${selector.prefix}${actionName}${action.moves.length > 1 ? `.${move.key}` : ""}`;
|
|
88
|
+
const from = party(move.from);
|
|
89
|
+
const to = party(move.to);
|
|
90
|
+
const purpose = operator(to)
|
|
91
|
+
? "earning"
|
|
92
|
+
: operator(from)
|
|
93
|
+
? "participant_payout"
|
|
94
|
+
: "pass_through";
|
|
95
|
+
const source = from ? parameter(from) : (parameters[0] ?? "owner");
|
|
96
|
+
warnings.push({
|
|
97
|
+
code: "economic_purpose_missing",
|
|
98
|
+
message: `${attach.name}: ${path} moves money with no declared purpose, so the books will not count it as revenue or a payout`,
|
|
99
|
+
fix: `add economics ${path} { purpose: ${purpose}, sourceParty: ${source} } inside attach ${attach.name}`,
|
|
100
|
+
// Underline `attach <name>`, the line the declaration goes under.
|
|
101
|
+
span: {
|
|
102
|
+
start: attach.entry.span.start,
|
|
103
|
+
end: attach.entry.span.start + `attach ${attach.name}`.length,
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return warnings;
|
|
110
|
+
}
|
|
55
111
|
//# sourceMappingURL=attachment-economics.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attachment-economics.js","sourceRoot":"","sources":["../../src/attachment-economics.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,aAAa,GAKd,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,uFAAuF;AACvF,MAAM,UAAU,wBAAwB,CACtC,QAAqB,EACrB,UAAyB,EACzB,OAA+C,EAC/C,YAAqB,EACrB,IAAmC;
|
|
1
|
+
{"version":3,"file":"attachment-economics.js","sourceRoot":"","sources":["../../src/attachment-economics.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,aAAa,GAKd,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAA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,eAAe,OAAO,kBAAkB,MAAM,oBAAoB,MAAM,CAAC,IAAI,EAAE;oBACzG,kEAAkE;oBAClE,IAAI,EAAE;wBACJ,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK;wBAC9B,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,GAAG,UAAU,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM;qBAC9D;iBACF,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One program that attaches every standard template with bindings the
|
|
3
|
+
* compiler admits. Each template guide takes its example from here, and
|
|
4
|
+
* std-headers.spec proves the whole program compiles.
|
|
5
|
+
*/
|
|
6
|
+
export declare const catalogProgramSource = "program catalog \"Template catalog\"\nuse money\nuse escrow\nuse purchase\nuse booking\nuse marketplace\nuse financing\nuse insurance\nuse lending\nuse wallet\nuse cards\nuse collections\nuse savings\nuse reporting\nparty supplier: business\nparty inspector: staff role claim_inspector\nparty investor: business\nobject item \"Item\" {\n attach transfer = money.transfer { payer: actor, payee: owner, amount: 750 SAR }\n attach hold = money.hold { payer: actor, payee: owner, amount: 750 SAR }\n attach split = money.split { payer: actor, amount: 750 SAR }\n attach schedule = money.schedule { payer: actor, payee: owner, amount: 750 SAR, count: 3 }\n attach pool = money.pool { payer: actor, payee: owner, target: 1000 SAR, closes: 2027-01-01 }\n attach swap = money.swap { first: actor, second: owner, first_amount: 100 SAR, second_amount: 200 SAR, expires: 2027-01-01 }\n attach payout = money.payout { payer: actor, payee: owner, adapter: \"conformance_boundary\" }\n attach mandate = money.mandate { payer: actor, payee: owner }\n attach metered = money.metered { payer: actor, payee: owner, unit_price: 10 SAR }\n attach policy = insurance.cover { holder: actor, adapter: \"conformance_boundary\" }\n attach claim = insurance.claim { cover: policy, inspector: inspector }\n attach cov = insurance.cover { holder: actor, broker: supplier, adapter: \"conformance_boundary\", covers: sale }\n attach deposit = escrow.hold { payer: actor, payee: owner }\n attach sale = escrow.hold { funding: { controllers: [checkout], reference: \"funds\", blocking_states: [active] }, payer: actor, payee: owner }\n attach trip = booking.reservation { customer: actor, operator: owner }\n attach limits = financing.limits { borrower: actor, per_borrower: 60000 SAR }\n attach ceiling = financing.portfolio_limit { limit: 1500000 SAR }\n attach checkout = purchase.checkout { plans: plan, funds: sale, borrower: actor, capital: operator }\n attach plan = financing.installments { borrower: actor, capital: operator, months: 3, pricing: flat_total, profit_rate: 2.5%, down_payment: 20%, funds: checkout, limits: limits, portfolio: ceiling }\n attach late = financing.late_charge { on: plan, borrower: actor }\n attach line = financing.credit_line { borrower: operator, adapter: \"conformance_boundary\", limit: 100000 SAR, expires: 2027-01-01 }\n attach advance = financing.advance { line: line }\n attach case = collections.case { on: plan, agency: supplier }\n attach contact = collections.contact { case: case, agency: supplier }\n attach reminder = collections.reminder { on: plan }\n attach wallet = wallet.balance { holder: investor }\n attach spend = wallet.spend { wallet: wallet, payee: supplier, holder: investor }\n attach round = lending.round { borrower: actor, plan: plan, minimum_ticket: 100 SAR, investor_cap: 100% }\n attach commitment = lending.commitment { round: round, wallet: wallet, investor: investor }\n attach distribution = lending.distribution { round: round, receipt: plan.settlement }\n attach cardholder = cards.cardholder { holder: actor }\n attach card = cards.card { holder: cardholder, person: actor, spend_limit: 5000 SAR }\n attach authorization = cards.authorization { card: card, merchant: supplier }\n attach transaction = cards.transaction { authorization: authorization }\n attach dispute = cards.dispute { transaction: transaction }\n attach listing = marketplace.listing { seller: owner }\n attach order = marketplace.order { listing: listing, buyer: actor }\n attach reservation = marketplace.reservation { listing: listing, funds: sale, converters: checkout, buyer: actor, seller: owner }\n attach circle = savings.circle { contribution: 300 SAR, members: 8, starts: 2027-01-01 }\n attach membership = savings.membership { circle: circle, member: actor }\n attach reports = reporting.portfolio { on: plan }\n}";
|
|
7
|
+
//# sourceMappingURL=catalog-program.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog-program.d.ts","sourceRoot":"","sources":["../../src/catalog-program.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,swHA2D/B,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One program that attaches every standard template with bindings the
|
|
3
|
+
* compiler admits. Each template guide takes its example from here, and
|
|
4
|
+
* std-headers.spec proves the whole program compiles.
|
|
5
|
+
*/
|
|
6
|
+
export const catalogProgramSource = `program catalog "Template catalog"
|
|
7
|
+
use money
|
|
8
|
+
use escrow
|
|
9
|
+
use purchase
|
|
10
|
+
use booking
|
|
11
|
+
use marketplace
|
|
12
|
+
use financing
|
|
13
|
+
use insurance
|
|
14
|
+
use lending
|
|
15
|
+
use wallet
|
|
16
|
+
use cards
|
|
17
|
+
use collections
|
|
18
|
+
use savings
|
|
19
|
+
use reporting
|
|
20
|
+
party supplier: business
|
|
21
|
+
party inspector: staff role claim_inspector
|
|
22
|
+
party investor: business
|
|
23
|
+
object item "Item" {
|
|
24
|
+
attach transfer = money.transfer { payer: actor, payee: owner, amount: 750 SAR }
|
|
25
|
+
attach hold = money.hold { payer: actor, payee: owner, amount: 750 SAR }
|
|
26
|
+
attach split = money.split { payer: actor, amount: 750 SAR }
|
|
27
|
+
attach schedule = money.schedule { payer: actor, payee: owner, amount: 750 SAR, count: 3 }
|
|
28
|
+
attach pool = money.pool { payer: actor, payee: owner, target: 1000 SAR, closes: 2027-01-01 }
|
|
29
|
+
attach swap = money.swap { first: actor, second: owner, first_amount: 100 SAR, second_amount: 200 SAR, expires: 2027-01-01 }
|
|
30
|
+
attach payout = money.payout { payer: actor, payee: owner, adapter: "conformance_boundary" }
|
|
31
|
+
attach mandate = money.mandate { payer: actor, payee: owner }
|
|
32
|
+
attach metered = money.metered { payer: actor, payee: owner, unit_price: 10 SAR }
|
|
33
|
+
attach policy = insurance.cover { holder: actor, adapter: "conformance_boundary" }
|
|
34
|
+
attach claim = insurance.claim { cover: policy, inspector: inspector }
|
|
35
|
+
attach cov = insurance.cover { holder: actor, broker: supplier, adapter: "conformance_boundary", covers: sale }
|
|
36
|
+
attach deposit = escrow.hold { payer: actor, payee: owner }
|
|
37
|
+
attach sale = escrow.hold { funding: { controllers: [checkout], reference: "funds", blocking_states: [active] }, payer: actor, payee: owner }
|
|
38
|
+
attach trip = booking.reservation { customer: actor, operator: owner }
|
|
39
|
+
attach limits = financing.limits { borrower: actor, per_borrower: 60000 SAR }
|
|
40
|
+
attach ceiling = financing.portfolio_limit { limit: 1500000 SAR }
|
|
41
|
+
attach checkout = purchase.checkout { plans: plan, funds: sale, borrower: actor, capital: operator }
|
|
42
|
+
attach plan = financing.installments { borrower: actor, capital: operator, months: 3, pricing: flat_total, profit_rate: 2.5%, down_payment: 20%, funds: checkout, limits: limits, portfolio: ceiling }
|
|
43
|
+
attach late = financing.late_charge { on: plan, borrower: actor }
|
|
44
|
+
attach line = financing.credit_line { borrower: operator, adapter: "conformance_boundary", limit: 100000 SAR, expires: 2027-01-01 }
|
|
45
|
+
attach advance = financing.advance { line: line }
|
|
46
|
+
attach case = collections.case { on: plan, agency: supplier }
|
|
47
|
+
attach contact = collections.contact { case: case, agency: supplier }
|
|
48
|
+
attach reminder = collections.reminder { on: plan }
|
|
49
|
+
attach wallet = wallet.balance { holder: investor }
|
|
50
|
+
attach spend = wallet.spend { wallet: wallet, payee: supplier, holder: investor }
|
|
51
|
+
attach round = lending.round { borrower: actor, plan: plan, minimum_ticket: 100 SAR, investor_cap: 100% }
|
|
52
|
+
attach commitment = lending.commitment { round: round, wallet: wallet, investor: investor }
|
|
53
|
+
attach distribution = lending.distribution { round: round, receipt: plan.settlement }
|
|
54
|
+
attach cardholder = cards.cardholder { holder: actor }
|
|
55
|
+
attach card = cards.card { holder: cardholder, person: actor, spend_limit: 5000 SAR }
|
|
56
|
+
attach authorization = cards.authorization { card: card, merchant: supplier }
|
|
57
|
+
attach transaction = cards.transaction { authorization: authorization }
|
|
58
|
+
attach dispute = cards.dispute { transaction: transaction }
|
|
59
|
+
attach listing = marketplace.listing { seller: owner }
|
|
60
|
+
attach order = marketplace.order { listing: listing, buyer: actor }
|
|
61
|
+
attach reservation = marketplace.reservation { listing: listing, funds: sale, converters: checkout, buyer: actor, seller: owner }
|
|
62
|
+
attach circle = savings.circle { contribution: 300 SAR, members: 8, starts: 2027-01-01 }
|
|
63
|
+
attach membership = savings.membership { circle: circle, member: actor }
|
|
64
|
+
attach reports = reporting.portfolio { on: plan }
|
|
65
|
+
}`;
|
|
66
|
+
//# sourceMappingURL=catalog-program.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog-program.js","sourceRoot":"","sources":["../../src/catalog-program.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2DlC,CAAC"}
|
package/dist/src/cli.js
CHANGED
|
@@ -74,8 +74,8 @@ export async function runCli(argv, io) {
|
|
|
74
74
|
}
|
|
75
75
|
else {
|
|
76
76
|
const result = compile(source, { standardLibrary });
|
|
77
|
-
for (const d of result.diagnostics)
|
|
78
|
-
io.err(`${d.source && d.source !== "program" ? d.source : file}:${d.line}:${d.column}: ${d.code} ${d.message.replace(/[^.?!]$/, "$&.")} ${d.fix}`);
|
|
77
|
+
for (const d of [...result.diagnostics, ...result.warnings])
|
|
78
|
+
io.err(`${d.source && d.source !== "program" ? d.source : file}:${d.line}:${d.column}: ${d.severity === "warning" ? "warning " : ""}${d.code} ${d.message.replace(/[^.?!]$/, "$&.")} ${d.fix}`);
|
|
79
79
|
if (!result.artifacts || result.verdict !== "valid")
|
|
80
80
|
return 1;
|
|
81
81
|
if (command === "check")
|
package/dist/src/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
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AAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;QAChD,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAC1C,SAAS,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC;KACzD,CAAC,CAAC"}
|
package/dist/src/compile.d.ts
CHANGED
|
@@ -32,9 +32,14 @@ export interface CompileOptions {
|
|
|
32
32
|
standardLibrary?: StandardLibrary;
|
|
33
33
|
adapterRegistry?: Readonly<Record<string, AdapterBindingTarget>>;
|
|
34
34
|
}
|
|
35
|
+
export interface CompileWarning extends Omit<CompileDiagnostic, "severity"> {
|
|
36
|
+
severity: "warning";
|
|
37
|
+
}
|
|
35
38
|
export interface CompileResult {
|
|
36
39
|
verdict: "valid" | "invalid";
|
|
37
40
|
diagnostics: CompileDiagnostic[];
|
|
41
|
+
/** Advice that does not block a freeze, such as a money move with no purpose. */
|
|
42
|
+
warnings: CompileWarning[];
|
|
38
43
|
artifacts?: {
|
|
39
44
|
document: UdlDocument;
|
|
40
45
|
costManifest: UdlCostManifest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/compile.ts"],"names":[],"mappings":"AAOA,OAAO,EAAwB,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EAkBL,KAAK,WAAW,EAQjB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/compile.ts"],"names":[],"mappings":"AAOA,OAAO,EAAwB,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EAkBL,KAAK,WAAW,EAQjB,MAAM,kBAAkB,CAAC;AAa1B,OAAO,EAIL,KAAK,UAAU,EAKf,KAAK,IAAI,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QAAQ,EAAE,WAAW,CAAC;QACtB,YAAY,EAAE,eAAe,CAAC;QAC9B,SAAS,EAAE,qBAAqB,EAAE,CAAC;KACpC,CAAC;CACH;AAqVD,wBAAgB,OAAO,CACrB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,cAAmB,GAC3B,aAAa,CAssIf"}
|
package/dist/src/compile.js
CHANGED
|
@@ -5,7 +5,7 @@ import { validateUdl, resolveField, sameAccount, sameObjectField, subjectPartyRo
|
|
|
5
5
|
import { bindingDependencies, parameterDiagnostics, BindingContractError, } from "./binding-contract.js";
|
|
6
6
|
import { tunableBounds } from "./tunables.js";
|
|
7
7
|
import { parseProgram } from "./parse.js";
|
|
8
|
-
import { applyAttachmentEconomics } from "./attachment-economics.js";
|
|
8
|
+
import { applyAttachmentEconomics, purposeWarnings, } from "./attachment-economics.js";
|
|
9
9
|
import { parseHeader } from "./header-source.js";
|
|
10
10
|
import { lineColAt, } from "./ast.js";
|
|
11
11
|
import { bundledStandardLibrary } from "./std-library.js";
|
|
@@ -246,7 +246,9 @@ function literal(expr, expectedType) {
|
|
|
246
246
|
Number(iso[5] ?? 0) * units.s
|
|
247
247
|
: NaN;
|
|
248
248
|
if (!Number.isSafeInteger(n) || n <= 0)
|
|
249
|
-
fail(expr, "
|
|
249
|
+
fail(expr, expr.value.includes(" ")
|
|
250
|
+
? `${expr.value} is not a fixed duration`
|
|
251
|
+
: "invalid duration", "write a positive fixed duration such as 48h, 3d or 30d");
|
|
250
252
|
return n;
|
|
251
253
|
}
|
|
252
254
|
if (expr.kind === "date") {
|
|
@@ -291,6 +293,7 @@ export function compile(source, options = {}) {
|
|
|
291
293
|
return {
|
|
292
294
|
verdict: "invalid",
|
|
293
295
|
diagnostics: parsed.diagnostics.map((d) => diagnostic(d, "parse")),
|
|
296
|
+
warnings: [],
|
|
294
297
|
};
|
|
295
298
|
const program = parsed.program;
|
|
296
299
|
const bindingDiagnostics = [];
|
|
@@ -310,6 +313,9 @@ export function compile(source, options = {}) {
|
|
|
310
313
|
if (program.currency !== "SAR")
|
|
311
314
|
fail(program, "this release supports riyals", "write currency SAR or omit currency");
|
|
312
315
|
const templates = new Map();
|
|
316
|
+
// Attached instruments, for the warning on a money move with no purpose.
|
|
317
|
+
const attachedSelectors = new Map();
|
|
318
|
+
const attachEntries = new Map();
|
|
313
319
|
const declarationSources = new Map();
|
|
314
320
|
const standardOrigins = new Map();
|
|
315
321
|
const requirementOrigins = new Map();
|
|
@@ -621,10 +627,12 @@ export function compile(source, options = {}) {
|
|
|
621
627
|
enums.set(parameter.key, type.args.map(text));
|
|
622
628
|
}
|
|
623
629
|
const supplied = new Map();
|
|
630
|
+
const suppliedEntries = new Map();
|
|
624
631
|
for (const entry of arguments_.entries) {
|
|
625
632
|
if (supplied.has(entry.key))
|
|
626
633
|
fail(entry, `duplicate tunable ${entry.key}`, "supply each parameter once");
|
|
627
634
|
supplied.set(entry.key, entry.value);
|
|
635
|
+
suppliedEntries.set(entry.key, entry);
|
|
628
636
|
}
|
|
629
637
|
const environment = new Map(inherited);
|
|
630
638
|
const parameterErrors = [];
|
|
@@ -741,7 +749,8 @@ export function compile(source, options = {}) {
|
|
|
741
749
|
const target = candidates.length === 1 ? candidates[0].key : "yourMoneyField";
|
|
742
750
|
fail(suppliedValue, `\`${assignments.get(id)?.target ?? decl.name}\` has no \`${key}\` tunable. Its actions require the object's \`${field}\` field.`, `Remove \`${key}\`. To use your object's money field, add \`rename { ${field}: ${target} }\`.`);
|
|
743
751
|
}
|
|
744
|
-
|
|
752
|
+
const tunables = decl.parameters.map((p) => p.key);
|
|
753
|
+
fail(suppliedEntries.get(key) ?? suppliedValue, `${assignments.get(id)?.target ?? attachmentInfo?.template ?? decl.name} has no tunable "${key}".${didYouMean(key, tunables)} Tunables: ${tunables.join(", ")}`, `remove ${key}, or set one of ${tunables.join(", ")}`);
|
|
745
754
|
}
|
|
746
755
|
const isParty = (name) => !!document.parties[name] ||
|
|
747
756
|
(!!attachmentInfo &&
|
|
@@ -2309,8 +2318,31 @@ export function compile(source, options = {}) {
|
|
|
2309
2318
|
if (receipt)
|
|
2310
2319
|
move.transfer = `self.${receipt}`;
|
|
2311
2320
|
}
|
|
2312
|
-
|
|
2313
|
-
|
|
2321
|
+
// `economics occurrence.pay` classifies a record's move; an action of
|
|
2322
|
+
// the attached instrument wins over a record of the same name.
|
|
2323
|
+
const recordEconomics = new Map();
|
|
2324
|
+
if (attachmentInfo) {
|
|
2325
|
+
const own = [];
|
|
2326
|
+
for (const declaration of attachmentInfo.economics) {
|
|
2327
|
+
const [first = "", ...rest] = declaration.key
|
|
2328
|
+
.slice("economics ".length)
|
|
2329
|
+
.split(".");
|
|
2330
|
+
if (rest.length &&
|
|
2331
|
+
!Object.hasOwn(inst.actions, first) &&
|
|
2332
|
+
records.has(first))
|
|
2333
|
+
recordEconomics.set(first, [
|
|
2334
|
+
...(recordEconomics.get(first) ?? []),
|
|
2335
|
+
{ ...declaration, key: `economics ${rest.join(".")}` },
|
|
2336
|
+
]);
|
|
2337
|
+
else
|
|
2338
|
+
own.push(declaration);
|
|
2339
|
+
}
|
|
2340
|
+
applyAttachmentEconomics(document, inst, attachmentInfo.parties, own, data, [...records.keys()]);
|
|
2341
|
+
attachedSelectors.set(inst.id, {
|
|
2342
|
+
prefix: attachmentInfo.selectorPrefix ?? "",
|
|
2343
|
+
root: attachmentInfo.rootInstrument ?? inst.id,
|
|
2344
|
+
});
|
|
2345
|
+
}
|
|
2314
2346
|
for (const key of [
|
|
2315
2347
|
"invariants",
|
|
2316
2348
|
"reports",
|
|
@@ -2375,6 +2407,9 @@ export function compile(source, options = {}) {
|
|
|
2375
2407
|
attachmentName: `${attachmentInfo.attachmentName}_${key}`,
|
|
2376
2408
|
child: true,
|
|
2377
2409
|
exposed: new Map(),
|
|
2410
|
+
economics: recordEconomics.get(key) ?? [],
|
|
2411
|
+
selectorPrefix: `${attachmentInfo.selectorPrefix ?? ""}${key}.`,
|
|
2412
|
+
rootInstrument: attachmentInfo.rootInstrument ?? id,
|
|
2378
2413
|
}
|
|
2379
2414
|
: undefined;
|
|
2380
2415
|
if (childAttachment)
|
|
@@ -2489,6 +2524,7 @@ export function compile(source, options = {}) {
|
|
|
2489
2524
|
}
|
|
2490
2525
|
const parties = {};
|
|
2491
2526
|
attachments.push({ name: attachmentName, instrument: instId, parties });
|
|
2527
|
+
attachEntries.set(instId, { entry, name: attachmentName, template });
|
|
2492
2528
|
const tunableBlock = {
|
|
2493
2529
|
kind: "block",
|
|
2494
2530
|
entries: tunableEntries,
|
|
@@ -2505,6 +2541,7 @@ export function compile(source, options = {}) {
|
|
|
2505
2541
|
parties,
|
|
2506
2542
|
attachments,
|
|
2507
2543
|
economics,
|
|
2544
|
+
template: targetTemplate,
|
|
2508
2545
|
}, templateFamily ? { ...templateFamily } : undefined, standardOrigins.get(template));
|
|
2509
2546
|
}
|
|
2510
2547
|
catch (error) {
|
|
@@ -2652,6 +2689,7 @@ export function compile(source, options = {}) {
|
|
|
2652
2689
|
if (bindingDiagnostics.length)
|
|
2653
2690
|
return {
|
|
2654
2691
|
verdict: "invalid",
|
|
2692
|
+
warnings: [],
|
|
2655
2693
|
diagnostics: distinct(bindingDiagnostics)
|
|
2656
2694
|
.sort((a, b) => a.span.start - b.span.start)
|
|
2657
2695
|
.map((d) => diagnostic(d, "check")),
|
|
@@ -3250,6 +3288,7 @@ export function compile(source, options = {}) {
|
|
|
3250
3288
|
if (collisions.length)
|
|
3251
3289
|
return {
|
|
3252
3290
|
verdict: "invalid",
|
|
3291
|
+
warnings: [],
|
|
3253
3292
|
diagnostics: collisions
|
|
3254
3293
|
.sort((a, b) => a.span.start - b.span.start)
|
|
3255
3294
|
.map((d) => diagnostic(d, "check")),
|
|
@@ -3298,6 +3337,7 @@ export function compile(source, options = {}) {
|
|
|
3298
3337
|
if (!validated.ok)
|
|
3299
3338
|
return {
|
|
3300
3339
|
verdict: "invalid",
|
|
3340
|
+
warnings: [],
|
|
3301
3341
|
diagnostics: issues.map((i) => {
|
|
3302
3342
|
const origin = [...origins]
|
|
3303
3343
|
.reverse()
|
|
@@ -3351,6 +3391,7 @@ export function compile(source, options = {}) {
|
|
|
3351
3391
|
return {
|
|
3352
3392
|
verdict: "valid",
|
|
3353
3393
|
diagnostics: [],
|
|
3394
|
+
warnings: purposeWarnings(document, attachedSelectors, attachEntries).map((d) => ({ ...diagnostic(d, "check"), severity: "warning" })),
|
|
3354
3395
|
artifacts: {
|
|
3355
3396
|
document: validated.value,
|
|
3356
3397
|
costManifest: buildUdlCostManifest(validated.value),
|
|
@@ -3362,6 +3403,7 @@ export function compile(source, options = {}) {
|
|
|
3362
3403
|
if (error instanceof CompileFailure)
|
|
3363
3404
|
return {
|
|
3364
3405
|
verdict: "invalid",
|
|
3406
|
+
warnings: [],
|
|
3365
3407
|
diagnostics: distinct([...bindingDiagnostics, error.diagnostic]).map((d) => diagnostic(d, "check")),
|
|
3366
3408
|
};
|
|
3367
3409
|
throw error;
|