@cloudbase/manager-node 4.7.1 → 4.7.3

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.
@@ -261,6 +261,7 @@ class CloudRunService {
261
261
  }
262
262
  catch (e) {
263
263
  if (e.code === 'ResourceNotFound' ||
264
+ e.code === 'ResourceNotFound.ServerNotFound' ||
264
265
  // 备注:以下条件当 NotFound 处理(已与 fisheryan 确认过)
265
266
  (e.code === 'InvalidParameter' && e.original.Message === 'service data illegal')) {
266
267
  return false;
@@ -1298,12 +1298,12 @@ class FunctionService {
1298
1298
  }
1299
1299
  async getCodeParams(options, installDependency) {
1300
1300
  const { func, functionPath, functionRootPath, base64Code, deployMode } = options;
1301
- // 更新的时候直接上传的zip包的情况
1302
- // ZIP 包大小上限 20MB,base64 编码后长度约为原始大小的 4/3
1303
- const MAX_ZIP_SIZE = 20 * 1024 * 1024; // 20MB
1304
- const MAX_BASE64_LENGTH = Math.floor(MAX_ZIP_SIZE * 4 / 3); // ≈ 27962026
1301
+ // 直接传入 base64Code 的情况,校验大小
1302
+ // ZipFile 上传大小上限 1.5MB,base64 编码后长度约为原始大小的 4/3
1303
+ const MAX_ZIP_SIZE = 1.5 * 1024 * 1024; // 1.5MB
1304
+ const MAX_BASE64_LENGTH = Math.floor(MAX_ZIP_SIZE * 4 / 3); // ≈ 2097152
1305
1305
  if ((base64Code === null || base64Code === void 0 ? void 0 : base64Code.length) > MAX_BASE64_LENGTH) {
1306
- throw new error_1.CloudBaseError('ZIP 包不能大于 20MB');
1306
+ throw new error_1.CloudBaseError('ZipFile 上传不能大于 1.5MB,请使用 COS 上传方式');
1307
1307
  }
1308
1308
  if (base64Code === null || base64Code === void 0 ? void 0 : base64Code.length) {
1309
1309
  return {
@@ -1323,10 +1323,14 @@ class FunctionService {
1323
1323
  root: functionRootPath
1324
1324
  });
1325
1325
  await packer.build();
1326
- // 如果指定了上传方式,按指定方式上传
1327
- // 判断是否需要走 COS 上传
1326
+ // 判断是否超过 ZipFile 上传大小限制(1.5MB)
1328
1327
  const reachMax = await packer.isReachMaxSize();
1329
- const useCos = deployMode === 'cos' || (deployMode !== 'zip' && reachMax);
1328
+ // 如果指定了 zip 上传方式但超过大小限制,直接报错
1329
+ if (deployMode === 'zip' && reachMax) {
1330
+ throw new error_1.CloudBaseError('ZipFile 上传不能大于 1.5MB,请使用 COS 上传方式(deployMode: "cos")');
1331
+ }
1332
+ // 走 COS 上传:指定 cos 模式,或未指定模式但超过大小限制
1333
+ const useCos = deployMode === 'cos' || reachMax;
1330
1334
  if (useCos) {
1331
1335
  // 先调用scf的 COS 上传方式
1332
1336
  const legacyResult = await this.uploadFunctionZipToCosLegacy(options, installDependency);
@@ -47,7 +47,8 @@ const error_1 = require("../error");
47
47
  const os = __importStar(require("os"));
48
48
  // 10 MB
49
49
  exports.BIG_FILE_SIZE = 10485760;
50
- exports.API_MAX_SIZE = 52428800;
50
+ // ZipFile 上传最大 1.5MB
51
+ exports.API_MAX_SIZE = 1.5 * 1024 * 1024;
51
52
  var CodeType;
52
53
  (function (CodeType) {
53
54
  CodeType[CodeType["File"] = 0] = "File";
@@ -136,7 +137,7 @@ class FunctionPacker {
136
137
  const fileStats = await promiseStat(this.zipFilePath);
137
138
  return fileStats.size > exports.BIG_FILE_SIZE;
138
139
  }
139
- // API 最大 50MB
140
+ // ZipFile 上传最大 1.5MB
140
141
  async isReachMaxSize() {
141
142
  if (!this.zipFilePath) {
142
143
  await this.build();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/manager-node",
3
- "version": "4.7.1",
3
+ "version": "4.7.3",
4
4
  "description": "The node manage service api for cloudbase.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  export declare const BIG_FILE_SIZE = 10485760;
2
- export declare const API_MAX_SIZE = 52428800;
2
+ export declare const API_MAX_SIZE: number;
3
3
  export declare enum CodeType {
4
4
  File = 0,
5
5
  JavaFile = 1