@almadar/core 4.6.0 → 4.7.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 +143 -3
- package/dist/builders.js +59 -1
- package/dist/builders.js.map +1 -1
- package/dist/{compose-behaviors-Bp32KayC.d.ts → compose-behaviors-BLEoAOk6.d.ts} +1 -1
- package/dist/domain-language/index.d.ts +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/{schema-CLFPg1xW.d.ts → schema-C-6fdZ5P.d.ts} +1 -1
- package/dist/types/index.d.ts +2 -2
- package/package.json +1 -1
package/dist/builders.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as TraitReference, a as TraitEventContract, E as
|
|
2
|
-
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-
|
|
1
|
+
import { T as TraitReference, a as TraitEventContract, E as Entity, S as SExpr, b as TraitEventListener, c as EntityField, d as EntityPersistence, e as EntityRow, U as UseDeclaration, f as EntityRef, g as TraitRef, P as PageRef, O as OrbitalDefinition, h as OrbitalSchema, i as Trait, j as Page, k as PageRefObject } from './schema-C-6fdZ5P.js';
|
|
2
|
+
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-BLEoAOk6.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import '@almadar/patterns';
|
|
5
5
|
|
|
@@ -96,6 +96,146 @@ declare function makePage(opts: MakePageOpts): Page;
|
|
|
96
96
|
* Build an OrbitalDefinition from its three components.
|
|
97
97
|
*/
|
|
98
98
|
declare function makeOrbital(name: string, entity: Entity, traits: Trait[], pages: Page[]): OrbitalDefinition;
|
|
99
|
+
/**
|
|
100
|
+
* Options for {@link makeTraitRef}.
|
|
101
|
+
*/
|
|
102
|
+
interface MakeTraitRefOpts {
|
|
103
|
+
/**
|
|
104
|
+
* Optional registry path disambiguator that pairs with {@link ref}
|
|
105
|
+
* (see {@link TraitReference.from}).
|
|
106
|
+
*/
|
|
107
|
+
from?: string;
|
|
108
|
+
/** Trait reference string, e.g. "Browse.traits.BrowseItemBrowse". */
|
|
109
|
+
ref: string;
|
|
110
|
+
/** Rename the inlined trait at the call site. */
|
|
111
|
+
name?: string;
|
|
112
|
+
/** Rebind the trait to a different linkedEntity. */
|
|
113
|
+
linkedEntity?: string;
|
|
114
|
+
/** Per-key rename map, e.g. `{ OPEN: "ADD_ITEM" }`. */
|
|
115
|
+
events?: Record<string, string>;
|
|
116
|
+
/**
|
|
117
|
+
* Per-event SExpression effect replacement. Keys are POST-rename event
|
|
118
|
+
* names. See {@link TraitReference.effects} for the full contract.
|
|
119
|
+
*/
|
|
120
|
+
effects?: Record<string, SExpr[]>;
|
|
121
|
+
/** Replace the imported trait's `listens` array entirely. */
|
|
122
|
+
listens?: TraitEventListener[];
|
|
123
|
+
/** Set every emit's scope. */
|
|
124
|
+
emitsScope?: 'internal' | 'external';
|
|
125
|
+
/**
|
|
126
|
+
* Nested config overrides. Matches the real {@link TraitReference.config}
|
|
127
|
+
* shape: `Record<string, Record<string, unknown>>` (the outer key is the
|
|
128
|
+
* config field name, the inner record is its value shape).
|
|
129
|
+
*/
|
|
130
|
+
config?: Record<string, Record<string, unknown>>;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Build a {@link TraitReference} from options.
|
|
134
|
+
*
|
|
135
|
+
* Pass-through factory: copies only the fields that are actually provided,
|
|
136
|
+
* so optionals stay absent (no `key: undefined` slots) and the emitted
|
|
137
|
+
* object matches the inliner's expectation that "present = override".
|
|
138
|
+
*/
|
|
139
|
+
declare function makeTraitRef(opts: MakeTraitRefOpts): TraitReference;
|
|
140
|
+
/**
|
|
141
|
+
* Options for {@link makePageRef}.
|
|
142
|
+
*/
|
|
143
|
+
interface MakePageRefOpts {
|
|
144
|
+
/**
|
|
145
|
+
* Optional registry path disambiguator that pairs with {@link ref}
|
|
146
|
+
* (see {@link PageRefObject.from}).
|
|
147
|
+
*/
|
|
148
|
+
from?: string;
|
|
149
|
+
/** Page reference string, e.g. "Browse.pages.BrowseItemPage". */
|
|
150
|
+
ref: string;
|
|
151
|
+
/** URL path override. */
|
|
152
|
+
path?: string;
|
|
153
|
+
/** Rebind the page's primary entity. */
|
|
154
|
+
linkedEntity?: string;
|
|
155
|
+
/** Replace the page's trait list. */
|
|
156
|
+
traits?: TraitRef[];
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Build a {@link PageRefObject} from options. Pass-through factory — omits
|
|
160
|
+
* optional keys that are `undefined`.
|
|
161
|
+
*/
|
|
162
|
+
declare function makePageRef(opts: MakePageRefOpts): PageRefObject;
|
|
163
|
+
/**
|
|
164
|
+
* Options for {@link makeOrbitalWithUses}.
|
|
165
|
+
*/
|
|
166
|
+
interface MakeOrbitalWithUsesOpts {
|
|
167
|
+
/** Orbital name. */
|
|
168
|
+
name: string;
|
|
169
|
+
/**
|
|
170
|
+
* Per-orbital `uses:` header entries (see CLAUDE.md "uses: lives inside
|
|
171
|
+
* the orbital").
|
|
172
|
+
*/
|
|
173
|
+
uses: UseDeclaration[];
|
|
174
|
+
/** Entity (inline or reference form). */
|
|
175
|
+
entity: EntityRef;
|
|
176
|
+
/** Trait references. */
|
|
177
|
+
traits: TraitRef[];
|
|
178
|
+
/** Optional page references (omitted entirely when not provided). */
|
|
179
|
+
pages?: PageRef[];
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Build an {@link OrbitalDefinition} with the `uses:` header set. Follows
|
|
183
|
+
* the convention that `uses:` lives on the orbital (not the schema).
|
|
184
|
+
*
|
|
185
|
+
* When `pages` is omitted, the result has no `pages` property (matches the
|
|
186
|
+
* existing {@link OrbitalDefinition.pages} optionality in descriptors that
|
|
187
|
+
* carry trait-only atoms).
|
|
188
|
+
*/
|
|
189
|
+
declare function makeOrbitalWithUses(opts: MakeOrbitalWithUsesOpts): OrbitalDefinition;
|
|
190
|
+
/**
|
|
191
|
+
* Options for {@link makeAtomOrbital}.
|
|
192
|
+
*
|
|
193
|
+
* Overrides for the single trait reference. Mirrors the {@link MakeTraitRefOpts}
|
|
194
|
+
* subset that is meaningful at the atom-wrapping call site.
|
|
195
|
+
*/
|
|
196
|
+
interface MakeAtomOrbitalTraitOverrides {
|
|
197
|
+
name?: string;
|
|
198
|
+
events?: Record<string, string>;
|
|
199
|
+
effects?: Record<string, SExpr[]>;
|
|
200
|
+
listens?: TraitEventListener[];
|
|
201
|
+
emitsScope?: 'internal' | 'external';
|
|
202
|
+
config?: Record<string, Record<string, unknown>>;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Options for {@link makeAtomOrbital}.
|
|
206
|
+
*/
|
|
207
|
+
interface MakeAtomOrbitalOpts {
|
|
208
|
+
/** Orbital name, e.g. `${entityName}Orbital`. */
|
|
209
|
+
name: string;
|
|
210
|
+
/** Atom registry path, e.g. `std/behaviors/atoms/std-browse`. */
|
|
211
|
+
atomPath: string;
|
|
212
|
+
/** Import alias (PascalCase), e.g. `Browse`. */
|
|
213
|
+
alias: string;
|
|
214
|
+
/** Entity definition to attach to the orbital. */
|
|
215
|
+
entity: Entity;
|
|
216
|
+
/** Trait reference string, e.g. `Browse.traits.BrowseItemBrowse`. */
|
|
217
|
+
traitRef: string;
|
|
218
|
+
/** Optional trait-level overrides applied at the call site. */
|
|
219
|
+
traitOverrides?: MakeAtomOrbitalTraitOverrides;
|
|
220
|
+
/** Optional page reference string, e.g. `Browse.pages.BrowseItemPage`. */
|
|
221
|
+
pageRef?: string;
|
|
222
|
+
/** Optional page-level overrides applied at the call site. */
|
|
223
|
+
pageOverrides?: {
|
|
224
|
+
path?: string;
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Build a single-atom {@link OrbitalDefinition}.
|
|
229
|
+
*
|
|
230
|
+
* The common atom shape: one entity + one trait reference + (optionally) one
|
|
231
|
+
* page reference, all under a single `uses:` import. Wraps
|
|
232
|
+
* {@link makeTraitRef}, {@link makePageRef}, and {@link makeOrbitalWithUses}.
|
|
233
|
+
*
|
|
234
|
+
* The trait reference is linkedEntity-bound to `entity.name` by default so
|
|
235
|
+
* that the inliner's entity-substitution pass rewrites every `["ref", X]`
|
|
236
|
+
* and `@X.path` reference inside the atom.
|
|
237
|
+
*/
|
|
238
|
+
declare function makeAtomOrbital(opts: MakeAtomOrbitalOpts): OrbitalDefinition;
|
|
99
239
|
/**
|
|
100
240
|
* Wrap one or more OrbitalDefinitions into an OrbitalSchema.
|
|
101
241
|
* Every .orb file should be a full OrbitalSchema — this is the builder for that.
|
|
@@ -147,4 +287,4 @@ declare function compose(orbitals: (OrbitalDefinition | OrbitalSchema)[], pages:
|
|
|
147
287
|
*/
|
|
148
288
|
declare function pipe(orbitals: (OrbitalDefinition | OrbitalSchema)[], events: TraitEventContract[], appName?: string): OrbitalSchema;
|
|
149
289
|
|
|
150
|
-
export { type ComposeConnection, type ComposePage, type MakeEntityOpts, type MakePageOpts, compose, connect, ensureIdField, explodeBehaviorComposition, extractTrait, makeEntity, makeOrbital, makePage, makeSchema, mergeOrbitals, pipe, plural, wire };
|
|
290
|
+
export { type ComposeConnection, type ComposePage, type MakeAtomOrbitalOpts, type MakeAtomOrbitalTraitOverrides, type MakeEntityOpts, type MakeOrbitalWithUsesOpts, type MakePageOpts, type MakePageRefOpts, type MakeTraitRefOpts, compose, connect, ensureIdField, explodeBehaviorComposition, extractTrait, makeAtomOrbital, makeEntity, makeOrbital, makeOrbitalWithUses, makePage, makePageRef, makeSchema, makeTraitRef, mergeOrbitals, pipe, plural, wire };
|
package/dist/builders.js
CHANGED
|
@@ -1181,6 +1181,64 @@ function makePage(opts) {
|
|
|
1181
1181
|
function makeOrbital(name, entity, traits, pages) {
|
|
1182
1182
|
return { name, entity, traits, pages };
|
|
1183
1183
|
}
|
|
1184
|
+
function makeTraitRef(opts) {
|
|
1185
|
+
const ref = { ref: opts.ref };
|
|
1186
|
+
if (opts.from !== void 0) ref.from = opts.from;
|
|
1187
|
+
if (opts.name !== void 0) ref.name = opts.name;
|
|
1188
|
+
if (opts.linkedEntity !== void 0) ref.linkedEntity = opts.linkedEntity;
|
|
1189
|
+
if (opts.events !== void 0) ref.events = opts.events;
|
|
1190
|
+
if (opts.effects !== void 0) ref.effects = opts.effects;
|
|
1191
|
+
if (opts.listens !== void 0) ref.listens = opts.listens;
|
|
1192
|
+
if (opts.emitsScope !== void 0) ref.emitsScope = opts.emitsScope;
|
|
1193
|
+
if (opts.config !== void 0) ref.config = opts.config;
|
|
1194
|
+
return ref;
|
|
1195
|
+
}
|
|
1196
|
+
function makePageRef(opts) {
|
|
1197
|
+
const ref = { ref: opts.ref };
|
|
1198
|
+
if (opts.from !== void 0) ref.from = opts.from;
|
|
1199
|
+
if (opts.path !== void 0) ref.path = opts.path;
|
|
1200
|
+
if (opts.linkedEntity !== void 0) ref.linkedEntity = opts.linkedEntity;
|
|
1201
|
+
if (opts.traits !== void 0) ref.traits = opts.traits;
|
|
1202
|
+
return ref;
|
|
1203
|
+
}
|
|
1204
|
+
function makeOrbitalWithUses(opts) {
|
|
1205
|
+
const orbital = {
|
|
1206
|
+
name: opts.name,
|
|
1207
|
+
uses: opts.uses,
|
|
1208
|
+
entity: opts.entity,
|
|
1209
|
+
traits: opts.traits,
|
|
1210
|
+
pages: opts.pages ?? []
|
|
1211
|
+
};
|
|
1212
|
+
return orbital;
|
|
1213
|
+
}
|
|
1214
|
+
function makeAtomOrbital(opts) {
|
|
1215
|
+
const traitRef = makeTraitRef({
|
|
1216
|
+
from: opts.atomPath,
|
|
1217
|
+
ref: opts.traitRef,
|
|
1218
|
+
linkedEntity: opts.entity.name,
|
|
1219
|
+
...opts.traitOverrides?.name !== void 0 ? { name: opts.traitOverrides.name } : {},
|
|
1220
|
+
...opts.traitOverrides?.events !== void 0 ? { events: opts.traitOverrides.events } : {},
|
|
1221
|
+
...opts.traitOverrides?.effects !== void 0 ? { effects: opts.traitOverrides.effects } : {},
|
|
1222
|
+
...opts.traitOverrides?.listens !== void 0 ? { listens: opts.traitOverrides.listens } : {},
|
|
1223
|
+
...opts.traitOverrides?.emitsScope !== void 0 ? { emitsScope: opts.traitOverrides.emitsScope } : {},
|
|
1224
|
+
...opts.traitOverrides?.config !== void 0 ? { config: opts.traitOverrides.config } : {}
|
|
1225
|
+
});
|
|
1226
|
+
const pages = opts.pageRef ? [
|
|
1227
|
+
makePageRef({
|
|
1228
|
+
from: opts.atomPath,
|
|
1229
|
+
ref: opts.pageRef,
|
|
1230
|
+
linkedEntity: opts.entity.name,
|
|
1231
|
+
...opts.pageOverrides?.path !== void 0 ? { path: opts.pageOverrides.path } : {}
|
|
1232
|
+
})
|
|
1233
|
+
] : void 0;
|
|
1234
|
+
return makeOrbitalWithUses({
|
|
1235
|
+
name: opts.name,
|
|
1236
|
+
uses: [{ from: opts.atomPath, as: opts.alias }],
|
|
1237
|
+
entity: opts.entity,
|
|
1238
|
+
traits: [traitRef],
|
|
1239
|
+
...pages !== void 0 ? { pages } : {}
|
|
1240
|
+
});
|
|
1241
|
+
}
|
|
1184
1242
|
function makeSchema(name, ...definitions) {
|
|
1185
1243
|
return { name, version: "1.0.0", orbitals: definitions };
|
|
1186
1244
|
}
|
|
@@ -1328,6 +1386,6 @@ function pipe(orbitals, events, appName) {
|
|
|
1328
1386
|
};
|
|
1329
1387
|
}
|
|
1330
1388
|
|
|
1331
|
-
export { applyEventWiring, compose, composeBehaviors, connect, detectLayoutStrategy, ensureIdField, explodeBehaviorComposition, extractTrait, makeEntity, makeOrbital, makePage, makeSchema, mergeOrbitals, pipe, plural, wire };
|
|
1389
|
+
export { applyEventWiring, compose, composeBehaviors, connect, detectLayoutStrategy, ensureIdField, explodeBehaviorComposition, extractTrait, makeAtomOrbital, makeEntity, makeOrbital, makeOrbitalWithUses, makePage, makePageRef, makeSchema, makeTraitRef, mergeOrbitals, pipe, plural, wire };
|
|
1332
1390
|
//# sourceMappingURL=builders.js.map
|
|
1333
1391
|
//# sourceMappingURL=builders.js.map
|