@geek-fun/serverlessinsight 0.9.0 → 0.9.2
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 +1 -1
- package/.serverlessinsight/state-iam-test-app-iam-test-service.json.backup +2 -2
- package/.serverlessinsight/state-insight-poc-app-insight-poc-tencent.json.backup +2 -2
- package/.serverlessinsight/state-insight-poc-app-log-insight-poc-tencent-log.json.backup +3 -3
- package/.serverlessinsight/state-insight-poc-deploy-app-insight-poc-deploy.json.backup +4 -4
- package/.serverlessinsight/state-insight-poc-destroy-app-insight-poc-destroy.json.backup +1 -1
- package/.serverlessinsight/state-insight-poc-timer-app-insight-poc-timer.json.backup +109 -0
- package/.serverlessinsight/state-insight-volc-app-insight-volc.json.backup +2 -2
- package/.serverlessinsight/state-insight-volc-nested-app-insight-volc-nested.json.backup +3 -3
- package/.serverlessinsight/state-nested-drift-app-nested-drift-service.json.backup +2 -2
- package/.serverlessinsight/state-role-reconcile-test-app-role-reconcile-test-service.json.backup +3 -3
- package/CHANGELOG.md +17 -0
- package/README.md +78 -2
- package/README.zh-CN.md +69 -2
- package/codecov +0 -0
- package/codecov.SHA256SUM +1 -0
- package/codecov.SHA256SUM.sig +16 -0
- package/dist/package.json +2 -2
- package/dist/src/commands/deploy.js +9 -3
- package/dist/src/commands/destroy.js +8 -2
- package/dist/src/commands/forceUnlock.js +5 -5
- package/dist/src/commands/index.js +173 -85
- package/dist/src/commands/login.js +12 -1
- package/dist/src/commands/migrate.js +287 -0
- package/dist/src/commands/plan.js +28 -2
- package/dist/src/commands/schema.js +24 -0
- package/dist/src/commands/show.js +99 -33
- package/dist/src/commands/validate.js +34 -2
- package/dist/src/common/aliyunClient/apigwOperations.js +4 -4
- package/dist/src/common/aliyunClient/ecsOperations.js +22 -13
- package/dist/src/common/aliyunClient/fc3Operations.js +39 -4
- package/dist/src/common/aliyunClient/nasOperations.js +4 -3
- package/dist/src/common/aliyunClient/ossOperations.js +52 -8
- package/dist/src/common/aliyunClient/slsOperations.js +3 -2
- package/dist/src/common/aliyunClient/tablestoreOperations.js +22 -11
- package/dist/src/common/apiClient.js +22 -5
- package/dist/src/common/constants.js +7 -1
- package/dist/src/common/context.js +5 -4
- package/dist/src/common/jsonOutput.js +77 -0
- package/dist/src/common/lockManager.js +1 -1
- package/dist/src/common/logger.js +6 -3
- package/dist/src/common/migrationMarker.js +34 -0
- package/dist/src/common/noColor.js +9 -0
- package/dist/src/common/planFormatter.js +12 -6
- package/dist/src/common/runtimeMapper.js +7 -3
- package/dist/src/common/siCron.js +415 -0
- package/dist/src/common/stateBackend/cosStateBackend.js +1 -1
- package/dist/src/common/stateBackend/index.js +5 -2
- package/dist/src/common/stateBackend/localStateBackend.js +8 -2
- package/dist/src/common/stateBackend/ossStateBackend.js +1 -1
- package/dist/src/common/stateBackend/remoteStateBackend.js +19 -2
- package/dist/src/common/stateBackend/saasStateBackend.js +88 -9
- package/dist/src/common/stateManager.js +56 -5
- package/dist/src/common/tencentClient/cosOperations.js +1 -1
- package/dist/src/common/tencentClient/scfOperations.js +4 -1
- package/dist/src/common/volcengineClient/apigwOperations.js +2 -2
- package/dist/src/common/volcengineClient/index.js +6 -2
- package/dist/src/common/volcengineClient/vefaasOperations.js +48 -3
- package/dist/src/lang/en.js +254 -1
- package/dist/src/lang/index.js +36 -1
- package/dist/src/lang/zh-CN.js +253 -1
- package/dist/src/parser/functionParser.js +47 -1
- package/dist/src/parser/index.js +1 -1
- package/dist/src/stack/aliyunStack/apigwExecutor.js +2 -2
- package/dist/src/stack/aliyunStack/apigwResource.js +22 -10
- package/dist/src/stack/aliyunStack/databaseExecutor.js +5 -5
- package/dist/src/stack/aliyunStack/databasePlanner.js +2 -2
- package/dist/src/stack/aliyunStack/databaseResource.js +18 -10
- package/dist/src/stack/aliyunStack/esServerlessTypes.js +2 -1
- package/dist/src/stack/aliyunStack/fc3Executor.js +2 -2
- package/dist/src/stack/aliyunStack/fc3Planner.js +26 -0
- package/dist/src/stack/aliyunStack/fc3Resource.js +190 -13
- package/dist/src/stack/aliyunStack/ossExecutor.js +2 -2
- package/dist/src/stack/aliyunStack/ossResource.js +5 -1
- package/dist/src/stack/aliyunStack/rdsTypes.js +5 -1
- package/dist/src/stack/aliyunStack/tablestoreExecutor.js +2 -2
- package/dist/src/stack/aliyunStack/tablestoreResource.js +3 -3
- package/dist/src/stack/aliyunStack/tablestoreTypes.js +3 -2
- package/dist/src/stack/deploy.js +2 -3
- package/dist/src/stack/localStack/event.js +2 -13
- package/dist/src/stack/localStack/function.js +2 -13
- package/dist/src/stack/localStack/functionRunner.js +5 -4
- package/dist/src/stack/localStack/index.js +8 -1
- package/dist/src/stack/localStack/timer.js +162 -0
- package/dist/src/stack/localStack/utils.js +19 -1
- package/dist/src/stack/scfStack/cosExecutor.js +2 -2
- package/dist/src/stack/scfStack/cosResource.js +2 -2
- package/dist/src/stack/scfStack/esServerlessExecutor.js +5 -5
- package/dist/src/stack/scfStack/esServerlessResource.js +7 -3
- package/dist/src/stack/scfStack/esServerlessTypes.js +2 -1
- package/dist/src/stack/scfStack/scfExecutor.js +2 -2
- package/dist/src/stack/scfStack/scfPlanner.js +52 -18
- package/dist/src/stack/scfStack/scfResource.js +202 -12
- package/dist/src/stack/scfStack/tdsqlcExecutor.js +5 -5
- package/dist/src/stack/scfStack/tdsqlcResource.js +7 -3
- package/dist/src/stack/volcengineStack/apigwExecutor.js +2 -2
- package/dist/src/stack/volcengineStack/apigwResource.js +7 -4
- package/dist/src/stack/volcengineStack/tosExecutor.js +2 -2
- package/dist/src/stack/volcengineStack/tosResource.js +1 -1
- package/dist/src/stack/volcengineStack/vefaasExecutor.js +2 -2
- package/dist/src/stack/volcengineStack/vefaasPlanner.js +49 -0
- package/dist/src/stack/volcengineStack/vefaasResource.js +221 -4
- package/dist/src/validator/functionSchema.js +25 -2
- package/dist/src/validator/iacSchema.js +2 -1
- package/dist/src/validator/index.js +4 -1
- package/dist/src/validator/rootSchema.js +77 -19
- package/dist/src/validator/schemaExport.js +60 -0
- package/dist/src/validator/semanticValidation.js +79 -0
- package/dist/src/validator/templateRefSchema.js +9 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/samples/aliyun-poc-timer.yml +39 -0
|
@@ -103,7 +103,7 @@ const createApigwOperations = (apigwClient, dnsClient, _context) => {
|
|
|
103
103
|
}
|
|
104
104
|
};
|
|
105
105
|
if (!shouldLoop) {
|
|
106
|
-
logger_1.logger.info('
|
|
106
|
+
logger_1.logger.info(lang_1.lang.__('APIGW_CHECKING_DNS_STATUS'));
|
|
107
107
|
return await checkPropagation();
|
|
108
108
|
}
|
|
109
109
|
logger_1.logger.info(lang_1.lang.__('APIGW_DNS_PROPAGATION_WAITING'));
|
|
@@ -371,7 +371,7 @@ const createApigwOperations = (apigwClient, dnsClient, _context) => {
|
|
|
371
371
|
});
|
|
372
372
|
const response = await apigwClient.createApiGroup(request);
|
|
373
373
|
if (!response.body?.groupId) {
|
|
374
|
-
throw new Error('
|
|
374
|
+
throw new Error(lang_1.lang.__('APIGW_GROUP_CREATE_NO_ID'));
|
|
375
375
|
}
|
|
376
376
|
return response.body.groupId;
|
|
377
377
|
},
|
|
@@ -609,7 +609,7 @@ const createApigwOperations = (apigwClient, dnsClient, _context) => {
|
|
|
609
609
|
});
|
|
610
610
|
const response = await apigwClient.createApi(request);
|
|
611
611
|
if (!response.body?.apiId) {
|
|
612
|
-
throw new Error('
|
|
612
|
+
throw new Error(lang_1.lang.__('APIGW_API_CREATE_NO_ID'));
|
|
613
613
|
}
|
|
614
614
|
return response.body.apiId;
|
|
615
615
|
},
|
|
@@ -976,7 +976,7 @@ const createApigwOperations = (apigwClient, dnsClient, _context) => {
|
|
|
976
976
|
const groupSubdomain = groupInfo.body?.subDomain;
|
|
977
977
|
const groupId = groupInfo.body?.groupId || config.groupId;
|
|
978
978
|
if (!groupSubdomain) {
|
|
979
|
-
throw new Error(
|
|
979
|
+
throw new Error(lang_1.lang.__('APIGW_GROUP_NO_SUBDOMAIN', { groupName: config.groupId }));
|
|
980
980
|
}
|
|
981
981
|
if (!skipDns) {
|
|
982
982
|
logger_1.logger.info(lang_1.lang.__('APIGW_ENSURING_CNAME', { domain: config.domainName }));
|
|
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.createEcsOperations = exports.parseSecurityGroupRule = exports.canonicalSecurityGroupRule = exports.securityGroupRangeMap = void 0;
|
|
37
37
|
const ecs = __importStar(require("@alicloud/ecs20140526"));
|
|
38
38
|
const logger_1 = require("../logger");
|
|
39
|
+
const lang_1 = require("../../lang");
|
|
39
40
|
exports.securityGroupRangeMap = {
|
|
40
41
|
TCP: '1/65535',
|
|
41
42
|
UDP: '1/65535',
|
|
@@ -61,13 +62,13 @@ exports.canonicalSecurityGroupRule = canonicalSecurityGroupRule;
|
|
|
61
62
|
/* istanbul ignore next */ const parseSecurityGroupRule = (rule) => {
|
|
62
63
|
const [rawProtocol, second, third, ...rest] = rule.split(':');
|
|
63
64
|
if (rest.length > 0 || !rawProtocol || !second || !third) {
|
|
64
|
-
throw new Error(
|
|
65
|
+
throw new Error(lang_1.lang.__('SG_INVALID_RULE_FORMAT', { rule }));
|
|
65
66
|
}
|
|
66
67
|
const protocol = normalizeProtocol(rawProtocol);
|
|
67
68
|
const secondTrimmed = second.trim();
|
|
68
69
|
const thirdTrimmed = third.trim();
|
|
69
70
|
if (!secondTrimmed || !thirdTrimmed) {
|
|
70
|
-
throw new Error(
|
|
71
|
+
throw new Error(lang_1.lang.__('SG_INVALID_RULE_FORMAT', { rule }));
|
|
71
72
|
}
|
|
72
73
|
return { protocol, cidr: secondTrimmed, portRange: thirdTrimmed };
|
|
73
74
|
};
|
|
@@ -98,7 +99,7 @@ const isDuplicateSecurityGroupRuleError = (error) => {
|
|
|
98
99
|
const response = await ecsClient.createSecurityGroup(createRequest);
|
|
99
100
|
const securityGroupId = response.body?.securityGroupId;
|
|
100
101
|
if (!securityGroupId) {
|
|
101
|
-
throw new Error('
|
|
102
|
+
throw new Error(lang_1.lang.__('SG_CREATE_FAILED'));
|
|
102
103
|
}
|
|
103
104
|
// Add ingress rules
|
|
104
105
|
for (const rule of ingressRules) {
|
|
@@ -107,7 +108,7 @@ const isDuplicateSecurityGroupRuleError = (error) => {
|
|
|
107
108
|
parsedRule = (0, exports.parseSecurityGroupRule)(rule);
|
|
108
109
|
}
|
|
109
110
|
catch (error) {
|
|
110
|
-
logger_1.logger.warn(
|
|
111
|
+
logger_1.logger.warn(lang_1.lang.__('SG_SKIP_INVALID_INGRESS', { rule, error: String(error) }));
|
|
111
112
|
continue;
|
|
112
113
|
}
|
|
113
114
|
const ingressRequest = new ecs.AuthorizeSecurityGroupRequest({
|
|
@@ -122,10 +123,10 @@ const isDuplicateSecurityGroupRuleError = (error) => {
|
|
|
122
123
|
}
|
|
123
124
|
catch (error) {
|
|
124
125
|
if (isDuplicateSecurityGroupRuleError(error)) {
|
|
125
|
-
logger_1.logger.debug(
|
|
126
|
+
logger_1.logger.debug(lang_1.lang.__('SG_INGRESS_ALREADY_EXISTS', { rule }));
|
|
126
127
|
continue;
|
|
127
128
|
}
|
|
128
|
-
logger_1.logger.warn(
|
|
129
|
+
logger_1.logger.warn(lang_1.lang.__('SG_ADD_INGRESS_FAILED', { rule, error: String(error) }));
|
|
129
130
|
}
|
|
130
131
|
}
|
|
131
132
|
// Add egress rules
|
|
@@ -135,7 +136,7 @@ const isDuplicateSecurityGroupRuleError = (error) => {
|
|
|
135
136
|
parsedRule = (0, exports.parseSecurityGroupRule)(rule);
|
|
136
137
|
}
|
|
137
138
|
catch (error) {
|
|
138
|
-
logger_1.logger.warn(
|
|
139
|
+
logger_1.logger.warn(lang_1.lang.__('SG_SKIP_INVALID_EGRESS', { rule, error: String(error) }));
|
|
139
140
|
continue;
|
|
140
141
|
}
|
|
141
142
|
const egressRequest = new ecs.AuthorizeSecurityGroupEgressRequest({
|
|
@@ -150,10 +151,10 @@ const isDuplicateSecurityGroupRuleError = (error) => {
|
|
|
150
151
|
}
|
|
151
152
|
catch (error) {
|
|
152
153
|
if (isDuplicateSecurityGroupRuleError(error)) {
|
|
153
|
-
logger_1.logger.debug(
|
|
154
|
+
logger_1.logger.debug(lang_1.lang.__('SG_EGRESS_ALREADY_EXISTS', { rule }));
|
|
154
155
|
continue;
|
|
155
156
|
}
|
|
156
|
-
logger_1.logger.warn(
|
|
157
|
+
logger_1.logger.warn(lang_1.lang.__('SG_ADD_EGRESS_FAILED', { rule, error: String(error) }));
|
|
157
158
|
}
|
|
158
159
|
}
|
|
159
160
|
const sg = await operations.getSecurityGroup(securityGroupId);
|
|
@@ -195,7 +196,11 @@ const isDuplicateSecurityGroupRuleError = (error) => {
|
|
|
195
196
|
if (isDuplicateSecurityGroupRuleError(error)) {
|
|
196
197
|
continue;
|
|
197
198
|
}
|
|
198
|
-
logger_1.logger.warn(
|
|
199
|
+
logger_1.logger.warn(lang_1.lang.__('SG_AUTHORIZE_RULE_FAILED', {
|
|
200
|
+
ruleType: direction,
|
|
201
|
+
target: securityGroupId,
|
|
202
|
+
error: String(error),
|
|
203
|
+
}));
|
|
199
204
|
}
|
|
200
205
|
}
|
|
201
206
|
},
|
|
@@ -224,7 +229,11 @@ const isDuplicateSecurityGroupRuleError = (error) => {
|
|
|
224
229
|
}
|
|
225
230
|
}
|
|
226
231
|
catch (error) {
|
|
227
|
-
logger_1.logger.warn(
|
|
232
|
+
logger_1.logger.warn(lang_1.lang.__('SG_REVOKE_RULE_FAILED', {
|
|
233
|
+
ruleType: direction,
|
|
234
|
+
target: securityGroupId,
|
|
235
|
+
error: String(error),
|
|
236
|
+
}));
|
|
228
237
|
}
|
|
229
238
|
}
|
|
230
239
|
},
|
|
@@ -254,7 +263,7 @@ const isDuplicateSecurityGroupRuleError = (error) => {
|
|
|
254
263
|
}
|
|
255
264
|
}
|
|
256
265
|
catch (error) {
|
|
257
|
-
logger_1.logger.debug(
|
|
266
|
+
logger_1.logger.debug(lang_1.lang.__('SG_GET_INGRESS_FAILED', { error: String(error) }));
|
|
258
267
|
}
|
|
259
268
|
try {
|
|
260
269
|
const request = new ecs.DescribeSecurityGroupAttributeRequest({
|
|
@@ -279,7 +288,7 @@ const isDuplicateSecurityGroupRuleError = (error) => {
|
|
|
279
288
|
}
|
|
280
289
|
}
|
|
281
290
|
catch (error) {
|
|
282
|
-
logger_1.logger.debug(
|
|
291
|
+
logger_1.logger.debug(lang_1.lang.__('SG_GET_EGRESS_FAILED', { error: String(error) }));
|
|
283
292
|
}
|
|
284
293
|
return { ingressRules, egressRules };
|
|
285
294
|
},
|
|
@@ -41,6 +41,7 @@ const fc = __importStar(require("@alicloud/fc20230330"));
|
|
|
41
41
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
42
42
|
const polling_1 = require("../polling");
|
|
43
43
|
const constants_1 = require("../constants");
|
|
44
|
+
const lang_1 = require("../../lang");
|
|
44
45
|
const buildCodeLocation = (codePath, ossCode) => {
|
|
45
46
|
if (ossCode) {
|
|
46
47
|
return new fc.InputCodeLocation({
|
|
@@ -66,7 +67,10 @@ const buildCodeLocation = (codePath, ossCode) => {
|
|
|
66
67
|
fetch: () => operations.getFunction(functionName),
|
|
67
68
|
isDone: (info) => {
|
|
68
69
|
if (info?.state === 'Failed') {
|
|
69
|
-
throw new Error(
|
|
70
|
+
throw new Error(lang_1.lang.__('FC3_FUNCTION_FAILED_STATE', {
|
|
71
|
+
functionName,
|
|
72
|
+
reason: info.stateReason ?? 'unknown',
|
|
73
|
+
}));
|
|
70
74
|
}
|
|
71
75
|
// Built-in runtimes (zip code) never reach Active (issue #219):
|
|
72
76
|
// they hold Pending while a create/update transition is in flight
|
|
@@ -83,7 +87,7 @@ const buildCodeLocation = (codePath, ossCode) => {
|
|
|
83
87
|
}
|
|
84
88
|
catch (e) {
|
|
85
89
|
if (e instanceof polling_1.PollingTimeoutError) {
|
|
86
|
-
throw new Error(
|
|
90
|
+
throw new Error(lang_1.lang.__('FC3_TIMEOUT_ACTIVE', { functionName }), {
|
|
87
91
|
cause: e,
|
|
88
92
|
});
|
|
89
93
|
}
|
|
@@ -102,7 +106,7 @@ const buildCodeLocation = (codePath, ossCode) => {
|
|
|
102
106
|
}
|
|
103
107
|
catch (e) {
|
|
104
108
|
if (e instanceof polling_1.PollingTimeoutError) {
|
|
105
|
-
throw new Error(
|
|
109
|
+
throw new Error(lang_1.lang.__('FC3_TIMEOUT_DELETED', { functionName }), {
|
|
106
110
|
cause: e,
|
|
107
111
|
});
|
|
108
112
|
}
|
|
@@ -490,18 +494,49 @@ const buildCodeLocation = (codePath, ossCode) => {
|
|
|
490
494
|
// a subsequent create (retry) does not collide with a still-deleting function.
|
|
491
495
|
await operations.waitForFunctionDeleted(functionName);
|
|
492
496
|
},
|
|
493
|
-
createTrigger: async (functionName, triggerName, triggerType, triggerConfig, qualifier) => {
|
|
497
|
+
createTrigger: async (functionName, triggerName, triggerType, triggerConfig, qualifier, description) => {
|
|
494
498
|
const createTriggerInput = new fc.CreateTriggerInput({
|
|
495
499
|
triggerName,
|
|
496
500
|
triggerType,
|
|
497
501
|
triggerConfig: JSON.stringify(triggerConfig),
|
|
498
502
|
...(qualifier ? { qualifier } : {}),
|
|
503
|
+
...(description ? { description } : {}),
|
|
499
504
|
});
|
|
500
505
|
const request = new fc.CreateTriggerRequest({
|
|
501
506
|
body: createTriggerInput,
|
|
502
507
|
});
|
|
503
508
|
await fc3Client.createTrigger(functionName, request);
|
|
504
509
|
},
|
|
510
|
+
listTriggers: async (functionName) => {
|
|
511
|
+
// follow nextToken — a partial page would make the trigger reconcile
|
|
512
|
+
// treat every page-2 trigger as stale and delete it
|
|
513
|
+
const triggers = [];
|
|
514
|
+
let nextToken;
|
|
515
|
+
do {
|
|
516
|
+
const response = await fc3Client.listTriggers(functionName, new fc.ListTriggersRequest(nextToken ? { nextToken } : {}));
|
|
517
|
+
const body = (response.body ?? {});
|
|
518
|
+
triggers.push(...(body.triggers ?? []));
|
|
519
|
+
nextToken = body.nextToken;
|
|
520
|
+
} while (nextToken);
|
|
521
|
+
// the SDK models triggerConfig as a JSON string — normalize to an object
|
|
522
|
+
const parseConfig = (raw) => {
|
|
523
|
+
if (typeof raw !== 'string') {
|
|
524
|
+
return raw;
|
|
525
|
+
}
|
|
526
|
+
try {
|
|
527
|
+
return JSON.parse(raw);
|
|
528
|
+
}
|
|
529
|
+
catch {
|
|
530
|
+
return raw;
|
|
531
|
+
}
|
|
532
|
+
};
|
|
533
|
+
return triggers.map((trigger) => ({
|
|
534
|
+
triggerName: trigger.triggerName,
|
|
535
|
+
triggerType: trigger.triggerType,
|
|
536
|
+
triggerConfig: parseConfig(trigger.triggerConfig),
|
|
537
|
+
description: trigger.description,
|
|
538
|
+
}));
|
|
539
|
+
},
|
|
505
540
|
deleteTrigger: async (functionName, triggerName) => {
|
|
506
541
|
await fc3Client.deleteTrigger(functionName, triggerName);
|
|
507
542
|
},
|
|
@@ -37,6 +37,7 @@ exports.createNasOperations = void 0;
|
|
|
37
37
|
const logger_1 = require("../logger");
|
|
38
38
|
const nas = __importStar(require("@alicloud/nas20170626"));
|
|
39
39
|
const types_1 = require("../../types");
|
|
40
|
+
const lang_1 = require("../../lang");
|
|
40
41
|
const storageClassMap = {
|
|
41
42
|
[types_1.NasStorageClassEnum.STANDARD_CAPACITY]: { fileSystemType: 'standard', storageType: 'Capacity' },
|
|
42
43
|
[types_1.NasStorageClassEnum.STANDARD_PERFORMANCE]: {
|
|
@@ -117,7 +118,7 @@ const createNasOperations = (nasClient) => {
|
|
|
117
118
|
const response = await nasClient.createFileSystem(request);
|
|
118
119
|
const fileSystemId = response.body?.fileSystemId;
|
|
119
120
|
if (!fileSystemId) {
|
|
120
|
-
throw new Error('
|
|
121
|
+
throw new Error(lang_1.lang.__('NAS_CREATE_FS_FAILED'));
|
|
121
122
|
}
|
|
122
123
|
// Wait for file system to be ready
|
|
123
124
|
let retries = 0;
|
|
@@ -185,7 +186,7 @@ const createNasOperations = (nasClient) => {
|
|
|
185
186
|
const response = await nasClient.createMountTarget(request);
|
|
186
187
|
const mountTargetDomain = response.body?.mountTargetDomain;
|
|
187
188
|
if (!mountTargetDomain) {
|
|
188
|
-
throw new Error('
|
|
189
|
+
throw new Error(lang_1.lang.__('NAS_CREATE_MOUNT_TARGET_FAILED'));
|
|
189
190
|
}
|
|
190
191
|
// Wait for mount target to be ready
|
|
191
192
|
let retries = 0;
|
|
@@ -221,7 +222,7 @@ const createNasOperations = (nasClient) => {
|
|
|
221
222
|
}));
|
|
222
223
|
}
|
|
223
224
|
catch (error) {
|
|
224
|
-
logger_1.logger.debug(
|
|
225
|
+
logger_1.logger.debug(lang_1.lang.__('NAS_LIST_MOUNT_TARGETS_FAILED', { error: String(error) }));
|
|
225
226
|
return [];
|
|
226
227
|
}
|
|
227
228
|
},
|
|
@@ -126,6 +126,41 @@ const parseReplicationRules = (xml) => {
|
|
|
126
126
|
expireTime: parsed.expireTime || '',
|
|
127
127
|
};
|
|
128
128
|
};
|
|
129
|
+
// ListCname (GET /?cname) → the CNAME entries bound to THIS bucket with their
|
|
130
|
+
// certificate info. Used to verify desired state after a 409 CnameAlreadyExists,
|
|
131
|
+
// since that error only means "bound elsewhere or image-processing domain"
|
|
132
|
+
// per the PutCname docs — it never guarantees the bind landed on this bucket.
|
|
133
|
+
const listBucketCnames = async (bucketName) => {
|
|
134
|
+
useBucket(bucketName);
|
|
135
|
+
const response = await ossRequest(ossClient, {
|
|
136
|
+
method: 'GET',
|
|
137
|
+
bucket: bucketName,
|
|
138
|
+
subres: { cname: '' },
|
|
139
|
+
successStatuses: [200],
|
|
140
|
+
});
|
|
141
|
+
const xml = response.data || '';
|
|
142
|
+
const entries = [];
|
|
143
|
+
const cnameRegex = /<Cname>([\s\S]*?)<\/Cname>/g;
|
|
144
|
+
let match;
|
|
145
|
+
while ((match = cnameRegex.exec(xml)) !== null) {
|
|
146
|
+
const cnameXml = match[1];
|
|
147
|
+
const read = (tag) => {
|
|
148
|
+
const m = new RegExp(`<${tag}>([\\s\\S]*?)<\\/${tag}>`).exec(cnameXml);
|
|
149
|
+
return m ? m[1].trim() : undefined;
|
|
150
|
+
};
|
|
151
|
+
const hasCertificate = /<Certificate>[\s\S]*?<\/Certificate>/.test(cnameXml);
|
|
152
|
+
entries.push({
|
|
153
|
+
domain: read('Domain') ?? '',
|
|
154
|
+
status: read('Status') ?? '',
|
|
155
|
+
certBound: hasCertificate,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
return entries;
|
|
159
|
+
};
|
|
160
|
+
const verifyCnameBoundToBucket = async (bucketName, domain) => {
|
|
161
|
+
const entries = await listBucketCnames(bucketName);
|
|
162
|
+
return entries.some((entry) => entry.domain === domain && (entry.status === 'Enabled' || entry.status === ''));
|
|
163
|
+
};
|
|
129
164
|
const putBucketCname = async (bucketName, domain, certificate) => {
|
|
130
165
|
useBucket(bucketName);
|
|
131
166
|
const certXml = buildCertificateXml(certificate);
|
|
@@ -149,24 +184,33 @@ const parseReplicationRules = (xml) => {
|
|
|
149
184
|
};
|
|
150
185
|
await ossClient.request(params);
|
|
151
186
|
logger_1.logger.info(lang_1.lang.__('OSS_BUCKET_CNAME_BOUND', { domain }));
|
|
152
|
-
return { success: true, needVerification: false };
|
|
187
|
+
return { success: true, needVerification: false, certBound: Boolean(certificate) };
|
|
153
188
|
}
|
|
154
189
|
catch (error) {
|
|
155
190
|
const err = error;
|
|
156
191
|
if (err.code === 'CnameAlreadyExists' || err.status === 409) {
|
|
157
|
-
|
|
158
|
-
|
|
192
|
+
// Per the PutCname docs, 409 CnameAlreadyExists fires when the domain is
|
|
193
|
+
// bound to ANOTHER bucket (or is an image-processing domain) — a rebind
|
|
194
|
+
// to the same bucket is idempotent 200. So never trust the 409 alone:
|
|
195
|
+
// cross-check via ListCname whether the domain is actually bound here.
|
|
196
|
+
const boundToThisBucket = await verifyCnameBoundToBucket(bucketName, domain);
|
|
197
|
+
if (boundToThisBucket) {
|
|
198
|
+
logger_1.logger.info(lang_1.lang.__('OSS_BUCKET_CNAME_EXISTS', { domain }));
|
|
199
|
+
return { success: true, needVerification: false, certBound: false };
|
|
200
|
+
}
|
|
201
|
+
// eslint-disable-next-line preserve-caught-error
|
|
202
|
+
throw new Error(lang_1.lang.__('OSS_BUCKET_CNAME_CONFLICT', { domain, bucketName, error: String(error) }));
|
|
159
203
|
}
|
|
160
204
|
if (err.code === 'NeedVerifyDomainOwnership') {
|
|
161
205
|
logger_1.logger.warn(lang_1.lang.__('OSS_BUCKET_CNAME_NEED_VERIFY', { domain }));
|
|
162
|
-
return { success: false, needVerification: true };
|
|
206
|
+
return { success: false, needVerification: true, certBound: false };
|
|
163
207
|
}
|
|
164
208
|
if (certificate) {
|
|
165
209
|
// eslint-disable-next-line preserve-caught-error
|
|
166
210
|
throw new Error(lang_1.lang.__('OSS_BUCKET_CNAME_BIND_FAILED', { error: String(error) }));
|
|
167
211
|
}
|
|
168
212
|
logger_1.logger.warn(lang_1.lang.__('OSS_BUCKET_CNAME_BIND_FAILED', { error: String(error) }));
|
|
169
|
-
return { success: false, needVerification: false };
|
|
213
|
+
return { success: false, needVerification: false, certBound: false };
|
|
170
214
|
}
|
|
171
215
|
};
|
|
172
216
|
const deleteBucketCname = async (bucketName, domain) => {
|
|
@@ -276,7 +320,7 @@ const parseReplicationRules = (xml) => {
|
|
|
276
320
|
txtRecordId = verificationResult.txtRecordId;
|
|
277
321
|
}
|
|
278
322
|
const bucketCnameBound = cnameResult.success;
|
|
279
|
-
if (certificate &&
|
|
323
|
+
if (certificate && cnameResult.certBound) {
|
|
280
324
|
logger_1.logger.info(lang_1.lang.__('OSS_BUCKET_CERT_BOUND', { domain: normalizedDomain }));
|
|
281
325
|
}
|
|
282
326
|
await addCorsRuleForDomain(bucketName, normalizedDomain);
|
|
@@ -429,7 +473,7 @@ const parseReplicationRules = (xml) => {
|
|
|
429
473
|
domain,
|
|
430
474
|
txtRecord: `${fullTxtRecord}.${(0, domainUtils_1.extractMainDomain)(domain)}`,
|
|
431
475
|
}));
|
|
432
|
-
return { success: false, needVerification: true };
|
|
476
|
+
return { success: false, needVerification: true, certBound: false };
|
|
433
477
|
};
|
|
434
478
|
const createOrFindDnsCnameRecord = async (domain, mainDomain, hostRecord, ossEndpoint, bucketCnameBound) => {
|
|
435
479
|
try {
|
|
@@ -456,7 +500,7 @@ const parseReplicationRules = (xml) => {
|
|
|
456
500
|
}
|
|
457
501
|
catch (error) {
|
|
458
502
|
logger_1.logger.warn(lang_1.lang.__('OSS_DNS_DOMAIN_NOT_MANAGED', { domain, cname: ossEndpoint }));
|
|
459
|
-
logger_1.logger.debug(
|
|
503
|
+
logger_1.logger.debug(lang_1.lang.__('DNS_OPERATION_ERROR', { error: String(error) }));
|
|
460
504
|
return { domain, cname: ossEndpoint, bucketCnameBound };
|
|
461
505
|
}
|
|
462
506
|
};
|
|
@@ -37,6 +37,7 @@ exports.createSlsOperations = exports.SLS_LOGSTORE_SHARDS = exports.SLS_LOGSTORE
|
|
|
37
37
|
const sls = __importStar(require("@alicloud/sls20201230"));
|
|
38
38
|
const logger_1 = require("../logger");
|
|
39
39
|
const polling_1 = require("../polling");
|
|
40
|
+
const lang_1 = require("../../lang");
|
|
40
41
|
// The logstore attributes si creates with (issue #234 M1): `fn.log` is a
|
|
41
42
|
// boolean — these are stack constants, so live values differing from them are
|
|
42
43
|
// out-of-band drift.
|
|
@@ -60,7 +61,7 @@ const waitForSlsProject = async (getProject, projectName) => {
|
|
|
60
61
|
maxAttempts: 30,
|
|
61
62
|
onProgress: (project) => {
|
|
62
63
|
if (project) {
|
|
63
|
-
logger_1.logger.info(
|
|
64
|
+
logger_1.logger.info(lang_1.lang.__('SLS_WAITING_PROJECT', { projectName, status: project.status ?? 'unknown' }));
|
|
64
65
|
}
|
|
65
66
|
},
|
|
66
67
|
});
|
|
@@ -91,7 +92,7 @@ const waitForSlsLogstore = async (getLogstore, projectName, logstoreName, ttl) =
|
|
|
91
92
|
maxAttempts: 30,
|
|
92
93
|
onProgress: (logstore) => {
|
|
93
94
|
if (logstore) {
|
|
94
|
-
logger_1.logger.info(
|
|
95
|
+
logger_1.logger.info(lang_1.lang.__('SLS_WAITING_LOGSTORE', { projectName, logstoreName }));
|
|
95
96
|
}
|
|
96
97
|
},
|
|
97
98
|
});
|
|
@@ -7,6 +7,7 @@ exports.createTablestoreOperations = exports.TableStoreInstanceStatus = void 0;
|
|
|
7
7
|
const tablestore_1 = __importDefault(require("tablestore"));
|
|
8
8
|
const logger_1 = require("../logger");
|
|
9
9
|
const polling_1 = require("../polling");
|
|
10
|
+
const lang_1 = require("../../lang");
|
|
10
11
|
var TableStoreInstanceStatus;
|
|
11
12
|
(function (TableStoreInstanceStatus) {
|
|
12
13
|
TableStoreInstanceStatus["RUNNING"] = "RUNNING";
|
|
@@ -24,15 +25,19 @@ const waitForTableReady = async (describeTable, tableName) => {
|
|
|
24
25
|
maxAttempts: 60,
|
|
25
26
|
onProgress: (table, attempt, maxAttempts) => {
|
|
26
27
|
if (!table) {
|
|
27
|
-
logger_1.logger.info(
|
|
28
|
+
logger_1.logger.info(lang_1.lang.__('OTS_WAITING_TABLE', {
|
|
29
|
+
tableName,
|
|
30
|
+
attempt: String(attempt),
|
|
31
|
+
maxAttempts: String(maxAttempts),
|
|
32
|
+
}));
|
|
28
33
|
}
|
|
29
34
|
},
|
|
30
35
|
});
|
|
31
|
-
logger_1.logger.info(
|
|
36
|
+
logger_1.logger.info(lang_1.lang.__('OTS_TABLE_READY', { tableName }));
|
|
32
37
|
}
|
|
33
38
|
catch (e) {
|
|
34
39
|
if (e instanceof polling_1.PollingTimeoutError) {
|
|
35
|
-
throw new Error(
|
|
40
|
+
throw new Error(lang_1.lang.__('OTS_TABLE_TIMEOUT', { tableName }), { cause: e });
|
|
36
41
|
}
|
|
37
42
|
throw e;
|
|
38
43
|
}
|
|
@@ -69,11 +74,14 @@ const createTablestoreOperations = (endpoint, instanceName, context) => {
|
|
|
69
74
|
return new Promise((resolve, reject) => {
|
|
70
75
|
client.createTable(params, (err) => {
|
|
71
76
|
if (err) {
|
|
72
|
-
logger_1.logger.error(
|
|
77
|
+
logger_1.logger.error(lang_1.lang.__('OTS_CREATE_TABLE_FAILED', {
|
|
78
|
+
tableName: config.tableName,
|
|
79
|
+
error: err.message,
|
|
80
|
+
}));
|
|
73
81
|
reject(err);
|
|
74
82
|
}
|
|
75
83
|
else {
|
|
76
|
-
logger_1.logger.info(
|
|
84
|
+
logger_1.logger.info(lang_1.lang.__('OTS_TABLE_CREATED', { tableName: config.tableName }));
|
|
77
85
|
resolve();
|
|
78
86
|
}
|
|
79
87
|
});
|
|
@@ -92,7 +100,7 @@ const createTablestoreOperations = (endpoint, instanceName, context) => {
|
|
|
92
100
|
resolve(null);
|
|
93
101
|
}
|
|
94
102
|
else {
|
|
95
|
-
logger_1.logger.error(
|
|
103
|
+
logger_1.logger.error(lang_1.lang.__('OTS_DESCRIBE_TABLE_FAILED', { tableName, error: errorMessage }));
|
|
96
104
|
reject(err);
|
|
97
105
|
}
|
|
98
106
|
}
|
|
@@ -133,11 +141,14 @@ const createTablestoreOperations = (endpoint, instanceName, context) => {
|
|
|
133
141
|
return new Promise((resolve, reject) => {
|
|
134
142
|
client.updateTable(params, (err) => {
|
|
135
143
|
if (err) {
|
|
136
|
-
logger_1.logger.error(
|
|
144
|
+
logger_1.logger.error(lang_1.lang.__('OTS_UPDATE_TABLE_FAILED', {
|
|
145
|
+
tableName: config.tableName,
|
|
146
|
+
error: err.message,
|
|
147
|
+
}));
|
|
137
148
|
reject(err);
|
|
138
149
|
}
|
|
139
150
|
else {
|
|
140
|
-
logger_1.logger.info(
|
|
151
|
+
logger_1.logger.info(lang_1.lang.__('OTS_TABLE_UPDATED', { tableName: config.tableName }));
|
|
141
152
|
resolve();
|
|
142
153
|
}
|
|
143
154
|
});
|
|
@@ -154,16 +165,16 @@ const createTablestoreOperations = (endpoint, instanceName, context) => {
|
|
|
154
165
|
// If table doesn't exist, consider deletion successful
|
|
155
166
|
if (errorMessage.includes('OTSObjectNotExist') ||
|
|
156
167
|
errorMessage.includes('does not exist')) {
|
|
157
|
-
logger_1.logger.info(
|
|
168
|
+
logger_1.logger.info(lang_1.lang.__('OTS_TABLE_ALREADY_DELETED', { tableName }));
|
|
158
169
|
resolve();
|
|
159
170
|
}
|
|
160
171
|
else {
|
|
161
|
-
logger_1.logger.error(
|
|
172
|
+
logger_1.logger.error(lang_1.lang.__('OTS_DELETE_TABLE_FAILED', { tableName, error: errorMessage }));
|
|
162
173
|
reject(err);
|
|
163
174
|
}
|
|
164
175
|
}
|
|
165
176
|
else {
|
|
166
|
-
logger_1.logger.info(
|
|
177
|
+
logger_1.logger.info(lang_1.lang.__('OTS_TABLE_DELETED', { tableName }));
|
|
167
178
|
resolve();
|
|
168
179
|
}
|
|
169
180
|
});
|
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateApiKey = exports.createApiClient = void 0;
|
|
3
|
+
exports.validateApiKey = exports.createApiClient = exports.ApiError = void 0;
|
|
4
4
|
const lang_1 = require("../lang");
|
|
5
|
+
/**
|
|
6
|
+
* API error carrying the HTTP status so callers can distinguish "not found"
|
|
7
|
+
* (legitimate empty state on first deploy) from network/5xx failures, which
|
|
8
|
+
* must never be mistaken for an empty state.
|
|
9
|
+
*/
|
|
10
|
+
class ApiError extends Error {
|
|
11
|
+
status;
|
|
12
|
+
constructor(message, status) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = 'ApiError';
|
|
15
|
+
this.status = status;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.ApiError = ApiError;
|
|
5
19
|
// Opaque JSONB payloads from the Console API — their internal keys must NOT be case-converted
|
|
6
20
|
const SKIP_CASE_CONVERT = new Set([
|
|
7
21
|
'spec',
|
|
@@ -29,13 +43,15 @@ const camelizeKeys = (value) => {
|
|
|
29
43
|
const handleHttpError = (response) => {
|
|
30
44
|
const status = response.status;
|
|
31
45
|
if (status === 401)
|
|
32
|
-
throw new
|
|
46
|
+
throw new ApiError(lang_1.lang.__('API_ERROR_401'), 401);
|
|
33
47
|
if (status === 403)
|
|
34
|
-
throw new
|
|
48
|
+
throw new ApiError(lang_1.lang.__('API_ERROR_403'), 403);
|
|
49
|
+
if (status === 404)
|
|
50
|
+
throw new ApiError(lang_1.lang.__('API_ERROR_404'), 404);
|
|
35
51
|
if (status === 409) {
|
|
36
|
-
throw new
|
|
52
|
+
throw new ApiError(lang_1.lang.__('API_ERROR_409', { message: `HTTP Error ${status}` }), 409);
|
|
37
53
|
}
|
|
38
|
-
throw new
|
|
54
|
+
throw new ApiError(lang_1.lang.__('API_ERROR_UNKNOWN', { status: String(status), message: `HTTP Error ${status}` }), status);
|
|
39
55
|
};
|
|
40
56
|
const buildRequestInit = (method, headers, body) => ({
|
|
41
57
|
method: method.toUpperCase(),
|
|
@@ -95,6 +111,7 @@ const validateApiKey = async (apiKey, baseUrl) => {
|
|
|
95
111
|
return {
|
|
96
112
|
orgId: result.orgId ?? '',
|
|
97
113
|
orgName: result.orgName ?? '',
|
|
114
|
+
orgSlug: result.orgSlug,
|
|
98
115
|
userEmail: result.userEmail ?? result.user?.email ?? '',
|
|
99
116
|
scopes: result.scopes ?? [],
|
|
100
117
|
};
|
|
@@ -5,7 +5,13 @@ exports.CODE_ZIP_SIZE_LIMIT = 300 * 1000; // 300 KB - code package size limit fo
|
|
|
5
5
|
exports.OSS_DEPLOYMENT_TIMEOUT = 3000; // in seconds
|
|
6
6
|
exports.SI_BOOTSTRAP_FC_PREFIX = 'si-bootstrap-api';
|
|
7
7
|
exports.SI_BOOTSTRAP_BUCKET_PREFIX = 'si-bootstrap-artifacts';
|
|
8
|
-
|
|
8
|
+
// Local dev server port. Under jest, each worker shifts its base port so
|
|
9
|
+
// parallel test files binding the server never collide on one fixed port
|
|
10
|
+
// (pre-existing flake: localServer/index/aliyunFc suites all bind 4567).
|
|
11
|
+
const SI_LOCALSTACK_TEST_WORKER_PORT = process.env.JEST_WORKER_ID && Number.isInteger(Number(process.env.JEST_WORKER_ID))
|
|
12
|
+
? 4570 + Number(process.env.JEST_WORKER_ID)
|
|
13
|
+
: undefined;
|
|
14
|
+
exports.SI_LOCALSTACK_SERVER_PORT = Number(process.env.SI_LOCALSTACK_SERVER_PORT) || SI_LOCALSTACK_TEST_WORKER_PORT || 4567;
|
|
9
15
|
exports.ALIYUN_FC3_CONNECT_TIMEOUT_MS = 120000;
|
|
10
16
|
exports.ALIYUN_FC3_READ_TIMEOUT_MS = 600000;
|
|
11
17
|
// Query-tier budget for synchronous management-plane RPCs (all non-fc3 aliyun
|
|
@@ -10,6 +10,7 @@ const credentials_1 = require("./credentials");
|
|
|
10
10
|
const imsClient_1 = require("./imsClient");
|
|
11
11
|
const providerEnum_1 = require("./providerEnum");
|
|
12
12
|
const refreshCache_1 = require("./refreshCache");
|
|
13
|
+
const lang_1 = require("../lang");
|
|
13
14
|
let context;
|
|
14
15
|
const DEFAULT_IAC_FILES = [
|
|
15
16
|
'serverlessinsight.yml',
|
|
@@ -50,7 +51,7 @@ const getIacLocation = (location) => {
|
|
|
50
51
|
const attemptedList = Array.from(attempted)
|
|
51
52
|
.map((n) => `'${n}'`)
|
|
52
53
|
.join(', ');
|
|
53
|
-
throw new Error(
|
|
54
|
+
throw new Error(lang_1.lang.__('CONTEXT_NO_IAC_FILE', { attemptedList }));
|
|
54
55
|
};
|
|
55
56
|
exports.getIacLocation = getIacLocation;
|
|
56
57
|
const setContext = async (config, reaValToken = false) => {
|
|
@@ -60,7 +61,7 @@ const setContext = async (config, reaValToken = false) => {
|
|
|
60
61
|
process.env.ALIYUN_REGION ??
|
|
61
62
|
'cn-hangzhou';
|
|
62
63
|
if (process.env.ROS_REGION_ID && !process.env.SI_REGION) {
|
|
63
|
-
console.warn(
|
|
64
|
+
console.warn(lang_1.lang.__('CONTEXT_REGION_DEPRECATED'));
|
|
64
65
|
}
|
|
65
66
|
const provider = (config.provider ??
|
|
66
67
|
config.iacProvider?.name ??
|
|
@@ -97,14 +98,14 @@ const setContext = async (config, reaValToken = false) => {
|
|
|
97
98
|
exports.setContext = setContext;
|
|
98
99
|
const getContext = () => {
|
|
99
100
|
if (!context) {
|
|
100
|
-
throw new Error('
|
|
101
|
+
throw new Error(lang_1.lang.__('CONTEXT_NOT_FOUND'));
|
|
101
102
|
}
|
|
102
103
|
return context;
|
|
103
104
|
};
|
|
104
105
|
exports.getContext = getContext;
|
|
105
106
|
const setIac = (iac) => {
|
|
106
107
|
if (!context) {
|
|
107
|
-
throw new Error('
|
|
108
|
+
throw new Error(lang_1.lang.__('CONTEXT_IAC_REQUIRES_CONTEXT'));
|
|
108
109
|
}
|
|
109
110
|
context.iac = iac;
|
|
110
111
|
};
|