@geek-fun/serverlessinsight 0.9.2 → 0.9.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/.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 +4 -8
- package/.serverlessinsight/state-insight-poc-app-log-insight-poc-tencent-log.json.backup +3 -8
- 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 +28 -5
- 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 +20 -5
- package/.serverlessinsight/state-role-reconcile-test-app-role-reconcile-test-service.json.backup +3 -3
- package/AGENTS.md +10 -0
- package/CHANGELOG.md +62 -0
- package/README.md +256 -175
- package/README.zh-CN.md +249 -159
- package/dist/package.json +22 -19
- package/dist/src/commands/index.js +21 -52
- package/dist/src/commands/local.js +16 -3
- package/dist/src/commands/plan.js +35 -4
- package/dist/src/common/aliyunClient/apigwOperations.js +48 -9
- package/dist/src/common/aliyunClient/fc3Operations.js +7 -1
- package/dist/src/common/aliyunClient/ossOperations.js +214 -221
- package/dist/src/common/bucketPolicy.js +63 -0
- package/dist/src/common/domainUtils.js +4 -1
- package/dist/src/common/functionDefinition.js +25 -0
- package/dist/src/common/index.js +4 -0
- package/dist/src/common/jsonOutput.js +6 -1
- package/dist/src/common/nameBuilder.js +3 -1
- package/dist/src/common/planCapabilities.js +119 -0
- package/dist/src/common/planCompare.js +119 -66
- package/dist/src/common/planFormatter.js +22 -14
- package/dist/src/common/planRedaction.js +26 -0
- package/dist/src/common/refreshPlanner.js +66 -21
- package/dist/src/common/tencentClient/cosOperations.js +326 -322
- package/dist/src/common/tencentClient/scfOperations.js +9 -2
- package/dist/src/common/tencentClient/tdsqlcOperations.js +6 -11
- package/dist/src/common/triggerMapper.js +16 -1
- package/dist/src/common/volcengineClient/apigwOperations.js +82 -0
- package/dist/src/common/volcengineClient/iamOperations.js +27 -3
- package/dist/src/common/volcengineClient/tosOperations.js +62 -56
- package/dist/src/lang/en.js +33 -8
- package/dist/src/lang/index.js +28 -14
- package/dist/src/lang/zh-CN.js +33 -8
- package/dist/src/parser/eventParser.js +1 -0
- package/dist/src/parser/functionParser.js +1 -1
- package/dist/src/stack/aliyunStack/apigwDomainPlan.js +82 -0
- package/dist/src/stack/aliyunStack/apigwExecutor.js +4 -1
- package/dist/src/stack/aliyunStack/apigwPlanner.js +165 -25
- package/dist/src/stack/aliyunStack/apigwResource.js +172 -126
- package/dist/src/stack/aliyunStack/apigwTypes.js +3 -7
- package/dist/src/stack/aliyunStack/deployer.js +2 -0
- package/dist/src/stack/aliyunStack/esServerlessTypes.js +8 -4
- package/dist/src/stack/aliyunStack/fc3Executor.js +7 -3
- package/dist/src/stack/aliyunStack/fc3Planner.js +124 -155
- package/dist/src/stack/aliyunStack/fc3Resource.js +48 -52
- package/dist/src/stack/aliyunStack/fc3Types.js +30 -16
- package/dist/src/stack/aliyunStack/ossPlanner.js +15 -1
- package/dist/src/stack/aliyunStack/ossResource.js +113 -102
- package/dist/src/stack/aliyunStack/ossTypes.js +20 -20
- package/dist/src/stack/localStack/aliyunFc.js +1 -6
- package/dist/src/stack/localStack/event.js +31 -60
- package/dist/src/stack/localStack/function.js +24 -65
- package/dist/src/stack/localStack/functionRunner.js +10 -2
- package/dist/src/stack/localStack/httpAdapter.js +54 -0
- package/dist/src/stack/localStack/httpError.js +5 -0
- package/dist/src/stack/localStack/legacyLambda.js +26 -0
- package/dist/src/stack/localStack/localContext.js +29 -0
- package/dist/src/stack/localStack/localRoute.js +12 -0
- package/dist/src/stack/localStack/localRuntimes.js +22 -0
- package/dist/src/stack/localStack/localServer.js +8 -3
- package/dist/src/stack/localStack/requestBody.js +24 -0
- package/dist/src/stack/localStack/requestId.js +18 -0
- package/dist/src/stack/localStack/tencent.js +147 -0
- package/dist/src/stack/localStack/timer.js +23 -2
- package/dist/src/stack/localStack/volcengine.js +68 -0
- package/dist/src/stack/scfStack/cosPlanner.js +9 -14
- package/dist/src/stack/scfStack/cosResource.js +42 -50
- package/dist/src/stack/scfStack/cosTypes.js +19 -14
- package/dist/src/stack/scfStack/deployer.js +2 -0
- package/dist/src/stack/scfStack/scfExecutor.js +7 -3
- package/dist/src/stack/scfStack/scfHttpTrigger.js +106 -0
- package/dist/src/stack/scfStack/scfPlanner.js +67 -16
- package/dist/src/stack/scfStack/scfResource.js +170 -321
- package/dist/src/stack/scfStack/scfTypes.js +4 -3
- package/dist/src/stack/scfStack/tdsqlcPlanner.js +10 -13
- package/dist/src/stack/volcengineStack/apigwDomains.js +64 -0
- package/dist/src/stack/volcengineStack/apigwPlanner.js +71 -15
- package/dist/src/stack/volcengineStack/apigwResource.js +60 -24
- package/dist/src/stack/volcengineStack/apigwTypes.js +5 -1
- package/dist/src/stack/volcengineStack/deployer.js +6 -0
- package/dist/src/stack/volcengineStack/tosPlanner.js +8 -13
- package/dist/src/stack/volcengineStack/tosResource.js +22 -35
- package/dist/src/stack/volcengineStack/tosTypes.js +5 -8
- package/dist/src/stack/volcengineStack/vefaasPlanner.js +142 -49
- package/dist/src/stack/volcengineStack/vefaasResource.js +17 -12
- package/dist/src/stack/volcengineStack/vefaasTypes.js +6 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +22 -19
- package/release-notes.md +53 -0
- package/samples/README_TENCENT_COS.md +3 -3
- package/samples/README_TENCENT_SCF.md +3 -3
- package/samples/tencent-local/index.js +13 -0
- package/samples/tencent-local/serverlessinsight.yml +23 -0
- package/samples/volcengine-local/index.js +13 -0
- package/samples/volcengine-local/serverlessinsight.yml +28 -0
|
@@ -205,7 +205,7 @@ const createScfOperations = (scfClient, deps) => {
|
|
|
205
205
|
await scfClient.UpdateFunctionCode(params);
|
|
206
206
|
},
|
|
207
207
|
createTrigger: async (params) => {
|
|
208
|
-
await scfClient.CreateTrigger({
|
|
208
|
+
const response = await scfClient.CreateTrigger({
|
|
209
209
|
FunctionName: params.FunctionName,
|
|
210
210
|
TriggerName: params.TriggerName,
|
|
211
211
|
Type: params.Type,
|
|
@@ -215,6 +215,7 @@ const createScfOperations = (scfClient, deps) => {
|
|
|
215
215
|
...(params.CustomArgument !== undefined ? { CustomArgument: params.CustomArgument } : {}),
|
|
216
216
|
...(params.Description ? { Description: params.Description } : {}),
|
|
217
217
|
});
|
|
218
|
+
return response?.TriggerInfo;
|
|
218
219
|
},
|
|
219
220
|
deleteTrigger: async (params) => {
|
|
220
221
|
await scfClient.DeleteTrigger({
|
|
@@ -262,7 +263,13 @@ const createScfOperations = (scfClient, deps) => {
|
|
|
262
263
|
}
|
|
263
264
|
},
|
|
264
265
|
deleteCustomDomain: async (domain) => {
|
|
265
|
-
|
|
266
|
+
try {
|
|
267
|
+
await scfClient.DeleteCustomDomain({ Domain: domain });
|
|
268
|
+
}
|
|
269
|
+
catch (error) {
|
|
270
|
+
if (error?.code !== 'ResourceNotFound')
|
|
271
|
+
throw error;
|
|
272
|
+
}
|
|
266
273
|
},
|
|
267
274
|
deleteFunction: async (functionName) => {
|
|
268
275
|
const params = {
|
|
@@ -173,19 +173,14 @@ const createTdsqlcOperations = (cynosdbClient, context) => {
|
|
|
173
173
|
if (typeof sdk.DescribeServerlessStrategy !== 'function') {
|
|
174
174
|
return null;
|
|
175
175
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (!response) {
|
|
179
|
-
return null;
|
|
180
|
-
}
|
|
181
|
-
return {
|
|
182
|
-
autoPause: response.AutoPause === undefined ? undefined : response.AutoPause === 'yes',
|
|
183
|
-
autoPauseDelay: response.AutoPauseDelay,
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
catch {
|
|
176
|
+
const response = await sdk.DescribeServerlessStrategy({ ClusterId: clusterId });
|
|
177
|
+
if (!response) {
|
|
187
178
|
return null;
|
|
188
179
|
}
|
|
180
|
+
return {
|
|
181
|
+
autoPause: response.AutoPause === undefined ? undefined : response.AutoPause === 'yes',
|
|
182
|
+
autoPauseDelay: response.AutoPauseDelay,
|
|
183
|
+
};
|
|
189
184
|
},
|
|
190
185
|
updateCluster: async (clusterId, config) => {
|
|
191
186
|
const params = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mapAliyunAccess = exports.mapAccess = exports.mapAuthType = void 0;
|
|
3
|
+
exports.buildTencentHttpTriggerDesc = exports.buildAliyunHttpTriggerConfig = exports.mapAliyunAccess = exports.mapAccess = exports.mapAuthType = void 0;
|
|
4
4
|
const providerEnum_1 = require("./providerEnum");
|
|
5
5
|
const mapAuthType = (provider, authType) => {
|
|
6
6
|
switch (provider) {
|
|
@@ -34,3 +34,18 @@ const mapAliyunAccess = (access) => {
|
|
|
34
34
|
};
|
|
35
35
|
};
|
|
36
36
|
exports.mapAliyunAccess = mapAliyunAccess;
|
|
37
|
+
/** Exact FC3 HTTP trigger write shape, also used for live comparison. */
|
|
38
|
+
const buildAliyunHttpTriggerConfig = (trigger) => ({
|
|
39
|
+
authType: (0, exports.mapAuthType)(providerEnum_1.ProviderEnum.ALIYUN, trigger.auth_type),
|
|
40
|
+
methods: ['GET', 'POST', 'PUT', 'DELETE', 'HEAD', 'PATCH'],
|
|
41
|
+
...(0, exports.mapAliyunAccess)(trigger.access),
|
|
42
|
+
});
|
|
43
|
+
exports.buildAliyunHttpTriggerConfig = buildAliyunHttpTriggerConfig;
|
|
44
|
+
const buildTencentHttpTriggerDesc = (authType, netConfig) => JSON.stringify({
|
|
45
|
+
AuthType: authType,
|
|
46
|
+
NetConfig: {
|
|
47
|
+
EnableIntranet: netConfig.enableIntranet ?? false,
|
|
48
|
+
EnableExtranet: netConfig.enableExtranet ?? true,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
exports.buildTencentHttpTriggerDesc = buildTencentHttpTriggerDesc;
|
|
@@ -25,14 +25,18 @@ const APIGW_POLL_MAX_ATTEMPTS = 120; // up to 20 minutes
|
|
|
25
25
|
findServiceByName: async (_g, _n) => notInitialized(),
|
|
26
26
|
deleteService: async (_id) => notInitialized(),
|
|
27
27
|
createUpstream: async (_c) => notInitialized(),
|
|
28
|
+
updateUpstream: async (_id, _c) => notInitialized(),
|
|
28
29
|
getUpstream: async (_id) => notInitialized(),
|
|
29
30
|
findUpstreamByName: async (_g, _n) => notInitialized(),
|
|
30
31
|
deleteUpstream: async (_id) => notInitialized(),
|
|
31
32
|
createRoute: async (_c) => notInitialized(),
|
|
33
|
+
updateRoute: async (_id, _c) => notInitialized(),
|
|
32
34
|
getRoute: async (_id) => notInitialized(),
|
|
33
35
|
findRouteByName: async (_s, _n) => notInitialized(),
|
|
34
36
|
listRoutesByService: async (_s) => notInitialized(),
|
|
35
37
|
deleteRoute: async (_id) => notInitialized(),
|
|
38
|
+
getCustomDomain: async (_id) => notInitialized(),
|
|
39
|
+
updateCustomDomain: async (_id, _c) => notInitialized(),
|
|
36
40
|
createCustomDomain: async (_c) => notInitialized(),
|
|
37
41
|
deleteCustomDomain: async (_id) => notInitialized(),
|
|
38
42
|
};
|
|
@@ -364,6 +368,21 @@ const APIGW_POLL_MAX_ATTEMPTS = 120; // up to 20 minutes
|
|
|
364
368
|
const data = (response.Result || {});
|
|
365
369
|
return data.Id ?? '';
|
|
366
370
|
},
|
|
371
|
+
updateUpstream: async (id, config) => {
|
|
372
|
+
await client.fetchOpenAPI({
|
|
373
|
+
Action: 'UpdateUpstream',
|
|
374
|
+
Version: '2021-03-03',
|
|
375
|
+
method: 'POST',
|
|
376
|
+
headers: { 'content-type': 'application/json' },
|
|
377
|
+
data: {
|
|
378
|
+
Id: id,
|
|
379
|
+
Name: config.upstreamName,
|
|
380
|
+
SourceType: config.sourceType,
|
|
381
|
+
Protocol: config.protocol ?? 'HTTP',
|
|
382
|
+
UpstreamSpec: { VeFaas: { FunctionId: config.functionId } },
|
|
383
|
+
},
|
|
384
|
+
});
|
|
385
|
+
},
|
|
367
386
|
getUpstream: async (upstreamId) => {
|
|
368
387
|
try {
|
|
369
388
|
const response = await client.fetchOpenAPI({
|
|
@@ -520,6 +539,25 @@ const APIGW_POLL_MAX_ATTEMPTS = 120; // up to 20 minutes
|
|
|
520
539
|
})),
|
|
521
540
|
};
|
|
522
541
|
},
|
|
542
|
+
updateRoute: async (id, config) => {
|
|
543
|
+
await client.fetchOpenAPI({
|
|
544
|
+
Action: 'UpdateRoute',
|
|
545
|
+
Version: '2022-11-12',
|
|
546
|
+
method: 'POST',
|
|
547
|
+
headers: { 'content-type': 'application/json' },
|
|
548
|
+
data: {
|
|
549
|
+
Id: id,
|
|
550
|
+
Name: config.routeName,
|
|
551
|
+
Enable: true,
|
|
552
|
+
Priority: 0,
|
|
553
|
+
MatchRule: {
|
|
554
|
+
Path: { MatchType: 'Exact', MatchContent: config.path },
|
|
555
|
+
Method: [config.method],
|
|
556
|
+
},
|
|
557
|
+
UpstreamList: [{ UpstreamId: config.upstreamId, Weight: 100 }],
|
|
558
|
+
},
|
|
559
|
+
});
|
|
560
|
+
},
|
|
523
561
|
getRoute: async (routeId) => {
|
|
524
562
|
try {
|
|
525
563
|
const response = await client.fetchOpenAPI({
|
|
@@ -622,6 +660,48 @@ const APIGW_POLL_MAX_ATTEMPTS = 120; // up to 20 minutes
|
|
|
622
660
|
data: { Id: routeId },
|
|
623
661
|
});
|
|
624
662
|
},
|
|
663
|
+
getCustomDomain: async (id) => {
|
|
664
|
+
try {
|
|
665
|
+
const response = await client.fetchOpenAPI({
|
|
666
|
+
Action: 'GetCustomDomain',
|
|
667
|
+
Version: '2021-03-03',
|
|
668
|
+
method: 'POST',
|
|
669
|
+
headers: { 'content-type': 'application/json' },
|
|
670
|
+
data: { Id: id },
|
|
671
|
+
});
|
|
672
|
+
const domain = response.Result
|
|
673
|
+
?.CustomDomain;
|
|
674
|
+
if (!domain)
|
|
675
|
+
throw new Error(lang_1.lang.__('APIGW_DOMAIN_READ_INVALID', { domainId: id }));
|
|
676
|
+
return {
|
|
677
|
+
id,
|
|
678
|
+
serviceId: domain.ServiceId,
|
|
679
|
+
domainName: domain.Domain,
|
|
680
|
+
certificateId: domain.CertificateId,
|
|
681
|
+
protocol: domain.Protocol,
|
|
682
|
+
sslRedirect: domain.SSLRedirect,
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
catch (error) {
|
|
686
|
+
if (['NotFound', 'DomainNotFound'].includes(error.code))
|
|
687
|
+
return null;
|
|
688
|
+
throw error;
|
|
689
|
+
}
|
|
690
|
+
},
|
|
691
|
+
updateCustomDomain: async (id, config) => {
|
|
692
|
+
await client.fetchOpenAPI({
|
|
693
|
+
Action: 'UpdateCustomDomain',
|
|
694
|
+
Version: '2021-03-03',
|
|
695
|
+
method: 'POST',
|
|
696
|
+
headers: { 'content-type': 'application/json' },
|
|
697
|
+
data: {
|
|
698
|
+
Id: id,
|
|
699
|
+
CertificateId: config.certificateId ?? '',
|
|
700
|
+
Protocol: config.protocol ?? ['HTTP'],
|
|
701
|
+
SSLRedirect: config.sslRedirect ?? false,
|
|
702
|
+
},
|
|
703
|
+
});
|
|
704
|
+
},
|
|
625
705
|
createCustomDomain: async (config) => {
|
|
626
706
|
const response = await client.fetchOpenAPI({
|
|
627
707
|
Action: 'CreateCustomDomain',
|
|
@@ -631,6 +711,8 @@ const APIGW_POLL_MAX_ATTEMPTS = 120; // up to 20 minutes
|
|
|
631
711
|
data: {
|
|
632
712
|
ServiceId: config.serviceId,
|
|
633
713
|
Domain: config.domainName,
|
|
714
|
+
Protocol: config.protocol ?? ['HTTP'],
|
|
715
|
+
SSLRedirect: config.sslRedirect ?? false,
|
|
634
716
|
...(config.certificateId && { CertificateId: config.certificateId }),
|
|
635
717
|
},
|
|
636
718
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createIamOperations = void 0;
|
|
3
|
+
exports.createIamOperations = exports.buildVefaasExecutionPolicy = void 0;
|
|
4
4
|
const iamStatements_1 = require("../iamStatements");
|
|
5
5
|
const nameBuilder_1 = require("../nameBuilder");
|
|
6
6
|
const logger_1 = require("../logger");
|
|
@@ -55,13 +55,14 @@ const mapToVolcengineStatement = (stmt) => {
|
|
|
55
55
|
}
|
|
56
56
|
return result;
|
|
57
57
|
};
|
|
58
|
-
const
|
|
58
|
+
const buildVefaasExecutionPolicy = (baseline, customStatements) => {
|
|
59
59
|
const nativeBaseline = baseline
|
|
60
60
|
? baseline.map(mapToVolcengineStatement)
|
|
61
61
|
: VEFAAS_EXECUTION_STATEMENTS;
|
|
62
62
|
const merged = (0, iamStatements_1.mergePolicyStatements)(nativeBaseline, customStatements, mapToVolcengineStatement);
|
|
63
63
|
return (0, iamStatements_1.buildPolicyDocument)(merged);
|
|
64
64
|
};
|
|
65
|
+
exports.buildVefaasExecutionPolicy = buildVefaasExecutionPolicy;
|
|
65
66
|
// TagResources expects flat numbered query params (ResourceIds.1, Tags.1.Key, ...).
|
|
66
67
|
// ResourceIds.1 carries the ROLE NAME (consistent with DeleteRole using RoleName).
|
|
67
68
|
const buildTagResourceQuery = (roleName, tags) => {
|
|
@@ -83,7 +84,7 @@ const createIamOperations = (iamClient) => {
|
|
|
83
84
|
headers: { 'content-type': 'application/json' },
|
|
84
85
|
query: {
|
|
85
86
|
PolicyName: policyName,
|
|
86
|
-
PolicyDocument:
|
|
87
|
+
PolicyDocument: (0, exports.buildVefaasExecutionPolicy)(baseline, customStatements),
|
|
87
88
|
Description: `veFaaS execution policy for ${roleName}`,
|
|
88
89
|
},
|
|
89
90
|
});
|
|
@@ -371,6 +372,29 @@ const createIamOperations = (iamClient) => {
|
|
|
371
372
|
throw error;
|
|
372
373
|
}
|
|
373
374
|
},
|
|
375
|
+
getPolicy: async (policyName) => {
|
|
376
|
+
try {
|
|
377
|
+
const response = await iamClient.fetchOpenAPI({
|
|
378
|
+
Action: 'GetPolicy',
|
|
379
|
+
Version: '2018-01-01',
|
|
380
|
+
method: 'GET',
|
|
381
|
+
headers: { 'content-type': 'application/json' },
|
|
382
|
+
query: { PolicyName: policyName, PolicyType: 'Custom' },
|
|
383
|
+
});
|
|
384
|
+
const policy = (response.Result ?? {}).Policy;
|
|
385
|
+
if (!policy?.PolicyDocument)
|
|
386
|
+
throw new Error(lang_1.lang.__('IAM_POLICY_READ_INVALID', { policyName }));
|
|
387
|
+
const document = JSON.parse(policy.PolicyDocument);
|
|
388
|
+
if (!Array.isArray(document.Statement))
|
|
389
|
+
throw new Error(lang_1.lang.__('IAM_POLICY_READ_INVALID', { policyName }));
|
|
390
|
+
return policy.PolicyDocument;
|
|
391
|
+
}
|
|
392
|
+
catch (error) {
|
|
393
|
+
if (error.code === 'PolicyNotExist')
|
|
394
|
+
return null;
|
|
395
|
+
throw error;
|
|
396
|
+
}
|
|
397
|
+
},
|
|
374
398
|
updateRoleTrustPolicy: async (roleName, trustPolicy) => {
|
|
375
399
|
const trustPolicyDocument = JSON.stringify(trustPolicy);
|
|
376
400
|
try {
|
|
@@ -188,75 +188,81 @@ const createTosOperations = (client, _region) => {
|
|
|
188
188
|
if (!client) {
|
|
189
189
|
throw new Error(lang_1.lang.__('VOLCENGINE_TOS_CLIENT_NOT_INITIALIZED'));
|
|
190
190
|
}
|
|
191
|
-
|
|
192
|
-
const response = await client.fetchOpenAPI({
|
|
193
|
-
Action: 'GetBucketInfo',
|
|
194
|
-
Version: '2018-08-01',
|
|
195
|
-
method: 'GET',
|
|
196
|
-
query: {
|
|
197
|
-
Bucket: bucketName,
|
|
198
|
-
},
|
|
199
|
-
});
|
|
200
|
-
const result = (response.Result || {});
|
|
201
|
-
const bucketData = (result.BucketInfo || {});
|
|
202
|
-
let websiteConfig;
|
|
191
|
+
const response = await (async () => {
|
|
203
192
|
try {
|
|
204
|
-
|
|
205
|
-
Action: '
|
|
193
|
+
return await client.fetchOpenAPI({
|
|
194
|
+
Action: 'GetBucketInfo',
|
|
206
195
|
Version: '2018-08-01',
|
|
207
196
|
method: 'GET',
|
|
208
197
|
query: {
|
|
209
198
|
Bucket: bucketName,
|
|
210
199
|
},
|
|
211
200
|
});
|
|
212
|
-
const websiteResult = (websiteResponse.Result || {});
|
|
213
|
-
if (websiteResult.IndexDocument) {
|
|
214
|
-
const indexDoc = websiteResult.IndexDocument;
|
|
215
|
-
websiteConfig = {
|
|
216
|
-
indexDocument: indexDoc.Suffix,
|
|
217
|
-
};
|
|
218
|
-
if (websiteResult.ErrorDocument) {
|
|
219
|
-
const errorDoc = websiteResult.ErrorDocument;
|
|
220
|
-
websiteConfig.errorDocument = errorDoc.Key;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
201
|
}
|
|
224
|
-
catch {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
method: 'GET',
|
|
233
|
-
query: {
|
|
234
|
-
Bucket: bucketName,
|
|
235
|
-
},
|
|
236
|
-
});
|
|
237
|
-
const taggingResult = (taggingResponse.Result || {});
|
|
238
|
-
const tagSet = (taggingResult.TagSet || {});
|
|
239
|
-
const tagList = (tagSet.Tags || []);
|
|
240
|
-
tags = tagList.map((t) => ({ Key: t.Key, Value: t.Value }));
|
|
202
|
+
catch (error) {
|
|
203
|
+
if (error &&
|
|
204
|
+
typeof error === 'object' &&
|
|
205
|
+
'code' in error &&
|
|
206
|
+
(error.code === 'NoSuchBucket' || error.code === 'ResourceNotFound')) {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
throw error;
|
|
241
210
|
}
|
|
242
|
-
|
|
243
|
-
|
|
211
|
+
})();
|
|
212
|
+
if (response === null)
|
|
213
|
+
return null;
|
|
214
|
+
const result = (response.Result || {});
|
|
215
|
+
const bucketData = (result.BucketInfo || {});
|
|
216
|
+
let websiteConfig = null;
|
|
217
|
+
try {
|
|
218
|
+
const websiteResponse = await client.fetchOpenAPI({
|
|
219
|
+
Action: 'GetBucketWebsite',
|
|
220
|
+
Version: '2018-08-01',
|
|
221
|
+
method: 'GET',
|
|
222
|
+
query: {
|
|
223
|
+
Bucket: bucketName,
|
|
224
|
+
},
|
|
225
|
+
});
|
|
226
|
+
const websiteResult = (websiteResponse.Result || {});
|
|
227
|
+
if (websiteResult.IndexDocument) {
|
|
228
|
+
const indexDoc = websiteResult.IndexDocument;
|
|
229
|
+
websiteConfig = {
|
|
230
|
+
indexDocument: indexDoc.Suffix,
|
|
231
|
+
};
|
|
232
|
+
if (websiteResult.ErrorDocument) {
|
|
233
|
+
const errorDoc = websiteResult.ErrorDocument;
|
|
234
|
+
websiteConfig.errorDocument = errorDoc.Key;
|
|
235
|
+
}
|
|
244
236
|
}
|
|
245
|
-
return {
|
|
246
|
-
...mapBucketInfo(bucketName, bucketData),
|
|
247
|
-
websiteConfig,
|
|
248
|
-
Tags: tags,
|
|
249
|
-
};
|
|
250
237
|
}
|
|
251
238
|
catch (error) {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
239
|
+
const code = error?.code;
|
|
240
|
+
if (code !== 'NoSuchWebsiteConfiguration' && code !== 'NoSuchConfiguration')
|
|
241
|
+
throw error;
|
|
242
|
+
}
|
|
243
|
+
let tags;
|
|
244
|
+
try {
|
|
245
|
+
const taggingResponse = await client.fetchOpenAPI({
|
|
246
|
+
Action: 'GetBucketTagging',
|
|
247
|
+
Version: '2018-08-01',
|
|
248
|
+
method: 'GET',
|
|
249
|
+
query: {
|
|
250
|
+
Bucket: bucketName,
|
|
251
|
+
},
|
|
252
|
+
});
|
|
253
|
+
const taggingResult = (taggingResponse.Result || {});
|
|
254
|
+
const tagSet = (taggingResult.TagSet || {});
|
|
255
|
+
const tagList = (tagSet.Tags || []);
|
|
256
|
+
tags = tagList.map((t) => ({ Key: t.Key, Value: t.Value }));
|
|
257
|
+
}
|
|
258
|
+
catch {
|
|
259
|
+
// Bucket tagging may not be configured
|
|
259
260
|
}
|
|
261
|
+
return {
|
|
262
|
+
...mapBucketInfo(bucketName, bucketData),
|
|
263
|
+
websiteConfig,
|
|
264
|
+
Tags: tags,
|
|
265
|
+
};
|
|
260
266
|
},
|
|
261
267
|
updateBucketAcl: async (bucketName, acl) => {
|
|
262
268
|
if (!client) {
|
package/dist/src/lang/en.js
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.en = void 0;
|
|
4
4
|
exports.en = {
|
|
5
|
+
PLAN_SENSITIVE_VALUE: '(sensitive)',
|
|
6
|
+
PLAN_NAS_NETWORK_REQUIRED: 'NAS storage on {{logicalId}} needs a declared VPC network or recorded mount targets. Planning stopped before creating any resources.',
|
|
7
|
+
APIGW_DOMAIN_READ_INVALID: 'Invalid domain response for: {{domainId}}',
|
|
8
|
+
APIGW_DOMAIN_CERTIFICATE_UPDATED: 'Updated gateway certificate for domain: {{domain}}',
|
|
9
|
+
PLAN_DRIFT_EVENT_DOMAIN: 'Gateway domain or certificate differs from the requested configuration or is missing',
|
|
10
|
+
PLAN_DRIFT_HTTP_TRIGGER: 'HTTP trigger differs from the requested configuration or is missing',
|
|
11
|
+
PLAN_DRIFT_FUNCTION_DOMAIN: 'Function domain differs from the requested configuration or is missing',
|
|
12
|
+
PLAN_REPLACEMENT_REQUIRED: 'Changes to {{fields}} on {{logicalId}} require resource replacement. Automatic replacement is not supported; explicitly migrate or recreate the resource.',
|
|
13
|
+
PLAN_UPDATE_NOT_SUPPORTED: 'Cannot update {{fields}} on {{logicalId}}: the provider update implementation does not support these fields. No changes have been applied.',
|
|
14
|
+
PLAN_STATE_ONLY: '{{logicalId}} already matches the cloud; only saved intent will be updated.',
|
|
5
15
|
// Validation messages
|
|
6
16
|
VALIDATING_YAML: 'Validating yaml...',
|
|
7
17
|
YAML_VALID: 'Yaml is valid! 🎉',
|
|
@@ -121,7 +131,7 @@ exports.en = {
|
|
|
121
131
|
PLAN_COMPUTED_VALUE: '(known after deploy)',
|
|
122
132
|
PLAN_REVERT_ANNOTATION: '(changed in the cloud, will be restored to config)',
|
|
123
133
|
PLAN_DRIFTED_MARKER: '(drifted — cloud changed outside of this config, will be reconciled)',
|
|
124
|
-
PLAN_LIVE_READ_FAILED: 'Failed to read live state for {{logicalId}}; planning
|
|
134
|
+
PLAN_LIVE_READ_FAILED: 'Failed to read live state for {{logicalId}}; planning stopped: {{error}}',
|
|
125
135
|
PLAN_DRIFT_ROLE_MISSING: 'IAM role missing in the cloud',
|
|
126
136
|
PLAN_DRIFT_ROLE_POLICY: 'IAM role policy changed in the cloud',
|
|
127
137
|
PLAN_DRIFT_LOGSTORE: 'function log resources changed in the cloud',
|
|
@@ -225,7 +235,7 @@ exports.en = {
|
|
|
225
235
|
FORCE_UNLOCK_CONFIRM: 'Are you absolutely sure? (yes/no): ',
|
|
226
236
|
FORCE_UNLOCK_CANCELLED: 'Force unlock cancelled',
|
|
227
237
|
SAAS_FORCE_UNLOCK_NOT_SUPPORTED: 'Force unlock is not supported via CLI for SaaS state. Open {{consoleUrl}} in your browser and unlock the deployment from the Deployments page.',
|
|
228
|
-
PLAN_COMMAND_NOT_SUPPORTED: '
|
|
238
|
+
PLAN_COMMAND_NOT_SUPPORTED: 'Planning is not supported for this provider',
|
|
229
239
|
// Lock info formatting
|
|
230
240
|
LOCK_INFO_HEADER: 'Lock Info:',
|
|
231
241
|
LOCK_INFO_ID: ' ID: {{id}}',
|
|
@@ -250,8 +260,8 @@ exports.en = {
|
|
|
250
260
|
SHARED_SLS_PROJECT_ADOPTED: 'Adopting existing shared SLS project {{projectName}} owned by this app',
|
|
251
261
|
REFRESH_CACHE_HIT: 'Refresh read cache hit: {{key}}',
|
|
252
262
|
PLAN_FUNCTION_ROLE_MISSING: 'Function {{functionName}} role {{roleName}} is missing in the provider; it will be recreated and rebound on deploy',
|
|
253
|
-
PLAN_FUNCTION_ROLE_PROBE_FAILED: 'Live role policy check for function {{functionName}} (role {{roleName}}) failed: {{error}};
|
|
254
|
-
PLAN_FUNCTION_NESTED_PROBE_FAILED: 'Nested resource probe for function {{functionName}} failed: {{error}};
|
|
263
|
+
PLAN_FUNCTION_ROLE_PROBE_FAILED: 'Live role policy check for function {{functionName}} (role {{roleName}}) failed: {{error}}; planning stopped',
|
|
264
|
+
PLAN_FUNCTION_NESTED_PROBE_FAILED: 'Nested resource probe for function {{functionName}} failed: {{error}}; planning stopped',
|
|
255
265
|
NESTED_LOGSTORE_RECREATED: 'Logstore {{logstoreName}} was deleted out-of-band; recreating it',
|
|
256
266
|
NESTED_LOGSTORE_UPDATED: 'Logstore {{logstoreName}} attributes drifted; updating to match si defaults',
|
|
257
267
|
NESTED_TLS_TOPIC_UPDATED: 'TLS topic {{topicId}} ttl drifted; updating to match si defaults',
|
|
@@ -860,7 +870,7 @@ exports.en = {
|
|
|
860
870
|
MIGRATE_ROLLBACK_NO_MARKER: 'No migration marker found on the legacy state — nothing to roll back.',
|
|
861
871
|
MIGRATE_ROLLBACK_DONE: 'Migration marker cleared. The legacy backend is writable again.',
|
|
862
872
|
MIGRATE_ROLLBACK_DONE_HINT: 'If you already removed the backend.state_manager block from your YAML, restore it before deploying via the legacy backend.',
|
|
863
|
-
MIGRATE_CUTOVER_STEPS: 'Cutover checklist:\n 1. Remove the backend.state_manager block from serverlessinsight.yml, add a top-level org declaration (org: <slug> — see your org settings in Console), and merge\n 2. Run `si
|
|
873
|
+
MIGRATE_CUTOVER_STEPS: 'Cutover checklist:\n 1. Remove the backend.state_manager block from serverlessinsight.yml, add a top-level org declaration (org: <slug> — see your org settings in Console), and merge\n 2. Run `si diff` — it MUST report no changes and exit 0 (that is the proof of a lossless migration)\n 3. Resume deploys; the Console now owns the deployment timeline',
|
|
864
874
|
MIGRATION_MARKER_REFUSED: 'This state has been migrated to the ServerlessInsight Console (managedBy=saas) and the legacy backend is closed for changes.\n • To continue with the Console: remove the backend.state_manager block from your YAML, declare a top-level org: <slug>, then deploy again.\n • To deliberately use the legacy backend: run `si migrate --rollback` to clear the marker.',
|
|
865
875
|
MIGRATION_MARKER_WARN: 'This state has been migrated to the Console (managedBy=saas) — the copy shown here is read-only and may be stale. Do not deploy from this backend.',
|
|
866
876
|
// HTTP trigger messages
|
|
@@ -895,7 +905,7 @@ exports.en = {
|
|
|
895
905
|
TIMER_TRIGGER_DELETED: "Timer trigger '{{triggerName}}' deleted",
|
|
896
906
|
TIMER_TRIGGER_NOT_FOUND: "Timer trigger '{{triggerName}}' not found in provider, skipping delete",
|
|
897
907
|
TIMER_TRIGGER_ALREADY_ATTACHED: "Timer trigger '{{triggerName}}' is already attached to function '{{functionName}}', skipping create",
|
|
898
|
-
PLAN_DRIFT_TIMER_TRIGGER: 'Timer triggers
|
|
908
|
+
PLAN_DRIFT_TIMER_TRIGGER: 'Timer triggers differ from the requested configuration',
|
|
899
909
|
PLAN_TIMER_TRIGGER_PROBE_FAILED: "Failed to probe timer triggers for function '{{functionName}}': {{error}}",
|
|
900
910
|
// si-cron messages (issue #258)
|
|
901
911
|
SI_CRON_EMPTY: 'si-cron expression is empty',
|
|
@@ -1016,11 +1026,26 @@ exports.en = {
|
|
|
1016
1026
|
OTS_ATTRIBUTE_NOT_FOUND: 'Attribute not found for key: {{key}}',
|
|
1017
1027
|
LOCAL_HANDLER_NOT_FOUND: 'Handler "{{handlerMethod}}" not found or is not a function in {{handlerPath}}',
|
|
1018
1028
|
LOCAL_EXECUTION_TIMEOUT: 'Function execution timed out after {{timeoutMs}}ms',
|
|
1029
|
+
LOCAL_FUNCTION_NOT_FOUND: 'Function not found',
|
|
1030
|
+
LOCAL_FUNCTION_CODE_MISSING: 'Function code configuration not found',
|
|
1031
|
+
LOCAL_FUNCTION_EXECUTION_FAILED: 'Function execution failed',
|
|
1032
|
+
LOCAL_HTTP_PROVIDER_UNSUPPORTED: 'Local HTTP invocation is not supported for provider {{provider}}',
|
|
1033
|
+
LOCAL_VOLCENGINE_MODE_UNSUPPORTED: 'Local veFaaS HTTP invocation supports node14/v1 and node20/v1 code packages only (function: {{functionName}}). Containers, native runtimes and other languages are not simulated.',
|
|
1034
|
+
LOCAL_VOLCENGINE_BINARY_UNSUPPORTED: 'Local veFaaS HTTP invocation supports UTF-8 request bodies only. Binary bodies containing invalid UTF-8 are not simulated; no base64 event contract is assumed.',
|
|
1035
|
+
LOCAL_VOLCENGINE_INVALID_RESPONSE: 'Invalid local veFaaS response: return an object with an optional integer statusCode (200-599), string-valued headers and a string body. Binary responses are not simulated.',
|
|
1036
|
+
LOCAL_EVENT_TYPE_UNSUPPORTED: 'Local event endpoints support API_GATEWAY triggers only.',
|
|
1037
|
+
LOCAL_SCF_EVENT_UNSUPPORTED: 'Local SCF simulation covers the function-owned function URL, not API Gateway events (no Tencent API Gateway is deployed). Invoke the function URL at /si_functions/<function-key>/<path>.',
|
|
1038
|
+
LOCAL_SCF_MODE_UNSUPPORTED: 'Local SCF HTTP invocation supports {{runtimes}} code packages only (function: {{functionName}}). Containers, Web Functions and other languages are not simulated.',
|
|
1039
|
+
LOCAL_SCF_BINARY_REQUEST_UNSUPPORTED: 'Local SCF HTTP invocation supports UTF-8 request bodies only. The function-URL event carries no isBase64Encoded field, so binary bodies are not simulated.',
|
|
1040
|
+
LOCAL_SCF_BINARY_RESPONSE_UNSUPPORTED: 'Local SCF responses do not support binary bodies: the function-URL response carries no isBase64Encoded field, so isBase64Encoded responses are not simulated.',
|
|
1041
|
+
LOCAL_SCF_INVALID_RESPONSE: 'Invalid local SCF response: return a string or JSON object, or an object with an optional integer statusCode (200-599), string-valued headers and a string body.',
|
|
1019
1042
|
LOCAL_PORT_CLOSED: 'Port closed before receiving response',
|
|
1020
1043
|
LOCAL_WORKER_EXITED: 'Worker stopped with exit code {{code}}',
|
|
1021
1044
|
REFRESH_STATE_BUCKET: 'Failed to refresh state for bucket: {{name}}',
|
|
1022
1045
|
RESOURCE_SPACE_ID_NOT_FOUND: 'Space ID not found in state for {{logicalId}}',
|
|
1023
1046
|
REFRESH_STATE_ES_SPACE: 'Failed to refresh state for ES space: {{spaceId}}',
|
|
1047
|
+
IAM_POLICY_READ_INVALID: 'Invalid policy document returned for: {{policyName}}',
|
|
1048
|
+
SCF_HTTP_TRIGGER_ID_UNAVAILABLE: 'Cannot record the cloud-assigned HTTP trigger identity for function: {{functionName}}',
|
|
1024
1049
|
SCF_HTTP_TRIGGER_ALREADY_ATTACHED: 'HTTP trigger {{triggerName}} already attached to {{functionName}}, skipping creation',
|
|
1025
1050
|
SCF_HTTP_TRIGGER_ALREADY_EXISTS: 'HTTP trigger {{triggerName}} already exists on {{functionName}}, continuing: {{error}}',
|
|
1026
1051
|
SCF_HANDLER_IMMUTABLE: 'Handler is immutable in Tencent SCF and cannot be changed on update ({{oldHandler}} -> {{newHandler}}). Delete and recreate the function instead.',
|
|
@@ -1055,8 +1080,8 @@ exports.en = {
|
|
|
1055
1080
|
CMD_WHOAMI_DESC: 'show current login status',
|
|
1056
1081
|
CMD_SHOW_DESC: 'show deployed resources from state',
|
|
1057
1082
|
CMD_VALIDATE_DESC: 'validate serverless Iac yaml',
|
|
1058
|
-
|
|
1059
|
-
|
|
1083
|
+
CMD_DIFF_DESC: 'show changes between your config and the live cloud',
|
|
1084
|
+
CMD_PLAN_REMOVED: 'the plan command has been removed; use the diff command instead — it accepts the same options and arguments.',
|
|
1060
1085
|
CMD_DEPLOY_DESC: 'deploy serverless Iac yaml',
|
|
1061
1086
|
CMD_DESTROY_DESC: 'destroy serverless stack',
|
|
1062
1087
|
CMD_LOCAL_DESC: 'run Serverless application locally for debugging',
|
package/dist/src/lang/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.lang = exports.lookupErrorCode = exports.hasLangKey = void 0;
|
|
3
|
+
exports.getSystemLanguage = exports.lang = exports.lookupErrorCode = exports.hasLangKey = void 0;
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
5
|
const i18n_1 = require("i18n");
|
|
6
6
|
const en_1 = require("./en");
|
|
@@ -11,24 +11,38 @@ const zh_CN_1 = require("./zh-CN");
|
|
|
11
11
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
12
12
|
const mustache = require('mustache');
|
|
13
13
|
mustache.escape = (text) => text;
|
|
14
|
+
const normalizeLocale = (value) => {
|
|
15
|
+
if (!value)
|
|
16
|
+
return null;
|
|
17
|
+
const normalized = value.trim().toLowerCase();
|
|
18
|
+
if (normalized.startsWith('zh'))
|
|
19
|
+
return 'zh-CN';
|
|
20
|
+
if (normalized.startsWith('en'))
|
|
21
|
+
return 'en-US';
|
|
22
|
+
return null;
|
|
23
|
+
};
|
|
14
24
|
const getSystemLanguage = (defaultLang) => {
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
+
const override = normalizeLocale(process.env.SI_LANG);
|
|
26
|
+
if (override)
|
|
27
|
+
return override;
|
|
28
|
+
const envLocale = [process.env.LC_ALL, process.env.LANG].reduce((found, value) => found ?? normalizeLocale(value), null);
|
|
29
|
+
if (envLocale)
|
|
30
|
+
return envLocale;
|
|
31
|
+
if (process.platform === 'win32') {
|
|
32
|
+
try {
|
|
33
|
+
const codePageOutput = (0, child_process_1.execSync)('chcp').toString();
|
|
34
|
+
const codePageMatch = codePageOutput.match(/(\d+)\s*$/m);
|
|
35
|
+
if (codePageMatch) {
|
|
36
|
+
return parseInt(codePageMatch[1]) === 936 ? 'zh-CN' : 'en-US';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
// ignore
|
|
25
41
|
}
|
|
26
|
-
}
|
|
27
|
-
catch {
|
|
28
|
-
// ignore
|
|
29
42
|
}
|
|
30
43
|
return defaultLang;
|
|
31
44
|
};
|
|
45
|
+
exports.getSystemLanguage = getSystemLanguage;
|
|
32
46
|
const lang = new i18n_1.I18n({
|
|
33
47
|
locales: ['en-US', 'zh-CN'],
|
|
34
48
|
defaultLocale: getSystemLanguage('zh-CN'),
|