@nocobase/server 2.1.0-beta.26 → 2.1.0-beta.29

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.
@@ -30,11 +30,6 @@ __export(ai_exports, {
30
30
  default: () => ai_default
31
31
  });
32
32
  module.exports = __toCommonJS(ai_exports);
33
- var import_create_docs_index = require("../ai/create-docs-index");
34
33
  var ai_default = /* @__PURE__ */ __name((app) => {
35
- const ai = app.command("ai");
36
- ai.command("create-docs-index").option("--pkg [pkg]", "Generate docs index for the specified plugin package (comma separated).").action(async (...cliArgs) => {
37
- const [opts] = cliArgs;
38
- await (0, import_create_docs_index.createDocsIndex)(app, opts);
39
- });
34
+ app.command("ai");
40
35
  }, "default");
@@ -30,16 +30,12 @@ __export(install_exports, {
30
30
  default: () => install_default
31
31
  });
32
32
  module.exports = __toCommonJS(install_exports);
33
- var import_create_docs_index = require("../ai/create-docs-index");
34
33
  /* istanbul ignore file -- @preserve */
35
34
  var install_default = /* @__PURE__ */ __name((app) => {
36
35
  app.command("install").ipc().auth().option("-f, --force").option("-c, --clean").option("--lang <lang>").action(async (options) => {
37
36
  if (options.lang) {
38
37
  process.env.INIT_APP_LANG = options.lang;
39
38
  }
40
- if (!process.env.VITEST) {
41
- await (0, import_create_docs_index.createDocsIndex)(app);
42
- }
43
39
  await app.install(options);
44
40
  const reinstall = options.clean || options.force;
45
41
  app.log.info(`app ${reinstall ? "reinstalled" : "installed"} successfully [v${app.getVersion()}]`);
@@ -42,7 +42,6 @@ __export(start_exports, {
42
42
  module.exports = __toCommonJS(start_exports);
43
43
  var import_fs_extra = __toESM(require("fs-extra"));
44
44
  var import_utils = require("@nocobase/utils");
45
- var import_create_docs_index = require("../ai/create-docs-index");
46
45
  var import_application_not_install = require("../errors/application-not-install");
47
46
  /* istanbul ignore file -- @preserve */
48
47
  var start_default = /* @__PURE__ */ __name((app) => {
@@ -53,7 +52,6 @@ var start_default = /* @__PURE__ */ __name((app) => {
53
52
  if (upgrading) {
54
53
  if (!process.env.VITEST) {
55
54
  if (await app.isInstalled()) {
56
- await (0, import_create_docs_index.createDocsIndex)(app);
57
55
  await app.upgrade();
58
56
  }
59
57
  }
@@ -62,7 +60,6 @@ var start_default = /* @__PURE__ */ __name((app) => {
62
60
  } catch (error) {
63
61
  }
64
62
  } else if (options.quickstart) {
65
- await (0, import_create_docs_index.createDocsIndex)(app);
66
63
  if (await app.isInstalled()) {
67
64
  await app.upgrade({ quickstart: true });
68
65
  } else {
@@ -30,13 +30,9 @@ __export(upgrade_exports, {
30
30
  default: () => upgrade_default
31
31
  });
32
32
  module.exports = __toCommonJS(upgrade_exports);
33
- var import_create_docs_index = require("../ai/create-docs-index");
34
33
  /* istanbul ignore file -- @preserve */
35
34
  var upgrade_default = /* @__PURE__ */ __name((app) => {
36
35
  app.command("upgrade").ipc().auth().action(async (options) => {
37
- if (!process.env.VITEST) {
38
- await (0, import_create_docs_index.createDocsIndex)(app);
39
- }
40
36
  await app.upgrade(options);
41
37
  app.log.info(`\u2728 NocoBase has been upgraded to v${app.getVersion()}`);
42
38
  });
@@ -60,6 +60,8 @@ export declare class Gateway extends EventEmitter {
60
60
  private socketPath;
61
61
  private v2IndexTemplateCache;
62
62
  private terminating;
63
+ private getOriginalRequestUrl;
64
+ private proxyRequestToSubApp;
63
65
  private onTerminate;
64
66
  private constructor();
65
67
  static getInstance(options?: any): Gateway;
@@ -103,6 +103,18 @@ const _Gateway = class _Gateway extends import_events.EventEmitter {
103
103
  socketPath = getSocketPath();
104
104
  v2IndexTemplateCache = null;
105
105
  terminating = false;
106
+ getOriginalRequestUrl(req) {
107
+ return req.originalUrl || req.url;
108
+ }
109
+ async proxyRequestToSubApp(supervisor, appName, req, res) {
110
+ const internalUrl = req.url;
111
+ req.url = this.getOriginalRequestUrl(req);
112
+ try {
113
+ return await supervisor.proxyWeb(appName, req, res);
114
+ } finally {
115
+ req.url = internalUrl;
116
+ }
117
+ }
106
118
  onTerminate = /* @__PURE__ */ __name(async (signal) => {
107
119
  var _a;
108
120
  if (this.terminating) {
@@ -340,7 +352,7 @@ const _Gateway = class _Gateway extends import_events.EventEmitter {
340
352
  }
341
353
  if (pathname.startsWith(APP_PUBLIC_PATH + "storage/uploads/")) {
342
354
  if (handleApp !== "main") {
343
- const isProxy = await supervisor.proxyWeb(handleApp, req, res);
355
+ const isProxy = await this.proxyRequestToSubApp(supervisor, handleApp, req, res);
344
356
  if (isProxy) {
345
357
  return;
346
358
  }
@@ -354,7 +366,7 @@ const _Gateway = class _Gateway extends import_events.EventEmitter {
354
366
  }
355
367
  if (pathname.startsWith(PLUGIN_STATICS_PATH) && !pathname.includes("/server/")) {
356
368
  if (handleApp !== "main") {
357
- const isProxy = await supervisor.proxyWeb(handleApp, req, res);
369
+ const isProxy = await this.proxyRequestToSubApp(supervisor, handleApp, req, res);
358
370
  if (isProxy) {
359
371
  return;
360
372
  }
@@ -376,7 +388,7 @@ const _Gateway = class _Gateway extends import_events.EventEmitter {
376
388
  if (!pathname.startsWith(import_node_process.default.env.API_BASE_PATH)) {
377
389
  if (this.isV2Request(pathname)) {
378
390
  if (handleApp !== "main") {
379
- const isProxy = await supervisor.proxyWeb(handleApp, req, res);
391
+ const isProxy = await this.proxyRequestToSubApp(supervisor, handleApp, req, res);
380
392
  if (isProxy) {
381
393
  return;
382
394
  }
@@ -396,7 +408,7 @@ const _Gateway = class _Gateway extends import_events.EventEmitter {
396
408
  });
397
409
  }
398
410
  if (handleApp !== "main") {
399
- const isProxy = await supervisor.proxyWeb(handleApp, req, res);
411
+ const isProxy = await this.proxyRequestToSubApp(supervisor, handleApp, req, res);
400
412
  if (isProxy) {
401
413
  return;
402
414
  }
@@ -409,7 +421,7 @@ const _Gateway = class _Gateway extends import_events.EventEmitter {
409
421
  });
410
422
  }
411
423
  if (handleApp !== "main") {
412
- const isProxy = await supervisor.proxyWeb(handleApp, req, res);
424
+ const isProxy = await this.proxyRequestToSubApp(supervisor, handleApp, req, res);
413
425
  if (isProxy) {
414
426
  return;
415
427
  }
@@ -96,6 +96,7 @@ const _MainDataSource = class _MainDataSource extends import_data_source_manager
96
96
  const results = await this.tables2Collections(toAddTables);
97
97
  const values = results.map((result) => ({
98
98
  ...result,
99
+ from: "dbsync",
99
100
  underscored: false
100
101
  }));
101
102
  await repo.create({ values, context: ctx });
@@ -115,10 +116,12 @@ const _MainDataSource = class _MainDataSource extends import_data_source_manager
115
116
  ...filter
116
117
  }
117
118
  });
118
- const collections = loadedCollections.filter((collection) => {
119
- var _a;
120
- return ((_a = collection.options) == null ? void 0 : _a.from) !== "db2cm";
121
- });
119
+ const collections = loadedCollections.filter(
120
+ (collection) => {
121
+ var _a;
122
+ return !["db2cm", "dbsync"].includes((_a = collection.options) == null ? void 0 : _a.from);
123
+ }
124
+ );
122
125
  const loadedData = {};
123
126
  for (const collection of collections) {
124
127
  const c = db.getCollection(collection.name);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/server",
3
- "version": "2.1.0-beta.26",
3
+ "version": "2.1.0-beta.29",
4
4
  "main": "lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "license": "Apache-2.0",
@@ -10,21 +10,21 @@
10
10
  "@koa/cors": "^5.0.0",
11
11
  "@koa/multer": "^3.1.0",
12
12
  "@koa/router": "^13.1.0",
13
- "@nocobase/acl": "2.1.0-beta.26",
14
- "@nocobase/actions": "2.1.0-beta.26",
15
- "@nocobase/ai": "2.1.0-beta.26",
16
- "@nocobase/auth": "2.1.0-beta.26",
17
- "@nocobase/cache": "2.1.0-beta.26",
18
- "@nocobase/data-source-manager": "2.1.0-beta.26",
19
- "@nocobase/database": "2.1.0-beta.26",
20
- "@nocobase/evaluators": "2.1.0-beta.26",
21
- "@nocobase/lock-manager": "2.1.0-beta.26",
22
- "@nocobase/logger": "2.1.0-beta.26",
23
- "@nocobase/resourcer": "2.1.0-beta.26",
24
- "@nocobase/sdk": "2.1.0-beta.26",
25
- "@nocobase/snowflake-id": "2.1.0-beta.26",
26
- "@nocobase/telemetry": "2.1.0-beta.26",
27
- "@nocobase/utils": "2.1.0-beta.26",
13
+ "@nocobase/acl": "2.1.0-beta.29",
14
+ "@nocobase/actions": "2.1.0-beta.29",
15
+ "@nocobase/ai": "2.1.0-beta.29",
16
+ "@nocobase/auth": "2.1.0-beta.29",
17
+ "@nocobase/cache": "2.1.0-beta.29",
18
+ "@nocobase/data-source-manager": "2.1.0-beta.29",
19
+ "@nocobase/database": "2.1.0-beta.29",
20
+ "@nocobase/evaluators": "2.1.0-beta.29",
21
+ "@nocobase/lock-manager": "2.1.0-beta.29",
22
+ "@nocobase/logger": "2.1.0-beta.29",
23
+ "@nocobase/resourcer": "2.1.0-beta.29",
24
+ "@nocobase/sdk": "2.1.0-beta.29",
25
+ "@nocobase/snowflake-id": "2.1.0-beta.29",
26
+ "@nocobase/telemetry": "2.1.0-beta.29",
27
+ "@nocobase/utils": "2.1.0-beta.29",
28
28
  "@types/decompress": "4.2.7",
29
29
  "@types/ini": "^1.3.31",
30
30
  "@types/koa-send": "^4.1.3",
@@ -61,5 +61,5 @@
61
61
  "@types/serve-handler": "^6.1.1",
62
62
  "@types/ws": "^8.5.5"
63
63
  },
64
- "gitHead": "b17e1a72057813fa27d8435bf0f2af67ea4b059f"
64
+ "gitHead": "86c41be29dcbcac6fd6aa46b4a137ef07a27c1d0"
65
65
  }
@@ -1,13 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
- import type Application from '../application';
10
- export type DocsIndexOptions = {
11
- pkg?: string | string[];
12
- };
13
- export declare function createDocsIndex(app: Application, options?: DocsIndexOptions): Promise<void>;
@@ -1,893 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
-
10
- var __create = Object.create;
11
- var __defProp = Object.defineProperty;
12
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
- var __getOwnPropNames = Object.getOwnPropertyNames;
14
- var __getProtoOf = Object.getPrototypeOf;
15
- var __hasOwnProp = Object.prototype.hasOwnProperty;
16
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
17
- var __export = (target, all) => {
18
- for (var name in all)
19
- __defProp(target, name, { get: all[name], enumerable: true });
20
- };
21
- var __copyProps = (to, from, except, desc) => {
22
- if (from && typeof from === "object" || typeof from === "function") {
23
- for (let key of __getOwnPropNames(from))
24
- if (!__hasOwnProp.call(to, key) && key !== except)
25
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
26
- }
27
- return to;
28
- };
29
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
30
- // If the importer is in node compatibility mode or this is not an ESM
31
- // file that has been converted to a CommonJS file using a Babel-
32
- // compatible transform (i.e. "__esModule" has not been set), then set
33
- // "default" to the CommonJS "module.exports" for node compatibility.
34
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
- mod
36
- ));
37
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
- var create_docs_index_exports = {};
39
- __export(create_docs_index_exports, {
40
- createDocsIndex: () => createDocsIndex
41
- });
42
- module.exports = __toCommonJS(create_docs_index_exports);
43
- var import_fast_glob = __toESM(require("fast-glob"));
44
- var import_fs_extra = __toESM(require("fs-extra"));
45
- var import_path = __toESM(require("path"));
46
- var import_utils = require("@nocobase/utils");
47
- var import_ai = require("@nocobase/ai");
48
- var import_findPackageNames = require("../plugin-manager/findPackageNames");
49
- var import_plugin_manager = require("../plugin-manager");
50
- const DOCS_STORAGE_DIR = (0, import_utils.storagePathJoin)("ai", "docs");
51
- const REFERENCE_START = "<!-- docs:references:start -->";
52
- const REFERENCE_END = "<!-- docs:references:end -->";
53
- const SPLIT_REFERENCE_START = "<!-- docs:splits:start -->";
54
- const SPLIT_REFERENCE_END = "<!-- docs:splits:end -->";
55
- const SPLIT_MAX_LENGTH = 5e3;
56
- const SPLIT_MAX_CODE_BLOCKS = 3;
57
- const CREATE_INDEX_RETRY_MAX = 3;
58
- const CREATE_INDEX_RETRY_DELAY_MS = 200;
59
- function normalizeMetaEntries(meta, fallbackModule) {
60
- if (Array.isArray(meta)) {
61
- return meta.filter((item) => item && typeof item.module === "string").map((item) => ({
62
- module: item.module.trim(),
63
- description: typeof item.description === "string" ? item.description.trim() : "",
64
- source: typeof item.source === "string" ? item.source.trim() : ""
65
- })).filter((item) => item.module);
66
- }
67
- if (meta && typeof meta.module === "string") {
68
- return [
69
- {
70
- module: meta.module.trim() || fallbackModule,
71
- description: typeof meta.description === "string" ? meta.description.trim() : "",
72
- source: typeof meta.source === "string" ? meta.source.trim() : ""
73
- }
74
- ];
75
- }
76
- return [
77
- {
78
- module: fallbackModule,
79
- description: "",
80
- source: ""
81
- }
82
- ];
83
- }
84
- __name(normalizeMetaEntries, "normalizeMetaEntries");
85
- async function resolvePkgs(pkg) {
86
- if (!pkg) {
87
- return await (0, import_findPackageNames.findAllPlugins)();
88
- }
89
- const scopes = (Array.isArray(pkg) ? pkg : pkg.split(",")).map((item) => item.trim()).filter(Boolean);
90
- return Array.from(new Set(scopes));
91
- }
92
- __name(resolvePkgs, "resolvePkgs");
93
- function buildDirectoryChildren(files, docsDir) {
94
- const map = /* @__PURE__ */ new Map();
95
- const ensureDir = /* @__PURE__ */ __name((dir) => {
96
- if (!map.has(dir)) {
97
- map.set(dir, { files: [], directories: [] });
98
- }
99
- }, "ensureDir");
100
- ensureDir(docsDir);
101
- files.forEach((file) => {
102
- var _a;
103
- const dir = import_path.default.dirname(file);
104
- ensureDir(dir);
105
- (_a = map.get(dir)) == null ? void 0 : _a.files.push(file);
106
- });
107
- files.forEach((file) => {
108
- let current = import_path.default.dirname(file);
109
- while (current && current.startsWith(docsDir)) {
110
- const parent = import_path.default.dirname(current);
111
- if (parent && parent.startsWith(docsDir)) {
112
- ensureDir(parent);
113
- const list = map.get(parent);
114
- if (list && !list.directories.includes(current)) {
115
- list.directories.push(current);
116
- }
117
- }
118
- if (current === docsDir) break;
119
- current = import_path.default.dirname(current);
120
- }
121
- });
122
- return map;
123
- }
124
- __name(buildDirectoryChildren, "buildDirectoryChildren");
125
- async function resolveSourcePath(source, metaFile) {
126
- if (!source) return "";
127
- if (import_path.default.isAbsolute(source)) {
128
- return await import_fs_extra.default.pathExists(source) ? source : "";
129
- }
130
- const fromRepo = import_path.default.resolve(process.cwd(), source);
131
- if (await import_fs_extra.default.pathExists(fromRepo)) {
132
- return fromRepo;
133
- }
134
- const fromMeta = import_path.default.resolve(import_path.default.dirname(metaFile), source);
135
- if (await import_fs_extra.default.pathExists(fromMeta)) {
136
- return fromMeta;
137
- }
138
- return "";
139
- }
140
- __name(resolveSourcePath, "resolveSourcePath");
141
- function errorToString(error) {
142
- if (error instanceof Error) {
143
- return error.stack || error.message;
144
- }
145
- return String(error);
146
- }
147
- __name(errorToString, "errorToString");
148
- async function collectModuleGroups(packageName) {
149
- const packageJsonPath = require.resolve(`${packageName}/package.json`);
150
- const packageDir = import_path.default.dirname(packageJsonPath);
151
- const distDocsDir = import_path.default.join(packageDir, "dist", "ai", "docs");
152
- const srcDocsDir = import_path.default.join(packageDir, "src", "ai", "docs");
153
- const preferSrc = process.env.APP_ENV !== "production";
154
- const preferredDocsDir = preferSrc ? srcDocsDir : distDocsDir;
155
- const fallbackDocsDir = preferSrc ? distDocsDir : srcDocsDir;
156
- const docsDir = await import_fs_extra.default.pathExists(preferredDocsDir) ? preferredDocsDir : fallbackDocsDir;
157
- if (!await import_fs_extra.default.pathExists(docsDir)) {
158
- return [];
159
- }
160
- const rootMetaPath = import_path.default.join(docsDir, "meta.json");
161
- let metaEntries = [];
162
- if (await import_fs_extra.default.pathExists(rootMetaPath)) {
163
- try {
164
- const rootMeta = await import_fs_extra.default.readJson(rootMetaPath);
165
- metaEntries = normalizeMetaEntries(rootMeta, import_path.default.basename(docsDir));
166
- } catch {
167
- metaEntries = [];
168
- }
169
- }
170
- const moduleMetaFiles = metaEntries.length === 0 ? await (0, import_fast_glob.default)(["*/meta.json"], {
171
- cwd: docsDir,
172
- onlyFiles: true,
173
- absolute: true
174
- }) : [];
175
- if (!metaEntries.length && !moduleMetaFiles.length) {
176
- return [];
177
- }
178
- moduleMetaFiles.sort();
179
- const moduleRoots = moduleMetaFiles.map((metaPath) => import_path.default.dirname(metaPath));
180
- const groups = [];
181
- const entriesToProcess = metaEntries.length > 0 ? metaEntries.map((entry) => ({ metaFile: rootMetaPath, entry })) : moduleMetaFiles.map((metaFile) => ({ metaFile, entry: void 0 }));
182
- for (const item of entriesToProcess) {
183
- const metaFile = item.metaFile;
184
- const moduleRoot = import_path.default.dirname(metaFile);
185
- const moduleDirName = import_path.default.basename(moduleRoot);
186
- let perFileEntries = [];
187
- if (item.entry) {
188
- perFileEntries = [item.entry];
189
- } else {
190
- try {
191
- const meta = await import_fs_extra.default.readJson(metaFile);
192
- perFileEntries = normalizeMetaEntries(meta, moduleDirName);
193
- } catch {
194
- perFileEntries = normalizeMetaEntries(null, moduleDirName);
195
- }
196
- }
197
- for (const metaEntry of perFileEntries) {
198
- const moduleName = metaEntry.module || moduleDirName;
199
- const description = metaEntry.description || "";
200
- const source = metaEntry.source || "";
201
- const defaultModuleRoot = import_path.default.join(docsDir, moduleName);
202
- let effectiveModuleRoot = defaultModuleRoot;
203
- if (source && preferSrc) {
204
- const resolvedSource = await resolveSourcePath(source, metaFile);
205
- if (resolvedSource) {
206
- effectiveModuleRoot = resolvedSource;
207
- }
208
- }
209
- if (!await import_fs_extra.default.pathExists(effectiveModuleRoot)) {
210
- continue;
211
- }
212
- const ignore = [];
213
- if (moduleRoot === docsDir && effectiveModuleRoot === moduleRoot) {
214
- for (const otherRoot of moduleRoots) {
215
- if (otherRoot === moduleRoot) continue;
216
- const rel = import_path.default.relative(moduleRoot, otherRoot).split(import_path.default.sep).join("/");
217
- if (rel && !rel.startsWith("..")) {
218
- ignore.push(`${rel}/**`);
219
- }
220
- }
221
- }
222
- const files = await (0, import_fast_glob.default)(["**/*.{md,mdx}"], {
223
- cwd: effectiveModuleRoot,
224
- onlyFiles: true,
225
- absolute: true,
226
- ignore
227
- });
228
- if (!files.length) {
229
- continue;
230
- }
231
- files.sort();
232
- const directoryChildren = buildDirectoryChildren(files, effectiveModuleRoot);
233
- const docEntries = await Promise.all(
234
- files.map(async (file) => {
235
- const relativePath = import_path.default.relative(effectiveModuleRoot, file);
236
- const normalizedRelativePath = relativePath.split(import_path.default.sep).join("/");
237
- const canonicalPath = import_path.default.posix.join(moduleName, normalizedRelativePath);
238
- const content = await import_fs_extra.default.readFile(file, "utf8");
239
- const meta = extractDocMetadata(content, file);
240
- return {
241
- absolutePath: file,
242
- relativePath,
243
- canonicalPath,
244
- content,
245
- moduleName,
246
- moduleRoot,
247
- packageName,
248
- ...meta
249
- };
250
- })
251
- );
252
- const docMap = new Map(docEntries.map((entry) => [entry.absolutePath, entry]));
253
- groups.push({
254
- moduleName,
255
- description,
256
- moduleRoot,
257
- packageName,
258
- entries: docEntries,
259
- directoryChildren,
260
- docMap
261
- });
262
- }
263
- }
264
- return groups;
265
- }
266
- __name(collectModuleGroups, "collectModuleGroups");
267
- async function buildDocsIndexForPackages(packageNames) {
268
- const moduleGroups = /* @__PURE__ */ new Map();
269
- const moduleDescriptions = /* @__PURE__ */ new Map();
270
- const conflicts = /* @__PURE__ */ new Map();
271
- for (const packageName of packageNames) {
272
- const groups = await collectModuleGroups(packageName);
273
- for (const group of groups) {
274
- const existing = moduleGroups.get(group.moduleName);
275
- if (existing) {
276
- existing.push(group);
277
- } else {
278
- moduleGroups.set(group.moduleName, [group]);
279
- }
280
- if (group.description) {
281
- const existingDesc = moduleDescriptions.get(group.moduleName);
282
- if (existingDesc && existingDesc !== group.description) {
283
- const list = conflicts.get(group.moduleName) || [];
284
- list.push(
285
- `${group.packageName}: description mismatch (existing="${existingDesc}", new="${group.description}")`
286
- );
287
- conflicts.set(group.moduleName, list);
288
- } else if (!existingDesc) {
289
- moduleDescriptions.set(group.moduleName, group.description);
290
- }
291
- }
292
- }
293
- }
294
- const results = /* @__PURE__ */ new Map();
295
- for (const [moduleName, groups] of moduleGroups.entries()) {
296
- const outputDir = import_path.default.join(DOCS_STORAGE_DIR, moduleName);
297
- if (!groups.length) {
298
- results.set(moduleName, { created: false, reason: "no doc files found" });
299
- continue;
300
- }
301
- const docsOutputDir = outputDir;
302
- const index = new import_ai.FlexSearchIndex();
303
- const fileMap = {};
304
- let currentId = 1;
305
- let indexedDocs = 0;
306
- const markdownExt = /* @__PURE__ */ new Set([".md", ".mdx"]);
307
- const storagePathMap = /* @__PURE__ */ new Map();
308
- const moduleConflicts = [];
309
- await import_fs_extra.default.remove(outputDir);
310
- await import_fs_extra.default.ensureDir(docsOutputDir);
311
- const sortedGroups = groups.slice().sort((a, b) => {
312
- if (a.packageName !== b.packageName) {
313
- return a.packageName.localeCompare(b.packageName);
314
- }
315
- return a.moduleRoot.localeCompare(b.moduleRoot);
316
- });
317
- for (const group of sortedGroups) {
318
- for (const entry of group.entries) {
319
- const storageDocPath = import_path.default.join(docsOutputDir, entry.relativePath);
320
- const existing = storagePathMap.get(storageDocPath);
321
- if (existing) {
322
- moduleConflicts.push(
323
- `Duplicate path "${entry.relativePath}" from ${entry.packageName} and ${existing.packageName}`
324
- );
325
- continue;
326
- }
327
- storagePathMap.set(storageDocPath, entry);
328
- await import_fs_extra.default.ensureDir(import_path.default.dirname(storageDocPath));
329
- let processedContent = rewriteRelativeLinks(entry.content, entry);
330
- const splitResult = splitMarkdownIfNeeded(processedContent, entry);
331
- const splitRefs = splitResult.splits.map((split, index2) => {
332
- const splitRelativePath = entry.relativePath.replace(/\.mdx?$/i, "") + split.suffix;
333
- const splitCanonicalPath = import_path.default.posix.join(entry.moduleName, splitRelativePath.split(import_path.default.sep).join("/"));
334
- return {
335
- index: index2,
336
- splitRelativePath,
337
- splitCanonicalPath,
338
- ...split
339
- };
340
- });
341
- processedContent = splitResult.content;
342
- if (entry.isIndex) {
343
- processedContent = applyReferencesToIndex(
344
- processedContent,
345
- entry.absolutePath,
346
- group.directoryChildren,
347
- group.docMap
348
- );
349
- }
350
- if (splitRefs.length) {
351
- processedContent = applySplitReferences(
352
- processedContent,
353
- splitRefs.map((split) => ({
354
- pathRef: split.splitCanonicalPath,
355
- title: split.title,
356
- description: split.description
357
- }))
358
- );
359
- }
360
- if (!entry.hasFrontMatter) {
361
- processedContent = injectFrontMatter(processedContent, entry);
362
- }
363
- await import_fs_extra.default.writeFile(storageDocPath, processedContent, "utf8");
364
- for (const split of splitRefs) {
365
- const splitStoragePath = import_path.default.join(docsOutputDir, split.splitRelativePath);
366
- if (storagePathMap.has(splitStoragePath)) {
367
- moduleConflicts.push(`Duplicate split path "${split.splitRelativePath}" in ${entry.packageName}`);
368
- continue;
369
- }
370
- storagePathMap.set(splitStoragePath, entry);
371
- await import_fs_extra.default.ensureDir(import_path.default.dirname(splitStoragePath));
372
- let splitContent = split.content;
373
- splitContent = injectFrontMatter(splitContent, {
374
- title: split.title,
375
- description: split.description
376
- });
377
- await import_fs_extra.default.writeFile(splitStoragePath, splitContent, "utf8");
378
- }
379
- const ext = import_path.default.extname(entry.absolutePath).toLowerCase();
380
- if (!markdownExt.has(ext)) {
381
- continue;
382
- }
383
- const content = processedContent.trim();
384
- if (!content) {
385
- continue;
386
- }
387
- const docId = currentId++;
388
- await index.addAsync(docId, processedContent);
389
- fileMap[docId] = entry.canonicalPath;
390
- indexedDocs++;
391
- }
392
- }
393
- if (!indexedDocs) {
394
- await import_fs_extra.default.remove(outputDir);
395
- results.set(moduleName, { created: false, reason: "no markdown doc content to index" });
396
- continue;
397
- }
398
- const indexData = {};
399
- index.export((key, data) => {
400
- indexData[key] = data;
401
- });
402
- await import_fs_extra.default.ensureDir(outputDir);
403
- await import_fs_extra.default.writeJSON(import_path.default.join(outputDir, "index.json"), indexData, { spaces: 2 });
404
- await import_fs_extra.default.writeJSON(import_path.default.join(outputDir, "files.json"), fileMap, { spaces: 2 });
405
- const allConflicts = [...conflicts.get(moduleName) || [], ...moduleConflicts];
406
- if (allConflicts.length) {
407
- results.set(moduleName, { created: true, conflicts: allConflicts });
408
- } else {
409
- results.set(moduleName, { created: true });
410
- }
411
- }
412
- if (moduleGroups.size) {
413
- const metaOutput = {};
414
- for (const moduleName of moduleGroups.keys()) {
415
- metaOutput[moduleName] = {
416
- description: moduleDescriptions.get(moduleName) || ""
417
- };
418
- }
419
- await import_fs_extra.default.ensureDir(DOCS_STORAGE_DIR);
420
- await import_fs_extra.default.writeJSON(import_path.default.join(DOCS_STORAGE_DIR, "meta.json"), metaOutput, { spaces: 2 });
421
- }
422
- return results;
423
- }
424
- __name(buildDocsIndexForPackages, "buildDocsIndexForPackages");
425
- function extractDocMetadata(content, filePath) {
426
- const normalized = content.replace(/\r\n/g, "\n");
427
- const hasFrontMatter = normalized.startsWith("---\n") && normalized.indexOf("\n---", 4) !== -1;
428
- let searchStart = 0;
429
- if (hasFrontMatter) {
430
- const closingIndex = normalized.indexOf("\n---", 4);
431
- if (closingIndex !== -1) {
432
- const closingLineEnd = normalized.indexOf("\n", closingIndex + 4);
433
- searchStart = closingLineEnd === -1 ? normalized.length : closingLineEnd + 1;
434
- }
435
- }
436
- let title = "";
437
- let description = "";
438
- const lines = normalized.slice(searchStart).split("\n");
439
- for (let i = 0; i < lines.length; i++) {
440
- const line = lines[i].trim();
441
- if (line.startsWith("# ")) {
442
- title = line.replace(/^#\s+/, "").trim();
443
- let j = i + 1;
444
- const descParts = [];
445
- while (j < lines.length) {
446
- const descLine = lines[j].trim();
447
- if (!descLine) {
448
- if (descParts.length) break;
449
- j++;
450
- continue;
451
- }
452
- if (descLine.startsWith("#")) break;
453
- descParts.push(descLine);
454
- if (descParts.join(" ").length > 160) break;
455
- j++;
456
- }
457
- description = descParts.join(" ");
458
- break;
459
- }
460
- }
461
- if (!title) {
462
- const base = import_path.default.basename(filePath, import_path.default.extname(filePath));
463
- title = base.split(/[-_]/).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1)).join(" ");
464
- }
465
- if (!description) {
466
- description = `Reference snippet for ${title}`;
467
- }
468
- return {
469
- title,
470
- description,
471
- hasFrontMatter,
472
- isIndex: import_path.default.basename(filePath).toLowerCase() === "index.md"
473
- };
474
- }
475
- __name(extractDocMetadata, "extractDocMetadata");
476
- function injectFrontMatter(content, meta) {
477
- const trimmed = content.replace(/^\uFEFF/, "");
478
- const fmLines = [
479
- "---",
480
- `title: ${JSON.stringify(meta.title)}`,
481
- `description: ${JSON.stringify(meta.description)}`,
482
- "---"
483
- ];
484
- const frontMatter = `${fmLines.join("\n")}
485
- `;
486
- const separator = trimmed.startsWith("\n") ? "" : "\n";
487
- return `${frontMatter}${separator}${trimmed}`;
488
- }
489
- __name(injectFrontMatter, "injectFrontMatter");
490
- function splitFrontMatter(content) {
491
- const normalized = content.replace(/\r\n/g, "\n");
492
- if (!normalized.startsWith("---\n")) {
493
- return { frontMatter: "", body: normalized, hasFrontMatter: false };
494
- }
495
- const closingIndex = normalized.indexOf("\n---", 4);
496
- if (closingIndex === -1) {
497
- return { frontMatter: "", body: normalized, hasFrontMatter: false };
498
- }
499
- const closingLineEnd = normalized.indexOf("\n", closingIndex + 4);
500
- const bodyStart = closingLineEnd === -1 ? normalized.length : closingLineEnd + 1;
501
- return {
502
- frontMatter: normalized.slice(0, bodyStart),
503
- body: normalized.slice(bodyStart),
504
- hasFrontMatter: true
505
- };
506
- }
507
- __name(splitFrontMatter, "splitFrontMatter");
508
- function getPrimaryHeading(body) {
509
- var _a;
510
- const match = body.match(/^#\s+(.+)$/m);
511
- return ((_a = match == null ? void 0 : match[1]) == null ? void 0 : _a.trim()) || "";
512
- }
513
- __name(getPrimaryHeading, "getPrimaryHeading");
514
- function countCodeBlocks(content) {
515
- return (content.match(/```[\s\S]*?```/g) || []).length;
516
- }
517
- __name(countCodeBlocks, "countCodeBlocks");
518
- function normalizeHeadingText(text) {
519
- return text.replace(/^#+\s+/, "").trim();
520
- }
521
- __name(normalizeHeadingText, "normalizeHeadingText");
522
- function splitByHeadings(body) {
523
- const lines = body.split("\n");
524
- const sections = [];
525
- let current = null;
526
- for (const line of lines) {
527
- const headingMatch = line.match(/^(#{2,3})\s+(.+)$/);
528
- if (headingMatch) {
529
- if (current) {
530
- sections.push(current);
531
- }
532
- current = {
533
- level: headingMatch[1].length,
534
- heading: normalizeHeadingText(headingMatch[0]),
535
- content: []
536
- };
537
- continue;
538
- }
539
- if (current) {
540
- current.content.push(line);
541
- }
542
- }
543
- if (current) {
544
- sections.push(current);
545
- }
546
- return sections.filter((section) => section.content.join("\n").trim().length > 0);
547
- }
548
- __name(splitByHeadings, "splitByHeadings");
549
- function splitExamples(body) {
550
- var _a;
551
- const codeRegex = /```[\s\S]*?```/g;
552
- const headingRegex = /^(#{2,3})\s+(.+)$/gm;
553
- const headings = [];
554
- for (const match of body.matchAll(headingRegex)) {
555
- const raw = normalizeHeadingText(match[0]);
556
- const key = raw.toLowerCase();
557
- headings.push({
558
- index: match.index ?? 0,
559
- level: match[1].length,
560
- text: raw,
561
- key
562
- });
563
- }
564
- const examples = [];
565
- const excludeKeys = /* @__PURE__ */ new Set([
566
- "type definition",
567
- "type definition (simplified)",
568
- "parameters",
569
- "return value",
570
- "\u7C7B\u578B\u5B9A\u4E49",
571
- "\u53C2\u6570",
572
- "\u8FD4\u56DE\u503C"
573
- ]);
574
- const codeMatches = Array.from(body.matchAll(codeRegex));
575
- const exampleCodeRanges = [];
576
- const exampleSectionRanges = [];
577
- for (const match of codeMatches) {
578
- const code = match[0];
579
- const index = match.index ?? 0;
580
- const priorHeadings = headings.filter((item) => item.index < index);
581
- const currentH2 = priorHeadings.filter((item) => item.level === 2).slice(-1)[0];
582
- const currentH3 = priorHeadings.filter((item) => item.level === 3).slice(-1)[0];
583
- const h2Key = (currentH2 == null ? void 0 : currentH2.key) || "";
584
- const h3Key = (currentH3 == null ? void 0 : currentH3.key) || "";
585
- if (excludeKeys.has(h2Key) || excludeKeys.has(h3Key)) {
586
- continue;
587
- }
588
- const heading = (currentH3 == null ? void 0 : currentH3.text) || (currentH2 == null ? void 0 : currentH2.text) || "";
589
- examples.push({ heading, content: code });
590
- exampleCodeRanges.push({ start: index, end: index + code.length });
591
- if (currentH3 || currentH2) {
592
- const anchor = currentH3 || currentH2;
593
- const nextHeadingIndex = ((_a = headings.filter((item) => item.index > anchor.index && item.level <= anchor.level).slice(0, 1)[0]) == null ? void 0 : _a.index) ?? body.length;
594
- exampleSectionRanges.push({ start: anchor.index, end: nextHeadingIndex });
595
- }
596
- }
597
- let cleanedBody = body;
598
- if (exampleSectionRanges.length) {
599
- const ranges = exampleSectionRanges.sort((a, b) => a.start - b.start).filter((range, index, list) => index === 0 || range.start >= list[index - 1].end);
600
- let result = "";
601
- let last = 0;
602
- for (const range of ranges) {
603
- result += body.slice(last, range.start);
604
- last = range.end;
605
- }
606
- result += body.slice(last);
607
- cleanedBody = result;
608
- } else if (exampleCodeRanges.length) {
609
- const ranges = exampleCodeRanges.sort((a, b) => a.start - b.start).filter((range, index, list) => index === 0 || range.start >= list[index - 1].end);
610
- let result = "";
611
- let last = 0;
612
- for (const range of ranges) {
613
- result += body.slice(last, range.start);
614
- last = range.end;
615
- }
616
- result += body.slice(last);
617
- cleanedBody = result;
618
- }
619
- return { examples, cleanedBody };
620
- }
621
- __name(splitExamples, "splitExamples");
622
- function splitMarkdownIfNeeded(content, entry) {
623
- const { body, frontMatter, hasFrontMatter } = splitFrontMatter(content);
624
- const bodyLength = body.trim().length;
625
- const codeBlocks = countCodeBlocks(body);
626
- const shouldSplitByLength = bodyLength > SPLIT_MAX_LENGTH;
627
- const shouldSplitByExamples = codeBlocks > SPLIT_MAX_CODE_BLOCKS;
628
- if (!shouldSplitByLength && !shouldSplitByExamples) {
629
- return {
630
- splits: [],
631
- content
632
- };
633
- }
634
- const h1 = getPrimaryHeading(body) || entry.title;
635
- const splits = [];
636
- let nextBody = body;
637
- let didSplitByExamples = false;
638
- if (shouldSplitByExamples) {
639
- const { examples, cleanedBody } = splitExamples(body);
640
- if (examples.length) {
641
- didSplitByExamples = true;
642
- nextBody = cleanedBody;
643
- examples.forEach((example, index) => {
644
- const headingLine = example.heading ? `## ${example.heading}
645
-
646
- ` : "";
647
- const exampleContent = `# ${h1}
648
-
649
- ${headingLine}${example.content}
650
- `;
651
- const title = example.heading ? `${example.heading} Example` : `${h1} Example ${index + 1}`;
652
- splits.push({
653
- suffix: `__example-${index + 1}.md`,
654
- title,
655
- description: `Extracted example from ${entry.title}`,
656
- content: exampleContent
657
- });
658
- });
659
- }
660
- }
661
- if (shouldSplitByLength && !didSplitByExamples) {
662
- const sections = splitByHeadings(body);
663
- sections.forEach((section, index) => {
664
- const headingLine = `${"#".repeat(section.level)} ${section.heading}`;
665
- const sectionBody = section.content.join("\n").trim();
666
- const chunkContent = `# ${h1}
667
-
668
- ${headingLine}
669
- ${sectionBody}
670
- `;
671
- const title = section.heading || `${h1} Chunk ${index + 1}`;
672
- splits.push({
673
- suffix: `__chunk-${index + 1}.md`,
674
- title,
675
- description: `Extracted section from ${entry.title}`,
676
- content: chunkContent
677
- });
678
- });
679
- }
680
- const rebuilt = hasFrontMatter ? `${frontMatter}${nextBody}` : nextBody;
681
- return { splits, content: rebuilt };
682
- }
683
- __name(splitMarkdownIfNeeded, "splitMarkdownIfNeeded");
684
- function applySplitReferences(content, splits) {
685
- if (!splits.length) return content;
686
- const refLines = splits.map((split) => referenceLine(split.title, split.description, split.pathRef));
687
- const baseContent = stripSplitReferenceBlock(content).trimEnd();
688
- const block = `${SPLIT_REFERENCE_START}
689
-
690
- ## Extracted references
691
-
692
- ${refLines.join(
693
- "\n"
694
- )}
695
-
696
- ${SPLIT_REFERENCE_END}`;
697
- if (!baseContent) {
698
- return `${block}
699
- `;
700
- }
701
- return `${baseContent}
702
-
703
- ${block}
704
- `;
705
- }
706
- __name(applySplitReferences, "applySplitReferences");
707
- function stripSplitReferenceBlock(content) {
708
- const start = content.indexOf(SPLIT_REFERENCE_START);
709
- if (start === -1) return content;
710
- const end = content.indexOf(SPLIT_REFERENCE_END, start + SPLIT_REFERENCE_START.length);
711
- if (end === -1) return content;
712
- const before = content.slice(0, start).trimEnd();
713
- const after = content.slice(end + SPLIT_REFERENCE_END.length).trimStart();
714
- if (!before) return after;
715
- if (!after) return `${before}
716
- `;
717
- return `${before}
718
-
719
- ${after}`;
720
- }
721
- __name(stripSplitReferenceBlock, "stripSplitReferenceBlock");
722
- function rewriteRelativeLinks(content, entry) {
723
- const { body, frontMatter, hasFrontMatter } = splitFrontMatter(content);
724
- const segments = [];
725
- const codeRegex = /```[\s\S]*?```/g;
726
- let lastIndex = 0;
727
- for (const match of body.matchAll(codeRegex)) {
728
- const index = match.index ?? 0;
729
- if (index > lastIndex) {
730
- segments.push({ type: "text", content: body.slice(lastIndex, index) });
731
- }
732
- segments.push({ type: "code", content: match[0] });
733
- lastIndex = index + match[0].length;
734
- }
735
- if (lastIndex < body.length) {
736
- segments.push({ type: "text", content: body.slice(lastIndex) });
737
- }
738
- const dir = import_path.default.posix.dirname(entry.relativePath.split(import_path.default.sep).join("/"));
739
- const rewritten = segments.map((segment) => {
740
- if (segment.type === "code") return segment.content;
741
- return segment.content.replace(/(!?)\[[^\]]+]\(([^)]+)\)/g, (match, bang, link) => {
742
- if (bang) return match;
743
- const trimmed = link.trim();
744
- if (trimmed.startsWith("http://") || trimmed.startsWith("https://") || trimmed.startsWith("/") || trimmed.startsWith("#") || trimmed.startsWith("mailto:") || trimmed.startsWith("tel:")) {
745
- return match;
746
- }
747
- const hashIndex = trimmed.indexOf("#");
748
- const hash = hashIndex >= 0 ? trimmed.slice(hashIndex) : "";
749
- const beforeHash = hashIndex >= 0 ? trimmed.slice(0, hashIndex) : trimmed;
750
- const queryIndex = beforeHash.indexOf("?");
751
- const query = queryIndex >= 0 ? beforeHash.slice(queryIndex) : "";
752
- const pathPart = queryIndex >= 0 ? beforeHash.slice(0, queryIndex) : beforeHash;
753
- const resolved = import_path.default.posix.normalize(import_path.default.posix.join(dir, pathPart));
754
- const normalized = resolved.startsWith(".") ? resolved.replace(/^(\.\.\/?)+/, "") : resolved;
755
- const absolutePath = import_path.default.posix.join("/", entry.moduleName, normalized);
756
- const nextLink = `${absolutePath}${query}${hash}`;
757
- return match.replace(link, nextLink);
758
- });
759
- }).join("");
760
- if (!hasFrontMatter) {
761
- return rewritten;
762
- }
763
- return `${frontMatter}${rewritten}`;
764
- }
765
- __name(rewriteRelativeLinks, "rewriteRelativeLinks");
766
- function applyReferencesToIndex(content, filePath, directoryChildren, docMap) {
767
- const dir = import_path.default.dirname(filePath);
768
- const entry = directoryChildren.get(dir);
769
- if (!entry) {
770
- return stripExistingReferenceBlock(content);
771
- }
772
- const refLines = [];
773
- const refs = /* @__PURE__ */ new Set();
774
- const childFiles = entry.files.filter((file) => file !== import_path.default.join(dir, "index.md"));
775
- for (const child of childFiles.sort()) {
776
- const meta = docMap.get(child);
777
- if (!meta) continue;
778
- const refPath = meta.canonicalPath;
779
- if (refs.has(refPath)) continue;
780
- refs.add(refPath);
781
- refLines.push(referenceLine(meta.title, meta.description, refPath));
782
- }
783
- for (const subDir of entry.directories.sort()) {
784
- const indexFile = import_path.default.join(subDir, "index.md");
785
- const meta = docMap.get(indexFile);
786
- if (!meta) continue;
787
- const refPath = meta.canonicalPath;
788
- if (refs.has(refPath)) continue;
789
- refs.add(refPath);
790
- refLines.push(referenceLine(meta.title, meta.description, refPath));
791
- }
792
- if (!refLines.length) {
793
- return stripExistingReferenceBlock(content);
794
- }
795
- const baseContent = stripExistingReferenceBlock(content).trimEnd();
796
- const block = `${REFERENCE_START}
797
-
798
- ## References
799
-
800
- ${refLines.join("\n")}
801
-
802
- ${REFERENCE_END}`;
803
- if (!baseContent) {
804
- return `${block}
805
- `;
806
- }
807
- return `${baseContent}
808
-
809
- ${block}
810
- `;
811
- }
812
- __name(applyReferencesToIndex, "applyReferencesToIndex");
813
- function referenceLine(title, description, pathRef) {
814
- const summary = description.length > 200 ? `${description.slice(0, 197)}...` : description;
815
- const descText = summary ? ` - ${summary}` : "";
816
- return `- **${title}** (\`${pathRef}\`)${descText}`;
817
- }
818
- __name(referenceLine, "referenceLine");
819
- function stripExistingReferenceBlock(content) {
820
- const start = content.indexOf(REFERENCE_START);
821
- if (start === -1) return content;
822
- const end = content.indexOf(REFERENCE_END, start + REFERENCE_START.length);
823
- if (end === -1) return content;
824
- const before = content.slice(0, start).trimEnd();
825
- const after = content.slice(end + REFERENCE_END.length).trimStart();
826
- if (!before) return after;
827
- if (!after) return `${before}
828
- `;
829
- return `${before}
830
-
831
- ${after}`;
832
- }
833
- __name(stripExistingReferenceBlock, "stripExistingReferenceBlock");
834
- async function createDocsIndex(app, options = {}) {
835
- var _a;
836
- const pkgs = await resolvePkgs(options.pkg);
837
- if (!pkgs.length) {
838
- app.log.info("No plugin packages detected for docs index generation");
839
- return;
840
- }
841
- const packageNames = [];
842
- for (const pkg of pkgs) {
843
- try {
844
- const { packageName } = await import_plugin_manager.PluginManager.parseName(pkg);
845
- packageNames.push(packageName);
846
- } catch (error) {
847
- app.log.error(error, { pkg });
848
- }
849
- }
850
- if (!packageNames.length) {
851
- app.log.info("No plugin packages resolved for docs index generation");
852
- return;
853
- }
854
- let results = null;
855
- let lastError;
856
- for (let attempt = 0; attempt < CREATE_INDEX_RETRY_MAX; attempt++) {
857
- try {
858
- results = await buildDocsIndexForPackages(packageNames);
859
- break;
860
- } catch (error) {
861
- lastError = error;
862
- if (attempt === CREATE_INDEX_RETRY_MAX - 1) {
863
- break;
864
- }
865
- app.log.warn(`Docs index build failed, retrying (${attempt + 1}/${CREATE_INDEX_RETRY_MAX})`);
866
- await new Promise((resolve) => setTimeout(resolve, CREATE_INDEX_RETRY_DELAY_MS * (attempt + 1)));
867
- }
868
- }
869
- if (!results) {
870
- const message = lastError ? errorToString(lastError) : "Docs index build failed";
871
- app.log.error(message);
872
- return;
873
- }
874
- if (!results.size) {
875
- app.log.info("No module docs found to index");
876
- return;
877
- }
878
- for (const [moduleName, result] of results.entries()) {
879
- if (result.created) {
880
- app.log.info(`Docs index generated for module "${moduleName}"`);
881
- if ((_a = result.conflicts) == null ? void 0 : _a.length) {
882
- app.log.warn(`Module "${moduleName}" has conflicts: ${result.conflicts.join("; ")}`);
883
- }
884
- } else {
885
- app.log.info(`Skipped docs index for module "${moduleName}": ${result.reason}`);
886
- }
887
- }
888
- }
889
- __name(createDocsIndex, "createDocsIndex");
890
- // Annotate the CommonJS export names for ESM import in node:
891
- 0 && (module.exports = {
892
- createDocsIndex
893
- });