@hyperscale0/udl 4.8.0 → 5.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.
- package/CHANGELOG.md +22 -0
- package/README.md +4 -13
- package/dist/diagnostics.d.ts +1 -15
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/diagnostics.js +0 -12
- package/dist/diagnostics.js.map +1 -1
- package/dist/index.d.ts +1 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/dist/object-contract.d.ts +0 -52
- package/dist/object-contract.d.ts.map +1 -1
- package/dist/object-contract.js +0 -19
- package/dist/object-contract.js.map +1 -1
- package/dist/object-semantics-schema.d.ts +1 -0
- package/dist/object-semantics-schema.d.ts.map +1 -1
- package/dist/schema.d.ts +4 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +2 -0
- package/dist/schema.js.map +1 -1
- package/package.json +4 -8
- package/spec/README.md +12 -0
- package/spec/udl.schema.json +12 -0
- package/src/diagnostics.ts +1 -18
- package/src/index.ts +1 -13
- package/src/object-contract.ts +0 -47
- package/src/schema.ts +2 -0
- package/dist/cli.d.ts +0 -3
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -184
- package/dist/cli.js.map +0 -1
- package/dist/evolution.d.ts +0 -5
- package/dist/evolution.d.ts.map +0 -1
- package/dist/evolution.js +0 -27
- package/dist/evolution.js.map +0 -1
- package/dist/instrument-references.d.ts +0 -5
- package/dist/instrument-references.d.ts.map +0 -1
- package/dist/instrument-references.js +0 -90
- package/dist/instrument-references.js.map +0 -1
- package/dist/parser.d.ts +0 -4
- package/dist/parser.d.ts.map +0 -1
- package/dist/parser.js +0 -67
- package/dist/parser.js.map +0 -1
- package/docs/README.md +0 -282
- package/src/cli.ts +0 -196
- package/src/evolution.ts +0 -46
- package/src/instrument-references.ts +0 -123
- package/src/parser.ts +0 -80
package/spec/README.md
CHANGED
|
@@ -71,6 +71,18 @@ Object instances carry `objectId`, `kind`, `revision`, optional `externalId`,
|
|
|
71
71
|
`fields` and `productBuildId`. Action responses carry the object and either a
|
|
72
72
|
financial instrument outcome or null.
|
|
73
73
|
|
|
74
|
+
An object may declare `entryActions`, a list of exposed attachment creation
|
|
75
|
+
names. The host admits an active enrolled customer only to an entry action whose
|
|
76
|
+
actor is the session's `actor` role. Other records remain closed. Retained
|
|
77
|
+
participants can read their record and use the actions granted to their roles;
|
|
78
|
+
participation never changes the owner.
|
|
79
|
+
|
|
80
|
+
An instrument may declare `scope: "product"`. Object creation can resolve a
|
|
81
|
+
reference to that instrument on another record in the same Product when every
|
|
82
|
+
retained party account matches the current bindings. Otherwise references stay
|
|
83
|
+
on the current record. Create and approve shared limits once per Product or
|
|
84
|
+
borrower; referencing them does not create a new limit.
|
|
85
|
+
|
|
74
86
|
## Object operations
|
|
75
87
|
|
|
76
88
|
The host owns transport routes for object discovery, creation, listing,
|
package/spec/udl.schema.json
CHANGED
|
@@ -94,6 +94,14 @@
|
|
|
94
94
|
"__schema3": {
|
|
95
95
|
"type": "object",
|
|
96
96
|
"properties": {
|
|
97
|
+
"entryActions": {
|
|
98
|
+
"minItems": 1,
|
|
99
|
+
"maxItems": 128,
|
|
100
|
+
"type": "array",
|
|
101
|
+
"items": {
|
|
102
|
+
"$ref": "#/$defs/__schema1"
|
|
103
|
+
}
|
|
104
|
+
},
|
|
97
105
|
"id": {
|
|
98
106
|
"$ref": "#/$defs/__schema4"
|
|
99
107
|
},
|
|
@@ -705,6 +713,10 @@
|
|
|
705
713
|
"__schema25": {
|
|
706
714
|
"type": "object",
|
|
707
715
|
"properties": {
|
|
716
|
+
"scope": {
|
|
717
|
+
"type": "string",
|
|
718
|
+
"const": "product"
|
|
719
|
+
},
|
|
708
720
|
"reports": {
|
|
709
721
|
"maxItems": 16,
|
|
710
722
|
"type": "array",
|
package/src/diagnostics.ts
CHANGED
|
@@ -9,8 +9,6 @@ export type UdlIssueCode =
|
|
|
9
9
|
| "staff_role_unknown"
|
|
10
10
|
| "product_party_unbound"
|
|
11
11
|
| "product_party_invalid"
|
|
12
|
-
| "UDL1001"
|
|
13
|
-
| "UDL1002"
|
|
14
12
|
| "UDL1003"
|
|
15
13
|
| "UDL1004"
|
|
16
14
|
| "UDL2001"
|
|
@@ -18,9 +16,7 @@ export type UdlIssueCode =
|
|
|
18
16
|
| "UDL2010"
|
|
19
17
|
| "UDL3001"
|
|
20
18
|
| "UDL4001"
|
|
21
|
-
| "UDL5001"
|
|
22
|
-
| "UDL7001"
|
|
23
|
-
| "UDL7002";
|
|
19
|
+
| "UDL5001";
|
|
24
20
|
export interface UdlIssue {
|
|
25
21
|
code: UdlIssueCode;
|
|
26
22
|
path: string;
|
|
@@ -51,8 +47,6 @@ const fixes: Record<UdlIssueCode, string> = {
|
|
|
51
47
|
product_party_invalid:
|
|
52
48
|
"Bind a business participant in the same tenant and environment.",
|
|
53
49
|
|
|
54
|
-
UDL1001: "Encode the source as UTF-8.",
|
|
55
|
-
UDL1002: "Repair JSON syntax.",
|
|
56
50
|
UDL1003: "Use the UDL 4 typed grammar.",
|
|
57
51
|
UDL1004: "Reduce the declared structure or expansion.",
|
|
58
52
|
UDL2001: "Give each declaration a distinct name.",
|
|
@@ -62,8 +56,6 @@ const fixes: Record<UdlIssueCode, string> = {
|
|
|
62
56
|
UDL4001:
|
|
63
57
|
"Fund owned accounts before spending and close them with zero balances.",
|
|
64
58
|
UDL5001: "Use a declared reference of the required type.",
|
|
65
|
-
UDL7001: "Preserve existing instance meaning or recreate the estate.",
|
|
66
|
-
UDL7002: "Increase the contract version.",
|
|
67
59
|
};
|
|
68
60
|
export function issue(
|
|
69
61
|
code: UdlIssueCode,
|
|
@@ -85,12 +77,3 @@ function category(code: string): string {
|
|
|
85
77
|
? "resource_limit"
|
|
86
78
|
: "invalid_semantics";
|
|
87
79
|
}
|
|
88
|
-
export const udlDiagnostics = Object.entries(fixes).map(([code, fix]) => ({
|
|
89
|
-
code,
|
|
90
|
-
fix,
|
|
91
|
-
title: fix,
|
|
92
|
-
category: category(code),
|
|
93
|
-
family: "document",
|
|
94
|
-
}));
|
|
95
|
-
export const udlDiagnostic = (code: string) =>
|
|
96
|
-
udlDiagnostics.find((d) => d.code === code);
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export * from "./schema.js";
|
|
2
|
-
export { parseUdl, canonicalizeUdl } from "./parser.js";
|
|
3
2
|
export { serializeUdl, canonicalDigest } from "./canonical.js";
|
|
4
3
|
export {
|
|
5
4
|
validateUdl,
|
|
@@ -10,19 +9,8 @@ export {
|
|
|
10
9
|
UdlError,
|
|
11
10
|
type UdlValidationResult,
|
|
12
11
|
} from "./validation.js";
|
|
13
|
-
export {
|
|
14
|
-
issue,
|
|
15
|
-
udlDiagnostic,
|
|
16
|
-
udlDiagnostics,
|
|
17
|
-
type UdlIssue,
|
|
18
|
-
type UdlIssueCode,
|
|
19
|
-
} from "./diagnostics.js";
|
|
12
|
+
export { issue, type UdlIssue, type UdlIssueCode } from "./diagnostics.js";
|
|
20
13
|
export { analyzeInstrumentFinance, type FinanceIssue } from "./finance.js";
|
|
21
|
-
export {
|
|
22
|
-
mapUdlInstrumentReferences,
|
|
23
|
-
referencedUdlInstrumentIds,
|
|
24
|
-
} from "./instrument-references.js";
|
|
25
|
-
export { diffValidatedUdlEvolution } from "./evolution.js";
|
|
26
14
|
export { fixedIsoDurationMs } from "./duration.js";
|
|
27
15
|
|
|
28
16
|
export * from "./reporting.js";
|
package/src/object-contract.ts
CHANGED
|
@@ -20,27 +20,6 @@ import {
|
|
|
20
20
|
type UdlInstrument,
|
|
21
21
|
} from "./schema.js";
|
|
22
22
|
|
|
23
|
-
export const requestAttributionSchema = z.union([
|
|
24
|
-
z.strictObject({
|
|
25
|
-
kind: z.literal("human"),
|
|
26
|
-
principalId: z.string().min(1),
|
|
27
|
-
humanId: z.string().min(1),
|
|
28
|
-
source: z.enum(["staff_session", "customer_session"]),
|
|
29
|
-
}),
|
|
30
|
-
z.strictObject({
|
|
31
|
-
kind: z.literal("machine"),
|
|
32
|
-
principalId: z.string().min(1),
|
|
33
|
-
source: z.enum(["api_key", "system"]),
|
|
34
|
-
}),
|
|
35
|
-
z.strictObject({
|
|
36
|
-
kind: z.literal("machine"),
|
|
37
|
-
principalId: z.string().min(1),
|
|
38
|
-
humanId: z.string().min(1),
|
|
39
|
-
source: z.literal("api_key_delegate"),
|
|
40
|
-
}),
|
|
41
|
-
]);
|
|
42
|
-
export type RequestAttribution = z.infer<typeof requestAttributionSchema>;
|
|
43
|
-
|
|
44
23
|
export type JsonSchemaDocument = z.core.JSONSchema.BaseSchema;
|
|
45
24
|
|
|
46
25
|
export interface ObjectKindDiscovery {
|
|
@@ -183,32 +162,6 @@ export interface ObjectDiscovery {
|
|
|
183
162
|
digest: string;
|
|
184
163
|
kinds: readonly ObjectKindDiscovery[];
|
|
185
164
|
}
|
|
186
|
-
export interface ObjectActionsResponse {
|
|
187
|
-
objectId: string;
|
|
188
|
-
revision: number;
|
|
189
|
-
actions: readonly ObjectActionState[];
|
|
190
|
-
evidence: readonly ObjectEvidenceSummary[];
|
|
191
|
-
nextCursor?: string;
|
|
192
|
-
}
|
|
193
|
-
export interface ObjectInstance {
|
|
194
|
-
objectId: string;
|
|
195
|
-
kind: string;
|
|
196
|
-
revision: number;
|
|
197
|
-
externalId?: string;
|
|
198
|
-
fields: Record<string, unknown>;
|
|
199
|
-
productBuildId: string;
|
|
200
|
-
}
|
|
201
|
-
export interface ObjectListResponse {
|
|
202
|
-
items: ObjectInstance[];
|
|
203
|
-
nextCursor?: string;
|
|
204
|
-
total: number;
|
|
205
|
-
facets: Record<string, Record<string, number>>;
|
|
206
|
-
}
|
|
207
|
-
export interface ObjectActionResponse {
|
|
208
|
-
object: ObjectInstance;
|
|
209
|
-
outcome: { instrument: string; instanceId: string; state: string } | null;
|
|
210
|
-
evidence: readonly ObjectEvidenceSummary[];
|
|
211
|
-
}
|
|
212
165
|
|
|
213
166
|
/** Creation accepts the full metadata union, with every value optional. */
|
|
214
167
|
export function objectCreateSchema(kind: UdlObjectKind): z.ZodObject {
|
package/src/schema.ts
CHANGED
|
@@ -236,6 +236,7 @@ export type SubjectPartyRole = (typeof subjectPartyRoles)[number];
|
|
|
236
236
|
export type UdlObjectAttachment = z.infer<typeof udlObjectAttachmentSchema>;
|
|
237
237
|
|
|
238
238
|
export const udlObjectKindSchema = z.strictObject({
|
|
239
|
+
entryActions: z.array(name).min(1).max(128).optional(),
|
|
239
240
|
id: objectKindId,
|
|
240
241
|
title: text,
|
|
241
242
|
authoredFields: z.array(name).max(256),
|
|
@@ -510,6 +511,7 @@ export const udlLifecycleSchema = z.strictObject({
|
|
|
510
511
|
),
|
|
511
512
|
});
|
|
512
513
|
export const udlInstrumentSchema = z.strictObject({
|
|
514
|
+
scope: z.literal("product").optional(),
|
|
513
515
|
reports: z.array(reportDefinitionSchema).max(16).optional(),
|
|
514
516
|
revisioned: z.literal(true).optional(),
|
|
515
517
|
family: udlFamilySchema.optional(),
|
package/dist/cli.d.ts
DELETED
package/dist/cli.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* The `udl` command. Actions over the same library the compiler uses:
|
|
4
|
-
* `validate` answers whether a document is admissible, `fmt` writes the
|
|
5
|
-
* canonical bytes, and `diff` answers whether a change is legal against a
|
|
6
|
-
* document that already has live instances.
|
|
7
|
-
*/
|
|
8
|
-
import { readFile, writeFile } from "node:fs/promises";
|
|
9
|
-
import { canonicalizeUdl, canonicalDigest, diffValidatedUdlEvolution, parseUdl, UdlError, udlDiagnostic, } from "./index.js";
|
|
10
|
-
const USAGE = `udl - the Universal Domain Language toolchain
|
|
11
|
-
|
|
12
|
-
usage:
|
|
13
|
-
udl validate <file> parse <file> and report every issue found
|
|
14
|
-
udl fmt <file> [--write] print the canonical form, or rewrite the file
|
|
15
|
-
udl canon <file> [--digest] print canonical bytes, or their SHA-256 digest
|
|
16
|
-
udl diff <live> <next> check <next> against the append-only law
|
|
17
|
-
udl explain UDL#### explain one stable diagnostic code
|
|
18
|
-
udl help print this
|
|
19
|
-
|
|
20
|
-
exit codes:
|
|
21
|
-
0 the document is admissible, or the change is additive
|
|
22
|
-
1 the document was refused, or the change breaks the append-only law
|
|
23
|
-
2 the command line was wrong, or a file could not be read`;
|
|
24
|
-
async function main(argv) {
|
|
25
|
-
const [command, ...rest] = argv;
|
|
26
|
-
switch (command) {
|
|
27
|
-
case "help":
|
|
28
|
-
case "-h":
|
|
29
|
-
case "--help":
|
|
30
|
-
console.log(USAGE);
|
|
31
|
-
return 0;
|
|
32
|
-
case "validate":
|
|
33
|
-
return validateCommand(rest);
|
|
34
|
-
case "fmt":
|
|
35
|
-
return formatCommand(rest);
|
|
36
|
-
case "canon":
|
|
37
|
-
return canonCommand(rest);
|
|
38
|
-
case "diff":
|
|
39
|
-
return diffCommand(rest);
|
|
40
|
-
case "explain":
|
|
41
|
-
return explainCommand(rest);
|
|
42
|
-
case undefined:
|
|
43
|
-
return usageError("udl: no command given");
|
|
44
|
-
default:
|
|
45
|
-
return usageError(`udl: unknown command ${command}`);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
async function canonCommand(args) {
|
|
49
|
-
const digest = args.includes("--digest");
|
|
50
|
-
const [file, ...extra] = args.filter((argument) => argument !== "--digest");
|
|
51
|
-
if (file === undefined || extra.length > 0) {
|
|
52
|
-
return usageError("usage: udl canon <file> [--digest]");
|
|
53
|
-
}
|
|
54
|
-
const bytes = await readDocument(file);
|
|
55
|
-
if (bytes === null)
|
|
56
|
-
return 2;
|
|
57
|
-
let document;
|
|
58
|
-
try {
|
|
59
|
-
document = parseUdl(bytes);
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
return reportIssues(file, error);
|
|
63
|
-
}
|
|
64
|
-
if (digest)
|
|
65
|
-
console.log(await canonicalDigest(document));
|
|
66
|
-
else
|
|
67
|
-
process.stdout.write(canonicalizeUdl(bytes));
|
|
68
|
-
return 0;
|
|
69
|
-
}
|
|
70
|
-
function explainCommand(args) {
|
|
71
|
-
const [code, ...extra] = args;
|
|
72
|
-
if (code === undefined || extra.length > 0) {
|
|
73
|
-
return usageError("usage: udl explain UDL####");
|
|
74
|
-
}
|
|
75
|
-
const diagnostic = udlDiagnostic(code);
|
|
76
|
-
if (!diagnostic) {
|
|
77
|
-
return usageError(`udl: unknown diagnostic code ${code}`);
|
|
78
|
-
}
|
|
79
|
-
console.log(`${code} ${diagnostic.title}`);
|
|
80
|
-
console.log(`category: ${diagnostic.category}`);
|
|
81
|
-
console.log(`family: ${diagnostic.family}`);
|
|
82
|
-
console.log(`fix: ${diagnostic.fix}`);
|
|
83
|
-
return 0;
|
|
84
|
-
}
|
|
85
|
-
async function validateCommand(args) {
|
|
86
|
-
const [file, ...extra] = args;
|
|
87
|
-
if (file === undefined || extra.length > 0) {
|
|
88
|
-
return usageError("usage: udl validate <file>");
|
|
89
|
-
}
|
|
90
|
-
const bytes = await readDocument(file);
|
|
91
|
-
if (bytes === null)
|
|
92
|
-
return 2;
|
|
93
|
-
if (parseDocument(file, bytes) === null)
|
|
94
|
-
return 1;
|
|
95
|
-
console.log(`${file}: ok`);
|
|
96
|
-
return 0;
|
|
97
|
-
}
|
|
98
|
-
async function formatCommand(args) {
|
|
99
|
-
const write = args.includes("--write");
|
|
100
|
-
const [file, ...extra] = args.filter((argument) => argument !== "--write");
|
|
101
|
-
if (file === undefined || extra.length > 0) {
|
|
102
|
-
return usageError("usage: udl fmt <file> [--write]");
|
|
103
|
-
}
|
|
104
|
-
const bytes = await readDocument(file);
|
|
105
|
-
if (bytes === null)
|
|
106
|
-
return 2;
|
|
107
|
-
let canonical;
|
|
108
|
-
try {
|
|
109
|
-
canonical = canonicalizeUdl(bytes);
|
|
110
|
-
}
|
|
111
|
-
catch (error) {
|
|
112
|
-
return reportIssues(file, error);
|
|
113
|
-
}
|
|
114
|
-
if (!write) {
|
|
115
|
-
process.stdout.write(canonical);
|
|
116
|
-
return 0;
|
|
117
|
-
}
|
|
118
|
-
// The bytes decoded cleanly already: canonicalizeUdl refuses anything else.
|
|
119
|
-
if (new TextDecoder().decode(bytes) === canonical)
|
|
120
|
-
return 0;
|
|
121
|
-
await writeFile(file, canonical);
|
|
122
|
-
console.log(`${file}: formatted`);
|
|
123
|
-
return 0;
|
|
124
|
-
}
|
|
125
|
-
async function diffCommand(args) {
|
|
126
|
-
const [livePath, nextPath, ...extra] = args;
|
|
127
|
-
if (livePath === undefined || nextPath === undefined || extra.length > 0) {
|
|
128
|
-
return usageError("usage: udl diff <live> <next>");
|
|
129
|
-
}
|
|
130
|
-
const liveBytes = await readDocument(livePath);
|
|
131
|
-
const nextBytes = await readDocument(nextPath);
|
|
132
|
-
if (liveBytes === null || nextBytes === null)
|
|
133
|
-
return 2;
|
|
134
|
-
const live = parseDocument(livePath, liveBytes);
|
|
135
|
-
const next = parseDocument(nextPath, nextBytes);
|
|
136
|
-
if (live === null || next === null)
|
|
137
|
-
return 1;
|
|
138
|
-
// `parseDocument` already validated both, so take the door that does not
|
|
139
|
-
// validate a second time.
|
|
140
|
-
const violations = diffValidatedUdlEvolution(live, next);
|
|
141
|
-
if (violations.length === 0) {
|
|
142
|
-
console.log(`${nextPath}: additive`);
|
|
143
|
-
return 0;
|
|
144
|
-
}
|
|
145
|
-
for (const violation of violations) {
|
|
146
|
-
console.error(`${nextPath}: ${violation.code} ${violation.path}: ${violation.message}`);
|
|
147
|
-
}
|
|
148
|
-
return 1;
|
|
149
|
-
}
|
|
150
|
-
async function readDocument(file) {
|
|
151
|
-
try {
|
|
152
|
-
return await readFile(file);
|
|
153
|
-
}
|
|
154
|
-
catch (error) {
|
|
155
|
-
const reason = error instanceof Error ? error.message : String(error);
|
|
156
|
-
console.error(`udl: cannot read ${file}: ${reason}`);
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
/** Parses one document, printing its issues. Null means the document was refused. */
|
|
161
|
-
function parseDocument(file, bytes) {
|
|
162
|
-
try {
|
|
163
|
-
return parseUdl(bytes);
|
|
164
|
-
}
|
|
165
|
-
catch (error) {
|
|
166
|
-
reportIssues(file, error);
|
|
167
|
-
return null;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
function reportIssues(file, error) {
|
|
171
|
-
if (!(error instanceof UdlError))
|
|
172
|
-
throw error;
|
|
173
|
-
for (const issue of error.issues) {
|
|
174
|
-
console.error(`${file}: ${issue.code} ${issue.path}: ${issue.message}`);
|
|
175
|
-
}
|
|
176
|
-
return 1;
|
|
177
|
-
}
|
|
178
|
-
function usageError(message) {
|
|
179
|
-
console.error(message);
|
|
180
|
-
console.error(USAGE);
|
|
181
|
-
return 2;
|
|
182
|
-
}
|
|
183
|
-
process.exitCode = await main(process.argv.slice(2));
|
|
184
|
-
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AACH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EACL,eAAe,EACf,eAAe,EACf,yBAAyB,EACzB,QAAQ,EACR,QAAQ,EAER,aAAa,GACd,MAAM,YAAY,CAAC;AAEpB,MAAM,KAAK,GAAG;;;;;;;;;;;;;6DAa+C,CAAC;AAE9D,KAAK,UAAU,IAAI,CAAC,IAAuB;IACzC,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAChC,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,MAAM,CAAC;QACZ,KAAK,IAAI,CAAC;QACV,KAAK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AAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/evolution.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { UdlDocument } from "./schema.js";
|
|
2
|
-
import { type UdlIssue } from "./diagnostics.js";
|
|
3
|
-
/** Existing instruments are frozen; a live document may add independent instruments. */
|
|
4
|
-
export declare function diffValidatedUdlEvolution(live: UdlDocument, next: UdlDocument): UdlIssue[];
|
|
5
|
-
//# sourceMappingURL=evolution.d.ts.map
|
package/dist/evolution.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"evolution.d.ts","sourceRoot":"","sources":["../src/evolution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAS,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGxD,wFAAwF;AACxF,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,WAAW,GAChB,QAAQ,EAAE,CAqCZ"}
|
package/dist/evolution.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { issue } from "./diagnostics.js";
|
|
2
|
-
import { writeJson } from "./json.js";
|
|
3
|
-
/** Existing instruments are frozen; a live document may add independent instruments. */
|
|
4
|
-
export function diffValidatedUdlEvolution(live, next) {
|
|
5
|
-
const issues = [];
|
|
6
|
-
const refuse = (path, message) => issues.push(issue("UDL7001", path, message));
|
|
7
|
-
if (live.product !== next.product || live.currency !== next.currency)
|
|
8
|
-
refuse("$", "product identity and currency are immutable");
|
|
9
|
-
for (const [name, party] of Object.entries(live.parties))
|
|
10
|
-
if (!Object.hasOwn(next.parties, name) ||
|
|
11
|
-
writeJson(party) !== writeJson(next.parties[name]))
|
|
12
|
-
refuse(`$.parties.${name}`, "a live party cannot change or disappear");
|
|
13
|
-
for (const object of live.objects) {
|
|
14
|
-
const updated = next.objects.find((o) => o.id === object.id);
|
|
15
|
-
if (!updated || writeJson(object) !== writeJson(updated))
|
|
16
|
-
refuse(`$.objects.${object.id}`, "a live object kind cannot change or disappear; recreate development estates");
|
|
17
|
-
}
|
|
18
|
-
for (const instrument of live.instruments) {
|
|
19
|
-
const updated = next.instruments.find((i) => i.id === instrument.id);
|
|
20
|
-
if (!updated || writeJson(instrument) !== writeJson(updated))
|
|
21
|
-
refuse(`$.instruments.${instrument.id}`, "a live instrument cannot change or disappear; recreate development estates");
|
|
22
|
-
}
|
|
23
|
-
if (writeJson(live) !== writeJson(next) && next.version <= live.version)
|
|
24
|
-
issues.push(issue("UDL7002", "$.version", "a changed document needs a higher version"));
|
|
25
|
-
return issues;
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=evolution.js.map
|
package/dist/evolution.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"evolution.js","sourceRoot":"","sources":["../src/evolution.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAiB,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,wFAAwF;AACxF,MAAM,UAAU,yBAAyB,CACvC,IAAiB,EACjB,IAAiB;IAEjB,MAAM,MAAM,GAAe,EAAE,CAAC;IAC9B,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,OAAe,EAAE,EAAE,CAC/C,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IAC/C,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,QAAQ;QAClE,MAAM,CAAC,GAAG,EAAE,6CAA6C,CAAC,CAAC;IAC7D,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;Q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 -1,5 +0,0 @@
|
|
|
1
|
-
import { type UdlDocument, type UdlInstrument } from "./schema.js";
|
|
2
|
-
/** Visit identities through schema annotations, never through user JSON keys. */
|
|
3
|
-
export declare function mapUdlInstrumentReferences(document: UdlDocument, map: (id: string) => string): UdlDocument;
|
|
4
|
-
export declare function referencedUdlInstrumentIds(instrument: UdlInstrument): readonly string[];
|
|
5
|
-
//# sourceMappingURL=instrument-references.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"instrument-references.d.ts","sourceRoot":"","sources":["../src/instrument-references.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AAOrB,iFAAiF;AACjF,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,WAAW,EACrB,GAAG,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,GAC1B,WAAW,CAkFb;AAED,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,aAAa,GACxB,SAAS,MAAM,EAAE,CAoBnB"}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import * as z from "zod";
|
|
2
|
-
import { udlDocumentSchema, } from "./schema.js";
|
|
3
|
-
const object = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
4
|
-
let documentSchema;
|
|
5
|
-
/** Visit identities through schema annotations, never through user JSON keys. */
|
|
6
|
-
export function mapUdlInstrumentReferences(document, map) {
|
|
7
|
-
const root = (documentSchema ??= z.toJSONSchema(udlDocumentSchema));
|
|
8
|
-
const result = structuredClone(document);
|
|
9
|
-
const locations = new Map();
|
|
10
|
-
function visit(schema, value, parent, key, path) {
|
|
11
|
-
if (!object(schema))
|
|
12
|
-
return;
|
|
13
|
-
if (typeof schema.$ref === "string") {
|
|
14
|
-
if (!schema.$ref.startsWith("#/"))
|
|
15
|
-
throw new Error("UDL reference schema must be local");
|
|
16
|
-
let target = root;
|
|
17
|
-
for (const part of schema.$ref.slice(2).split("/")) {
|
|
18
|
-
target = object(target)
|
|
19
|
-
? target[part.replaceAll("~1", "/").replaceAll("~0", "~")]
|
|
20
|
-
: undefined;
|
|
21
|
-
}
|
|
22
|
-
visit(target, value, parent, key, path);
|
|
23
|
-
}
|
|
24
|
-
const kind = schema["x-udl-reference"];
|
|
25
|
-
if (typeof kind === "string" && typeof value === "string")
|
|
26
|
-
locations.set(JSON.stringify(path), { parent, key, kind });
|
|
27
|
-
for (const union of [schema.anyOf, schema.oneOf, schema.allOf])
|
|
28
|
-
if (Array.isArray(union))
|
|
29
|
-
for (const branch of union)
|
|
30
|
-
visit(branch, value, parent, key, path);
|
|
31
|
-
if (Array.isArray(value)) {
|
|
32
|
-
value.forEach((entry, index) => visit(schema.items, entry, value, index, [...path, index]));
|
|
33
|
-
}
|
|
34
|
-
else if (object(value)) {
|
|
35
|
-
const properties = object(schema.properties) ? schema.properties : {};
|
|
36
|
-
const discriminator = object(properties.type)
|
|
37
|
-
? properties.type.const
|
|
38
|
-
: undefined;
|
|
39
|
-
if ((discriminator === "ref" || discriminator === "list") &&
|
|
40
|
-
value.type === discriminator &&
|
|
41
|
-
value.targetKind === "instrument") {
|
|
42
|
-
if (typeof value.target === "string")
|
|
43
|
-
locations.set(JSON.stringify([...path, "target"]), {
|
|
44
|
-
parent: value,
|
|
45
|
-
key: "target",
|
|
46
|
-
kind: "instrument",
|
|
47
|
-
});
|
|
48
|
-
else if (Array.isArray(value.target))
|
|
49
|
-
value.target.forEach((_, index) => locations.set(JSON.stringify([...path, "target", index]), {
|
|
50
|
-
parent: value.target,
|
|
51
|
-
key: index,
|
|
52
|
-
kind: "instrument",
|
|
53
|
-
}));
|
|
54
|
-
}
|
|
55
|
-
for (const [name, entry] of Object.entries(value))
|
|
56
|
-
visit(properties[name] ?? schema.additionalProperties, entry, value, name, [...path, name]);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
visit(root, result, [result], 0, []);
|
|
60
|
-
for (const { parent, key, kind } of locations.values()) {
|
|
61
|
-
const holder = parent;
|
|
62
|
-
const value = holder[key];
|
|
63
|
-
if (kind === "instrument")
|
|
64
|
-
holder[key] = map(value);
|
|
65
|
-
else if (kind === "instrument_event") {
|
|
66
|
-
const separator = value.indexOf(".");
|
|
67
|
-
holder[key] = map(value.slice(0, separator)) + value.slice(separator);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return result;
|
|
71
|
-
}
|
|
72
|
-
export function referencedUdlInstrumentIds(instrument) {
|
|
73
|
-
const found = new Set();
|
|
74
|
-
mapUdlInstrumentReferences({
|
|
75
|
-
udl: 4,
|
|
76
|
-
version: 1,
|
|
77
|
-
product: "references",
|
|
78
|
-
title: "References",
|
|
79
|
-
currency: "SAR",
|
|
80
|
-
parties: {},
|
|
81
|
-
objects: [],
|
|
82
|
-
instruments: [instrument],
|
|
83
|
-
}, (id) => {
|
|
84
|
-
found.add(id);
|
|
85
|
-
return id;
|
|
86
|
-
});
|
|
87
|
-
found.delete(instrument.id);
|
|
88
|
-
return [...found];
|
|
89
|
-
}
|
|
90
|
-
//# sourceMappingURL=instrument-references.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"instrument-references.js","sourceRoot":"","sources":["../src/instrument-references.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EACL,iBAAiB,GAGlB,MAAM,aAAa,CAAC;AAGrB,MAAM,MAAM,GAAG,CAAC,KAAc,EAAmB,EAAE,CACjD,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACvE,IAAI,cAAkC,CAAC;AAEvC,iFAAiF;AACjF,MAAM,UAAU,0BAA0B,CACxC,QAAqB,EACrB,GAA2B;IAE3B,MAAM,IAAI,GAAG,CAAC,cAAc,KAAK,CAAC,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC,CAAC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CAAC,CAAC;QACxE,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,UAAyB;IAEzB,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,0BAA0B,CACxB;QACE,GAAG,EAAE,CAAC;QACN,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,YAAY;QACrB,KAAK,EAAE,YAAY;QACnB,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,CAAC,UAAU,CAAC;KAC1B,EACD,CAAC,EAAE,EAAE,EAAE;QACL,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACd,OAAO,EAAE,CAAC;IACZ,CAAC,CACF,CAAC;IACF,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAC5B,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;AACpB,CAAC"}
|
package/dist/parser.d.ts
DELETED
package/dist/parser.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAK/C,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,CAmBjE;AAwCD,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CAEnE"}
|
package/dist/parser.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { serializeUdl } from "./canonical.js";
|
|
2
|
-
import { issue } from "./diagnostics.js";
|
|
3
|
-
import { UDL_LIMITS } from "./limits.js";
|
|
4
|
-
import { assertValidUdl, UdlError } from "./validation.js";
|
|
5
|
-
const utf8Decoder = new TextDecoder("utf-8", { fatal: true });
|
|
6
|
-
export function parseUdl(source) {
|
|
7
|
-
const sourceBytes = typeof source === "string"
|
|
8
|
-
? source.length > UDL_LIMITS.maxSourceBytes
|
|
9
|
-
? source.length
|
|
10
|
-
: new TextEncoder().encode(source).byteLength
|
|
11
|
-
: source.byteLength;
|
|
12
|
-
if (sourceBytes > UDL_LIMITS.maxSourceBytes) {
|
|
13
|
-
throw new UdlError([
|
|
14
|
-
issue("UDL1004", "$", `UDL source exceeds ${UDL_LIMITS.maxSourceBytes} bytes`),
|
|
15
|
-
]);
|
|
16
|
-
}
|
|
17
|
-
return parseUdlText(typeof source === "string" ? source : decodeUdlBytes(source));
|
|
18
|
-
}
|
|
19
|
-
function parseUdlText(source) {
|
|
20
|
-
let value;
|
|
21
|
-
try {
|
|
22
|
-
value = JSON.parse(source);
|
|
23
|
-
}
|
|
24
|
-
catch (error) {
|
|
25
|
-
throw new UdlError([
|
|
26
|
-
issue("UDL1002", "$", error instanceof Error ? error.message : "could not parse JSON"),
|
|
27
|
-
]);
|
|
28
|
-
}
|
|
29
|
-
// JSON.parse has already checked syntax. Scan member names before its
|
|
30
|
-
// last-value-wins behavior can erase an authored declaration.
|
|
31
|
-
const members = [];
|
|
32
|
-
let name = "";
|
|
33
|
-
for (const token of source.matchAll(/"(?:[^"\\]|\\.)*"|[{}[\]:]/g)) {
|
|
34
|
-
const text = token[0];
|
|
35
|
-
if (text === "{")
|
|
36
|
-
members.push(new Set());
|
|
37
|
-
else if (text === "[")
|
|
38
|
-
members.push(null);
|
|
39
|
-
else if (text === "}" || text === "]")
|
|
40
|
-
members.pop();
|
|
41
|
-
else if (text === ":") {
|
|
42
|
-
const keys = members[members.length - 1];
|
|
43
|
-
if (keys?.has(name))
|
|
44
|
-
throw new UdlError([
|
|
45
|
-
issue("UDL1002", "$", `duplicate JSON member ${name} at offset ${token.index}`),
|
|
46
|
-
]);
|
|
47
|
-
keys?.add(name);
|
|
48
|
-
}
|
|
49
|
-
else
|
|
50
|
-
name = JSON.parse(text);
|
|
51
|
-
}
|
|
52
|
-
return assertValidUdl(value);
|
|
53
|
-
}
|
|
54
|
-
export function canonicalizeUdl(source) {
|
|
55
|
-
return serializeUdl(parseUdl(source));
|
|
56
|
-
}
|
|
57
|
-
function decodeUdlBytes(source) {
|
|
58
|
-
try {
|
|
59
|
-
return utf8Decoder.decode(source);
|
|
60
|
-
}
|
|
61
|
-
catch {
|
|
62
|
-
throw new UdlError([
|
|
63
|
-
issue("UDL1001", "$", "UDL bytes must be valid UTF-8"),
|
|
64
|
-
]);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
//# sourceMappingURL=parser.js.map
|
package/dist/parser.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3D,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAE9D,MAAM,UAAU,QAAQ,CAAC,MAA2B;IAClD,MAAM,WAAW,GACf,OAAO,MAAM,KAAK,QAAQ;QACxB,CAAC,CAAC,MAAM,CAAC,MAAM,GAAG,UAAU,CAAC,cAAc;YACzC,CAAC,CAAC,MAAM,CAAC,MAAM;YACf,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,UAAU;QAC/C,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC;IACxB,IAAI,WAAW,GAAG,UAAU,CAAC,cAAc,EAAE,CAAC;QAC5C,MAAM,IAAI,QAAQ,CAAC;YACjB,KAAK,CACH,SAAS,EACT,GAAG,E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