@almadar/shell-runtime 0.1.0 → 1.1.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/chunk-2WCVOMZ2.js +112 -0
- package/dist/chunk-57SBCUSM.js +62 -0
- package/dist/{chunk-Q2H75UYT.js → chunk-A2JJT4GA.js} +1 -37
- package/dist/chunk-BAS26HBN.js +10 -0
- package/dist/{chunk-REPX5QPI.js → chunk-BOVU4TCQ.js} +11 -3
- package/dist/chunk-BY5G4225.js +6 -0
- package/dist/chunk-DFDNHVDW.js +284 -0
- package/dist/{chunk-NATGCIVM.js → chunk-JVSREWQO.js} +378 -130
- package/dist/{chunk-DYOJGLIX.js → chunk-LKWYCYX5.js} +2 -5
- package/dist/chunk-LYFIQPXX.js +1 -0
- package/dist/{chunk-ODJCZ27I.js → chunk-N7HYNKK6.js} +35 -2
- package/dist/{chunk-4J2QEIUV.js → chunk-NTFQ36UN.js} +4 -30
- package/dist/chunk-NU6LVKGS.js +15 -0
- package/dist/{chunk-VNMG7NKY.js → chunk-OQVSN7DP.js} +21 -26
- package/dist/chunk-P2N6K2IV.js +20 -0
- package/dist/{chunk-QQRDUMB2.js → chunk-QCJWPXLH.js} +11 -11
- package/dist/{chunk-QELZ6TEJ.js → chunk-UD2CXYSJ.js} +39 -3
- package/dist/{chunk-UJHOUZAL.js → chunk-V4EMDPCO.js} +2 -5
- package/dist/chunk-VKQA2DJX.js +409 -0
- package/dist/chunk-VNGXRYFF.js +9 -0
- package/dist/{chunk-HNOAZWFH.js → chunk-WGCWJOT2.js} +2 -0
- package/dist/chunk-XZGVOBY6.js +33 -0
- package/dist/chunk-ZUSM4VW4.js +197 -0
- package/dist/client/EventTransport.d.ts +23 -7
- package/dist/client/EventTransport.js +1 -2
- package/dist/client/awaiting.js +0 -1
- package/dist/client/channel-transport.d.ts +6 -6
- package/dist/client/channel-transport.js +0 -1
- package/dist/client/circuit-store.d.ts +16 -5
- package/dist/client/circuit-store.js +2 -3
- package/dist/client/client-kernel.d.ts +36 -15
- package/dist/client/declared-input-dispatch.d.ts +19 -2
- package/dist/client/declared-input-dispatch.js +1 -2
- package/dist/client/inbound-dispatch.d.ts +21 -2
- package/dist/client/inbound-dispatch.js +1 -2
- package/dist/client/local-fold.d.ts +15 -8
- package/dist/client/local-fold.js +1 -2
- package/dist/client/render-sigils.js +0 -1
- package/dist/client/state-book.d.ts +9 -16
- package/dist/client/state-book.js +1 -2
- package/dist/client/trait-mount-error.js +0 -1
- package/dist/credentials/env-vars.d.ts +5 -1
- package/dist/credentials/env-vars.js +1 -3
- package/dist/credentials/scope.d.ts +8 -7
- package/dist/credentials/scope.js +0 -1
- package/dist/credentials/vault.d.ts +142 -0
- package/dist/credentials/vault.js +1 -0
- package/dist/effects/in-flight-calls.js +0 -1
- package/dist/effects/on-device-model.js +0 -1
- package/dist/events/EventBus.d.ts +1 -4
- package/dist/events/EventBus.js +0 -1
- package/dist/events/emit-stamp.js +0 -1
- package/dist/index.d.ts +25 -42
- package/dist/index.js +27 -45
- package/dist/kernel/decode.d.ts +10 -10
- package/dist/kernel/decode.js +1 -2
- package/dist/kernel/engine.d.ts +133 -31
- package/dist/kernel/engine.js +7 -9
- package/dist/kernel/frame-applier.d.ts +8 -7
- package/dist/kernel/frame-applier.js +1 -2
- package/dist/kernel/host.d.ts +148 -16
- package/dist/kernel/host.js +4 -7
- package/dist/kernel/lane.d.ts +1 -22
- package/dist/kernel/lane.js +1 -2
- package/dist/kernel/os-fetch-port.d.ts +7 -0
- package/dist/kernel/os-fetch-port.js +3 -0
- package/dist/kernel/os-port.d.ts +30 -8
- package/dist/kernel/os-port.js +1 -2
- package/dist/kernel/program-effects.d.ts +11 -28
- package/dist/kernel/program-effects.js +1 -2
- package/dist/kernel/secret-ports.d.ts +139 -0
- package/dist/kernel/secret-ports.js +2 -0
- package/dist/kernel/wire.d.ts +113 -12
- package/dist/loader/fetch-loader.d.ts +26 -0
- package/dist/loader/fetch-loader.js +1 -0
- package/dist/loader/lazy-page.js +0 -1
- package/dist/loader/schema-loader.d.ts +1 -17
- package/dist/persistence/native-memory.js +0 -1
- package/dist/runtime/entities/declaredCollections.d.ts +6 -0
- package/dist/runtime/entities/declaredCollections.js +1 -0
- package/dist/runtime/evaluation/local-store-transport.d.ts +16 -23
- package/dist/runtime/evaluation/local-store-transport.js +9 -13
- package/dist/runtime/evaluation/residence-transport.d.ts +3 -3
- package/dist/runtime/evaluation/residence-transport.js +1 -2
- package/dist/runtime/evaluation/routed-persistence.js +0 -1
- package/dist/runtime/events/identity/routing.d.ts +2 -53
- package/dist/runtime/events/identity/routing.js +1 -2
- package/dist/runtime/types.d.ts +5 -205
- package/dist/runtime/types.js +1 -2
- package/dist/service/default-call-service.js +0 -1
- package/dist/service/service-provider.js +0 -1
- package/package.json +8 -5
- package/dist/chunk-2JU7Y4KU.js +0 -21
- package/dist/chunk-46RWK2B5.js +0 -28
- package/dist/chunk-4ZICQ5PM.js +0 -192
- package/dist/chunk-53IPZXDP.js +0 -76
- package/dist/chunk-5D63EMO5.js +0 -16
- package/dist/chunk-CPSQXEJ6.js +0 -55
- package/dist/chunk-CQP5XAX6.js +0 -173
- package/dist/chunk-CROS2GEX.js +0 -49
- package/dist/chunk-D4XJTBLB.js +0 -217
- package/dist/chunk-D5USD2EX.js +0 -232
- package/dist/chunk-EV56K4GB.js +0 -63
- package/dist/chunk-FQ6IZMIU.js +0 -10
- package/dist/chunk-HMK6YMQS.js +0 -135
- package/dist/chunk-IHQLE5M7.js +0 -62
- package/dist/chunk-JFWFDUTR.js +0 -35
- package/dist/chunk-MHYSHSRG.js +0 -54
- package/dist/chunk-MLKGABMK.js +0 -7
- package/dist/chunk-NAECVIAR.js +0 -322
- package/dist/chunk-Q7JK4KY7.js +0 -9
- package/dist/chunk-RBUMDYFS.js +0 -681
- package/dist/chunk-SAS5KKCR.js +0 -43
- package/dist/chunk-SWPDU752.js +0 -28
- package/dist/chunk-T775TUCD.js +0 -18
- package/dist/chunk-VMOBW7RK.js +0 -21
- package/dist/chunk-WNPNNYXY.js +0 -22
- package/dist/chunk-XB5GYODW.js +0 -28
- package/dist/chunk-YL2SO5TP.js +0 -334
- package/dist/chunk-YO4LWS3I.js +0 -606
- package/dist/chunk-ZAQSS47X.js +0 -157
- package/dist/chunk-ZCQUUJIF.js +0 -129
- package/dist/client/ServerBridge.d.ts +0 -126
- package/dist/client/ServerBridge.js +0 -3
- package/dist/credentials/seed.d.ts +0 -21
- package/dist/credentials/seed.js +0 -2
- package/dist/credentials/store.d.ts +0 -110
- package/dist/credentials/store.js +0 -2
- package/dist/index-hT1xCdTq.d.ts +0 -46
- package/dist/kernel/beacon.d.ts +0 -32
- package/dist/kernel/beacon.js +0 -2
- package/dist/kernel/http.d.ts +0 -302
- package/dist/kernel/http.js +0 -6
- package/dist/kernel/oauth-effects.d.ts +0 -25
- package/dist/kernel/oauth-effects.js +0 -7
- package/dist/kernel/oauth-port.d.ts +0 -31
- package/dist/kernel/oauth-port.js +0 -2
- package/dist/loader/http-loader.d.ts +0 -111
- package/dist/loader/http-loader.js +0 -2
- package/dist/runtime/effects/composition/compose-behaviors.d.ts +0 -58
- package/dist/runtime/effects/composition/compose-behaviors.js +0 -4
- package/dist/runtime/effects/composition/event-wiring.d.ts +0 -38
- package/dist/runtime/effects/composition/event-wiring.js +0 -2
- package/dist/runtime/effects/composition/index.d.ts +0 -5
- package/dist/runtime/effects/composition/index.js +0 -6
- package/dist/runtime/effects/composition/layout-strategy.d.ts +0 -35
- package/dist/runtime/effects/composition/layout-strategy.js +0 -2
- package/dist/runtime/effects/composition/pipe.d.ts +0 -25
- package/dist/runtime/effects/composition/pipe.js +0 -2
- package/dist/runtime/entities/mockStoreSeed.d.ts +0 -56
- package/dist/runtime/entities/mockStoreSeed.js +0 -3
- package/dist/runtime/entities/seedBrowserStore.d.ts +0 -28
- package/dist/runtime/entities/seedBrowserStore.js +0 -2
- package/dist/runtime/entities/std-mock-seed.d.ts +0 -87
- package/dist/runtime/entities/std-mock-seed.js +0 -2
- package/dist/runtime/time/TickScheduler.d.ts +0 -77
- package/dist/runtime/time/TickScheduler.js +0 -3
- package/dist/runtime/time/cron.d.ts +0 -25
- package/dist/runtime/time/cron.js +0 -2
- package/dist/runtime/time/duration.d.ts +0 -20
- package/dist/runtime/time/duration.js +0 -2
- package/dist/runtime/traits/OrbitalTraitParsing.d.ts +0 -34
- package/dist/runtime/traits/OrbitalTraitParsing.js +0 -2
- package/dist/runtime/traits/listen-targets.d.ts +0 -16
- package/dist/runtime/traits/listen-targets.js +0 -3
- package/dist/runtime/traits/trait-index.d.ts +0 -35
- package/dist/runtime/traits/trait-index.js +0 -3
package/dist/chunk-D4XJTBLB.js
DELETED
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
import { declareCapabilities, answerRequest } from './chunk-NATGCIVM.js';
|
|
2
|
-
import { DispatchLane } from './chunk-53IPZXDP.js';
|
|
3
|
-
import { decodeResolveProgress, decodeProgress } from './chunk-RBUMDYFS.js';
|
|
4
|
-
import { installKernelEvaluator, MountSeedSchema, EventStreamItemSchema, isEntityReferenceAny } from '@almadar/core';
|
|
5
|
-
|
|
6
|
-
function declaredEntityTypes(schema) {
|
|
7
|
-
return schema.orbitals.flatMap((orbital) => [orbital.entity, ...orbital.auxiliaryEntities ?? []].flatMap((entity) => isEntityReferenceAny(entity) ? [] : [entity.name]));
|
|
8
|
-
}
|
|
9
|
-
var KernelEngine = class _KernelEngine {
|
|
10
|
-
constructor(kernel, schemaJson, ports, entityTypes = [], forkedFrom, providedHandle, preserveProgramContext = false) {
|
|
11
|
-
this.kernel = kernel;
|
|
12
|
-
this.schemaJson = schemaJson;
|
|
13
|
-
this.ports = ports;
|
|
14
|
-
this.entityTypes = entityTypes;
|
|
15
|
-
this.preserveProgramContext = preserveProgramContext;
|
|
16
|
-
installKernelEvaluator(kernel);
|
|
17
|
-
this.ports = {
|
|
18
|
-
...ports,
|
|
19
|
-
substrateMessage: (site, key, value) => JSON.parse(kernel.osCompletionEvent(JSON.stringify({ ...site, emit: { success: site.emit.onMessage } }), key, JSON.stringify({ ok: value }))),
|
|
20
|
-
substrateCompletion: (site, key, op, args, outcome) => JSON.parse(kernel.substrateCompletionEvent(JSON.stringify(site), key, op, JSON.stringify(args), JSON.stringify(outcome)))
|
|
21
|
-
};
|
|
22
|
-
this.handle = providedHandle ?? forkedFrom?.fork() ?? this.openServer();
|
|
23
|
-
this.declare();
|
|
24
|
-
}
|
|
25
|
-
kernel;
|
|
26
|
-
schemaJson;
|
|
27
|
-
ports;
|
|
28
|
-
entityTypes;
|
|
29
|
-
preserveProgramContext;
|
|
30
|
-
handle;
|
|
31
|
-
lane = new DispatchLane();
|
|
32
|
-
tickMount = [];
|
|
33
|
-
messages = { locales: [], catalogs: {} };
|
|
34
|
-
/**
|
|
35
|
-
* A kernel on the same program, registered once, holding none of this one's session: every trait at its initial
|
|
36
|
-
* state, no rows the kernel held, its locales and mounted ticks kept. A stateless host serves each request a
|
|
37
|
-
* fork (EXEC-DIST-5), `ports` answering it.
|
|
38
|
-
*/
|
|
39
|
-
fork(ports = this.ports) {
|
|
40
|
-
const forked = new _KernelEngine(this.kernel, this.schemaJson, ports, this.entityTypes, this.handle, void 0, this.preserveProgramContext);
|
|
41
|
-
forked.tickMount = this.tickMount;
|
|
42
|
-
forked.messages = this.messages;
|
|
43
|
-
return forked;
|
|
44
|
-
}
|
|
45
|
-
forkProgram(program, ports = this.ports) {
|
|
46
|
-
const schemaJson = JSON.stringify(program);
|
|
47
|
-
const entityTypes = [.../* @__PURE__ */ new Set([
|
|
48
|
-
...this.entityTypes,
|
|
49
|
-
...declaredEntityTypes(program)
|
|
50
|
-
])];
|
|
51
|
-
return new _KernelEngine(this.kernel, schemaJson, ports, entityTypes, void 0, this.handle.forkProgram(schemaJson), true);
|
|
52
|
-
}
|
|
53
|
-
/** A server over the host's ports. */
|
|
54
|
-
openServer() {
|
|
55
|
-
return new this.kernel.Server(this.schemaJson);
|
|
56
|
-
}
|
|
57
|
-
declare() {
|
|
58
|
-
const handle = this.handle;
|
|
59
|
-
declareCapabilities(this.ports.persistence, (entityType, queryJson, writeJson) => handle.setCapabilities(entityType, queryJson, writeJson), this.entityTypes);
|
|
60
|
-
}
|
|
61
|
-
static open(kernel, schema, ports) {
|
|
62
|
-
return new _KernelEngine(kernel, JSON.stringify(schema), ports, declaredEntityTypes(schema));
|
|
63
|
-
}
|
|
64
|
-
/** A fresh kernel on the same program: every trait back at its initial state. */
|
|
65
|
-
reset() {
|
|
66
|
-
const contextualHandle = this.preserveProgramContext ? this.handle.fork() : void 0;
|
|
67
|
-
this.handle.free();
|
|
68
|
-
this.handle = contextualHandle ?? this.openServer();
|
|
69
|
-
this.declare();
|
|
70
|
-
this.handle.setTickMount(JSON.stringify(this.tickMount));
|
|
71
|
-
this.handle.setMessages(JSON.stringify(this.messages.locales), JSON.stringify(this.messages.catalogs));
|
|
72
|
-
if (this.managedProgram !== void 0) this.handle.setManagedProgram(this.managedProgram);
|
|
73
|
-
}
|
|
74
|
-
managedProgram;
|
|
75
|
-
/** The program whose declared credentials this kernel's credential effects manage beside its own (a console's app). */
|
|
76
|
-
setManagedProgram(program) {
|
|
77
|
-
this.managedProgram = JSON.stringify(program);
|
|
78
|
-
this.handle.setManagedProgram(this.managedProgram);
|
|
79
|
-
}
|
|
80
|
-
/** The program's declared locales and merged catalogs (a lazy page's behavior contributes its namespaced keys). */
|
|
81
|
-
setMessages(locales, catalogs) {
|
|
82
|
-
this.messages = { locales, catalogs };
|
|
83
|
-
this.handle.setMessages(JSON.stringify(locales), JSON.stringify(catalogs));
|
|
84
|
-
}
|
|
85
|
-
/** The traits some client has mounted: a tick that is not `[background]` fires only for these. */
|
|
86
|
-
setTickMount(traits) {
|
|
87
|
-
this.tickMount = traits;
|
|
88
|
-
this.handle.setTickMount(JSON.stringify(traits));
|
|
89
|
-
}
|
|
90
|
-
/** What this host mounts when it starts: the kernel's boot mounts for the side it serves (EXEC-ENDPOINT-3). */
|
|
91
|
-
bootMounts(side) {
|
|
92
|
-
return MountSeedSchema.array().parse(JSON.parse(this.handle.bootMounts(side)));
|
|
93
|
-
}
|
|
94
|
-
/** What mounts when a client opens `routePath` (EXEC-ENDPOINT-3). */
|
|
95
|
-
routeMounts(routePath) {
|
|
96
|
-
return MountSeedSchema.array().parse(JSON.parse(this.handle.routeMounts(routePath)));
|
|
97
|
-
}
|
|
98
|
-
/** Mock-seed the `[runtime]` entities the kernel holds itself, owner columns stamped with `viewerId`. */
|
|
99
|
-
seedRuntimeMock(viewerId) {
|
|
100
|
-
this.handle.seedRuntimeMock(viewerId);
|
|
101
|
-
}
|
|
102
|
-
dispose() {
|
|
103
|
-
this.handle.free();
|
|
104
|
-
}
|
|
105
|
-
liveItemDelivered(item, viewer, clientId) {
|
|
106
|
-
return this.handle.liveItemDelivered(JSON.stringify(item), JSON.stringify(viewer), clientId);
|
|
107
|
-
}
|
|
108
|
-
/** `OsGrants::allows` over the grants of the program this kernel runs. */
|
|
109
|
-
osAllows(requirementJson) {
|
|
110
|
-
return this.handle.osAllows(requirementJson);
|
|
111
|
-
}
|
|
112
|
-
/** Place the program's anchored grants and arguments under the host's anchors. */
|
|
113
|
-
setOsAnchors(anchorsJson) {
|
|
114
|
-
return this.handle.setOsAnchors(anchorsJson);
|
|
115
|
-
}
|
|
116
|
-
/** An `os/` call's arguments with its anchored parts resolved under the host's anchors. */
|
|
117
|
-
osResolveArgs(op, argsJson) {
|
|
118
|
-
return this.handle.osResolveArgs(op, argsJson);
|
|
119
|
-
}
|
|
120
|
-
/** The current state of a trait instance, `''` when it has none. */
|
|
121
|
-
stateOf(traitName, entityId) {
|
|
122
|
-
return this.handle.getState(traitName, entityId);
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* `reference` resolved for `scope.user` against the host-answered store (EXEC-RENDER-3): the rows that still
|
|
126
|
-
* match its query and the viewer's `@read` in the reference's order, a missing or hidden row omitted, and `total`
|
|
127
|
-
* re-counted (a `total: none` reference is not re-counted: the total is the resolved window). Each read the
|
|
128
|
-
* kernel makes is answered here, as in `evaluate`.
|
|
129
|
-
*/
|
|
130
|
-
async resolveRows(reference, scope) {
|
|
131
|
-
const handle = this.handle;
|
|
132
|
-
let progress = decodeResolveProgress(handle.resolveRows(JSON.stringify(reference), JSON.stringify(scope.user ?? null)));
|
|
133
|
-
while (progress.status === "await") {
|
|
134
|
-
const { flight, requests } = progress;
|
|
135
|
-
let replies;
|
|
136
|
-
try {
|
|
137
|
-
replies = await Promise.all(
|
|
138
|
-
requests.map(async (pending) => ({ id: pending.id, answer: await answerRequest(this.ports, pending.request, scope) }))
|
|
139
|
-
);
|
|
140
|
-
} catch (error) {
|
|
141
|
-
handle.abandon(flight);
|
|
142
|
-
throw error;
|
|
143
|
-
}
|
|
144
|
-
progress = decodeResolveProgress(handle.resumeResolve(flight, JSON.stringify(replies)));
|
|
145
|
-
}
|
|
146
|
-
return { rows: progress.rows, total: progress.total };
|
|
147
|
-
}
|
|
148
|
-
/** Run `request` against `orbital`: start it, answer every request the kernel asks for, resume until done. */
|
|
149
|
-
async evaluate(orbital, request, scope) {
|
|
150
|
-
const guard = await this.lane.enter();
|
|
151
|
-
try {
|
|
152
|
-
const handle = this.handle;
|
|
153
|
-
let progress = decodeProgress(handle.start(orbital, JSON.stringify(request)));
|
|
154
|
-
while (progress.status === "await") {
|
|
155
|
-
const { flight, requests } = progress;
|
|
156
|
-
let replies;
|
|
157
|
-
guard.park(request.event);
|
|
158
|
-
try {
|
|
159
|
-
replies = await Promise.all(
|
|
160
|
-
requests.map(async (pending) => ({ id: pending.id, answer: await answerRequest(this.ports, pending.request, { ...scope, assertReentry: () => this.lane.assertCanReenter(guard.turn) }) }))
|
|
161
|
-
);
|
|
162
|
-
} catch (error) {
|
|
163
|
-
handle.abandon(flight);
|
|
164
|
-
throw error;
|
|
165
|
-
}
|
|
166
|
-
guard.resume();
|
|
167
|
-
progress = decodeProgress(handle.resume(flight, JSON.stringify(replies)));
|
|
168
|
-
}
|
|
169
|
-
if (scope.onStream !== void 0) {
|
|
170
|
-
const items = EventStreamItemSchema.array().parse(JSON.parse(handle.dispatchStream()));
|
|
171
|
-
for (const item of items) scope.onStream(item);
|
|
172
|
-
}
|
|
173
|
-
return progress.response;
|
|
174
|
-
} finally {
|
|
175
|
-
guard.release();
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
function kernelRequest(request, user, locale) {
|
|
180
|
-
const { _activeTraits: _dropped, _targetTrait: sidecarTarget, ...rest } = request.payload ?? {};
|
|
181
|
-
const payload = rest;
|
|
182
|
-
const target = request.targetTrait ?? (typeof sidecarTarget === "string" ? sidecarTarget : void 0);
|
|
183
|
-
const { payload: _payload, ...others } = request;
|
|
184
|
-
return {
|
|
185
|
-
...others,
|
|
186
|
-
...request.payload !== void 0 ? { payload } : {},
|
|
187
|
-
...target !== void 0 ? { targetTrait: target } : {},
|
|
188
|
-
...user !== void 0 ? { user } : {},
|
|
189
|
-
...locale !== void 0 ? { locale } : {}
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
function withOriginClient(response, clientId) {
|
|
193
|
-
if (clientId === void 0) return response;
|
|
194
|
-
return {
|
|
195
|
-
...response,
|
|
196
|
-
emittedEvents: response.emittedEvents.map((emitted) => emitted.source === void 0 ? emitted : { ...emitted, source: { ...emitted.source, originClientId: emitted.source.originClientId ?? clientId } })
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
async function evaluateOnKernel(kernel, request, user, locale) {
|
|
200
|
-
return withOriginClient(await kernel.engine.evaluate(kernel.orbital, kernelRequest(request, user, locale), {
|
|
201
|
-
orbital: kernel.orbital,
|
|
202
|
-
...user !== void 0 ? { user } : {},
|
|
203
|
-
...request.clientId !== void 0 ? { originClientId: request.clientId } : {},
|
|
204
|
-
...locale !== void 0 ? { locale } : {},
|
|
205
|
-
...request.entityId !== void 0 ? { entityId: request.entityId } : {},
|
|
206
|
-
...kernel.onStream !== void 0 ? { onStream: (item) => {
|
|
207
|
-
if (item.type === "event" && item.data.source !== void 0 && request.clientId !== void 0) {
|
|
208
|
-
kernel.onStream?.({ ...item, data: { ...item.data, source: { ...item.data.source, originClientId: item.data.source.originClientId ?? request.clientId } } });
|
|
209
|
-
} else if (item.type === "complete") {
|
|
210
|
-
kernel.onStream?.({ ...item, data: withOriginClient(item.data, request.clientId) });
|
|
211
|
-
} else kernel.onStream?.(item);
|
|
212
|
-
} } : {},
|
|
213
|
-
...kernel.outsideEventQueue !== void 0 ? { outsideEventQueue: kernel.outsideEventQueue } : {}
|
|
214
|
-
}), request.clientId);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
export { KernelEngine, evaluateOnKernel, kernelRequest };
|
package/dist/chunk-D5USD2EX.js
DELETED
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
import { createHttpTransport } from './chunk-QELZ6TEJ.js';
|
|
2
|
-
import { createLogger } from '@almadar/logger';
|
|
3
|
-
|
|
4
|
-
var log = createLogger("almadar:runtime:server-bridge");
|
|
5
|
-
var ServerBridge = class {
|
|
6
|
-
config;
|
|
7
|
-
state = {
|
|
8
|
-
connected: false,
|
|
9
|
-
eventsForwarded: 0,
|
|
10
|
-
eventsReceived: 0
|
|
11
|
-
};
|
|
12
|
-
unsubscribes = [];
|
|
13
|
-
pollTimer;
|
|
14
|
-
ws;
|
|
15
|
-
fetchFn;
|
|
16
|
-
/** The one HTTP request/response leg — shared with `@almadar/ui`'s transport (P5, EventTransport.ts). */
|
|
17
|
-
transport;
|
|
18
|
-
constructor(config) {
|
|
19
|
-
this.config = {
|
|
20
|
-
pollInterval: 5e3,
|
|
21
|
-
...config
|
|
22
|
-
};
|
|
23
|
-
this.fetchFn = config.fetch || fetch.bind(globalThis);
|
|
24
|
-
this.transport = createHttpTransport({ serverUrl: config.serverUrl, fetch: this.fetchFn });
|
|
25
|
-
}
|
|
26
|
-
// ==========================================================================
|
|
27
|
-
// Connection Management
|
|
28
|
-
// ==========================================================================
|
|
29
|
-
/**
|
|
30
|
-
* Connect the bridge - start forwarding events
|
|
31
|
-
*/
|
|
32
|
-
connect() {
|
|
33
|
-
if (this.state.connected) {
|
|
34
|
-
this.log("warn", "Already connected");
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
this.log("info", "Connecting bridge...");
|
|
38
|
-
this.setupEventForwarding();
|
|
39
|
-
if (this.config.useWebSocket) {
|
|
40
|
-
this.setupWebSocket();
|
|
41
|
-
} else if (this.config.pollInterval && this.config.pollInterval > 0) {
|
|
42
|
-
this.setupPolling();
|
|
43
|
-
}
|
|
44
|
-
this.state.connected = true;
|
|
45
|
-
this.log("info", "Bridge connected");
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Disconnect the bridge
|
|
49
|
-
*/
|
|
50
|
-
disconnect() {
|
|
51
|
-
for (const unsub of this.unsubscribes) {
|
|
52
|
-
unsub();
|
|
53
|
-
}
|
|
54
|
-
this.unsubscribes = [];
|
|
55
|
-
if (this.pollTimer) {
|
|
56
|
-
clearInterval(this.pollTimer);
|
|
57
|
-
this.pollTimer = void 0;
|
|
58
|
-
}
|
|
59
|
-
if (this.ws) {
|
|
60
|
-
this.ws.close();
|
|
61
|
-
this.ws = void 0;
|
|
62
|
-
}
|
|
63
|
-
this.state.connected = false;
|
|
64
|
-
this.log("info", "Bridge disconnected");
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Get current bridge state
|
|
68
|
-
*/
|
|
69
|
-
getState() {
|
|
70
|
-
return { ...this.state };
|
|
71
|
-
}
|
|
72
|
-
// ==========================================================================
|
|
73
|
-
// Event Forwarding (Client -> Server)
|
|
74
|
-
// ==========================================================================
|
|
75
|
-
setupEventForwarding() {
|
|
76
|
-
const { eventBus, forwardEvents, forwardPattern } = this.config;
|
|
77
|
-
if (forwardEvents && forwardEvents.length > 0) {
|
|
78
|
-
for (const eventType of forwardEvents) {
|
|
79
|
-
const unsub = eventBus.on(eventType, (event) => {
|
|
80
|
-
this.forwardToServer(event);
|
|
81
|
-
});
|
|
82
|
-
this.unsubscribes.push(unsub);
|
|
83
|
-
}
|
|
84
|
-
} else if (forwardPattern) {
|
|
85
|
-
if (forwardPattern === "*") {
|
|
86
|
-
const unsub = eventBus.on("*", (event) => {
|
|
87
|
-
if (!event.type.startsWith("UI:") && !event.type.startsWith("BRIDGE:")) {
|
|
88
|
-
this.forwardToServer(event);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
this.unsubscribes.push(unsub);
|
|
92
|
-
} else {
|
|
93
|
-
const prefix = forwardPattern.replace("*", "");
|
|
94
|
-
const unsub = eventBus.on("*", (event) => {
|
|
95
|
-
if (event.type.startsWith(prefix)) {
|
|
96
|
-
this.forwardToServer(event);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
this.unsubscribes.push(unsub);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
async forwardToServer(event) {
|
|
104
|
-
const { serverUrl, targetOrbital } = this.config;
|
|
105
|
-
try {
|
|
106
|
-
if (targetOrbital && targetOrbital !== "broadcast") {
|
|
107
|
-
await this.sendEventToOrbital(targetOrbital, event);
|
|
108
|
-
} else {
|
|
109
|
-
const orbitals = await this.fetchOrbitals();
|
|
110
|
-
for (const orbital of orbitals) {
|
|
111
|
-
await this.sendEventToOrbital(orbital.name, event);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
this.state.eventsForwarded++;
|
|
115
|
-
this.log("debug", `Forwarded event: ${event.type}`);
|
|
116
|
-
} catch (error) {
|
|
117
|
-
this.state.lastError = String(error);
|
|
118
|
-
this.log("error", `Failed to forward event: ${event.type}`, error instanceof Error ? error : String(error));
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
async sendEventToOrbital(orbitalName, event) {
|
|
122
|
-
const request = { event: event.type, payload: event.payload };
|
|
123
|
-
const result = await this.transport.send(orbitalName, request);
|
|
124
|
-
if (result.emittedEvents && result.emittedEvents.length > 0) {
|
|
125
|
-
for (const emitted of result.emittedEvents) {
|
|
126
|
-
this.config.eventBus.emit(`SERVER:${emitted.event}`, emitted.payload);
|
|
127
|
-
this.state.eventsReceived++;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
async fetchOrbitals() {
|
|
132
|
-
const response = await this.fetchFn(this.config.serverUrl);
|
|
133
|
-
if (!response.ok) {
|
|
134
|
-
throw new Error(`Failed to fetch orbitals: ${response.status}`);
|
|
135
|
-
}
|
|
136
|
-
const data = await response.json();
|
|
137
|
-
return data.orbitals || [];
|
|
138
|
-
}
|
|
139
|
-
// ==========================================================================
|
|
140
|
-
// Server -> Client (Polling)
|
|
141
|
-
// ==========================================================================
|
|
142
|
-
setupPolling() {
|
|
143
|
-
this.log("debug", "Polling mode - events received via forward response");
|
|
144
|
-
}
|
|
145
|
-
// ==========================================================================
|
|
146
|
-
// Server -> Client (WebSocket)
|
|
147
|
-
// ==========================================================================
|
|
148
|
-
setupWebSocket() {
|
|
149
|
-
const { serverUrl } = this.config;
|
|
150
|
-
const wsUrl = serverUrl.replace(/^http:/, "ws:").replace(/^https:/, "wss:").replace(/\/api\/orbitals$/, "/ws/orbitals");
|
|
151
|
-
try {
|
|
152
|
-
this.ws = new WebSocket(wsUrl);
|
|
153
|
-
this.ws.onopen = () => {
|
|
154
|
-
this.log("info", "WebSocket connected");
|
|
155
|
-
};
|
|
156
|
-
this.ws.onmessage = (msg) => {
|
|
157
|
-
try {
|
|
158
|
-
const data = JSON.parse(msg.data);
|
|
159
|
-
if (data.type === "event") {
|
|
160
|
-
this.config.eventBus.emit(`SERVER:${data.event}`, data.payload);
|
|
161
|
-
this.state.eventsReceived++;
|
|
162
|
-
this.log("debug", `Received server event: ${data.event}`);
|
|
163
|
-
}
|
|
164
|
-
} catch (error) {
|
|
165
|
-
this.log("error", "Failed to parse WebSocket message", error instanceof Error ? error : String(error));
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
this.ws.onerror = (error) => {
|
|
169
|
-
this.state.lastError = "WebSocket error";
|
|
170
|
-
this.log("error", "WebSocket error", error);
|
|
171
|
-
};
|
|
172
|
-
this.ws.onclose = () => {
|
|
173
|
-
this.log("info", "WebSocket closed");
|
|
174
|
-
};
|
|
175
|
-
} catch (error) {
|
|
176
|
-
this.log("error", "Failed to create WebSocket", error instanceof Error ? error : String(error));
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
// ==========================================================================
|
|
180
|
-
// Direct Methods
|
|
181
|
-
// ==========================================================================
|
|
182
|
-
/**
|
|
183
|
-
* Send an event directly to a specific orbital (bypassing EventBus)
|
|
184
|
-
*/
|
|
185
|
-
async sendEvent(orbitalName, event, payload) {
|
|
186
|
-
try {
|
|
187
|
-
const result = await this.transport.send(orbitalName, { event, payload });
|
|
188
|
-
return {
|
|
189
|
-
success: result.success,
|
|
190
|
-
states: result.states,
|
|
191
|
-
emittedEvents: result.emittedEvents,
|
|
192
|
-
error: result.error
|
|
193
|
-
};
|
|
194
|
-
} catch (error) {
|
|
195
|
-
return { success: false, error: String(error) };
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Get current state of an orbital's traits
|
|
200
|
-
*/
|
|
201
|
-
async getOrbitalState(orbitalName) {
|
|
202
|
-
const { serverUrl } = this.config;
|
|
203
|
-
const url = `${serverUrl}/${orbitalName}`;
|
|
204
|
-
try {
|
|
205
|
-
const response = await this.fetchFn(url);
|
|
206
|
-
const data = await response.json();
|
|
207
|
-
if (data.success && data.orbital) {
|
|
208
|
-
const states = {};
|
|
209
|
-
for (const trait of data.orbital.traits) {
|
|
210
|
-
states[trait.name] = trait.currentState;
|
|
211
|
-
}
|
|
212
|
-
return { success: true, states };
|
|
213
|
-
}
|
|
214
|
-
return { success: false, error: data.error };
|
|
215
|
-
} catch (error) {
|
|
216
|
-
return { success: false, error: String(error) };
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
// ==========================================================================
|
|
220
|
-
// Utilities
|
|
221
|
-
// ==========================================================================
|
|
222
|
-
log(level, message, data) {
|
|
223
|
-
if (!this.config.debug && level === "debug") return;
|
|
224
|
-
const meta = data === void 0 ? {} : data instanceof Error ? { error: data } : { detail: typeof data === "string" ? data : JSON.stringify(data) };
|
|
225
|
-
log[level](message, meta);
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
function createServerBridge(config) {
|
|
229
|
-
return new ServerBridge(config);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
export { ServerBridge, createServerBridge };
|
package/dist/chunk-EV56K4GB.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
// src/runtime/effects/composition/layout-strategy.ts
|
|
2
|
-
function hasSequentialChain(wiring) {
|
|
3
|
-
if (wiring.length < 2) {
|
|
4
|
-
return false;
|
|
5
|
-
}
|
|
6
|
-
const adjacency = /* @__PURE__ */ new Map();
|
|
7
|
-
const allTargets = /* @__PURE__ */ new Set();
|
|
8
|
-
for (const entry of wiring) {
|
|
9
|
-
let targets = adjacency.get(entry.from);
|
|
10
|
-
if (!targets) {
|
|
11
|
-
targets = /* @__PURE__ */ new Set();
|
|
12
|
-
adjacency.set(entry.from, targets);
|
|
13
|
-
}
|
|
14
|
-
targets.add(entry.to);
|
|
15
|
-
allTargets.add(entry.to);
|
|
16
|
-
}
|
|
17
|
-
const roots = [];
|
|
18
|
-
for (const from of adjacency.keys()) {
|
|
19
|
-
if (!allTargets.has(from)) {
|
|
20
|
-
roots.push(from);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
const starts = roots.length > 0 ? roots : [...adjacency.keys()];
|
|
24
|
-
for (const start of starts) {
|
|
25
|
-
let current = start;
|
|
26
|
-
let length = 1;
|
|
27
|
-
const visited = /* @__PURE__ */ new Set([current]);
|
|
28
|
-
while (true) {
|
|
29
|
-
const nexts = adjacency.get(current);
|
|
30
|
-
if (!nexts || nexts.size === 0) break;
|
|
31
|
-
let advanced = false;
|
|
32
|
-
for (const next of nexts) {
|
|
33
|
-
if (!visited.has(next)) {
|
|
34
|
-
visited.add(next);
|
|
35
|
-
current = next;
|
|
36
|
-
length++;
|
|
37
|
-
advanced = true;
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
if (!advanced) break;
|
|
42
|
-
}
|
|
43
|
-
if (length >= 3) {
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
function detectLayoutStrategy(orbitals, eventWiring) {
|
|
50
|
-
if (eventWiring && eventWiring.length > 0 && hasSequentialChain(eventWiring)) {
|
|
51
|
-
return "wizard-flow";
|
|
52
|
-
}
|
|
53
|
-
const count = orbitals.length;
|
|
54
|
-
if (count <= 1) {
|
|
55
|
-
return "single";
|
|
56
|
-
}
|
|
57
|
-
if (count <= 4) {
|
|
58
|
-
return "tabs";
|
|
59
|
-
}
|
|
60
|
-
return "sidebar";
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export { detectLayoutStrategy };
|
package/dist/chunk-FQ6IZMIU.js
DELETED
package/dist/chunk-HMK6YMQS.js
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { eventPayloadOf, isInlineTrait, normalizeCallSiteConfigToValues, JsonValueSchema, isJsonObject, EntityRowSchema, orbitalInlineEntities } from '@almadar/core';
|
|
2
|
-
import { ownerFieldsFromSchema } from '@almadar/core/mock';
|
|
3
|
-
|
|
4
|
-
// src/runtime/entities/std-mock-seed.ts
|
|
5
|
-
var SEED_ORBITAL = "MockSeedOrbital";
|
|
6
|
-
var SEED_TRAIT = "MockSeed";
|
|
7
|
-
function asJson(value) {
|
|
8
|
-
return JsonValueSchema.parse(JSON.parse(JSON.stringify(value)));
|
|
9
|
-
}
|
|
10
|
-
function fieldOf(value, name, what) {
|
|
11
|
-
if (value === void 0 || !isJsonObject(value)) throw new Error(`std-mock-seed: ${what} is not an object`);
|
|
12
|
-
const found = value[name];
|
|
13
|
-
if (found === void 0) throw new Error(`std-mock-seed: ${what} has no ${name}`);
|
|
14
|
-
return found;
|
|
15
|
-
}
|
|
16
|
-
function textOf(value, what) {
|
|
17
|
-
if (typeof value !== "string") throw new Error(`std-mock-seed: ${what} is not a string`);
|
|
18
|
-
return value;
|
|
19
|
-
}
|
|
20
|
-
function cellOf(value) {
|
|
21
|
-
return {
|
|
22
|
-
store: textOf(fieldOf(value, "store", "owner cell"), "cell store"),
|
|
23
|
-
id: textOf(fieldOf(value, "id", "owner cell"), "cell id"),
|
|
24
|
-
column: textOf(fieldOf(value, "column", "owner cell"), "cell column")
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
function cellsOf(value, what) {
|
|
28
|
-
if (!Array.isArray(value)) throw new Error(`std-mock-seed: ${what} is not an array`);
|
|
29
|
-
return value.map(cellOf);
|
|
30
|
-
}
|
|
31
|
-
function journalOf(value) {
|
|
32
|
-
return {
|
|
33
|
-
viewerId: textOf(fieldOf(value, "viewerId", "journal"), "journal viewerId"),
|
|
34
|
-
stamped: cellsOf(fieldOf(value, "stamped", "journal"), "journal stamped"),
|
|
35
|
-
deferred: cellsOf(fieldOf(value, "deferred", "journal"), "journal deferred")
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
function changeOf(value) {
|
|
39
|
-
const kind = fieldOf(value, "kind", "owner change");
|
|
40
|
-
if (kind !== "set" && kind !== "rekey") throw new Error("std-mock-seed: owner change kind is neither set nor rekey");
|
|
41
|
-
return { ...cellOf(value), kind, ownerId: textOf(fieldOf(value, "ownerId", "owner change"), "change ownerId") };
|
|
42
|
-
}
|
|
43
|
-
function storesOf(value) {
|
|
44
|
-
if (!isJsonObject(value)) throw new Error("std-mock-seed: dataset stores is not an object");
|
|
45
|
-
return Object.fromEntries(Object.entries(value).map(([store, rows]) => [store, EntityRowSchema.array().parse(rows)]));
|
|
46
|
-
}
|
|
47
|
-
function ownerPairsOf(schema) {
|
|
48
|
-
return ownerFieldsFromSchema(schema).map((field) => {
|
|
49
|
-
const dot = field.indexOf(".");
|
|
50
|
-
if (dot <= 0 || dot === field.length - 1) throw new Error(`std-mock-seed: owner field ${field} is not Entity.column`);
|
|
51
|
-
return { entity: field.slice(0, dot), column: field.slice(dot + 1) };
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
var StdMockSeed = class {
|
|
55
|
-
constructor(engine, config, user) {
|
|
56
|
-
this.engine = engine;
|
|
57
|
-
this.config = config;
|
|
58
|
-
this.user = user;
|
|
59
|
-
}
|
|
60
|
-
engine;
|
|
61
|
-
config;
|
|
62
|
-
user;
|
|
63
|
-
async ask(event, payload, done) {
|
|
64
|
-
const response = await this.engine.evaluate(
|
|
65
|
-
SEED_ORBITAL,
|
|
66
|
-
{ event, targetTrait: SEED_TRAIT, payload: eventPayloadOf(asJson(payload)) },
|
|
67
|
-
{ orbital: SEED_ORBITAL, ...this.user !== void 0 ? { user: this.user } : {} }
|
|
68
|
-
);
|
|
69
|
-
const failed = response.emittedEvents.find((emitted) => emitted.event === "DATASET_FAILED");
|
|
70
|
-
if (failed !== void 0) throw new Error(`std-mock-seed: ${event} refused: ${JSON.stringify(failed.payload ?? {})}`);
|
|
71
|
-
const answer = response.emittedEvents.find((emitted) => emitted.event === done);
|
|
72
|
-
if (answer === void 0) throw new Error(`std-mock-seed: ${event} did not answer ${done}`);
|
|
73
|
-
return asJson(answer.payload ?? {});
|
|
74
|
-
}
|
|
75
|
-
/** Sample the program's dataset (`DATASET_INPUT`). */
|
|
76
|
-
async dataset(program, run) {
|
|
77
|
-
const done = await this.ask("DATASET_INPUT", {
|
|
78
|
-
program,
|
|
79
|
-
count: this.config.count,
|
|
80
|
-
seed: this.config.seed,
|
|
81
|
-
nowMs: run.nowMs,
|
|
82
|
-
viewerId: run.viewerId ?? "",
|
|
83
|
-
ownerPairs: ownerPairsOf(program),
|
|
84
|
-
...run.locale !== void 0 ? { locale: run.locale } : {}
|
|
85
|
-
}, "DATASET_DONE");
|
|
86
|
-
return { stores: storesOf(fieldOf(done, "stores", "DATASET_DONE")), journal: journalOf(fieldOf(done, "journal", "DATASET_DONE")) };
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Re-point the dataset's tracked owner cells at `viewer` (`RESTAMP_INPUT`); `stores` are the current authoritative rows.
|
|
90
|
-
* `firstOwner` marks the stamp right after seeding; a persona switch restamps only when the program's
|
|
91
|
-
* `restampOnPersona` config says so, otherwise it answers no changes.
|
|
92
|
-
*/
|
|
93
|
-
async restamp(program, stores, journal, viewer, firstOwner) {
|
|
94
|
-
const done = await this.ask("RESTAMP_INPUT", { program, stores, journal, viewer, firstOwner, restampOnPersona: this.config.restampOnPersona }, "RESTAMP_DONE");
|
|
95
|
-
const changes = fieldOf(done, "changes", "RESTAMP_DONE");
|
|
96
|
-
if (!Array.isArray(changes)) throw new Error("std-mock-seed: RESTAMP_DONE changes is not an array");
|
|
97
|
-
return { journal: journalOf(fieldOf(done, "journal", "RESTAMP_DONE")), changes: changes.map(changeOf) };
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
var STD_MOCK_SEED_SOURCE = "std/behaviors/std-mock-seed";
|
|
101
|
-
var SEED_TRAIT_REF = "traits.MockSeed";
|
|
102
|
-
function declaredValue(values, key, is) {
|
|
103
|
-
const value = values[key];
|
|
104
|
-
if (value === void 0 || !is(value)) throw new Error(`std-mock-seed: config ${key} is not declared as expected`);
|
|
105
|
-
return value;
|
|
106
|
-
}
|
|
107
|
-
function declaredSeedConfig(seedProgram, app) {
|
|
108
|
-
const seedTrait = seedProgram.orbitals.flatMap((orbital) => orbital.traits ?? []).find((t) => isInlineTrait(t) && t.name === SEED_TRAIT);
|
|
109
|
-
if (seedTrait === void 0 || !isInlineTrait(seedTrait)) throw new Error(`std-mock-seed: the seed program has no ${SEED_TRAIT} trait`);
|
|
110
|
-
const composed = (app?.orbitals ?? []).flatMap((orbital) => {
|
|
111
|
-
const aliases = (orbital.uses ?? []).filter((u) => u.from === STD_MOCK_SEED_SOURCE).map((u) => u.as);
|
|
112
|
-
return (orbital.traits ?? []).flatMap((t) => typeof t !== "string" && !isInlineTrait(t) && aliases.some((alias) => t.ref === `${alias}.${SEED_TRAIT_REF}`) ? [normalizeCallSiteConfigToValues(t.config) ?? {}] : []);
|
|
113
|
-
});
|
|
114
|
-
const values = Object.assign({}, normalizeCallSiteConfigToValues(seedTrait.config) ?? {}, ...composed);
|
|
115
|
-
return {
|
|
116
|
-
count: declaredValue(values, "count", (v) => typeof v === "number"),
|
|
117
|
-
seed: declaredValue(values, "seed", (v) => typeof v === "number"),
|
|
118
|
-
defaultPersona: declaredValue(values, "defaultPersona", (v) => typeof v === "string"),
|
|
119
|
-
restampOnPersona: declaredValue(values, "restampOnPersona", (v) => typeof v === "boolean")
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
function entityByStore(program) {
|
|
123
|
-
const byStore = /* @__PURE__ */ new Map();
|
|
124
|
-
for (const entity of program.orbitals.flatMap(orbitalInlineEntities)) {
|
|
125
|
-
if (entity.collection !== void 0 && entity.collection !== "") byStore.set(entity.collection, entity.name);
|
|
126
|
-
}
|
|
127
|
-
return byStore;
|
|
128
|
-
}
|
|
129
|
-
async function readSeededStores(persistence, program) {
|
|
130
|
-
const stores = {};
|
|
131
|
-
for (const [store, entityType] of entityByStore(program)) stores[store] = await persistence.list(entityType);
|
|
132
|
-
return stores;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export { StdMockSeed, declaredSeedConfig, readSeededStores };
|