@nwire/scan 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 +50 -0
- package/dist/__tests__/scan.test.d.ts +5 -0
- package/dist/__tests__/scan.test.d.ts.map +1 -0
- package/dist/__tests__/scan.test.js +103 -0
- package/dist/__tests__/scan.test.js.map +1 -0
- package/dist/scan.d.ts +328 -0
- package/dist/scan.d.ts.map +1 -0
- package/dist/scan.js +364 -0
- package/dist/scan.js.map +1 -0
- package/dist/vite-plugin.d.ts +9 -0
- package/dist/vite-plugin.d.ts.map +1 -0
- package/dist/vite-plugin.js +33 -0
- package/dist/vite-plugin.js.map +1 -0
- package/dist/zod-to-json.d.ts +14 -0
- package/dist/zod-to-json.d.ts.map +1 -0
- package/dist/zod-to-json.js +32 -0
- package/dist/zod-to-json.js.map +1 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alex Gefter / 200apps Ltd.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# @nwire/scan
|
|
2
|
+
|
|
3
|
+
> Walks `AppDefinition[]` and produces the `.nwire/` cache — the framework's static-reflection layer.
|
|
4
|
+
|
|
5
|
+
## What it does
|
|
6
|
+
|
|
7
|
+
Reads every action / event / actor / projection / query / workflow / module across all registered apps and emits a set of JSON files (`actions.json`, `events.json`, `actors.json`, `projections.json`, `queries.json`, `routes.json`, `modules.json`, `graph.json`, `manifest.json`). Studio reads these; the CLI reads these; codegen pipelines read these. Rebuilt from scratch on each invocation (a few ms for hundreds of definitions).
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add @nwire/scan
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick start
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { buildCache, writeCache } from "@nwire/scan";
|
|
19
|
+
import { allApps } from "../apps/apps";
|
|
20
|
+
|
|
21
|
+
const cache = buildCache(allApps);
|
|
22
|
+
await writeCache(cache, ".nwire");
|
|
23
|
+
//.nwire/manifest.json +.nwire/actions.json +... now on disk
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Most users invoke this via the CLI: `nwire cache`.
|
|
27
|
+
|
|
28
|
+
## API surface
|
|
29
|
+
|
|
30
|
+
- `buildCache(apps)` — returns the cache object.
|
|
31
|
+
- `writeCache(cache, dir)` — write the cache to disk.
|
|
32
|
+
- Entry types: `ActionEntry`, `EventEntry`, `ActorEntry`, `ProjectionEntry`, `QueryEntry`, `RouteEntry`, `ModuleEntry`, etc.
|
|
33
|
+
|
|
34
|
+
## When to use
|
|
35
|
+
|
|
36
|
+
When building tooling that needs to introspect a Nwire app — Studio panels, codegen, generated docs, custom CLIs. Fits every level (tooling concern).
|
|
37
|
+
|
|
38
|
+
## Used only within nwire-app
|
|
39
|
+
|
|
40
|
+
This package is part of the Nwire stack — it only makes sense inside a Nwire application built with `@nwire/app` + `@nwire/forge`. If you're looking for a standalone primitive, see:
|
|
41
|
+
|
|
42
|
+
- [`@nwire/handler`](../nwire-handler/README.md) — the operation primitive (transport-agnostic)
|
|
43
|
+
- [`@nwire/hooks`](../nwire-hooks/README.md) — universal dispatch (chain + listeners)
|
|
44
|
+
- [`@nwire/http`](../nwire-http/README.md) — typed HTTP without forge
|
|
45
|
+
- [`@nwire/endpoint`](../nwire-endpoint/README.md) — graceful shutdown for any host
|
|
46
|
+
|
|
47
|
+
## See also
|
|
48
|
+
|
|
49
|
+
- [Architecture sketch §05 — Tooling](../../architecture-sketch.html#packages)
|
|
50
|
+
- Sibling packages: [@nwire/cli](../nwire-cli), [@nwire/studio](../nwire-studio)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/scan.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nwire/scan — cache builder walks AppDefinition[] manifests.
|
|
3
|
+
*/
|
|
4
|
+
import { describe, it, expect } from "vitest";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { defineEvent } from "@nwire/messages";
|
|
7
|
+
import * as forge from "@nwire/forge";
|
|
8
|
+
import { buildCache } from "../scan";
|
|
9
|
+
const SubmittedEvent = defineEvent({
|
|
10
|
+
name: "sub.submitted",
|
|
11
|
+
description: "Avi turns in his answer.",
|
|
12
|
+
schema: z.object({ submissionId: z.string(), answer: z.string() }),
|
|
13
|
+
visibility: "public",
|
|
14
|
+
scope: "integration",
|
|
15
|
+
version: 1,
|
|
16
|
+
});
|
|
17
|
+
const InternalCheckEvent = defineEvent({
|
|
18
|
+
name: "sub.internal-check",
|
|
19
|
+
schema: z.object({ id: z.string() }),
|
|
20
|
+
visibility: "internal",
|
|
21
|
+
});
|
|
22
|
+
const submitAnswer = forge.defineAction({
|
|
23
|
+
name: "sub.submit-answer",
|
|
24
|
+
description: "Avi (9, beginner) finishes a Hebrew Letters exercise.",
|
|
25
|
+
schema: z.object({ submissionId: z.string(), answer: z.string() }),
|
|
26
|
+
policy: "self",
|
|
27
|
+
handler: async () => undefined,
|
|
28
|
+
});
|
|
29
|
+
const Submissions = forge.defineProjection("submissions-by-student", {
|
|
30
|
+
listens: [SubmittedEvent],
|
|
31
|
+
initial: () => ({ all: [] }),
|
|
32
|
+
on: { [SubmittedEvent.name]: (s) => s },
|
|
33
|
+
});
|
|
34
|
+
const subsByStudent = forge.defineQuery(Submissions, {
|
|
35
|
+
name: "sub.by-student",
|
|
36
|
+
description: "Avi's history.",
|
|
37
|
+
schema: z.object({ studentId: z.string() }),
|
|
38
|
+
execute: (state) => state.all,
|
|
39
|
+
});
|
|
40
|
+
const submissionsModule = forge.defineModule("submissions", {
|
|
41
|
+
actions: [submitAnswer],
|
|
42
|
+
events: [SubmittedEvent, InternalCheckEvent],
|
|
43
|
+
projections: [Submissions],
|
|
44
|
+
queries: [subsByStudent],
|
|
45
|
+
});
|
|
46
|
+
const masteryWorkflow = forge.defineWorkflow("mastery.observe-submission", ({ on }) => {
|
|
47
|
+
on(SubmittedEvent, async () => { });
|
|
48
|
+
});
|
|
49
|
+
const masteryModule = forge.defineModule("mastery", {
|
|
50
|
+
workflows: [masteryWorkflow],
|
|
51
|
+
needs: { events: [SubmittedEvent] },
|
|
52
|
+
});
|
|
53
|
+
const testApp = forge.defineApp("test-app", {
|
|
54
|
+
description: "Test fixture",
|
|
55
|
+
modules: [submissionsModule, masteryModule],
|
|
56
|
+
});
|
|
57
|
+
describe("buildCache", () => {
|
|
58
|
+
it("collects every action across modules with module+app provenance", () => {
|
|
59
|
+
const cache = buildCache([testApp]);
|
|
60
|
+
const submit = cache.actions.find((a) => a.name === "sub.submit-answer");
|
|
61
|
+
expect(submit).toBeDefined();
|
|
62
|
+
expect(submit?.module).toBe("submissions");
|
|
63
|
+
expect(submit?.app).toBe("test-app");
|
|
64
|
+
expect(submit?.description).toContain("Avi");
|
|
65
|
+
expect(submit?.policy).toBe("self");
|
|
66
|
+
expect(submit?.hasInlineHandler).toBe(true);
|
|
67
|
+
expect(submit?.schema).toMatchObject({ type: "object" });
|
|
68
|
+
});
|
|
69
|
+
it("collects events with visibility preserved", () => {
|
|
70
|
+
const cache = buildCache([testApp]);
|
|
71
|
+
expect(cache.events.find((e) => e.name === "sub.submitted")?.visibility).toBe("public");
|
|
72
|
+
expect(cache.events.find((e) => e.name === "sub.internal-check")?.visibility).toBe("internal");
|
|
73
|
+
});
|
|
74
|
+
it("collects projections with listens; queries with their projection", () => {
|
|
75
|
+
const cache = buildCache([testApp]);
|
|
76
|
+
const proj = cache.projections.find((p) => p.name === "submissions-by-student");
|
|
77
|
+
expect(proj?.listens).toEqual(["sub.submitted"]);
|
|
78
|
+
const q = cache.queries.find((q) => q.name === "sub.by-student");
|
|
79
|
+
expect(q?.projection).toBe("submissions-by-student");
|
|
80
|
+
});
|
|
81
|
+
it("builds an event graph linking producers to consumers", () => {
|
|
82
|
+
const cache = buildCache([testApp]);
|
|
83
|
+
const edge = cache.graph.events.find((e) => e.event === "sub.submitted");
|
|
84
|
+
expect(edge).toBeDefined();
|
|
85
|
+
expect(edge?.producer).toEqual({ app: "test-app", module: "submissions" });
|
|
86
|
+
// mastery has a workflow subscribing to SubmittedEvent AND declares it in needs.events
|
|
87
|
+
const masteryConsumers = edge?.consumers.filter((c) => c.module === "mastery");
|
|
88
|
+
expect(masteryConsumers?.some((c) => c.via === "workflow")).toBe(true);
|
|
89
|
+
// submissions' own projection also listens
|
|
90
|
+
const subProjConsumer = edge?.consumers.find((c) => c.module === "submissions" && c.via === "projection");
|
|
91
|
+
expect(subProjConsumer).toBeDefined();
|
|
92
|
+
});
|
|
93
|
+
it("module entries carry provides + needs + counts", () => {
|
|
94
|
+
const cache = buildCache([testApp]);
|
|
95
|
+
const mastery = cache.modules.find((m) => m.name === "mastery");
|
|
96
|
+
expect(mastery?.needs.events).toEqual(["sub.submitted"]);
|
|
97
|
+
expect(mastery?.counts.workflows).toBe(1);
|
|
98
|
+
const subs = cache.modules.find((m) => m.name === "submissions");
|
|
99
|
+
expect(subs?.provides.events).toEqual(["sub.submitted", "sub.internal-check"]);
|
|
100
|
+
expect(subs?.provides.actions).toEqual(["sub.submit-answer"]);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
//# sourceMappingURL=scan.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan.test.js","sourceRoot":"","sources":["../../src/__tests__/scan.test.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,MAAM,cAAc,GAAG,WAAW,CAAC;IACjC,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,0BAA0B;IACvC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;IAClE,UAAU,EAAE,QAAQ;IACpB,KAAK,EAAE,aAAa;IACpB,OAAO,EAAE,CAAC;CACX,CAAC,CAAC;AAEH,MAAM,kBAA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,CAAC;QACpC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;QAChE,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC;QACzD,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC1C,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,aAAa,CAAC,CAAC;QACjE,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,eAAe,EAAE,oBAAoB,CAAC,CAAC,CAAC;QAC/E,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/scan.d.ts
ADDED
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@nwire/scan` — walks `AppDefinition[]` and produces the `.nwire/` cache.
|
|
3
|
+
*
|
|
4
|
+
* The framework's static-reflection layer: every action/event/actor/
|
|
5
|
+
* projection/query/route plus the cross-module event graph emitted as
|
|
6
|
+
* JSON. Studio reads it; the CLI reads it; codegen reads it. Rebuilt
|
|
7
|
+
* from scratch on each invocation (a few ms for hundreds of definitions).
|
|
8
|
+
*
|
|
9
|
+
* See: architecture-sketch.html §05 (Tooling).
|
|
10
|
+
*/
|
|
11
|
+
import { zodToJsonSchema } from "./zod-to-json";
|
|
12
|
+
import type * as forge from "@nwire/forge";
|
|
13
|
+
export interface ActionEntry {
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly description?: string;
|
|
16
|
+
readonly module: string;
|
|
17
|
+
readonly app: string;
|
|
18
|
+
readonly schema: object;
|
|
19
|
+
readonly retry?: object;
|
|
20
|
+
readonly policy?: string | readonly string[];
|
|
21
|
+
readonly hasInlineHandler: boolean;
|
|
22
|
+
readonly emits: readonly string[];
|
|
23
|
+
/** True when the module's manifest marked this action `.public()`. */
|
|
24
|
+
readonly public: boolean;
|
|
25
|
+
/** Studio-aware metadata (all optional). */
|
|
26
|
+
readonly persona?: string;
|
|
27
|
+
readonly journeyStep?: string;
|
|
28
|
+
readonly capability?: string;
|
|
29
|
+
readonly slo?: {
|
|
30
|
+
readonly p95LatencyMs?: number;
|
|
31
|
+
readonly successRate?: number;
|
|
32
|
+
};
|
|
33
|
+
readonly tags?: readonly string[];
|
|
34
|
+
}
|
|
35
|
+
export interface ExternalCallEntry {
|
|
36
|
+
readonly name: string;
|
|
37
|
+
readonly description?: string;
|
|
38
|
+
readonly module: string;
|
|
39
|
+
readonly app: string;
|
|
40
|
+
readonly target: {
|
|
41
|
+
provider: string;
|
|
42
|
+
endpoint: string;
|
|
43
|
+
region?: string;
|
|
44
|
+
};
|
|
45
|
+
readonly request: object;
|
|
46
|
+
readonly response?: object;
|
|
47
|
+
readonly hasIdempotencyKey: boolean;
|
|
48
|
+
readonly slo?: {
|
|
49
|
+
p95LatencyMs?: number;
|
|
50
|
+
successRate?: number;
|
|
51
|
+
};
|
|
52
|
+
readonly retry?: {
|
|
53
|
+
max: number;
|
|
54
|
+
backoff?: string;
|
|
55
|
+
};
|
|
56
|
+
readonly tags?: readonly string[];
|
|
57
|
+
}
|
|
58
|
+
export interface InboundWebhookEntry {
|
|
59
|
+
readonly name: string;
|
|
60
|
+
readonly description?: string;
|
|
61
|
+
readonly module: string;
|
|
62
|
+
readonly app: string;
|
|
63
|
+
readonly source: string;
|
|
64
|
+
readonly path: string;
|
|
65
|
+
readonly hasSignatureVerifier: boolean;
|
|
66
|
+
readonly dedupe?: {
|
|
67
|
+
window: string;
|
|
68
|
+
};
|
|
69
|
+
readonly discriminator: string;
|
|
70
|
+
/** Map of discriminator value → action name. */
|
|
71
|
+
readonly routes: Readonly<Record<string, string>>;
|
|
72
|
+
readonly tags?: readonly string[];
|
|
73
|
+
}
|
|
74
|
+
export interface OutboxEntry {
|
|
75
|
+
readonly name: string;
|
|
76
|
+
readonly description?: string;
|
|
77
|
+
readonly module: string;
|
|
78
|
+
readonly app: string;
|
|
79
|
+
readonly publishes: readonly string[];
|
|
80
|
+
readonly flushIntervalMs: number;
|
|
81
|
+
readonly maxBatch: number;
|
|
82
|
+
readonly tags?: readonly string[];
|
|
83
|
+
}
|
|
84
|
+
export interface InboxEntry {
|
|
85
|
+
readonly name: string;
|
|
86
|
+
readonly description?: string;
|
|
87
|
+
readonly module: string;
|
|
88
|
+
readonly app: string;
|
|
89
|
+
readonly window: string;
|
|
90
|
+
readonly on: readonly string[];
|
|
91
|
+
readonly tags?: readonly string[];
|
|
92
|
+
}
|
|
93
|
+
export interface CronEntry {
|
|
94
|
+
readonly name: string;
|
|
95
|
+
readonly description?: string;
|
|
96
|
+
readonly module: string;
|
|
97
|
+
readonly app: string;
|
|
98
|
+
readonly schedule: string;
|
|
99
|
+
readonly dispatches: string;
|
|
100
|
+
readonly timezone?: string;
|
|
101
|
+
readonly tags?: readonly string[];
|
|
102
|
+
}
|
|
103
|
+
export interface WorkflowEntry {
|
|
104
|
+
/** The workflow name (`defineWorkflow("on-wash-complete", …)`). */
|
|
105
|
+
readonly name: string;
|
|
106
|
+
/** The bounded context (module) that owns this workflow. */
|
|
107
|
+
readonly module: string;
|
|
108
|
+
readonly app: string;
|
|
109
|
+
/** Free-form description from `options.description`. */
|
|
110
|
+
readonly description?: string;
|
|
111
|
+
/** Every event this workflow declares an `on(...)` for. */
|
|
112
|
+
readonly subscribesTo: readonly string[];
|
|
113
|
+
/** Every action this workflow declares it dispatches (via `opts.dispatches`). */
|
|
114
|
+
readonly dispatches: readonly string[];
|
|
115
|
+
/** True when the module's manifest marked this workflow `.public()`. */
|
|
116
|
+
readonly public: boolean;
|
|
117
|
+
}
|
|
118
|
+
export interface EventEntry {
|
|
119
|
+
readonly name: string;
|
|
120
|
+
readonly description?: string;
|
|
121
|
+
readonly module: string;
|
|
122
|
+
readonly app: string;
|
|
123
|
+
readonly visibility: "public" | "internal";
|
|
124
|
+
/**
|
|
125
|
+
* True when the module's manifest marked this event `.public()`. Distinct
|
|
126
|
+
* from `visibility` (which the event definition itself may declare for
|
|
127
|
+
* back-compat) — `public` reflects the canonical module-level decision.
|
|
128
|
+
*/
|
|
129
|
+
readonly public: boolean;
|
|
130
|
+
readonly schema: object;
|
|
131
|
+
/** Studio-aware metadata. */
|
|
132
|
+
readonly outcome?: "success" | "failure" | "milestone" | "warning";
|
|
133
|
+
readonly businessWeight?: number;
|
|
134
|
+
readonly audience?: readonly string[];
|
|
135
|
+
}
|
|
136
|
+
export interface ActorEntry {
|
|
137
|
+
readonly name: string;
|
|
138
|
+
readonly module: string;
|
|
139
|
+
readonly app: string;
|
|
140
|
+
readonly key: string;
|
|
141
|
+
readonly initial: string;
|
|
142
|
+
readonly states: ReadonlyArray<{
|
|
143
|
+
readonly name: string;
|
|
144
|
+
readonly final?: boolean;
|
|
145
|
+
readonly on: ReadonlyArray<{
|
|
146
|
+
readonly eventName: string;
|
|
147
|
+
readonly target?: string;
|
|
148
|
+
}>;
|
|
149
|
+
readonly after: ReadonlyArray<{
|
|
150
|
+
readonly timerName: string;
|
|
151
|
+
readonly action: string;
|
|
152
|
+
readonly delay: string;
|
|
153
|
+
}>;
|
|
154
|
+
}>;
|
|
155
|
+
readonly methods: readonly string[];
|
|
156
|
+
readonly schema: object;
|
|
157
|
+
/** Studio-aware metadata. */
|
|
158
|
+
readonly stuckThresholds?: Readonly<Record<string, number>>;
|
|
159
|
+
readonly slas?: Readonly<Record<string, {
|
|
160
|
+
maxDurationMs: number;
|
|
161
|
+
escalateTo?: string;
|
|
162
|
+
}>>;
|
|
163
|
+
}
|
|
164
|
+
export interface ProjectionEntry {
|
|
165
|
+
readonly name: string;
|
|
166
|
+
readonly module: string;
|
|
167
|
+
readonly app: string;
|
|
168
|
+
readonly listens: readonly string[];
|
|
169
|
+
/** Studio-aware metadata. */
|
|
170
|
+
readonly description?: string;
|
|
171
|
+
readonly freshness?: {
|
|
172
|
+
p95MsBehindStream?: number;
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
export interface QueryEntry {
|
|
176
|
+
readonly name: string;
|
|
177
|
+
readonly description?: string;
|
|
178
|
+
readonly module: string;
|
|
179
|
+
readonly app: string;
|
|
180
|
+
readonly projection: string;
|
|
181
|
+
readonly schema: object;
|
|
182
|
+
/** True when the module's manifest marked this query `.public()`. */
|
|
183
|
+
readonly public: boolean;
|
|
184
|
+
/** Studio-aware metadata. */
|
|
185
|
+
readonly slo?: {
|
|
186
|
+
p95LatencyMs?: number;
|
|
187
|
+
};
|
|
188
|
+
readonly cacheable?: boolean;
|
|
189
|
+
}
|
|
190
|
+
export interface ModuleEntry {
|
|
191
|
+
readonly name: string;
|
|
192
|
+
readonly app: string;
|
|
193
|
+
readonly provides: {
|
|
194
|
+
readonly events: readonly string[];
|
|
195
|
+
readonly actions: readonly string[];
|
|
196
|
+
};
|
|
197
|
+
readonly needs: {
|
|
198
|
+
readonly events: readonly string[];
|
|
199
|
+
readonly externalEvents: readonly string[];
|
|
200
|
+
readonly actions: readonly string[];
|
|
201
|
+
};
|
|
202
|
+
readonly counts: {
|
|
203
|
+
readonly actions: number;
|
|
204
|
+
readonly actors: number;
|
|
205
|
+
readonly projections: number;
|
|
206
|
+
readonly queries: number;
|
|
207
|
+
readonly workflows: number;
|
|
208
|
+
readonly events: number;
|
|
209
|
+
readonly routes: number;
|
|
210
|
+
};
|
|
211
|
+
/** Studio-aware metadata. */
|
|
212
|
+
readonly description?: string;
|
|
213
|
+
readonly owners?: readonly string[];
|
|
214
|
+
readonly journey?: readonly {
|
|
215
|
+
id: string;
|
|
216
|
+
label: string;
|
|
217
|
+
description?: string;
|
|
218
|
+
}[];
|
|
219
|
+
}
|
|
220
|
+
export interface AppEntry {
|
|
221
|
+
readonly name: string;
|
|
222
|
+
readonly description?: string;
|
|
223
|
+
readonly modules: readonly string[];
|
|
224
|
+
/** Studio-aware metadata. */
|
|
225
|
+
readonly tenantModel?: "single" | "per-org" | "per-account" | "per-workspace";
|
|
226
|
+
readonly tenantKey?: string;
|
|
227
|
+
}
|
|
228
|
+
export interface RouteEntry {
|
|
229
|
+
readonly method: string;
|
|
230
|
+
readonly path: string;
|
|
231
|
+
readonly target: string;
|
|
232
|
+
readonly targetKind: "action" | "query" | "resolver";
|
|
233
|
+
readonly module: string;
|
|
234
|
+
readonly app: string;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Interface-layer operation. Each resolver is a typed, transport-agnostic
|
|
238
|
+
* surface — Studio's canonical "what does this app expose?" answer.
|
|
239
|
+
*/
|
|
240
|
+
export interface ResolverEntry {
|
|
241
|
+
readonly operation: string;
|
|
242
|
+
readonly version: number;
|
|
243
|
+
readonly status: "draft" | "active" | "deprecated" | "sunset";
|
|
244
|
+
readonly summary?: string;
|
|
245
|
+
readonly description?: string;
|
|
246
|
+
readonly tags?: readonly string[];
|
|
247
|
+
readonly app: string;
|
|
248
|
+
/** Transport bindings — verb/path table from httpInterface().wire() + friends. */
|
|
249
|
+
readonly bindings: ReadonlyArray<{
|
|
250
|
+
readonly transport: "rest" | "graphql" | "cli";
|
|
251
|
+
readonly method?: string;
|
|
252
|
+
readonly path?: string;
|
|
253
|
+
}>;
|
|
254
|
+
/** Zod schemas converted to JSON schema. */
|
|
255
|
+
readonly params?: object;
|
|
256
|
+
readonly query?: object;
|
|
257
|
+
readonly body?: object;
|
|
258
|
+
readonly returns: ReadonlyArray<{
|
|
259
|
+
readonly status: number;
|
|
260
|
+
readonly kind: "single" | "list" | "empty";
|
|
261
|
+
}>;
|
|
262
|
+
readonly errors: ReadonlyArray<{
|
|
263
|
+
readonly code: string;
|
|
264
|
+
readonly status: number;
|
|
265
|
+
}>;
|
|
266
|
+
readonly successor?: {
|
|
267
|
+
readonly operation: string;
|
|
268
|
+
readonly version: number;
|
|
269
|
+
};
|
|
270
|
+
readonly sunsetDate?: string;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Optional mount table for resolvers. The scanner can't reach into
|
|
274
|
+
* `@nwire/http`'s rest registry (transport-layer dep), so callers pass
|
|
275
|
+
* the mount tuples in. Passing nothing is fine — resolvers will be
|
|
276
|
+
* emitted without verb/path bindings.
|
|
277
|
+
*/
|
|
278
|
+
export interface ResolverMount {
|
|
279
|
+
readonly resolver: any;
|
|
280
|
+
readonly transport: "rest" | "graphql" | "cli";
|
|
281
|
+
readonly method?: string;
|
|
282
|
+
readonly path?: string;
|
|
283
|
+
}
|
|
284
|
+
export interface EventGraphEdge {
|
|
285
|
+
readonly event: string;
|
|
286
|
+
readonly producer: {
|
|
287
|
+
app: string;
|
|
288
|
+
module: string;
|
|
289
|
+
};
|
|
290
|
+
readonly consumers: ReadonlyArray<{
|
|
291
|
+
readonly app: string;
|
|
292
|
+
readonly module: string;
|
|
293
|
+
readonly via: "workflow" | "projection" | "actor" | "external";
|
|
294
|
+
}>;
|
|
295
|
+
}
|
|
296
|
+
export interface Cache {
|
|
297
|
+
readonly generatedAt: string;
|
|
298
|
+
readonly apps: readonly AppEntry[];
|
|
299
|
+
readonly modules: readonly ModuleEntry[];
|
|
300
|
+
readonly actions: readonly ActionEntry[];
|
|
301
|
+
readonly events: readonly EventEntry[];
|
|
302
|
+
readonly actors: readonly ActorEntry[];
|
|
303
|
+
readonly projections: readonly ProjectionEntry[];
|
|
304
|
+
readonly queries: readonly QueryEntry[];
|
|
305
|
+
readonly resolvers: readonly ResolverEntry[];
|
|
306
|
+
readonly routes: readonly RouteEntry[];
|
|
307
|
+
readonly workflows: readonly WorkflowEntry[];
|
|
308
|
+
readonly externalCalls: readonly ExternalCallEntry[];
|
|
309
|
+
readonly inboundWebhooks: readonly InboundWebhookEntry[];
|
|
310
|
+
readonly outboxes: readonly OutboxEntry[];
|
|
311
|
+
readonly inboxes: readonly InboxEntry[];
|
|
312
|
+
readonly crons: readonly CronEntry[];
|
|
313
|
+
readonly graph: {
|
|
314
|
+
readonly events: readonly EventGraphEdge[];
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
export interface BuildCacheOptions {
|
|
318
|
+
/**
|
|
319
|
+
* Resolver mount tuples — pass in from the runtime side (typically
|
|
320
|
+
* `rest.listMounts()` from `@nwire/http`) so resolvers carry their
|
|
321
|
+
* verb/path bindings in the cache.
|
|
322
|
+
*/
|
|
323
|
+
readonly mounts?: readonly ResolverMount[];
|
|
324
|
+
}
|
|
325
|
+
export declare function buildCache(apps: readonly forge.AppDefinition[], options?: BuildCacheOptions): Cache;
|
|
326
|
+
export declare function writeCache(cache: Cache, dir: string): Promise<void>;
|
|
327
|
+
export { zodToJsonSchema };
|
|
328
|
+
//# sourceMappingURL=scan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../src/scan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAE3C,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;IAC7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AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,SAAS,KAAK,CAAC,aAAa,EAAE,EACpC,OAAO,GAAE,iBAAsB,GAC9B,KAAK,CAwVP;AAED,wBAAsB,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAwBzE;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
package/dist/scan.js
ADDED
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@nwire/scan` — walks `AppDefinition[]` and produces the `.nwire/` cache.
|
|
3
|
+
*
|
|
4
|
+
* The framework's static-reflection layer: every action/event/actor/
|
|
5
|
+
* projection/query/route plus the cross-module event graph emitted as
|
|
6
|
+
* JSON. Studio reads it; the CLI reads it; codegen reads it. Rebuilt
|
|
7
|
+
* from scratch on each invocation (a few ms for hundreds of definitions).
|
|
8
|
+
*
|
|
9
|
+
* See: architecture-sketch.html §05 (Tooling).
|
|
10
|
+
*/
|
|
11
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
12
|
+
import { resolve } from "node:path";
|
|
13
|
+
import { zodToJsonSchema } from "./zod-to-json";
|
|
14
|
+
export function buildCache(apps, options = {}) {
|
|
15
|
+
const out = {
|
|
16
|
+
apps: [],
|
|
17
|
+
modules: [],
|
|
18
|
+
actions: [],
|
|
19
|
+
events: [],
|
|
20
|
+
actors: [],
|
|
21
|
+
projections: [],
|
|
22
|
+
queries: [],
|
|
23
|
+
resolvers: [],
|
|
24
|
+
routes: [],
|
|
25
|
+
workflows: [],
|
|
26
|
+
externalCalls: [],
|
|
27
|
+
inboundWebhooks: [],
|
|
28
|
+
outboxes: [],
|
|
29
|
+
inboxes: [],
|
|
30
|
+
crons: [],
|
|
31
|
+
};
|
|
32
|
+
const mounts = options.mounts ?? [];
|
|
33
|
+
for (const app of apps) {
|
|
34
|
+
out.apps.push({
|
|
35
|
+
name: app.name,
|
|
36
|
+
description: app.description,
|
|
37
|
+
modules: app.modules.map((m) => m.name),
|
|
38
|
+
tenantModel: app.tenantModel,
|
|
39
|
+
tenantKey: app.tenantKey,
|
|
40
|
+
});
|
|
41
|
+
// Resolvers as a concept were removed — operations now ship as
|
|
42
|
+
// RouteBinding values wired on `httpInterface`. Scan reads them
|
|
43
|
+
// from the http builder's manifest at boot, not from the app.
|
|
44
|
+
//
|
|
45
|
+
// `mounts` stays as a parameter so callers can still pass route
|
|
46
|
+
// metadata explicitly; it's just no longer derived from
|
|
47
|
+
// `app.resolvers`.
|
|
48
|
+
void mounts;
|
|
49
|
+
void zodToJsonSchema;
|
|
50
|
+
for (const module of app.modules) {
|
|
51
|
+
const m = module.manifest;
|
|
52
|
+
const provides = {
|
|
53
|
+
events: (m.events ?? []).map((e) => e.name),
|
|
54
|
+
actions: (m.actions ?? []).map((a) => a.name),
|
|
55
|
+
};
|
|
56
|
+
const needs = {
|
|
57
|
+
events: (m.needs?.events ?? []).map((e) => e.name),
|
|
58
|
+
externalEvents: (m.needs?.externalEvents ?? []).map((e) => e.name),
|
|
59
|
+
actions: (m.needs?.actions ?? []).map((a) => a.name),
|
|
60
|
+
};
|
|
61
|
+
out.modules.push({
|
|
62
|
+
name: module.name,
|
|
63
|
+
app: app.name,
|
|
64
|
+
provides,
|
|
65
|
+
needs,
|
|
66
|
+
counts: {
|
|
67
|
+
actions: (m.actions ?? []).length,
|
|
68
|
+
actors: (m.actors ?? []).length,
|
|
69
|
+
projections: (m.projections ?? []).length,
|
|
70
|
+
queries: (m.queries ?? []).length,
|
|
71
|
+
workflows: (m.workflows ?? []).length,
|
|
72
|
+
events: (m.events ?? []).length,
|
|
73
|
+
// routes are app-level (httpInterface().wire()); not module-owned.
|
|
74
|
+
routes: 0,
|
|
75
|
+
},
|
|
76
|
+
description: m.description,
|
|
77
|
+
owners: m.owners,
|
|
78
|
+
journey: m.journey,
|
|
79
|
+
});
|
|
80
|
+
for (const action of m.actions ?? []) {
|
|
81
|
+
out.actions.push({
|
|
82
|
+
name: action.name,
|
|
83
|
+
description: action.description,
|
|
84
|
+
module: module.name,
|
|
85
|
+
app: app.name,
|
|
86
|
+
schema: zodToJsonSchema(action.schema),
|
|
87
|
+
retry: action.retry,
|
|
88
|
+
policy: action.policy,
|
|
89
|
+
hasInlineHandler: Boolean(action.handler),
|
|
90
|
+
emits: (action.emits ?? []).map((e) => e.name),
|
|
91
|
+
public: module.publicSurface.actions.has(action.name),
|
|
92
|
+
persona: action.persona,
|
|
93
|
+
journeyStep: action.journeyStep,
|
|
94
|
+
capability: action.capability,
|
|
95
|
+
slo: action.slo,
|
|
96
|
+
tags: action.tags,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
for (const event of m.events ?? []) {
|
|
100
|
+
out.events.push({
|
|
101
|
+
name: event.name,
|
|
102
|
+
description: event.description,
|
|
103
|
+
module: module.name,
|
|
104
|
+
app: app.name,
|
|
105
|
+
visibility: event.visibility ?? "public",
|
|
106
|
+
public: module.publicSurface.events.has(event.name),
|
|
107
|
+
schema: zodToJsonSchema(event.schema),
|
|
108
|
+
outcome: event.outcome,
|
|
109
|
+
businessWeight: event.businessWeight,
|
|
110
|
+
audience: event.audience,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
for (const actor of m.actors ?? []) {
|
|
114
|
+
out.actors.push({
|
|
115
|
+
name: actor.name,
|
|
116
|
+
module: module.name,
|
|
117
|
+
app: app.name,
|
|
118
|
+
key: actor.key,
|
|
119
|
+
initial: actor.initial,
|
|
120
|
+
states: Object.entries(actor.states).map(([stateName, cfg]) => ({
|
|
121
|
+
name: stateName,
|
|
122
|
+
final: cfg.final,
|
|
123
|
+
on: Object.entries(cfg.on ?? {}).map(([eventName, reaction]) => ({
|
|
124
|
+
eventName,
|
|
125
|
+
target: reaction.target,
|
|
126
|
+
})),
|
|
127
|
+
after: Object.entries(cfg.after ?? {}).map(([timerName, spec]) => ({
|
|
128
|
+
timerName,
|
|
129
|
+
action: typeof spec === "string" ? spec : spec.action,
|
|
130
|
+
delay: typeof spec === "string" ? timerName : spec.delay,
|
|
131
|
+
})),
|
|
132
|
+
})),
|
|
133
|
+
methods: Object.keys(actor.methods ?? {}),
|
|
134
|
+
schema: zodToJsonSchema(actor.schema),
|
|
135
|
+
stuckThresholds: actor.stuckThresholds,
|
|
136
|
+
slas: actor.slas,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
for (const projection of m.projections ?? []) {
|
|
140
|
+
out.projections.push({
|
|
141
|
+
name: projection.name,
|
|
142
|
+
module: module.name,
|
|
143
|
+
app: app.name,
|
|
144
|
+
listens: (projection.listens ?? []).map((e) => e.name),
|
|
145
|
+
description: projection.description,
|
|
146
|
+
freshness: projection.freshness,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
for (const query of m.queries ?? []) {
|
|
150
|
+
out.queries.push({
|
|
151
|
+
name: query.name,
|
|
152
|
+
description: query.description,
|
|
153
|
+
module: module.name,
|
|
154
|
+
app: app.name,
|
|
155
|
+
projection: query.projection.name,
|
|
156
|
+
schema: zodToJsonSchema(query.schema),
|
|
157
|
+
public: module.publicSurface.queries.has(query.name),
|
|
158
|
+
slo: query.slo,
|
|
159
|
+
cacheable: query.cacheable,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
// Routes are no longer module-owned. The interface layer (httpInterface
|
|
163
|
+
// builders + .wire() bindings) lives in the app composition; route
|
|
164
|
+
// emission walks the running wire's introspection mount.
|
|
165
|
+
for (const call of m.externalCalls ?? []) {
|
|
166
|
+
out.externalCalls.push({
|
|
167
|
+
name: call.name,
|
|
168
|
+
description: call.description,
|
|
169
|
+
module: module.name,
|
|
170
|
+
app: app.name,
|
|
171
|
+
target: call.target,
|
|
172
|
+
request: zodToJsonSchema(call.request),
|
|
173
|
+
response: call.response ? zodToJsonSchema(call.response) : undefined,
|
|
174
|
+
hasIdempotencyKey: call.hasIdempotencyKey,
|
|
175
|
+
slo: call.slo,
|
|
176
|
+
retry: call.retry ? { max: call.retry.max, backoff: call.retry.backoff } : undefined,
|
|
177
|
+
tags: call.tags,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
for (const wh of m.inboundWebhooks ?? []) {
|
|
181
|
+
const routes = {};
|
|
182
|
+
for (const [discValue, action] of Object.entries(wh.routes)) {
|
|
183
|
+
routes[discValue] = action.name;
|
|
184
|
+
}
|
|
185
|
+
out.inboundWebhooks.push({
|
|
186
|
+
name: wh.name,
|
|
187
|
+
description: wh.description,
|
|
188
|
+
module: module.name,
|
|
189
|
+
app: app.name,
|
|
190
|
+
source: wh.source,
|
|
191
|
+
path: wh.path,
|
|
192
|
+
hasSignatureVerifier: !!wh.verifySignature,
|
|
193
|
+
dedupe: wh.dedupe ? { window: wh.dedupe.window } : undefined,
|
|
194
|
+
discriminator: wh.discriminator,
|
|
195
|
+
routes,
|
|
196
|
+
tags: wh.tags,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
for (const ob of m.outboxes ?? []) {
|
|
200
|
+
out.outboxes.push({
|
|
201
|
+
name: ob.name,
|
|
202
|
+
description: ob.description,
|
|
203
|
+
module: module.name,
|
|
204
|
+
app: app.name,
|
|
205
|
+
publishes: ob.publishes.map((e) => e.name),
|
|
206
|
+
flushIntervalMs: ob.flushIntervalMs,
|
|
207
|
+
maxBatch: ob.maxBatch,
|
|
208
|
+
tags: ob.tags,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
for (const ib of m.inboxes ?? []) {
|
|
212
|
+
out.inboxes.push({
|
|
213
|
+
name: ib.name,
|
|
214
|
+
description: ib.description,
|
|
215
|
+
module: module.name,
|
|
216
|
+
app: app.name,
|
|
217
|
+
window: ib.window,
|
|
218
|
+
on: ib.on.map((a) => a.name),
|
|
219
|
+
tags: ib.tags,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
for (const cron of m.crons ?? []) {
|
|
223
|
+
out.crons.push({
|
|
224
|
+
name: cron.name,
|
|
225
|
+
description: cron.description,
|
|
226
|
+
module: module.name,
|
|
227
|
+
app: app.name,
|
|
228
|
+
schedule: cron.schedule,
|
|
229
|
+
dispatches: cron.dispatches.name,
|
|
230
|
+
timezone: cron.timezone,
|
|
231
|
+
tags: cron.tags,
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
// Build event graph: producer (module that emits) → consumers (modules
|
|
237
|
+
// that listen via reaction or have it in needs).
|
|
238
|
+
const eventOwners = new Map();
|
|
239
|
+
for (const ev of out.events) {
|
|
240
|
+
eventOwners.set(ev.name, { app: ev.app, module: ev.module });
|
|
241
|
+
}
|
|
242
|
+
const edges = new Map();
|
|
243
|
+
const seed = (eventName) => {
|
|
244
|
+
const owner = eventOwners.get(eventName);
|
|
245
|
+
if (!owner)
|
|
246
|
+
return null;
|
|
247
|
+
let e = edges.get(eventName);
|
|
248
|
+
if (!e) {
|
|
249
|
+
e = { event: eventName, producer: owner, consumers: [] };
|
|
250
|
+
edges.set(eventName, e);
|
|
251
|
+
}
|
|
252
|
+
return e;
|
|
253
|
+
};
|
|
254
|
+
// Workflows = explicit cross-cutting subscribers. Studio reads one
|
|
255
|
+
// .nwire/workflows.json and renders every reaction-style handler on
|
|
256
|
+
// the same node type.
|
|
257
|
+
for (const app of apps) {
|
|
258
|
+
for (const module of app.modules) {
|
|
259
|
+
for (const workflow of module.manifest.workflows ?? []) {
|
|
260
|
+
out.workflows.push({
|
|
261
|
+
name: workflow.name,
|
|
262
|
+
module: module.name,
|
|
263
|
+
app: app.name,
|
|
264
|
+
description: workflow.description,
|
|
265
|
+
subscribesTo: [...workflow.subscribedEvents],
|
|
266
|
+
dispatches: [...workflow.dispatchedActions],
|
|
267
|
+
public: module.publicSurface.workflows.has(workflow.name),
|
|
268
|
+
});
|
|
269
|
+
for (const eventName of workflow.subscribedEvents) {
|
|
270
|
+
const edge = seed(eventName);
|
|
271
|
+
if (!edge)
|
|
272
|
+
continue;
|
|
273
|
+
edge.consumers.push({
|
|
274
|
+
app: app.name,
|
|
275
|
+
module: module.name,
|
|
276
|
+
via: "workflow",
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
// Actor reactions = state-machine reactions
|
|
281
|
+
for (const actor of module.manifest.actors ?? []) {
|
|
282
|
+
for (const [stateName, cfg] of Object.entries(actor.states)) {
|
|
283
|
+
for (const eventName of Object.keys(cfg.on ?? {})) {
|
|
284
|
+
const edge = seed(eventName);
|
|
285
|
+
if (!edge)
|
|
286
|
+
continue;
|
|
287
|
+
edge.consumers.push({
|
|
288
|
+
app: app.name,
|
|
289
|
+
module: module.name,
|
|
290
|
+
via: "actor",
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
// Projection listens
|
|
296
|
+
for (const projection of module.manifest.projections ?? []) {
|
|
297
|
+
for (const ev of projection.listens ?? []) {
|
|
298
|
+
const edge = seed(ev.name);
|
|
299
|
+
if (!edge)
|
|
300
|
+
continue;
|
|
301
|
+
edge.consumers.push({
|
|
302
|
+
app: app.name,
|
|
303
|
+
module: module.name,
|
|
304
|
+
via: "projection",
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
// External event needs = cross-service consumers
|
|
309
|
+
for (const ev of module.manifest.needs?.externalEvents ?? []) {
|
|
310
|
+
const edge = seed(ev.name);
|
|
311
|
+
if (!edge)
|
|
312
|
+
continue;
|
|
313
|
+
edge.consumers.push({
|
|
314
|
+
app: app.name,
|
|
315
|
+
module: module.name,
|
|
316
|
+
via: "external",
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return {
|
|
322
|
+
generatedAt: new Date().toISOString(),
|
|
323
|
+
apps: out.apps,
|
|
324
|
+
modules: out.modules,
|
|
325
|
+
actions: out.actions,
|
|
326
|
+
events: out.events,
|
|
327
|
+
actors: out.actors,
|
|
328
|
+
projections: out.projections,
|
|
329
|
+
queries: out.queries,
|
|
330
|
+
resolvers: out.resolvers,
|
|
331
|
+
routes: out.routes,
|
|
332
|
+
workflows: out.workflows,
|
|
333
|
+
externalCalls: out.externalCalls,
|
|
334
|
+
inboundWebhooks: out.inboundWebhooks,
|
|
335
|
+
outboxes: out.outboxes,
|
|
336
|
+
inboxes: out.inboxes,
|
|
337
|
+
crons: out.crons,
|
|
338
|
+
graph: { events: Array.from(edges.values()) },
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
export async function writeCache(cache, dir) {
|
|
342
|
+
await mkdir(dir, { recursive: true });
|
|
343
|
+
await Promise.all([
|
|
344
|
+
writeFile(resolve(dir, "manifest.json"), JSON.stringify(cache, null, 2)),
|
|
345
|
+
writeFile(resolve(dir, "actions.json"), JSON.stringify(cache.actions, null, 2)),
|
|
346
|
+
writeFile(resolve(dir, "events.json"), JSON.stringify(cache.events, null, 2)),
|
|
347
|
+
writeFile(resolve(dir, "actors.json"), JSON.stringify(cache.actors, null, 2)),
|
|
348
|
+
writeFile(resolve(dir, "projections.json"), JSON.stringify(cache.projections, null, 2)),
|
|
349
|
+
writeFile(resolve(dir, "queries.json"), JSON.stringify(cache.queries, null, 2)),
|
|
350
|
+
writeFile(resolve(dir, "modules.json"), JSON.stringify(cache.modules, null, 2)),
|
|
351
|
+
writeFile(resolve(dir, "apps.json"), JSON.stringify(cache.apps, null, 2)),
|
|
352
|
+
writeFile(resolve(dir, "resolvers.json"), JSON.stringify(cache.resolvers, null, 2)),
|
|
353
|
+
writeFile(resolve(dir, "routes.json"), JSON.stringify(cache.routes, null, 2)),
|
|
354
|
+
writeFile(resolve(dir, "workflows.json"), JSON.stringify(cache.workflows, null, 2)),
|
|
355
|
+
writeFile(resolve(dir, "external-calls.json"), JSON.stringify(cache.externalCalls, null, 2)),
|
|
356
|
+
writeFile(resolve(dir, "inbound-webhooks.json"), JSON.stringify(cache.inboundWebhooks, null, 2)),
|
|
357
|
+
writeFile(resolve(dir, "outboxes.json"), JSON.stringify(cache.outboxes, null, 2)),
|
|
358
|
+
writeFile(resolve(dir, "inboxes.json"), JSON.stringify(cache.inboxes, null, 2)),
|
|
359
|
+
writeFile(resolve(dir, "crons.json"), JSON.stringify(cache.crons, null, 2)),
|
|
360
|
+
writeFile(resolve(dir, "graph.json"), JSON.stringify(cache.graph, null, 2)),
|
|
361
|
+
]);
|
|
362
|
+
}
|
|
363
|
+
export { zodToJsonSchema };
|
|
364
|
+
//# sourceMappingURL=scan.js.map
|
package/dist/scan.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan.js","sourceRoot":"","sources":["../src/scan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AA6ShD,MAAM,UAAU,UAAU,CACxB,IAAoC,EACpC,UAA6B,EAAE;IAE/B,MAAM,GAAG,GAgBL;QACF,IAAI,EAAE,EAAE;QACR,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,EAAE;QACX,MAAM,EAAE,EAAE;QACV,MAAM,EAAE,EAAE;QACV,WAAW,EAAE,EAAE;QACf,OAAO,EAAE,EAAE;QACX,SAAS,EAAE,EAAE;QACb,MAAM,EAAE,EAAE;QACV,SAAS,EAAE,EAAE;QACb,aAAa,EAAE,EAAE;QACjB,eAAe,EAAE,EAAE;QACnB,QAAQ,EAAE,EAAE;QACZ,OAAO,EAAE,EAAE;QACX,KAAK,EAAE,EAAE;KACV,CAAC;IACF,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC;IAEpC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;YACZ,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,WAAW,EAAE,GAAG,CAA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AAgB,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACnF,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,qBAAqB,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC5F,SAAS,CACP,OAAO,CAAC,GAAG,EAAE,uBAAuB,CAAC,EACrC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC,CAC/C;QACD,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,eAAe,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACjF,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,cAAc,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC/E,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,YAAY,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC3E,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,YAAY,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;KAC5E,CAAC,CAAC;AACL,CAAC;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
import type * as forge from "@nwire/forge";
|
|
3
|
+
export interface NwireCachePluginOptions {
|
|
4
|
+
readonly apps: readonly forge.AppDefinition[];
|
|
5
|
+
/** Output directory. Default: '.nwire'. */
|
|
6
|
+
readonly outDir?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function nwireCachePlugin(options: NwireCachePluginOptions): Plugin;
|
|
9
|
+
//# sourceMappingURL=vite-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAG3C,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,IAAI,EAAE,SAAS,KAAK,CAAC,aAAa,EAAE,CAAC;IAC9C,2CAA2C;IAC3C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,MAAM,CAiBzE"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Vite plugin form — invoke buildCache + writeCache at dev/build startup.
|
|
2
|
+
//
|
|
3
|
+
// // vite.config.ts
|
|
4
|
+
// import { nwireCachePlugin } from '@nwire/scan/vite-plugin'
|
|
5
|
+
// import { allApps } from './apps/apps'
|
|
6
|
+
//
|
|
7
|
+
// export default defineConfig({
|
|
8
|
+
// plugins: [nwireCachePlugin({ apps: allApps })]
|
|
9
|
+
// })
|
|
10
|
+
//
|
|
11
|
+
// Hooks into Vite's `buildStart` and `configureServer` so the cache is
|
|
12
|
+
// fresh whenever Vite reloads. For the rare case where the cache is needed
|
|
13
|
+
// without Vite running, use the CLI: `nwire cache`.
|
|
14
|
+
import { buildCache, writeCache } from "./scan";
|
|
15
|
+
export function nwireCachePlugin(options) {
|
|
16
|
+
const outDir = options.outDir ?? ".nwire";
|
|
17
|
+
return {
|
|
18
|
+
name: "nwire:cache",
|
|
19
|
+
async buildStart() {
|
|
20
|
+
const cache = buildCache(options.apps);
|
|
21
|
+
await writeCache(cache, outDir);
|
|
22
|
+
},
|
|
23
|
+
async configureServer(server) {
|
|
24
|
+
const cache = buildCache(options.apps);
|
|
25
|
+
await writeCache(cache, outDir);
|
|
26
|
+
server.middlewares.use("/__nwire/cache", (_req, res) => {
|
|
27
|
+
res.setHeader("Content-Type", "application/json");
|
|
28
|
+
res.end(JSON.stringify(cache, null, 2));
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=vite-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-plugin.js","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,EAAE;AACF,sBAAsB;AACtB,+DAA+D;AAC/D,0CAA0C;AAC1C,EAAE;AACF,kCAAkC;AAClC,qDAAqD;AACrD,OAAO;AACP,EAAE;AACF,uEAAuE;AACvE,2EAA2E;AAC3E,oDAAoD;AAIpD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAQhD,MAAM,UAAU,gBAAgB,CAAC,OAAgC;IAC/D,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,QAAQ,CAAC;IAC1C,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,KAAK,CAAC,UAAU;YACd,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACvC,MAAM,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAClC,CAAC;QACD,KAAK,CAAC,eAAe,CAAC,MAAM;YAC1B,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACvC,MAAM,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YAChC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;gBACrD,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;gBAClD,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YAC1C,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod → JSON Schema for the cache.
|
|
3
|
+
*
|
|
4
|
+
* Zod 4 ships a first-class `z.toJSONSchema()` exporter — we delegate to it
|
|
5
|
+
* instead of maintaining our own walk. Studio reads these schemas to render
|
|
6
|
+
* form fields + show "expected shape" hints; the OpenAPI path uses
|
|
7
|
+
* `@asteasolutions/zod-to-openapi` separately.
|
|
8
|
+
*
|
|
9
|
+
* The output is a JSON Schema 2020-12 object. We strip the top-level
|
|
10
|
+
* `$schema` URL since callers don't need it embedded in every cache entry.
|
|
11
|
+
*/
|
|
12
|
+
import type { ZodTypeAny } from "@nwire/messages";
|
|
13
|
+
export declare function zodToJsonSchema(schema: ZodTypeAny): object;
|
|
14
|
+
//# sourceMappingURL=zod-to-json.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zod-to-json.d.ts","sourceRoot":"","sources":["../src/zod-to-json.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAiB1D"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod → JSON Schema for the cache.
|
|
3
|
+
*
|
|
4
|
+
* Zod 4 ships a first-class `z.toJSONSchema()` exporter — we delegate to it
|
|
5
|
+
* instead of maintaining our own walk. Studio reads these schemas to render
|
|
6
|
+
* form fields + show "expected shape" hints; the OpenAPI path uses
|
|
7
|
+
* `@asteasolutions/zod-to-openapi` separately.
|
|
8
|
+
*
|
|
9
|
+
* The output is a JSON Schema 2020-12 object. We strip the top-level
|
|
10
|
+
* `$schema` URL since callers don't need it embedded in every cache entry.
|
|
11
|
+
*/
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
export function zodToJsonSchema(schema) {
|
|
14
|
+
try {
|
|
15
|
+
const json = z.toJSONSchema(schema);
|
|
16
|
+
// The cache doesn't need the $schema dialect URL — it's the same on
|
|
17
|
+
// every entry. Strip it for a leaner manifest.
|
|
18
|
+
if (json && typeof json === "object") {
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
20
|
+
const { $schema, ...rest } = json;
|
|
21
|
+
return rest;
|
|
22
|
+
}
|
|
23
|
+
return json;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
// toJSONSchema throws on a few edge cases (cyclic refs, transforms with
|
|
27
|
+
// no encoder). Surface "unknown" so Studio shows a placeholder instead
|
|
28
|
+
// of failing the whole cache build.
|
|
29
|
+
return { type: "unknown" };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=zod-to-json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zod-to-json.js","sourceRoot":"","sources":["../src/zod-to-json.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,UAAU,eAAe,CAAC,MAAkB;IAChD,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,CAAC,CAAC,YAAY,CAAC,MAAM,CAA4B,CAAC;QAC/D,oEAAoE;QACpE,+CAA+C;QAC/C,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YACrC,6DAA6D;YAC7D,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;YAClC,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,wEAAwE;QACxE,uEAAuE;QACvE,oCAAoC;QACpC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IAC7B,CAAC;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nwire/scan",
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "Nwire — system registry scanner. Walks AppDefinition[] manifests and writes the .nwire/ cache (actions, events, actors, projections, queries, modules, routes, event graph). Vite plugin + standalone function.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cache",
|
|
7
|
+
"nwire",
|
|
8
|
+
"registry",
|
|
9
|
+
"scan",
|
|
10
|
+
"vite-plugin"
|
|
11
|
+
],
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "./dist/scan.js",
|
|
18
|
+
"types": "./dist/scan.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"import": "./dist/scan.js",
|
|
22
|
+
"types": "./dist/scan.d.ts"
|
|
23
|
+
},
|
|
24
|
+
"./vite-plugin": {
|
|
25
|
+
"import": "./dist/vite-plugin.js",
|
|
26
|
+
"types": "./dist/vite-plugin.d.ts"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"zod": "^4.4.3",
|
|
34
|
+
"@nwire/forge": "0.7.0",
|
|
35
|
+
"@nwire/messages": "0.7.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/node": "^22.19.9",
|
|
39
|
+
"typescript": "^5.9.3",
|
|
40
|
+
"vite": "npm:rolldown-vite@latest",
|
|
41
|
+
"vitest": "^4.0.18"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsc",
|
|
45
|
+
"dev": "tsc --watch",
|
|
46
|
+
"typecheck": "tsc --noEmit"
|
|
47
|
+
}
|
|
48
|
+
}
|