@pactor-app/module-pack 1.55.0 → 1.57.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/README.md +56 -10
- package/dist/index.cjs +508 -157
- package/dist/index.d.cts +122 -11
- package/dist/index.d.ts +122 -11
- package/dist/index.js +462 -124
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -28,6 +28,7 @@ interface BuildModuleResult {
|
|
|
28
28
|
assets: number;
|
|
29
29
|
};
|
|
30
30
|
clientBundled: boolean;
|
|
31
|
+
serverBundled: boolean;
|
|
31
32
|
warnings: string[];
|
|
32
33
|
}
|
|
33
34
|
/** 执行模块构建全链路,返回产物摘要;失败抛 ModuleBuildError */
|
|
@@ -62,17 +63,36 @@ declare function validateModule(options?: ValidateModuleOptions): ValidateModule
|
|
|
62
63
|
/**
|
|
63
64
|
* `initModule`:目标工程接入面的一次性初始化(幂等、只新增不破坏):
|
|
64
65
|
* - 生成 pactor.module.json(已存在则跳过);
|
|
65
|
-
* -
|
|
66
|
+
* - 生成 module/client.ts + module/module.css(已存在则跳过);
|
|
67
|
+
* - `--server` 时额外生成 module/server.ts 并在新建配置中写入 serverEntry / apiPrefixes;
|
|
66
68
|
* - 向 package.json 注入 files / exports / scripts / peerDependencies
|
|
67
69
|
* (已存在的字段不覆盖,冲突时 warning)。
|
|
68
70
|
* 绝不修改目标工程 app/、src/ 下的任何现有文件。
|
|
69
71
|
*/
|
|
72
|
+
/** 生成的模块样式入口(与 client entry 同属脚手架,由 client.ts import) */
|
|
73
|
+
declare const CLIENT_STYLES_ENTRY = "module/module.css";
|
|
74
|
+
/** 默认 server 入口(仅 `init --server` 生成) */
|
|
75
|
+
declare const SERVER_ENTRY = "module/server.ts";
|
|
70
76
|
interface InitModuleOptions {
|
|
71
77
|
/** 目标工程根(默认 cwd) */
|
|
72
78
|
dir?: string;
|
|
79
|
+
/**
|
|
80
|
+
* 覆盖已存在的初始化文件(pactor.module.json / module/client.ts / 脚手架样式,
|
|
81
|
+
* --server 时含 module/server.ts)。
|
|
82
|
+
* 缺省 false 时跳过已存在文件;由 CLI 负责询问用户后传入。
|
|
83
|
+
*/
|
|
84
|
+
overwrite?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* 额外生成 module/server.ts,并在新建的 pactor.module.json 中写入
|
|
87
|
+
* serverEntry 与 apiPrefixes(默认 /api/<模块 slug>)。
|
|
88
|
+
* 缺省 false:纯 DSL 模块不引入 server entry。
|
|
89
|
+
*/
|
|
90
|
+
server?: boolean;
|
|
73
91
|
}
|
|
74
92
|
interface InitModuleResult {
|
|
75
93
|
created: string[];
|
|
94
|
+
/** overwrite 时重新生成(覆盖)的文件 */
|
|
95
|
+
overwritten: string[];
|
|
76
96
|
skipped: string[];
|
|
77
97
|
warnings: string[];
|
|
78
98
|
}
|
|
@@ -82,16 +102,24 @@ interface ActionSource {
|
|
|
82
102
|
/** 具名导出(如 riskActions) */
|
|
83
103
|
exports: string[];
|
|
84
104
|
}
|
|
85
|
-
/** 执行初始化,返回创建 / 跳过 / 告警清单 */
|
|
105
|
+
/** 执行初始化,返回创建 / 覆盖 / 跳过 / 告警清单 */
|
|
86
106
|
declare function initModule(options?: InitModuleOptions): InitModuleResult;
|
|
87
|
-
/**
|
|
107
|
+
/** 模块 id 统一前缀(缺省自动补齐,已有则不重复添加) */
|
|
108
|
+
declare const MODULE_ID_PREFIX = "pactor-app-";
|
|
109
|
+
/** 从包名推导模块 id:去 scope、kebab 化、补 pactor-app- 前缀 */
|
|
88
110
|
declare function deriveModuleId(name: unknown): string;
|
|
111
|
+
/** 由模块 id 推导默认 API 前缀:/api/<去掉 pactor-app- 前缀的 slug> */
|
|
112
|
+
declare function deriveApiPrefix(moduleId: string): string;
|
|
89
113
|
/** 扫描 src/pactor/*-actions.ts 的具名导出(export const xxx) */
|
|
90
114
|
declare function discoverActions(projectDir: string): ActionSource[];
|
|
91
115
|
/** 检测 src/pactor/components/index.ts 是否导出 pactorComponents */
|
|
92
116
|
declare function discoverComponents(projectDir: string): boolean;
|
|
93
117
|
/** 生成 module/client.ts 内容(export const extensions = { components, actions }) */
|
|
94
118
|
declare function renderClientEntry(hasComponents: boolean, actions: ActionSource[]): string;
|
|
119
|
+
/** 生成 module/module.css 内容(模块自带样式入口,随 client bundle 打进 tgz) */
|
|
120
|
+
declare function renderModuleStyles(): string;
|
|
121
|
+
/** 生成 module/server.ts 内容(逻辑路径 → 方法处理函数映射) */
|
|
122
|
+
declare function renderServerEntry(moduleId: string): string;
|
|
95
123
|
|
|
96
124
|
/**
|
|
97
125
|
* `pactor.module.json` 配置加载与校验(手写校验,避免重依赖)。
|
|
@@ -116,13 +144,24 @@ interface ModulePackConfig {
|
|
|
116
144
|
basePath: string;
|
|
117
145
|
yamlRoot: string;
|
|
118
146
|
clientEntry: string;
|
|
147
|
+
/** 服务端入口(工程相对路径,如 module/server.ts);与 apiPrefixes 成对出现 */
|
|
148
|
+
serverEntry?: string;
|
|
149
|
+
/**
|
|
150
|
+
* 模块 API 逻辑前缀(如 /api/risk-analysis)。打包时命中这些前缀的 DSL URL
|
|
151
|
+
* 会改写为 /api/modules/<id>/...,由 Shell 的通用分发入口承接。
|
|
152
|
+
*/
|
|
153
|
+
apiPrefixes?: string[];
|
|
119
154
|
/** init 时自动发现的 src/pactor/*-actions.ts(仅记录,client entry 自行 import) */
|
|
120
155
|
actions: string[];
|
|
121
156
|
publicDir: string;
|
|
122
157
|
/** target profile id(如 innospots-web-shell@2) */
|
|
123
158
|
target: string;
|
|
124
|
-
|
|
125
|
-
|
|
159
|
+
/**
|
|
160
|
+
* 模块级访问默认值:'public' 时构建期给未声明 public/permission 的
|
|
161
|
+
* pages / menus 补 public: true(缺省填充);默认 'authenticated' 不改动。
|
|
162
|
+
*/
|
|
163
|
+
access: {
|
|
164
|
+
default: 'public' | 'authenticated';
|
|
126
165
|
};
|
|
127
166
|
tailwind: TailwindConfig;
|
|
128
167
|
rewrite: {
|
|
@@ -172,6 +211,8 @@ interface TargetProfile {
|
|
|
172
211
|
rewriteAssetUrls: (id: string, version: string) => string;
|
|
173
212
|
/** 禁止 basePath: "/"(Shell joinPublicPath 会产生 "//login" 这类坏路径) */
|
|
174
213
|
forbidRootBasePath: boolean;
|
|
214
|
+
/** Shell 支持 `/api/modules/<moduleId>/*` 通用模块 API 分发 */
|
|
215
|
+
moduleServerApi: boolean;
|
|
175
216
|
}
|
|
176
217
|
|
|
177
218
|
/**
|
|
@@ -181,16 +222,23 @@ interface TargetProfile {
|
|
|
181
222
|
*/
|
|
182
223
|
declare const innospotsWebShellV1: TargetProfile;
|
|
183
224
|
/**
|
|
184
|
-
* innospots-web-shell@2
|
|
225
|
+
* innospots-web-shell@2:Shell lazy 页面端点已修复,
|
|
185
226
|
* 返回 PageResource 信封 { id, resourceType: "page", version, dslVersion, schema },
|
|
186
227
|
* 与 @pactor-app/app createSitemapLoader 契约对齐,lazy: true 原样保留。
|
|
187
228
|
*/
|
|
188
229
|
declare const innospotsWebShellV2: TargetProfile;
|
|
230
|
+
/**
|
|
231
|
+
* innospots-web-shell@3(当前默认):在 @2 的页面/导航/资源契约之上,
|
|
232
|
+
* Shell 新增 `/api/modules/<moduleId>/*` 通用分发入口,支持模块把
|
|
233
|
+
* server entry(module/server.ts)打进 tgz 并由 Shell 统一承接。
|
|
234
|
+
* 未使用 serverEntry 的模块产物与 @2 完全一致。
|
|
235
|
+
*/
|
|
236
|
+
declare const innospotsWebShellV3: TargetProfile;
|
|
189
237
|
|
|
190
238
|
/** 未知 profile 错误(信息中列出可用值) */
|
|
191
239
|
declare class ProfileError extends Error {
|
|
192
240
|
}
|
|
193
|
-
/** 默认 target
|
|
241
|
+
/** 默认 target:支持模块 server entry 的 Shell 契约版本 */
|
|
194
242
|
declare const DEFAULT_TARGET: string;
|
|
195
243
|
/** 全部可用 profile id(用于报错提示与文档) */
|
|
196
244
|
declare function listProfiles(): string[];
|
|
@@ -252,12 +300,15 @@ declare function expandIncludes(value: unknown, ctx: ExpandContext): unknown;
|
|
|
252
300
|
* - inlineStringLayouts:字符串形式的布局引用解析为内联布局对象;
|
|
253
301
|
* - stripMenuPaths:删除菜单显式 path(运行时按 pageId 从 pages 回填);
|
|
254
302
|
* - forceInlinePages:删除页面 lazy(随 bootstrap 内联下发);
|
|
255
|
-
* -
|
|
303
|
+
* - accessDefault='public':给未声明 public/permission 的 pages / menus 补 public: true。
|
|
256
304
|
*/
|
|
257
305
|
interface TransformSitemapOptions {
|
|
258
306
|
profile: TargetProfile;
|
|
259
|
-
/**
|
|
260
|
-
|
|
307
|
+
/**
|
|
308
|
+
* 模块级访问默认值:'public' 时给未声明 public/permission 的 pages / menus
|
|
309
|
+
* 补 public: true(缺省填充,不覆盖显式声明);'authenticated' 不改动。
|
|
310
|
+
*/
|
|
311
|
+
accessDefault?: 'public' | 'authenticated';
|
|
261
312
|
/** 解析字符串布局引用(yamlRoot 相对路径 -> 布局对象,应走 $include 展开) */
|
|
262
313
|
loadLayout: (relPath: string) => unknown;
|
|
263
314
|
}
|
|
@@ -299,6 +350,10 @@ interface RewriteContext {
|
|
|
299
350
|
assetPrefix: string;
|
|
300
351
|
/** 绝对 API 地址重写为相对路径(false 时仅告警不改写) */
|
|
301
352
|
absoluteApiToRelative: boolean;
|
|
353
|
+
/** 模块 id(与 apiPrefixes 同时存在时,命中前缀的 API URL 改写为模块挂载路径) */
|
|
354
|
+
moduleId?: string;
|
|
355
|
+
/** 模块声明的逻辑 API 前缀(如 `/api/risk-analysis`) */
|
|
356
|
+
apiPrefixes?: string[];
|
|
302
357
|
}
|
|
303
358
|
interface RewriteResult {
|
|
304
359
|
value: unknown;
|
|
@@ -352,6 +407,38 @@ declare function tsconfigAliases(projectDir: string): Record<string, string>;
|
|
|
352
407
|
/** 宽松 JSONC 解析:去注释(尊重字符串字面量)与尾逗号 */
|
|
353
408
|
declare function parseJsonc(text: string): unknown;
|
|
354
409
|
|
|
410
|
+
/**
|
|
411
|
+
* server entry 打包(esbuild):
|
|
412
|
+
* - `--bundle --format=esm --platform=node --target=node20`;
|
|
413
|
+
* - 产物固定为 server/index.mjs:模块包通常没有 `"type": "module"`,
|
|
414
|
+
* 若输出 .js 会被 Node 按 CJS 解析;esbuild 的 format=esm 不会自动改扩展名,
|
|
415
|
+
* 因此必须显式 outExtension;
|
|
416
|
+
* - react / next / pactor 保持 external(server 端不需要,也不该打入模块);
|
|
417
|
+
* Node built-in 由 platform=node 自动 external;
|
|
418
|
+
* - alias 复用 tsconfig 的 paths(如 `@/*` → `./src/*`);
|
|
419
|
+
* - 入口必须位于工程根内,防止越界读取。
|
|
420
|
+
*/
|
|
421
|
+
/** 内置 externals:宿主/框架依赖,绝不打进 server bundle */
|
|
422
|
+
declare const SERVER_EXTERNALS: string[];
|
|
423
|
+
/** server 产物文件名(与 manifest.serverEntry 一致) */
|
|
424
|
+
declare const SERVER_BUNDLE_FILE: "index.mjs";
|
|
425
|
+
/** server 打包错误(入口缺失 / 越界 / 产物缺失) */
|
|
426
|
+
declare class ServerBundleError extends Error {
|
|
427
|
+
}
|
|
428
|
+
interface BundleServerOptions {
|
|
429
|
+
projectDir: string;
|
|
430
|
+
/** 工程相对路径(配置 serverEntry) */
|
|
431
|
+
serverEntry: string;
|
|
432
|
+
/** 输出目录(绝对路径,产物为 index.mjs / index.mjs.map) */
|
|
433
|
+
outDir: string;
|
|
434
|
+
}
|
|
435
|
+
interface BundleServerResult {
|
|
436
|
+
bundled: true;
|
|
437
|
+
entry: typeof SERVER_BUNDLE_FILE;
|
|
438
|
+
}
|
|
439
|
+
/** esbuild 打包 server entry;入口不存在或越界时抛 ServerBundleError */
|
|
440
|
+
declare function bundleServer(options: BundleServerOptions): BundleServerResult;
|
|
441
|
+
|
|
355
442
|
/**
|
|
356
443
|
* 可选 Tailwind 预编译(配置 `tailwind: { enabled, input?, scan? }`):
|
|
357
444
|
* 调用目标工程的 tailwindcss CLI(npx --no-install tailwindcss,v4 / @tailwindcss/cli),
|
|
@@ -396,6 +483,10 @@ interface ModuleManifest {
|
|
|
396
483
|
/** 纯 DSL 模块无 client bundle 时缺省 */
|
|
397
484
|
clientEntry?: 'client/index.js';
|
|
398
485
|
styles?: ['client/index.css'];
|
|
486
|
+
/** 服务端入口(存在 server bundle 时输出) */
|
|
487
|
+
serverEntry?: 'server/index.mjs';
|
|
488
|
+
/** 模块 API 逻辑前缀(与 serverEntry 成对输出) */
|
|
489
|
+
apiPrefixes?: string[];
|
|
399
490
|
}
|
|
400
491
|
interface EmitDslInput {
|
|
401
492
|
config: ModulePackConfig;
|
|
@@ -416,6 +507,8 @@ interface WriteManifestInput {
|
|
|
416
507
|
outDir: string;
|
|
417
508
|
clientEntry?: 'client/index.js';
|
|
418
509
|
styles?: ['client/index.css'];
|
|
510
|
+
serverEntry?: 'server/index.mjs';
|
|
511
|
+
apiPrefixes?: string[];
|
|
419
512
|
/** 追加版本推导相关的告警 */
|
|
420
513
|
warnings: string[];
|
|
421
514
|
}
|
|
@@ -436,4 +529,22 @@ declare function readProjectVersion(projectDir: string): string;
|
|
|
436
529
|
*/
|
|
437
530
|
declare function resolvePactorVersionRange(projectDir: string, warnings: string[]): string;
|
|
438
531
|
|
|
439
|
-
|
|
532
|
+
/** 版本递增类型:语义化级别或显式版本号(如 2.0.0 / 2.0.0-beta.1) */
|
|
533
|
+
type VersionRelease = 'major' | 'minor' | 'patch' | (string & {});
|
|
534
|
+
/** 计算下一版本号;release 为 major/minor/patch 时递增,否则按显式版本号原样采用 */
|
|
535
|
+
declare function bumpVersion(current: string, release: VersionRelease): string;
|
|
536
|
+
interface BumpPackageVersionOptions {
|
|
537
|
+
/** 工程根目录 */
|
|
538
|
+
dir?: string;
|
|
539
|
+
/** 递增级别或显式版本号 */
|
|
540
|
+
release: VersionRelease;
|
|
541
|
+
}
|
|
542
|
+
interface BumpPackageVersionResult {
|
|
543
|
+
name: string;
|
|
544
|
+
from: string;
|
|
545
|
+
to: string;
|
|
546
|
+
}
|
|
547
|
+
/** 递增工程 package.json 的 version 并写回(保留其余字段,2 空格缩进 + 末尾换行) */
|
|
548
|
+
declare function bumpPackageVersion(options: BumpPackageVersionOptions): BumpPackageVersionResult;
|
|
549
|
+
|
|
550
|
+
export { type BuildModuleOptions, type BuildModuleResult, type BumpPackageVersionOptions, type BumpPackageVersionResult, type BundleClientOptions, type BundleClientResult, type BundleServerOptions, type BundleServerResult, CLIENT_EXTERNALS, CLIENT_STYLES_ENTRY, CONFIG_DEFAULTS, CONFIG_FILE, type CollectedSource, type CompileTailwindOptions, type CompileTailwindResult, ConfigError, DEFAULT_TARGET, INCLUDE_KEY, IncludeError, type InitModuleOptions, type InitModuleResult, MODULE_ID_PREFIX, ModuleBuildError, type ModuleManifest, type ModulePackConfig, ProfileError, type RewriteContext, type RewriteNavigationProfile, type RewriteResult, SERVER_BUNDLE_FILE, SERVER_ENTRY, SERVER_EXTERNALS, ServerBundleError, type TailwindConfig, type TargetProfile, type TransformSitemapOptions, type TransformSitemapResult, type ValidateModuleOptions, type ValidateModuleResult, type VersionRelease, buildModule, bumpPackageVersion, bumpVersion, bundleClient, bundleServer, collectModuleSource, compileTailwind, deriveApiPrefix, deriveModuleId, discoverActions, discoverComponents, emitDsl, emitModule, expandIncludes, getProfile, initModule, innospotsWebShellV1, innospotsWebShellV2, innospotsWebShellV3, listProfiles, loadModuleConfig, loadYamlExpanded, matchPathPattern, parseJsonc, parseYamlFile, readProjectVersion, renderClientEntry, renderModuleStyles, renderServerEntry, resolvePactorVersionRange, rewriteDslUrls, rewriteNavigationTo, transformSitemap, tsconfigAliases, validateModule, writeManifest };
|
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ interface BuildModuleResult {
|
|
|
28
28
|
assets: number;
|
|
29
29
|
};
|
|
30
30
|
clientBundled: boolean;
|
|
31
|
+
serverBundled: boolean;
|
|
31
32
|
warnings: string[];
|
|
32
33
|
}
|
|
33
34
|
/** 执行模块构建全链路,返回产物摘要;失败抛 ModuleBuildError */
|
|
@@ -62,17 +63,36 @@ declare function validateModule(options?: ValidateModuleOptions): ValidateModule
|
|
|
62
63
|
/**
|
|
63
64
|
* `initModule`:目标工程接入面的一次性初始化(幂等、只新增不破坏):
|
|
64
65
|
* - 生成 pactor.module.json(已存在则跳过);
|
|
65
|
-
* -
|
|
66
|
+
* - 生成 module/client.ts + module/module.css(已存在则跳过);
|
|
67
|
+
* - `--server` 时额外生成 module/server.ts 并在新建配置中写入 serverEntry / apiPrefixes;
|
|
66
68
|
* - 向 package.json 注入 files / exports / scripts / peerDependencies
|
|
67
69
|
* (已存在的字段不覆盖,冲突时 warning)。
|
|
68
70
|
* 绝不修改目标工程 app/、src/ 下的任何现有文件。
|
|
69
71
|
*/
|
|
72
|
+
/** 生成的模块样式入口(与 client entry 同属脚手架,由 client.ts import) */
|
|
73
|
+
declare const CLIENT_STYLES_ENTRY = "module/module.css";
|
|
74
|
+
/** 默认 server 入口(仅 `init --server` 生成) */
|
|
75
|
+
declare const SERVER_ENTRY = "module/server.ts";
|
|
70
76
|
interface InitModuleOptions {
|
|
71
77
|
/** 目标工程根(默认 cwd) */
|
|
72
78
|
dir?: string;
|
|
79
|
+
/**
|
|
80
|
+
* 覆盖已存在的初始化文件(pactor.module.json / module/client.ts / 脚手架样式,
|
|
81
|
+
* --server 时含 module/server.ts)。
|
|
82
|
+
* 缺省 false 时跳过已存在文件;由 CLI 负责询问用户后传入。
|
|
83
|
+
*/
|
|
84
|
+
overwrite?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* 额外生成 module/server.ts,并在新建的 pactor.module.json 中写入
|
|
87
|
+
* serverEntry 与 apiPrefixes(默认 /api/<模块 slug>)。
|
|
88
|
+
* 缺省 false:纯 DSL 模块不引入 server entry。
|
|
89
|
+
*/
|
|
90
|
+
server?: boolean;
|
|
73
91
|
}
|
|
74
92
|
interface InitModuleResult {
|
|
75
93
|
created: string[];
|
|
94
|
+
/** overwrite 时重新生成(覆盖)的文件 */
|
|
95
|
+
overwritten: string[];
|
|
76
96
|
skipped: string[];
|
|
77
97
|
warnings: string[];
|
|
78
98
|
}
|
|
@@ -82,16 +102,24 @@ interface ActionSource {
|
|
|
82
102
|
/** 具名导出(如 riskActions) */
|
|
83
103
|
exports: string[];
|
|
84
104
|
}
|
|
85
|
-
/** 执行初始化,返回创建 / 跳过 / 告警清单 */
|
|
105
|
+
/** 执行初始化,返回创建 / 覆盖 / 跳过 / 告警清单 */
|
|
86
106
|
declare function initModule(options?: InitModuleOptions): InitModuleResult;
|
|
87
|
-
/**
|
|
107
|
+
/** 模块 id 统一前缀(缺省自动补齐,已有则不重复添加) */
|
|
108
|
+
declare const MODULE_ID_PREFIX = "pactor-app-";
|
|
109
|
+
/** 从包名推导模块 id:去 scope、kebab 化、补 pactor-app- 前缀 */
|
|
88
110
|
declare function deriveModuleId(name: unknown): string;
|
|
111
|
+
/** 由模块 id 推导默认 API 前缀:/api/<去掉 pactor-app- 前缀的 slug> */
|
|
112
|
+
declare function deriveApiPrefix(moduleId: string): string;
|
|
89
113
|
/** 扫描 src/pactor/*-actions.ts 的具名导出(export const xxx) */
|
|
90
114
|
declare function discoverActions(projectDir: string): ActionSource[];
|
|
91
115
|
/** 检测 src/pactor/components/index.ts 是否导出 pactorComponents */
|
|
92
116
|
declare function discoverComponents(projectDir: string): boolean;
|
|
93
117
|
/** 生成 module/client.ts 内容(export const extensions = { components, actions }) */
|
|
94
118
|
declare function renderClientEntry(hasComponents: boolean, actions: ActionSource[]): string;
|
|
119
|
+
/** 生成 module/module.css 内容(模块自带样式入口,随 client bundle 打进 tgz) */
|
|
120
|
+
declare function renderModuleStyles(): string;
|
|
121
|
+
/** 生成 module/server.ts 内容(逻辑路径 → 方法处理函数映射) */
|
|
122
|
+
declare function renderServerEntry(moduleId: string): string;
|
|
95
123
|
|
|
96
124
|
/**
|
|
97
125
|
* `pactor.module.json` 配置加载与校验(手写校验,避免重依赖)。
|
|
@@ -116,13 +144,24 @@ interface ModulePackConfig {
|
|
|
116
144
|
basePath: string;
|
|
117
145
|
yamlRoot: string;
|
|
118
146
|
clientEntry: string;
|
|
147
|
+
/** 服务端入口(工程相对路径,如 module/server.ts);与 apiPrefixes 成对出现 */
|
|
148
|
+
serverEntry?: string;
|
|
149
|
+
/**
|
|
150
|
+
* 模块 API 逻辑前缀(如 /api/risk-analysis)。打包时命中这些前缀的 DSL URL
|
|
151
|
+
* 会改写为 /api/modules/<id>/...,由 Shell 的通用分发入口承接。
|
|
152
|
+
*/
|
|
153
|
+
apiPrefixes?: string[];
|
|
119
154
|
/** init 时自动发现的 src/pactor/*-actions.ts(仅记录,client entry 自行 import) */
|
|
120
155
|
actions: string[];
|
|
121
156
|
publicDir: string;
|
|
122
157
|
/** target profile id(如 innospots-web-shell@2) */
|
|
123
158
|
target: string;
|
|
124
|
-
|
|
125
|
-
|
|
159
|
+
/**
|
|
160
|
+
* 模块级访问默认值:'public' 时构建期给未声明 public/permission 的
|
|
161
|
+
* pages / menus 补 public: true(缺省填充);默认 'authenticated' 不改动。
|
|
162
|
+
*/
|
|
163
|
+
access: {
|
|
164
|
+
default: 'public' | 'authenticated';
|
|
126
165
|
};
|
|
127
166
|
tailwind: TailwindConfig;
|
|
128
167
|
rewrite: {
|
|
@@ -172,6 +211,8 @@ interface TargetProfile {
|
|
|
172
211
|
rewriteAssetUrls: (id: string, version: string) => string;
|
|
173
212
|
/** 禁止 basePath: "/"(Shell joinPublicPath 会产生 "//login" 这类坏路径) */
|
|
174
213
|
forbidRootBasePath: boolean;
|
|
214
|
+
/** Shell 支持 `/api/modules/<moduleId>/*` 通用模块 API 分发 */
|
|
215
|
+
moduleServerApi: boolean;
|
|
175
216
|
}
|
|
176
217
|
|
|
177
218
|
/**
|
|
@@ -181,16 +222,23 @@ interface TargetProfile {
|
|
|
181
222
|
*/
|
|
182
223
|
declare const innospotsWebShellV1: TargetProfile;
|
|
183
224
|
/**
|
|
184
|
-
* innospots-web-shell@2
|
|
225
|
+
* innospots-web-shell@2:Shell lazy 页面端点已修复,
|
|
185
226
|
* 返回 PageResource 信封 { id, resourceType: "page", version, dslVersion, schema },
|
|
186
227
|
* 与 @pactor-app/app createSitemapLoader 契约对齐,lazy: true 原样保留。
|
|
187
228
|
*/
|
|
188
229
|
declare const innospotsWebShellV2: TargetProfile;
|
|
230
|
+
/**
|
|
231
|
+
* innospots-web-shell@3(当前默认):在 @2 的页面/导航/资源契约之上,
|
|
232
|
+
* Shell 新增 `/api/modules/<moduleId>/*` 通用分发入口,支持模块把
|
|
233
|
+
* server entry(module/server.ts)打进 tgz 并由 Shell 统一承接。
|
|
234
|
+
* 未使用 serverEntry 的模块产物与 @2 完全一致。
|
|
235
|
+
*/
|
|
236
|
+
declare const innospotsWebShellV3: TargetProfile;
|
|
189
237
|
|
|
190
238
|
/** 未知 profile 错误(信息中列出可用值) */
|
|
191
239
|
declare class ProfileError extends Error {
|
|
192
240
|
}
|
|
193
|
-
/** 默认 target
|
|
241
|
+
/** 默认 target:支持模块 server entry 的 Shell 契约版本 */
|
|
194
242
|
declare const DEFAULT_TARGET: string;
|
|
195
243
|
/** 全部可用 profile id(用于报错提示与文档) */
|
|
196
244
|
declare function listProfiles(): string[];
|
|
@@ -252,12 +300,15 @@ declare function expandIncludes(value: unknown, ctx: ExpandContext): unknown;
|
|
|
252
300
|
* - inlineStringLayouts:字符串形式的布局引用解析为内联布局对象;
|
|
253
301
|
* - stripMenuPaths:删除菜单显式 path(运行时按 pageId 从 pages 回填);
|
|
254
302
|
* - forceInlinePages:删除页面 lazy(随 bootstrap 内联下发);
|
|
255
|
-
* -
|
|
303
|
+
* - accessDefault='public':给未声明 public/permission 的 pages / menus 补 public: true。
|
|
256
304
|
*/
|
|
257
305
|
interface TransformSitemapOptions {
|
|
258
306
|
profile: TargetProfile;
|
|
259
|
-
/**
|
|
260
|
-
|
|
307
|
+
/**
|
|
308
|
+
* 模块级访问默认值:'public' 时给未声明 public/permission 的 pages / menus
|
|
309
|
+
* 补 public: true(缺省填充,不覆盖显式声明);'authenticated' 不改动。
|
|
310
|
+
*/
|
|
311
|
+
accessDefault?: 'public' | 'authenticated';
|
|
261
312
|
/** 解析字符串布局引用(yamlRoot 相对路径 -> 布局对象,应走 $include 展开) */
|
|
262
313
|
loadLayout: (relPath: string) => unknown;
|
|
263
314
|
}
|
|
@@ -299,6 +350,10 @@ interface RewriteContext {
|
|
|
299
350
|
assetPrefix: string;
|
|
300
351
|
/** 绝对 API 地址重写为相对路径(false 时仅告警不改写) */
|
|
301
352
|
absoluteApiToRelative: boolean;
|
|
353
|
+
/** 模块 id(与 apiPrefixes 同时存在时,命中前缀的 API URL 改写为模块挂载路径) */
|
|
354
|
+
moduleId?: string;
|
|
355
|
+
/** 模块声明的逻辑 API 前缀(如 `/api/risk-analysis`) */
|
|
356
|
+
apiPrefixes?: string[];
|
|
302
357
|
}
|
|
303
358
|
interface RewriteResult {
|
|
304
359
|
value: unknown;
|
|
@@ -352,6 +407,38 @@ declare function tsconfigAliases(projectDir: string): Record<string, string>;
|
|
|
352
407
|
/** 宽松 JSONC 解析:去注释(尊重字符串字面量)与尾逗号 */
|
|
353
408
|
declare function parseJsonc(text: string): unknown;
|
|
354
409
|
|
|
410
|
+
/**
|
|
411
|
+
* server entry 打包(esbuild):
|
|
412
|
+
* - `--bundle --format=esm --platform=node --target=node20`;
|
|
413
|
+
* - 产物固定为 server/index.mjs:模块包通常没有 `"type": "module"`,
|
|
414
|
+
* 若输出 .js 会被 Node 按 CJS 解析;esbuild 的 format=esm 不会自动改扩展名,
|
|
415
|
+
* 因此必须显式 outExtension;
|
|
416
|
+
* - react / next / pactor 保持 external(server 端不需要,也不该打入模块);
|
|
417
|
+
* Node built-in 由 platform=node 自动 external;
|
|
418
|
+
* - alias 复用 tsconfig 的 paths(如 `@/*` → `./src/*`);
|
|
419
|
+
* - 入口必须位于工程根内,防止越界读取。
|
|
420
|
+
*/
|
|
421
|
+
/** 内置 externals:宿主/框架依赖,绝不打进 server bundle */
|
|
422
|
+
declare const SERVER_EXTERNALS: string[];
|
|
423
|
+
/** server 产物文件名(与 manifest.serverEntry 一致) */
|
|
424
|
+
declare const SERVER_BUNDLE_FILE: "index.mjs";
|
|
425
|
+
/** server 打包错误(入口缺失 / 越界 / 产物缺失) */
|
|
426
|
+
declare class ServerBundleError extends Error {
|
|
427
|
+
}
|
|
428
|
+
interface BundleServerOptions {
|
|
429
|
+
projectDir: string;
|
|
430
|
+
/** 工程相对路径(配置 serverEntry) */
|
|
431
|
+
serverEntry: string;
|
|
432
|
+
/** 输出目录(绝对路径,产物为 index.mjs / index.mjs.map) */
|
|
433
|
+
outDir: string;
|
|
434
|
+
}
|
|
435
|
+
interface BundleServerResult {
|
|
436
|
+
bundled: true;
|
|
437
|
+
entry: typeof SERVER_BUNDLE_FILE;
|
|
438
|
+
}
|
|
439
|
+
/** esbuild 打包 server entry;入口不存在或越界时抛 ServerBundleError */
|
|
440
|
+
declare function bundleServer(options: BundleServerOptions): BundleServerResult;
|
|
441
|
+
|
|
355
442
|
/**
|
|
356
443
|
* 可选 Tailwind 预编译(配置 `tailwind: { enabled, input?, scan? }`):
|
|
357
444
|
* 调用目标工程的 tailwindcss CLI(npx --no-install tailwindcss,v4 / @tailwindcss/cli),
|
|
@@ -396,6 +483,10 @@ interface ModuleManifest {
|
|
|
396
483
|
/** 纯 DSL 模块无 client bundle 时缺省 */
|
|
397
484
|
clientEntry?: 'client/index.js';
|
|
398
485
|
styles?: ['client/index.css'];
|
|
486
|
+
/** 服务端入口(存在 server bundle 时输出) */
|
|
487
|
+
serverEntry?: 'server/index.mjs';
|
|
488
|
+
/** 模块 API 逻辑前缀(与 serverEntry 成对输出) */
|
|
489
|
+
apiPrefixes?: string[];
|
|
399
490
|
}
|
|
400
491
|
interface EmitDslInput {
|
|
401
492
|
config: ModulePackConfig;
|
|
@@ -416,6 +507,8 @@ interface WriteManifestInput {
|
|
|
416
507
|
outDir: string;
|
|
417
508
|
clientEntry?: 'client/index.js';
|
|
418
509
|
styles?: ['client/index.css'];
|
|
510
|
+
serverEntry?: 'server/index.mjs';
|
|
511
|
+
apiPrefixes?: string[];
|
|
419
512
|
/** 追加版本推导相关的告警 */
|
|
420
513
|
warnings: string[];
|
|
421
514
|
}
|
|
@@ -436,4 +529,22 @@ declare function readProjectVersion(projectDir: string): string;
|
|
|
436
529
|
*/
|
|
437
530
|
declare function resolvePactorVersionRange(projectDir: string, warnings: string[]): string;
|
|
438
531
|
|
|
439
|
-
|
|
532
|
+
/** 版本递增类型:语义化级别或显式版本号(如 2.0.0 / 2.0.0-beta.1) */
|
|
533
|
+
type VersionRelease = 'major' | 'minor' | 'patch' | (string & {});
|
|
534
|
+
/** 计算下一版本号;release 为 major/minor/patch 时递增,否则按显式版本号原样采用 */
|
|
535
|
+
declare function bumpVersion(current: string, release: VersionRelease): string;
|
|
536
|
+
interface BumpPackageVersionOptions {
|
|
537
|
+
/** 工程根目录 */
|
|
538
|
+
dir?: string;
|
|
539
|
+
/** 递增级别或显式版本号 */
|
|
540
|
+
release: VersionRelease;
|
|
541
|
+
}
|
|
542
|
+
interface BumpPackageVersionResult {
|
|
543
|
+
name: string;
|
|
544
|
+
from: string;
|
|
545
|
+
to: string;
|
|
546
|
+
}
|
|
547
|
+
/** 递增工程 package.json 的 version 并写回(保留其余字段,2 空格缩进 + 末尾换行) */
|
|
548
|
+
declare function bumpPackageVersion(options: BumpPackageVersionOptions): BumpPackageVersionResult;
|
|
549
|
+
|
|
550
|
+
export { type BuildModuleOptions, type BuildModuleResult, type BumpPackageVersionOptions, type BumpPackageVersionResult, type BundleClientOptions, type BundleClientResult, type BundleServerOptions, type BundleServerResult, CLIENT_EXTERNALS, CLIENT_STYLES_ENTRY, CONFIG_DEFAULTS, CONFIG_FILE, type CollectedSource, type CompileTailwindOptions, type CompileTailwindResult, ConfigError, DEFAULT_TARGET, INCLUDE_KEY, IncludeError, type InitModuleOptions, type InitModuleResult, MODULE_ID_PREFIX, ModuleBuildError, type ModuleManifest, type ModulePackConfig, ProfileError, type RewriteContext, type RewriteNavigationProfile, type RewriteResult, SERVER_BUNDLE_FILE, SERVER_ENTRY, SERVER_EXTERNALS, ServerBundleError, type TailwindConfig, type TargetProfile, type TransformSitemapOptions, type TransformSitemapResult, type ValidateModuleOptions, type ValidateModuleResult, type VersionRelease, buildModule, bumpPackageVersion, bumpVersion, bundleClient, bundleServer, collectModuleSource, compileTailwind, deriveApiPrefix, deriveModuleId, discoverActions, discoverComponents, emitDsl, emitModule, expandIncludes, getProfile, initModule, innospotsWebShellV1, innospotsWebShellV2, innospotsWebShellV3, listProfiles, loadModuleConfig, loadYamlExpanded, matchPathPattern, parseJsonc, parseYamlFile, readProjectVersion, renderClientEntry, renderModuleStyles, renderServerEntry, resolvePactorVersionRange, rewriteDslUrls, rewriteNavigationTo, transformSitemap, tsconfigAliases, validateModule, writeManifest };
|