@geek-fun/serverlessinsight 0.7.0 → 0.7.1

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 (37) hide show
  1. package/README.md +58 -1
  2. package/README.zh-CN.md +3 -1
  3. package/dist/package.json +37 -35
  4. package/dist/src/common/aliyunClient/apigwOperations.js +9 -4
  5. package/dist/src/common/aliyunClient/cdnOperations.js +191 -0
  6. package/dist/src/common/aliyunClient/ecsOperations.js +2 -2
  7. package/dist/src/common/aliyunClient/fc3Operations.js +1 -1
  8. package/dist/src/common/aliyunClient/index.js +8 -0
  9. package/dist/src/common/aliyunClient/ossOperations.js +62 -2
  10. package/dist/src/common/aliyunClient/ramOperations.js +1 -1
  11. package/dist/src/common/hashUtils.js +4 -0
  12. package/dist/src/common/iacHelper.js +5 -0
  13. package/dist/src/common/lockManager.js +8 -0
  14. package/dist/src/common/planFormatter.js +4 -0
  15. package/dist/src/common/retryUtils.js +1 -1
  16. package/dist/src/common/stateManager.js +10 -0
  17. package/dist/src/common/volcengineClient/apigwOperations.js +1 -1
  18. package/dist/src/lang/en.js +15 -0
  19. package/dist/src/lang/zh-CN.js +16 -1
  20. package/dist/src/parser/bucketParser.js +111 -46
  21. package/dist/src/stack/aliyunStack/apigwResource.js +310 -47
  22. package/dist/src/stack/aliyunStack/apigwTypes.js +61 -1
  23. package/dist/src/stack/aliyunStack/ossResource.js +401 -69
  24. package/dist/src/stack/aliyunStack/ossTypes.js +58 -16
  25. package/dist/src/stack/scfStack/cosTypes.js +3 -6
  26. package/dist/src/stack/volcengineStack/tosTypes.js +1 -3
  27. package/dist/src/types/domains/state.js +3 -0
  28. package/dist/src/validator/bucketSchema.js +124 -56
  29. package/dist/src/validator/eventSchema.js +20 -0
  30. package/dist/tsconfig.tsbuildinfo +1 -1
  31. package/package.json +37 -35
  32. package/samples/README_TENCENT_COS.md +3 -15
  33. package/samples/aliyun-poc-bucket-cdn.yml +63 -0
  34. package/samples/aliyun-poc-bucket.yml +0 -2
  35. package/samples/aliyun-poc-domain.yml +0 -2
  36. package/samples/tencent-poc-cos.yml +0 -2
  37. package/samples/volcengine-poc-bucket.yml +0 -1
package/README.md CHANGED
@@ -9,7 +9,9 @@
9
9
  [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
10
10
  [![codecov](https://codecov.io/gh/geek-fun/serverlessinsight/graph/badge.svg?token=ISW7MFuSlf)](https://codecov.io/gh/geek-fun/serverlessinsight)
11
11
 
12
- **Full life cycle cross-provider serverless application management for your fast-growing business**
12
+ **Describe your app. We handle the rest.**
13
+
14
+ *Full life cycle cross-provider serverless application management for your fast-growing business*
13
15
 
14
16
  [Website](https://serverlessinsight.geekfun.club) • [Documentation](https://serverlessinsight.geekfun.club) • [Examples](./samples) • [中文文档](./README.zh-CN.md)
15
17
 
@@ -344,6 +346,61 @@ For OSS static website hosting, ServerlessInsight supports:
344
346
 
345
347
  For detailed configuration, see [OSS Custom Domain Binding Guide](./docs/oss-custom-domain-binding.md).
346
348
 
349
+ ### CDN Acceleration & OSS Transfer Acceleration
350
+
351
+ ServerlessInsight supports CDN acceleration and OSS Transfer Acceleration for buckets, enabling global content delivery and optimized origin fetch.
352
+
353
+ **CDN** (`cdn`): Create a CDN distribution in front of your bucket for edge caching and global acceleration. Accepts `boolean` (simple on/off) or `object` for advanced configuration:
354
+
355
+ ```yaml
356
+ buckets:
357
+ # Simple: CDN with sensible defaults
358
+ my_site:
359
+ name: my-static-site
360
+ website:
361
+ code: ./dist
362
+ index: index.html
363
+ domain:
364
+ domain_name: www.example.com
365
+ certificate_id: cas-abc123
366
+ cdn: true
367
+
368
+ # Advanced: CDN with custom config
369
+ releases:
370
+ name: app-releases
371
+ security:
372
+ acl: PRIVATE
373
+ domain:
374
+ domain_name: releases.example.com
375
+ cdn:
376
+ enabled: true
377
+ cdn_type: download # web | download | video
378
+ scope: global # domestic | overseas | global
379
+ ```
380
+
381
+ **Transfer Acceleration** (`accelerate`): Enables OSS Transfer Acceleration for cross-region/global data transfers. Routes traffic through Alibaba backbone network:
382
+
383
+ ```yaml
384
+ buckets:
385
+ cross_region_backups:
386
+ name: backup-bucket
387
+ domain:
388
+ domain_name: backups.internal.example.com
389
+ accelerate: true # No CDN, just accelerate
390
+
391
+ # CDN + Accelerate (dual-layer)
392
+ global_assets:
393
+ name: global-assets
394
+ domain:
395
+ domain_name: assets.example.com
396
+ cdn:
397
+ enabled: true
398
+ cdn_type: web
399
+ accelerate: true # CDN origin uses accelerated endpoint
400
+ ```
401
+
402
+ **Backward Compatibility**: Existing `website.domain` config continues to work. When a bucket uses `website.domain` without the top-level `domain` block, a deprecation notice is logged suggesting migration to the canonical form.
403
+
347
404
  ---
348
405
 
349
406
  ## 🗄️ State Management
package/README.zh-CN.md CHANGED
@@ -9,7 +9,9 @@
9
9
  [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
10
10
  [![codecov](https://codecov.io/gh/geek-fun/serverlessinsight/graph/badge.svg?token=ISW7MFuSlf)](https://codecov.io/gh/geek-fun/serverlessinsight)
11
11
 
12
- **为快速增长的业务提供全生命周期跨云服务商的 Serverless 应用管理**
12
+ **描述你的应用,剩下的交给我们。**
13
+
14
+ *为快速增长的业务提供全生命周期跨云服务商的 Serverless 应用管理*
13
15
 
14
16
  [官方网站](https://serverlessinsight.geekfun.club) • [文档](https://serverlessinsight.geekfun.club) • [示例](./samples) • [English](./README.md)
15
17
 
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geek-fun/serverlessinsight",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Full life cycle cross providers serverless application management for your fast-growing business.",
5
5
  "homepage": "https://serverlessinsight.geekfun.club",
6
6
  "main": "dist/src/index.js",
@@ -53,61 +53,63 @@
53
53
  "function"
54
54
  ],
55
55
  "dependencies": {
56
- "@alicloud/alidns20150109": "^4.3.1",
57
- "@alicloud/cas20200407": "^3.2.0",
58
- "@alicloud/cloudapi20160714": "^4.7.9",
59
- "@alicloud/ecs20140526": "^7.6.0",
60
- "@alicloud/es-serverless20230627": "^2.3.0",
61
- "@alicloud/fc20230330": "^4.6.8",
62
- "@alicloud/ims20190815": "^2.3.3",
63
- "@alicloud/nas20170626": "^3.3.1",
56
+ "@alicloud/alidns20150109": "^4.4.1",
57
+ "@alicloud/cas20200407": "^3.2.8",
58
+ "@alicloud/cdn20180510": "^9.2.0",
59
+ "@alicloud/cloudapi20160714": "^4.8.0",
60
+ "@alicloud/ecs20140526": "^7.8.4",
61
+ "@alicloud/es-serverless20230627": "^2.3.1",
62
+ "@alicloud/fc20230330": "^4.7.6",
63
+ "@alicloud/ims20190815": "^2.3.6",
64
+ "@alicloud/nas20170626": "^3.4.2",
64
65
  "@alicloud/openapi-client": "^0.4.15",
65
- "@alicloud/ram20150501": "^1.2.0",
66
- "@alicloud/rds20140815": "^15.5.1",
67
- "@alicloud/sls20201230": "^5.9.0",
68
- "@volcengine/openapi": "^1.36.0",
69
- "@volcengine/tos-sdk": "^2.7.0",
70
- "ajv": "^8.18.0",
66
+ "@alicloud/ram20150501": "^1.2.1",
67
+ "@alicloud/rds20140815": "^15.9.0",
68
+ "@alicloud/sls20201230": "^5.10.1",
69
+ "@volcengine/openapi": "^1.36.2",
70
+ "@volcengine/tos-sdk": "^2.9.1",
71
+ "ajv": "^8.20.0",
71
72
  "ali-oss": "^6.23.0",
72
- "commander": "^14.0.3",
73
+ "commander": "^15.0.0",
73
74
  "cos-nodejs-sdk-v5": "^2.16.0-beta.8",
74
75
  "i18n": "^0.15.3",
75
76
  "iconv-lite": "^0.7.2",
76
77
  "jszip": "^3.10.1",
77
- "lodash": "^4.17.23",
78
+ "lodash": "^4.18.1",
78
79
  "pino": "^10.3.1",
79
80
  "pino-pretty": "^13.1.3",
80
- "tablestore": "^5.6.3",
81
- "tencentcloud-sdk-nodejs-cynosdb": "^4.1.188",
82
- "tencentcloud-sdk-nodejs-dnspod": "^4.1.197",
83
- "tencentcloud-sdk-nodejs-es": "^4.1.183",
81
+ "tablestore": "^5.6.5",
82
+ "tencentcloud-sdk-nodejs-cynosdb": "^4.1.249",
83
+ "tencentcloud-sdk-nodejs-dnspod": "^4.1.213",
84
+ "tencentcloud-sdk-nodejs-es": "^4.1.238",
84
85
  "tencentcloud-sdk-nodejs-scf": "^4.1.168",
85
- "tencentcloud-sdk-nodejs-ssl": "^4.1.191",
86
- "yaml": "^2.8.2"
86
+ "tencentcloud-sdk-nodejs-ssl": "^4.1.239",
87
+ "yaml": "^2.9.0"
87
88
  },
88
89
  "devDependencies": {
89
- "@eslint/eslintrc": "^3.3.4",
90
+ "@eslint/eslintrc": "^3.3.5",
90
91
  "@eslint/js": "^10.0.1",
91
92
  "@types/ali-oss": "^6.23.3",
92
93
  "@types/i18n": "^0.13.12",
93
94
  "@types/jest": "^30.0.0",
94
95
  "@types/lodash": "^4.17.24",
95
- "@types/node": "^25.3.2",
96
- "@typescript-eslint/eslint-plugin": "^8.56.1",
97
- "@typescript-eslint/parser": "^8.56.1",
96
+ "@types/node": "^25.9.3",
97
+ "@typescript-eslint/eslint-plugin": "^8.61.0",
98
+ "@typescript-eslint/parser": "^8.61.0",
98
99
  "cross-env": "^10.1.0",
99
- "eslint": "^10.0.2",
100
+ "eslint": "^10.5.0",
100
101
  "eslint-config-prettier": "^10.1.8",
101
- "eslint-plugin-prettier": "^5.5.5",
102
- "globals": "^17.3.0",
102
+ "eslint-plugin-prettier": "^5.5.6",
103
+ "globals": "^17.6.0",
103
104
  "husky": "^9.1.7",
104
- "jest": "^30.2.0",
105
- "prettier": "^3.8.1",
106
- "ts-jest": "^29.4.6",
105
+ "jest": "^30.4.2",
106
+ "prettier": "^3.8.4",
107
+ "ts-jest": "^29.4.11",
107
108
  "ts-node": "^10.9.2",
108
- "typescript": "^5.9.3"
109
+ "typescript": "^6.0.3"
109
110
  },
110
111
  "overrides": {
111
- "fast-xml-parser": ">=5.3.8"
112
+ "fast-xml-parser": ">=5.3.8",
113
+ "protobufjs": "^7.6.1"
112
114
  }
113
115
  }
@@ -47,6 +47,7 @@ const retryUtils_1 = require("../retryUtils");
47
47
  const removeUndefined = (obj) => {
48
48
  return Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== undefined));
49
49
  };
50
+ /* istanbul ignore next */
50
51
  const isNetworkTimeoutError = (error) => {
51
52
  if (!error || typeof error !== 'object')
52
53
  return false;
@@ -59,6 +60,7 @@ const isNetworkTimeoutError = (error) => {
59
60
  (err.message?.includes('RequestTimeoutError') ?? false));
60
61
  };
61
62
  exports.isNetworkTimeoutError = isNetworkTimeoutError;
63
+ /* istanbul ignore next */
62
64
  const isDomainAlreadyBoundError = (error) => {
63
65
  if (!error || typeof error !== 'object')
64
66
  return false;
@@ -69,6 +71,7 @@ const isDomainAlreadyBoundError = (error) => {
69
71
  (err.message?.toLowerCase().includes('domain bindedbyother') ?? false));
70
72
  };
71
73
  exports.isDomainAlreadyBoundError = isDomainAlreadyBoundError;
74
+ /* istanbul ignore next */
72
75
  const createApigwOperations = (apigwClient, dnsClient, _context) => {
73
76
  const dnsOps = (0, dnsOperations_1.createDnsOperations)(dnsClient);
74
77
  const buildTxtVerificationRecord = (groupId, domainName, groupSubdomain, mainDomain) => {
@@ -660,7 +663,7 @@ const createApigwOperations = (apigwClient, dnsClient, _context) => {
660
663
  * Per Aliyun docs: CNAME must exist BEFORE calling SetDomain.
661
664
  * On SingleDomainOwnershipCheckFail, falls back to TXT verification with retry.
662
665
  */
663
- bindCustomDomain: async (config, state, eventLogicalId) => {
666
+ bindCustomDomain: async (config, state, eventLogicalId, skipDns) => {
664
667
  logger_1.logger.info(lang_1.lang.__('APIGW_BINDING_DOMAIN', { domain: config.domainName }));
665
668
  const groupInfo = await apigwClient.describeApiGroup(new cloudapi.DescribeApiGroupRequest({ groupId: config.groupId }));
666
669
  const region = groupInfo.body?.regionId || _context.region;
@@ -669,9 +672,11 @@ const createApigwOperations = (apigwClient, dnsClient, _context) => {
669
672
  if (!groupSubdomain) {
670
673
  throw new Error(`API group ${config.groupId} has no subDomain — cannot configure domain binding`);
671
674
  }
672
- logger_1.logger.info(lang_1.lang.__('APIGW_ENSURING_CNAME', { domain: config.domainName }));
673
- state = await addDomainVerificationRecord(config.domainName, groupId, groupSubdomain, region, state, eventLogicalId);
674
- await pollPublicDnsResolution(config.domainName);
675
+ if (!skipDns) {
676
+ logger_1.logger.info(lang_1.lang.__('APIGW_ENSURING_CNAME', { domain: config.domainName }));
677
+ state = await addDomainVerificationRecord(config.domainName, groupId, groupSubdomain, region, state, eventLogicalId);
678
+ await pollPublicDnsResolution(config.domainName);
679
+ }
675
680
  const setDomainRequest = new cloudapi.SetDomainRequest({
676
681
  groupId: config.groupId,
677
682
  domainName: config.domainName,
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.createCdnOperations = void 0;
37
+ const cdn = __importStar(require("@alicloud/cdn20180510"));
38
+ const addCdnDomain = (cdnClient) => async (config) => {
39
+ const request = new cdn.AddCdnDomainRequest({
40
+ domainName: config.domainName,
41
+ cdnType: config.cdnType,
42
+ sources: JSON.stringify(config.sources.map((s) => ({
43
+ type: s.type,
44
+ content: s.content,
45
+ port: s.port ?? 80,
46
+ priority: s.priority ?? 20,
47
+ weight: s.weight ?? 10,
48
+ }))),
49
+ scope: config.scope ?? 'global',
50
+ checkUrl: config.checkUrl,
51
+ });
52
+ await cdnClient.addCdnDomain(request);
53
+ };
54
+ const describeCdnDomainDetail = (cdnClient) => async (domainName) => {
55
+ try {
56
+ const request = new cdn.DescribeCdnDomainDetailRequest({ domainName });
57
+ const response = await cdnClient.describeCdnDomainDetail(request);
58
+ const detail = response.body?.getDomainDetailModel;
59
+ if (!detail)
60
+ return null;
61
+ return {
62
+ domainName: detail.domainName,
63
+ cname: detail.cname,
64
+ status: detail.domainStatus,
65
+ scope: detail.scope,
66
+ cdnType: detail.cdnType,
67
+ };
68
+ }
69
+ catch {
70
+ return null;
71
+ }
72
+ };
73
+ const deleteCdnDomain = (cdnClient) => async (domainName) => {
74
+ const request = new cdn.DeleteCdnDomainRequest({ domainName });
75
+ await cdnClient.deleteCdnDomain(request);
76
+ };
77
+ const modifyCdnDomain = (cdnClient) => async (config) => {
78
+ const request = new cdn.ModifyCdnDomainRequest({
79
+ domainName: config.domainName,
80
+ ...(config.cdnType ? { cdnType: config.cdnType } : {}),
81
+ ...(config.scope ? { scope: config.scope } : {}),
82
+ sources: config.sources
83
+ ? JSON.stringify(config.sources.map((s) => ({
84
+ type: s.type,
85
+ content: s.content,
86
+ port: s.port ?? 80,
87
+ priority: s.priority ?? 20,
88
+ weight: s.weight ?? 10,
89
+ })))
90
+ : undefined,
91
+ });
92
+ await cdnClient.modifyCdnDomain(request);
93
+ };
94
+ const setDomainServerCertificate = (cdnClient) => async (domainName, certConfig) => {
95
+ const request = new cdn.SetCdnDomainSSLCertificateRequest({
96
+ domainName,
97
+ certName: certConfig.certName,
98
+ certType: certConfig.certType ?? 'upload',
99
+ certId: certConfig.certId,
100
+ SSLPub: certConfig.serverCertificate,
101
+ SSLPri: certConfig.privateKey,
102
+ SSLProtocol: certConfig.serverCertificateStatus ?? 'on',
103
+ certRegion: certConfig.certRegion,
104
+ });
105
+ await cdnClient.setCdnDomainSSLCertificate(request);
106
+ };
107
+ const applyCacheConfig = (cdnClient) => async (domainName, cacheTtl, ignoreQueryString) => {
108
+ const functions = [];
109
+ if (cacheTtl != null || ignoreQueryString != null) {
110
+ functions.push({
111
+ featureName: 'cache_expire',
112
+ featureParameters: {
113
+ cache_ttl: cacheTtl != null ? String(cacheTtl) : '0',
114
+ ignore_query_string: ignoreQueryString != null ? (ignoreQueryString ? 'on' : 'off') : 'off',
115
+ redirect_type: 'default',
116
+ },
117
+ });
118
+ }
119
+ if (functions.length > 0) {
120
+ const request = new cdn.BatchSetCdnDomainConfigRequest({
121
+ domainNames: domainName,
122
+ functions: JSON.stringify(functions),
123
+ });
124
+ await cdnClient.batchSetCdnDomainConfig(request);
125
+ }
126
+ };
127
+ const applyProtocolConfig = (cdnClient) => async (domainName, originProtocol) => {
128
+ if (originProtocol) {
129
+ const functions = [
130
+ {
131
+ featureName: 'forward_scheme',
132
+ featureParameters: {
133
+ enable: originProtocol,
134
+ },
135
+ },
136
+ ];
137
+ const request = new cdn.BatchSetCdnDomainConfigRequest({
138
+ domainNames: domainName,
139
+ functions: JSON.stringify(functions),
140
+ });
141
+ await cdnClient.batchSetCdnDomainConfig(request);
142
+ }
143
+ };
144
+ const applyCompression = (cdnClient) => async (domainName, enabled) => {
145
+ if (enabled != null) {
146
+ const functions = [
147
+ {
148
+ featureName: 'page_compress',
149
+ featureParameters: {
150
+ enable: enabled ? 'on' : 'off',
151
+ },
152
+ },
153
+ ];
154
+ const request = new cdn.BatchSetCdnDomainConfigRequest({
155
+ domainNames: domainName,
156
+ functions: JSON.stringify(functions),
157
+ });
158
+ await cdnClient.batchSetCdnDomainConfig(request);
159
+ }
160
+ };
161
+ const applyHttpsRedirect = (cdnClient) => async (domainName, enabled) => {
162
+ if (enabled != null) {
163
+ const functions = [
164
+ {
165
+ featureName: 'force_redirect',
166
+ featureParameters: {
167
+ redirect_code: '301',
168
+ redirect_type: enabled ? 'https' : 'http',
169
+ },
170
+ },
171
+ ];
172
+ const request = new cdn.BatchSetCdnDomainConfigRequest({
173
+ domainNames: domainName,
174
+ functions: JSON.stringify(functions),
175
+ });
176
+ await cdnClient.batchSetCdnDomainConfig(request);
177
+ }
178
+ };
179
+ /* istanbul ignore next */
180
+ const createCdnOperations = (cdnClient) => ({
181
+ addCdnDomain: addCdnDomain(cdnClient),
182
+ describeCdnDomainDetail: describeCdnDomainDetail(cdnClient),
183
+ deleteCdnDomain: deleteCdnDomain(cdnClient),
184
+ modifyCdnDomain: modifyCdnDomain(cdnClient),
185
+ setDomainServerCertificate: setDomainServerCertificate(cdnClient),
186
+ applyCacheConfig: applyCacheConfig(cdnClient),
187
+ applyProtocolConfig: applyProtocolConfig(cdnClient),
188
+ applyCompression: applyCompression(cdnClient),
189
+ applyHttpsRedirect: applyHttpsRedirect(cdnClient),
190
+ });
191
+ exports.createCdnOperations = createCdnOperations;
@@ -50,7 +50,7 @@ const transformPortRange = (protocol, portRange) => {
50
50
  return portRange.includes('/') ? portRange : `${portRange}/${portRange}`;
51
51
  };
52
52
  const normalizeProtocol = (protocol) => protocol.trim().toUpperCase();
53
- const parseSecurityGroupRule = (rule) => {
53
+ /* istanbul ignore next */ const parseSecurityGroupRule = (rule) => {
54
54
  const [rawProtocol, second, third, ...rest] = rule.split(':');
55
55
  if (rest.length > 0 || !rawProtocol || !second || !third) {
56
56
  throw new Error(`Invalid security group rule format: ${rule}`);
@@ -78,7 +78,7 @@ const isDuplicateSecurityGroupRuleError = (error) => {
78
78
  ]);
79
79
  return duplicateCodes.has(error.code);
80
80
  };
81
- const createEcsOperations = (ecsClient, context) => {
81
+ /* istanbul ignore next */ const createEcsOperations = (ecsClient, context) => {
82
82
  const operations = {
83
83
  createSecurityGroup: async (securityGroupName, vpcId, ingressRules, egressRules, description) => {
84
84
  const createRequest = new ecs.CreateSecurityGroupRequest({
@@ -50,7 +50,7 @@ const buildCodeLocation = (codePath, ossCode) => {
50
50
  const codeBase64 = codeBuffer.toString('base64');
51
51
  return new fc.InputCodeLocation({ zipFile: codeBase64 });
52
52
  };
53
- const createFc3Operations = (fc3Client) => ({
53
+ /* istanbul ignore next */ const createFc3Operations = (fc3Client) => ({
54
54
  createFunction: async (config, codePath, ossCode) => {
55
55
  const createFunctionInput = new fc.CreateFunctionInput({
56
56
  functionName: config.functionName,
@@ -50,6 +50,7 @@ const rds20140815_1 = __importDefault(require("@alicloud/rds20140815"));
50
50
  const es_serverless20230627_1 = __importDefault(require("@alicloud/es-serverless20230627"));
51
51
  const alidns20150109_1 = __importDefault(require("@alicloud/alidns20150109"));
52
52
  const cas20200407_1 = __importDefault(require("@alicloud/cas20200407"));
53
+ const cdn20180510_1 = __importDefault(require("@alicloud/cdn20180510"));
53
54
  const $OpenApi = __importStar(require("@alicloud/openapi-client"));
54
55
  const ali_oss_1 = __importDefault(require("ali-oss"));
55
56
  const constants_1 = require("../constants");
@@ -65,6 +66,7 @@ const esOperations_1 = require("./esOperations");
65
66
  const tablestoreOperations_1 = require("./tablestoreOperations");
66
67
  const dnsOperations_1 = require("./dnsOperations");
67
68
  const casOperations_1 = require("./casOperations");
69
+ const cdnOperations_1 = require("./cdnOperations");
68
70
  __exportStar(require("./types"), exports);
69
71
  __exportStar(require("./apigwOperations"), exports);
70
72
  __exportStar(require("./ossOperations"), exports);
@@ -73,6 +75,7 @@ __exportStar(require("./esOperations"), exports);
73
75
  __exportStar(require("./tablestoreOperations"), exports);
74
76
  __exportStar(require("./dnsOperations"), exports);
75
77
  __exportStar(require("./casOperations"), exports);
78
+ __exportStar(require("./cdnOperations"), exports);
76
79
  const initializeSdkClients = (context) => {
77
80
  const baseConfig = {
78
81
  accessKeyId: context.accessKeyId,
@@ -118,6 +121,9 @@ const initializeSdkClients = (context) => {
118
121
  const casConfig = new $OpenApi.Config(baseConfig);
119
122
  casConfig.endpoint = `cas.aliyuncs.com`;
120
123
  const casClient = new cas20200407_1.default(casConfig);
124
+ const cdnConfig = new $OpenApi.Config(baseConfig);
125
+ cdnConfig.endpoint = `cdn.aliyuncs.com`;
126
+ const cdnClient = new cdn20180510_1.default(cdnConfig);
121
127
  return {
122
128
  fc3: fc3Client,
123
129
  sls: slsClient,
@@ -130,6 +136,7 @@ const initializeSdkClients = (context) => {
130
136
  es: esClient,
131
137
  dns: dnsClient,
132
138
  cas: casClient,
139
+ cdn: cdnClient,
133
140
  };
134
141
  };
135
142
  const createAliyunClient = (context) => {
@@ -147,6 +154,7 @@ const createAliyunClient = (context) => {
147
154
  es: (0, esOperations_1.createEsOperations)(sdkClients.es, context),
148
155
  cas: (0, casOperations_1.createCasOperations)(sdkClients.cas),
149
156
  dns: dnsOps,
157
+ cdn: (0, cdnOperations_1.createCdnOperations)(sdkClients.cdn),
150
158
  tablestore: (instanceName) => (0, tablestoreOperations_1.createTablestoreOperations)(`https://${instanceName}.${context.region}.ots.aliyuncs.com`, instanceName, context),
151
159
  };
152
160
  };
@@ -36,7 +36,7 @@ const parseXmlResponse = (xml, tagName) => {
36
36
  return null;
37
37
  }
38
38
  };
39
- const createOssOperations = (ossClient, region, dnsOps) => {
39
+ /* istanbul ignore next */ const createOssOperations = (ossClient, region, dnsOps) => {
40
40
  const useBucket = (bucketName) => {
41
41
  ossClient.useBucket(bucketName);
42
42
  };
@@ -232,7 +232,7 @@ const createOssOperations = (ossClient, region, dnsOps) => {
232
232
  logger_1.logger.warn(lang_1.lang.__('OSS_CORS_RULE_REMOVE_FAILED', { domain, error: String(error) }));
233
233
  }
234
234
  };
235
- const bindCustomDomain = async (bucketName, domain, certificate) => {
235
+ const bindCustomDomain = async (bucketName, domain, certificate, skipDns) => {
236
236
  const normalizedDomain = (0, domainUtils_1.normalizeDomain)(domain);
237
237
  const mainDomain = (0, domainUtils_1.extractMainDomain)(normalizedDomain);
238
238
  const hostRecord = (0, domainUtils_1.extractHostRecord)(normalizedDomain, mainDomain);
@@ -249,6 +249,10 @@ const createOssOperations = (ossClient, region, dnsOps) => {
249
249
  logger_1.logger.info(lang_1.lang.__('OSS_BUCKET_CERT_BOUND', { domain: normalizedDomain }));
250
250
  }
251
251
  await addCorsRuleForDomain(bucketName, normalizedDomain);
252
+ // When skipDns is true, caller manages DNS separately (e.g. CDN mode)
253
+ if (skipDns) {
254
+ return { domain: normalizedDomain, cname: ossEndpoint, bucketCnameBound, txtRecordId };
255
+ }
252
256
  if (!dnsOps) {
253
257
  logger_1.logger.warn(lang_1.lang.__('OSS_DNS_MANUAL_CONFIG_REQUIRED', { domain: normalizedDomain, cname: ossEndpoint }));
254
258
  return { domain: normalizedDomain, cname: ossEndpoint, bucketCnameBound, txtRecordId };
@@ -501,6 +505,8 @@ const createOssOperations = (ossClient, region, dnsOps) => {
501
505
  await ossClient.putBucketWebsite(config.bucketName, {
502
506
  index: config.websiteConfig.indexDocument,
503
507
  error: config.websiteConfig.errorDocument,
508
+ supportSubDir: true,
509
+ type: 2,
504
510
  });
505
511
  }
506
512
  return {
@@ -653,6 +659,8 @@ const createOssOperations = (ossClient, region, dnsOps) => {
653
659
  await ossClient.putBucketWebsite(bucketName, {
654
660
  index: websiteConfig.indexDocument,
655
661
  error: websiteConfig.errorDocument,
662
+ supportSubDir: true,
663
+ type: 2,
656
664
  });
657
665
  },
658
666
  deleteBucketWebsite: async (bucketName) => {
@@ -709,9 +717,61 @@ const createOssOperations = (ossClient, region, dnsOps) => {
709
717
  useBucket(bucketName);
710
718
  await ossClient.put(objectKey, filePath);
711
719
  },
720
+ enableTransferAcceleration: async (bucketName) => {
721
+ useBucket(bucketName);
722
+ try {
723
+ const xml = `<?xml version="1.0" encoding="UTF-8"?>
724
+ <TransferAccelerationConfiguration>
725
+ <Enabled>true</Enabled>
726
+ </TransferAccelerationConfiguration>`;
727
+ const params = {
728
+ method: 'PUT',
729
+ bucket: bucketName,
730
+ subres: { transferAcceleration: '' },
731
+ headers: { 'Content-Type': 'application/xml' },
732
+ content: xml,
733
+ successStatuses: [200],
734
+ };
735
+ await ossRequest(ossClient, params);
736
+ logger_1.logger.info(lang_1.lang.__('OSS_TRANSFER_ACCELERATION_ENABLED', { bucketName }));
737
+ return true;
738
+ }
739
+ catch (error) {
740
+ logger_1.logger.warn(lang_1.lang.__('OSS_TRANSFER_ACCELERATION_ENABLE_FAILED', {
741
+ bucketName,
742
+ error: String(error),
743
+ }));
744
+ return false;
745
+ }
746
+ },
747
+ getTransferAccelerationStatus: async (bucketName) => {
748
+ useBucket(bucketName);
749
+ try {
750
+ const params = {
751
+ method: 'GET',
752
+ bucket: bucketName,
753
+ subres: { transferAcceleration: '' },
754
+ successStatuses: [200],
755
+ };
756
+ const response = await ossRequest(ossClient, params);
757
+ const xml = response.data || '';
758
+ const match = /<Enabled>(\w+)<\/Enabled>/.exec(xml);
759
+ return match?.[1]?.toLowerCase() === 'true';
760
+ }
761
+ catch {
762
+ return false;
763
+ }
764
+ },
765
+ getAccelerateEndpoint: async (bucketName) => {
766
+ const infoResult = await ossClient.getBucketInfo(bucketName);
767
+ const bucket = infoResult.bucket;
768
+ const actualBucketName = bucket.Name || bucketName;
769
+ return `${actualBucketName}.oss-accelerate.aliyuncs.com`;
770
+ },
712
771
  bindCustomDomain,
713
772
  unbindCustomDomain,
714
773
  createCnameToken,
774
+ getBucketCnameEndpoint,
715
775
  };
716
776
  };
717
777
  exports.createOssOperations = createOssOperations;
@@ -92,7 +92,7 @@ const FC_EXECUTION_POLICY = JSON.stringify({
92
92
  },
93
93
  ],
94
94
  });
95
- const createRamOperations = (ramClient) => {
95
+ /* istanbul ignore next */ const createRamOperations = (ramClient) => {
96
96
  const attachRolePolicyForFc = async (roleName) => {
97
97
  const policyName = `${roleName}-policy`;
98
98
  // Create policy
@@ -7,11 +7,13 @@ exports.diffAttributes = exports.attributesEqual = exports.computeDirectoryHash
7
7
  const node_crypto_1 = __importDefault(require("node:crypto"));
8
8
  const node_fs_1 = __importDefault(require("node:fs"));
9
9
  const node_path_1 = __importDefault(require("node:path"));
10
+ /* istanbul ignore next */
10
11
  const computeFileHash = (filePath) => {
11
12
  const fileBuffer = node_fs_1.default.readFileSync(filePath);
12
13
  return node_crypto_1.default.createHash('sha256').update(fileBuffer).digest('hex');
13
14
  };
14
15
  exports.computeFileHash = computeFileHash;
16
+ /* istanbul ignore next */
15
17
  const computeDirectoryHash = (dirPath) => {
16
18
  const files = [];
17
19
  const collectFiles = (currentPath) => {
@@ -105,6 +107,7 @@ const deepEqual = (a, b) => {
105
107
  * @param b - Second attributes object
106
108
  * @returns True if objects are equal, false otherwise
107
109
  */
110
+ /* istanbul ignore next */
108
111
  const attributesEqual = (a, b) => {
109
112
  return deepEqual(a, b);
110
113
  };
@@ -116,6 +119,7 @@ exports.attributesEqual = attributesEqual;
116
119
  * @param after - New attributes
117
120
  * @returns Object with changed, added, and removed keys
118
121
  */
122
+ /* istanbul ignore next */
119
123
  const diffAttributes = (before, after) => {
120
124
  const changed = {};
121
125
  const added = {};