@geek-fun/serverlessinsight 0.7.0 → 0.7.4
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/CHANGELOG.md +26 -0
- package/README.md +58 -1
- package/README.zh-CN.md +3 -1
- package/dist/package.json +37 -35
- package/dist/src/commands/index.js +1 -3
- package/dist/src/commands/local.js +1 -2
- package/dist/src/common/aliyunClient/apigwOperations.js +9 -4
- package/dist/src/common/aliyunClient/cdnOperations.js +191 -0
- package/dist/src/common/aliyunClient/ecsOperations.js +2 -2
- package/dist/src/common/aliyunClient/fc3Operations.js +1 -1
- package/dist/src/common/aliyunClient/index.js +8 -0
- package/dist/src/common/aliyunClient/ossOperations.js +62 -2
- package/dist/src/common/aliyunClient/ramOperations.js +1 -1
- package/dist/src/common/hashUtils.js +4 -0
- package/dist/src/common/iacHelper.js +5 -0
- package/dist/src/common/lockManager.js +8 -0
- package/dist/src/common/planFormatter.js +4 -0
- package/dist/src/common/retryUtils.js +1 -1
- package/dist/src/common/stateManager.js +10 -0
- package/dist/src/common/volcengineClient/apigwOperations.js +1 -1
- package/dist/src/lang/en.js +16 -1
- package/dist/src/lang/zh-CN.js +17 -2
- package/dist/src/parser/bucketParser.js +111 -46
- package/dist/src/stack/aliyunStack/apigwResource.js +310 -47
- package/dist/src/stack/aliyunStack/apigwTypes.js +61 -1
- package/dist/src/stack/aliyunStack/ossResource.js +401 -69
- package/dist/src/stack/aliyunStack/ossTypes.js +58 -16
- package/dist/src/stack/localStack/event.js +1 -1
- package/dist/src/stack/localStack/functionRunner.js +4 -1
- package/dist/src/stack/scfStack/cosTypes.js +3 -6
- package/dist/src/stack/volcengineStack/tosTypes.js +1 -3
- package/dist/src/types/domains/state.js +3 -0
- package/dist/src/validator/bucketSchema.js +124 -56
- package/dist/src/validator/eventSchema.js +20 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +37 -35
- package/samples/README_TENCENT_COS.md +3 -15
- package/samples/aliyun-poc-bucket-cdn.yml +63 -0
- package/samples/aliyun-poc-bucket.yml +0 -2
- package/samples/aliyun-poc-domain.yml +0 -2
- package/samples/tencent-poc-cos.yml +0 -2
- package/samples/volcengine-poc-bucket.yml +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.7.2] - 2026-06-26
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Remove misleading `-p`/`--port` flag from `si local` command. The local stack
|
|
13
|
+
is a single unified HTTP server that multiplexes across all simulated cloud
|
|
14
|
+
services (API Gateway, functions, buckets) — a single port flag creates false
|
|
15
|
+
expectations about which service's port is being controlled.
|
|
16
|
+
|
|
17
|
+
## [0.7.1] - 2026-06-26
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
21
|
+
- Always set errorDocument=indexDocument and enable SupportSubDir for OSS
|
|
22
|
+
static websites (#196) (#197)
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- CDN integration with OSS and API Gateway CDN support (#195)
|
package/README.md
CHANGED
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
10
10
|
[](https://codecov.io/gh/geek-fun/serverlessinsight)
|
|
11
11
|
|
|
12
|
-
**
|
|
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
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
10
10
|
[](https://codecov.io/gh/geek-fun/serverlessinsight)
|
|
11
11
|
|
|
12
|
-
|
|
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.
|
|
3
|
+
"version": "0.7.4",
|
|
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.
|
|
57
|
-
"@alicloud/cas20200407": "^3.2.
|
|
58
|
-
"@alicloud/
|
|
59
|
-
"@alicloud/
|
|
60
|
-
"@alicloud/
|
|
61
|
-
"@alicloud/
|
|
62
|
-
"@alicloud/
|
|
63
|
-
"@alicloud/
|
|
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.6",
|
|
61
|
+
"@alicloud/es-serverless20230627": "^2.3.1",
|
|
62
|
+
"@alicloud/fc20230330": "^4.7.7",
|
|
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.
|
|
66
|
-
"@alicloud/rds20140815": "^15.
|
|
67
|
-
"@alicloud/sls20201230": "^5.
|
|
68
|
-
"@volcengine/openapi": "^1.36.
|
|
69
|
-
"@volcengine/tos-sdk": "^2.
|
|
70
|
-
"ajv": "^8.
|
|
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": "^
|
|
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.
|
|
78
|
+
"lodash": "^4.18.1",
|
|
78
79
|
"pino": "^10.3.1",
|
|
79
80
|
"pino-pretty": "^13.1.3",
|
|
80
|
-
"tablestore": "^5.6.
|
|
81
|
-
"tencentcloud-sdk-nodejs-cynosdb": "^4.1.
|
|
82
|
-
"tencentcloud-sdk-nodejs-dnspod": "^4.1.
|
|
83
|
-
"tencentcloud-sdk-nodejs-es": "^4.1.
|
|
81
|
+
"tablestore": "^5.6.5",
|
|
82
|
+
"tencentcloud-sdk-nodejs-cynosdb": "^4.1.257",
|
|
83
|
+
"tencentcloud-sdk-nodejs-dnspod": "^4.1.257",
|
|
84
|
+
"tencentcloud-sdk-nodejs-es": "^4.1.257",
|
|
84
85
|
"tencentcloud-sdk-nodejs-scf": "^4.1.168",
|
|
85
|
-
"tencentcloud-sdk-nodejs-ssl": "^4.1.
|
|
86
|
-
"yaml": "^2.
|
|
86
|
+
"tencentcloud-sdk-nodejs-ssl": "^4.1.239",
|
|
87
|
+
"yaml": "^2.9.0"
|
|
87
88
|
},
|
|
88
89
|
"devDependencies": {
|
|
89
|
-
"@eslint/eslintrc": "^3.3.
|
|
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": "^
|
|
96
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
97
|
-
"@typescript-eslint/parser": "^8.
|
|
96
|
+
"@types/node": "^26.0.1",
|
|
97
|
+
"@typescript-eslint/eslint-plugin": "^8.62.0",
|
|
98
|
+
"@typescript-eslint/parser": "^8.62.0",
|
|
98
99
|
"cross-env": "^10.1.0",
|
|
99
|
-
"eslint": "^10.0
|
|
100
|
+
"eslint": "^10.6.0",
|
|
100
101
|
"eslint-config-prettier": "^10.1.8",
|
|
101
|
-
"eslint-plugin-prettier": "^5.5.
|
|
102
|
-
"globals": "^17.
|
|
102
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
103
|
+
"globals": "^17.7.0",
|
|
103
104
|
"husky": "^9.1.7",
|
|
104
|
-
"jest": "^30.2
|
|
105
|
-
"prettier": "^3.8.
|
|
106
|
-
"ts-jest": "^29.4.
|
|
105
|
+
"jest": "^30.4.2",
|
|
106
|
+
"prettier": "^3.8.5",
|
|
107
|
+
"ts-jest": "^29.4.11",
|
|
107
108
|
"ts-node": "^10.9.2",
|
|
108
|
-
"typescript": "^
|
|
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
|
}
|
|
@@ -162,13 +162,11 @@ program
|
|
|
162
162
|
.description('run Serverless application locally for debugging')
|
|
163
163
|
.option('-f, --file <path>', 'specify the yaml file')
|
|
164
164
|
.option('-s, --stage <stage>', 'specify the stage', 'default')
|
|
165
|
-
.option('-p, --port <port>', 'specify the port', '3000')
|
|
166
165
|
.option('-d, --debug', 'enable debug mode')
|
|
167
166
|
.option('-w, --watch', 'enable file watch', true)
|
|
168
|
-
.action(actionWrapper('local', async ({ stage,
|
|
167
|
+
.action(actionWrapper('local', async ({ stage, debug, watch, file }) => {
|
|
169
168
|
await (0, local_1.runLocal)({
|
|
170
169
|
stage,
|
|
171
|
-
port: Number(port) || 3000,
|
|
172
170
|
debug: !!debug,
|
|
173
171
|
watch: typeof watch === 'boolean' ? watch : true,
|
|
174
172
|
location: file,
|
|
@@ -6,7 +6,7 @@ const localStack_1 = require("../stack/localStack");
|
|
|
6
6
|
const parser_1 = require("../parser");
|
|
7
7
|
const lang_1 = require("../lang");
|
|
8
8
|
const runLocal = async (opts) => {
|
|
9
|
-
const { stage,
|
|
9
|
+
const { stage, debug, watch, location } = opts;
|
|
10
10
|
const iacLocation = (0, common_1.getIacLocation)(location);
|
|
11
11
|
const rawIac = (0, parser_1.parseYaml)(iacLocation);
|
|
12
12
|
await (0, common_1.setContext)({ stage, app: rawIac.app, service: rawIac.service, location });
|
|
@@ -16,7 +16,6 @@ const runLocal = async (opts) => {
|
|
|
16
16
|
(0, common_1.setIac)(iac);
|
|
17
17
|
common_1.logger.info(lang_1.lang.__('RUN_LOCAL_STARTING', {
|
|
18
18
|
stage,
|
|
19
|
-
port: String(port),
|
|
20
19
|
debug: String(debug),
|
|
21
20
|
watch: String(watch),
|
|
22
21
|
}));
|
|
@@ -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
|
-
|
|
673
|
-
|
|
674
|
-
|
|
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
|
};
|