@githolon/dsl 0.1.1 → 0.1.3
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/LICENSE.md +1 -1
- package/compile_package.mjs +1 -1
- package/package.json +1 -1
- package/src/compile_package_main.ts +31 -0
- package/src/ops.ts +23 -2
package/LICENSE.md
CHANGED
|
@@ -12,7 +12,7 @@ with it; we keep the rest for now.
|
|
|
12
12
|
authorizes;
|
|
13
13
|
- build, run, and ship applications on top of them — including commercial ones;
|
|
14
14
|
- keep everything that's yours: code you write, and everything these tools
|
|
15
|
-
generate FOR you (scaffolds from `create-
|
|
15
|
+
generate FOR you (scaffolds from `create-githolon` / `githolon generate`, generated
|
|
16
16
|
clients, compiled domain packages) carries NO restriction from us — it is
|
|
17
17
|
yours outright.
|
|
18
18
|
|
package/compile_package.mjs
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// caller's, else the DSL's own dependency) and run `src/compile_package_main.ts`
|
|
10
10
|
// under it (the main dynamically imports the caller's TS domain modules, which
|
|
11
11
|
// needs the tsx ESM loader). tsx is a regular dependency of @githolon/dsl, so a bare
|
|
12
|
-
// `npx
|
|
12
|
+
// `npx githolon compile` / `npx nomos-compile` works with zero devDependency setup.
|
|
13
13
|
// Resolution goes through Node's resolver (createRequire), NOT node_modules/.bin
|
|
14
14
|
// paths — hoisted/workspace installs put the bin shims elsewhere.
|
|
15
15
|
import { execFileSync } from "node:child_process";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@githolon/dsl",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Nomos 2 domain-authoring DSL: aggregates + directives in TS, executed and encoded to the Rust kernel's wire shapes.",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -442,7 +442,24 @@ async function main(): Promise<void> {
|
|
|
442
442
|
const { manifestsPath } = writeIdentity(identity, outDir);
|
|
443
443
|
|
|
444
444
|
// ── 4. the one-call deploy body (package + per-workspace manifest overlay) ──
|
|
445
|
+
// SELF-DESCRIBING: `summary` states what the (otherwise hex-opaque) package
|
|
446
|
+
// contains — purely derived from the inputs (no timestamps), ignored by the
|
|
447
|
+
// deploy endpoint, and mirrored as build/<name>.summary.txt for a human or
|
|
448
|
+
// agent who simply cats the build output.
|
|
449
|
+
const summary = {
|
|
450
|
+
package: cfg.name,
|
|
451
|
+
domainHash,
|
|
452
|
+
domains: domainModules.map((m) => ({
|
|
453
|
+
domain: m.domain ?? m.name,
|
|
454
|
+
aggregates: m.aggregates.map((a) => a.id),
|
|
455
|
+
directives: m.directives.map((d) => d.id),
|
|
456
|
+
queries: (m.queries ?? []).map((q) => q.id),
|
|
457
|
+
counts: (m.counts ?? []).map((c) => c.id),
|
|
458
|
+
identityHash: identity.hashes[m.domain ?? m.name],
|
|
459
|
+
})),
|
|
460
|
+
};
|
|
445
461
|
const deployBody = {
|
|
462
|
+
summary,
|
|
446
463
|
packageUsda: text,
|
|
447
464
|
readManifest,
|
|
448
465
|
identityManifests: identity.manifests,
|
|
@@ -450,6 +467,20 @@ async function main(): Promise<void> {
|
|
|
450
467
|
};
|
|
451
468
|
const deployPath = path.join(outDir, `${cfg.name}.deploy.json`);
|
|
452
469
|
writeFileSync(deployPath, JSON.stringify(deployBody) + "\n", "utf8");
|
|
470
|
+
const summaryTxt = [
|
|
471
|
+
`${cfg.name} — compiled Nomos domain package`,
|
|
472
|
+
`law (domainHash): ${domainHash} # sha256(${cfg.name}.package.usda) — content-addressed`,
|
|
473
|
+
...summary.domains.flatMap((d) => [
|
|
474
|
+
`domain '${d.domain}'${d.identityHash ? ` (identity ${d.identityHash.slice(0, 12)}…)` : " (EXCLUDED from identity manifest)"}`,
|
|
475
|
+
` aggregates: ${d.aggregates.join(", ") || "—"}`,
|
|
476
|
+
` directives: ${d.directives.join(", ") || "—"}`,
|
|
477
|
+
` queries: ${d.queries.join(", ") || "—"} counts: ${d.counts.join(", ") || "—"}`,
|
|
478
|
+
]),
|
|
479
|
+
`deploy: POST ${cfg.name}.deploy.json to /v1/workspaces/<ws>/domains (or: githolon deploy <ws>)`,
|
|
480
|
+
`typed client: ${cfg.name}.client.ts — ${cfg.name}Client(holon), law hash baked in`,
|
|
481
|
+
``,
|
|
482
|
+
].join("\n");
|
|
483
|
+
writeFileSync(path.join(outDir, `${cfg.name}.summary.txt`), summaryTxt, "utf8");
|
|
453
484
|
|
|
454
485
|
// ── 5. the typed TS client (#10 — the web sibling of codegen_dart), with the
|
|
455
486
|
// deployed law's content hash baked in (emitted AFTER the package is hashed) ──
|
package/src/ops.ts
CHANGED
|
@@ -93,11 +93,32 @@ function addressOf(agg: Target): { aggregateId: string; aggregateType?: string }
|
|
|
93
93
|
return { aggregateId: (agg as AggregateHandle).id };
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
/**
|
|
96
|
+
/**
|
|
97
|
+
* Set a scalar (or map-whole/ref) field. Field name + value type are both checked.
|
|
98
|
+
*
|
|
99
|
+
* REFUSES set-kind fields — at the TYPE level (the parameter collapses to an
|
|
100
|
+
* instructive error string) AND at runtime (so the sealed engine refuses non-TS
|
|
101
|
+
* callers too): `set()` on an AddWins set would OVERWRITE the merge — concurrent
|
|
102
|
+
* adds would silently lose. The additive write is {@link addToSet}.
|
|
103
|
+
*/
|
|
97
104
|
export function set<
|
|
98
105
|
A extends Target,
|
|
99
106
|
K extends keyof Fields<A> & string,
|
|
100
|
-
>(
|
|
107
|
+
>(
|
|
108
|
+
agg: A,
|
|
109
|
+
field: K &
|
|
110
|
+
(Fields<A>[K] extends { kind: "set" }
|
|
111
|
+
? `TYPE ERROR: '${K}' is a set field — set() would OVERWRITE the merge; use addToSet(handle, "${K}", values)`
|
|
112
|
+
: K),
|
|
113
|
+
value: FieldValue<Fields<A>[K]>,
|
|
114
|
+
): FieldOp {
|
|
115
|
+
const f = (agg as { fields?: Record<string, { kind?: string }> }).fields?.[field];
|
|
116
|
+
if (f?.kind === "set") {
|
|
117
|
+
throw new Error(
|
|
118
|
+
`set('${field}'): '${field}' is a set field — set() would OVERWRITE the merge ` +
|
|
119
|
+
`(concurrent adds would be lost). Use addToSet(handle, '${field}', values) — the additive write.`,
|
|
120
|
+
);
|
|
121
|
+
}
|
|
101
122
|
return { ...addressOf(agg), field, kind: "set", value };
|
|
102
123
|
}
|
|
103
124
|
|