@aomex/asyncapi-generator 0.0.0-stage → 4.4.1-alpha.c1419fd5.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-2024 geekact
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 CHANGED
@@ -1,3 +1,3 @@
1
- # Temporary Holding Version
1
+ # @aomex/asyncapi-generator
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 文档:https://aomex.js.org
@@ -0,0 +1,112 @@
1
+ import { AsyncAPI } from "@aomex/common";
2
+ import { ConsoleMiddleware } from "@aomex/console";
3
+ import { Channel } from "@aomex/websocket";
4
+ import { GlobPathOptions } from "@aomex/internal-file-import";
5
+ import { Mode } from "node:fs";
6
+ export interface GenerateAsyncapiOptions {
7
+ /**
8
+ * Channel 来源:目录 glob,或已实例化的 `Channel[]`。
9
+ *
10
+ * ```ts
11
+ * generateAsyncapi({
12
+ * channels: './src/channels',
13
+ * docs: { asyncapi: '3.1.0' },
14
+ * });
15
+ * generateAsyncapi({
16
+ * channels: [channel],
17
+ * docs: { asyncapi: '3.1.0' },
18
+ * });
19
+ * ```
20
+ */
21
+ channels: GlobPathOptions | Channel[];
22
+ /**
23
+ * AsyncAPI 基础信息(会与空文档骨架合并)。
24
+ * `asyncapi` 版本须由调用方显式填写(`3.0.0` / `3.1.0`)。
25
+ * `channels` / `operations` / `components` 由生成器写入;
26
+ * `servers`、`id`、`defaultContentType` 以及 `info` 的其余字段会保留。
27
+ */
28
+ docs: {
29
+ asyncapi: AsyncAPI.Document['asyncapi'];
30
+ info?: Partial<AsyncAPI.InfoObject>;
31
+ } & Omit<AsyncAPI.Document, 'asyncapi' | 'info' | 'channels' | 'operations' | 'components'>;
32
+ /**
33
+ * 手动修复文档内容。
34
+ */
35
+ fix?: (data: AsyncAPI.Document) => void | Promise<void>;
36
+ }
37
+ /**
38
+ * 从 Channel 生成 AsyncAPI 3.x 文档。
39
+ */
40
+ export declare const generateAsyncapi: (config: GenerateAsyncapiOptions) => Promise<AsyncAPI.Document>;
41
+ export interface GenerateAsyncapiWithSpinnerOptions extends GenerateAsyncapiOptions {
42
+ /**
43
+ * 保存到指定文件。默认值:`asyncapi.json`
44
+ * - `*.json` 保存为 JSON
45
+ * - `*.yaml` / `*.yml` 保存为 YAML
46
+ */
47
+ saveToFile?: string;
48
+ /**
49
+ * 设置保存文件的系统权限。
50
+ */
51
+ fileMode?: Mode;
52
+ }
53
+ /**
54
+ * 生成 → 保存 → 校验,并在终端展示步骤。
55
+ * 编程调用请优先用 {@link generateAsyncapi}。
56
+ */
57
+ export declare const generateAsyncapiWithSpinner: (config: GenerateAsyncapiWithSpinnerOptions) => Promise<AsyncAPI.Document | null>;
58
+ export interface AsyncapiOptions extends GenerateAsyncapiWithSpinnerOptions {
59
+ /**
60
+ * 指令名称。默认值:`asyncapi`
61
+ */
62
+ commandName?: string;
63
+ }
64
+ /**
65
+ * Console 中间件:生成 AsyncAPI 文档。
66
+ *
67
+ * ```ts
68
+ * import { asyncapi } from '@aomex/asyncapi-generator';
69
+ *
70
+ * asyncapi({
71
+ * commandName: 'asyncapi',
72
+ * channels: './src/channels',
73
+ * docs: { asyncapi: '3.1.0' },
74
+ * saveToFile: 'asyncapi.json',
75
+ * });
76
+ * ```
77
+ */
78
+ export declare const asyncapi: (options: AsyncapiOptions) => ConsoleMiddleware;
79
+ /** 深拷贝 `docs` 并补上生成器要写的空骨架。`title` / `version` 为空时回退到 cwd 的 package.json。 */
80
+ export declare const initializeDocument: (basic: GenerateAsyncapiOptions['docs']) => Promise<AsyncAPI.Document>;
81
+ /**
82
+ * 遍历 Channel,预建入站骨架后按中间件链调用 `asyncapi()` 注入器。
83
+ * 顺序对齐 OpenAPI:先建骨架,再 `onDocument` → `onEvent` → `postEvent`(倒序) → `postDocument`(倒序)。
84
+ */
85
+ export declare const parseChannels: (document: AsyncAPI.Document, channels: Channel[]) => void;
86
+ export declare const saveToFile: (document: AsyncAPI.Document, filename?: string, fileMode?: Mode) => Promise<{
87
+ dest: string;
88
+ size: string;
89
+ }>;
90
+ export interface AsyncapiValidateResultItem {
91
+ path: string[];
92
+ message: string;
93
+ }
94
+ export interface AsyncapiValidateResult {
95
+ errors: AsyncapiValidateResultItem[];
96
+ warnings: AsyncapiValidateResultItem[];
97
+ }
98
+ export declare const validateAsyncapi: (document: AsyncAPI.Document) => Promise<AsyncapiValidateResult>;
99
+ /** JSON Pointer 段转义(`~` → `~0`,`/` → `~1`) */
100
+ export declare const encodeJsonPointerSegment: (segment: string) => string;
101
+ /**
102
+ * 确保 document 上存在某事件的 channel / message / operation 骨架(幂等)。
103
+ * 对齐 OpenAPI `parse-files` 预建 `pathItem` / `methodItem`。
104
+ */
105
+ export declare const ensureAsyncApiMessage: (document: AsyncAPI.Document, options: {
106
+ event: string;
107
+ action: 'receive' | 'send';
108
+ }) => {
109
+ channel: AsyncAPI.ChannelObject;
110
+ message: AsyncAPI.MessageObject;
111
+ operation: AsyncAPI.OperationObject;
112
+ };
package/dist/index.js ADDED
@@ -0,0 +1,318 @@
1
+ import { createRequire } from "node:module";
2
+ import { I18n, createI18n, middleware } from "@aomex/common";
3
+ import path from "node:path";
4
+ import { setTimeout } from "node:timers/promises";
5
+ import { terminal } from "@aomex/console";
6
+ import { Channel, SocketMiddleware } from "@aomex/websocket";
7
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
8
+ import { getFileValues, pathToFiles } from "@aomex/internal-file-import";
9
+ import YAML from "yaml";
10
+ import { bytes } from "@aomex/internal-tools";
11
+ // src/i18n/locales/zh-cn.ts
12
+ const zh = I18n.define({
13
+ initialize: "初始化文档",
14
+ search_channels_files: "搜索 Channel 文件",
15
+ parse_channels: "解析 Channel",
16
+ hand_fix_documentation: "手动修复文档",
17
+ save_to_file: "保存到文件",
18
+ validate: "验证文档",
19
+ help_summary: "AsyncAPI 3 文档生成器",
20
+ has_error: "{{error_count}} 个错误,{{warning_count}} 条警告",
21
+ no_error: "没有错误"
22
+ });
23
+ // src/i18n/locales/en-us.ts
24
+ const en = I18n.satisfies(zh).define({
25
+ initialize: "initialize document",
26
+ search_channels_files: "search Channel files",
27
+ parse_channels: "parse Channels",
28
+ hand_fix_documentation: "fix documentation by manual",
29
+ save_to_file: "save to file",
30
+ validate: "validate document",
31
+ help_summary: "AsyncAPI 3 documentation generator",
32
+ has_error: "{{error_count}} errors, {{warning_count}} warnings",
33
+ no_error: "No errors"
34
+ });
35
+ // src/i18n/index.ts
36
+ const i18n = createI18n({
37
+ zh,
38
+ en,
39
+ load: (file) => import(new URL(`./locales/${file}.js`, import.meta.url).href)
40
+ });
41
+ // src/lib/initialize-document.ts
42
+ /** 深拷贝 `docs` 并补上生成器要写的空骨架。`title` / `version` 为空时回退到 cwd 的 package.json。 */
43
+ const initializeDocument = async (basic) => {
44
+ const document = JSON.parse(JSON.stringify(basic));
45
+ const pkg = await readPackageJson();
46
+ document.info ||= {
47
+ title: "",
48
+ version: ""
49
+ };
50
+ document.info.title ||= pkg.name || "AsyncAPI";
51
+ document.info.version ||= pkg.version || "0.0.0";
52
+ document.channels = {};
53
+ document.operations = {};
54
+ document.components ||= {};
55
+ document.components.messages ||= {};
56
+ return document;
57
+ };
58
+ const readPackageJson = async () => {
59
+ try {
60
+ const content = await readFile(path.resolve("package.json"), "utf8");
61
+ const json = JSON.parse(content);
62
+ return json && typeof json === "object" ? json : {};
63
+ } catch {
64
+ return {};
65
+ }
66
+ };
67
+ // src/lib/write-message.ts
68
+ /** JSON Pointer 段转义(`~` → `~0`,`/` → `~1`) */
69
+ const encodeJsonPointerSegment = (segment) => segment.replaceAll("~", "~0").replaceAll("/", "~1");
70
+ const isRef = (value) => !!value && typeof value === "object" && "$ref" in value;
71
+ /**
72
+ * 确保 document 上存在某事件的 channel / message / operation 骨架(幂等)。
73
+ * 对齐 OpenAPI `parse-files` 预建 `pathItem` / `methodItem`。
74
+ */
75
+ const ensureAsyncApiMessage = (document, options) => {
76
+ const { event, action } = options;
77
+ const operationId = `${action}:${event}`;
78
+ const encoded = encodeJsonPointerSegment(event);
79
+ document.channels ||= {};
80
+ document.operations ||= {};
81
+ document.components ||= {};
82
+ document.components.messages ||= {};
83
+ const existingMessage = document.components.messages[event];
84
+ const message = existingMessage && !isRef(existingMessage) ? existingMessage : document.components.messages[event] = {
85
+ name: event,
86
+ contentType: "application/json"
87
+ };
88
+ const existingChannel = document.channels[event];
89
+ const channel = existingChannel && !isRef(existingChannel) ? existingChannel : document.channels[event] = {
90
+ address: event,
91
+ messages: {}
92
+ };
93
+ channel.messages ||= {};
94
+ channel.messages[event] ||= { $ref: `#/components/messages/${encoded}` };
95
+ const existingOperation = document.operations[operationId];
96
+ return {
97
+ channel,
98
+ message,
99
+ operation: existingOperation && !isRef(existingOperation) ? existingOperation : document.operations[operationId] = {
100
+ action,
101
+ channel: { $ref: `#/channels/${encoded}` },
102
+ messages: [{ $ref: `#/channels/${encoded}/messages/${encoded}` }]
103
+ }
104
+ };
105
+ };
106
+ // src/lib/parse-channels.ts
107
+ /**
108
+ * 遍历 Channel,预建入站骨架后按中间件链调用 `asyncapi()` 注入器。
109
+ * 顺序对齐 OpenAPI:先建骨架,再 `onDocument` → `onEvent` → `postEvent`(倒序) → `postDocument`(倒序)。
110
+ */
111
+ const parseChannels = (document, channels) => {
112
+ const entries = [];
113
+ for (const channel of channels) {
114
+ const channelMount = channel["middlewareList"];
115
+ for (const [event, handler] of channel["handlers"]) {
116
+ const list = [...channelMount, ...handler.middlewareList].filter((item) => item instanceof SocketMiddleware);
117
+ const receive = ensureAsyncApiMessage(document, {
118
+ event,
119
+ action: "receive"
120
+ });
121
+ entries.push({
122
+ event,
123
+ injectors: list.map((item) => item["asyncapi"]()),
124
+ ctx: createEventContext(document, event, receive)
125
+ });
126
+ }
127
+ }
128
+ for (const { injectors } of entries) for (const injector of injectors) injector.onDocument?.(document);
129
+ for (const { injectors, ctx } of entries) for (const injector of injectors) injector.onEvent?.(ctx);
130
+ for (const { injectors, ctx } of entries) for (let i = injectors.length - 1; i >= 0; i--) injectors[i].postEvent?.(ctx);
131
+ for (const { injectors } of entries) for (let i = injectors.length - 1; i >= 0; i--) injectors[i].postDocument?.(document);
132
+ };
133
+ const createEventContext = (document, event, receive) => ({
134
+ document,
135
+ event,
136
+ channel: receive.channel,
137
+ message: receive.message,
138
+ operation: receive.operation,
139
+ addSend(sendEvent, fill) {
140
+ const send = ensureAsyncApiMessage(document, {
141
+ event: sendEvent,
142
+ action: "send"
143
+ });
144
+ fill?.(send.message, send.operation);
145
+ }
146
+ });
147
+ // src/lib/resolve-channels.ts
148
+ /** 把 glob 或已实例化的 `Channel[]` 收成 Channel 列表。不从包入口导出。 */
149
+ const resolveChannels = async (options) => {
150
+ if (isChannelList(options)) return options;
151
+ const files = await pathToFiles(options);
152
+ return getFileValues(files, (item) => !!item && item instanceof Channel);
153
+ };
154
+ const isChannelList = (options) => {
155
+ if (!Array.isArray(options)) return false;
156
+ if (options.length === 0) return true;
157
+ return options[0] instanceof Channel;
158
+ };
159
+ // src/lib/save-to-file.ts
160
+ const saveToFile = async (document, filename, fileMode) => {
161
+ const dest = path.resolve(filename || "asyncapi.json");
162
+ const ext = path.extname(dest);
163
+ const content = ext.endsWith(".yaml") || ext.endsWith(".yml") ? YAML.stringify(document) : JSON.stringify(document);
164
+ const size = bytes(Buffer.byteLength(content), { unitSeparator: "" });
165
+ await mkdir(path.dirname(dest), { recursive: true });
166
+ await writeFile(dest, content, {
167
+ mode: fileMode,
168
+ flush: true
169
+ });
170
+ return {
171
+ dest,
172
+ size
173
+ };
174
+ };
175
+ // src/lib/validate-asyncapi.ts
176
+ const requireCJS = createRequire(import.meta.url);
177
+ let _spectral = null;
178
+ const initSpectral = () => {
179
+ if (!_spectral) {
180
+ const { Spectral } = requireCJS("@stoplight/spectral-core");
181
+ const { asyncapi } = requireCJS("@stoplight/spectral-rulesets");
182
+ _spectral = new Spectral();
183
+ _spectral.setRuleset({ extends: asyncapi });
184
+ }
185
+ return _spectral;
186
+ };
187
+ const validateAsyncapi = async (document) => {
188
+ const result = {
189
+ warnings: [],
190
+ errors: []
191
+ };
192
+ (await initSpectral().run(document)).forEach((item) => {
193
+ result[item.severity === 0 ? "errors" : "warnings"].push({
194
+ path: item.path.map(String),
195
+ message: item.message
196
+ });
197
+ });
198
+ return result;
199
+ };
200
+ // src/lib/generate-document-with-spinner.ts
201
+ /**
202
+ * 生成 → 保存 → 校验,并在终端展示步骤。
203
+ * 编程调用请优先用 {@link generateAsyncapi}。
204
+ */
205
+ const generateAsyncapiWithSpinner = async (config) => {
206
+ const { error, context } = await terminal.runTasks([
207
+ {
208
+ title: i18n.t("initialize"),
209
+ task: async (ctx) => {
210
+ ctx.document = await initializeDocument(config.docs);
211
+ }
212
+ },
213
+ {
214
+ title: i18n.t("search_channels_files"),
215
+ task: async (ctx, task) => {
216
+ if (isChannelList(config.channels)) {
217
+ ctx.channels = config.channels;
218
+ task.status = "skip";
219
+ return;
220
+ }
221
+ ctx.channels = await resolveChannels(config.channels);
222
+ await setTimeout(500);
223
+ }
224
+ },
225
+ {
226
+ title: i18n.t("parse_channels"),
227
+ task: async (ctx) => {
228
+ parseChannels(ctx.document, ctx.channels);
229
+ await setTimeout(500);
230
+ }
231
+ },
232
+ {
233
+ title: i18n.t("hand_fix_documentation"),
234
+ skip: !config.fix,
235
+ task: async (ctx) => {
236
+ await config.fix(ctx.document);
237
+ await setTimeout(500);
238
+ }
239
+ },
240
+ {
241
+ title: i18n.t("save_to_file"),
242
+ task: async (ctx, task) => {
243
+ const result = await saveToFile(ctx.document, config.saveToFile, config.fileMode);
244
+ task.suffix = terminal.style(["blue", "underline"], path.relative(process.cwd(), result.dest)) + terminal.style("green", ` [${result.size}]`);
245
+ }
246
+ },
247
+ {
248
+ title: i18n.t("validate"),
249
+ task: async (ctx, task) => {
250
+ const result = ctx.validateResult = await validateAsyncapi(ctx.document);
251
+ await setTimeout(500);
252
+ if (result.errors.length || result.warnings.length) task.suffix = terminal.style("yellow", i18n.t("has_error", {
253
+ error_count: result.errors.length,
254
+ warning_count: result.warnings.length
255
+ }));
256
+ else task.suffix = terminal.style("green", i18n.t("no_error"));
257
+ }
258
+ }
259
+ ]);
260
+ if (error) return null;
261
+ const logSession = terminal.createSession();
262
+ const { errors, warnings } = context.validateResult;
263
+ for (const item of errors) {
264
+ logSession.update(` %error% ${formatValidateMessage(item)}`);
265
+ logSession.commit();
266
+ }
267
+ for (const item of warnings) {
268
+ logSession.update(` %warning% ${formatValidateMessage(item)}`);
269
+ logSession.commit();
270
+ }
271
+ return JSON.parse(JSON.stringify(context.document));
272
+ };
273
+ const formatValidateMessage = (item) => {
274
+ const pathname = item.path.length ? item.path.join(".") : "";
275
+ return `${terminal.style("gray", `[${pathname || "."}]`)} ${item.message}`;
276
+ };
277
+ // src/asyncapi.ts
278
+ /**
279
+ * Console 中间件:生成 AsyncAPI 文档。
280
+ *
281
+ * ```ts
282
+ * import { asyncapi } from '@aomex/asyncapi-generator';
283
+ *
284
+ * asyncapi({
285
+ * commandName: 'asyncapi',
286
+ * channels: './src/channels',
287
+ * docs: { asyncapi: '3.1.0' },
288
+ * saveToFile: 'asyncapi.json',
289
+ * });
290
+ * ```
291
+ */
292
+ const asyncapi = (options) => {
293
+ const { commandName = "asyncapi" } = options;
294
+ return middleware.console({
295
+ fn: async (ctx, next) => {
296
+ if (ctx.input.command !== commandName) return next();
297
+ ctx.commandMatched = true;
298
+ await generateAsyncapiWithSpinner(options);
299
+ },
300
+ help: { onDocument(doc) {
301
+ doc[commandName] = { summary: i18n.t("help_summary") };
302
+ } }
303
+ });
304
+ };
305
+ // src/lib/generate-asyncapi.ts
306
+ /**
307
+ * 从 Channel 生成 AsyncAPI 3.x 文档。
308
+ */
309
+ const generateAsyncapi = async (config) => {
310
+ const document = await initializeDocument(config.docs);
311
+ const channels = await resolveChannels(config.channels);
312
+ parseChannels(document, channels);
313
+ await config.fix?.(document);
314
+ return JSON.parse(JSON.stringify(document));
315
+ };
316
+ export { asyncapi, encodeJsonPointerSegment, ensureAsyncApiMessage, generateAsyncapi, generateAsyncapiWithSpinner, initializeDocument, parseChannels, saveToFile, validateAsyncapi };
317
+
318
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["sleep"],"sources":["../src/i18n/locales/zh-cn.ts","../src/i18n/locales/en-us.ts","../src/i18n/index.ts","../src/lib/initialize-document.ts","../src/lib/write-message.ts","../src/lib/parse-channels.ts","../src/lib/resolve-channels.ts","../src/lib/save-to-file.ts","../src/lib/validate-asyncapi.ts","../src/lib/generate-document-with-spinner.ts","../src/asyncapi.ts","../src/lib/generate-asyncapi.ts"],"sourcesContent":["import { I18n } from '@aomex/common';\n\nexport const zh = I18n.define({\n initialize: '初始化文档',\n search_channels_files: '搜索 Channel 文件',\n parse_channels: '解析 Channel',\n hand_fix_documentation: '手动修复文档',\n save_to_file: '保存到文件',\n validate: '验证文档',\n help_summary: 'AsyncAPI 3 文档生成器',\n has_error: '{{error_count}} 个错误,{{warning_count}} 条警告',\n no_error: '没有错误',\n});\n","import { I18n } from '@aomex/common';\nimport { zh } from './zh-cn';\n\nexport const en = I18n.satisfies(zh).define({\n initialize: 'initialize document',\n search_channels_files: 'search Channel files',\n parse_channels: 'parse Channels',\n hand_fix_documentation: 'fix documentation by manual',\n save_to_file: 'save to file',\n validate: 'validate document',\n help_summary: 'AsyncAPI 3 documentation generator',\n has_error: '{{error_count}} errors, {{warning_count}} warnings',\n no_error: 'No errors',\n});\n","import { createI18n } from '@aomex/common';\nimport { zh } from './locales/zh-cn';\nimport { en } from './locales/en-us';\n\nexport const i18n = createI18n({\n zh,\n en,\n load: (file) => import(new URL(`./locales/${file}.js`, import.meta.url).href),\n});\n","import { readFile } from 'node:fs/promises';\nimport path from 'node:path';\nimport type { AsyncAPI } from '@aomex/common';\nimport type { GenerateAsyncapiOptions } from './generate-asyncapi';\n\n/** 深拷贝 `docs` 并补上生成器要写的空骨架。`title` / `version` 为空时回退到 cwd 的 package.json。 */\nexport const initializeDocument = async (\n basic: GenerateAsyncapiOptions['docs'],\n): Promise<AsyncAPI.Document> => {\n const document: AsyncAPI.Document = JSON.parse(JSON.stringify(basic));\n const pkg = await readPackageJson();\n document.info ||= { title: '', version: '' };\n document.info.title ||= pkg.name || 'AsyncAPI';\n document.info.version ||= pkg.version || '0.0.0';\n document.channels = {};\n document.operations = {};\n document.components ||= {};\n document.components.messages ||= {};\n return document;\n};\n\nconst readPackageJson = async (): Promise<{ name?: string; version?: string }> => {\n try {\n const content = await readFile(path.resolve('package.json'), 'utf8');\n const json = JSON.parse(content);\n return json && typeof json === 'object' ? json : {};\n } catch {\n return {};\n }\n};\n","import type { AsyncAPI } from '@aomex/common';\n\n/** JSON Pointer 段转义(`~` → `~0`,`/` → `~1`) */\nexport const encodeJsonPointerSegment = (segment: string): string =>\n segment.replaceAll('~', '~0').replaceAll('/', '~1');\n\nconst isRef = (value: unknown): value is AsyncAPI.ReferenceObject =>\n !!value && typeof value === 'object' && '$ref' in value;\n\n/**\n * 确保 document 上存在某事件的 channel / message / operation 骨架(幂等)。\n * 对齐 OpenAPI `parse-files` 预建 `pathItem` / `methodItem`。\n */\nexport const ensureAsyncApiMessage = (\n document: AsyncAPI.Document,\n options: {\n event: string;\n action: 'receive' | 'send';\n },\n): {\n channel: AsyncAPI.ChannelObject;\n message: AsyncAPI.MessageObject;\n operation: AsyncAPI.OperationObject;\n} => {\n const { event, action } = options;\n const operationId = `${action}:${event}`;\n const encoded = encodeJsonPointerSegment(event);\n\n document.channels ||= {};\n document.operations ||= {};\n document.components ||= {};\n document.components.messages ||= {};\n\n const existingMessage = document.components.messages[event];\n const message: AsyncAPI.MessageObject =\n existingMessage && !isRef(existingMessage)\n ? existingMessage\n : (document.components.messages[event] = {\n name: event,\n contentType: 'application/json',\n });\n\n const existingChannel = document.channels[event];\n const channel: AsyncAPI.ChannelObject =\n existingChannel && !isRef(existingChannel)\n ? existingChannel\n : (document.channels[event] = {\n address: event,\n messages: {},\n });\n channel.messages ||= {};\n channel.messages[event] ||= {\n $ref: `#/components/messages/${encoded}`,\n };\n\n const existingOperation = document.operations[operationId];\n const operation: AsyncAPI.OperationObject =\n existingOperation && !isRef(existingOperation)\n ? existingOperation\n : (document.operations[operationId] = {\n action,\n channel: { $ref: `#/channels/${encoded}` },\n messages: [\n {\n $ref: `#/channels/${encoded}/messages/${encoded}`,\n },\n ],\n });\n\n return { channel, message, operation };\n};\n","import type { AsyncAPI } from '@aomex/common';\nimport {\n Channel,\n SocketMiddleware,\n type AsyncApiEventContext,\n type AsyncApiInjector,\n} from '@aomex/websocket';\nimport { ensureAsyncApiMessage } from './write-message';\n\ntype EventEntry = {\n event: string;\n injectors: AsyncApiInjector[];\n ctx: AsyncApiEventContext;\n};\n\n/**\n * 遍历 Channel,预建入站骨架后按中间件链调用 `asyncapi()` 注入器。\n * 顺序对齐 OpenAPI:先建骨架,再 `onDocument` → `onEvent` → `postEvent`(倒序) → `postDocument`(倒序)。\n */\nexport const parseChannels = (document: AsyncAPI.Document, channels: Channel[]): void => {\n const entries: EventEntry[] = [];\n\n for (const channel of channels) {\n const channelMount = channel['middlewareList'];\n for (const [event, handler] of channel['handlers']) {\n const list = [...channelMount, ...handler.middlewareList].filter(\n (item): item is SocketMiddleware => item instanceof SocketMiddleware,\n );\n const receive = ensureAsyncApiMessage(document, { event, action: 'receive' });\n entries.push({\n event,\n injectors: list.map((item) => item['asyncapi']()),\n ctx: createEventContext(document, event, receive),\n });\n }\n }\n\n for (const { injectors } of entries) {\n for (const injector of injectors) {\n injector.onDocument?.(document);\n }\n }\n\n for (const { injectors, ctx } of entries) {\n for (const injector of injectors) {\n injector.onEvent?.(ctx);\n }\n }\n\n for (const { injectors, ctx } of entries) {\n for (let i = injectors.length - 1; i >= 0; i--) {\n injectors[i]!.postEvent?.(ctx);\n }\n }\n\n for (const { injectors } of entries) {\n for (let i = injectors.length - 1; i >= 0; i--) {\n injectors[i]!.postDocument?.(document);\n }\n }\n};\n\nconst createEventContext = (\n document: AsyncAPI.Document,\n event: string,\n receive: {\n channel: AsyncAPI.ChannelObject;\n message: AsyncAPI.MessageObject;\n operation: AsyncAPI.OperationObject;\n },\n): AsyncApiEventContext => ({\n document,\n event,\n channel: receive.channel,\n message: receive.message,\n operation: receive.operation,\n addSend(sendEvent, fill) {\n const send = ensureAsyncApiMessage(document, {\n event: sendEvent,\n action: 'send',\n });\n fill?.(send.message, send.operation);\n },\n});\n","import {\n pathToFiles,\n getFileValues,\n type GlobPathOptions,\n} from '@aomex/internal-file-import';\nimport { Channel } from '@aomex/websocket';\n\n/** 把 glob 或已实例化的 `Channel[]` 收成 Channel 列表。不从包入口导出。 */\nexport const resolveChannels = async (\n options: GlobPathOptions | Channel[],\n): Promise<Channel[]> => {\n if (isChannelList(options)) return options;\n const files = await pathToFiles(options);\n return getFileValues<Channel>(files, (item) => !!item && item instanceof Channel);\n};\n\nexport const isChannelList = (\n options: GlobPathOptions | Channel[],\n): options is Channel[] => {\n if (!Array.isArray(options)) return false;\n if (options.length === 0) return true;\n return options[0] instanceof Channel;\n};\n","import path from 'node:path';\nimport { mkdir, writeFile } from 'node:fs/promises';\nimport type { Mode } from 'node:fs';\nimport YAML from 'yaml';\nimport { bytes } from '@aomex/internal-tools';\nimport type { AsyncAPI } from '@aomex/common';\n\nexport const saveToFile = async (\n document: AsyncAPI.Document,\n filename?: string,\n fileMode?: Mode,\n) => {\n const dest = path.resolve(filename || 'asyncapi.json');\n const ext = path.extname(dest);\n const content =\n ext.endsWith('.yaml') || ext.endsWith('.yml')\n ? YAML.stringify(document)\n : JSON.stringify(document);\n const size = bytes(Buffer.byteLength(content), { unitSeparator: '' });\n\n await mkdir(path.dirname(dest), { recursive: true });\n await writeFile(dest, content, { mode: fileMode, flush: true });\n\n return { dest, size };\n};\n","import type { AsyncAPI } from '@aomex/common';\nimport type spectral from '@stoplight/spectral-core';\nimport type ruleset from '@stoplight/spectral-rulesets';\nimport { createRequire } from 'node:module';\n\nconst requireCJS = createRequire(import.meta.url);\n\nenum DiagnosticSeverity {\n Error = 0,\n Warning = 1,\n Information = 2,\n Hint = 3,\n}\n\nlet _spectral: spectral.Spectral | null = null;\nconst initSpectral = () => {\n if (!_spectral) {\n const { Spectral } = requireCJS('@stoplight/spectral-core') as typeof spectral;\n const { asyncapi } = requireCJS('@stoplight/spectral-rulesets') as typeof ruleset;\n _spectral = new Spectral();\n _spectral.setRuleset({\n extends: asyncapi as spectral.RulesetDefinition,\n });\n }\n return _spectral;\n};\n\nexport interface AsyncapiValidateResultItem {\n path: string[];\n message: string;\n}\n\nexport interface AsyncapiValidateResult {\n errors: AsyncapiValidateResultItem[];\n warnings: AsyncapiValidateResultItem[];\n}\n\nexport const validateAsyncapi = async (document: AsyncAPI.Document) => {\n const result: AsyncapiValidateResult = { warnings: [], errors: [] };\n const spectral = initSpectral();\n const originResult = await spectral.run(document as unknown as Record<string, unknown>);\n originResult.forEach((item) => {\n result[item.severity === DiagnosticSeverity.Error ? 'errors' : 'warnings'].push({\n path: item.path.map(String),\n message: item.message,\n });\n });\n return result;\n};\n","import type { Mode } from 'node:fs';\nimport path from 'node:path';\nimport { setTimeout as sleep } from 'node:timers/promises';\nimport { terminal } from '@aomex/console';\nimport type { AsyncAPI } from '@aomex/common';\nimport { Channel } from '@aomex/websocket';\nimport { i18n } from '../i18n';\nimport type { GenerateAsyncapiOptions } from './generate-asyncapi';\nimport { initializeDocument } from './initialize-document';\nimport { parseChannels } from './parse-channels';\nimport { isChannelList, resolveChannels } from './resolve-channels';\nimport { saveToFile } from './save-to-file';\nimport {\n validateAsyncapi,\n type AsyncapiValidateResult,\n type AsyncapiValidateResultItem,\n} from './validate-asyncapi';\n\nexport interface GenerateAsyncapiWithSpinnerOptions extends GenerateAsyncapiOptions {\n /**\n * 保存到指定文件。默认值:`asyncapi.json`\n * - `*.json` 保存为 JSON\n * - `*.yaml` / `*.yml` 保存为 YAML\n */\n saveToFile?: string;\n /**\n * 设置保存文件的系统权限。\n */\n fileMode?: Mode;\n}\n\ninterface SpinnerContext {\n document: AsyncAPI.Document;\n channels: Channel[];\n validateResult: AsyncapiValidateResult;\n}\n\n/**\n * 生成 → 保存 → 校验,并在终端展示步骤。\n * 编程调用请优先用 {@link generateAsyncapi}。\n */\nexport const generateAsyncapiWithSpinner = async (\n config: GenerateAsyncapiWithSpinnerOptions,\n): Promise<AsyncAPI.Document | null> => {\n const { error, context } = await terminal.runTasks<SpinnerContext>([\n {\n title: i18n.t('initialize'),\n task: async (ctx) => {\n ctx.document = await initializeDocument(config.docs);\n },\n },\n {\n title: i18n.t('search_channels_files'),\n task: async (ctx, task) => {\n if (isChannelList(config.channels)) {\n ctx.channels = config.channels;\n task.status = 'skip';\n return;\n }\n ctx.channels = await resolveChannels(config.channels);\n await sleep(500);\n },\n },\n {\n title: i18n.t('parse_channels'),\n task: async (ctx) => {\n parseChannels(ctx.document, ctx.channels);\n await sleep(500);\n },\n },\n {\n title: i18n.t('hand_fix_documentation'),\n skip: !config.fix,\n task: async (ctx) => {\n await config.fix!(ctx.document);\n await sleep(500);\n },\n },\n {\n title: i18n.t('save_to_file'),\n task: async (ctx, task) => {\n const result = await saveToFile(ctx.document, config.saveToFile, config.fileMode);\n task.suffix =\n terminal.style(\n ['blue', 'underline'],\n path.relative(process.cwd(), result.dest),\n ) + terminal.style('green', ` [${result.size}]`);\n },\n },\n {\n title: i18n.t('validate'),\n task: async (ctx, task) => {\n const result = (ctx.validateResult = await validateAsyncapi(ctx.document));\n await sleep(500);\n if (result.errors.length || result.warnings.length) {\n task.suffix = terminal.style(\n 'yellow',\n i18n.t('has_error', {\n error_count: result.errors.length,\n warning_count: result.warnings.length,\n }),\n );\n } else {\n task.suffix = terminal.style('green', i18n.t('no_error'));\n }\n },\n },\n ]);\n\n if (error) return null;\n\n const logSession = terminal.createSession();\n const { errors, warnings } = context.validateResult;\n for (const item of errors) {\n logSession.update(` %error% ${formatValidateMessage(item)}`);\n logSession.commit();\n }\n for (const item of warnings) {\n logSession.update(` %warning% ${formatValidateMessage(item)}`);\n logSession.commit();\n }\n\n return JSON.parse(JSON.stringify(context.document));\n};\n\nconst formatValidateMessage = (item: AsyncapiValidateResultItem) => {\n const pathname = item.path.length ? item.path.join('.') : '';\n return `${terminal.style('gray', `[${pathname || '.'}]`)} ${item.message}`;\n};\n","import { middleware } from '@aomex/common';\nimport type { ConsoleMiddleware } from '@aomex/console';\nimport {\n generateAsyncapiWithSpinner,\n type GenerateAsyncapiWithSpinnerOptions,\n} from './lib/generate-document-with-spinner';\nimport { i18n } from './i18n';\n\nexport interface AsyncapiOptions extends GenerateAsyncapiWithSpinnerOptions {\n /**\n * 指令名称。默认值:`asyncapi`\n */\n commandName?: string;\n}\n\n/**\n * Console 中间件:生成 AsyncAPI 文档。\n *\n * ```ts\n * import { asyncapi } from '@aomex/asyncapi-generator';\n *\n * asyncapi({\n * commandName: 'asyncapi',\n * channels: './src/channels',\n * docs: { asyncapi: '3.1.0' },\n * saveToFile: 'asyncapi.json',\n * });\n * ```\n */\nexport const asyncapi = (options: AsyncapiOptions): ConsoleMiddleware => {\n const { commandName = 'asyncapi' } = options;\n\n return middleware.console({\n fn: async (ctx, next) => {\n if (ctx.input.command !== commandName) return next();\n ctx.commandMatched = true;\n await generateAsyncapiWithSpinner(options);\n },\n help: {\n onDocument(doc) {\n doc[commandName] = {\n summary: i18n.t('help_summary'),\n };\n },\n },\n });\n};\n","import type { GlobPathOptions } from '@aomex/internal-file-import';\nimport type { AsyncAPI } from '@aomex/common';\nimport { Channel } from '@aomex/websocket';\nimport { initializeDocument } from './initialize-document';\nimport { parseChannels } from './parse-channels';\nimport { resolveChannels } from './resolve-channels';\n\nexport interface GenerateAsyncapiOptions {\n /**\n * Channel 来源:目录 glob,或已实例化的 `Channel[]`。\n *\n * ```ts\n * generateAsyncapi({\n * channels: './src/channels',\n * docs: { asyncapi: '3.1.0' },\n * });\n * generateAsyncapi({\n * channels: [channel],\n * docs: { asyncapi: '3.1.0' },\n * });\n * ```\n */\n channels: GlobPathOptions | Channel[];\n /**\n * AsyncAPI 基础信息(会与空文档骨架合并)。\n * `asyncapi` 版本须由调用方显式填写(`3.0.0` / `3.1.0`)。\n * `channels` / `operations` / `components` 由生成器写入;\n * `servers`、`id`、`defaultContentType` 以及 `info` 的其余字段会保留。\n */\n docs: {\n asyncapi: AsyncAPI.Document['asyncapi'];\n info?: Partial<AsyncAPI.InfoObject>;\n } & Omit<\n AsyncAPI.Document,\n 'asyncapi' | 'info' | 'channels' | 'operations' | 'components'\n >;\n /**\n * 手动修复文档内容。\n */\n fix?: (data: AsyncAPI.Document) => void | Promise<void>;\n}\n\n/**\n * 从 Channel 生成 AsyncAPI 3.x 文档。\n */\nexport const generateAsyncapi = async (\n config: GenerateAsyncapiOptions,\n): Promise<AsyncAPI.Document> => {\n const document = await initializeDocument(config.docs);\n const channels = await resolveChannels(config.channels);\n parseChannels(document, channels);\n await config.fix?.(document);\n return JSON.parse(JSON.stringify(document));\n};\n"],"mappings":";;;;;;;;;;;AAEA,MAAa,KAAK,KAAK,OAAO;CAC5B,YAAY;CACZ,uBAAuB;CACvB,gBAAgB;CAChB,wBAAwB;CACxB,cAAc;CACd,UAAU;CACV,cAAc;CACd,WAAW;CACX,UAAU;AACZ,CAAC;;ACTD,MAAa,KAAK,KAAK,UAAU,EAAE,CAAC,CAAC,OAAO;CAC1C,YAAY;CACZ,uBAAuB;CACvB,gBAAgB;CAChB,wBAAwB;CACxB,cAAc;CACd,UAAU;CACV,cAAc;CACd,WAAW;CACX,UAAU;AACZ,CAAC;;ACTD,MAAa,OAAO,WAAW;CAC7B;CACA;CACA,OAAO,SAAS,OAAO,IAAI,IAAI,aAAa,KAAK,MAAM,YAAY,GAAG,CAAC,CAAC;AAC1E,CAAC;;;ACFD,MAAa,qBAAqB,OAChC,UAC+B;CAC/B,MAAM,WAA8B,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC;CACpE,MAAM,MAAM,MAAM,gBAAgB;CAClC,SAAS,SAAS;EAAE,OAAO;EAAI,SAAS;CAAG;CAC3C,SAAS,KAAK,UAAU,IAAI,QAAQ;CACpC,SAAS,KAAK,YAAY,IAAI,WAAW;CACzC,SAAS,WAAW,CAAC;CACrB,SAAS,aAAa,CAAC;CACvB,SAAS,eAAe,CAAC;CACzB,SAAS,WAAW,aAAa,CAAC;CAClC,OAAO;AACT;AAEA,MAAM,kBAAkB,YAA0D;CAChF,IAAI;EACF,MAAM,UAAU,MAAM,SAAS,KAAK,QAAQ,cAAc,GAAG,MAAM;EACnE,MAAM,OAAO,KAAK,MAAM,OAAO;EAC/B,OAAO,QAAQ,OAAO,SAAS,WAAW,OAAO,CAAC;CACpD,QAAQ;EACN,OAAO,CAAC;CACV;AACF;;;AC1BA,MAAa,4BAA4B,YACvC,QAAQ,WAAW,KAAK,IAAI,CAAC,CAAC,WAAW,KAAK,IAAI;AA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;CAC1C,MAAM,EAAE,QAAQ,aAAa,QAAQ;CACrC,KAAK,MAAM,QAAQ,QAAQ;EACzB,WAAW,OAAO,aAAa,sBAAsB,IAAI,GAAG;EAC5D,WAAW,OAAO;CACpB;CACA,KAAK,MAAM,QAAQ,UAAU;EAC3B,WAAW,OAAO,eAAe,sBAAsB,IAAI,GAAG;EAC9D,WAAW,OAAO;CACpB;CAEA,OAAO,KAAK,MAAM,KAAK,UAAU,QAAQ,QAAQ,CAAC;AACpD;AAEA,MAAM,yBAAyB,SAAqC;CAClE,MAAM,WAAW,KAAK,KAAK,SAAS,KAAK,KAAK,KAAK,GAAG,IAAI;CAC1D,OAAO,GAAG,SAAS,MAAM,QAAQ,IAAI,YAAY,IAAI,EAAE,EAAE,GAAG,KAAK;AACnE;;;;;;;;;;;;;;;;ACnGA,MAAa,YAAY,YAAgD;CACvE,MAAM,EAAE,cAAc,eAAe;CAErC,OAAO,WAAW,QAAQ;EACxB,IAAI,OAAO,KAAK,SAAS;GACvB,IAAI,IAAI,MAAM,YAAY,aAAa,OAAO,KAAK;GACnD,IAAI,iBAAiB;GACrB,MAAM,4BAA4B,OAAO;EAC3C;EACA,MAAM,EACJ,WAAW,KAAK;GACd,IAAI,eAAe,EACjB,SAAS,KAAK,EAAE,cAAc,EAChC;EACF,EACF;CACF,CAAC;AACH;;;;;ACDA,MAAa,mBAAmB,OAC9B,WAC+B;CAC/B,MAAM,WAAW,MAAM,mBAAmB,OAAO,IAAI;CACrD,MAAM,WAAW,MAAM,gBAAgB,OAAO,QAAQ;CACtD,cAAc,UAAU,QAAQ;CAChC,MAAM,OAAO,MAAM,QAAQ;CAC3B,OAAO,KAAK,MAAM,KAAK,UAAU,QAAQ,CAAC;AAC5C"}
package/package.json CHANGED
@@ -1,6 +1,54 @@
1
1
  {
2
2
  "name": "@aomex/asyncapi-generator",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "4.4.1-alpha.c1419fd5.0",
4
+ "description": "AsyncAPI 文档生成工具",
5
+ "type": "module",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js"
11
+ },
12
+ "./package.json": "./package.json"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "LICENSE",
20
+ "package.json",
21
+ "README.md",
22
+ "CHANGELOG.md"
23
+ ],
24
+ "keywords": [],
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git@github.com:aomex/aomex.git"
28
+ },
29
+ "homepage": "https://aomex.js.org",
30
+ "license": "MIT",
31
+ "peerDependencies": {
32
+ "@aomex/common": "^4.0.0",
33
+ "@aomex/console": "^4.0.0",
34
+ "@aomex/websocket": "^4.0.0"
35
+ },
36
+ "peerDependenciesMeta": {
37
+ "@aomex/console": {
38
+ "optional": true
39
+ }
40
+ },
41
+ "dependencies": {
42
+ "@aomex/internal-file-import": "4.4.1-alpha.c1419fd5.0",
43
+ "@aomex/internal-tools": "4.4.1-alpha.c1419fd5.0",
44
+ "@stoplight/spectral-core": "^1.24.1",
45
+ "@stoplight/spectral-rulesets": "^1.23.1",
46
+ "yaml": "^2.9.1"
47
+ },
48
+ "devDependencies": {
49
+ "@aomex/common": "4.4.1-alpha.c1419fd5.0",
50
+ "@aomex/console": "4.4.1-alpha.c1419fd5.0",
51
+ "@aomex/websocket": "4.4.1-alpha.c1419fd5.0"
52
+ },
53
+ "scripts": {}
6
54
  }