@orthograph/compiler 0.0.0-stage → 0.1.0-next.2
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 +202 -0
- package/README.md +4 -2
- package/dist/index.d.ts +12 -0
- package/dist/index.js +9 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +18 -0
- package/dist/modules/app/internal/checks.d.ts +30 -0
- package/dist/modules/app/internal/checks.js +99 -0
- package/dist/modules/app/internal/describe.d.ts +6 -0
- package/dist/modules/app/internal/describe.js +59 -0
- package/dist/modules/app/internal/hash.d.ts +1 -0
- package/dist/modules/app/internal/hash.js +7 -0
- package/dist/modules/app/internal/known.d.ts +19 -0
- package/dist/modules/app/internal/known.js +45 -0
- package/dist/modules/app/internal/read.d.ts +6 -0
- package/dist/modules/app/internal/read.js +45 -0
- package/dist/modules/app/service.d.ts +2 -0
- package/dist/modules/app/service.js +3 -0
- package/dist/modules/app/types.d.ts +87 -0
- package/dist/modules/app/types.js +1 -0
- package/dist/modules/compare/internal/assets.d.ts +4 -0
- package/dist/modules/compare/internal/assets.js +40 -0
- package/dist/modules/compare/internal/chain.d.ts +4 -0
- package/dist/modules/compare/internal/chain.js +37 -0
- package/dist/modules/compare/internal/diff.d.ts +3 -0
- package/dist/modules/compare/internal/diff.js +27 -0
- package/dist/modules/compare/internal/versions.d.ts +9 -0
- package/dist/modules/compare/internal/versions.js +75 -0
- package/dist/modules/compare/service.d.ts +2 -0
- package/dist/modules/compare/service.js +43 -0
- package/dist/modules/compare/types.d.ts +47 -0
- package/dist/modules/compare/types.js +1 -0
- package/dist/modules/lock/internal/evolve.d.ts +7 -0
- package/dist/modules/lock/internal/evolve.js +52 -0
- package/dist/modules/lock/internal/runtime.d.ts +3 -0
- package/dist/modules/lock/internal/runtime.js +12 -0
- package/dist/modules/lock/service.d.ts +4 -0
- package/dist/modules/lock/service.js +20 -0
- package/dist/modules/lock/types.d.ts +101 -0
- package/dist/modules/lock/types.js +6 -0
- package/dist/modules/model/internal/allowed.d.ts +26 -0
- package/dist/modules/model/internal/allowed.js +78 -0
- package/dist/modules/model/internal/approval.d.ts +4 -0
- package/dist/modules/model/internal/approval.js +10 -0
- package/dist/modules/model/internal/assets.d.ts +5 -0
- package/dist/modules/model/internal/assets.js +31 -0
- package/dist/modules/model/internal/bits.d.ts +6 -0
- package/dist/modules/model/internal/bits.js +9 -0
- package/dist/modules/model/internal/chain.d.ts +9 -0
- package/dist/modules/model/internal/chain.js +47 -0
- package/dist/modules/model/internal/codes.d.ts +59 -0
- package/dist/modules/model/internal/codes.js +80 -0
- package/dist/modules/model/internal/derive.d.ts +11 -0
- package/dist/modules/model/internal/derive.js +31 -0
- package/dist/modules/model/internal/describe.d.ts +8 -0
- package/dist/modules/model/internal/describe.js +248 -0
- package/dist/modules/model/internal/device.d.ts +5 -0
- package/dist/modules/model/internal/device.js +12 -0
- package/dist/modules/model/internal/environments.d.ts +7 -0
- package/dist/modules/model/internal/environments.js +90 -0
- package/dist/modules/model/internal/exits.d.ts +49 -0
- package/dist/modules/model/internal/exits.js +85 -0
- package/dist/modules/model/internal/fields.d.ts +23 -0
- package/dist/modules/model/internal/fields.js +50 -0
- package/dist/modules/model/internal/fillable.d.ts +3 -0
- package/dist/modules/model/internal/fillable.js +9 -0
- package/dist/modules/model/internal/forms.d.ts +47 -0
- package/dist/modules/model/internal/forms.js +75 -0
- package/dist/modules/model/internal/found.d.ts +40 -0
- package/dist/modules/model/internal/found.js +60 -0
- package/dist/modules/model/internal/handler-files.d.ts +18 -0
- package/dist/modules/model/internal/handler-files.js +23 -0
- package/dist/modules/model/internal/hash.d.ts +4 -0
- package/dist/modules/model/internal/hash.js +7 -0
- package/dist/modules/model/internal/holds.d.ts +19 -0
- package/dist/modules/model/internal/holds.js +65 -0
- package/dist/modules/model/internal/invariants.d.ts +38 -0
- package/dist/modules/model/internal/invariants.js +134 -0
- package/dist/modules/model/internal/journeys.d.ts +15 -0
- package/dist/modules/model/internal/journeys.js +135 -0
- package/dist/modules/model/internal/layout.d.ts +143 -0
- package/dist/modules/model/internal/layout.js +203 -0
- package/dist/modules/model/internal/lock-fields.d.ts +3 -0
- package/dist/modules/model/internal/lock-fields.js +17 -0
- package/dist/modules/model/internal/money.d.ts +17 -0
- package/dist/modules/model/internal/money.js +49 -0
- package/dist/modules/model/internal/nullable.d.ts +7 -0
- package/dist/modules/model/internal/nullable.js +21 -0
- package/dist/modules/model/internal/operations.d.ts +27 -0
- package/dist/modules/model/internal/operations.js +81 -0
- package/dist/modules/model/internal/reads.d.ts +16 -0
- package/dist/modules/model/internal/reads.js +58 -0
- package/dist/modules/model/internal/rules.d.ts +2 -0
- package/dist/modules/model/internal/rules.js +33 -0
- package/dist/modules/model/internal/same-value.d.ts +10 -0
- package/dist/modules/model/internal/same-value.js +50 -0
- package/dist/modules/model/internal/secrets.d.ts +4 -0
- package/dist/modules/model/internal/secrets.js +35 -0
- package/dist/modules/model/internal/source-refusals.d.ts +7 -0
- package/dist/modules/model/internal/source-refusals.js +52 -0
- package/dist/modules/model/internal/sources.d.ts +12 -0
- package/dist/modules/model/internal/sources.js +65 -0
- package/dist/modules/model/internal/stores.d.ts +20 -0
- package/dist/modules/model/internal/stores.js +44 -0
- package/dist/modules/model/internal/things.d.ts +33 -0
- package/dist/modules/model/internal/things.js +99 -0
- package/dist/modules/model/service.d.ts +4 -0
- package/dist/modules/model/service.js +105 -0
- package/dist/modules/model/types.d.ts +485 -0
- package/dist/modules/model/types.js +5 -0
- package/dist/modules/mounts/fixtures/both/things/echo/thing.d.ts +1 -0
- package/dist/modules/mounts/fixtures/both/things/echo/thing.js +1 -0
- package/dist/modules/mounts/fixtures/both/things/echo/verbs/only.d.ts +1 -0
- package/dist/modules/mounts/fixtures/both/things/echo/verbs/only.js +1 -0
- package/dist/modules/mounts/internal/attribute.d.ts +2 -0
- package/dist/modules/mounts/internal/attribute.js +4 -0
- package/dist/modules/mounts/internal/calls.d.ts +12 -0
- package/dist/modules/mounts/internal/calls.js +42 -0
- package/dist/modules/mounts/internal/choices.d.ts +11 -0
- package/dist/modules/mounts/internal/choices.js +34 -0
- package/dist/modules/mounts/internal/fold.d.ts +6 -0
- package/dist/modules/mounts/internal/fold.js +8 -0
- package/dist/modules/mounts/internal/needs.d.ts +14 -0
- package/dist/modules/mounts/internal/needs.js +26 -0
- package/dist/modules/mounts/internal/verbs.d.ts +11 -0
- package/dist/modules/mounts/internal/verbs.js +44 -0
- package/dist/modules/mounts/service.d.ts +2 -0
- package/dist/modules/mounts/service.js +165 -0
- package/dist/modules/mounts/types.d.ts +78 -0
- package/dist/modules/mounts/types.js +1 -0
- package/dist/modules/source/internal/plugins.d.ts +25 -0
- package/dist/modules/source/internal/plugins.js +49 -0
- package/dist/modules/source/service.d.ts +6 -0
- package/dist/modules/source/service.js +86 -0
- package/dist/modules/source/types.d.ts +55 -0
- package/dist/modules/source/types.js +6 -0
- package/dist/modules/time/internal/anchor.d.ts +2 -0
- package/dist/modules/time/internal/anchor.js +48 -0
- package/dist/modules/time/internal/keeper.d.ts +13 -0
- package/dist/modules/time/internal/keeper.js +19 -0
- package/dist/modules/time/internal/zones.d.ts +1 -0
- package/dist/modules/time/internal/zones.js +3 -0
- package/dist/modules/time/service.d.ts +2 -0
- package/dist/modules/time/service.js +56 -0
- package/dist/modules/time/types.d.ts +89 -0
- package/dist/modules/time/types.js +1 -0
- package/package.json +35 -3
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { App, AppComponent, AppPage, LayoutName, Operation, Read, Role, Thing, Value } from "orthograph";
|
|
2
|
+
import type { LoadedFile } from "#modules/source/types.js";
|
|
3
|
+
import type { AllowedModel, FieldModel, Model } from "#modules/model/types.js";
|
|
4
|
+
/** A page: its file, its route with each parameter typed, who may open it, and what it shows and offers (its own, then its components'). */
|
|
5
|
+
export interface PageModel {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly file: string;
|
|
8
|
+
readonly description: string;
|
|
9
|
+
readonly route: {
|
|
10
|
+
readonly path: string;
|
|
11
|
+
readonly params: Readonly<Record<string, FieldModel>>;
|
|
12
|
+
};
|
|
13
|
+
/** The page above it; absent for a page at the top. */
|
|
14
|
+
readonly parent?: string;
|
|
15
|
+
readonly allowed: ReadonlyArray<AllowedModel>;
|
|
16
|
+
/** The effective lists, as operation names (`profile.get`): the page's own, then each component's, each named once. */
|
|
17
|
+
readonly shows: ReadonlyArray<string>;
|
|
18
|
+
readonly offers: ReadonlyArray<string>;
|
|
19
|
+
/** The components it holds, by name. */
|
|
20
|
+
readonly components: ReadonlyArray<string>;
|
|
21
|
+
readonly hash: string;
|
|
22
|
+
}
|
|
23
|
+
/** A composite component (K36): what a region of a page shows and offers, which no single operation says. */
|
|
24
|
+
export interface ComponentModel {
|
|
25
|
+
readonly name: string;
|
|
26
|
+
readonly file: string;
|
|
27
|
+
readonly description: string;
|
|
28
|
+
readonly shows: ReadonlyArray<string>;
|
|
29
|
+
readonly offers: ReadonlyArray<string>;
|
|
30
|
+
readonly hash: string;
|
|
31
|
+
}
|
|
32
|
+
/** A navigation group: pages by name, in the order declared. */
|
|
33
|
+
export interface NavGroupModel {
|
|
34
|
+
readonly title: string;
|
|
35
|
+
readonly pages: ReadonlyArray<string>;
|
|
36
|
+
readonly folded: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface AppModel {
|
|
39
|
+
readonly description: string;
|
|
40
|
+
readonly layout: LayoutName;
|
|
41
|
+
readonly home: string;
|
|
42
|
+
readonly nav: ReadonlyArray<NavGroupModel>;
|
|
43
|
+
readonly pages: Readonly<Record<string, PageModel>>;
|
|
44
|
+
readonly components: Readonly<Record<string, ComponentModel>>;
|
|
45
|
+
readonly hash: string;
|
|
46
|
+
}
|
|
47
|
+
/** The files of `blueprint/app/`, read: the app, each page and each component by the name its file gives it. */
|
|
48
|
+
export interface AppFiles {
|
|
49
|
+
/** Whether the blueprint has an `app/` folder at all. */
|
|
50
|
+
readonly present: boolean;
|
|
51
|
+
readonly app: {
|
|
52
|
+
readonly file: string;
|
|
53
|
+
readonly declaration: App;
|
|
54
|
+
} | undefined;
|
|
55
|
+
readonly pages: ReadonlyMap<string, {
|
|
56
|
+
readonly file: string;
|
|
57
|
+
readonly declaration: AppPage;
|
|
58
|
+
}>;
|
|
59
|
+
readonly components: ReadonlyMap<string, {
|
|
60
|
+
readonly file: string;
|
|
61
|
+
readonly declaration: AppComponent;
|
|
62
|
+
}>;
|
|
63
|
+
readonly problems: ReadonlyArray<string>;
|
|
64
|
+
}
|
|
65
|
+
/** What the app's declarations are matched against: the blueprint's own layout (the model's `Layout` has this shape), by the names its paths gave. */
|
|
66
|
+
export interface AppWorld {
|
|
67
|
+
readonly values: ReadonlyMap<string, Value>;
|
|
68
|
+
readonly things: ReadonlyMap<string, {
|
|
69
|
+
readonly thing?: Thing | undefined;
|
|
70
|
+
readonly roles: ReadonlyMap<string, Role>;
|
|
71
|
+
readonly verbs: ReadonlyMap<string, {
|
|
72
|
+
readonly declaration: Operation | Read;
|
|
73
|
+
}>;
|
|
74
|
+
}>;
|
|
75
|
+
}
|
|
76
|
+
export interface AppApi {
|
|
77
|
+
/** Take the `app/` files out of the blueprint's files, before the rest is laid out; what is left is what `readLayout` reads. */
|
|
78
|
+
readonly setAside: (files: ReadonlyArray<LoadedFile>) => {
|
|
79
|
+
readonly app: AppFiles;
|
|
80
|
+
readonly rest: ReadonlyArray<LoadedFile>;
|
|
81
|
+
};
|
|
82
|
+
/** The map, once the model is described: `app` absent when the blueprint has no `app/` folder. Problems each name their file. */
|
|
83
|
+
readonly describe: (files: AppFiles, world: AppWorld, model: Model) => {
|
|
84
|
+
readonly app?: AppModel;
|
|
85
|
+
readonly problems: ReadonlyArray<string>;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Model } from "#modules/model/types.js";
|
|
2
|
+
import type { Versioned } from "../types.ts";
|
|
3
|
+
/** Each asset that was added, removed or changed: major when a money field of `before` counts it and it changed or went, else a patch. */
|
|
4
|
+
export declare const assetBumps: (before: Model, after: Model) => ReadonlyArray<Versioned>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// What a change to a declared asset means for the version (M6-chain item 2): a row's amounts are what it means for good, so an asset
|
|
2
|
+
// that a money field counts, changed or gone, is another number to every old reader. One nothing counts moves nothing.
|
|
3
|
+
import { canonical } from "#modules/model/service.js";
|
|
4
|
+
/** Every asset name a money field counts, wherever it sits in the things and operations (`{ asset: { token: "usdc" } }`). */
|
|
5
|
+
const referenced = (x, into = new Set()) => {
|
|
6
|
+
if (Array.isArray(x))
|
|
7
|
+
x.forEach((v) => referenced(v, into));
|
|
8
|
+
else if (typeof x === "object" && x !== null) {
|
|
9
|
+
const o = x;
|
|
10
|
+
const asset = o["type"] === "money" ? o["asset"] : undefined;
|
|
11
|
+
for (const k of ["token", "currency"])
|
|
12
|
+
if (typeof asset?.[k] === "string")
|
|
13
|
+
into.add(asset[k]);
|
|
14
|
+
Object.values(o).forEach((v) => referenced(v, into));
|
|
15
|
+
}
|
|
16
|
+
return into;
|
|
17
|
+
};
|
|
18
|
+
/** The parts of a definition that differ, `code EUR to JPY`; the file says where it lives, not what it is. */
|
|
19
|
+
const detailOf = (a, b) => {
|
|
20
|
+
const [x, y] = [a, b];
|
|
21
|
+
const said = [...new Set([...Object.keys(x), ...Object.keys(y)])].filter((k) => k !== "file" && k !== "name" && canonical(x[k]) !== canonical(y[k]))
|
|
22
|
+
.sort().map((k) => `${k} ${x[k] === undefined ? "added" : y[k] === undefined ? "removed" : `${canonical(x[k])} to ${canonical(y[k])}`}`);
|
|
23
|
+
return said.length > 0 ? said.join(", ") : undefined;
|
|
24
|
+
};
|
|
25
|
+
/** Each asset that was added, removed or changed: major when a money field of `before` counts it and it changed or went, else a patch. */
|
|
26
|
+
export const assetBumps = (before, after) => {
|
|
27
|
+
const [a, b] = [before.assets ?? {}, after.assets ?? {}];
|
|
28
|
+
const counted = referenced([before.things, before.operations]);
|
|
29
|
+
return [...new Set([...Object.keys(a), ...Object.keys(b)])].sort().flatMap((name) => {
|
|
30
|
+
const what = `asset:${name}`;
|
|
31
|
+
const [was, now] = [a[name], b[name]];
|
|
32
|
+
if (!was)
|
|
33
|
+
return [{ kind: "added", what, bump: "patch" }];
|
|
34
|
+
const bump = counted.has(name) ? "major" : "patch";
|
|
35
|
+
if (!now)
|
|
36
|
+
return [{ kind: "removed", what, bump }];
|
|
37
|
+
const detail = detailOf(was, now);
|
|
38
|
+
return detail === undefined ? [] : [{ kind: "changed", what, detail, bump }];
|
|
39
|
+
});
|
|
40
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Model } from "#modules/model/types.js";
|
|
2
|
+
import type { Versioned } from "../types.ts";
|
|
3
|
+
/** The bumps a change to one thing makes beyond a patch: its place, the numbers of its states on chain, and what its amounts count. */
|
|
4
|
+
export declare const thingBumps: (name: string, before: Model, after: Model) => ReadonlyArray<Versioned>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { canonical } from "#modules/model/service.js";
|
|
2
|
+
const onChain = (model, t) => t.store !== undefined && model.stores?.[t.store]?.kind === "chain.evm";
|
|
3
|
+
/** Each field of a thing by place (`fields.limit`, `events.Spent.amount`, `errors.Exceeded.remaining`), with its value as recorded. */
|
|
4
|
+
const valuesOf = (t) => {
|
|
5
|
+
const at = (place, fields) => Object.entries(fields).map(([k, f]) => [`${place}.${k}`, canonical(f.value)]);
|
|
6
|
+
return new Map([
|
|
7
|
+
...at("fields", t.fields),
|
|
8
|
+
...Object.entries(t.events).flatMap(([e, f]) => at(`events.${e}`, f)),
|
|
9
|
+
...Object.entries(t.errors).flatMap(([e, x]) => at(`errors.${e}`, x.fields)),
|
|
10
|
+
]);
|
|
11
|
+
};
|
|
12
|
+
/** The bumps a change to one thing makes beyond a patch: its place, the numbers of its states on chain, and what its amounts count. */
|
|
13
|
+
export const thingBumps = (name, before, after) => {
|
|
14
|
+
const [was, now] = [before.things[name], after.things[name]];
|
|
15
|
+
if (!was || !now)
|
|
16
|
+
return [];
|
|
17
|
+
const [wasChain, nowChain] = [onChain(before, was), onChain(after, now)];
|
|
18
|
+
const what = `thing:${name}`;
|
|
19
|
+
if (wasChain !== nowChain)
|
|
20
|
+
return [{ kind: "changed", what, detail: nowChain ? "moved to a chain store" : "moved off a chain store", bump: "major" }];
|
|
21
|
+
const out = [];
|
|
22
|
+
if (wasChain) {
|
|
23
|
+
const [a, b] = [was.stateNumbers ?? {}, now.stateNumbers ?? {}];
|
|
24
|
+
const moved = Object.entries(a).filter(([s, n]) => b[s] !== n).map(([s]) => s);
|
|
25
|
+
const added = Object.keys(b).filter((s) => !(s in a));
|
|
26
|
+
if (moved.length > 0)
|
|
27
|
+
out.push({ kind: "changed", what, detail: `states renumbered or removed: ${moved.join(", ")}`, bump: "major" });
|
|
28
|
+
else if (added.length > 0)
|
|
29
|
+
out.push({ kind: "changed", what, detail: `states added at the end: ${added.join(", ")}`, bump: "minor" });
|
|
30
|
+
}
|
|
31
|
+
// An amount that counts another asset, has other bits or another sign, or that stops or starts being money, means another number to every old reader.
|
|
32
|
+
const [a, b] = [valuesOf(was), valuesOf(now)];
|
|
33
|
+
const counted = [...a].filter(([place, v]) => b.has(place) && b.get(place) !== v && (v.includes('"money"') || b.get(place).includes('"money"'))).map(([place]) => place);
|
|
34
|
+
if (counted.length > 0)
|
|
35
|
+
out.push({ kind: "changed", what, detail: `what an amount counts changed: ${counted.join(", ")}`, bump: "major" });
|
|
36
|
+
return out;
|
|
37
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { canonical } from "#modules/model/service.js";
|
|
2
|
+
const KINDS = [
|
|
3
|
+
["value", (m) => m.values],
|
|
4
|
+
["thing", (m) => m.things],
|
|
5
|
+
["operation", (m) => m.operations],
|
|
6
|
+
];
|
|
7
|
+
// Compared as canonical text: a model that has been through the logbook has its keys sorted, one just compiled has not.
|
|
8
|
+
const same = (a, b) => canonical(a) === canonical(b);
|
|
9
|
+
/** The top-level fields of two entries that differ, leaving out the hash, which differs whenever any of them does. */
|
|
10
|
+
const partsOf = (a, b) => {
|
|
11
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null)
|
|
12
|
+
return same(a, b) ? [] : ["value"];
|
|
13
|
+
const keys = [...new Set([...Object.keys(a), ...Object.keys(b)])].filter((k) => k !== "hash").sort();
|
|
14
|
+
return keys.filter((k) => !same(a[k], b[k]));
|
|
15
|
+
};
|
|
16
|
+
export const diff = (before, after) => KINDS.flatMap(([kind, of]) => {
|
|
17
|
+
const a = of(before);
|
|
18
|
+
const b = of(after);
|
|
19
|
+
return [...new Set([...Object.keys(a), ...Object.keys(b)])].sort().flatMap((name) => {
|
|
20
|
+
if (!(name in b))
|
|
21
|
+
return [{ kind, name, change: "removed", parts: [] }];
|
|
22
|
+
if (!(name in a))
|
|
23
|
+
return [{ kind, name, change: "added", parts: [] }];
|
|
24
|
+
const parts = partsOf(a[name], b[name]);
|
|
25
|
+
return parts.length === 0 ? [] : [{ kind, name, change: "changed", parts }];
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Model } from "#modules/model/types.js";
|
|
2
|
+
import type { Bump, Release } from "../types.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Everything that differs between two models, each with what it does to the version, and the largest of them.
|
|
5
|
+
* Nothing different still makes a release (a rebuilt revision, never an identical version), so it is a patch.
|
|
6
|
+
*/
|
|
7
|
+
export declare const release: (before: Model, after: Model) => Release;
|
|
8
|
+
/** The version after `last` for `bump`: `1.0.0` when there is no release yet; undefined when `last` is not a plain `x.y.z`. */
|
|
9
|
+
export declare const next: (last: string | undefined, bump: Bump) => string | undefined;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// What a change to the model means for the version (D3 #1): an added operation or read is minor; a changed payload, answer
|
|
2
|
+
// or error set (or a removed operation) is major; anything else, a budget or the docs, is a patch.
|
|
3
|
+
import { canonical } from "#modules/model/service.js";
|
|
4
|
+
import { assetBumps } from "./assets.js";
|
|
5
|
+
import { thingBumps } from "./chain.js";
|
|
6
|
+
import { diff } from "./diff.js";
|
|
7
|
+
const RANK = { patch: 0, minor: 1, major: 2 };
|
|
8
|
+
/** The parts of an operation that callers depend on: what goes in, what comes out, and what it can refuse with. */
|
|
9
|
+
const BREAKING = new Set(["payload", "answer", "errors", "refusals"]);
|
|
10
|
+
/** Parts that move with the file or the hash, saying nothing of what the operation is. */
|
|
11
|
+
const QUIET = new Set(["file", "identifier"]);
|
|
12
|
+
const keysOf = (x) => (Array.isArray(x) ? x.map(String) : typeof x === "object" && x !== null ? Object.keys(x) : []);
|
|
13
|
+
/** `memo removed, to added`: how a payload, an answer or an error list differs, by name. */
|
|
14
|
+
const detailOf = (part, before, after) => {
|
|
15
|
+
if (part === "budget") {
|
|
16
|
+
const ms = (b) => (typeof b === "object" && b !== null ? `${b.p95Ms}ms` : "none");
|
|
17
|
+
return `${ms(before)} to ${ms(after)}`;
|
|
18
|
+
}
|
|
19
|
+
if (!BREAKING.has(part))
|
|
20
|
+
return undefined;
|
|
21
|
+
const a = keysOf(before);
|
|
22
|
+
const b = keysOf(after);
|
|
23
|
+
const said = [
|
|
24
|
+
...a.filter((k) => !b.includes(k)).map((k) => `${k} removed`),
|
|
25
|
+
...b.filter((k) => !a.includes(k)).map((k) => `${k} added`),
|
|
26
|
+
...b.filter((k) => a.includes(k) && canonical(before[k]) !== canonical(after[k])).map((k) => `${k} changed`),
|
|
27
|
+
];
|
|
28
|
+
return said.length > 0 ? said.join(", ") : "changed";
|
|
29
|
+
};
|
|
30
|
+
const entriesOf = (change, before, after) => {
|
|
31
|
+
if (change.kind !== "operation") {
|
|
32
|
+
// A thing or a value moves nothing a caller sees by itself: what an operation takes or gives shows in its own entry.
|
|
33
|
+
// On a chain it does: a row's states and amounts are what it means for good (M6-chain item 2).
|
|
34
|
+
const quiet = { kind: change.change, what: `${change.kind === "thing" ? "thing:" : "value:"}${change.name}`, bump: "patch" };
|
|
35
|
+
return change.kind === "thing" && change.change === "changed" ? [quiet, ...thingBumps(change.name, before, after)] : [quiet];
|
|
36
|
+
}
|
|
37
|
+
if (change.change === "added")
|
|
38
|
+
return [{ kind: "added", what: change.name, bump: "minor" }];
|
|
39
|
+
if (change.change === "removed")
|
|
40
|
+
return [{ kind: "removed", what: change.name, bump: "major" }];
|
|
41
|
+
const was = before.operations[change.name];
|
|
42
|
+
const now = after.operations[change.name];
|
|
43
|
+
return change.parts.filter((p) => !QUIET.has(p)).map((part) => {
|
|
44
|
+
const detail = detailOf(part, was[part], now[part]);
|
|
45
|
+
return { kind: "changed", what: `${change.name}.${part}`, ...(detail ? { detail } : {}), bump: BREAKING.has(part) ? "major" : "patch" };
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* A refusal code that shipped is a promise (L2.P): clients match on `[AL-002]`. One that changed, or went away with its
|
|
50
|
+
* refusal, is major. A new refusal's code is new, and moves nothing.
|
|
51
|
+
*/
|
|
52
|
+
const movedCodes = (before, after) => Object.entries(before.refusals ?? {}).flatMap(([name, code]) => {
|
|
53
|
+
const now = after.refusals?.[name];
|
|
54
|
+
return now === code ? [] : [{ kind: now === undefined ? "removed" : "changed", what: `refusal:${name}`, detail: now === undefined ? `${code} removed` : `${code} to ${now}`, bump: "major" }];
|
|
55
|
+
});
|
|
56
|
+
/**
|
|
57
|
+
* Everything that differs between two models, each with what it does to the version, and the largest of them.
|
|
58
|
+
* Nothing different still makes a release (a rebuilt revision, never an identical version), so it is a patch.
|
|
59
|
+
*/
|
|
60
|
+
export const release = (before, after) => {
|
|
61
|
+
const changes = [...diff(before, after).flatMap((c) => entriesOf(c, before, after)), ...movedCodes(before, after), ...assetBumps(before, after)];
|
|
62
|
+
const bump = changes.reduce((top, c) => (RANK[c.bump] > RANK[top] ? c.bump : top), "patch");
|
|
63
|
+
return { bump, changes };
|
|
64
|
+
};
|
|
65
|
+
const SEMVER = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
|
|
66
|
+
/** The version after `last` for `bump`: `1.0.0` when there is no release yet; undefined when `last` is not a plain `x.y.z`. */
|
|
67
|
+
export const next = (last, bump) => {
|
|
68
|
+
if (last === undefined)
|
|
69
|
+
return "1.0.0";
|
|
70
|
+
const m = SEMVER.exec(last);
|
|
71
|
+
if (!m)
|
|
72
|
+
return undefined;
|
|
73
|
+
const [major, minor, patch] = [Number(m[1]), Number(m[2]), Number(m[3])];
|
|
74
|
+
return bump === "major" ? `${major + 1}.0.0` : bump === "minor" ? `${major}.${minor + 1}.0` : `${major}.${minor}.${patch + 1}`;
|
|
75
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { diff } from "./internal/diff.js";
|
|
2
|
+
import { next, release } from "./internal/versions.js";
|
|
3
|
+
/** The mounts an operation calls out through, in name order. */
|
|
4
|
+
const callsOf = (op) => [...new Set(Object.values(op.steps).flatMap((s) => (s.call ? [s.call.mount] : [])))].sort();
|
|
5
|
+
const dependsOn = (model, name) => {
|
|
6
|
+
const op = model.operations[name];
|
|
7
|
+
if (!op)
|
|
8
|
+
return {};
|
|
9
|
+
const thingOf = (ref) => (ref ? [ref.split(".")[0]] : []);
|
|
10
|
+
const fields = [...Object.values(op.payload), ...Object.values(op.answer), ...Object.values(model.things[op.thing]?.fields ?? {})];
|
|
11
|
+
const roles = op.allowed.flatMap((a) => ("role" in a ? thingOf(a.role) : []));
|
|
12
|
+
const things = [...new Set([op.thing, ...fields.flatMap((f) => thingOf(f.ref)), ...roles])].sort();
|
|
13
|
+
// A plugin's operation rests on its mount: the picks, the verbs and the installed package's bytes (M1-plugins section 7).
|
|
14
|
+
// Stored models from before M1.03 may have no discriminator.
|
|
15
|
+
const from = op.from?.kind === "app" ? undefined : op.from;
|
|
16
|
+
const mount = from ? model.mounts?.[from.mount] : undefined;
|
|
17
|
+
// An operation that calls an adapter rests on that mount too: its picks and its installed bytes (section 9).
|
|
18
|
+
const reached = callsOf(op).flatMap((m) => (model.mounts?.[m] ? [[`${model.mounts[m].kind}:${m}`, model.mounts[m].hash]] : []));
|
|
19
|
+
return {
|
|
20
|
+
[`operation:${name}`]: op.hash,
|
|
21
|
+
...Object.fromEntries(things.flatMap((t) => (model.things[t] ? [[`thing:${t}`, model.things[t].hash]] : []))),
|
|
22
|
+
...(mount && from ? { [`${mount.kind}:${from.mount}`]: mount.hash } : {}),
|
|
23
|
+
...Object.fromEntries(reached),
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
const hashOf = (model, key) => {
|
|
27
|
+
const [kind, name] = key.split(/:(.*)/s);
|
|
28
|
+
if (kind === "operation")
|
|
29
|
+
return model.operations[name]?.hash;
|
|
30
|
+
if (kind === "thing")
|
|
31
|
+
return model.things[name]?.hash;
|
|
32
|
+
const mount = model.mounts?.[name];
|
|
33
|
+
return mount && mount.kind === kind ? mount.hash : undefined;
|
|
34
|
+
};
|
|
35
|
+
const edges = (model) => {
|
|
36
|
+
const lines = Object.entries(model.mounts ?? {}).flatMap(([name, m]) => [
|
|
37
|
+
...Object.values(model.operations).filter((op) => op.from?.kind !== "app" && op.from?.mount === name).map((op) => `${m.kind}:${name} -> ${op.name} provides`),
|
|
38
|
+
...(m.needs ?? []).map((need) => `${m.kind}:${name} -> ${need} needs`),
|
|
39
|
+
...Object.values(model.operations).filter((op) => callsOf(op).includes(name)).map((op) => `${m.kind}:${name} -> ${op.name} used-by`),
|
|
40
|
+
]);
|
|
41
|
+
return [...new Set(lines)].sort();
|
|
42
|
+
};
|
|
43
|
+
export const Compare = { models: diff, release, next, dependsOn, hashOf, edges };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Model } from "#modules/model/types.js";
|
|
2
|
+
export type Kind = "value" | "thing" | "operation";
|
|
3
|
+
/** One declaration that differs between two models. `parts` names the fields of its entry that changed. */
|
|
4
|
+
export interface Change {
|
|
5
|
+
readonly kind: Kind;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly change: "added" | "removed" | "changed";
|
|
8
|
+
readonly parts: ReadonlyArray<string>;
|
|
9
|
+
}
|
|
10
|
+
/** What an operation's proof rests on: `operation:<name>` and `thing:<name>`, each with the hash it had. */
|
|
11
|
+
export type Depends = Readonly<Record<string, string>>;
|
|
12
|
+
export type Bump = "major" | "minor" | "patch";
|
|
13
|
+
/** One line of `changes.json`: what changed in a declaration's part and what it does to the version. */
|
|
14
|
+
export interface Versioned {
|
|
15
|
+
readonly kind: "added" | "removed" | "changed";
|
|
16
|
+
/** `allowance.list`, or `allowance.spend.payload` for a part of one; `thing:` and `value:` for those. */
|
|
17
|
+
readonly what: string;
|
|
18
|
+
readonly detail?: string;
|
|
19
|
+
readonly bump: Bump;
|
|
20
|
+
}
|
|
21
|
+
/** The changes between two models and the version bump they make together. */
|
|
22
|
+
export interface Release {
|
|
23
|
+
readonly bump: Bump;
|
|
24
|
+
readonly changes: ReadonlyArray<Versioned>;
|
|
25
|
+
}
|
|
26
|
+
export interface CompareApi {
|
|
27
|
+
/** Every declaration that was added, removed or changed from `before` to `after`, in kind then name order. */
|
|
28
|
+
readonly models: (before: Model, after: Model) => ReadonlyArray<Change>;
|
|
29
|
+
/**
|
|
30
|
+
* What the changes mean for the version (D3 #1): an added operation or read is minor; a changed payload, answer or
|
|
31
|
+
* error set, or a removed operation, is major; anything else (a budget, the docs) is a patch.
|
|
32
|
+
*/
|
|
33
|
+
readonly release: (before: Model, after: Model) => Release;
|
|
34
|
+
/** The version after `last` for `bump`: `1.0.0` when there is none; undefined when `last` is not `x.y.z`. */
|
|
35
|
+
readonly next: (last: string | undefined, bump: Bump) => string | undefined;
|
|
36
|
+
/** The declarations an operation's proof depends on: itself, its thing, the things its own or its
|
|
37
|
+
* thing's fields refer to, and the things whose roles may call it. */
|
|
38
|
+
readonly dependsOn: (model: Model, operation: string) => Depends;
|
|
39
|
+
/** The current hash of each key of `depends`, or undefined when it no longer exists. */
|
|
40
|
+
readonly hashOf: (model: Model, key: string) => string | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* What each mount provides and needs, one line each, sorted and without duplicates:
|
|
43
|
+
* `feature:echo -> echo.repeat provides`, `feature:greet -> feature:echo needs`, and for an adapter the
|
|
44
|
+
* operation that calls it, `adapter:pricing -> probe.quote used-by`. None without mounts.
|
|
45
|
+
*/
|
|
46
|
+
readonly edges: (model: Model) => ReadonlyArray<string>;
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Lock, Wanted } from "../types.ts";
|
|
2
|
+
/** The lock after the blueprint, and the code each wanted refusal got (in the order asked: two that claim one code are both told it). */
|
|
3
|
+
export declare const assign: (before: Lock, wanted: ReadonlyArray<Wanted>) => {
|
|
4
|
+
readonly lock: Lock;
|
|
5
|
+
readonly codes: ReadonlyArray<string>;
|
|
6
|
+
};
|
|
7
|
+
export declare const evolve: (before: Lock, wanted: ReadonlyArray<Wanted>) => Lock;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** A declared error is numbered below this: 900 is every machine's refusal and 901 its not-found (M6-chain item 4). */
|
|
2
|
+
const GENERATED = 900;
|
|
3
|
+
const numberOf = (code) => Number(code.slice(code.indexOf("-") + 1));
|
|
4
|
+
const prefixOf = (code) => code.slice(0, code.indexOf("-"));
|
|
5
|
+
const codeOf = (prefix, n) => `${prefix}-${String(n).padStart(3, "0")}`;
|
|
6
|
+
const byCode = (m) => Object.fromEntries(Object.entries(m).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)));
|
|
7
|
+
const sameWire = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
8
|
+
/** The entry for a wanted refusal: what the blueprint says now, and every wire identity the code had before kept in `earlier`. */
|
|
9
|
+
const entryOf = (w, was) => {
|
|
10
|
+
const wire = { effect: { tag: w.name }, ...(was?.wire.solidity ? { solidity: was.wire.solidity } : {}) };
|
|
11
|
+
const left = was && !sameWire(was.wire, wire) && was.wire.effect?.tag !== w.name ? [was.wire] : [];
|
|
12
|
+
const earlier = [...(was?.earlier ?? []), ...left.filter((l) => !(was?.earlier ?? []).some((e) => sameWire(e, l)))];
|
|
13
|
+
return { name: w.name, owner: w.owner, ...(w.from === undefined ? {} : { from: w.from }), fields: w.fields, wire, earlier };
|
|
14
|
+
};
|
|
15
|
+
/** The lock after the blueprint, and the code each wanted refusal got (in the order asked: two that claim one code are both told it). */
|
|
16
|
+
export const assign = (before, wanted) => {
|
|
17
|
+
const codes = [];
|
|
18
|
+
const live = {};
|
|
19
|
+
const retired = { ...before.retired };
|
|
20
|
+
/** Every code the lock has ever held or this pass has given: a declared error's next number is above all of them. */
|
|
21
|
+
const used = new Set([...Object.keys(before.refusals), ...Object.keys(before.retired)]);
|
|
22
|
+
const taken = (code) => code in live;
|
|
23
|
+
const find = (w) => {
|
|
24
|
+
if (w.code !== undefined)
|
|
25
|
+
return { code: w.code, was: before.refusals[w.code] ?? retired[w.code] };
|
|
26
|
+
// By name, owner and number, not prefix: a code that shipped is a promise clients match on, so it outlives its thing's prefix.
|
|
27
|
+
const holds = (e, code) => e.name === w.name && e.owner === w.owner && numberOf(code) < GENERATED;
|
|
28
|
+
const there = Object.entries(before.refusals).find(([c, e]) => holds(e, c) && !taken(c)) ?? Object.entries(retired).find(([c, e]) => holds(e, c) && !taken(c));
|
|
29
|
+
if (there)
|
|
30
|
+
return { code: there[0], was: there[1] };
|
|
31
|
+
const top = [...used].filter((c) => prefixOf(c) === w.prefix && numberOf(c) < GENERATED).reduce((m, c) => Math.max(m, numberOf(c)), 0);
|
|
32
|
+
return { code: codeOf(w.prefix, top + 1), was: undefined };
|
|
33
|
+
};
|
|
34
|
+
for (const w of wanted) {
|
|
35
|
+
const { code, was } = find(w);
|
|
36
|
+
codes.push(code);
|
|
37
|
+
used.add(code);
|
|
38
|
+
delete retired[code];
|
|
39
|
+
live[code] = entryOf(w, was);
|
|
40
|
+
}
|
|
41
|
+
// The runtime's refusals stay as they are; any other that no longer has a name in the blueprint is retired as it was.
|
|
42
|
+
for (const [code, e] of Object.entries(before.refusals)) {
|
|
43
|
+
if (code in live)
|
|
44
|
+
continue;
|
|
45
|
+
if (e.owner === "runtime")
|
|
46
|
+
live[code] = e;
|
|
47
|
+
else
|
|
48
|
+
retired[code] = e;
|
|
49
|
+
}
|
|
50
|
+
return { lock: { refusals: byCode(live), retired: byCode(retired) }, codes };
|
|
51
|
+
};
|
|
52
|
+
export const evolve = (before, wanted) => assign(before, wanted).lock;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const WHOLE = { value: "uint", bits: 256 };
|
|
2
|
+
/** Each runtime refusal, its code and the fields it carries. AR-001 and AR-002 are Effect's; AR-003 to AR-006 are the chain's. */
|
|
3
|
+
const RUNTIME = [
|
|
4
|
+
["NotAllowed", "AR-001", {}],
|
|
5
|
+
["IdempotencyConflict", "AR-002", {}],
|
|
6
|
+
["SignatureExpired", "AR-003", { deadline: WHOLE }],
|
|
7
|
+
["InvalidNonce", "AR-004", { expected: WHOLE, got: WHOLE }],
|
|
8
|
+
["BadSignature", "AR-005", {}],
|
|
9
|
+
["AlreadyExists", "AR-006", { id: { value: "text", max: 32 } }],
|
|
10
|
+
];
|
|
11
|
+
/** The runtime's refusals a project has: the chain's four only when it has a chain store. */
|
|
12
|
+
export const runtimeWanted = (chain) => RUNTIME.filter(([, code]) => chain || code <= "AR-002").map(([name, code, fields]) => ({ name, owner: "runtime", fields, code, prefix: "AR" }));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { LockInvalid } from "./types.js";
|
|
3
|
+
import { assign, evolve } from "./internal/evolve.js";
|
|
4
|
+
import { runtimeWanted } from "./internal/runtime.js";
|
|
5
|
+
export const EMPTY_LOCK = { refusals: {}, retired: {} };
|
|
6
|
+
const EMPTY = EMPTY_LOCK;
|
|
7
|
+
const isRecord = (x) => typeof x === "object" && x !== null && !Array.isArray(x);
|
|
8
|
+
export const HEADER = "Generated from blueprint/. Append-only. Do not edit.";
|
|
9
|
+
export const RefusalLock = {
|
|
10
|
+
parse: (text) => text === undefined
|
|
11
|
+
? Effect.succeed(EMPTY)
|
|
12
|
+
: Effect.try({ try: () => JSON.parse(text), catch: () => new LockInvalid({ message: "is not JSON" }) }).pipe(Effect.flatMap((parsed) => isRecord(parsed) && parsed["lockVersion"] === 1 && isRecord(parsed["refusals"]) && isRecord(parsed["retired"])
|
|
13
|
+
? Effect.succeed({ refusals: parsed["refusals"], retired: parsed["retired"] })
|
|
14
|
+
: Effect.fail(new LockInvalid({ message: "is not a refusals lock of lockVersion 1" })))),
|
|
15
|
+
evolve,
|
|
16
|
+
assign,
|
|
17
|
+
runtime: runtimeWanted,
|
|
18
|
+
text: (lock) => `${JSON.stringify({ generated: HEADER, lockVersion: 1, refusals: lock.refusals, retired: lock.retired }, null, 2)}\n`,
|
|
19
|
+
codes: (lock) => Object.fromEntries(Object.entries(lock.refusals).map(([code, e]) => [e.name, code])),
|
|
20
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { type Effect } from "effect";
|
|
2
|
+
/** A field of a refusal, as the lock writes a value: the kind and what the kind needs, nothing else. */
|
|
3
|
+
export type LockValue = LockKind & {
|
|
4
|
+
/** A field that may be left out; absent for a required one. */
|
|
5
|
+
readonly optional?: true;
|
|
6
|
+
};
|
|
7
|
+
type LockKind = {
|
|
8
|
+
readonly value: "uint";
|
|
9
|
+
readonly bits: number;
|
|
10
|
+
} | {
|
|
11
|
+
readonly value: "id";
|
|
12
|
+
readonly prefix: string;
|
|
13
|
+
} | {
|
|
14
|
+
readonly value: "text";
|
|
15
|
+
readonly max: number;
|
|
16
|
+
} | {
|
|
17
|
+
readonly value: "account";
|
|
18
|
+
} | {
|
|
19
|
+
readonly value: "instant";
|
|
20
|
+
} | {
|
|
21
|
+
readonly value: "day";
|
|
22
|
+
} | {
|
|
23
|
+
readonly value: "decimal";
|
|
24
|
+
readonly places: number;
|
|
25
|
+
} | {
|
|
26
|
+
readonly value: "schema";
|
|
27
|
+
} | {
|
|
28
|
+
readonly value: "money";
|
|
29
|
+
readonly bits: number;
|
|
30
|
+
readonly signed: boolean;
|
|
31
|
+
readonly asset: {
|
|
32
|
+
readonly token: string;
|
|
33
|
+
} | {
|
|
34
|
+
readonly currency: string;
|
|
35
|
+
} | {
|
|
36
|
+
readonly field: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
/** How a refusal goes on the wire in one language: Effect's tag, Solidity's signature and its selector (slice 4). */
|
|
40
|
+
export interface Wire {
|
|
41
|
+
readonly effect?: {
|
|
42
|
+
readonly tag: string;
|
|
43
|
+
};
|
|
44
|
+
readonly solidity?: {
|
|
45
|
+
readonly signature: string;
|
|
46
|
+
readonly selector: string;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export interface LockEntry {
|
|
50
|
+
readonly name: string;
|
|
51
|
+
/** A thing's name, or `runtime` for the AR- codes. */
|
|
52
|
+
readonly owner: string;
|
|
53
|
+
/** The errors file it is declared in; absent for a generated refusal (the machine's, not-found) and the runtime's. */
|
|
54
|
+
readonly from?: string;
|
|
55
|
+
readonly fields: Readonly<Record<string, LockValue>>;
|
|
56
|
+
readonly wire: Wire;
|
|
57
|
+
/** Wire identities this code had before, kept so an old contract still decodes. */
|
|
58
|
+
readonly earlier: ReadonlyArray<Wire>;
|
|
59
|
+
}
|
|
60
|
+
export interface Lock {
|
|
61
|
+
readonly refusals: Readonly<Record<string, LockEntry>>;
|
|
62
|
+
/** Code to the entry as it was when its name left the blueprint. A retired code is never given again. */
|
|
63
|
+
readonly retired: Readonly<Record<string, LockEntry>>;
|
|
64
|
+
}
|
|
65
|
+
/** One refusal the blueprint declares or generates now: what the lock must hold for it. */
|
|
66
|
+
export interface Wanted {
|
|
67
|
+
readonly name: string;
|
|
68
|
+
readonly owner: string;
|
|
69
|
+
readonly from?: string;
|
|
70
|
+
readonly fields: Readonly<Record<string, LockValue>>;
|
|
71
|
+
/** A code that is not numbered by order: the runtime's, the machine's 900 and not-found's 901. Absent for a declared error. */
|
|
72
|
+
readonly code?: string;
|
|
73
|
+
/** The thing's code prefix, for a declared error's next number. */
|
|
74
|
+
readonly prefix: string;
|
|
75
|
+
}
|
|
76
|
+
declare const LockInvalid_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
77
|
+
readonly _tag: "LockInvalid";
|
|
78
|
+
} & Readonly<A>;
|
|
79
|
+
/** Text that is no refusals lock: the compiler refuses the project, naming the file. */
|
|
80
|
+
export declare class LockInvalid extends LockInvalid_base<{
|
|
81
|
+
readonly message: string;
|
|
82
|
+
}> {
|
|
83
|
+
}
|
|
84
|
+
export interface LockApi {
|
|
85
|
+
/** The lock a text holds, an empty one for no text. */
|
|
86
|
+
readonly parse: (text: string | undefined) => Effect.Effect<Lock, LockInvalid>;
|
|
87
|
+
/** The lock after the blueprint: names keep their codes, new names take the next unused number, a name that left is retired. */
|
|
88
|
+
readonly evolve: (before: Lock, wanted: ReadonlyArray<Wanted>) => Lock;
|
|
89
|
+
/** `evolve`, and the code each wanted refusal got, in the order asked. */
|
|
90
|
+
readonly assign: (before: Lock, wanted: ReadonlyArray<Wanted>) => {
|
|
91
|
+
readonly lock: Lock;
|
|
92
|
+
readonly codes: ReadonlyArray<string>;
|
|
93
|
+
};
|
|
94
|
+
/** The runtime's refusals a project has, as the lock wants them: the chain's four only with a chain store. */
|
|
95
|
+
readonly runtime: (chain: boolean) => ReadonlyArray<Wanted>;
|
|
96
|
+
/** The exact text of a lock: JSON with two spaces and a closing newline. */
|
|
97
|
+
readonly text: (lock: Lock) => string;
|
|
98
|
+
/** Each live refusal's name and its code. */
|
|
99
|
+
readonly codes: (lock: Lock) => Readonly<Record<string, string>>;
|
|
100
|
+
}
|
|
101
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// `blueprint/refusals.lock` (M6-chain item 4): every refusal of the project with the code it keeps for good. Written by
|
|
2
|
+
// `ortho generate`, checked in, append-only; the compiler reads it, so every generator reads codes from the model.
|
|
3
|
+
import { Data } from "effect";
|
|
4
|
+
/** Text that is no refusals lock: the compiler refuses the project, naming the file. */
|
|
5
|
+
export class LockInvalid extends Data.TaggedError("LockInvalid") {
|
|
6
|
+
}
|