@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,485 @@
|
|
|
1
|
+
import { type Effect } from "effect";
|
|
2
|
+
import type { BlueprintSource, SourceError } from "#modules/source/types.js";
|
|
3
|
+
import type { ClockModel, MoveTimeModel } from "#modules/time/types.js";
|
|
4
|
+
import type { ValueMeta as DeclaredMeta } from "orthograph";
|
|
5
|
+
import type { MountModel } from "#modules/mounts/types.js";
|
|
6
|
+
import type { AppModel } from "#modules/app/types.js";
|
|
7
|
+
/** What an amount counts, in the model: an asset file's name (a token or a currency), or the field of the same row that holds the token. */
|
|
8
|
+
export type MoneyAssetModel = {
|
|
9
|
+
readonly token: string;
|
|
10
|
+
} | {
|
|
11
|
+
readonly currency: string;
|
|
12
|
+
} | {
|
|
13
|
+
readonly field: string;
|
|
14
|
+
};
|
|
15
|
+
/** A value as the model records it: the declared meta, its money resolved to names (M6-money). */
|
|
16
|
+
export type ValueMeta = Exclude<DeclaredMeta, {
|
|
17
|
+
readonly type: "money";
|
|
18
|
+
}> | {
|
|
19
|
+
readonly type: "money";
|
|
20
|
+
readonly bits: number;
|
|
21
|
+
readonly signed: boolean;
|
|
22
|
+
readonly asset: MoneyAssetModel;
|
|
23
|
+
};
|
|
24
|
+
export type { MountModel };
|
|
25
|
+
/** A declaration belongs to the app or to a mount, with its original name inside that plugin. */
|
|
26
|
+
export type FromModel = {
|
|
27
|
+
readonly kind: "app";
|
|
28
|
+
} | {
|
|
29
|
+
readonly kind: "feature" | "adapter";
|
|
30
|
+
readonly mount: string;
|
|
31
|
+
readonly package: string;
|
|
32
|
+
readonly version: string;
|
|
33
|
+
readonly thing: string;
|
|
34
|
+
};
|
|
35
|
+
/** Who may see a field's value, when it is not everyone: `secret`, or private to some roles (`thing.role`). Public is absent. */
|
|
36
|
+
export type VisibilityModel = "secret" | {
|
|
37
|
+
readonly private: ReadonlyArray<string>;
|
|
38
|
+
};
|
|
39
|
+
/** A field: what it holds, the named value it uses if any, and the thing field it was taken from if any. */
|
|
40
|
+
export interface FieldModel {
|
|
41
|
+
readonly value: ValueMeta;
|
|
42
|
+
readonly named?: string;
|
|
43
|
+
readonly ref?: string;
|
|
44
|
+
/** A payload field the caller may leave out (a list's filters and cursor). */
|
|
45
|
+
readonly optional?: true;
|
|
46
|
+
/** The Solidity type the value works out to on a chain store (M6-chain item 2); present only on a field of a thing that lives in one. */
|
|
47
|
+
readonly solidity?: string;
|
|
48
|
+
/** The value may be null (a union with null): its column may be NULL too. Absent for every other field. */
|
|
49
|
+
readonly nullable?: true;
|
|
50
|
+
/** A payload field that travels as a list or an object: a command line takes it as JSON. Absent for every other field. */
|
|
51
|
+
readonly json?: "list" | "object";
|
|
52
|
+
/** What the field is for, as the blueprint says (`Blueprint.described`); every output carries it (M1.42). */
|
|
53
|
+
readonly description?: string;
|
|
54
|
+
/** Absent means public, the default. Only a public field's value may be a span attribute, a log line or a journal field. */
|
|
55
|
+
readonly visibility?: VisibilityModel;
|
|
56
|
+
/** A secret answer field handed to its caller once, by `Blueprint.issued`: it leaves in the answer of the call that issued it, and nowhere else. */
|
|
57
|
+
readonly issued?: true;
|
|
58
|
+
}
|
|
59
|
+
export type FieldsModel = Readonly<Record<string, FieldModel>>;
|
|
60
|
+
export interface MachineModel {
|
|
61
|
+
readonly states: ReadonlyArray<string>;
|
|
62
|
+
/** A move made by time also carries `by`, and `late` and `lazy` when declared (M8.09); a move made by a person carries none. */
|
|
63
|
+
readonly moves: Readonly<Record<string, {
|
|
64
|
+
readonly from: ReadonlyArray<string>;
|
|
65
|
+
readonly to: ReadonlyArray<string>;
|
|
66
|
+
readonly emits: string;
|
|
67
|
+
} & Partial<MoveTimeModel>>>;
|
|
68
|
+
/** The generated refusal: `<Thing>Not<State>`, named after the machine's first state. */
|
|
69
|
+
readonly notFrom: {
|
|
70
|
+
readonly error: string;
|
|
71
|
+
readonly exit: number;
|
|
72
|
+
readonly code: string;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/** One rule of a thing (G5): the fields that are one instance's alone, within the states it is `while`, refused with `refuse` when broken. */
|
|
76
|
+
export interface InvariantModel {
|
|
77
|
+
readonly kind: "unique";
|
|
78
|
+
/** The key's fields, in the order written. */
|
|
79
|
+
readonly fields: ReadonlyArray<string>;
|
|
80
|
+
/** Absent: the rule holds in every state. */
|
|
81
|
+
readonly while?: ReadonlyArray<string>;
|
|
82
|
+
/** The thing's own error the runtime refuses with; absent when no caller can break the rule. */
|
|
83
|
+
readonly refuse?: string;
|
|
84
|
+
/** Written words that replace the sentence generated from the rule. */
|
|
85
|
+
readonly description?: string;
|
|
86
|
+
/** The framework's own, held by every thing with versions and declared in no `invariants.ts`: one row per revision of a key. */
|
|
87
|
+
readonly framework?: true;
|
|
88
|
+
}
|
|
89
|
+
export interface ThingModel {
|
|
90
|
+
readonly name: string;
|
|
91
|
+
readonly identifier: string;
|
|
92
|
+
/** The prefix of its refusal codes: `AL` in `[AL-002]`. */
|
|
93
|
+
readonly code: string;
|
|
94
|
+
readonly description: string;
|
|
95
|
+
readonly fields: FieldsModel;
|
|
96
|
+
/** A thing with versions (K40 fix 2): one current version per `key`. Absent when it has none. */
|
|
97
|
+
readonly versions?: {
|
|
98
|
+
readonly key: string;
|
|
99
|
+
};
|
|
100
|
+
/** The kind of place its state is kept: D1 rows, or a Durable Object per instance. */
|
|
101
|
+
readonly lives: "database" | "actor" | (string & {});
|
|
102
|
+
/** The declared store it lives in (a key of `Model.stores`); absent when it lives in the project's default store. */
|
|
103
|
+
readonly store?: string;
|
|
104
|
+
/** Its rules (G5), by name: what stays true among its instances. Absent when it has none; a rule's full name is `<thing>.<name>`. */
|
|
105
|
+
readonly invariants?: Readonly<Record<string, InvariantModel>>;
|
|
106
|
+
readonly machine: MachineModel | null;
|
|
107
|
+
/**
|
|
108
|
+
* Its not-found refusal, present only when some operation can refuse it (K16): the one it declares under the name
|
|
109
|
+
* `<Thing>NotFound`, else generated at `<XX>-901`, exit 4, HTTP 404.
|
|
110
|
+
*/
|
|
111
|
+
readonly notFound?: {
|
|
112
|
+
readonly error: string;
|
|
113
|
+
readonly exit: number;
|
|
114
|
+
readonly code: string;
|
|
115
|
+
};
|
|
116
|
+
readonly events: Readonly<Record<string, FieldsModel>>;
|
|
117
|
+
/** Each with its code, which never moves once released. */
|
|
118
|
+
readonly errors: Readonly<Record<string, {
|
|
119
|
+
readonly fields: FieldsModel;
|
|
120
|
+
readonly exit: number;
|
|
121
|
+
readonly code: string;
|
|
122
|
+
}>>;
|
|
123
|
+
readonly roles: ReadonlyArray<string>;
|
|
124
|
+
/** A `rule` role's text (null while it is a `Blueprint.todo`), or a `who` role as declared: the field of the thing that holds whoever the role is for (K20). */
|
|
125
|
+
readonly roleRules: Readonly<Record<string, string | null | {
|
|
126
|
+
readonly kind: "who";
|
|
127
|
+
readonly who: string;
|
|
128
|
+
}>>;
|
|
129
|
+
/** On a chain store: each state's number on chain, `absent` 0 and then the declared states in order (M6-chain item 2). */
|
|
130
|
+
readonly stateNumbers?: Readonly<Record<string, number>>;
|
|
131
|
+
readonly from: FromModel;
|
|
132
|
+
readonly hash: string;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* One `allowed` entry. `via` is the ways in it keeps, sorted, when `.via` or `.notVia` narrowed it (M2-auth, fork 2): absent, every way in.
|
|
136
|
+
* `system` admits the runtime's own work only; a role with a `service` admits the service of that mount only.
|
|
137
|
+
*/
|
|
138
|
+
export type AllowedModel = {
|
|
139
|
+
readonly kind: "anyone";
|
|
140
|
+
} | {
|
|
141
|
+
readonly kind: "signed-in";
|
|
142
|
+
readonly via?: ReadonlyArray<string>;
|
|
143
|
+
} | {
|
|
144
|
+
readonly kind: "system";
|
|
145
|
+
} | {
|
|
146
|
+
readonly kind: "keeper";
|
|
147
|
+
} | {
|
|
148
|
+
readonly kind: "role";
|
|
149
|
+
readonly role: string;
|
|
150
|
+
readonly via?: ReadonlyArray<string>;
|
|
151
|
+
readonly service?: string;
|
|
152
|
+
} | {
|
|
153
|
+
readonly kind: "role-of";
|
|
154
|
+
readonly role: string;
|
|
155
|
+
readonly path: string;
|
|
156
|
+
readonly via?: ReadonlyArray<string>;
|
|
157
|
+
readonly service?: string;
|
|
158
|
+
};
|
|
159
|
+
/** A step of an operation: its span's name and kind, and, for a call out, the adapter's call it makes. */
|
|
160
|
+
export interface StepModel {
|
|
161
|
+
readonly name: string;
|
|
162
|
+
readonly type: string;
|
|
163
|
+
/** The things a database step writes, when it names them (stores). */
|
|
164
|
+
readonly writes?: ReadonlyArray<string>;
|
|
165
|
+
/** Present only when the step may be skipped (K5): eval 6 lets an answered call run without it. */
|
|
166
|
+
readonly optional?: boolean;
|
|
167
|
+
readonly call?: {
|
|
168
|
+
readonly mount: string;
|
|
169
|
+
readonly call: string;
|
|
170
|
+
readonly mode: "promise" | "effect";
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
export interface OperationModel {
|
|
174
|
+
/** A read is answered from the thing's records with no handler. */
|
|
175
|
+
readonly kind: "operation" | "read";
|
|
176
|
+
readonly name: string;
|
|
177
|
+
readonly thing: string;
|
|
178
|
+
readonly verb: string;
|
|
179
|
+
readonly identifier: string;
|
|
180
|
+
readonly file: string;
|
|
181
|
+
readonly description: string;
|
|
182
|
+
readonly payload: FieldsModel;
|
|
183
|
+
readonly answer: FieldsModel;
|
|
184
|
+
readonly move: {
|
|
185
|
+
readonly key: string;
|
|
186
|
+
readonly from: ReadonlyArray<string>;
|
|
187
|
+
readonly to: ReadonlyArray<string>;
|
|
188
|
+
readonly emits: string;
|
|
189
|
+
} | null;
|
|
190
|
+
/** Declared errors, then the generated ones the runtime can refuse with: the machine's, `<Thing>NotFound`, and NotAllowed. */
|
|
191
|
+
readonly errors: ReadonlyArray<string>;
|
|
192
|
+
/** The refusals the runtime makes for this operation, never in `errors`: each to the full name of the rule it refuses for (`handle.oneHolderPerName`), G5. Absent when none. */
|
|
193
|
+
readonly invariants?: Readonly<Record<string, string>>;
|
|
194
|
+
/** Every rule this operation can break, as `<thing>.<rule>`, each once, whether or not the rule owns a refusal (G5 section 3, S31). `[]` when none. */
|
|
195
|
+
readonly breaks: ReadonlyArray<string>;
|
|
196
|
+
readonly refusals: ReadonlyArray<string>;
|
|
197
|
+
/** Each payload field holding some thing's id, and that thing: read before the handler and handed in as `refs.<field>`. */
|
|
198
|
+
readonly refs?: Readonly<Record<string, string>>;
|
|
199
|
+
/** The payload fields no role check reads, and the `<Thing>NotFound` a missing one is refused with before the handler. */
|
|
200
|
+
readonly notFound?: Readonly<Record<string, string>>;
|
|
201
|
+
/** A creating move's field (the answer's, else the payload's) that carries the id the runtime mints and hands in as `id`. */
|
|
202
|
+
readonly mints?: string;
|
|
203
|
+
/** A save or restore of a thing with versions: the declared error whose only field is `current`, its refusal of a save made from an old version (K40 fix 2). */
|
|
204
|
+
readonly stale?: string;
|
|
205
|
+
readonly allowed: ReadonlyArray<AllowedModel>;
|
|
206
|
+
/**
|
|
207
|
+
* Whether the MCP door lists it as a tool: some `allowed` entry admits an agent, the mount's narrowing (`via`) keeps `agent`, and it does
|
|
208
|
+
* not run on the caller's device (M2-auth, fork 2). Said on every operation and read, so a projection never works it out again.
|
|
209
|
+
*/
|
|
210
|
+
readonly agentTool: boolean;
|
|
211
|
+
readonly steps: Readonly<Record<string, StepModel>>;
|
|
212
|
+
readonly idempotent: "request" | null;
|
|
213
|
+
/** A person must say yes before it runs. Present only when declared, and only ever `true` (#466). */
|
|
214
|
+
readonly needsApproval?: true;
|
|
215
|
+
/** Where it runs: `server`, `client` (on the caller's device) for a plugin's operation that has a code entry per host, or `chain` for an operation of a thing in a chain store (K25 item 6). */
|
|
216
|
+
readonly runs: "server" | "client" | "chain";
|
|
217
|
+
/** `network` when its guarantee needs a network test (a target sets it); `unit` otherwise. */
|
|
218
|
+
readonly test: "unit" | "network";
|
|
219
|
+
readonly budget: {
|
|
220
|
+
readonly p95Ms: number;
|
|
221
|
+
} | null;
|
|
222
|
+
/** A list read: what it filters by, its order and its page size. Present only for lists. */
|
|
223
|
+
readonly list?: {
|
|
224
|
+
readonly where: ReadonlyArray<string>;
|
|
225
|
+
readonly order: string;
|
|
226
|
+
readonly page: number;
|
|
227
|
+
};
|
|
228
|
+
/** A list read's fields pinned to one value, taken out of its payload (GOAL17-derived-reads). */
|
|
229
|
+
readonly only?: Readonly<Record<string, unknown>>;
|
|
230
|
+
/** A read worked out from other records: what it looks at, what it adds to its answer, and the hash of its function. */
|
|
231
|
+
readonly derive?: {
|
|
232
|
+
readonly looks: Readonly<Record<string, unknown>>;
|
|
233
|
+
readonly adds: FieldsModel;
|
|
234
|
+
readonly hash: string;
|
|
235
|
+
};
|
|
236
|
+
/** The events that call it, each as an outbox hop (`Blueprint.on`), with the thing that declares the event. */
|
|
237
|
+
readonly on?: ReadonlyArray<{
|
|
238
|
+
readonly event: string;
|
|
239
|
+
readonly thing: string;
|
|
240
|
+
}>;
|
|
241
|
+
/** A plugin operation’s `file` is a package specifier. */
|
|
242
|
+
readonly from: FromModel;
|
|
243
|
+
readonly blanks?: ReadonlyArray<string>;
|
|
244
|
+
/** The ways in a mount left it, when the mount narrowed it. */
|
|
245
|
+
readonly via?: ReadonlyArray<string>;
|
|
246
|
+
readonly hash: string;
|
|
247
|
+
}
|
|
248
|
+
export type PublicationModel = {
|
|
249
|
+
readonly how: "npm";
|
|
250
|
+
readonly tag: string | null;
|
|
251
|
+
} | {
|
|
252
|
+
readonly how: "homebrew";
|
|
253
|
+
readonly tap: string;
|
|
254
|
+
} | {
|
|
255
|
+
readonly how: "binaries";
|
|
256
|
+
readonly on: "github-releases";
|
|
257
|
+
};
|
|
258
|
+
/** Where an environment's traces and logs go; never a token, an address or the name of a secret. */
|
|
259
|
+
export type SinkModel = {
|
|
260
|
+
readonly sink: "local";
|
|
261
|
+
} | {
|
|
262
|
+
readonly sink: "axiom";
|
|
263
|
+
readonly group: string;
|
|
264
|
+
};
|
|
265
|
+
/** An environment, named by its file: `blueprint/environments/staging.ts` is `staging`. */
|
|
266
|
+
export interface EnvironmentModel {
|
|
267
|
+
readonly name: string;
|
|
268
|
+
readonly file: string;
|
|
269
|
+
readonly runs: string;
|
|
270
|
+
/** Superseded by `issues` (M2-auth, "Smaller calls" 4); present only when the environment still says it. */
|
|
271
|
+
readonly identity?: "test-principals" | "better-auth";
|
|
272
|
+
/** The ways in it issues credentials for, sorted; present only when it names them (absent: every way in). */
|
|
273
|
+
readonly issues?: ReadonlyArray<string>;
|
|
274
|
+
/** How its worlds tell time; present only when it declares a clock (M8.09). */
|
|
275
|
+
readonly clock?: ClockModel;
|
|
276
|
+
/** How long a world of this environment lives, when it has a lifetime. */
|
|
277
|
+
readonly lifetimeMs: number | null;
|
|
278
|
+
readonly cloud: {
|
|
279
|
+
readonly provider: "cloudflare";
|
|
280
|
+
readonly database: "d1" | "d1-local";
|
|
281
|
+
} | null;
|
|
282
|
+
readonly database: "d1" | "d1-local" | null;
|
|
283
|
+
/** Only the stores it binds differently from the default, by store name; present only when it binds any. A chain store is bound to a network. */
|
|
284
|
+
readonly stores?: Readonly<Record<string, "d1" | "d1-local" | {
|
|
285
|
+
readonly chain: "evm";
|
|
286
|
+
readonly network: string;
|
|
287
|
+
}>>;
|
|
288
|
+
/** The contract each fixed token asset is, by asset and then by chain store; present only when it binds any (M6-money item 2). */
|
|
289
|
+
readonly assets?: Readonly<Record<string, Readonly<Record<string, {
|
|
290
|
+
readonly chain: "evm";
|
|
291
|
+
readonly address: string;
|
|
292
|
+
}>>>>;
|
|
293
|
+
/** Secret names, and how each gets its value. Never a value. */
|
|
294
|
+
readonly secrets: Readonly<Record<string, "generated" | "stored">>;
|
|
295
|
+
readonly promotesFrom: string | null;
|
|
296
|
+
/** The sinks it declares, in order; present only when it declares any (O1, D3 #100). */
|
|
297
|
+
readonly telemetry?: ReadonlyArray<SinkModel>;
|
|
298
|
+
readonly deploy: Readonly<Record<string, {
|
|
299
|
+
readonly how: "worker" | "site";
|
|
300
|
+
readonly domain: string | null;
|
|
301
|
+
}>>;
|
|
302
|
+
readonly publish: Readonly<Record<string, ReadonlyArray<PublicationModel>>>;
|
|
303
|
+
readonly hash: string;
|
|
304
|
+
}
|
|
305
|
+
export interface JourneyCallModel {
|
|
306
|
+
readonly actor: string;
|
|
307
|
+
readonly operation: string;
|
|
308
|
+
readonly payload: Readonly<Record<string, unknown>>;
|
|
309
|
+
readonly request?: string;
|
|
310
|
+
/** The way in the cast member's credential is made for, when the call says one (`s.ada.via(Via.key)`). */
|
|
311
|
+
readonly via?: string;
|
|
312
|
+
/** The keeper's call: the instant the move made by time was due (M8-checks call 4). */
|
|
313
|
+
readonly due?: string;
|
|
314
|
+
}
|
|
315
|
+
export interface JourneyModel {
|
|
316
|
+
readonly file: string;
|
|
317
|
+
readonly sourceHash?: string;
|
|
318
|
+
readonly name: string;
|
|
319
|
+
readonly cast: Readonly<Record<string, AllowedModel>>;
|
|
320
|
+
readonly starts: string | null;
|
|
321
|
+
/** What isn't written yet: a stub from `ortho add journeys` until it is filled. `prove` skips it, naming it (K16 e). */
|
|
322
|
+
readonly blanks?: ReadonlyArray<string>;
|
|
323
|
+
readonly steps: ReadonlyArray<{
|
|
324
|
+
readonly title: string;
|
|
325
|
+
} & ({
|
|
326
|
+
readonly call: JourneyCallModel;
|
|
327
|
+
readonly checks: ReadonlyArray<{
|
|
328
|
+
readonly kind: string;
|
|
329
|
+
}>;
|
|
330
|
+
} | {
|
|
331
|
+
readonly skipped: string;
|
|
332
|
+
})>;
|
|
333
|
+
}
|
|
334
|
+
export interface StartingWorldModel {
|
|
335
|
+
readonly name: string;
|
|
336
|
+
readonly file: string;
|
|
337
|
+
readonly sourceHash?: string;
|
|
338
|
+
readonly from: string | null;
|
|
339
|
+
readonly cast: Readonly<Record<string, AllowedModel>>;
|
|
340
|
+
readonly makes: ReadonlyArray<JourneyCallModel | null>;
|
|
341
|
+
readonly gives: unknown;
|
|
342
|
+
}
|
|
343
|
+
export type BlankOperationModel = Pick<OperationModel, "kind" | "name" | "thing" | "verb" | "file" | "from"> & {
|
|
344
|
+
readonly description?: string;
|
|
345
|
+
readonly blanks: ReadonlyArray<string>;
|
|
346
|
+
};
|
|
347
|
+
/** Where a plugin's store came from: its mount, package and version, and the plugin's own name for the store. */
|
|
348
|
+
export interface StoreFromModel {
|
|
349
|
+
readonly mount: string;
|
|
350
|
+
readonly package: string;
|
|
351
|
+
readonly version: string;
|
|
352
|
+
readonly store: string;
|
|
353
|
+
}
|
|
354
|
+
/** Where a secret was declared: the app's own `blueprint/secrets.ts`, or the plugin a mount brought in. */
|
|
355
|
+
export type SecretFromModel = {
|
|
356
|
+
readonly kind: "app";
|
|
357
|
+
} | {
|
|
358
|
+
readonly kind: "feature" | "adapter" | "projection";
|
|
359
|
+
readonly mount: string;
|
|
360
|
+
readonly package: string;
|
|
361
|
+
readonly version: string;
|
|
362
|
+
};
|
|
363
|
+
/** A declared secret, by the name derived from its mount and export: how it gets a value and who holds it. Never a value. */
|
|
364
|
+
export interface SecretModel {
|
|
365
|
+
readonly how: "generated" | "stored";
|
|
366
|
+
/** `runtime` (a running place holds it), `release` (CI's) or `builder` (a developer's machine's). */
|
|
367
|
+
readonly kind: "runtime" | "release" | "builder";
|
|
368
|
+
/** The export's name in the declaring `secrets.ts`: what the plugin's layer reads it by. */
|
|
369
|
+
readonly export: string;
|
|
370
|
+
readonly from: SecretFromModel;
|
|
371
|
+
readonly describe?: string;
|
|
372
|
+
}
|
|
373
|
+
/** A store, named by its file (`blueprint/stores/ledger.ts` is `ledger`), or by its mount and path (`echo-ledger`). */
|
|
374
|
+
export interface StoreModel {
|
|
375
|
+
readonly name: string;
|
|
376
|
+
readonly file: string;
|
|
377
|
+
/** Which host supplies it: `database` or `actor` on Cloudflare. */
|
|
378
|
+
readonly kind: string;
|
|
379
|
+
/** Present only for a plugin's store; its `file` is then a package specifier. */
|
|
380
|
+
readonly from?: StoreFromModel;
|
|
381
|
+
readonly hash: string;
|
|
382
|
+
}
|
|
383
|
+
/** An asset, named by its file (`blueprint/assets/usdc.ts` is `usdc`): a token with its symbol and places, or a currency with its code and places. */
|
|
384
|
+
export interface AssetModel {
|
|
385
|
+
readonly name: string;
|
|
386
|
+
readonly file: string;
|
|
387
|
+
readonly kind: "token" | "currency";
|
|
388
|
+
readonly symbol?: string;
|
|
389
|
+
readonly code?: string;
|
|
390
|
+
/** The places of an amount: 6 for USDC, so `1250000` is 1.25 USDC; a currency's come from its code. */
|
|
391
|
+
readonly decimals: number;
|
|
392
|
+
}
|
|
393
|
+
/** One burn alert of an objective: it fires when the objective burns at `burn` or more over both windows (long, then short). */
|
|
394
|
+
export interface BurnAlertModel {
|
|
395
|
+
readonly name: string;
|
|
396
|
+
readonly burn: number;
|
|
397
|
+
readonly windowsMs: ReadonlyArray<number>;
|
|
398
|
+
readonly severity: "page" | "ticket";
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* One alert condition the compiler derives (K18): the labels are exactly `environment` (`*` where the rule holds in every environment), its subject
|
|
402
|
+
* (`operation`, `code` or `journey`), `severity` and `owner`. A latency or defect rule is an objective with its burn alerts; a latency rule also holds the
|
|
403
|
+
* operation's `budget.p95Ms` as `thresholdMs`. An anomaly or a verdict has neither.
|
|
404
|
+
*/
|
|
405
|
+
export interface AlertRuleModel {
|
|
406
|
+
readonly id: string;
|
|
407
|
+
readonly kind: "latency" | "defect" | "anomaly" | "verdict";
|
|
408
|
+
readonly labels: Readonly<Record<string, string>>;
|
|
409
|
+
readonly target?: number;
|
|
410
|
+
readonly windowDays?: number;
|
|
411
|
+
readonly thresholdMs?: number;
|
|
412
|
+
readonly minCalls?: number;
|
|
413
|
+
readonly alerts?: ReadonlyArray<BurnAlertModel>;
|
|
414
|
+
}
|
|
415
|
+
export interface Model {
|
|
416
|
+
/** Every refusal in the project and its code: declared errors, each machine's, and the runtime's (`NotAllowed`). */
|
|
417
|
+
readonly refusals: Readonly<Record<string, string>>;
|
|
418
|
+
readonly values: Readonly<Record<string, ValueMeta>>;
|
|
419
|
+
/** The declared assets, by name: present only when the blueprint declares any (M6-money). */
|
|
420
|
+
readonly assets?: Readonly<Record<string, AssetModel>>;
|
|
421
|
+
/** The declared stores, by name: present only when the blueprint (or a mount) declares any. */
|
|
422
|
+
readonly stores?: Readonly<Record<string, StoreModel>>;
|
|
423
|
+
readonly things: Readonly<Record<string, ThingModel>>;
|
|
424
|
+
readonly operations: Readonly<Record<string, OperationModel>>;
|
|
425
|
+
readonly journeys: Readonly<Record<string, JourneyModel>>;
|
|
426
|
+
readonly startingWorlds: Readonly<Record<string, StartingWorldModel>>;
|
|
427
|
+
/** Incomplete operations are described here and have no generated entry points. */
|
|
428
|
+
readonly blankOperations?: Readonly<Record<string, BlankOperationModel>>;
|
|
429
|
+
/**
|
|
430
|
+
* What is still `Blueprint.todo`, by declaration (`allowance`, `allowance.spend`): present only when something is.
|
|
431
|
+
* An incomplete operation is described under `blankOperations` until its blanks are filled.
|
|
432
|
+
*/
|
|
433
|
+
readonly blanks?: Readonly<Record<string, ReadonlyArray<string>>>;
|
|
434
|
+
/** Where the application runs, by name: present only when the blueprint has an `environments/` folder. */
|
|
435
|
+
readonly environments?: Readonly<Record<string, EnvironmentModel>>;
|
|
436
|
+
/** The declared secrets by derived name (`STRIPE_API_KEY`): present only when the app or a mount declares any. */
|
|
437
|
+
readonly secrets?: Readonly<Record<string, SecretModel>>;
|
|
438
|
+
/** Each mount, by its name: present only when the blueprint has a mount. */
|
|
439
|
+
readonly mounts?: Readonly<Record<string, MountModel>>;
|
|
440
|
+
/** Each agent kind, by its file's name: present only when the blueprint (or a mount) declares any. */
|
|
441
|
+
readonly agents?: Readonly<Record<string, {
|
|
442
|
+
readonly file: string;
|
|
443
|
+
readonly slots?: {
|
|
444
|
+
readonly size: string;
|
|
445
|
+
readonly reserve: number;
|
|
446
|
+
readonly held: string;
|
|
447
|
+
};
|
|
448
|
+
}>>;
|
|
449
|
+
/** Each active source, by its file's name (GOAL17-source-from). */
|
|
450
|
+
readonly sources?: Readonly<Record<string, unknown>>;
|
|
451
|
+
/** Each hold, by the name it is exported under, with the app's held and unheld deliveries (GOAL17-pause). */
|
|
452
|
+
readonly holds?: Readonly<Record<string, unknown>>;
|
|
453
|
+
/** What can fail beside a thing, and when it shows (GOAL17-derived-reads). */
|
|
454
|
+
readonly problems?: ReadonlyArray<{
|
|
455
|
+
readonly kind: string;
|
|
456
|
+
readonly thing: string;
|
|
457
|
+
readonly of: string;
|
|
458
|
+
readonly name: string;
|
|
459
|
+
readonly failures: string;
|
|
460
|
+
readonly after: string | number;
|
|
461
|
+
}>;
|
|
462
|
+
/** Instances the blueprint declares, by their thing's plural (`superagents`). */
|
|
463
|
+
readonly declared?: Readonly<Record<string, ReadonlyArray<unknown>>>;
|
|
464
|
+
/** The alert rules the model implies (K18), sorted by id. The portal evaluates them and a sink writes them. */
|
|
465
|
+
readonly alertRules: ReadonlyArray<AlertRuleModel>;
|
|
466
|
+
/** The app's map: its pages, components and navigation (K31, K36). Present only when the blueprint has an `app/` folder. */
|
|
467
|
+
readonly app?: AppModel;
|
|
468
|
+
}
|
|
469
|
+
declare const BlueprintInvalid_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 & {
|
|
470
|
+
readonly _tag: "BlueprintInvalid";
|
|
471
|
+
} & Readonly<A>;
|
|
472
|
+
/** A blueprint the compiler refuses, with every problem found, each naming its file. */
|
|
473
|
+
export declare class BlueprintInvalid extends BlueprintInvalid_base<{
|
|
474
|
+
readonly problems: ReadonlyArray<string>;
|
|
475
|
+
}> {
|
|
476
|
+
}
|
|
477
|
+
export interface CompilerApi {
|
|
478
|
+
/** Load the blueprint and build its model. */
|
|
479
|
+
readonly model: Effect.Effect<Model, BlueprintInvalid | SourceError, BlueprintSource>;
|
|
480
|
+
/** The model, and the text `blueprint/refusals.lock` must have for it (M6-chain item 4): what `ortho generate` writes. */
|
|
481
|
+
readonly locked: Effect.Effect<{
|
|
482
|
+
readonly model: Model;
|
|
483
|
+
readonly lock: string;
|
|
484
|
+
}, BlueprintInvalid | SourceError, BlueprintSource>;
|
|
485
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// The model: every declaration in the blueprint, named, described and hashed. Generators and evals read only this.
|
|
2
|
+
import { Data } from "effect";
|
|
3
|
+
/** A blueprint the compiler refuses, with every problem found, each naming its file. */
|
|
4
|
+
export class BlueprintInvalid extends Data.TaggedError("BlueprintInvalid") {
|
|
5
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AdapterCall, Mount } from "orthograph";
|
|
2
|
+
import type { CallReach } from "../types.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Each call of the adapter, whether this mount includes it, which events it includes, and what is wrong with the
|
|
5
|
+
* `include` verbs, naming the mount's file.
|
|
6
|
+
*/
|
|
7
|
+
export declare const callsOf: (file: string, pkg: string, mountName: string, mount: Mount) => {
|
|
8
|
+
problems: string[];
|
|
9
|
+
reach: (readonly [AdapterCall<"effect" | "promise">, CallReach])[];
|
|
10
|
+
included: string[];
|
|
11
|
+
events: string[];
|
|
12
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const kindOf = (x) => (typeof x === "object" && x !== null ? x.kind : undefined);
|
|
2
|
+
/** The adapter's own calls, by the dotted name its descriptor gives them: a group's calls are `group.call`. */
|
|
3
|
+
const offered = (calls, prefix = "") => typeof calls === "object" && calls !== null
|
|
4
|
+
? Object.entries(calls).sort(([a], [b]) => a.localeCompare(b)).flatMap(([name, c]) => kindOf(c) === "call" ? [[`${prefix}${name}`, c]] : offered(c, `${prefix}${name}.`))
|
|
5
|
+
: [];
|
|
6
|
+
/** The adapter's own events, by name. */
|
|
7
|
+
const eventsOffered = (events) => typeof events === "object" && events !== null ? Object.entries(events).filter(([, e]) => kindOf(e) === "event").sort(([a], [b]) => a.localeCompare(b)) : [];
|
|
8
|
+
/**
|
|
9
|
+
* Each call of the adapter, whether this mount includes it, which events it includes, and what is wrong with the
|
|
10
|
+
* `include` verbs, naming the mount's file.
|
|
11
|
+
*/
|
|
12
|
+
export const callsOf = (file, pkg, mountName, mount) => {
|
|
13
|
+
const problems = [];
|
|
14
|
+
const known = offered(mount.plugin.calls);
|
|
15
|
+
const knownEvents = eventsOffered(mount.plugin.events);
|
|
16
|
+
const said = known.map(([name]) => name).join(", ") || "none";
|
|
17
|
+
const saidEvents = knownEvents.map(([name]) => name).join(", ") || "none";
|
|
18
|
+
const named = new Set();
|
|
19
|
+
const namedEvents = new Set();
|
|
20
|
+
for (const verb of mount.verbs) {
|
|
21
|
+
if (verb.verb !== "include")
|
|
22
|
+
continue;
|
|
23
|
+
for (const item of verb.items) {
|
|
24
|
+
if (known.some(([, call]) => call === item))
|
|
25
|
+
named.add(item);
|
|
26
|
+
else if (knownEvents.some(([, event]) => event === item))
|
|
27
|
+
namedEvents.add(item);
|
|
28
|
+
else if (kindOf(item) === "missing-call")
|
|
29
|
+
problems.push(`${file}: includes the call ${item.name}, which ${pkg} doesn't have (its calls: ${said})`);
|
|
30
|
+
else if (kindOf(item) === "missing-event")
|
|
31
|
+
problems.push(`${file}: includes the event ${item.name}, which ${pkg} doesn't have (its events: ${saidEvents})`);
|
|
32
|
+
else
|
|
33
|
+
problems.push(`${file}: include takes one of ${pkg}'s calls, written p.calls.<call> (${said}), or one of its events, written p.events.<event> (${saidEvents}); it was given ${JSON.stringify(item) ?? String(item)}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const reach = known.map(([call, value]) => [value, { mount: mountName, file, package: pkg, call, included: named.has(value) }]);
|
|
37
|
+
return {
|
|
38
|
+
problems, reach,
|
|
39
|
+
included: reach.filter(([, r]) => r.included).map(([, r]) => r.call),
|
|
40
|
+
events: knownEvents.filter(([, event]) => namedEvents.has(event)).map(([name]) => name),
|
|
41
|
+
};
|
|
42
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AnyChoice, Mount } from "orthograph";
|
|
2
|
+
import type { PluginPackage } from "#modules/source/types.js";
|
|
3
|
+
/** Every choice in a plugin's choices, by its dotted path, in name order. */
|
|
4
|
+
export declare const choicesIn: (choices: unknown, path?: ReadonlyArray<string>) => ReadonlyArray<readonly [string, AnyChoice]>;
|
|
5
|
+
/** What the mount picked of each choice, and what's wrong with its `choose` verbs, naming its file. */
|
|
6
|
+
export declare const chosenOf: (file: string, pkg: string, mount: Mount, choices: ReadonlyArray<readonly [string, AnyChoice]>, installed?: ReadonlyArray<PluginPackage>) => {
|
|
7
|
+
chosen: {
|
|
8
|
+
[k: string]: string;
|
|
9
|
+
};
|
|
10
|
+
problems: string[];
|
|
11
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const kindOf = (x) => (typeof x === "object" && x !== null ? x.kind : undefined);
|
|
2
|
+
/** Every choice in a plugin's choices, by its dotted path, in name order. */
|
|
3
|
+
export const choicesIn = (choices, path = []) => typeof choices !== "object" || choices === null ? [] : Object.entries(choices).sort(([a], [b]) => a.localeCompare(b)).flatMap(([key, value]) => kindOf(value) === "choice" ? [[[...path, key].join("."), value]]
|
|
4
|
+
: typeof value === "object" && value !== null ? choicesIn(value, [...path, key])
|
|
5
|
+
: []);
|
|
6
|
+
const said = (choices) => choices.map(([name, c]) => `${name}: ${Object.keys(c.options).join(" or ")}`).join("; ") || "none";
|
|
7
|
+
/** What the mount picked of each choice, and what's wrong with its `choose` verbs, naming its file. */
|
|
8
|
+
export const chosenOf = (file, pkg, mount, choices, installed = []) => {
|
|
9
|
+
const problems = [];
|
|
10
|
+
const picks = new Map();
|
|
11
|
+
for (const verb of mount.verbs) {
|
|
12
|
+
if (verb.verb !== "choose")
|
|
13
|
+
continue;
|
|
14
|
+
const option = verb.option;
|
|
15
|
+
if (kindOf(option) !== "option") {
|
|
16
|
+
problems.push(`${file}: choose takes one of ${pkg}'s options, written p.choices.<choice>.<option> (${said(choices)}); it was given ${JSON.stringify(option) ?? String(option)}`);
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
const { choice } = option;
|
|
20
|
+
const named = choices.find(([, c]) => c === choice);
|
|
21
|
+
if (!named) {
|
|
22
|
+
const owner = installed.find((p) => p.name !== pkg && choicesIn(p.descriptor?.choices).some(([, c]) => c === choice));
|
|
23
|
+
problems.push(`${file}: chooses an option that isn't one of ${pkg}'s choices (${said(choices)})${owner ? `: it is one of ${owner.name}'s, another plugin` : ""}`);
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
if (picks.has(choice)) {
|
|
27
|
+
problems.push(`${file}: chooses ${named[0]} twice; a mount picks one option of each choice`);
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
picks.set(choice, option);
|
|
31
|
+
}
|
|
32
|
+
const chosen = Object.fromEntries(choices.map(([name, c]) => [name, picks.get(c)?.key ?? Object.keys(c.options)[0] ?? ""]));
|
|
33
|
+
return { chosen, problems };
|
|
34
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Layout, StoreFile, ThingFiles } from "#modules/model/internal/layout.js";
|
|
2
|
+
/** `@fixture/echo` is `echo`: the last part of its package name. */
|
|
3
|
+
export declare const ownName: (pkg: string) => string;
|
|
4
|
+
export declare const renamed: (plugin: Layout, mount: string, pkg: string, version: string) => ReadonlyArray<ThingFiles>;
|
|
5
|
+
/** A feature's own stores: the mount's name and the store's path, so two plugins never collide and the project never sees a bare one. */
|
|
6
|
+
export declare const renamedStores: (plugin: Layout, mount: string, pkg: string, version: string) => ReadonlyArray<StoreFile>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** `@fixture/echo` is `echo`: the last part of its package name. */
|
|
2
|
+
export const ownName = (pkg) => pkg.slice(pkg.lastIndexOf("/") + 1);
|
|
3
|
+
export const renamed = (plugin, mount, pkg, version) => [...plugin.things.values()].map((t) => {
|
|
4
|
+
const from = { kind: "feature", mount, package: pkg, version, thing: t.name };
|
|
5
|
+
return { ...t, name: mount === ownName(pkg) ? t.name : `${mount}-${t.name}`, from };
|
|
6
|
+
});
|
|
7
|
+
/** A feature's own stores: the mount's name and the store's path, so two plugins never collide and the project never sees a bare one. */
|
|
8
|
+
export const renamedStores = (plugin, mount, pkg, version) => [...plugin.stores.values()].map((s) => ({ ...s, name: `${mount}-${s.name}`, from: { mount, package: pkg, version, store: s.name } }));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Mount } from "orthograph";
|
|
2
|
+
import type { PluginPackage } from "#modules/source/types.js";
|
|
3
|
+
export interface Matched {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly kind: string;
|
|
6
|
+
readonly file: string;
|
|
7
|
+
readonly mount: Mount;
|
|
8
|
+
readonly plugin: PluginPackage;
|
|
9
|
+
}
|
|
10
|
+
/** The mounts meeting this mount's needs (`feature:echo`), and the needs nothing meets, each naming the command to mount it. */
|
|
11
|
+
export declare const needsOf: (me: Matched, matched: ReadonlyArray<Matched>, installed: ReadonlyArray<PluginPackage>) => {
|
|
12
|
+
needs: string[];
|
|
13
|
+
problems: string[];
|
|
14
|
+
};
|