@cloudbase/manager-node 5.6.7 → 5.7.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 (60) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/lib/cloudApp/index.js +12 -3
  3. package/lib/deploy/DatabaseDeployer.js +238 -0
  4. package/lib/deploy/DeployOrchestrator.js +564 -0
  5. package/lib/deploy/FunctionDeployer.js +611 -0
  6. package/lib/deploy/GatewayDeployer.js +522 -0
  7. package/lib/deploy/StateStore.js +327 -0
  8. package/lib/deploy/StaticDeployer.js +289 -0
  9. package/lib/deploy/domain.js +39 -0
  10. package/lib/deploy/framework.js +105 -0
  11. package/lib/deploy/function/artifact.js +207 -0
  12. package/lib/deploy/function/builders/cloud.js +454 -0
  13. package/lib/deploy/function/cam-preflight.js +157 -0
  14. package/lib/deploy/function/cloud-build-service.js +170 -0
  15. package/lib/deploy/function/config-guard.js +588 -0
  16. package/lib/deploy/function/docker-preflight.js +87 -0
  17. package/lib/deploy/function/image-preflight.js +164 -0
  18. package/lib/deploy/function/local-builder.js +110 -0
  19. package/lib/deploy/function/planner.js +282 -0
  20. package/lib/deploy/function/preflight.js +264 -0
  21. package/lib/deploy/types.js +99 -0
  22. package/lib/environment.js +11 -0
  23. package/lib/hosting/index.js +4 -1
  24. package/lib/index.js +31 -0
  25. package/lib/projectValidator/index.js +375 -0
  26. package/lib/projectValidator/types.js +2 -0
  27. package/lib/storage/index.js +6 -7
  28. package/lib/utils/index.js +41 -1
  29. package/package.json +2 -1
  30. package/types/cloudApp/index.d.ts +4 -0
  31. package/types/cloudApp/types.d.ts +87 -6
  32. package/types/deploy/DatabaseDeployer.d.ts +70 -0
  33. package/types/deploy/DeployOrchestrator.d.ts +150 -0
  34. package/types/deploy/FunctionDeployer.d.ts +158 -0
  35. package/types/deploy/GatewayDeployer.d.ts +175 -0
  36. package/types/deploy/StateStore.d.ts +170 -0
  37. package/types/deploy/StaticDeployer.d.ts +104 -0
  38. package/types/deploy/domain.d.ts +17 -0
  39. package/types/deploy/framework.d.ts +23 -0
  40. package/types/deploy/function/artifact.d.ts +40 -0
  41. package/types/deploy/function/builders/cloud.d.ts +110 -0
  42. package/types/deploy/function/cam-preflight.d.ts +51 -0
  43. package/types/deploy/function/cloud-build-service.d.ts +10 -0
  44. package/types/deploy/function/config-guard.d.ts +41 -0
  45. package/types/deploy/function/docker-preflight.d.ts +17 -0
  46. package/types/deploy/function/image-preflight.d.ts +21 -0
  47. package/types/deploy/function/local-builder.d.ts +26 -0
  48. package/types/deploy/function/planner.d.ts +15 -0
  49. package/types/deploy/function/preflight.d.ts +9 -0
  50. package/types/deploy/types.d.ts +429 -0
  51. package/types/env/type.d.ts +4 -4
  52. package/types/environment.d.ts +7 -0
  53. package/types/function/types.d.ts +15 -0
  54. package/types/hosting/index.d.ts +6 -0
  55. package/types/index.d.ts +18 -0
  56. package/types/interfaces/function.interface.d.ts +1 -1
  57. package/types/projectValidator/index.d.ts +24 -0
  58. package/types/projectValidator/types.d.ts +26 -0
  59. package/types/storage/index.d.ts +6 -0
  60. package/types/utils/index.d.ts +13 -0
@@ -0,0 +1,9 @@
1
+ import { ICheckReport, INormalizedDeployConfig } from '../types';
2
+ /**
3
+ * 执行部署前本地检查
4
+ *
5
+ * 目前仅 HTTP 代码包部署有文件系统前置条件;其它策略返回空报告,表示本阶段无需检查。
6
+ * base64Code 来源无本地目录,跳过文件检查。
7
+ * @returns 本地检查报告,聚合全部问题
8
+ */
9
+ export declare function runLocalPreflight(config: INormalizedDeployConfig): ICheckReport;
@@ -0,0 +1,429 @@
1
+ import { ICloudFunctionTrigger, IFunctionImageConfig, IFunctionVPC } from '../interfaces';
2
+ /**
3
+ * 镜像 HTTP 函数固定监听端口
4
+ * SCF HTTP 自定义镜像函数要求容器监听 9000
5
+ */
6
+ export declare const IMAGE_FUNCTION_PORT = 9000;
7
+ /**
8
+ * 镜像构建默认目标平台
9
+ * SCF 运行环境为 linux/amd64,Apple Silicon 也必须显式构建该平台
10
+ */
11
+ export declare const DEFAULT_IMAGE_PLATFORM = "linux/amd64";
12
+ /** 默认 Dockerfile 名称,相对于构建上下文 */
13
+ export declare const DEFAULT_DOCKERFILE = "Dockerfile";
14
+ /** HTTP 函数支持的构建策略 */
15
+ export type HttpBuildStrategy = 'zip' | 'cloud' | 'local' | 'image';
16
+ /** 函数运行模型 */
17
+ export type FunctionRuntimeModel = 'Event' | 'HTTP';
18
+ /** 自定义镜像运行时标识 */
19
+ export declare const CUSTOM_IMAGE_RUNTIME = "CustomImage";
20
+ /** 部署计划的粗粒度动作 */
21
+ export type DeployActionKind = 'create' | 'update' | 'replace' | 'noop';
22
+ /** 部署计划中的细粒度操作 */
23
+ export type DeployOperation = 'create-function' | 'update-code' | 'update-config' | 'replace-function' | 'configure-access' | 'configure-gateway';
24
+ /** 统一进度阶段 */
25
+ export type DeployStage = 'validate' | 'preflight' | 'plan' | 'pack' | 'upload' | 'build' | 'push' | 'deploy-function' | 'wait-active' | 'configure-access' | 'configure-gateway' | 'done';
26
+ /** 单项检查结论 */
27
+ export type CheckStatus = 'pass' | 'warn' | 'fail';
28
+ /**
29
+ * 单项检查结果
30
+ * 配置契约守卫与后续 Preflight 复用同一结构,便于上层统一展示
31
+ */
32
+ export interface ICheckResult {
33
+ /** 稳定错误码,供上层做本地化和引导 */
34
+ id: string;
35
+ status: CheckStatus;
36
+ /** 简短结论 */
37
+ summary: string;
38
+ /** 详细信息,不得包含凭证 */
39
+ detail?: string;
40
+ /** 可执行的修复建议 */
41
+ remediation?: string;
42
+ docsUrl?: string;
43
+ /** 该问题是否可以通过切换到云端构建规避 */
44
+ canFallbackToCloud?: boolean;
45
+ }
46
+ /** 检查报告 */
47
+ export interface ICheckReport {
48
+ /** config 表示纯配置契约校验;local/cloud 表示环境与云资源检查 */
49
+ scope: 'config' | 'local' | 'cloud';
50
+ strategy?: HttpBuildStrategy;
51
+ /** 是否没有 fail 项 */
52
+ ready: boolean;
53
+ checks: ICheckResult[];
54
+ /** 建议改用的策略 */
55
+ recommendedStrategy?: 'cloud';
56
+ }
57
+ /** 函数部署错误码 */
58
+ export declare const FUNCTION_DEPLOY_ERROR: {
59
+ readonly CONFIG_INVALID: "CONFIG_INVALID";
60
+ readonly CONFIG_NAME_INVALID: "CONFIG_NAME_INVALID";
61
+ readonly CONFIG_TYPE_INVALID: "CONFIG_TYPE_INVALID";
62
+ readonly CONFIG_STRATEGY_INVALID: "CONFIG_STRATEGY_INVALID";
63
+ readonly CONFIG_TIMEOUT_INVALID: "CONFIG_TIMEOUT_INVALID";
64
+ readonly CONFIG_MEMORY_SIZE_INVALID: "CONFIG_MEMORY_SIZE_INVALID";
65
+ readonly CONFIG_ENV_VARIABLE_INVALID: "CONFIG_ENV_VARIABLE_INVALID";
66
+ readonly EVENT_IMAGE_NOT_SUPPORTED: "EVENT_IMAGE_NOT_SUPPORTED";
67
+ readonly EVENT_GATEWAY_NOT_SUPPORTED: "EVENT_GATEWAY_NOT_SUPPORTED";
68
+ readonly EVENT_HTTP_FIELD_NOT_SUPPORTED: "EVENT_HTTP_FIELD_NOT_SUPPORTED";
69
+ readonly HTTP_ZIP_RUNTIME_INVALID: "HTTP_ZIP_RUNTIME_INVALID";
70
+ readonly HTTP_ZIP_IMAGE_CONFIG_CONFLICT: "HTTP_ZIP_IMAGE_CONFIG_CONFLICT";
71
+ readonly HTTP_ZIP_INSTALL_DEPENDENCY_OVERRIDDEN: "HTTP_ZIP_INSTALL_DEPENDENCY_OVERRIDDEN";
72
+ readonly HTTP_TRIGGER_NOT_SUPPORTED: "HTTP_TRIGGER_NOT_SUPPORTED";
73
+ readonly HTTP_CONCURRENCY_INVALID: "HTTP_CONCURRENCY_INVALID";
74
+ readonly HTTP_PROTOCOL_PARAMS_INVALID: "HTTP_PROTOCOL_PARAMS_INVALID";
75
+ readonly CODE_SOURCE_MISSING: "CODE_SOURCE_MISSING";
76
+ readonly CODE_SOURCE_CONFLICT: "CODE_SOURCE_CONFLICT";
77
+ readonly IMAGE_CONFIG_MISSING: "IMAGE_CONFIG_MISSING";
78
+ readonly IMAGE_CONFIG_NOT_ALLOWED: "IMAGE_CONFIG_NOT_ALLOWED";
79
+ readonly IMAGE_URI_INVALID: "IMAGE_URI_INVALID";
80
+ readonly IMAGE_TAG_MISSING: "IMAGE_TAG_MISSING";
81
+ readonly IMAGE_TAG_LATEST_FORBIDDEN: "IMAGE_TAG_LATEST_FORBIDDEN";
82
+ readonly IMAGE_TYPE_INVALID: "IMAGE_TYPE_INVALID";
83
+ readonly IMAGE_REGISTRY_ID_MISSING: "IMAGE_REGISTRY_ID_MISSING";
84
+ readonly IMAGE_PORT_INVALID: "IMAGE_PORT_INVALID";
85
+ readonly IMAGE_RUNTIME_INVALID: "IMAGE_RUNTIME_INVALID";
86
+ readonly IMAGE_HANDLER_NOT_ALLOWED: "IMAGE_HANDLER_NOT_ALLOWED";
87
+ readonly BUILD_CONFIG_MISSING: "BUILD_CONFIG_MISSING";
88
+ readonly BUILD_DOCKERFILE_INVALID: "BUILD_DOCKERFILE_INVALID";
89
+ readonly BUILD_CONTEXT_INVALID: "BUILD_CONTEXT_INVALID";
90
+ readonly BUILD_PLATFORM_INVALID: "BUILD_PLATFORM_INVALID";
91
+ readonly BUILD_TAG_INVALID: "BUILD_TAG_INVALID";
92
+ readonly BUILD_REPOSITORY_INVALID: "BUILD_REPOSITORY_INVALID";
93
+ readonly BUILD_ARG_INVALID: "BUILD_ARG_INVALID";
94
+ readonly CLOUD_REGISTRY_CREDENTIAL_MISSING: "CLOUD_REGISTRY_CREDENTIAL_MISSING";
95
+ readonly CLOUD_REGISTRY_CREDENTIAL_INVALID: "CLOUD_REGISTRY_CREDENTIAL_INVALID";
96
+ readonly GATEWAY_PATH_INVALID: "GATEWAY_PATH_INVALID";
97
+ readonly LOCAL_FALLBACK_INVALID: "LOCAL_FALLBACK_INVALID";
98
+ readonly PREFLIGHT_CODE_PATH_MISSING: "PREFLIGHT_CODE_PATH_MISSING";
99
+ readonly PREFLIGHT_CODE_PATH_NOT_DIRECTORY: "PREFLIGHT_CODE_PATH_NOT_DIRECTORY";
100
+ readonly PREFLIGHT_BOOTSTRAP_MISSING: "PREFLIGHT_BOOTSTRAP_MISSING";
101
+ readonly PREFLIGHT_BOOTSTRAP_NOT_FILE: "PREFLIGHT_BOOTSTRAP_NOT_FILE";
102
+ readonly PREFLIGHT_BOOTSTRAP_NOT_EXECUTABLE: "PREFLIGHT_BOOTSTRAP_NOT_EXECUTABLE";
103
+ readonly PREFLIGHT_PACKAGE_TOO_LARGE: "PREFLIGHT_PACKAGE_TOO_LARGE";
104
+ readonly PREFLIGHT_SYMLINK_ESCAPE: "PREFLIGHT_SYMLINK_ESCAPE";
105
+ readonly PREFLIGHT_DEPENDENCY_NOT_BUNDLED: "PREFLIGHT_DEPENDENCY_NOT_BUNDLED";
106
+ readonly PREFLIGHT_IO_ERROR: "PREFLIGHT_IO_ERROR";
107
+ readonly PREFLIGHT_DOCKER_CLI_MISSING: "PREFLIGHT_DOCKER_CLI_MISSING";
108
+ readonly PREFLIGHT_DOCKER_DAEMON_UNAVAILABLE: "PREFLIGHT_DOCKER_DAEMON_UNAVAILABLE";
109
+ readonly PREFLIGHT_DOCKER_BUILDX_MISSING: "PREFLIGHT_DOCKER_BUILDX_MISSING";
110
+ readonly LOCAL_BUILD_CONTEXT_MISSING: "LOCAL_BUILD_CONTEXT_MISSING";
111
+ readonly LOCAL_BUILD_DOCKERFILE_MISSING: "LOCAL_BUILD_DOCKERFILE_MISSING";
112
+ readonly LOCAL_BUILD_REPOSITORY_MISSING: "LOCAL_BUILD_REPOSITORY_MISSING";
113
+ readonly LOCAL_BUILD_FAILED: "LOCAL_BUILD_FAILED";
114
+ readonly LOCAL_PUSH_FAILED: "LOCAL_PUSH_FAILED";
115
+ readonly LOCAL_DIGEST_QUERY_FAILED: "LOCAL_DIGEST_QUERY_FAILED";
116
+ readonly CLOUD_UPLOAD_FAILED: "CLOUD_UPLOAD_FAILED";
117
+ readonly CLOUD_BUILD_TRIGGER_FAILED: "CLOUD_BUILD_TRIGGER_FAILED";
118
+ readonly CLOUD_BUILD_FAILED: "CLOUD_BUILD_FAILED";
119
+ readonly CLOUD_BUILD_CANCELED: "CLOUD_BUILD_CANCELED";
120
+ readonly CLOUD_BUILD_TIMEOUT: "CLOUD_BUILD_TIMEOUT";
121
+ readonly PREFLIGHT_IMAGE_REMOTE_NOT_FOUND: "PREFLIGHT_IMAGE_REMOTE_NOT_FOUND";
122
+ readonly PREFLIGHT_IMAGE_REMOTE_UNVERIFIABLE: "PREFLIGHT_IMAGE_REMOTE_UNVERIFIABLE";
123
+ readonly PREFLIGHT_IMAGE_DIGEST_UNRESOLVED: "PREFLIGHT_IMAGE_DIGEST_UNRESOLVED";
124
+ readonly PREFLIGHT_IMAGE_REGION_MISMATCH: "PREFLIGHT_IMAGE_REGION_MISMATCH";
125
+ readonly PREFLIGHT_IMAGE_PULL_ROLE_MISSING: "PREFLIGHT_IMAGE_PULL_ROLE_MISSING";
126
+ readonly PREFLIGHT_IMAGE_PULL_POLICY_MISSING: "PREFLIGHT_IMAGE_PULL_POLICY_MISSING";
127
+ readonly PREFLIGHT_IMAGE_PULL_AUTH_GRANTED: "PREFLIGHT_IMAGE_PULL_AUTH_GRANTED";
128
+ readonly PREFLIGHT_IMAGE_PULL_AUTH_UNVERIFIABLE: "PREFLIGHT_IMAGE_PULL_AUTH_UNVERIFIABLE";
129
+ readonly PREFLIGHT_CAM_PERMISSION_DENIED: "PREFLIGHT_CAM_PERMISSION_DENIED";
130
+ readonly REPLACE_NOT_APPROVED: "REPLACE_NOT_APPROVED";
131
+ readonly NOT_IMPLEMENTED: "NOT_IMPLEMENTED";
132
+ };
133
+ export type FunctionDeployErrorCode = typeof FUNCTION_DEPLOY_ERROR[keyof typeof FUNCTION_DEPLOY_ERROR];
134
+ /** 函数通用属性,Event 与 HTTP 共用 */
135
+ export interface IFunctionDeployCommon {
136
+ name: string;
137
+ description?: string;
138
+ timeout?: number;
139
+ memorySize?: number;
140
+ envVariables?: Record<string, string | number | boolean>;
141
+ vpc?: IFunctionVPC;
142
+ layers?: {
143
+ name: string;
144
+ version: number;
145
+ }[];
146
+ role?: string;
147
+ codeSecret?: string;
148
+ /** 声明式配置中的函数代码目录,由 DeployOrchestrator 解析为绝对 functionPath */
149
+ dir?: string;
150
+ l5?: boolean | 'TRUE' | 'FALSE';
151
+ }
152
+ /** 本地代码来源,三者互斥 */
153
+ export interface ILocalCodeSource {
154
+ /** 函数所在目录 */
155
+ functionRootPath?: string;
156
+ /** 单个函数目录 */
157
+ functionPath?: string;
158
+ /** ZIP 的 base64 内容 */
159
+ base64Code?: string;
160
+ ignore?: string | string[];
161
+ }
162
+ /** Event 函数部署配置 */
163
+ export interface IEventFunctionDeployConfig extends IFunctionDeployCommon, ILocalCodeSource {
164
+ type?: 'Event';
165
+ /** Event 函数只支持代码包部署 */
166
+ buildStrategy?: 'zip';
167
+ runtime?: string;
168
+ handler?: string;
169
+ installDependency?: boolean | 'TRUE' | 'FALSE';
170
+ triggers?: ICloudFunctionTrigger[];
171
+ }
172
+ /** HTTP 函数公共配置 */
173
+ export interface IHttpFunctionDeployCommon extends IFunctionDeployCommon {
174
+ type: 'HTTP';
175
+ /**
176
+ * 是否允许匿名访问
177
+ * 不传表示不由部署器管理访问规则
178
+ */
179
+ public?: boolean;
180
+ /** 云接入路径(兼容既有声明式部署配置) */
181
+ path?: string;
182
+ /** 网关路径,例如 /api */
183
+ gatewayPath?: string;
184
+ /** HTTP 为普通 HTTP,WS 为 WebSocket;不传等价于 HTTP */
185
+ protocolType?: 'HTTP' | 'WS';
186
+ protocolParams?: {
187
+ wsParams?: {
188
+ idleTimeOut?: number;
189
+ };
190
+ };
191
+ instanceConcurrencyConfig?: {
192
+ dynamicEnabled?: boolean | 'TRUE' | 'FALSE';
193
+ maxConcurrency?: number;
194
+ [key: string]: any;
195
+ };
196
+ /** 镜像地址兼容字段;image 策略会转换为 imageConfig.imageUri */
197
+ imageUri?: string;
198
+ }
199
+ /** HTTP 托管运行时代码包部署 */
200
+ export interface IHttpZipDeployConfig extends IHttpFunctionDeployCommon, ILocalCodeSource {
201
+ buildStrategy?: 'zip';
202
+ runtime?: string;
203
+ /**
204
+ * HTTP 代码包部署要求依赖随包携带
205
+ * 该字段会被强制置为 false
206
+ */
207
+ installDependency?: boolean | 'TRUE' | 'FALSE';
208
+ }
209
+ /** 个人版 TCR 云端推送凭证,只能通过 CloudApp Secrets 传递密码。 */
210
+ export interface IRegistryCredential {
211
+ /** 腾讯云账号 ID(UIN),作为个人版 CCR 登录用户名 */
212
+ username: string;
213
+ /** 个人版 CCR 固定密码 */
214
+ password: string;
215
+ }
216
+ /** 镜像构建目标配置 */
217
+ export interface IImageBuildTarget {
218
+ /** 构建上下文目录,默认取部署调用方指定的函数目录 */
219
+ cwd?: string;
220
+ /** Dockerfile 相对构建上下文的路径,默认 Dockerfile */
221
+ dockerfile?: string;
222
+ /** 目标镜像仓库实例 ID */
223
+ registryId?: string;
224
+ /** 目标镜像命名空间;个人版 cloud 构建必填,推荐使用 {{env.TCB_TCR_NAMESPACE}} */
225
+ namespace?: string;
226
+ /**
227
+ * 目标镜像仓库路径。
228
+ * cloud 策略可提供 repository 名、namespace/repository 或完整
229
+ * registry/namespace/repository;省略时默认使用函数名。
230
+ */
231
+ repository?: string;
232
+ /** 目标镜像 tag,缺省时由构建器按构建上下文摘要生成 */
233
+ tag?: string;
234
+ /** 目标平台,默认 linux/amd64 */
235
+ platform?: string;
236
+ /** 构建参数,不得写入敏感值 */
237
+ buildArgs?: Record<string, string>;
238
+ /** 个人版 TCR 云端推送凭证;personal + cloud 必填,推荐使用 {{env.*}} */
239
+ registryCredential?: IRegistryCredential;
240
+ /** 忽略同摘要镜像复用,强制重新构建 */
241
+ forceBuild?: boolean;
242
+ }
243
+ /** HTTP 自定义镜像公共配置 */
244
+ export interface IHttpImageRuntimeCommon extends IHttpFunctionDeployCommon {
245
+ runtime?: typeof CUSTOM_IMAGE_RUNTIME;
246
+ /** 容器监听端口,仅允许 9000 */
247
+ imagePort?: number;
248
+ /** 镜像类型,默认 enterprise */
249
+ imageType?: 'enterprise' | 'personal';
250
+ /** 企业版 TCR 实例 ID;个人版镜像不传 */
251
+ registryId?: string;
252
+ entryPoint?: string;
253
+ command?: string;
254
+ args?: string;
255
+ commandList?: string[];
256
+ argsList?: string[];
257
+ containerImageAccelerate?: boolean;
258
+ }
259
+ /** 云端构建镜像部署 */
260
+ export interface IHttpCloudDeployConfig extends IHttpImageRuntimeCommon {
261
+ buildStrategy: 'cloud';
262
+ build: IImageBuildTarget;
263
+ }
264
+ /** 本地构建镜像部署 */
265
+ export interface IHttpLocalDeployConfig extends IHttpImageRuntimeCommon {
266
+ buildStrategy: 'local';
267
+ build: IImageBuildTarget;
268
+ /**
269
+ * 本地构建环境不可用时的处理方式
270
+ * 默认 error,避免静默改变构建环境
271
+ */
272
+ localFallback?: 'cloud' | 'error';
273
+ }
274
+ /** 已有镜像直接部署 */
275
+ export interface IHttpImageDeployConfig extends IHttpImageRuntimeCommon {
276
+ buildStrategy: 'image';
277
+ imageConfig: IFunctionImageConfig;
278
+ }
279
+ export type IHttpFunctionDeployConfig = IHttpZipDeployConfig | IHttpCloudDeployConfig | IHttpLocalDeployConfig | IHttpImageDeployConfig;
280
+ export type IFunctionDeployConfig = IEventFunctionDeployConfig | IHttpFunctionDeployConfig;
281
+ /** 规范化后的 Event 配置 */
282
+ export type INormalizedEventConfig = IEventFunctionDeployConfig & {
283
+ type: 'Event';
284
+ buildStrategy: 'zip';
285
+ };
286
+ /** 规范化后的 HTTP 代码包配置 */
287
+ export type INormalizedHttpZipConfig = IHttpZipDeployConfig & {
288
+ type: 'HTTP';
289
+ buildStrategy: 'zip';
290
+ };
291
+ /** 规范化后的 HTTP 云端构建配置 */
292
+ export type INormalizedHttpCloudConfig = IHttpCloudDeployConfig & {
293
+ type: 'HTTP';
294
+ buildStrategy: 'cloud';
295
+ runtime: typeof CUSTOM_IMAGE_RUNTIME;
296
+ imagePort: number;
297
+ };
298
+ /** 规范化后的 HTTP 本地构建配置 */
299
+ export type INormalizedHttpLocalConfig = IHttpLocalDeployConfig & {
300
+ type: 'HTTP';
301
+ buildStrategy: 'local';
302
+ runtime: typeof CUSTOM_IMAGE_RUNTIME;
303
+ imagePort: number;
304
+ localFallback: 'cloud' | 'error';
305
+ };
306
+ /** 规范化后的 HTTP 已有镜像配置 */
307
+ export type INormalizedHttpImageConfig = IHttpImageDeployConfig & {
308
+ type: 'HTTP';
309
+ buildStrategy: 'image';
310
+ runtime: typeof CUSTOM_IMAGE_RUNTIME;
311
+ imagePort: number;
312
+ };
313
+ export type INormalizedDeployConfig = INormalizedEventConfig | INormalizedHttpZipConfig | INormalizedHttpCloudConfig | INormalizedHttpLocalConfig | INormalizedHttpImageConfig;
314
+ /** 代码类部署物 */
315
+ export interface ICodeArtifact {
316
+ kind: 'code';
317
+ /** 交给 SCF 的代码传输方式 */
318
+ deployMode: 'cos' | 'zip';
319
+ functionRootPath?: string;
320
+ functionPath?: string;
321
+ base64Code?: string;
322
+ }
323
+ /** 镜像类部署物 */
324
+ export interface IImageArtifact {
325
+ kind: 'image';
326
+ deployMode: 'image';
327
+ imageUri: string;
328
+ imageDigest?: string;
329
+ imageType: 'enterprise' | 'personal';
330
+ registryId?: string;
331
+ imagePort: number;
332
+ /** 实际产出该镜像的策略 */
333
+ effectiveStrategy: HttpBuildStrategy;
334
+ buildId?: string;
335
+ logsUrl?: string;
336
+ entryPoint?: string;
337
+ command?: string;
338
+ args?: string;
339
+ commandList?: string[];
340
+ argsList?: string[];
341
+ containerImageAccelerate?: boolean;
342
+ }
343
+ export type IFunctionArtifact = ICodeArtifact | IImageArtifact;
344
+ /** 线上函数当前状态摘要 */
345
+ export interface IFunctionCurrentState {
346
+ functionName: string;
347
+ type: FunctionRuntimeModel;
348
+ runtime?: string;
349
+ status?: string;
350
+ protocolType?: string;
351
+ triggerNames: string[];
352
+ isCustomImage: boolean;
353
+ /** 以下字段用于 noop 差异比较,缺省表示线上未返回或不适用 */
354
+ imageUri?: string;
355
+ timeout?: number;
356
+ memorySize?: number;
357
+ description?: string;
358
+ /** 线上环境变量,键值对形式 */
359
+ envVariables?: Record<string, string>;
360
+ }
361
+ /** 部署计划 */
362
+ export interface IFunctionDeployPlan {
363
+ functionName: string;
364
+ functionType: FunctionRuntimeModel;
365
+ buildStrategy: HttpBuildStrategy;
366
+ /** 线上是否已存在同名函数 */
367
+ exists: boolean;
368
+ action: DeployActionKind;
369
+ operations: DeployOperation[];
370
+ /** 计划说明,用于向用户解释将要发生什么 */
371
+ reasons: string[];
372
+ /** 需要删除重建的原因,非空表示存在不可原地修改的变更 */
373
+ replaceReasons: string[];
374
+ /** 是否需要调用方显式授权后才能执行 */
375
+ requiresReplaceApproval: boolean;
376
+ current?: IFunctionCurrentState;
377
+ }
378
+ /** 单步执行结果 */
379
+ export interface IDeployStepResult {
380
+ stage: DeployStage;
381
+ status: 'success' | 'skipped' | 'failed';
382
+ /** 毫秒 */
383
+ elapsedTime: number;
384
+ detail?: string;
385
+ }
386
+ /** 进度事件 */
387
+ export interface IDeployProgressEvent {
388
+ stage: DeployStage;
389
+ status: 'start' | 'success' | 'skipped' | 'failed';
390
+ message?: string;
391
+ }
392
+ /** 部署结果 */
393
+ export interface IFunctionDeployResult {
394
+ functionName: string;
395
+ functionType: FunctionRuntimeModel;
396
+ /** 调用方请求的策略 */
397
+ requestedStrategy: HttpBuildStrategy;
398
+ /** 实际执行的策略,local 回退 cloud 时两者不同 */
399
+ effectiveStrategy: HttpBuildStrategy;
400
+ action: DeployActionKind;
401
+ operations: DeployOperation[];
402
+ /** 是否只生成计划未执行变更 */
403
+ dryRun: boolean;
404
+ imageUri?: string;
405
+ imageDigest?: string;
406
+ buildId?: string;
407
+ gatewayUrl?: string;
408
+ public?: boolean;
409
+ /** 毫秒 */
410
+ elapsedTime: number;
411
+ steps: IDeployStepResult[];
412
+ warnings: string[];
413
+ plan: IFunctionDeployPlan;
414
+ }
415
+ /** 部署选项 */
416
+ export interface IFunctionDeployOptions {
417
+ /** 允许删除重建,缺省不允许 */
418
+ allowReplace?: boolean;
419
+ /** 只生成计划,不执行任何变更 */
420
+ dryRun?: boolean;
421
+ /**
422
+ * 是否允许自动补齐镜像拉取所需的 CAM 授权(默认 true)
423
+ *
424
+ * 仅在检测到 image 策略缺少拉镜像策略时,为固定角色绑定唯一白名单策略;
425
+ * 绝不放大到其它策略。设为 false 时只诊断并给出手动授权指引,不做任何 CAM 写操作。
426
+ */
427
+ autoGrant?: boolean;
428
+ onProgress?: (event: IDeployProgressEvent) => void;
429
+ }
@@ -113,9 +113,9 @@ export interface HTTPServiceRouteParam {
113
113
  */
114
114
  export interface HTTPServiceDomainParam {
115
115
  Domain: string;
116
- AccessType?: 'DIRECT' | 'CDN' | 'CUSTOM';
116
+ AccessType?: 'DIRECT' | 'CDN' | 'CUSTOM' | 'EO';
117
117
  CertId?: string;
118
- Protocol?: 'HTTP_AND_HTTPS' | 'HTTP_TO_HTTPS' | 'HTTPS_TO_HTTP';
118
+ Protocol?: 'HTTP' | 'HTTPS' | 'HTTP_AND_HTTPS' | 'HTTP_TO_HTTPS' | 'HTTPS_TO_HTTP';
119
119
  CustomCname?: string;
120
120
  Enable?: boolean;
121
121
  Routes?: HTTPServiceRouteParam[];
@@ -167,8 +167,8 @@ export interface DeleteHttpServiceRouteRes {
167
167
  export interface BindCustomDomainDomainParam {
168
168
  Domain: string;
169
169
  CertId: string;
170
- AccessType?: 'DIRECT' | 'CDN' | 'CUSTOM';
171
- Protocol?: 'HTTP_AND_HTTPS' | 'HTTP_TO_HTTPS' | 'HTTPS_TO_HTTP';
170
+ AccessType?: 'DIRECT' | 'CDN' | 'CUSTOM' | 'EO';
171
+ Protocol?: 'HTTP' | 'HTTPS' | 'HTTP_AND_HTTPS' | 'HTTP_TO_HTTPS' | 'HTTPS_TO_HTTP';
172
172
  Enable?: boolean;
173
173
  CustomCname?: string;
174
174
  }
@@ -1,5 +1,6 @@
1
1
  import { DatabaseService } from './database';
2
2
  import { FunctionService } from './function';
3
+ import { FunctionDeployer } from './deploy/FunctionDeployer';
3
4
  import { CloudRunService } from './cloudrun';
4
5
  import { AgentService } from './agent';
5
6
  import { StorageService } from './storage';
@@ -27,6 +28,7 @@ export declare class Environment {
27
28
  private envId;
28
29
  private envType?;
29
30
  private functionService;
31
+ private functionDeployer;
30
32
  private cloudRunService;
31
33
  private agentService;
32
34
  private databaseService;
@@ -52,6 +54,11 @@ export declare class Environment {
52
54
  getStorageService(): StorageService;
53
55
  getDatabaseService(): DatabaseService;
54
56
  getFunctionService(): FunctionService;
57
+ /**
58
+ * 获取函数部署编排器
59
+ * 采用懒初始化,避免模块循环引用导致的初始化顺序问题
60
+ */
61
+ getFunctionDeployer(): FunctionDeployer;
55
62
  getCloudRunService(): CloudRunService;
56
63
  getAgentService(): AgentService;
57
64
  getEnvService(): EnvService;
@@ -105,6 +105,21 @@ export interface IFunctionInfo {
105
105
  Variables: IEnvVariable[];
106
106
  };
107
107
  Type: string;
108
+ /** HTTP 函数协议类型;SCF 缺省时表示普通 HTTP */
109
+ ProtocolType?: string;
110
+ /** 自定义镜像函数配置 */
111
+ ImageConfig?: {
112
+ ImageType?: string;
113
+ ImageUri?: string;
114
+ RegistryId?: string;
115
+ EntryPoint?: string;
116
+ Command?: string;
117
+ Args?: string;
118
+ ContainerImageAccelerate?: boolean;
119
+ ImagePort?: number;
120
+ CommandList?: string[];
121
+ ArgsList?: string[];
122
+ };
108
123
  EipConfig: {
109
124
  EipFixed: 'FALSE' | 'TRUE';
110
125
  Eips: string[];
@@ -122,6 +122,12 @@ export interface IRoutingRules {
122
122
  export interface IBucketWebsiteOptiosn {
123
123
  indexDocument: string;
124
124
  errorDocument?: string;
125
+ /** 错误文档是否保留原始 HTTP 状态码:Enabled / Disabled(SPA 回退需 Disabled) */
126
+ originalHttpStatus?: string;
127
+ /** 404 是否展示腾讯云公益页面:Enabled / Disabled(SPA 回退需 Disabled) */
128
+ charity404?: string;
129
+ /** 忽略 HTML 扩展名:Enabled / Disabled */
130
+ autoAddressing?: string;
125
131
  routingRules?: Array<IRoutingRules>;
126
132
  }
127
133
  export interface IFindOptions {
package/types/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { EnvService } from './env';
2
2
  import { FunctionService } from './function';
3
+ import { FunctionDeployer } from './deploy/FunctionDeployer';
3
4
  import { CloudRunService } from './cloudrun';
4
5
  import { AgentService } from './agent';
5
6
  import { StorageService } from './storage';
@@ -21,6 +22,8 @@ import { CloudAppService } from './cloudApp';
21
22
  import { AiModelService } from './aiModel';
22
23
  import { IntegrationService } from './integration';
23
24
  import { MonitorService } from './monitor';
25
+ import { ProjectValidator } from './projectValidator';
26
+ import { DeployOrchestrator } from './deploy/DeployOrchestrator';
24
27
  interface CloudBaseConfig {
25
28
  secretId?: string;
26
29
  secretKey?: string;
@@ -47,10 +50,17 @@ declare class CloudBase {
47
50
  private cloudBaseConfig;
48
51
  private environmentManager;
49
52
  private docsService;
53
+ private projectValidatorService;
54
+ private deployOrchestratorService;
50
55
  constructor(config?: CloudBaseConfig);
51
56
  addEnvironment(envId: string): void;
52
57
  currentEnvironment(): Environment;
53
58
  get functions(): FunctionService;
59
+ /**
60
+ * 函数部署编排器(FunctionDeployer)
61
+ * 在现有 FunctionService 之上,按 buildStrategy 编排 Event/HTTP 函数的创建、更新与访问收敛
62
+ */
63
+ get functionDeployer(): FunctionDeployer;
54
64
  get cloudrun(): CloudRunService;
55
65
  get agent(): AgentService;
56
66
  get storage(): StorageService;
@@ -101,6 +111,14 @@ declare class CloudBase {
101
111
  */
102
112
  get monitor(): MonitorService;
103
113
  get docs(): DocsService;
114
+ get projectValidator(): ProjectValidator;
115
+ getProjectValidator(): ProjectValidator;
116
+ /**
117
+ * 声明式部署编排器
118
+ * 顺序:database → functions → app → hosting → gateway;支持 dry-run / only / skip / 幂等重试
119
+ */
120
+ get deployOrchestrator(): DeployOrchestrator;
121
+ getDeployOrchestrator(): DeployOrchestrator;
104
122
  getEnvironmentManager(): EnvironmentManager;
105
123
  getManagerConfig(): CloudBaseConfig;
106
124
  get isInternalEndpoint(): Boolean;
@@ -44,7 +44,7 @@ export interface ICloudFunction extends ICloudFunctionConfig {
44
44
  name: string;
45
45
  description?: string;
46
46
  type?: 'Event' | 'HTTP';
47
- protocolType?: 'WS';
47
+ protocolType?: 'HTTP' | 'WS';
48
48
  protocolParams?: {
49
49
  wsParams?: {
50
50
  idleTimeOut?: number;
@@ -0,0 +1,24 @@
1
+ import { ProjectValidationResult, ProjectValidatorValidateOptions } from './types';
2
+ export declare class ProjectValidator {
3
+ validate(options?: ProjectValidatorValidateOptions): Promise<ProjectValidationResult>;
4
+ private loadProjectConfig;
5
+ private validateSchema;
6
+ private validateEnvId;
7
+ /**
8
+ * 个人版 TCR 的 username/password/namespace 必须在 cloudbaserc 中显式声明。
9
+ * ConfigParser 已先解析 {{env.*}},因此这里同时承担缺失 env 值的前置校验。
10
+ */
11
+ private validatePersonalRegistryConfig;
12
+ private hasPersonalCloudFunction;
13
+ private isPersonalCloudFunction;
14
+ private validateResources;
15
+ private validateConsistency;
16
+ private validateUniqueNames;
17
+ private validateUniqueField;
18
+ private validateGatewayTargets;
19
+ private getSummary;
20
+ private getLinkedEnvId;
21
+ private normalizeSchemaPath;
22
+ private getErrorMessage;
23
+ }
24
+ export * from './types';
@@ -0,0 +1,26 @@
1
+ export type ProjectValidationIssueLevel = 'error' | 'warning';
2
+ export interface ProjectValidationIssue {
3
+ level: ProjectValidationIssueLevel;
4
+ resource?: string;
5
+ field?: string;
6
+ message: string;
7
+ fix?: string;
8
+ }
9
+ export interface ProjectValidationSummary {
10
+ functions: number;
11
+ hosting: number;
12
+ databases: number;
13
+ gateways: number;
14
+ }
15
+ export interface ProjectValidationResult {
16
+ valid: boolean;
17
+ version: string;
18
+ errors: ProjectValidationIssue[];
19
+ warnings: ProjectValidationIssue[];
20
+ summary: ProjectValidationSummary;
21
+ }
22
+ export interface ProjectValidatorValidateOptions {
23
+ cwd?: string;
24
+ configPath?: string;
25
+ mode?: string;
26
+ }
@@ -49,6 +49,12 @@ export interface IRoutingRules {
49
49
  export interface IBucketWebsiteOptions {
50
50
  indexDocument: string;
51
51
  errorDocument?: string;
52
+ /** 错误文档是否保留原始 HTTP 状态码:Enabled / Disabled(SPA 回退需 Disabled,否则 404 状态码使前端路由失效) */
53
+ originalHttpStatus?: string;
54
+ /** 404 是否展示腾讯云公益页面:Enabled / Disabled(SPA 回退需 Disabled,否则覆盖错误文档) */
55
+ charity404?: string;
56
+ /** 忽略 HTML 扩展名:Enabled / Disabled(未传则保持默认 Disabled) */
57
+ autoAddressing?: string;
52
58
  routingRules?: Array<IRoutingRules>;
53
59
  region: string;
54
60
  bucket: string;
@@ -6,11 +6,24 @@ export * from './envLazy';
6
6
  export * from './fs';
7
7
  export * from './http-request';
8
8
  export { guid6 } from './uuid';
9
+ interface IZipExtraEntry {
10
+ /** zip 包内的相对路径 */
11
+ zipPath: string;
12
+ /** 文件文本内容 */
13
+ content: string | Buffer;
14
+ /** unix 权限位(八进制),如 0o755 */
15
+ mode?: number;
16
+ }
9
17
  interface IZipOption {
10
18
  dirPath: string;
11
19
  outputPath: string;
12
20
  ignore?: string | string[];
13
21
  pattern?: string;
22
+ /**
23
+ * 额外注入 zip 的文件条目(不来自 dirPath),用于把 SDK 生成的辅助文件
24
+ * (如构建推送脚本)打进包内,而不污染用户源码目录。
25
+ */
26
+ extraEntries?: IZipExtraEntry[];
14
27
  }
15
28
  export declare function compressToZip(option: IZipOption): Promise<unknown>;
16
29
  /**