@cloudbase/manager-node 5.7.1-beta.1 → 5.8.0-beta.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.
Files changed (62) hide show
  1. package/lib/cloudApp/index.js +12 -3
  2. package/lib/deploy/DatabaseDeployer.js +238 -0
  3. package/lib/deploy/DeployOrchestrator.js +645 -0
  4. package/lib/deploy/FunctionDeployer.js +611 -0
  5. package/lib/deploy/GatewayDeployer.js +612 -0
  6. package/lib/deploy/StateStore.js +327 -0
  7. package/lib/deploy/StaticDeployer.js +236 -0
  8. package/lib/deploy/domain.js +41 -0
  9. package/lib/deploy/framework.js +230 -0
  10. package/lib/deploy/function/artifact.js +207 -0
  11. package/lib/deploy/function/builders/cloud.js +654 -0
  12. package/lib/deploy/function/cam-preflight.js +157 -0
  13. package/lib/deploy/function/cloud-build-service.js +191 -0
  14. package/lib/deploy/function/config-guard.js +595 -0
  15. package/lib/deploy/function/docker-preflight.js +87 -0
  16. package/lib/deploy/function/image-preflight.js +164 -0
  17. package/lib/deploy/function/local-builder.js +129 -0
  18. package/lib/deploy/function/planner.js +278 -0
  19. package/lib/deploy/function/preflight.js +329 -0
  20. package/lib/deploy/types.js +103 -0
  21. package/lib/env/index.js +0 -27
  22. package/lib/environment.js +11 -0
  23. package/lib/function/index.js +1 -1
  24. package/lib/hosting/index.js +4 -1
  25. package/lib/index.js +31 -0
  26. package/lib/projectValidator/index.js +452 -0
  27. package/lib/projectValidator/types.js +2 -0
  28. package/lib/storage/index.js +6 -7
  29. package/lib/utils/index.js +62 -5
  30. package/package.json +2 -1
  31. package/types/cloudApp/index.d.ts +4 -0
  32. package/types/cloudApp/types.d.ts +87 -6
  33. package/types/deploy/DatabaseDeployer.d.ts +70 -0
  34. package/types/deploy/DeployOrchestrator.d.ts +170 -0
  35. package/types/deploy/FunctionDeployer.d.ts +159 -0
  36. package/types/deploy/GatewayDeployer.d.ts +194 -0
  37. package/types/deploy/StateStore.d.ts +170 -0
  38. package/types/deploy/StaticDeployer.d.ts +97 -0
  39. package/types/deploy/domain.d.ts +17 -0
  40. package/types/deploy/framework.d.ts +63 -0
  41. package/types/deploy/function/artifact.d.ts +40 -0
  42. package/types/deploy/function/builders/cloud.d.ts +110 -0
  43. package/types/deploy/function/cam-preflight.d.ts +51 -0
  44. package/types/deploy/function/cloud-build-service.d.ts +10 -0
  45. package/types/deploy/function/config-guard.d.ts +41 -0
  46. package/types/deploy/function/docker-preflight.d.ts +17 -0
  47. package/types/deploy/function/image-preflight.d.ts +21 -0
  48. package/types/deploy/function/local-builder.d.ts +26 -0
  49. package/types/deploy/function/planner.d.ts +15 -0
  50. package/types/deploy/function/preflight.d.ts +9 -0
  51. package/types/deploy/types.d.ts +429 -0
  52. package/types/env/index.d.ts +1 -17
  53. package/types/env/type.d.ts +6 -260
  54. package/types/environment.d.ts +7 -0
  55. package/types/function/types.d.ts +15 -0
  56. package/types/hosting/index.d.ts +6 -0
  57. package/types/index.d.ts +18 -0
  58. package/types/interfaces/function.interface.d.ts +1 -1
  59. package/types/projectValidator/index.d.ts +38 -0
  60. package/types/projectValidator/types.d.ts +26 -0
  61. package/types/storage/index.d.ts +6 -0
  62. package/types/utils/index.d.ts +13 -0
@@ -10,19 +10,80 @@
10
10
  * 部署类型
11
11
  * - static-hosting: 静态托管部署
12
12
  * - http-function: HTTP 云函数部署(预留)
13
+ * - custom: 自定义构建(CloudApp custom:源码 ZIP → 容器内执行 CustomSteps → docker build/push TCR),
14
+ * 用于 HTTP 函数镜像的云端构建(buildStrategy: cloud)
13
15
  */
14
- export type DeployType = 'static-hosting' | 'http-function';
16
+ export type DeployType = 'static-hosting' | 'http-function' | 'custom';
15
17
  /**
16
18
  * 构建类型
17
19
  * - GIT: 从 Git 仓库构建
18
20
  * - ZIP: 从 ZIP 包构建
19
21
  * - TEMPLATE: 从模板构建
22
+ * - zip: custom 构建的源码 ZIP(与 API 文档 BuildType 大小写保持一致)
20
23
  */
21
- export type BuildType = 'GIT' | 'ZIP' | 'TEMPLATE';
24
+ export type BuildType = 'GIT' | 'ZIP' | 'TEMPLATE' | 'zip' | 'git';
25
+ /**
26
+ * custom 构建源码来源
27
+ *对应 API 的 Source 字段,zip 模式回填 DescribeCloudAppCosInfo 返回的时间戳
28
+ */
29
+ export interface ICustomBuildSource {
30
+ /** 源码类型,当前实现为 zip */
31
+ type: 'zip' | 'git';
32
+ /** COS 时间戳,原样使用 DescribeCloudAppCosInfo 返回的 UnixTimestamp */
33
+ cosTimestamp?: string;
34
+ /** COS 文件后缀,默认 .zip */
35
+ cosSuffix?: string;
36
+ }
37
+ /** custom 构建环境变量项(明文,禁止写入敏感值) */
38
+ export interface ICustomBuildEnv {
39
+ key: string;
40
+ value: string;
41
+ }
42
+ /**
43
+ * custom 构建密钥项
44
+ * CloudApp 在构建容器中按 $SECRET_{NAME} 注入,Value 不应进入日志或普通环境变量。
45
+ */
46
+ export interface ICustomBuildSecret {
47
+ name: string;
48
+ value: string;
49
+ }
50
+ /**
51
+ * custom 构建自定义步骤
52
+ * SDK 固定生成模板,用户不可控字段绝不作为任意 shell 片段拼接
53
+ */
54
+ export interface ICustomBuildStep {
55
+ name: string;
56
+ command: string;
57
+ }
58
+ /**
59
+ * custom 构建单步状态(API 响应,字段大小写与响应一致)
60
+ * 注意:Duration 为字符串、Status 为小写
61
+ */
62
+ export interface CloudAppBuildStep {
63
+ Name: string;
64
+ Status: string;
65
+ Duration?: string;
66
+ /** 失败时的退出码,用于定位 */
67
+ ExitCode?: number;
68
+ }
69
+ /**
70
+ * custom 构建产物(API 响应)
71
+ * 镜像构建成功后Type 通常为 image
72
+ */
73
+ export interface CloudAppArtifact {
74
+ Type: string;
75
+ Name: string;
76
+ Status?: string;
77
+ /** 部分场景直接回传完整镜像地址 */
78
+ ImageUri?: string;
79
+ /** 部分场景回传 digest */
80
+ Digest?: string;
81
+ }
22
82
  /**
23
83
  * 构建状态
84
+ * custom 构建终态为 SUCCESS / FAILED / CANCELED
24
85
  */
25
- export type BuildStatus = 'BUILDING' | 'SUCCESS' | 'FAILED';
86
+ export type BuildStatus = 'BUILDING' | 'SUCCESS' | 'FAILED' | 'CANCELED';
26
87
  /**
27
88
  * 构建命令配置(入参)
28
89
  */
@@ -149,14 +210,24 @@ export interface CloudAppVersion {
149
210
  export interface ICreateCloudAppParams {
150
211
  /** 环境 ID(可选,默认从 Environment 获取) */
151
212
  envId?: string;
152
- /** 部署类型:static-hosting / http-function */
213
+ /** 部署类型:static-hosting / http-function / custom */
153
214
  deployType: DeployType;
154
215
  /** 服务名称 */
155
216
  serviceName: string;
156
- /** 构建类型:GIT / ZIP / TEMPLATE */
217
+ /** 构建类型:GIT / ZIP / TEMPLATE / zip / git */
157
218
  buildType?: BuildType;
158
219
  /** 静态托管配置(deployType 为 static-hosting 时使用) */
159
220
  staticConfig?: IStaticConfig;
221
+ /** custom 构建源码来源(deployType 为 custom 时使用) */
222
+ source?: ICustomBuildSource;
223
+ /** custom 构建环境变量(deployType 为 custom 时使用,禁止敏感值) */
224
+ env?: ICustomBuildEnv[];
225
+ /** custom 构建密钥(deployType 为 custom 时使用) */
226
+ secrets?: ICustomBuildSecret[];
227
+ /** custom 构建自定义步骤(deployType 为 custom 时使用,SDK 固定模板) */
228
+ customSteps?: ICustomBuildStep[];
229
+ /** 跳过云端构建(纯静态直传场景:产物已直传,仅写部署记录,对应 API SkipBuild) */
230
+ skipBuild?: boolean;
160
231
  }
161
232
  export interface ICreateCloudAppResult {
162
233
  ServiceName: string;
@@ -232,6 +303,10 @@ export interface IDescribeCloudAppVersionResult {
232
303
  Framework?: string;
233
304
  StaticConfig?: CloudAppStaticConfig;
234
305
  BuildTime?: string;
306
+ /** custom 构建的分步状态(deployType 为 custom 时返回) */
307
+ Steps?: CloudAppBuildStep[] | null;
308
+ /** custom 构建产物(deployType 为 custom 时返回,镜像信息优先从此获取) */
309
+ Artifacts?: CloudAppArtifact[] | null;
235
310
  RequestId: string;
236
311
  }
237
312
  export interface IDescribeCloudAppVersionListParams {
@@ -324,8 +399,14 @@ export interface IUploadCloudAppCodeParams {
324
399
  serviceName: string;
325
400
  /** 本地文件夹路径 */
326
401
  localPath: string;
327
- /** 忽略的文件/目录模式 */
402
+ /** 忽略的文件/目录模式(追加到内置默认规则之后) */
328
403
  ignore?: string[];
404
+ /**
405
+ * 是否排除 node_modules:
406
+ * 默认 true(静态产物 / 版本快照场景,避免误传大目录);
407
+ * 云端构建(需云端 install)场景设为 false,允许私有/离线依赖随源码包上传
408
+ */
409
+ excludeNodeModules?: boolean;
329
410
  /** 进度回调 */
330
411
  onProgress?: (progress: IProgressData) => void;
331
412
  /** 分步计时回调(各阶段完成时触发,用于 verbose 模式输出耗时) */
@@ -0,0 +1,70 @@
1
+ import { Environment } from '../environment';
2
+ import { IPGUserMigrationInput } from '../database/type';
3
+ /** 数据库迁移部署配置(对应 cloudbaserc.json 中的 database 块) */
4
+ export interface IDatabaseDeployConfig {
5
+ /** 数据库类型(v2.1 schema: 目前仅支持 postgresql) */
6
+ type: 'postgresql';
7
+ /** migration SQL 文件目录(相对项目根) */
8
+ migrations?: string;
9
+ }
10
+ /** Plan 中单条 migration 的状态 */
11
+ export interface IDatabasePlanItem {
12
+ /** 14位数字时间串 */
13
+ version: string;
14
+ /** migration 名称 */
15
+ name: string;
16
+ /** pending=待执行;applied=已应用;conflict=冲突 */
17
+ status: 'pending' | 'applied' | 'conflict';
18
+ /** 冲突原因(仅 conflict 时有值) */
19
+ reason?: string;
20
+ }
21
+ /** deploy 返回结果 */
22
+ export interface IDatabaseDeployResult {
23
+ /** 异步任务 ID(无pending时为空字符串) */
24
+ taskId: string;
25
+ }
26
+ export declare class DatabaseDeployer {
27
+ private environment;
28
+ constructor(environment: Environment);
29
+ /**
30
+ * 从本地目录解析 migration 文件列表
31
+ *
32
+ * 文件名格式:{14位时间戳}_{小写下划线名称}.sql
33
+ * 例如:20260526000000_create_users.sql
34
+ *
35
+ * 按文件名升序排列(即按版本号从早到晚)
36
+ */
37
+ parseMigrationFiles(migrationsDir: string): IPGUserMigrationInput[];
38
+ /**
39
+ * 生成部署计划
40
+ *
41
+ * 调用 previewPGUserMigrations 获取云端对比结果,
42
+ * 返回每条migration 的状态(pending / applied / conflict)
43
+ */
44
+ plan(config: IDatabaseDeployConfig, cwd: string, envId: string): Promise<IDatabasePlanItem[]>;
45
+ /**
46
+ * 执行数据库迁移
47
+ *
48
+ * 流程:
49
+ * 1. 解析本地 migration 文件
50
+ * 2. 预览确认无冲突(有冲突直接 throw,中断整个部署)
51
+ * 3. 无 pending 则跳过
52
+ * 4. 提交 pushPGUserMigrations
53
+ * 5. 轮询describeTaskResult 等待完成
54
+ */
55
+ deploy(config: IDatabaseDeployConfig, cwd: string, envId: string): Promise<IDatabaseDeployResult>;
56
+ /**
57
+ * 解析 migrations 目录路径
58
+ * - 未配置:默认 ./cloudbase/migrations
59
+ * - 仅允许相对路径(禁止 / 开头)
60
+ */
61
+ private resolveMigrationsDir;
62
+ /**
63
+ * 校验 database.type(当前仅支持 postgresql)
64
+ */
65
+ private assertDatabaseType;
66
+ /**
67
+ * 轮询等待异步任务完成
68
+ */
69
+ private waitForTask;
70
+ }
@@ -0,0 +1,170 @@
1
+ import { Environment } from '../environment';
2
+ /** 可编排的资源类型 */
3
+ export type ResourceType = 'database' | 'functions' | 'app' | 'hosting' | 'gateway';
4
+ /** 声明式部署选项 */
5
+ export interface IDeployOptions {
6
+ /** 解析后的 cloudbaserc 配置(ConfigParser 输出,含 envOverrides 已应用) */
7
+ config: Record<string, any>;
8
+ envId: string;
9
+ /** 只部署指定类型 */
10
+ only?: ResourceType[];
11
+ /** 跳过指定类型 */
12
+ skip?: ResourceType[];
13
+ /** dry-run:只输出计划不实际部署 */
14
+ dryRun?: boolean;
15
+ /** 项目根目录(默认 process.cwd()) */
16
+ cwd?: string;
17
+ /** 已存在资源(函数)的覆盖更新:yes=true 直接放行(AI Agent / CI 场景) */
18
+ yes?: boolean;
19
+ /** 已存在资源(函数)的覆盖更新确认回调:返回 true 部署、false 跳过(CLI 注入 autoConfirm) */
20
+ confirmUpdate?: (item: IDeployPlanItem) => Promise<boolean>;
21
+ /** 强制云端对比(漂移检测):忽略本地 state 快照的 skip 判定,强制重新对比/部署 */
22
+ refresh?: boolean;
23
+ /** 同类型资源最大并行数,默认 1(串行)。仅作用于同类型连续实例之间,跨类型依赖顺序不变 */
24
+ concurrency?: number;
25
+ /** 失败后继续部署其余资源(database 失败仍强制中断) */
26
+ continueOnError?: boolean;
27
+ log?: {
28
+ info?: (msg: string) => void;
29
+ success?: (msg: string) => void;
30
+ warn?: (msg: string) => void;
31
+ error?: (msg: string) => void;
32
+ };
33
+ }
34
+ /** 部署计划项(资源级) */
35
+ export interface IDeployPlanItem {
36
+ type: ResourceType;
37
+ name: string;
38
+ /** 动作分类:create=新建;update=覆盖更新已有资源;skip=已存在且配置一致;conflict=检测到冲突(需中断);deploy=直传覆盖(无存在性概念) */
39
+ status: 'create' | 'update' | 'skip' | 'conflict' | 'deploy';
40
+ /** 动作说明(用户可读) */
41
+ action: string;
42
+ /** 变更字段明细(如 database 迁移聚合、gateway 路由差异等) */
43
+ changes?: Array<{
44
+ field: string;
45
+ from?: string;
46
+ to?: string;
47
+ }>;
48
+ /** hosting 文件级 diff(新增/修改/删除,前 N 条 + 统计) */
49
+ fileDiff?: {
50
+ added: string[];
51
+ modified: string[];
52
+ deleted: string[];
53
+ totalChanged: number;
54
+ };
55
+ /** 资源级详情子行(dry-run 树状渲染用):如函数 runtime/构建策略、迁移逐条状态等 */
56
+ details?: Array<{
57
+ label: string;
58
+ value: string;
59
+ }>;
60
+ }
61
+ /** 部署结果 */
62
+ export interface IDeployResult {
63
+ plan: IDeployPlanItem[];
64
+ results: Array<{
65
+ type: ResourceType;
66
+ name: string;
67
+ ok: boolean;
68
+ url?: string;
69
+ error?: string;
70
+ /** 原始异常中的请求 ID(若可提取),用于定位平台侧接口报错 */
71
+ requestId?: string;
72
+ /** 未执行原因:skip=未变更自动跳过;no-confirm=无确认机制保守跳过;skipped-by-user=用户拒绝覆盖 */
73
+ reason?: 'skip' | 'no-confirm' | 'skipped-by-user';
74
+ }>;
75
+ }
76
+ /**
77
+ * 声明式部署编排器
78
+ * 顺序:database → functions → app → hosting → gateway
79
+ * 支持 dry-run / only / skip / 幂等重试(database 失败/冲突会中断后续步骤)
80
+ */
81
+ export declare class DeployOrchestrator {
82
+ private environment;
83
+ private databaseDeployer;
84
+ private functionDeployer;
85
+ private staticDeployer;
86
+ private gatewayDeployer;
87
+ constructor(environment: Environment);
88
+ /**
89
+ * 计算部署计划(dry-run 输出)
90
+ */
91
+ deployPlan(options: IDeployOptions): Promise<IDeployPlanItem[]>;
92
+ /**
93
+ * 执行部署
94
+ *
95
+ * 编排模型:plan 按「连续相同资源类型」切成 segments,segment 之间严格按
96
+ * DEPLOY_ORDER 串行;segment 内部按 concurrency 并行执行。失败中断策略:
97
+ * - 默认 fail-fast:任一资源失败即中断后续(return)
98
+ * - continueOnError:非 database 资源失败仍继续,最后汇总失败数
99
+ * - database 失败始终强制中断(无论是否 continueOnError)
100
+ */
101
+ deploy(options: IDeployOptions): Promise<IDeployResult>;
102
+ /**
103
+ * 将扁平 plan 按「连续相同资源类型」切成有序 segments
104
+ *
105
+ * segment 之间保留 DEPLOY_ORDER 依赖顺序(严格串行);segment 内部为同类型
106
+ * 多实例,可并行执行。例如 [db, fnA, fnB, hostingX, hostingY, gateway]
107
+ * → [[db], [fnA, fnB], [hostingX, hostingY], [gateway]]
108
+ */
109
+ private segmentPlan;
110
+ /**
111
+ * 部署成功后写回本地 state 快照
112
+ *
113
+ * - hosting:成功部署/未变更(skip)的项重算产物指纹;失败项保留旧快照
114
+ * - app:成功部署写 buildAppConfig 快照;skip 复用旧快照
115
+ * - gateway:保留旧快照(本轮不做路由级实时快照)
116
+ */
117
+ private persistState;
118
+ /**
119
+ * 构建完整部署计划(按依赖顺序 + only/skip 过滤)
120
+ *
121
+ * 通过查询云端状态判定每个资源的动作:
122
+ * - database:先按迁移文件做 preview,再聚合成单条资源级计划项(pending→create,存在 conflict→conflict,全部 applied→不出现在 plan)
123
+ * - functions:ListFunctions 判断是否已存在 → create / update(不做本地 hash / 字段 diff)
124
+ * - app:describeAppInfo 判断是否已存在 → create / update;本地 state 配置一致 → skip
125
+ * - hosting:本地 state 指纹 diff → 一致 skip(不重新上传)/ 有差异 deploy(带文件级明细)
126
+ * - gateway:planRoutes 对比云端路由 → create / update / skip(含变更字段明细)
127
+ * 云端查询失败时降级为保守判定(全 create),不影响 dry-run 展示。
128
+ */
129
+ private buildPlan;
130
+ /**
131
+ * 按资源类型构建计划(拆分自 buildPlan,控制圈复杂度)
132
+ */
133
+ private buildPlanForType;
134
+ /**
135
+ * database 计划:preview 聚合成单条资源级计划项
136
+ */
137
+ private buildDatabasePlan;
138
+ /**
139
+ * app 计划:本地 state 配置一致 → skip;否则按云端存在性 → create / update
140
+ */
141
+ private buildAppPlan;
142
+ /**
143
+ * hosting 计划:本地 state 指纹 diff → 一致 skip / 有差异 deploy(带文件级明细)
144
+ */
145
+ private buildHostingPlans;
146
+ /**
147
+ * gateway 计划:planRoutes 对比云端路由 → create / update / skip(含变更字段明细)
148
+ */
149
+ private buildGatewayPlans;
150
+ /**
151
+ * 查询环境中已存在的函数名集合(查询失败返回空集,降级为全新建判定)
152
+ */
153
+ private listExistingFunctionNames;
154
+ /**
155
+ * 判断云应用是否已存在(查询失败返回 false,降级为新建判定)
156
+ */
157
+ private appExists;
158
+ /**
159
+ * 执行单个计划步骤
160
+ */
161
+ private executeStep;
162
+ /** 深比较(JSON 快照语义):仅用于 app 配置快照等简单对象 */
163
+ private deepEqual;
164
+ /** app 配置差异明细(from → to) */
165
+ private appConfigChanges;
166
+ /**
167
+ * 轻量 inline 守卫:配置合法 + 目录存在(validateProject 接线点)
168
+ */
169
+ private guardConfig;
170
+ }
@@ -0,0 +1,159 @@
1
+ import { Environment } from '../environment';
2
+ import { ICloudBuildService } from './function/builders/cloud';
3
+ import { IImagePreflightDeps } from './function/image-preflight';
4
+ import { ICheckReport, IFunctionDeployConfig, IFunctionDeployOptions, IFunctionDeployPlan, IFunctionDeployResult, INormalizedDeployConfig } from './types';
5
+ interface ILegacyFunctionDeployResult {
6
+ name: string;
7
+ url?: string;
8
+ }
9
+ /**
10
+ * 函数部署编排器
11
+ *
12
+ * 统一编排 Event 与 HTTP 函数的部署流程,对上层屏蔽以下差异:
13
+ * - Event 与 HTTP 的运行模型
14
+ * - zip、cloud、local、image 四种构建策略
15
+ * - 创建、更新与不可原地更新的场景识别
16
+ *
17
+ * 已支持代码包、已有镜像、云端构建、本地构建、匿名访问与网关路径收敛;
18
+ * 函数类型、运行时或协议等创建期字段变化时不会自动删除函数,而是引导用户
19
+ * 在控制台确认并手工删除后重新部署。local 企业版 TCR 等未实现能力会显式报错。
20
+ */
21
+ export declare class FunctionDeployer {
22
+ private readonly environment;
23
+ private readonly functionService;
24
+ /** 镜像远端校验依赖,默认真实 docker;测试可注入以避免真实网络/命令 */
25
+ private readonly imagePreflightDeps?;
26
+ /**
27
+ * 云端构建能力工厂,默认基于 CloudAppService 构造真实实现;
28
+ * 测试可注入以替换打包/网络/tcb API,避免真实 IO
29
+ */
30
+ private readonly cloudBuildServiceFactory;
31
+ constructor(environment: Environment, deps?: {
32
+ imagePreflightDeps?: IImagePreflightDeps;
33
+ cloudBuildServiceFactory?: () => ICloudBuildService;
34
+ });
35
+ /**
36
+ * 兼容既有声明式部署入口
37
+ *
38
+ * 该方法只负责补齐声明式上下文并委托 deployFunction,避免继续维护第二套
39
+ * cloud/local/image 分发逻辑。force 在旧入口中表示允许覆盖,计划阶段会自行
40
+ * 判断 create/update;不可原地更新的变更始终要求用户在控制台手工删除函数。
41
+ */
42
+ deploy(options: {
43
+ func: IFunctionDeployConfig;
44
+ functionRootPath?: string;
45
+ /** 直接指定函数代码目录(优先于 functionRootPath/name 拼接),对齐 CLI resolveFunctionPath 的 dir 语义 */
46
+ functionPath?: string;
47
+ force?: boolean;
48
+ }): Promise<ILegacyFunctionDeployResult>;
49
+ /** 解析最终部署策略:显式 buildStrategy 优先,未配置默认 zip */
50
+ resolveStrategy(config: IFunctionDeployConfig): IFunctionDeployPlan['buildStrategy'];
51
+ /**
52
+ * 配置 HTTP 函数匿名访问(public=true)
53
+ * 通过 OPA Rego 策略追加匿名放通规则,不覆盖用户已有策略
54
+ */
55
+ ensurePublicAccess(functionName: string): Promise<void>;
56
+ /**
57
+ * 收敛 HTTP 函数网关路由(gatewayPath 配置)
58
+ *
59
+ * 幂等:云端不存在该 path → 创建;已存在且一致 → 跳过;不一致 → 更新。
60
+ * 复用 GatewayDeployer 的幂等收敛与默认域名解析逻辑,与 gateway.routes 声明式部署行为一致。
61
+ * 返回该函数网关访问 URL(与 resolveUrl 解析结果一致),无 envId 时返回 undefined。
62
+ */
63
+ ensureGatewayRoute(config: INormalizedDeployConfig): Promise<string | undefined>;
64
+ /** 生成匿名访问 OPA Rego 规则 */
65
+ buildPublicAccessRego(functionName: string): string;
66
+ /** 生成 HTTP 函数可访问 URL */
67
+ resolveUrl(config: IFunctionDeployConfig): Promise<string | undefined>;
68
+ /**
69
+ * 校验部署配置
70
+ *
71
+ * 只做纯函数、无 IO 的配置契约校验,一次返回全部问题
72
+ */
73
+ checkConfig(config: IFunctionDeployConfig): ICheckReport;
74
+ /**
75
+ * 生成部署计划
76
+ *
77
+ * 会查询线上函数状态,用于判断创建、更新或识别不可原地更新的变更
78
+ */
79
+ plan(config: IFunctionDeployConfig): Promise<IFunctionDeployPlan>;
80
+ /**
81
+ * 部署前本地环境检查(有 IO)
82
+ *
83
+ * 与 checkConfig 不同,本方法会读取文件系统,覆盖 HTTP 代码包和 cloud 镜像构建
84
+ * 所需的本地文件条件。先做配置契约校验,再执行本地检查。
85
+ */
86
+ preflight(config: IFunctionDeployConfig): ICheckReport;
87
+ /**
88
+ * 部署函数
89
+ * @param config 部署配置
90
+ * @param options 部署选项,dryRun 时只生成计划不做任何变更
91
+ */
92
+ deployFunction(config: IFunctionDeployConfig, options?: IFunctionDeployOptions): Promise<IFunctionDeployResult>;
93
+ /**
94
+ * 将既有声明式调用补齐为完整部署配置
95
+ */
96
+ private withLegacyDeployContext;
97
+ /**
98
+ * 解析函数部署地域,供镜像远端地域校验使用
99
+ *
100
+ * 地域来源于 environment 的鉴权配置;未显式配置时返回 undefined,
101
+ * 由image-preflight 自动跳过地域校验,不误报。
102
+ */
103
+ private resolveDeployRegion;
104
+ /**
105
+ * 构造镜像拉取授权 Preflight 所需的 CAM 适配器
106
+ *
107
+ * 用 CommonService 走 CAM 通道:ListAttachedRolePolicies 读已绑策略、
108
+ * AttachRolePolicies 按策略名绑定。任何权限/网络错误都原样抛出,
109
+ * 交由 cam-preflight 判定并降级,本层不吞异常。
110
+ */
111
+ private createCamPreflightAdapter;
112
+ /** 查询线上函数详情,不存在时返回 null */
113
+ private getCurrentFunction;
114
+ /** 判断是否为函数不存在错误,其他错误必须继续抛出 */
115
+ private isFunctionNotFoundError;
116
+ /**
117
+ * 校验 Preflight 报告,存在 fail 项时聚合抛错
118
+ */
119
+ private assertPreflightReady;
120
+ /**
121
+ * 判断计划是否可以在当前实现范围内执行
122
+ *
123
+ * 未实现的能力必须显式报错,避免用户误认为访问规则或镜像构建已经生效
124
+ */
125
+ private assertPlanExecutable;
126
+ /**
127
+ * 准备部署物
128
+ *
129
+ * cloud 策略在云端构建容器内build+push,产出镜像部署物(不依赖本地 Docker);
130
+ * local 策略需要先做 Docker 本地能力检查,再本地构建并推送镜像,产出镜像部署物;
131
+ * 其余策略走同步的 pack。
132
+ */
133
+ private prepareArtifact;
134
+ /** 生成部署物 */
135
+ private createArtifact;
136
+ /** 执行部署计划 */
137
+ private applyPlan;
138
+ /** 收敛 HTTP 函数访问配置(匿名访问 + 网关路由) */
139
+ private applyAccessPlan;
140
+ /** 执行单个步骤并记录耗时与进度 */
141
+ private runStep;
142
+ /** 上报进度,回调异常不影响部署流程 */
143
+ private emitProgress;
144
+ /** 汇总部署结果 */
145
+ private buildResult;
146
+ private emitProgressDone;
147
+ }
148
+ export * from './types';
149
+ export { assertDeployConfig, checkDeployConfig, isCustomImageRuntime, normalizeDeployConfig, normalizeGatewayPath, parseImageReference } from './function/config-guard';
150
+ export { createDeployPlan, toCurrentState } from './function/planner';
151
+ export { createCodeArtifact, createImageArtifactFromConfig, toCloudFunction } from './function/artifact';
152
+ export { buildImageOnCloud } from './function/builders/cloud';
153
+ export type { ICloudBuildService, ICloudBuildResult, ICloudCosInfo, ICloudCreateBuildInput, ICloudCreateBuildResult, ICloudVersionStatus } from './function/builders/cloud';
154
+ export { createCloudBuildService } from './function/cloud-build-service';
155
+ export { runLocalPreflight } from './function/preflight';
156
+ export { runImageRemotePreflight } from './function/image-preflight';
157
+ export type { IImagePreflightDeps } from './function/image-preflight';
158
+ export { runImagePullAuthPreflight, isCamPermissionError, SCF_PULL_IMAGE_ROLE, REQUIRED_IMAGE_PULL_POLICY, IMAGE_PULL_GRANT_URL } from './function/cam-preflight';
159
+ export type { ICamPreflightService } from './function/cam-preflight';