@almadar/core 8.0.0 → 8.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builders.d.ts +3 -3
- package/dist/{compose-behaviors-Bq8tdeBU.d.ts → compose-behaviors-DsgVjsAB.d.ts} +1 -1
- package/dist/factory/index.d.ts +285 -17
- package/dist/factory/index.js +49 -100
- package/dist/factory/index.js.map +1 -1
- package/dist/index.d.ts +6 -7
- package/dist/index.js +132 -6359
- package/dist/index.js.map +1 -1
- package/dist/{schema-Bg4qX43l.d.ts → schema-Cov1FvVJ.d.ts} +1 -1
- package/dist/{trait-BPe356_9.d.ts → trait-g5-2JR48.d.ts} +1 -1
- package/dist/types/index.d.ts +4 -4
- package/package.json +1 -6
- package/dist/diff-factory-calls-DlBcMWPM.d.ts +0 -648
- package/dist/domain-language/index.d.ts +0 -833
- package/dist/domain-language/index.js +0 -7639
- package/dist/domain-language/index.js.map +0 -1
package/dist/builders.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { aA as UseDeclaration, B as EntityRef, ab as PageRef, X as OrbitalDefinition, a3 as OrbitalSchema, aa as Page, ac as PageRefObject } from './schema-
|
|
1
|
+
import { bK as UISlot, t as Effect, bg as Trait, aC as RenderUIEffect, bs as TraitEventContract, y as Entity, bu as TraitEventListener, bj as TraitConfig, B as EntityField, H as EntityPersistence, L as EntityRow, bx as TraitRef, bz as TraitReference } from './trait-g5-2JR48.js';
|
|
2
|
+
import { aA as UseDeclaration, B as EntityRef, ab as PageRef, X as OrbitalDefinition, a3 as OrbitalSchema, aa as Page, ac as PageRefObject } from './schema-Cov1FvVJ.js';
|
|
3
3
|
import { S as SExpr } from './expression-BVRFm0sV.js';
|
|
4
|
-
export { C as ComposeBehaviorsInput, a as ComposeBehaviorsResult, E as EventWiringEntry, L as LayoutStrategy, b as applyEventWiring, c as composeBehaviors, d as detectLayoutStrategy } from './compose-behaviors-
|
|
4
|
+
export { C as ComposeBehaviorsInput, a as ComposeBehaviorsResult, E as EventWiringEntry, L as LayoutStrategy, b as applyEventWiring, c as composeBehaviors, d as detectLayoutStrategy } from './compose-behaviors-DsgVjsAB.js';
|
|
5
5
|
import { AnyPatternConfig } from '@almadar/patterns';
|
|
6
6
|
import 'zod';
|
|
7
7
|
|
package/dist/factory/index.d.ts
CHANGED
|
@@ -1,27 +1,295 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { C as CallSiteDiff, F as FactoryCallSite, s as FactoryCallSiteParams, t as FactoryEntitySignature, u as FactoryPageSignature, w as FactorySignature, x as FactorySignatureCatalog, y as FactorySignatureEntityField, z as FactoryTraitSignature, O as OwnershipOverlayEntry, K as PresentationNavItem, M as PresentationOverlay, S as SchemaFieldType, V as TraitOverlay, W as TraitOverlayEntry, X as TraitOverlayListener, Y as TranslationBinding, Z as TranslationResult, _ as TranslationWarning, a0 as diffFactoryCalls, a1 as translateDomainToParams, a1 as translateOverlaysToParams } from '../diff-factory-calls-DlBcMWPM.js';
|
|
3
|
-
import { B as EntityField, H as EntityPersistence, bz as TraitReference } from '../trait-BPe356_9.js';
|
|
1
|
+
import { B as EntityField, H as EntityPersistence, bz as TraitReference, bu as TraitEventListener } from '../trait-g5-2JR48.js';
|
|
4
2
|
import 'zod';
|
|
5
3
|
import '../expression-BVRFm0sV.js';
|
|
6
4
|
import '@almadar/patterns';
|
|
7
5
|
|
|
8
6
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
* OrbitalSchema field type tags. The factory-signature extractor lifts
|
|
8
|
+
* these directly from the resolved `.orb`; consumers narrow further at
|
|
9
|
+
* dispatch time.
|
|
10
|
+
*/
|
|
11
|
+
type SchemaFieldType = 'string' | 'number' | 'boolean' | 'date' | 'timestamp' | 'datetime' | 'array' | 'object' | 'enum' | 'relation';
|
|
12
|
+
interface FactorySignatureEntityField {
|
|
13
|
+
name: string;
|
|
14
|
+
type: SchemaFieldType;
|
|
15
|
+
required: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The canonical entity a factory produces. Almost always one entity
|
|
19
|
+
* per orbital; modeled as an array to keep the door open for orbitals
|
|
20
|
+
* that compose multiple entities.
|
|
21
|
+
*/
|
|
22
|
+
interface FactoryEntitySignature {
|
|
23
|
+
/** Canonical entity name the factory's params build (e.g. `"ChatMessage"`). */
|
|
24
|
+
name: string;
|
|
25
|
+
/** Fields the factory emits, post-auto-field stripping. */
|
|
26
|
+
fields: ReadonlyArray<FactorySignatureEntityField>;
|
|
27
|
+
/** Persistence mode declared on the canonical entity in the `.orb`. */
|
|
28
|
+
persistence: EntityPersistence;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* One overridable config knob a trait advertises. Lifted directly from
|
|
32
|
+
* the source `.lolo` `config { }` block (which carries typed
|
|
33
|
+
* declarations + defaults). Consumers (the questionnaire generator,
|
|
34
|
+
* the studio) pick a widget from `type` and pre-fill from `default`.
|
|
16
35
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
36
|
+
* `label` is reserved for a future `.lolo` grammar extension that
|
|
37
|
+
* lets atom authors author a human-friendly question prompt; today
|
|
38
|
+
* it's always undefined and the questionnaire derives a fallback
|
|
39
|
+
* from the key name.
|
|
40
|
+
*/
|
|
41
|
+
interface FactoryConfigParam {
|
|
42
|
+
/** Key name as advertised by the trait. Matches the override path
|
|
43
|
+
* `traitOverrides.<traitName>.config.<key>`. */
|
|
44
|
+
key: string;
|
|
45
|
+
/** Type tag lifted from the `.lolo` config declaration. Drives the
|
|
46
|
+
* question widget selection. Free-form to admit array/object
|
|
47
|
+
* brackets (`[object]`, `[string]`) and atom-defined custom tags. */
|
|
48
|
+
type: string;
|
|
49
|
+
/** Canonical default value the factory uses when no override is
|
|
50
|
+
* supplied. Pre-fills the form widget so users see what they're
|
|
51
|
+
* about to change. */
|
|
52
|
+
default?: FactoryParamValue;
|
|
53
|
+
/** Optional human-friendly question prompt. Reserved for a future
|
|
54
|
+
* `.lolo` `@label` annotation. */
|
|
55
|
+
label?: string;
|
|
56
|
+
/** Optional help-text. Reserved for the same future annotation. */
|
|
57
|
+
description?: string;
|
|
58
|
+
/** Optional closed-enum value set. Reserved for the same future
|
|
59
|
+
* annotation. */
|
|
60
|
+
enumValues?: ReadonlyArray<string>;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* One trait the factory composes into the orbital. The projector reads
|
|
64
|
+
* these to determine which factory's trait stack covers a given
|
|
65
|
+
* orbital + which override knobs a presentation overlay can target.
|
|
66
|
+
*/
|
|
67
|
+
interface FactoryTraitSignature {
|
|
68
|
+
/** Canonical trait name post-rename (e.g. `"ChatMessageList"`). */
|
|
69
|
+
name: string;
|
|
70
|
+
/** Event keys this trait emits (post-rename). */
|
|
71
|
+
emittedEvents: ReadonlyArray<string>;
|
|
72
|
+
/** Event keys this trait listens for. */
|
|
73
|
+
listenedEvents: ReadonlyArray<string>;
|
|
74
|
+
/** Config knobs overridable via `traitOverrides.<name>.config.<key>`.
|
|
75
|
+
* Each entry carries the key name plus the typed declaration lifted
|
|
76
|
+
* from the source `.lolo` `config { }` block. */
|
|
77
|
+
overridableConfigKeys: ReadonlyArray<FactoryConfigParam>;
|
|
78
|
+
/** Capability tags lifted directly from the source `.lolo` trait's
|
|
79
|
+
* header annotations. Free-form strings — the translator overlay
|
|
80
|
+
* matches rules to traits by exact set membership. */
|
|
81
|
+
capabilities: ReadonlyArray<string>;
|
|
82
|
+
}
|
|
83
|
+
/** One page the factory emits. The path is the factory default; the
|
|
84
|
+
* projector may override via `params.pagePaths`. */
|
|
85
|
+
interface FactoryPageSignature {
|
|
86
|
+
name: string;
|
|
87
|
+
defaultPath: string;
|
|
88
|
+
primaryEntity: string;
|
|
89
|
+
}
|
|
90
|
+
interface FactorySignature {
|
|
91
|
+
/** Organism the factory belongs to (e.g. `"std-realtime-chat"`). */
|
|
92
|
+
organism: string;
|
|
93
|
+
/** Orbital this factory builds within that organism. */
|
|
94
|
+
orbital: string;
|
|
95
|
+
/** Tier the factory sits in (informational). */
|
|
96
|
+
tier: 'atoms' | 'molecules' | 'organisms';
|
|
97
|
+
/** Path of the generated factory source (relative to the std root). */
|
|
98
|
+
factoryPath: string;
|
|
99
|
+
/** Canonical entity surface(s) the factory produces. */
|
|
100
|
+
entities: ReadonlyArray<FactoryEntitySignature>;
|
|
101
|
+
/** Trait stack the factory composes. */
|
|
102
|
+
traits: ReadonlyArray<FactoryTraitSignature>;
|
|
103
|
+
/** Pages the factory emits. */
|
|
104
|
+
pages: ReadonlyArray<FactoryPageSignature>;
|
|
105
|
+
/** Union of all `traits[].emittedEvents`. */
|
|
106
|
+
emittedEvents: ReadonlyArray<string>;
|
|
107
|
+
/** Union of all `traits[].listenedEvents`. */
|
|
108
|
+
listenedEvents: ReadonlyArray<string>;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Aggregate catalog written to
|
|
112
|
+
* `packages/almadar-std/behaviors/registry/factory-signatures.json`.
|
|
113
|
+
* Sorted by organism then orbital.
|
|
114
|
+
*/
|
|
115
|
+
interface FactorySignatureCatalog {
|
|
116
|
+
/** Generated-by version stamp (the `@almadar/std` minor it shipped in). */
|
|
117
|
+
generatedFromStdVersion: string;
|
|
118
|
+
/** Sorted list of factory signatures. */
|
|
119
|
+
signatures: ReadonlyArray<FactorySignature>;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* A single factory invocation, as the typed result of the translator.
|
|
123
|
+
* Lower into runtime by calling the factory at `factoryPath` with
|
|
124
|
+
* these `params`. Stable identity for downstream diffing is
|
|
125
|
+
* `(organism, orbital)`.
|
|
126
|
+
*/
|
|
127
|
+
interface FactoryCallSite {
|
|
128
|
+
organism: string;
|
|
129
|
+
orbital: string;
|
|
130
|
+
factoryPath: string;
|
|
131
|
+
params: FactoryCallSiteParams;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* The typed param surface every factory's call site populates. Each
|
|
135
|
+
* field corresponds to one row in the translator's overlay → factory
|
|
136
|
+
* mapping table.
|
|
137
|
+
*/
|
|
138
|
+
interface FactoryCallSiteParams {
|
|
139
|
+
/** Override `signature.entities[0].name` (entity rename). */
|
|
140
|
+
entityName?: string;
|
|
141
|
+
/** Additional or overriding entity fields. Caller wins on collision. */
|
|
142
|
+
entityFields?: ReadonlyArray<EntityField>;
|
|
143
|
+
/** Override `signature.entities[0].persistence`. */
|
|
144
|
+
persistence?: EntityPersistence;
|
|
145
|
+
/** Override the entity's storage collection key. */
|
|
146
|
+
collection?: string;
|
|
147
|
+
/** Per-page path overrides keyed by `signature.pages[i].name`. */
|
|
148
|
+
pagePaths?: Readonly<Record<string, string>>;
|
|
149
|
+
/** Trait config overrides keyed by `signature.traits[i].name`. */
|
|
150
|
+
traitOverrides?: Readonly<Record<string, {
|
|
151
|
+
config?: Readonly<Record<string, FactoryParamValue>>;
|
|
152
|
+
}>>;
|
|
153
|
+
/** Extra traits to compose into the orbital that aren't part of the
|
|
154
|
+
* canonical signature trait stack. */
|
|
155
|
+
extraTraits?: ReadonlyArray<TraitReference>;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Allowed leaf values for the typed factory-param surface.
|
|
159
|
+
*/
|
|
160
|
+
type FactoryParamValue = string | number | boolean | ReadonlyArray<FactoryParamValue> | {
|
|
161
|
+
readonly [key: string]: FactoryParamValue;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Cross-cutting presentation knobs that don't live per orbital
|
|
166
|
+
* because they're factory-layer concerns (nav items live on a layout
|
|
167
|
+
* trait; theme is a separate `ThemeRef`). The translator reads these
|
|
168
|
+
* and threads them into the matching factory params.
|
|
169
|
+
*/
|
|
170
|
+
interface PresentationOverlay {
|
|
171
|
+
/** Nav items to add to the orbital's layout trait. The translator
|
|
172
|
+
* looks for a `signature.traits[i]` with `overridableConfigKeys`
|
|
173
|
+
* including `navItems` and writes into `traitOverrides[name].config.navItems`. */
|
|
174
|
+
navAdditions?: ReadonlyArray<PresentationNavItem>;
|
|
175
|
+
/** Optional theme ref override for the orbital. */
|
|
176
|
+
themeRef?: string;
|
|
177
|
+
}
|
|
178
|
+
interface PresentationNavItem {
|
|
179
|
+
label: string;
|
|
180
|
+
path: string;
|
|
181
|
+
icon?: string;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* LLM-authored trait-level overrides keyed by trait name (matches
|
|
185
|
+
* `signature.traits[].name`). Each entry's `config` keys are validated
|
|
186
|
+
* against `signature.traits[i].overridableConfigKeys`.
|
|
187
|
+
*/
|
|
188
|
+
type TraitOverlay = Readonly<Record<string, TraitOverlayEntry>>;
|
|
189
|
+
interface TraitOverlayEntry {
|
|
190
|
+
config?: Readonly<Record<string, FactoryParamValue>>;
|
|
191
|
+
linkedEntity?: string;
|
|
192
|
+
events?: Readonly<Record<string, string>>;
|
|
193
|
+
name?: string;
|
|
194
|
+
emitsScope?: 'internal' | 'external';
|
|
195
|
+
listens?: ReadonlyArray<TraitEventListener>;
|
|
196
|
+
}
|
|
197
|
+
type TraitOverlayListener = TraitEventListener;
|
|
198
|
+
/**
|
|
199
|
+
* Rules carry a free-form `capability: string` that the translator
|
|
200
|
+
* matches against `signature.traits[].capabilities` (source-tagged
|
|
201
|
+
* in `.lolo`).
|
|
202
|
+
*/
|
|
203
|
+
interface RuleOverlay {
|
|
204
|
+
rules: ReadonlyArray<RuleOverlayEntry>;
|
|
205
|
+
/** Entity-level ownership signal. The translator threads it into
|
|
206
|
+
* the matched trait's `config.ownerField` (when the matched trait
|
|
207
|
+
* advertises that key in `overridableConfigKeys`). */
|
|
208
|
+
ownership?: ReadonlyArray<OwnershipOverlayEntry>;
|
|
209
|
+
}
|
|
210
|
+
interface RuleOverlayEntry {
|
|
211
|
+
id: string;
|
|
212
|
+
/** Free-form capability label, matched against
|
|
213
|
+
* `signature.traits[].capabilities` by exact set membership. */
|
|
214
|
+
capability: string;
|
|
215
|
+
description: string;
|
|
216
|
+
/** Entity names this rule binds to. Empty array = cross-cutting. */
|
|
217
|
+
appliesTo: ReadonlyArray<string>;
|
|
218
|
+
/** Optional role name (e.g. `"admin"`) when the rule is role-scoped. */
|
|
219
|
+
role?: string;
|
|
220
|
+
/** Optional extra config knobs threaded into the matched trait's
|
|
221
|
+
* `config`. Validated against the trait's `overridableConfigKeys`. */
|
|
222
|
+
config?: Readonly<Record<string, FactoryParamValue>>;
|
|
223
|
+
}
|
|
224
|
+
interface OwnershipOverlayEntry {
|
|
225
|
+
/** Entity name (matches the orbital's bound entity name). */
|
|
226
|
+
entity: string;
|
|
227
|
+
/** Field name on the entity that carries the owner identifier. */
|
|
228
|
+
ownerField: string;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* The per-orbital binding the agent assembles when it picks a
|
|
233
|
+
* signature. Carries the user-authored overrides directly; no shared
|
|
234
|
+
* domain ontology, no DomainDocument.
|
|
235
|
+
*/
|
|
236
|
+
interface TranslationBinding {
|
|
237
|
+
/** Entity name override. When equal to `signature.entities[0].name`,
|
|
238
|
+
* no rename is emitted. */
|
|
239
|
+
entityName: string;
|
|
240
|
+
/** Extra fields beyond the signature's canonical entity surface. */
|
|
241
|
+
entityFields?: ReadonlyArray<EntityField>;
|
|
242
|
+
/** Persistence override. */
|
|
243
|
+
persistence?: EntityPersistence;
|
|
244
|
+
/** Collection name override. */
|
|
245
|
+
collection?: string;
|
|
246
|
+
/** Per-page path overrides keyed by `signature.pages[i].name`. */
|
|
247
|
+
pagePaths?: Readonly<Record<string, string>>;
|
|
248
|
+
}
|
|
249
|
+
interface TranslationWarning {
|
|
250
|
+
/** Dotted path of the binding field that couldn't be lowered. */
|
|
251
|
+
field: string;
|
|
252
|
+
/** Human-readable reason. */
|
|
253
|
+
reason: string;
|
|
254
|
+
}
|
|
255
|
+
interface TranslationResult {
|
|
256
|
+
callSite: FactoryCallSite;
|
|
257
|
+
warnings: ReadonlyArray<TranslationWarning>;
|
|
258
|
+
}
|
|
259
|
+
declare function translateOverlaysToParams(binding: TranslationBinding, signature: FactorySignature, presentation?: PresentationOverlay, ruleOverlay?: RuleOverlay, traitOverlay?: TraitOverlay, catalog?: ReadonlyArray<FactorySignature>): TranslationResult;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Structural diff between two `FactoryCallSite[]` lists. Pure typed,
|
|
263
|
+
* no side effects. Used by downstream consumers (agent planner, UI
|
|
264
|
+
* cascade view) to turn a "previous calls" + "next calls" pair into a
|
|
265
|
+
* minimal change set.
|
|
21
266
|
*
|
|
22
|
-
*
|
|
267
|
+
* Identity for diffing is `(organism, orbital)`. Renames are not
|
|
268
|
+
* handled here — they show up as a delete + add. The agent layer is
|
|
269
|
+
* expected to merge those back into a `'rename'` op if it can prove
|
|
270
|
+
* the underlying domain entity was renamed.
|
|
23
271
|
*/
|
|
24
272
|
|
|
273
|
+
type CallSiteDiff = {
|
|
274
|
+
kind: 'add';
|
|
275
|
+
orbitalName: string;
|
|
276
|
+
next: FactoryCallSite;
|
|
277
|
+
} | {
|
|
278
|
+
kind: 'delete';
|
|
279
|
+
orbitalName: string;
|
|
280
|
+
prior: FactoryCallSite;
|
|
281
|
+
} | {
|
|
282
|
+
kind: 'edit';
|
|
283
|
+
orbitalName: string;
|
|
284
|
+
prior: FactoryCallSite;
|
|
285
|
+
next: FactoryCallSite;
|
|
286
|
+
} | {
|
|
287
|
+
kind: 'keep';
|
|
288
|
+
orbitalName: string;
|
|
289
|
+
call: FactoryCallSite;
|
|
290
|
+
};
|
|
291
|
+
declare function diffFactoryCalls(prior: ReadonlyArray<FactoryCallSite>, next: ReadonlyArray<FactoryCallSite>): ReadonlyArray<CallSiteDiff>;
|
|
292
|
+
|
|
25
293
|
/**
|
|
26
294
|
* One slot the agent emits per orbital. Slim shape — agent-facing,
|
|
27
295
|
* carries only what factory dispatch needs. The studio renders forms
|
|
@@ -84,7 +352,7 @@ type FactoryCallPlanMutation = {
|
|
|
84
352
|
ref: string;
|
|
85
353
|
} | {
|
|
86
354
|
kind: 'set-rule';
|
|
87
|
-
rule:
|
|
355
|
+
rule: RuleOverlayEntry;
|
|
88
356
|
} | {
|
|
89
357
|
kind: 'remove-rule';
|
|
90
358
|
ruleId: string;
|
|
@@ -102,4 +370,4 @@ interface FactoryCallPlanState {
|
|
|
102
370
|
*/
|
|
103
371
|
declare function applyFactoryCallPlanMutation(state: FactoryCallPlanState, m: FactoryCallPlanMutation): FactoryCallPlanState;
|
|
104
372
|
|
|
105
|
-
export { type FactoryCallPlanMutation, type FactoryCallPlanState, FactoryParamValue, type OrbitalCallInput, RuleOverlay,
|
|
373
|
+
export { type CallSiteDiff, type FactoryCallPlanMutation, type FactoryCallPlanState, type FactoryCallSite, type FactoryCallSiteParams, type FactoryConfigParam, type FactoryEntitySignature, type FactoryPageSignature, type FactoryParamValue, type FactorySignature, type FactorySignatureCatalog, type FactorySignatureEntityField, type FactoryTraitSignature, type OrbitalCallInput, type OwnershipOverlayEntry, type PresentationNavItem, type PresentationOverlay, type RuleOverlay, type RuleOverlayEntry, type SchemaFieldType, type TraitOverlay, type TraitOverlayEntry, type TraitOverlayListener, type TranslationBinding, type TranslationResult, type TranslationWarning, applyFactoryCallPlanMutation, diffFactoryCalls, translateOverlaysToParams };
|
package/dist/factory/index.js
CHANGED
|
@@ -1,28 +1,12 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
|
|
3
|
-
"text": "string",
|
|
4
|
-
"long text": "string",
|
|
5
|
-
"number": "number",
|
|
6
|
-
"currency": "number",
|
|
7
|
-
"yes/no": "boolean",
|
|
8
|
-
"date": "date",
|
|
9
|
-
"timestamp": "timestamp",
|
|
10
|
-
"datetime": "datetime",
|
|
11
|
-
"list": "array",
|
|
12
|
-
"object": "object",
|
|
13
|
-
"enum": "enum",
|
|
14
|
-
"relation": "relation"
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// src/domain-language/sync/translate-domain-to-params.ts
|
|
18
|
-
function translateDomainToParams(binding, signature, presentation, ruleOverlay, traitOverlay, catalog) {
|
|
1
|
+
// src/factory/translate.ts
|
|
2
|
+
function translateOverlaysToParams(binding, signature, presentation, ruleOverlay, traitOverlay, catalog) {
|
|
19
3
|
const warnings = [];
|
|
20
4
|
const params = {};
|
|
21
|
-
applyEntityName(binding
|
|
22
|
-
applyEntityFields(binding
|
|
23
|
-
applyPersistence(binding
|
|
24
|
-
applyCollection(binding
|
|
25
|
-
applyPagePaths(binding
|
|
5
|
+
applyEntityName(binding, signature, params);
|
|
6
|
+
applyEntityFields(binding, signature, params);
|
|
7
|
+
applyPersistence(binding, signature, params, warnings);
|
|
8
|
+
applyCollection(binding, params);
|
|
9
|
+
applyPagePaths(binding, signature, params, warnings);
|
|
26
10
|
applyPresentation(presentation, signature, params, warnings);
|
|
27
11
|
applyTraitOverlay(traitOverlay, signature, params, warnings);
|
|
28
12
|
applyRuleOverlay(ruleOverlay, signature, binding, catalog, params, warnings);
|
|
@@ -36,67 +20,62 @@ function translateDomainToParams(binding, signature, presentation, ruleOverlay,
|
|
|
36
20
|
warnings
|
|
37
21
|
};
|
|
38
22
|
}
|
|
39
|
-
function applyEntityName(
|
|
23
|
+
function applyEntityName(binding, signature, params) {
|
|
40
24
|
if (signature.entities.length === 0) return;
|
|
41
|
-
if (
|
|
42
|
-
params.entityName =
|
|
25
|
+
if (binding.entityName === signature.entities[0].name) return;
|
|
26
|
+
params.entityName = binding.entityName;
|
|
43
27
|
}
|
|
44
|
-
function applyEntityFields(
|
|
28
|
+
function applyEntityFields(binding, signature, params) {
|
|
29
|
+
if (!binding.entityFields || binding.entityFields.length === 0) return;
|
|
45
30
|
if (signature.entities.length === 0) {
|
|
46
|
-
|
|
47
|
-
warnings.push({
|
|
48
|
-
field: `entity.${entity.name}.fields`,
|
|
49
|
-
reason: "factory signature does not advertise an entity surface"
|
|
50
|
-
});
|
|
51
|
-
}
|
|
31
|
+
params.entityFields = [...binding.entityFields];
|
|
52
32
|
return;
|
|
53
33
|
}
|
|
54
34
|
const canonical = new Set(signature.entities[0].fields.map((f) => f.name));
|
|
55
35
|
const extras = [];
|
|
56
|
-
for (const f of
|
|
57
|
-
if (canonical.has(f.name)) continue;
|
|
58
|
-
|
|
59
|
-
if (lowered) extras.push(lowered);
|
|
36
|
+
for (const f of binding.entityFields) {
|
|
37
|
+
if (f.name && canonical.has(f.name)) continue;
|
|
38
|
+
extras.push(f);
|
|
60
39
|
}
|
|
61
40
|
if (extras.length > 0) params.entityFields = extras;
|
|
62
41
|
}
|
|
63
|
-
function applyPersistence(
|
|
64
|
-
if (!
|
|
42
|
+
function applyPersistence(binding, signature, params, warnings) {
|
|
43
|
+
if (!binding.persistence) return;
|
|
65
44
|
if (signature.entities.length === 0) {
|
|
66
45
|
warnings.push({
|
|
67
|
-
field: `entity.${
|
|
46
|
+
field: `entity.${binding.entityName}.persistence`,
|
|
68
47
|
reason: "factory signature has no entity to apply persistence to"
|
|
69
48
|
});
|
|
70
49
|
return;
|
|
71
50
|
}
|
|
72
|
-
if (
|
|
73
|
-
params.persistence =
|
|
51
|
+
if (binding.persistence === signature.entities[0].persistence) return;
|
|
52
|
+
params.persistence = binding.persistence;
|
|
74
53
|
}
|
|
75
|
-
function applyCollection(
|
|
76
|
-
if (!
|
|
77
|
-
params.collection =
|
|
54
|
+
function applyCollection(binding, params) {
|
|
55
|
+
if (!binding.collection) return;
|
|
56
|
+
params.collection = binding.collection;
|
|
78
57
|
}
|
|
79
|
-
function applyPagePaths(
|
|
80
|
-
if (
|
|
58
|
+
function applyPagePaths(binding, signature, params, warnings) {
|
|
59
|
+
if (!binding.pagePaths) return;
|
|
81
60
|
const sigPages = new Map(signature.pages.map((p) => [p.name, p]));
|
|
82
61
|
const overrides = {};
|
|
83
|
-
for (const
|
|
84
|
-
const sig = sigPages.get(
|
|
62
|
+
for (const [pageName, url] of Object.entries(binding.pagePaths)) {
|
|
63
|
+
const sig = sigPages.get(pageName);
|
|
85
64
|
if (!sig) {
|
|
86
65
|
warnings.push({
|
|
87
|
-
field: `page.${
|
|
88
|
-
reason: `factory signature has no page named "${
|
|
66
|
+
field: `page.${pageName}.url`,
|
|
67
|
+
reason: `factory signature has no page named "${pageName}"`
|
|
89
68
|
});
|
|
90
69
|
continue;
|
|
91
70
|
}
|
|
92
|
-
if (sig.defaultPath !==
|
|
71
|
+
if (sig.defaultPath !== url) overrides[pageName] = url;
|
|
93
72
|
}
|
|
94
73
|
if (Object.keys(overrides).length > 0) params.pagePaths = overrides;
|
|
95
74
|
}
|
|
96
75
|
function applyPresentation(overlay, signature, params, warnings) {
|
|
97
76
|
if (!overlay?.navAdditions || overlay.navAdditions.length === 0) return;
|
|
98
77
|
const target = signature.traits.find(
|
|
99
|
-
(t) => t.overridableConfigKeys.
|
|
78
|
+
(t) => t.overridableConfigKeys.some((p) => p.key === "navItems")
|
|
100
79
|
);
|
|
101
80
|
if (!target) {
|
|
102
81
|
warnings.push({
|
|
@@ -134,29 +113,29 @@ function applyTraitOverlay(overlay, signature, params, warnings) {
|
|
|
134
113
|
}
|
|
135
114
|
}
|
|
136
115
|
function mergeTraitOverride(traitName, entry, trait, params, warnings) {
|
|
137
|
-
const advertised = new Set(trait.overridableConfigKeys);
|
|
116
|
+
const advertised = new Set(trait.overridableConfigKeys.map((p) => p.key));
|
|
138
117
|
const existing = params.traitOverrides?.[traitName] ?? {};
|
|
139
118
|
const existingConfig = existing.config ?? {};
|
|
140
119
|
const mergedConfig = { ...existingConfig };
|
|
141
120
|
if (entry.config) {
|
|
142
121
|
for (const [k, v] of Object.entries(entry.config)) {
|
|
143
122
|
if (!advertised.has(k)) {
|
|
123
|
+
const advertisedKeys = trait.overridableConfigKeys.map((p) => p.key).join(", ");
|
|
144
124
|
warnings.push({
|
|
145
125
|
field: `traitOverlay.${traitName}.config.${k}`,
|
|
146
|
-
reason: `trait does not advertise config key "${k}" (overridableConfigKeys: [${
|
|
126
|
+
reason: `trait does not advertise config key "${k}" (overridableConfigKeys: [${advertisedKeys}])`
|
|
147
127
|
});
|
|
148
128
|
continue;
|
|
149
129
|
}
|
|
150
130
|
mergedConfig[k] = v;
|
|
151
131
|
}
|
|
152
132
|
}
|
|
153
|
-
const next = {
|
|
154
|
-
...existing,
|
|
155
|
-
...Object.keys(mergedConfig).length > 0 ? { config: mergedConfig } : {}
|
|
156
|
-
};
|
|
157
133
|
params.traitOverrides = {
|
|
158
134
|
...params.traitOverrides,
|
|
159
|
-
[traitName]:
|
|
135
|
+
[traitName]: {
|
|
136
|
+
...existing,
|
|
137
|
+
...Object.keys(mergedConfig).length > 0 ? { config: mergedConfig } : {}
|
|
138
|
+
}
|
|
160
139
|
};
|
|
161
140
|
}
|
|
162
141
|
function applyRuleOverlay(overlay, signature, binding, catalog, params, warnings) {
|
|
@@ -185,14 +164,14 @@ function applyRuleOverlay(overlay, signature, binding, catalog, params, warnings
|
|
|
185
164
|
}
|
|
186
165
|
if (overlay.ownership) {
|
|
187
166
|
for (const entry of overlay.ownership) {
|
|
188
|
-
if (entry.entity !== binding.
|
|
167
|
+
if (entry.entity !== binding.entityName) continue;
|
|
189
168
|
applyOwnership(entry, params, signature, catalog, warnings);
|
|
190
169
|
}
|
|
191
170
|
}
|
|
192
171
|
}
|
|
193
172
|
function ruleAppliesToBinding(rule, binding) {
|
|
194
173
|
if (rule.appliesTo.length === 0) return true;
|
|
195
|
-
return rule.appliesTo.includes(binding.
|
|
174
|
+
return rule.appliesTo.includes(binding.entityName);
|
|
196
175
|
}
|
|
197
176
|
function findTraitByCapability(catalog, capability) {
|
|
198
177
|
for (const sig of catalog) {
|
|
@@ -204,13 +183,13 @@ function findTraitByCapability(catalog, capability) {
|
|
|
204
183
|
}
|
|
205
184
|
return void 0;
|
|
206
185
|
}
|
|
207
|
-
function appendRuleExtraTrait(
|
|
186
|
+
function appendRuleExtraTrait(_rule, match, binding, params) {
|
|
208
187
|
const fromPath = `std/behaviors/${match.signature.organism}`;
|
|
209
188
|
const alias = organismToAlias(match.signature.organism);
|
|
210
189
|
const ref = {
|
|
211
190
|
from: fromPath,
|
|
212
191
|
ref: `${alias}.traits.${match.trait.name}`,
|
|
213
|
-
linkedEntity: binding.
|
|
192
|
+
linkedEntity: binding.entityName
|
|
214
193
|
};
|
|
215
194
|
const existing = params.extraTraits ?? [];
|
|
216
195
|
params.extraTraits = [...existing, ref];
|
|
@@ -221,7 +200,7 @@ function organismToAlias(organism) {
|
|
|
221
200
|
}
|
|
222
201
|
function threadRuleConfig(rule, trait, params, warnings) {
|
|
223
202
|
if (!rule.config) return;
|
|
224
|
-
const advertised = new Set(trait.overridableConfigKeys);
|
|
203
|
+
const advertised = new Set(trait.overridableConfigKeys.map((p) => p.key));
|
|
225
204
|
const existing = params.traitOverrides?.[trait.name] ?? {};
|
|
226
205
|
const existingConfig = existing.config ?? {};
|
|
227
206
|
const merged = { ...existingConfig };
|
|
@@ -244,7 +223,7 @@ function threadRuleConfig(rule, trait, params, warnings) {
|
|
|
244
223
|
}
|
|
245
224
|
function applyOwnership(entry, params, signature, catalog, warnings) {
|
|
246
225
|
const local = signature.traits.find(
|
|
247
|
-
(t) => t.overridableConfigKeys.
|
|
226
|
+
(t) => t.overridableConfigKeys.some((p) => p.key === "ownerField")
|
|
248
227
|
);
|
|
249
228
|
if (local) {
|
|
250
229
|
writeOwnerField(local.name, entry.ownerField, params);
|
|
@@ -253,7 +232,7 @@ function applyOwnership(entry, params, signature, catalog, warnings) {
|
|
|
253
232
|
if (catalog) {
|
|
254
233
|
for (const sig of catalog) {
|
|
255
234
|
const trait = sig.traits.find(
|
|
256
|
-
(t) => t.overridableConfigKeys.
|
|
235
|
+
(t) => t.overridableConfigKeys.some((p) => p.key === "ownerField")
|
|
257
236
|
);
|
|
258
237
|
if (trait) {
|
|
259
238
|
writeOwnerField(trait.name, entry.ownerField, params);
|
|
@@ -277,37 +256,6 @@ function writeOwnerField(traitName, ownerField, params) {
|
|
|
277
256
|
}
|
|
278
257
|
};
|
|
279
258
|
}
|
|
280
|
-
function lowerField(f) {
|
|
281
|
-
const schemaType = DOMAIN_TO_SCHEMA_FIELD_TYPE[f.fieldType];
|
|
282
|
-
if (!schemaType) return void 0;
|
|
283
|
-
const out = {
|
|
284
|
-
name: f.name,
|
|
285
|
-
type: schemaType
|
|
286
|
-
};
|
|
287
|
-
if (f.required === true) out.required = true;
|
|
288
|
-
if (f.enumValues && f.enumValues.length > 0) out.values = [...f.enumValues];
|
|
289
|
-
if (f.default !== void 0) out.default = lowerDefault(f.default);
|
|
290
|
-
if (f.items) {
|
|
291
|
-
const itemSchema = DOMAIN_TO_SCHEMA_FIELD_TYPE[f.items.type];
|
|
292
|
-
if (itemSchema) out.items = { type: itemSchema };
|
|
293
|
-
}
|
|
294
|
-
return out;
|
|
295
|
-
}
|
|
296
|
-
function lowerDefault(d) {
|
|
297
|
-
if (d === void 0 || d === null) return d;
|
|
298
|
-
if (typeof d === "string" || typeof d === "number" || typeof d === "boolean") {
|
|
299
|
-
return d;
|
|
300
|
-
}
|
|
301
|
-
if (Array.isArray(d)) {
|
|
302
|
-
return d.map(lowerDefault);
|
|
303
|
-
}
|
|
304
|
-
if (typeof d === "object") {
|
|
305
|
-
const out = {};
|
|
306
|
-
for (const [k, v] of Object.entries(d)) out[k] = lowerDefault(v);
|
|
307
|
-
return out;
|
|
308
|
-
}
|
|
309
|
-
return void 0;
|
|
310
|
-
}
|
|
311
259
|
function navItemToParamValue(item) {
|
|
312
260
|
const out = {
|
|
313
261
|
label: item.label,
|
|
@@ -317,7 +265,7 @@ function navItemToParamValue(item) {
|
|
|
317
265
|
return out;
|
|
318
266
|
}
|
|
319
267
|
|
|
320
|
-
// src/
|
|
268
|
+
// src/factory/diff.ts
|
|
321
269
|
function diffFactoryCalls(prior, next) {
|
|
322
270
|
const out = [];
|
|
323
271
|
const priorByKey = new Map(prior.map((c) => [callKey(c), c]));
|
|
@@ -349,6 +297,7 @@ function paramsEqual(a, b) {
|
|
|
349
297
|
}
|
|
350
298
|
function canonicalParams(p) {
|
|
351
299
|
const keys = [
|
|
300
|
+
"collection",
|
|
352
301
|
"entityFields",
|
|
353
302
|
"entityName",
|
|
354
303
|
"extraTraits",
|
|
@@ -479,6 +428,6 @@ function patchOrbital(state, orbitalName, patch) {
|
|
|
479
428
|
};
|
|
480
429
|
}
|
|
481
430
|
|
|
482
|
-
export { applyFactoryCallPlanMutation, diffFactoryCalls,
|
|
431
|
+
export { applyFactoryCallPlanMutation, diffFactoryCalls, translateOverlaysToParams };
|
|
483
432
|
//# sourceMappingURL=index.js.map
|
|
484
433
|
//# sourceMappingURL=index.js.map
|