@nwire/forge 0.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/LICENSE +21 -0
- package/README.md +77 -0
- package/dist/__tests__/actor-methods.test.d.ts +9 -0
- package/dist/__tests__/actor-methods.test.d.ts.map +1 -0
- package/dist/__tests__/actor-methods.test.js +210 -0
- package/dist/__tests__/actor-methods.test.js.map +1 -0
- package/dist/__tests__/actor-schema-bound.test.d.ts +6 -0
- package/dist/__tests__/actor-schema-bound.test.d.ts.map +1 -0
- package/dist/__tests__/actor-schema-bound.test.js +112 -0
- package/dist/__tests__/actor-schema-bound.test.js.map +1 -0
- package/dist/__tests__/app-capabilities.test.d.ts +19 -0
- package/dist/__tests__/app-capabilities.test.d.ts.map +1 -0
- package/dist/__tests__/app-capabilities.test.js +57 -0
- package/dist/__tests__/app-capabilities.test.js.map +1 -0
- package/dist/__tests__/cli-runner.test.d.ts +6 -0
- package/dist/__tests__/cli-runner.test.d.ts.map +1 -0
- package/dist/__tests__/cli-runner.test.js +158 -0
- package/dist/__tests__/cli-runner.test.js.map +1 -0
- package/dist/__tests__/create-app.test.d.ts +18 -0
- package/dist/__tests__/create-app.test.d.ts.map +1 -0
- package/dist/__tests__/create-app.test.js +189 -0
- package/dist/__tests__/create-app.test.js.map +1 -0
- package/dist/__tests__/cross-service-bus.test.d.ts +8 -0
- package/dist/__tests__/cross-service-bus.test.d.ts.map +1 -0
- package/dist/__tests__/cross-service-bus.test.js +139 -0
- package/dist/__tests__/cross-service-bus.test.js.map +1 -0
- package/dist/__tests__/define-schema.test.d.ts +5 -0
- package/dist/__tests__/define-schema.test.d.ts.map +1 -0
- package/dist/__tests__/define-schema.test.js +83 -0
- package/dist/__tests__/define-schema.test.js.map +1 -0
- package/dist/__tests__/dev-logger.test.d.ts +9 -0
- package/dist/__tests__/dev-logger.test.d.ts.map +1 -0
- package/dist/__tests__/dev-logger.test.js +126 -0
- package/dist/__tests__/dev-logger.test.js.map +1 -0
- package/dist/__tests__/external-call.test.d.ts +14 -0
- package/dist/__tests__/external-call.test.d.ts.map +1 -0
- package/dist/__tests__/external-call.test.js +99 -0
- package/dist/__tests__/external-call.test.js.map +1 -0
- package/dist/__tests__/framework-events.test.d.ts +13 -0
- package/dist/__tests__/framework-events.test.d.ts.map +1 -0
- package/dist/__tests__/framework-events.test.js +204 -0
- package/dist/__tests__/framework-events.test.js.map +1 -0
- package/dist/__tests__/inline-handler.test.d.ts +8 -0
- package/dist/__tests__/inline-handler.test.d.ts.map +1 -0
- package/dist/__tests__/inline-handler.test.js +101 -0
- package/dist/__tests__/inline-handler.test.js.map +1 -0
- package/dist/__tests__/lifecycle-logging.test.d.ts +12 -0
- package/dist/__tests__/lifecycle-logging.test.d.ts.map +1 -0
- package/dist/__tests__/lifecycle-logging.test.js +112 -0
- package/dist/__tests__/lifecycle-logging.test.js.map +1 -0
- package/dist/__tests__/middleware.test.d.ts +7 -0
- package/dist/__tests__/middleware.test.d.ts.map +1 -0
- package/dist/__tests__/middleware.test.js +109 -0
- package/dist/__tests__/middleware.test.js.map +1 -0
- package/dist/__tests__/module-needs.test.d.ts +10 -0
- package/dist/__tests__/module-needs.test.d.ts.map +1 -0
- package/dist/__tests__/module-needs.test.js +77 -0
- package/dist/__tests__/module-needs.test.js.map +1 -0
- package/dist/__tests__/module-topo-sort.test.d.ts +15 -0
- package/dist/__tests__/module-topo-sort.test.d.ts.map +1 -0
- package/dist/__tests__/module-topo-sort.test.js +105 -0
- package/dist/__tests__/module-topo-sort.test.js.map +1 -0
- package/dist/__tests__/multi-tenancy.test.d.ts +10 -0
- package/dist/__tests__/multi-tenancy.test.d.ts.map +1 -0
- package/dist/__tests__/multi-tenancy.test.js +122 -0
- package/dist/__tests__/multi-tenancy.test.js.map +1 -0
- package/dist/__tests__/needs-topology.test.d.ts +11 -0
- package/dist/__tests__/needs-topology.test.d.ts.map +1 -0
- package/dist/__tests__/needs-topology.test.js +82 -0
- package/dist/__tests__/needs-topology.test.js.map +1 -0
- package/dist/__tests__/plugin-closure.test.d.ts +15 -0
- package/dist/__tests__/plugin-closure.test.d.ts.map +1 -0
- package/dist/__tests__/plugin-closure.test.js +140 -0
- package/dist/__tests__/plugin-closure.test.js.map +1 -0
- package/dist/__tests__/plugin.test.d.ts +10 -0
- package/dist/__tests__/plugin.test.d.ts.map +1 -0
- package/dist/__tests__/plugin.test.js +225 -0
- package/dist/__tests__/plugin.test.js.map +1 -0
- package/dist/__tests__/primitives.test.d.ts +9 -0
- package/dist/__tests__/primitives.test.d.ts.map +1 -0
- package/dist/__tests__/primitives.test.js +434 -0
- package/dist/__tests__/primitives.test.js.map +1 -0
- package/dist/__tests__/production-readiness.test.d.ts +22 -0
- package/dist/__tests__/production-readiness.test.d.ts.map +1 -0
- package/dist/__tests__/production-readiness.test.js +196 -0
- package/dist/__tests__/production-readiness.test.js.map +1 -0
- package/dist/__tests__/provider.test.d.ts +6 -0
- package/dist/__tests__/provider.test.d.ts.map +1 -0
- package/dist/__tests__/provider.test.js +122 -0
- package/dist/__tests__/provider.test.js.map +1 -0
- package/dist/__tests__/public-marker.test.d.ts +7 -0
- package/dist/__tests__/public-marker.test.d.ts.map +1 -0
- package/dist/__tests__/public-marker.test.js +54 -0
- package/dist/__tests__/public-marker.test.js.map +1 -0
- package/dist/__tests__/retry-dlq.test.d.ts +6 -0
- package/dist/__tests__/retry-dlq.test.d.ts.map +1 -0
- package/dist/__tests__/retry-dlq.test.js +68 -0
- package/dist/__tests__/retry-dlq.test.js.map +1 -0
- package/dist/__tests__/validate.test.d.ts +5 -0
- package/dist/__tests__/validate.test.d.ts.map +1 -0
- package/dist/__tests__/validate.test.js +53 -0
- package/dist/__tests__/validate.test.js.map +1 -0
- package/dist/__tests__/workflow-saga.test.d.ts +7 -0
- package/dist/__tests__/workflow-saga.test.d.ts.map +1 -0
- package/dist/__tests__/workflow-saga.test.js +239 -0
- package/dist/__tests__/workflow-saga.test.js.map +1 -0
- package/dist/actor-store.d.ts +83 -0
- package/dist/actor-store.d.ts.map +1 -0
- package/dist/actor-store.js +85 -0
- package/dist/actor-store.js.map +1 -0
- package/dist/cli-runner.d.ts +46 -0
- package/dist/cli-runner.d.ts.map +1 -0
- package/dist/cli-runner.js +164 -0
- package/dist/cli-runner.js.map +1 -0
- package/dist/create-app.d.ts +131 -0
- package/dist/create-app.d.ts.map +1 -0
- package/dist/create-app.js +593 -0
- package/dist/create-app.js.map +1 -0
- package/dist/define-action.d.ts +148 -0
- package/dist/define-action.d.ts.map +1 -0
- package/dist/define-action.js +52 -0
- package/dist/define-action.js.map +1 -0
- package/dist/define-actor.d.ts +302 -0
- package/dist/define-actor.d.ts.map +1 -0
- package/dist/define-actor.js +294 -0
- package/dist/define-actor.js.map +1 -0
- package/dist/define-app.d.ts +104 -0
- package/dist/define-app.d.ts.map +1 -0
- package/dist/define-app.js +49 -0
- package/dist/define-app.js.map +1 -0
- package/dist/define-cron.d.ts +50 -0
- package/dist/define-cron.d.ts.map +1 -0
- package/dist/define-cron.js +34 -0
- package/dist/define-cron.js.map +1 -0
- package/dist/define-error.d.ts +10 -0
- package/dist/define-error.d.ts.map +1 -0
- package/dist/define-error.js +10 -0
- package/dist/define-error.js.map +1 -0
- package/dist/define-external-call.d.ts +85 -0
- package/dist/define-external-call.d.ts.map +1 -0
- package/dist/define-external-call.js +38 -0
- package/dist/define-external-call.js.map +1 -0
- package/dist/define-handler.d.ts +98 -0
- package/dist/define-handler.d.ts.map +1 -0
- package/dist/define-handler.js +29 -0
- package/dist/define-handler.js.map +1 -0
- package/dist/define-inbound-webhook.d.ts +82 -0
- package/dist/define-inbound-webhook.d.ts.map +1 -0
- package/dist/define-inbound-webhook.js +42 -0
- package/dist/define-inbound-webhook.js.map +1 -0
- package/dist/define-inbox.d.ts +40 -0
- package/dist/define-inbox.d.ts.map +1 -0
- package/dist/define-inbox.js +31 -0
- package/dist/define-inbox.js.map +1 -0
- package/dist/define-initializer.d.ts +54 -0
- package/dist/define-initializer.d.ts.map +1 -0
- package/dist/define-initializer.js +38 -0
- package/dist/define-initializer.js.map +1 -0
- package/dist/define-middleware.d.ts +8 -0
- package/dist/define-middleware.d.ts.map +1 -0
- package/dist/define-middleware.js +8 -0
- package/dist/define-middleware.js.map +1 -0
- package/dist/define-model.d.ts +10 -0
- package/dist/define-model.d.ts.map +1 -0
- package/dist/define-model.js +13 -0
- package/dist/define-model.js.map +1 -0
- package/dist/define-module.d.ts +157 -0
- package/dist/define-module.d.ts.map +1 -0
- package/dist/define-module.js +60 -0
- package/dist/define-module.js.map +1 -0
- package/dist/define-outbox.d.ts +47 -0
- package/dist/define-outbox.d.ts.map +1 -0
- package/dist/define-outbox.js +36 -0
- package/dist/define-outbox.js.map +1 -0
- package/dist/define-plugin.d.ts +171 -0
- package/dist/define-plugin.d.ts.map +1 -0
- package/dist/define-plugin.js +134 -0
- package/dist/define-plugin.js.map +1 -0
- package/dist/define-projection.d.ts +56 -0
- package/dist/define-projection.d.ts.map +1 -0
- package/dist/define-projection.js +44 -0
- package/dist/define-projection.js.map +1 -0
- package/dist/define-provider.d.ts +49 -0
- package/dist/define-provider.d.ts.map +1 -0
- package/dist/define-provider.js +45 -0
- package/dist/define-provider.js.map +1 -0
- package/dist/define-query.d.ts +50 -0
- package/dist/define-query.d.ts.map +1 -0
- package/dist/define-query.js +33 -0
- package/dist/define-query.js.map +1 -0
- package/dist/define-resolver.d.ts +111 -0
- package/dist/define-resolver.d.ts.map +1 -0
- package/dist/define-resolver.js +146 -0
- package/dist/define-resolver.js.map +1 -0
- package/dist/define-schema.d.ts +88 -0
- package/dist/define-schema.d.ts.map +1 -0
- package/dist/define-schema.js +72 -0
- package/dist/define-schema.js.map +1 -0
- package/dist/define-workflow.d.ts +193 -0
- package/dist/define-workflow.d.ts.map +1 -0
- package/dist/define-workflow.js +345 -0
- package/dist/define-workflow.js.map +1 -0
- package/dist/dev-logger.d.ts +41 -0
- package/dist/dev-logger.d.ts.map +1 -0
- package/dist/dev-logger.js +135 -0
- package/dist/dev-logger.js.map +1 -0
- package/dist/event-message.d.ts +37 -0
- package/dist/event-message.d.ts.map +1 -0
- package/dist/event-message.js +51 -0
- package/dist/event-message.js.map +1 -0
- package/dist/foundation.d.ts +14 -0
- package/dist/foundation.d.ts.map +1 -0
- package/dist/foundation.js +14 -0
- package/dist/foundation.js.map +1 -0
- package/dist/framework-event-bus.d.ts +13 -0
- package/dist/framework-event-bus.d.ts.map +1 -0
- package/dist/framework-event-bus.js +13 -0
- package/dist/framework-event-bus.js.map +1 -0
- package/dist/framework-events.d.ts +121 -0
- package/dist/framework-events.d.ts.map +1 -0
- package/dist/framework-events.js +67 -0
- package/dist/framework-events.js.map +1 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +61 -0
- package/dist/index.js.map +1 -0
- package/dist/module-surface.d.ts +47 -0
- package/dist/module-surface.d.ts.map +1 -0
- package/dist/module-surface.js +65 -0
- package/dist/module-surface.js.map +1 -0
- package/dist/projection-store.d.ts +26 -0
- package/dist/projection-store.d.ts.map +1 -0
- package/dist/projection-store.js +28 -0
- package/dist/projection-store.js.map +1 -0
- package/dist/public-marker.d.ts +35 -0
- package/dist/public-marker.d.ts.map +1 -0
- package/dist/public-marker.js +45 -0
- package/dist/public-marker.js.map +1 -0
- package/dist/response.d.ts +8 -0
- package/dist/response.d.ts.map +1 -0
- package/dist/response.js +8 -0
- package/dist/response.js.map +1 -0
- package/dist/runtime.d.ts +497 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1083 -0
- package/dist/runtime.js.map +1 -0
- package/dist/validate.d.ts +33 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +48 -0
- package/dist/validate.js.map +1 -0
- package/dist/when.d.ts +101 -0
- package/dist/when.d.ts.map +1 -0
- package/dist/when.js +57 -0
- package/dist/when.js.map +1 -0
- package/dist/workflow-timer-store.d.ts +78 -0
- package/dist/workflow-timer-store.d.ts.map +1 -0
- package/dist/workflow-timer-store.js +56 -0
- package/dist/workflow-timer-store.js.map +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1,593 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `createApp` — declarative app composition.
|
|
3
|
+
*
|
|
4
|
+
* const app = createApp({
|
|
5
|
+
* modules: [submissions, enrollments],
|
|
6
|
+
* actorStore: new InMemoryActorStore(),
|
|
7
|
+
* projectionStore: new InMemoryProjectionStore()
|
|
8
|
+
* })
|
|
9
|
+
* await app.start()
|
|
10
|
+
*
|
|
11
|
+
* `createApp` walks each module's manifest and registers actions, actors,
|
|
12
|
+
* handlers, projections, queries, and workflows into a fresh `Runtime`.
|
|
13
|
+
* The runtime is exposed for transports (HTTP, queue, cron) to bind to.
|
|
14
|
+
*
|
|
15
|
+
* Transports are NOT bundled here yet — for now, wires hand-attach Koa
|
|
16
|
+
* routers using `createDispatchHttp(app)`. Full `expose: [http(...), worker(...)]`
|
|
17
|
+
* shape lands when the second wire (queue worker) needs it.
|
|
18
|
+
*
|
|
19
|
+
* Lifecycle:
|
|
20
|
+
* - `start()` — currently a no-op (registration happens at construction).
|
|
21
|
+
* Becomes meaningful when transports + timer scheduler join the surface.
|
|
22
|
+
* - `stop()` — drains pending work; reserved.
|
|
23
|
+
* - `runtime` — escape hatch for transports and tests.
|
|
24
|
+
*/
|
|
25
|
+
import { rootContainer } from "@nwire/container";
|
|
26
|
+
import { seedEnvelope } from "@nwire/envelope";
|
|
27
|
+
import { Runtime } from "./runtime.js";
|
|
28
|
+
import { buildPluginContext } from "./define-plugin.js";
|
|
29
|
+
import { AppRegistering, AppBooting, AppBooted, AppShuttingDown, AppShutdown, PluginRegistered, PluginBooting, PluginBooted, PluginShuttingDown, PluginShutdown, builtInLifecycleEvents, } from "./framework-events.js";
|
|
30
|
+
export function createApp(options) {
|
|
31
|
+
// Index local provides up-front — both validators and the bus-subscription
|
|
32
|
+
// loop need to know "is this event satisfiable locally in this app?"
|
|
33
|
+
const localEventProviders = indexLocalEventProviders(options.modules);
|
|
34
|
+
const localActionProviders = indexLocalActionProviders(options.modules);
|
|
35
|
+
validateModuleDepGraph(options.modules, localEventProviders, localActionProviders, !!options.bus);
|
|
36
|
+
validateExternalEventDeps(options.modules, localEventProviders, !!options.bus);
|
|
37
|
+
/**
|
|
38
|
+
* Sort modules topologically by `needs.events / needs.actions`.
|
|
39
|
+
* Producers register before consumers. Registration is order-independent
|
|
40
|
+
* for correctness today (every reference resolves through the runtime's
|
|
41
|
+
* registries which are populated up-front), but the order DOES affect:
|
|
42
|
+
*
|
|
43
|
+
* - Studio's render order (modules appear in dep order, not source order)
|
|
44
|
+
* - Telemetry: PluginRegistered events fire in topological order
|
|
45
|
+
* - Future module-as-plugin work: if defineModule ever produces a
|
|
46
|
+
* plugin with its own boot phase, the order will become load-bearing.
|
|
47
|
+
*
|
|
48
|
+
* Topo failures (cycles, unknown refs) throw at boot with a readable
|
|
49
|
+
* trace — same error class as validateModuleDepGraph so the cause is
|
|
50
|
+
* surfaced before any traffic.
|
|
51
|
+
*/
|
|
52
|
+
const orderedModules = topoSortModules(options.modules, localEventProviders, localActionProviders);
|
|
53
|
+
const runtime = new Runtime({
|
|
54
|
+
container: options.container ?? rootContainer,
|
|
55
|
+
actorStore: options.actorStore,
|
|
56
|
+
projectionStore: options.projectionStore,
|
|
57
|
+
logger: options.logger,
|
|
58
|
+
deadLetterSink: options.deadLetterSink,
|
|
59
|
+
bus: options.bus,
|
|
60
|
+
publishToBus: options.publishToBus,
|
|
61
|
+
appName: options.appName,
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* Register app capabilities on the container so handlers in any
|
|
65
|
+
* transport (HTTP / queue / CLI) can `ctx.resolve("execute")` etc.
|
|
66
|
+
* Each call seeds a fresh envelope — transports running outside an
|
|
67
|
+
* existing dispatch chain don't have one to inherit. For HTTP that's
|
|
68
|
+
* exactly right: each request is its own causal root.
|
|
69
|
+
*/
|
|
70
|
+
const containerForCaps = options.container ?? rootContainer;
|
|
71
|
+
containerForCaps.register("execute", () => {
|
|
72
|
+
return async function execute(action, input) {
|
|
73
|
+
return await runtime.dispatch(action, input, seedEnvelope({}));
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
containerForCaps.register("send", () => {
|
|
77
|
+
return async function send(action, input) {
|
|
78
|
+
// Fire-and-forget — same envelope-per-call story as `execute`.
|
|
79
|
+
await runtime.dispatch(action, input, seedEnvelope({}));
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
containerForCaps.register("useProjection", () => {
|
|
83
|
+
return async function useProjection(
|
|
84
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
85
|
+
queryDef, input) {
|
|
86
|
+
return runtime.query(queryDef.name, input, "");
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
let timerInterval = null;
|
|
90
|
+
/** Subscription handle from attachDevLogger — called in stop() to detach. */
|
|
91
|
+
let detachDevLogger = null;
|
|
92
|
+
/** Subscribe the bus for an external event name once (dedup across modules). */
|
|
93
|
+
const subscribedExternal = new Set();
|
|
94
|
+
const subscribeExternal = (eventName) => {
|
|
95
|
+
if (subscribedExternal.has(eventName))
|
|
96
|
+
return;
|
|
97
|
+
subscribedExternal.add(eventName);
|
|
98
|
+
runtime.registerExternalEvent(eventName);
|
|
99
|
+
if (!options.bus)
|
|
100
|
+
return; // validators ensured this won't happen
|
|
101
|
+
options.bus.subscribe(eventName, async (msg) => {
|
|
102
|
+
if (msg.origin && options.appName && msg.origin === options.appName)
|
|
103
|
+
return;
|
|
104
|
+
await runtime.applyExternalEvent(eventName, msg.payload, msg.envelope);
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
for (const module of orderedModules) {
|
|
108
|
+
const m = module.manifest;
|
|
109
|
+
for (const actor of m.actors ?? [])
|
|
110
|
+
runtime.registerActor(actor);
|
|
111
|
+
for (const handler of m.handlers ?? [])
|
|
112
|
+
runtime.registerHandler(handler);
|
|
113
|
+
// Inline handlers — `defineAction({..., handler})` attaches a synthesized
|
|
114
|
+
// HandlerDefinition to the action. Register here so authors can pick
|
|
115
|
+
// either form (inline action+handler OR separate defineHandler) without
|
|
116
|
+
// a module-manifest change.
|
|
117
|
+
for (const action of m.actions ?? []) {
|
|
118
|
+
if (action.handler)
|
|
119
|
+
runtime.registerHandler(action.handler);
|
|
120
|
+
}
|
|
121
|
+
for (const projection of m.projections ?? [])
|
|
122
|
+
runtime.registerProjection(projection);
|
|
123
|
+
for (const query of m.queries ?? [])
|
|
124
|
+
runtime.registerQuery(query);
|
|
125
|
+
for (const workflow of m.workflows ?? []) {
|
|
126
|
+
runtime.registerWorkflow(workflow);
|
|
127
|
+
}
|
|
128
|
+
// Orchestrator primitives — Studio sees them, runtime registers the
|
|
129
|
+
// call definitions for executor binding by wires/adapters.
|
|
130
|
+
for (const call of m.externalCalls ?? []) {
|
|
131
|
+
runtime.registerExternalCall(call);
|
|
132
|
+
}
|
|
133
|
+
// Track public-event names so the runtime knows which to bus-publish.
|
|
134
|
+
for (const e of m.events ?? []) {
|
|
135
|
+
if ((e.visibility ?? "public") === "public") {
|
|
136
|
+
runtime.registerPublicEvent(e.name);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
// For each declared event need: if a producer lives in THIS app,
|
|
140
|
+
// do nothing (the in-process publish pipeline handles it). If not,
|
|
141
|
+
// and a bus is configured, auto-subscribe — the same declaration
|
|
142
|
+
// works in monolith and split topologies.
|
|
143
|
+
for (const e of m.needs?.events ?? []) {
|
|
144
|
+
if (!localEventProviders.has(e.name)) {
|
|
145
|
+
subscribeExternal(e.name);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
// `externalEvents` is the strict-marker form — requires NON-local.
|
|
149
|
+
// The validator enforces that; here we just auto-wire.
|
|
150
|
+
for (const e of m.needs?.externalEvents ?? []) {
|
|
151
|
+
subscribeExternal(e.name);
|
|
152
|
+
}
|
|
153
|
+
// Routes are bound by transports, not by the runtime.
|
|
154
|
+
}
|
|
155
|
+
const container = options.container ?? rootContainer;
|
|
156
|
+
/** Booted provider values, indexed by provider name. Populated in start(). */
|
|
157
|
+
// Plugins: register synchronously up-front (before async boot) so they
|
|
158
|
+
// can declare container values + framework subscriptions + middleware
|
|
159
|
+
// before the first dispatch.
|
|
160
|
+
//
|
|
161
|
+
// The closure form's `setup` runs here too; its `boot`/`shutdown`
|
|
162
|
+
// builder calls accumulate into per-plugin lists that get fired in
|
|
163
|
+
// order during start() / stop().
|
|
164
|
+
/**
|
|
165
|
+
* Per-plugin closure-form boots, keyed by plugin index. Keeping the
|
|
166
|
+
* association lets the start() loop wrap each plugin with its own
|
|
167
|
+
* PluginBooting/PluginBooted framework events (rather than firing one
|
|
168
|
+
* "everyone's boots fired" event for the collapsed list).
|
|
169
|
+
*/
|
|
170
|
+
const closureBoots = new Map();
|
|
171
|
+
/** Keyed by plugin index so we can fire reverse on stop in-order. */
|
|
172
|
+
const closureShutdowns = new Map();
|
|
173
|
+
let pluginIdx = 0;
|
|
174
|
+
for (const plugin of options.plugins ?? []) {
|
|
175
|
+
if (plugin.register)
|
|
176
|
+
plugin.register(container);
|
|
177
|
+
if (plugin.setup) {
|
|
178
|
+
const { api, boots, shutdowns } = buildPluginContext(container, runtime, options.config ?? {});
|
|
179
|
+
// The setup function may be async; we kick it off and await its
|
|
180
|
+
// promise so the closure can use top-level `await` if it wants.
|
|
181
|
+
const result = plugin.setup(api);
|
|
182
|
+
if (result instanceof Promise) {
|
|
183
|
+
// Top-level register loop is sync; we can't await here without
|
|
184
|
+
// restructuring createApp. Surface the requirement explicitly.
|
|
185
|
+
throw new Error(`definePlugin("${plugin.name}"): closure form must be synchronous. ` +
|
|
186
|
+
`Use the api.boot(...) builder for async startup work.`);
|
|
187
|
+
}
|
|
188
|
+
closureBoots.set(pluginIdx, boots);
|
|
189
|
+
closureShutdowns.set(pluginIdx, shutdowns);
|
|
190
|
+
}
|
|
191
|
+
for (const mw of plugin.middleware ?? [])
|
|
192
|
+
runtime.use(mw);
|
|
193
|
+
if (plugin.actorHooks?.afterTransition) {
|
|
194
|
+
runtime.registerActorTransitionHook(plugin.actorHooks.afterTransition);
|
|
195
|
+
}
|
|
196
|
+
pluginIdx++;
|
|
197
|
+
}
|
|
198
|
+
// Name → definition map for `dispatchFrameworkEvent`. Built once from
|
|
199
|
+
// the built-in lifecycle catalog; endpoint passes event NAMES (strings)
|
|
200
|
+
// so it stays decoupled from `@nwire/app`'s typed event definitions.
|
|
201
|
+
const lifecycleEventsByName = new Map();
|
|
202
|
+
for (const def of builtInLifecycleEvents) {
|
|
203
|
+
lifecycleEventsByName.set(def.name, def);
|
|
204
|
+
}
|
|
205
|
+
const app = {
|
|
206
|
+
$nwireApp: true,
|
|
207
|
+
runtime,
|
|
208
|
+
modules: options.modules,
|
|
209
|
+
container,
|
|
210
|
+
get appName() {
|
|
211
|
+
return runtime.appName;
|
|
212
|
+
},
|
|
213
|
+
async dispatchFrameworkEvent(eventName, payload) {
|
|
214
|
+
const def = lifecycleEventsByName.get(eventName);
|
|
215
|
+
if (!def) {
|
|
216
|
+
// Unknown event — silently no-op. The endpoint may send events
|
|
217
|
+
// a future framework version defines; an older app shouldn't
|
|
218
|
+
// crash on receipt. Returning `true` matches "nothing
|
|
219
|
+
// prevented" semantics.
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
return runtime.frameworkEvents.fire(def, payload);
|
|
223
|
+
},
|
|
224
|
+
async boot() {
|
|
225
|
+
return this.start();
|
|
226
|
+
},
|
|
227
|
+
async shutdown() {
|
|
228
|
+
return this.stop();
|
|
229
|
+
},
|
|
230
|
+
async start() {
|
|
231
|
+
const appName = runtime.appName;
|
|
232
|
+
// Announce each plugin BEFORE any framework lifecycle fires. Lets
|
|
233
|
+
// observers (dev logger, Studio) print the app's composition before
|
|
234
|
+
// boot starts so "what's this app made of?" is answerable at first
|
|
235
|
+
// log line.
|
|
236
|
+
for (const plugin of options.plugins ?? []) {
|
|
237
|
+
await runtime.frameworkEvents.fire(PluginRegistered, {
|
|
238
|
+
appName,
|
|
239
|
+
pluginName: plugin.name,
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
// Framework event: AppRegistering — interceptable. Plugins that
|
|
243
|
+
// subscribed during their `register` hook can refuse boot here.
|
|
244
|
+
const registeringOk = await runtime.frameworkEvents.fire(AppRegistering, { appName });
|
|
245
|
+
if (!registeringOk) {
|
|
246
|
+
throw new Error(`Boot prevented by AppRegistering subscriber (app: ${appName})`);
|
|
247
|
+
}
|
|
248
|
+
// Framework event: AppBooting — interceptable. Fired after the sync
|
|
249
|
+
// plugin-register phase has populated the container, before any
|
|
250
|
+
// async plugin boot runs.
|
|
251
|
+
const bootingOk = await runtime.frameworkEvents.fire(AppBooting, { appName });
|
|
252
|
+
if (!bootingOk) {
|
|
253
|
+
throw new Error(`Boot prevented by AppBooting subscriber (app: ${appName})`);
|
|
254
|
+
}
|
|
255
|
+
// Plugins boot in declaration order. Each plugin is wrapped with
|
|
256
|
+
// PluginBooting (interceptable) + PluginBooted (observable, with
|
|
257
|
+
// duration) so logging/tracing/Studio can show per-plugin boot
|
|
258
|
+
// timing.
|
|
259
|
+
//
|
|
260
|
+
// Object-form plugins run their `boot` callback; closure-form
|
|
261
|
+
// plugins additionally fire every `api.boot(...)` they registered
|
|
262
|
+
// in setup, in declaration order.
|
|
263
|
+
const allPlugins = options.plugins ?? [];
|
|
264
|
+
for (let i = 0; i < allPlugins.length; i++) {
|
|
265
|
+
const plugin = allPlugins[i];
|
|
266
|
+
const pluginName = plugin.name;
|
|
267
|
+
const okToBoot = await runtime.frameworkEvents.fire(PluginBooting, {
|
|
268
|
+
appName,
|
|
269
|
+
pluginName,
|
|
270
|
+
});
|
|
271
|
+
if (!okToBoot) {
|
|
272
|
+
throw new Error(`Boot of plugin "${pluginName}" prevented by PluginBooting subscriber`);
|
|
273
|
+
}
|
|
274
|
+
const startedAt = Date.now();
|
|
275
|
+
if (plugin.boot)
|
|
276
|
+
await plugin.boot(container);
|
|
277
|
+
const boots = closureBoots.get(i);
|
|
278
|
+
if (boots) {
|
|
279
|
+
for (const fn of boots)
|
|
280
|
+
await fn();
|
|
281
|
+
}
|
|
282
|
+
await runtime.frameworkEvents.fire(PluginBooted, {
|
|
283
|
+
appName,
|
|
284
|
+
pluginName,
|
|
285
|
+
durationMs: Date.now() - startedAt,
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
// Default dev console logger. Off when:
|
|
289
|
+
// - `devLogs: false` is explicit
|
|
290
|
+
// - NODE_ENV=production (assume structured logger is configured)
|
|
291
|
+
// - NODE_ENV=test (vitest output stays clean)
|
|
292
|
+
// - a `logger` (pino/winston) is provided (structured wins)
|
|
293
|
+
const devLogsOpt = options.devLogs;
|
|
294
|
+
const env = process.env.NODE_ENV;
|
|
295
|
+
const wantDevLogs = devLogsOpt === undefined
|
|
296
|
+
? env !== "production" && env !== "test" && !options.logger
|
|
297
|
+
: devLogsOpt !== false;
|
|
298
|
+
if (wantDevLogs) {
|
|
299
|
+
const { attachDevLogger } = await import("./dev-logger.js");
|
|
300
|
+
detachDevLogger = attachDevLogger(runtime, typeof devLogsOpt === "object" ? devLogsOpt : undefined);
|
|
301
|
+
}
|
|
302
|
+
// Framework event: AppBooted — observable. Awaited (parallel under
|
|
303
|
+
// the hood) so start() returns only after every observer had a fair
|
|
304
|
+
// window; useful for diagnostics that want to flush before serving.
|
|
305
|
+
await runtime.frameworkEvents.fire(AppBooted, {
|
|
306
|
+
appName,
|
|
307
|
+
bootedAt: new Date().toISOString(),
|
|
308
|
+
});
|
|
309
|
+
if (options.timerScheduler) {
|
|
310
|
+
const intervalMs = typeof options.timerScheduler === "object"
|
|
311
|
+
? (options.timerScheduler.intervalMs ?? 60_000)
|
|
312
|
+
: 60_000;
|
|
313
|
+
timerInterval = setInterval(() => {
|
|
314
|
+
void runtime.fireDueTimers().catch(() => {
|
|
315
|
+
// Swallow per-tick errors so a single bad timer doesn't
|
|
316
|
+
// halt the scheduler. Production wires should plug in
|
|
317
|
+
// a logger here.
|
|
318
|
+
});
|
|
319
|
+
}, intervalMs);
|
|
320
|
+
// Don't keep the process alive solely on the timer interval —
|
|
321
|
+
// the wire's HTTP server is the foreground process.
|
|
322
|
+
if (typeof timerInterval.unref === "function") {
|
|
323
|
+
timerInterval.unref();
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
async stop(reason) {
|
|
328
|
+
const appName = runtime.appName;
|
|
329
|
+
// Framework event: AppShuttingDown — interceptable. Subscribers
|
|
330
|
+
// throwing here propagate as a failed shutdown; returning false
|
|
331
|
+
// cleanly aborts (the wire can decide to retry or hard-kill).
|
|
332
|
+
const shutdownOk = await runtime.frameworkEvents.fire(AppShuttingDown, {
|
|
333
|
+
appName,
|
|
334
|
+
reason,
|
|
335
|
+
});
|
|
336
|
+
if (!shutdownOk) {
|
|
337
|
+
throw new Error(`Shutdown prevented by AppShuttingDown subscriber (app: ${appName})`);
|
|
338
|
+
}
|
|
339
|
+
if (timerInterval) {
|
|
340
|
+
clearInterval(timerInterval);
|
|
341
|
+
timerInterval = null;
|
|
342
|
+
}
|
|
343
|
+
if (detachDevLogger) {
|
|
344
|
+
detachDevLogger();
|
|
345
|
+
detachDevLogger = null;
|
|
346
|
+
}
|
|
347
|
+
// Plugins shut down in REVERSE declaration order. For each
|
|
348
|
+
// closure-form plugin, fire every `api.shutdown(...)` it registered
|
|
349
|
+
// — also in reverse, so dependencies declared late tear down first.
|
|
350
|
+
//
|
|
351
|
+
// Shutdown error isolation: a plugin's shutdown that throws MUST
|
|
352
|
+
// NOT block subsequent plugins from running. A buggy plugin leaving
|
|
353
|
+
// resources leaked is bad; that same bug also skipping every
|
|
354
|
+
// downstream plugin's cleanup would compound the outage. Each
|
|
355
|
+
// shutdown step is wrapped + logged; we collect errors and re-throw
|
|
356
|
+
// the first one only AFTER the full sweep completes.
|
|
357
|
+
//
|
|
358
|
+
// Two contracts, both important:
|
|
359
|
+
// (a) A single bad shutdown must NOT block subsequent plugins from
|
|
360
|
+
// cleaning up. (production-readiness)
|
|
361
|
+
// (b) Wires must still be able to detect shutdown failure so
|
|
362
|
+
// SIGTERM → stop() → exit can surface the problem.
|
|
363
|
+
// Resolution: collect errors during the sweep, complete every step,
|
|
364
|
+
// then re-throw the first error AFTER the full sweep finishes.
|
|
365
|
+
const shutdownErrors = [];
|
|
366
|
+
const safeRun = async (label, fn) => {
|
|
367
|
+
try {
|
|
368
|
+
await fn();
|
|
369
|
+
}
|
|
370
|
+
catch (err) {
|
|
371
|
+
shutdownErrors.push(err);
|
|
372
|
+
// eslint-disable-next-line no-console
|
|
373
|
+
console.error(`[nwire/shutdown] step "${label}" threw — continuing with remaining steps:`, err);
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
const plugins = options.plugins ?? [];
|
|
377
|
+
for (let i = plugins.length - 1; i >= 0; i--) {
|
|
378
|
+
const plugin = plugins[i];
|
|
379
|
+
const pluginName = plugin.name;
|
|
380
|
+
// PluginShuttingDown is interceptable, but a refusal at shutdown
|
|
381
|
+
// is harder to honor cleanly — the app is on its way out and the
|
|
382
|
+
// host (lightship) may force-kill us regardless. Honor the signal
|
|
383
|
+
// by logging + skipping this plugin's teardown, NOT by throwing,
|
|
384
|
+
// so downstream plugins still get a chance to clean up.
|
|
385
|
+
const shutdownOkPerPlugin = await runtime.frameworkEvents.fire(PluginShuttingDown, {
|
|
386
|
+
appName,
|
|
387
|
+
pluginName,
|
|
388
|
+
});
|
|
389
|
+
if (!shutdownOkPerPlugin) {
|
|
390
|
+
// eslint-disable-next-line no-console
|
|
391
|
+
console.warn(`[nwire/shutdown] PluginShuttingDown subscriber refused — skipping plugin "${pluginName}"`);
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
const startedAt = Date.now();
|
|
395
|
+
if (plugin.shutdown)
|
|
396
|
+
await safeRun(`plugin:${pluginName}`, () => plugin.shutdown(container));
|
|
397
|
+
const shutdowns = closureShutdowns.get(i);
|
|
398
|
+
if (shutdowns) {
|
|
399
|
+
for (let j = shutdowns.length - 1; j >= 0; j--) {
|
|
400
|
+
await safeRun(`plugin:${pluginName}:closure[${j}]`, () => shutdowns[j]());
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
await runtime.frameworkEvents.fire(PluginShutdown, {
|
|
404
|
+
appName,
|
|
405
|
+
pluginName,
|
|
406
|
+
durationMs: Date.now() - startedAt,
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
// Framework event: AppShutdown — observable. Awaited so stop()
|
|
410
|
+
// doesn't return until subscribers had a fair window.
|
|
411
|
+
await runtime.frameworkEvents.fire(AppShutdown, { appName });
|
|
412
|
+
// Surface the first shutdown error (if any) AFTER every other step
|
|
413
|
+
// has run. Wires (and tests) that need to know shutdown failed will
|
|
414
|
+
// see the throw; meanwhile, downstream plugins still got cleaned up.
|
|
415
|
+
if (shutdownErrors.length > 0) {
|
|
416
|
+
throw shutdownErrors[0];
|
|
417
|
+
}
|
|
418
|
+
},
|
|
419
|
+
};
|
|
420
|
+
return app;
|
|
421
|
+
}
|
|
422
|
+
function indexLocalEventProviders(modules) {
|
|
423
|
+
const map = new Map();
|
|
424
|
+
for (const mod of modules) {
|
|
425
|
+
for (const e of mod.manifest.events ?? []) {
|
|
426
|
+
// Visibility: the `.public()` marker in the module manifest is the
|
|
427
|
+
// canonical signal. The older `visibility: "public" | "internal"`
|
|
428
|
+
// field on the event definition is still honored for back-compat
|
|
429
|
+
// until every example migrates to `.public()`.
|
|
430
|
+
const markedPublic = mod.publicSurface.events.has(e.name);
|
|
431
|
+
const declared = e.visibility;
|
|
432
|
+
const visibility = markedPublic ? "public" : (declared ?? "internal");
|
|
433
|
+
map.set(e.name, { module: mod.name, visibility });
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
return map;
|
|
437
|
+
}
|
|
438
|
+
function indexLocalActionProviders(modules) {
|
|
439
|
+
const map = new Map();
|
|
440
|
+
for (const mod of modules) {
|
|
441
|
+
for (const a of mod.manifest.actions ?? []) {
|
|
442
|
+
const visibility = mod.publicSurface.actions.has(a.name)
|
|
443
|
+
? "public"
|
|
444
|
+
: "internal";
|
|
445
|
+
map.set(a.name, { module: mod.name, visibility });
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
return map;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Validate that every `needs.externalEvents` entry has a bus to flow through
|
|
452
|
+
* and is NOT also provided by this same app (you don't go cross-service to
|
|
453
|
+
* reach your own publishes).
|
|
454
|
+
*/
|
|
455
|
+
function validateExternalEventDeps(modules, localEventProviders, hasBus) {
|
|
456
|
+
for (const mod of modules) {
|
|
457
|
+
const externals = mod.manifest.needs?.externalEvents;
|
|
458
|
+
if (!externals || externals.length === 0)
|
|
459
|
+
continue;
|
|
460
|
+
if (!hasBus) {
|
|
461
|
+
throw new Error(`Module "${mod.name}" declares needs.externalEvents but no bus is configured. ` +
|
|
462
|
+
`Pass a bus instance to createApp({ bus, publishToBus? }).`);
|
|
463
|
+
}
|
|
464
|
+
for (const e of externals) {
|
|
465
|
+
if (localEventProviders.has(e.name)) {
|
|
466
|
+
throw new Error(`Module "${mod.name}" declares needs.externalEvents for "${e.name}" ` +
|
|
467
|
+
`but this app also provides it. External needs are for events that ` +
|
|
468
|
+
`originate in OTHER services. Move "${e.name}" to needs.events instead.`);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Validate the cross-module dep graph for `needs.events` and `needs.actions`.
|
|
475
|
+
*
|
|
476
|
+
* For `needs.events`: the same declaration must work whether the producer is
|
|
477
|
+
* local (in-process apply) or remote (cross-service via bus). So:
|
|
478
|
+
* - If a local provider exists: validate visibility (no internal events
|
|
479
|
+
* leaking across modules) and reject self-references.
|
|
480
|
+
* - If no local provider exists: require a bus — the runtime will
|
|
481
|
+
* auto-subscribe at boot. No visibility check (the producer service
|
|
482
|
+
* decides what it exports).
|
|
483
|
+
*
|
|
484
|
+
* For `needs.actions`: must be local (we don't have cross-service action
|
|
485
|
+
* dispatch yet — that's a future RPC story over the bus or HTTP).
|
|
486
|
+
*/
|
|
487
|
+
function validateModuleDepGraph(modules, localEventProviders, localActionProviders, hasBus) {
|
|
488
|
+
for (const mod of modules) {
|
|
489
|
+
const needs = mod.manifest.needs;
|
|
490
|
+
if (!needs)
|
|
491
|
+
continue;
|
|
492
|
+
for (const event of needs.events ?? []) {
|
|
493
|
+
const provider = localEventProviders.get(event.name);
|
|
494
|
+
if (provider) {
|
|
495
|
+
if (provider.module === mod.name) {
|
|
496
|
+
throw new Error(`Module "${mod.name}" needs event "${event.name}" but provides it itself. ` +
|
|
497
|
+
`A module's needs are its dependencies — drop the self-reference.`);
|
|
498
|
+
}
|
|
499
|
+
if (provider.visibility === "internal") {
|
|
500
|
+
throw new Error(`Module "${mod.name}" needs event "${event.name}" but module "${provider.module}" ` +
|
|
501
|
+
`marks it as visibility: 'internal'. Internal events are module-private; ` +
|
|
502
|
+
`either change the producer to visibility: 'public' or refactor to avoid the cross-module subscription.`);
|
|
503
|
+
}
|
|
504
|
+
continue;
|
|
505
|
+
}
|
|
506
|
+
// No local provider — only satisfiable via the bus.
|
|
507
|
+
if (!hasBus) {
|
|
508
|
+
throw new Error(`Module "${mod.name}" needs event "${event.name}" but no module in this app provides it ` +
|
|
509
|
+
`and no bus is configured. Either include a providing module in this app, configure a bus ` +
|
|
510
|
+
`so the event can arrive from another service, or remove "${event.name}" from needs.events.`);
|
|
511
|
+
}
|
|
512
|
+
// hasBus + non-local: the createApp wiring loop auto-subscribes.
|
|
513
|
+
}
|
|
514
|
+
for (const action of needs.actions ?? []) {
|
|
515
|
+
const provider = localActionProviders.get(action.name);
|
|
516
|
+
if (!provider) {
|
|
517
|
+
throw new Error(`Module "${mod.name}" needs action "${action.name}" but no module provides it. ` +
|
|
518
|
+
`Cross-service action dispatch is not supported yet — actions must be local to the app.`);
|
|
519
|
+
}
|
|
520
|
+
if (provider.module === mod.name) {
|
|
521
|
+
throw new Error(`Module "${mod.name}" needs action "${action.name}" but provides it itself. ` +
|
|
522
|
+
`A module's needs are its cross-module dependencies — drop the self-reference.`);
|
|
523
|
+
}
|
|
524
|
+
if (provider.visibility === "internal") {
|
|
525
|
+
throw new Error(`Module "${mod.name}" needs action "${action.name}" but module "${provider.module}" ` +
|
|
526
|
+
`did not call .public() on it in its module manifest. Internal actions are ` +
|
|
527
|
+
`module-private; mark the action public in the producer's manifest or refactor ` +
|
|
528
|
+
`to avoid the cross-module dispatch.`);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Kahn-style topological sort over the `needs` graph.
|
|
535
|
+
*
|
|
536
|
+
* Two modules form an edge `A → B` when A needs an event or action that B
|
|
537
|
+
* provides locally. The returned order satisfies "producers before
|
|
538
|
+
* consumers." Modules without any deps preserve their declaration order
|
|
539
|
+
* (stable sort), so a no-needs codebase boots in the order the user wrote.
|
|
540
|
+
*
|
|
541
|
+
* Cycles throw a `Cycle detected` error naming every module on the cycle
|
|
542
|
+
* — readable so the offending pair is obvious. Cycles between BCs usually
|
|
543
|
+
* indicate the boundary is drawn wrong; the fix is to extract the shared
|
|
544
|
+
* concept into a third module, not paper over with externalEvents.
|
|
545
|
+
*
|
|
546
|
+
* External / unknown refs are ignored here because `validateModuleDepGraph`
|
|
547
|
+
* has already proven every `needs.events` either has a local provider OR
|
|
548
|
+
* a bus subscription path. Topo sort cares only about LOCAL edges.
|
|
549
|
+
*/
|
|
550
|
+
function topoSortModules(modules, localEventProviders, localActionProviders) {
|
|
551
|
+
if (modules.length <= 1)
|
|
552
|
+
return modules;
|
|
553
|
+
const byName = new Map();
|
|
554
|
+
for (const m of modules)
|
|
555
|
+
byName.set(m.name, m);
|
|
556
|
+
// edges[consumer] = set of producer module names
|
|
557
|
+
const edges = new Map();
|
|
558
|
+
for (const m of modules)
|
|
559
|
+
edges.set(m.name, new Set());
|
|
560
|
+
for (const m of modules) {
|
|
561
|
+
const needs = m.manifest.needs;
|
|
562
|
+
if (!needs)
|
|
563
|
+
continue;
|
|
564
|
+
for (const e of needs.events ?? []) {
|
|
565
|
+
const p = localEventProviders.get(e.name);
|
|
566
|
+
if (p && p.module !== m.name)
|
|
567
|
+
edges.get(m.name).add(p.module);
|
|
568
|
+
}
|
|
569
|
+
for (const a of needs.actions ?? []) {
|
|
570
|
+
const p = localActionProviders.get(a.name);
|
|
571
|
+
if (p && p.module !== m.name)
|
|
572
|
+
edges.get(m.name).add(p.module);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
// Kahn: repeatedly emit nodes whose dep set is empty, in stable declaration order.
|
|
576
|
+
const remaining = new Set(modules.map((m) => m.name));
|
|
577
|
+
const ordered = [];
|
|
578
|
+
while (remaining.size > 0) {
|
|
579
|
+
const ready = modules.filter((m) => remaining.has(m.name) && [...edges.get(m.name)].every((dep) => !remaining.has(dep)));
|
|
580
|
+
if (ready.length === 0) {
|
|
581
|
+
const cycle = [...remaining].sort();
|
|
582
|
+
throw new Error(`createApp: cycle detected in module needs graph among: ${cycle.join(", ")}. ` +
|
|
583
|
+
`Two or more modules need each other (directly or transitively). ` +
|
|
584
|
+
`Extract the shared concept into a third module or move one side to externalEvents (bus).`);
|
|
585
|
+
}
|
|
586
|
+
for (const m of ready) {
|
|
587
|
+
ordered.push(m);
|
|
588
|
+
remaining.delete(m.name);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
return ordered;
|
|
592
|
+
}
|
|
593
|
+
//# sourceMappingURL=create-app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-app.js","sourceRoot":"","sources":["../src/create-app.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,aAAa,EAAkB,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,MAA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