@geek-fun/serverlessinsight 0.8.2 → 0.8.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.
- package/.serverlessinsight/state-cdn-flow-app-cdn-flow-service.json.backup +14 -0
- package/.serverlessinsight/state-iam-test-app-iam-test-service.json.backup +14 -0
- package/.serverlessinsight/state-insight-poc-deploy-app-insight-poc-deploy.json.backup +348 -0
- package/.serverlessinsight/state-insight-poc-destroy-app-insight-poc-destroy.json.backup +14 -0
- package/.serverlessinsight/state-insight-volc-app-insight-volc.json.backup +114 -0
- package/.serverlessinsight/state-insight-volc-destroy-app-insight-volc-destroy.json.backup +1 -0
- package/README.md +26 -18
- package/README.zh-CN.md +19 -6
- package/dist/package.json +3 -1
- package/dist/src/commands/deploy.js +87 -4
- package/dist/src/commands/destroy.js +61 -10
- package/dist/src/commands/forceUnlock.js +8 -0
- package/dist/src/commands/index.js +34 -2
- package/dist/src/commands/login.js +195 -0
- package/dist/src/commands/logout.js +17 -0
- package/dist/src/commands/show.js +15 -7
- package/dist/src/commands/whoami.js +20 -0
- package/dist/src/common/aliyunClient/apigwOperations.js +327 -30
- package/dist/src/common/aliyunClient/esOperations.js +43 -29
- package/dist/src/common/aliyunClient/fc3Operations.js +481 -207
- package/dist/src/common/aliyunClient/ossOperations.js +165 -13
- package/dist/src/common/aliyunClient/rdsOperations.js +143 -39
- package/dist/src/common/aliyunClient/slsOperations.js +56 -26
- package/dist/src/common/aliyunClient/tablestoreOperations.js +25 -22
- package/dist/src/common/apiClient.js +102 -0
- package/dist/src/common/constants.js +9 -4
- package/dist/src/common/credentialStore.js +94 -0
- package/dist/src/common/credentials.js +2 -0
- package/dist/src/common/eventQueue.js +208 -0
- package/dist/src/common/hashUtils.js +87 -11
- package/dist/src/common/imsClient.js +1 -0
- package/dist/src/common/index.js +3 -0
- package/dist/src/common/lockManager.js +61 -54
- package/dist/src/common/logger.js +2 -0
- package/dist/src/common/polling.js +54 -0
- package/dist/src/common/reportResourceEvent.js +8 -0
- package/dist/src/common/runtimeMapper.js +11 -12
- package/dist/src/common/stateBackend/index.js +10 -1
- package/dist/src/common/stateBackend/localStateBackend.js +4 -1
- package/dist/src/common/stateBackend/remoteStateBackend.js +6 -3
- package/dist/src/common/stateBackend/saasStateBackend.js +266 -0
- package/dist/src/common/stateManager.js +135 -13
- package/dist/src/common/tencentClient/cosOperations.js +180 -3
- package/dist/src/common/tencentClient/esOperations.js +110 -46
- package/dist/src/common/tencentClient/index.js +22 -1
- package/dist/src/common/tencentClient/scfOperations.js +255 -133
- package/dist/src/common/tencentClient/tdsqlcClusterMapper.js +81 -0
- package/dist/src/common/tencentClient/tdsqlcOperations.js +93 -99
- package/dist/src/common/triggerMapper.js +36 -0
- package/dist/src/common/volcengineClient/apigwOperations.js +539 -159
- package/dist/src/common/volcengineClient/iamOperations.js +58 -48
- package/dist/src/common/volcengineClient/index.js +46 -21
- package/dist/src/common/volcengineClient/stsOperations.js +32 -0
- package/dist/src/common/volcengineClient/tlsOperations.js +229 -178
- package/dist/src/common/volcengineClient/tosOperations.js +78 -19
- package/dist/src/common/volcengineClient/vefaasOperations.js +272 -54
- package/dist/src/lang/en.js +84 -0
- package/dist/src/lang/zh-CN.js +84 -0
- package/dist/src/parser/eventParser.js +2 -0
- package/dist/src/parser/functionParser.js +96 -65
- package/dist/src/parser/index.js +7 -4
- package/dist/src/stack/aliyunStack/apigwExecutor.js +39 -1
- package/dist/src/stack/aliyunStack/apigwPlanner.js +14 -10
- package/dist/src/stack/aliyunStack/apigwResource.js +216 -124
- package/dist/src/stack/aliyunStack/apigwTypes.js +16 -3
- package/dist/src/stack/aliyunStack/databaseExecutor.js +39 -1
- package/dist/src/stack/aliyunStack/databasePlanner.js +13 -1
- package/dist/src/stack/aliyunStack/databaseResource.js +135 -40
- package/dist/src/stack/aliyunStack/deployer.js +2 -2
- package/dist/src/stack/aliyunStack/destroyer.js +2 -2
- package/dist/src/stack/aliyunStack/fc3Executor.js +25 -2
- package/dist/src/stack/aliyunStack/fc3Planner.js +11 -1
- package/dist/src/stack/aliyunStack/fc3Resource.js +327 -64
- package/dist/src/stack/aliyunStack/ossExecutor.js +39 -1
- package/dist/src/stack/aliyunStack/ossPlanner.js +15 -1
- package/dist/src/stack/aliyunStack/ossResource.js +267 -219
- package/dist/src/stack/aliyunStack/tablestoreExecutor.js +39 -1
- package/dist/src/stack/aliyunStack/tablestorePlanner.js +13 -1
- package/dist/src/stack/aliyunStack/tablestoreResource.js +54 -20
- package/dist/src/stack/alreadyExists.js +26 -0
- package/dist/src/stack/ownershipTag.js +40 -0
- package/dist/src/stack/rfsStack/index.js +3 -1
- package/dist/src/stack/scfStack/cosExecutor.js +39 -1
- package/dist/src/stack/scfStack/cosPlanner.js +11 -1
- package/dist/src/stack/scfStack/cosResource.js +167 -64
- package/dist/src/stack/scfStack/deployer.js +2 -2
- package/dist/src/stack/scfStack/destroyer.js +2 -2
- package/dist/src/stack/scfStack/esServerlessExecutor.js +39 -1
- package/dist/src/stack/scfStack/esServerlessPlanner.js +11 -1
- package/dist/src/stack/scfStack/esServerlessResource.js +88 -23
- package/dist/src/stack/scfStack/scfExecutor.js +39 -1
- package/dist/src/stack/scfStack/scfPlanner.js +12 -2
- package/dist/src/stack/scfStack/scfResource.js +484 -14
- package/dist/src/stack/scfStack/tdsqlcExecutor.js +39 -1
- package/dist/src/stack/scfStack/tdsqlcPlanner.js +12 -1
- package/dist/src/stack/scfStack/tdsqlcResource.js +95 -16
- package/dist/src/stack/scfStack/tdsqlcTypes.js +5 -1
- package/dist/src/stack/volcengineStack/apigwExecutor.js +39 -1
- package/dist/src/stack/volcengineStack/apigwPlanner.js +25 -53
- package/dist/src/stack/volcengineStack/apigwResource.js +418 -222
- package/dist/src/stack/volcengineStack/apigwTypes.js +76 -66
- package/dist/src/stack/volcengineStack/deployer.js +49 -14
- package/dist/src/stack/volcengineStack/destroyer.js +1 -1
- package/dist/src/stack/volcengineStack/index.js +1 -2
- package/dist/src/stack/volcengineStack/tosExecutor.js +25 -2
- package/dist/src/stack/volcengineStack/tosPlanner.js +11 -1
- package/dist/src/stack/volcengineStack/tosResource.js +82 -27
- package/dist/src/stack/volcengineStack/tosTypes.js +12 -0
- package/dist/src/stack/volcengineStack/vefaasExecutor.js +25 -2
- package/dist/src/stack/volcengineStack/vefaasPlanner.js +71 -2
- package/dist/src/stack/volcengineStack/vefaasResource.js +148 -98
- package/dist/src/stack/volcengineStack/vefaasTypes.js +1 -3
- package/dist/src/types/domains/backend.js +1 -0
- package/dist/src/types/domains/state.js +29 -1
- package/dist/src/validator/eventSchema.js +10 -0
- package/dist/src/validator/functionSchema.js +37 -12
- package/dist/src/validator/iacSchema.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -1
|
@@ -2,52 +2,72 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createTdsqlcOperations = void 0;
|
|
4
4
|
const types_1 = require("./types");
|
|
5
|
+
const tdsqlcClusterMapper_1 = require("./tdsqlcClusterMapper");
|
|
5
6
|
const logger_1 = require("../logger");
|
|
6
7
|
const lang_1 = require("../../lang");
|
|
8
|
+
const polling_1 = require("../polling");
|
|
7
9
|
// TDSQL-C helper functions
|
|
8
10
|
const waitForClusterReady = async (getCluster, clusterId) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
11
|
+
try {
|
|
12
|
+
await (0, polling_1.pollUntil)({
|
|
13
|
+
description: `TDSQL-C cluster ${clusterId} to be ready`,
|
|
14
|
+
fetch: async () => {
|
|
15
|
+
const cluster = await getCluster(clusterId);
|
|
16
|
+
if (!cluster) {
|
|
17
|
+
throw new Error(lang_1.lang.__('TDSQL_CLUSTER_NOT_FOUND', { clusterId }));
|
|
18
|
+
}
|
|
19
|
+
if (cluster.Status === types_1.TdsqlcClusterStatus.ISOLATED ||
|
|
20
|
+
cluster.Status === types_1.TdsqlcClusterStatus.OFFLINE) {
|
|
21
|
+
throw new Error(lang_1.lang.__('TDSQL_CLUSTER_ERROR_STATE', { status: cluster.Status }));
|
|
22
|
+
}
|
|
23
|
+
return cluster;
|
|
24
|
+
},
|
|
25
|
+
isDone: (cluster) => cluster?.Status === types_1.TdsqlcClusterStatus.RUNNING,
|
|
26
|
+
intervalMs: 10000,
|
|
27
|
+
maxAttempts: 60,
|
|
28
|
+
onProgress: (cluster) => {
|
|
29
|
+
if (cluster) {
|
|
30
|
+
logger_1.logger.info(lang_1.lang.__('TDSQL_CLUSTER_WAITING', { clusterId, status: cluster.Status }));
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
logger_1.logger.info(lang_1.lang.__('TDSQL_CLUSTER_READY', { clusterId }));
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
if (e instanceof polling_1.PollingTimeoutError) {
|
|
38
|
+
throw new Error(lang_1.lang.__('TDSQL_CLUSTER_TIMEOUT_READY', { clusterId }), { cause: e });
|
|
23
39
|
}
|
|
24
|
-
|
|
25
|
-
await new Promise((resolve) => setTimeout(resolve, 10000));
|
|
26
|
-
attempts++;
|
|
40
|
+
throw e;
|
|
27
41
|
}
|
|
28
|
-
throw new Error(lang_1.lang.__('TDSQL_CLUSTER_TIMEOUT_READY', { clusterId }));
|
|
29
42
|
};
|
|
30
43
|
const waitForClusterDeleted = async (getCluster, clusterId) => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
try {
|
|
45
|
+
await (0, polling_1.pollUntil)({
|
|
46
|
+
description: `TDSQL-C cluster ${clusterId} to be deleted`,
|
|
47
|
+
fetch: () => getCluster(clusterId),
|
|
48
|
+
isDone: (cluster) => cluster === null,
|
|
49
|
+
intervalMs: 10000,
|
|
50
|
+
maxAttempts: 60,
|
|
51
|
+
onProgress: (cluster) => {
|
|
52
|
+
if (cluster) {
|
|
53
|
+
if (cluster.Status === types_1.TdsqlcClusterStatus.ISOLATED ||
|
|
54
|
+
cluster.Status === types_1.TdsqlcClusterStatus.OFFLINE) {
|
|
55
|
+
logger_1.logger.info(lang_1.lang.__('TDSQL_CLUSTER_BEING_DELETED', { clusterId }));
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
logger_1.logger.info(lang_1.lang.__('TDSQL_CLUSTER_WAITING_DELETE', { clusterId, status: cluster.Status }));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
logger_1.logger.info(lang_1.lang.__('TDSQL_CLUSTER_DELETED', { clusterId }));
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
if (e instanceof polling_1.PollingTimeoutError) {
|
|
67
|
+
throw new Error(lang_1.lang.__('TDSQL_CLUSTER_TIMEOUT_DELETE', { clusterId }), { cause: e });
|
|
45
68
|
}
|
|
46
|
-
|
|
47
|
-
await new Promise((resolve) => setTimeout(resolve, 10000));
|
|
48
|
-
attempts++;
|
|
69
|
+
throw e;
|
|
49
70
|
}
|
|
50
|
-
throw new Error(lang_1.lang.__('TDSQL_CLUSTER_TIMEOUT_DELETE', { clusterId }));
|
|
51
71
|
};
|
|
52
72
|
// TDSQL-C operations
|
|
53
73
|
const createTdsqlcOperations = (cynosdbClient, context) => {
|
|
@@ -71,6 +91,7 @@ const createTdsqlcOperations = (cynosdbClient, context) => {
|
|
|
71
91
|
AutoPauseDelay: config.AutoPauseDelay,
|
|
72
92
|
StoragePayMode: config.StoragePayMode,
|
|
73
93
|
StorageLimit: config.MaxStorageSize,
|
|
94
|
+
...(config.ResourceTags ? { ResourceTags: config.ResourceTags } : {}),
|
|
74
95
|
};
|
|
75
96
|
try {
|
|
76
97
|
const response = await cynosdbClient.CreateClusters(params);
|
|
@@ -103,73 +124,46 @@ const createTdsqlcOperations = (cynosdbClient, context) => {
|
|
|
103
124
|
if (!response.ClusterSet || response.ClusterSet.length === 0) {
|
|
104
125
|
return null;
|
|
105
126
|
}
|
|
106
|
-
|
|
107
|
-
return {
|
|
108
|
-
ClusterId: cluster.ClusterId || '',
|
|
109
|
-
ClusterName: cluster.ClusterName || '',
|
|
110
|
-
Region: cluster.Region || context.region,
|
|
111
|
-
Zone: cluster.Zone,
|
|
112
|
-
PhysicalZone: cluster.PhysicalZone,
|
|
113
|
-
DbType: cluster.DbType || '',
|
|
114
|
-
DbVersion: cluster.DbVersion || '',
|
|
115
|
-
DbMode: cluster.DbMode,
|
|
116
|
-
Status: cluster.Status || '',
|
|
117
|
-
StatusDesc: cluster.StatusDesc,
|
|
118
|
-
ServerlessStatus: cluster.ServerlessStatus,
|
|
119
|
-
VpcId: cluster.VpcId,
|
|
120
|
-
VpcName: undefined,
|
|
121
|
-
SubnetId: cluster.SubnetId,
|
|
122
|
-
SubnetName: undefined,
|
|
123
|
-
Charset: undefined,
|
|
124
|
-
Vip: cluster.Vip,
|
|
125
|
-
Vport: cluster.Vport,
|
|
126
|
-
WanDomain: undefined,
|
|
127
|
-
WanIP: undefined,
|
|
128
|
-
WanPort: undefined,
|
|
129
|
-
WanStatus: undefined,
|
|
130
|
-
MinCpu: undefined,
|
|
131
|
-
MaxCpu: undefined,
|
|
132
|
-
MinStorageSize: cluster.MinStorageSize,
|
|
133
|
-
MaxStorageSize: cluster.MaxStorageSize,
|
|
134
|
-
StorageId: cluster.StorageId,
|
|
135
|
-
Storage: cluster.Storage,
|
|
136
|
-
StorageLimit: cluster.StorageLimit,
|
|
137
|
-
StoragePayMode: cluster.StoragePayMode,
|
|
138
|
-
AutoPause: cluster.ServerlessStatus,
|
|
139
|
-
AutoPauseDelay: undefined,
|
|
140
|
-
CreateTime: cluster.CreateTime,
|
|
141
|
-
UpdateTime: cluster.UpdateTime,
|
|
142
|
-
ProjectId: cluster.ProjectID,
|
|
143
|
-
PayMode: cluster.PayMode,
|
|
144
|
-
PeriodEndTime: cluster.PeriodEndTime,
|
|
145
|
-
AutoRenewFlag: cluster.RenewFlag,
|
|
146
|
-
InstanceCount: cluster.InstanceNum,
|
|
147
|
-
ProcessingTask: cluster.ProcessingTask,
|
|
148
|
-
SupportedFeatures: undefined,
|
|
149
|
-
RollbackSupport: undefined,
|
|
150
|
-
NetworkType: undefined,
|
|
151
|
-
ResourcePackageId: undefined,
|
|
152
|
-
ResourcePackageType: undefined,
|
|
153
|
-
ResourcePackageState: undefined,
|
|
154
|
-
PhysicalRegion: undefined,
|
|
155
|
-
ProxyStatus: undefined,
|
|
156
|
-
RwGroupId: undefined,
|
|
157
|
-
MasterZone: cluster.MasterZone,
|
|
158
|
-
SlaveZones: cluster.SlaveZones,
|
|
159
|
-
BusinessType: cluster.BusinessType,
|
|
160
|
-
IsFreeze: cluster.IsFreeze,
|
|
161
|
-
OrderSource: cluster.OrderSource,
|
|
162
|
-
Ability: cluster.Ability,
|
|
163
|
-
ResourceTags: cluster.ResourceTags,
|
|
164
|
-
CynosVersion: cluster.CynosVersion,
|
|
165
|
-
CynosVersionStatus: undefined,
|
|
166
|
-
IsLatestVersion: undefined,
|
|
167
|
-
};
|
|
127
|
+
return (0, tdsqlcClusterMapper_1.mapClusterToInfo)(response.ClusterSet[0], context.region);
|
|
168
128
|
}
|
|
169
129
|
catch (error) {
|
|
170
|
-
|
|
130
|
+
if (error &&
|
|
131
|
+
typeof error === 'object' &&
|
|
132
|
+
'code' in error &&
|
|
133
|
+
typeof error.code === 'string' &&
|
|
134
|
+
error.code.startsWith('ResourceNotFound')) {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
// DescribeClusters filters only support ClusterId/InstanceId/InstanceName
|
|
141
|
+
// (SDK QueryFilter docs), so a name probe lists clusters and matches by
|
|
142
|
+
// ClusterName client-side. Pages up to 500 clusters (5 requests).
|
|
143
|
+
getClusterByName: async (clusterName) => {
|
|
144
|
+
try {
|
|
145
|
+
for (let offset = 0; offset < 500; offset += 100) {
|
|
146
|
+
const response = await cynosdbClient.DescribeClusters({ Limit: 100, Offset: offset });
|
|
147
|
+
const cluster = (response.ClusterSet ?? []).find((c) => c.ClusterName === clusterName);
|
|
148
|
+
if (cluster) {
|
|
149
|
+
return (0, tdsqlcClusterMapper_1.mapClusterToInfo)(cluster, context.region);
|
|
150
|
+
}
|
|
151
|
+
if (!response.ClusterSet || response.ClusterSet.length < 100) {
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
171
155
|
return null;
|
|
172
156
|
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
if (error &&
|
|
159
|
+
typeof error === 'object' &&
|
|
160
|
+
'code' in error &&
|
|
161
|
+
typeof error.code === 'string' &&
|
|
162
|
+
error.code.startsWith('ResourceNotFound')) {
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
throw error;
|
|
166
|
+
}
|
|
173
167
|
},
|
|
174
168
|
updateCluster: async (clusterId, config) => {
|
|
175
169
|
const params = {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapAliyunAccess = exports.mapAccess = exports.mapAuthType = void 0;
|
|
4
|
+
const providerEnum_1 = require("./providerEnum");
|
|
5
|
+
const mapAuthType = (provider, authType) => {
|
|
6
|
+
switch (provider) {
|
|
7
|
+
case providerEnum_1.ProviderEnum.TENCENT:
|
|
8
|
+
return authType === 'public' ? 'NONE' : 'CAM';
|
|
9
|
+
case providerEnum_1.ProviderEnum.ALIYUN:
|
|
10
|
+
return authType === 'public' ? 'anonymous' : 'function';
|
|
11
|
+
case providerEnum_1.ProviderEnum.AWS:
|
|
12
|
+
return authType === 'public' ? 'NONE' : 'AWS_IAM';
|
|
13
|
+
default:
|
|
14
|
+
return authType === 'public' ? 'NONE' : 'CAM';
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
exports.mapAuthType = mapAuthType;
|
|
18
|
+
const mapAccess = (access) => {
|
|
19
|
+
if (!access || access.length === 0) {
|
|
20
|
+
return {};
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
enableExtranet: access.includes('public'),
|
|
24
|
+
enableIntranet: access.includes('internal'),
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
exports.mapAccess = mapAccess;
|
|
28
|
+
const mapAliyunAccess = (access) => {
|
|
29
|
+
if (!access || access.length === 0) {
|
|
30
|
+
return {};
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
disableURLInternet: !access.includes('public') && access.includes('internal'),
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
exports.mapAliyunAccess = mapAliyunAccess;
|