@geek-fun/serverlessinsight 0.9.2 → 0.9.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.
Files changed (101) hide show
  1. package/.serverlessinsight/state-cdn-flow-app-cdn-flow-service.json.backup +1 -1
  2. package/.serverlessinsight/state-iam-test-app-iam-test-service.json.backup +2 -2
  3. package/.serverlessinsight/state-insight-poc-app-insight-poc-tencent.json.backup +4 -8
  4. package/.serverlessinsight/state-insight-poc-app-log-insight-poc-tencent-log.json.backup +3 -8
  5. package/.serverlessinsight/state-insight-poc-deploy-app-insight-poc-deploy.json.backup +4 -4
  6. package/.serverlessinsight/state-insight-poc-destroy-app-insight-poc-destroy.json.backup +1 -1
  7. package/.serverlessinsight/state-insight-poc-timer-app-insight-poc-timer.json.backup +28 -5
  8. package/.serverlessinsight/state-insight-volc-app-insight-volc.json.backup +2 -2
  9. package/.serverlessinsight/state-insight-volc-nested-app-insight-volc-nested.json.backup +3 -3
  10. package/.serverlessinsight/state-nested-drift-app-nested-drift-service.json.backup +20 -5
  11. package/.serverlessinsight/state-role-reconcile-test-app-role-reconcile-test-service.json.backup +3 -3
  12. package/AGENTS.md +10 -0
  13. package/CHANGELOG.md +34 -0
  14. package/README.md +29 -15
  15. package/README.zh-CN.md +7 -14
  16. package/dist/package.json +1 -1
  17. package/dist/src/commands/index.js +19 -3
  18. package/dist/src/commands/local.js +16 -3
  19. package/dist/src/commands/plan.js +10 -3
  20. package/dist/src/common/aliyunClient/apigwOperations.js +17 -1
  21. package/dist/src/common/aliyunClient/fc3Operations.js +7 -1
  22. package/dist/src/common/aliyunClient/ossOperations.js +214 -221
  23. package/dist/src/common/bucketPolicy.js +63 -0
  24. package/dist/src/common/domainUtils.js +4 -1
  25. package/dist/src/common/functionDefinition.js +25 -0
  26. package/dist/src/common/index.js +4 -0
  27. package/dist/src/common/jsonOutput.js +6 -1
  28. package/dist/src/common/nameBuilder.js +3 -1
  29. package/dist/src/common/planCapabilities.js +119 -0
  30. package/dist/src/common/planCompare.js +119 -66
  31. package/dist/src/common/planFormatter.js +22 -14
  32. package/dist/src/common/planRedaction.js +26 -0
  33. package/dist/src/common/refreshPlanner.js +66 -21
  34. package/dist/src/common/tencentClient/cosOperations.js +326 -322
  35. package/dist/src/common/tencentClient/scfOperations.js +9 -2
  36. package/dist/src/common/tencentClient/tdsqlcOperations.js +6 -11
  37. package/dist/src/common/triggerMapper.js +16 -1
  38. package/dist/src/common/volcengineClient/apigwOperations.js +82 -0
  39. package/dist/src/common/volcengineClient/iamOperations.js +27 -3
  40. package/dist/src/common/volcengineClient/tosOperations.js +62 -56
  41. package/dist/src/lang/en.js +28 -4
  42. package/dist/src/lang/zh-CN.js +28 -4
  43. package/dist/src/parser/eventParser.js +1 -0
  44. package/dist/src/parser/functionParser.js +1 -1
  45. package/dist/src/stack/aliyunStack/apigwExecutor.js +1 -1
  46. package/dist/src/stack/aliyunStack/apigwPlanner.js +103 -23
  47. package/dist/src/stack/aliyunStack/apigwResource.js +4 -3
  48. package/dist/src/stack/aliyunStack/apigwTypes.js +3 -7
  49. package/dist/src/stack/aliyunStack/deployer.js +2 -0
  50. package/dist/src/stack/aliyunStack/esServerlessTypes.js +8 -4
  51. package/dist/src/stack/aliyunStack/fc3Executor.js +7 -3
  52. package/dist/src/stack/aliyunStack/fc3Planner.js +124 -155
  53. package/dist/src/stack/aliyunStack/fc3Resource.js +48 -52
  54. package/dist/src/stack/aliyunStack/fc3Types.js +30 -16
  55. package/dist/src/stack/aliyunStack/ossPlanner.js +15 -1
  56. package/dist/src/stack/aliyunStack/ossResource.js +113 -102
  57. package/dist/src/stack/aliyunStack/ossTypes.js +20 -20
  58. package/dist/src/stack/localStack/aliyunFc.js +1 -6
  59. package/dist/src/stack/localStack/event.js +31 -60
  60. package/dist/src/stack/localStack/function.js +24 -65
  61. package/dist/src/stack/localStack/functionRunner.js +10 -2
  62. package/dist/src/stack/localStack/httpAdapter.js +54 -0
  63. package/dist/src/stack/localStack/httpError.js +5 -0
  64. package/dist/src/stack/localStack/legacyLambda.js +26 -0
  65. package/dist/src/stack/localStack/localContext.js +29 -0
  66. package/dist/src/stack/localStack/localRoute.js +12 -0
  67. package/dist/src/stack/localStack/localRuntimes.js +22 -0
  68. package/dist/src/stack/localStack/localServer.js +8 -3
  69. package/dist/src/stack/localStack/requestBody.js +24 -0
  70. package/dist/src/stack/localStack/requestId.js +18 -0
  71. package/dist/src/stack/localStack/tencent.js +147 -0
  72. package/dist/src/stack/localStack/timer.js +23 -2
  73. package/dist/src/stack/localStack/volcengine.js +68 -0
  74. package/dist/src/stack/scfStack/cosPlanner.js +9 -14
  75. package/dist/src/stack/scfStack/cosResource.js +42 -50
  76. package/dist/src/stack/scfStack/cosTypes.js +19 -14
  77. package/dist/src/stack/scfStack/deployer.js +2 -0
  78. package/dist/src/stack/scfStack/scfExecutor.js +7 -3
  79. package/dist/src/stack/scfStack/scfHttpTrigger.js +106 -0
  80. package/dist/src/stack/scfStack/scfPlanner.js +67 -16
  81. package/dist/src/stack/scfStack/scfResource.js +170 -321
  82. package/dist/src/stack/scfStack/scfTypes.js +4 -3
  83. package/dist/src/stack/scfStack/tdsqlcPlanner.js +10 -13
  84. package/dist/src/stack/volcengineStack/apigwDomains.js +64 -0
  85. package/dist/src/stack/volcengineStack/apigwPlanner.js +71 -15
  86. package/dist/src/stack/volcengineStack/apigwResource.js +60 -24
  87. package/dist/src/stack/volcengineStack/apigwTypes.js +5 -1
  88. package/dist/src/stack/volcengineStack/deployer.js +6 -0
  89. package/dist/src/stack/volcengineStack/tosPlanner.js +8 -13
  90. package/dist/src/stack/volcengineStack/tosResource.js +22 -35
  91. package/dist/src/stack/volcengineStack/tosTypes.js +5 -8
  92. package/dist/src/stack/volcengineStack/vefaasPlanner.js +142 -49
  93. package/dist/src/stack/volcengineStack/vefaasResource.js +17 -12
  94. package/dist/src/stack/volcengineStack/vefaasTypes.js +6 -3
  95. package/dist/tsconfig.tsbuildinfo +1 -1
  96. package/package.json +1 -1
  97. package/release-notes.md +79 -0
  98. package/samples/tencent-local/index.js +13 -0
  99. package/samples/tencent-local/serverlessinsight.yml +23 -0
  100. package/samples/volcengine-local/index.js +13 -0
  101. 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
- await scfClient.DeleteCustomDomain({ Domain: domain });
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
- try {
177
- const response = await sdk.DescribeServerlessStrategy({ ClusterId: clusterId });
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 buildExecutionPolicy = (baseline, customStatements) => {
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: buildExecutionPolicy(baseline, customStatements),
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
- try {
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
- const websiteResponse = await client.fetchOpenAPI({
205
- Action: 'GetBucketWebsite',
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
- // Website config may not exist
226
- }
227
- let tags;
228
- try {
229
- const taggingResponse = await client.fetchOpenAPI({
230
- Action: 'GetBucketTagging',
231
- Version: '2018-08-01',
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
- catch {
243
- // Bucket tagging may not be configured
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
- if (error &&
253
- typeof error === 'object' &&
254
- 'code' in error &&
255
- (error.code === 'NoSuchBucket' || error.code === 'ResourceNotFound')) {
256
- return null;
257
- }
258
- throw error;
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) {
@@ -2,6 +2,15 @@
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
+ PLAN_DRIFT_EVENT_DOMAIN: 'Gateway domain or certificate differs from the requested configuration or is missing',
9
+ PLAN_DRIFT_HTTP_TRIGGER: 'HTTP trigger differs from the requested configuration or is missing',
10
+ PLAN_DRIFT_FUNCTION_DOMAIN: 'Function domain differs from the requested configuration or is missing',
11
+ PLAN_REPLACEMENT_REQUIRED: 'Changes to {{fields}} on {{logicalId}} require resource replacement. Automatic replacement is not supported; explicitly migrate or recreate the resource.',
12
+ PLAN_UPDATE_NOT_SUPPORTED: 'Cannot update {{fields}} on {{logicalId}}: the provider update implementation does not support these fields. No changes have been applied.',
13
+ PLAN_STATE_ONLY: '{{logicalId}} already matches the cloud; only saved intent will be updated.',
5
14
  // Validation messages
6
15
  VALIDATING_YAML: 'Validating yaml...',
7
16
  YAML_VALID: 'Yaml is valid! 🎉',
@@ -121,7 +130,7 @@ exports.en = {
121
130
  PLAN_COMPUTED_VALUE: '(known after deploy)',
122
131
  PLAN_REVERT_ANNOTATION: '(changed in the cloud, will be restored to config)',
123
132
  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 a create instead: {{error}}',
133
+ PLAN_LIVE_READ_FAILED: 'Failed to read live state for {{logicalId}}; planning stopped: {{error}}',
125
134
  PLAN_DRIFT_ROLE_MISSING: 'IAM role missing in the cloud',
126
135
  PLAN_DRIFT_ROLE_POLICY: 'IAM role policy changed in the cloud',
127
136
  PLAN_DRIFT_LOGSTORE: 'function log resources changed in the cloud',
@@ -250,8 +259,8 @@ exports.en = {
250
259
  SHARED_SLS_PROJECT_ADOPTED: 'Adopting existing shared SLS project {{projectName}} owned by this app',
251
260
  REFRESH_CACHE_HIT: 'Refresh read cache hit: {{key}}',
252
261
  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}}; skipping role drift detection for this plan',
254
- PLAN_FUNCTION_NESTED_PROBE_FAILED: 'Nested resource probe for function {{functionName}} failed: {{error}}; skipping nested drift detection for this plan',
262
+ PLAN_FUNCTION_ROLE_PROBE_FAILED: 'Live role policy check for function {{functionName}} (role {{roleName}}) failed: {{error}}; planning stopped',
263
+ PLAN_FUNCTION_NESTED_PROBE_FAILED: 'Nested resource probe for function {{functionName}} failed: {{error}}; planning stopped',
255
264
  NESTED_LOGSTORE_RECREATED: 'Logstore {{logstoreName}} was deleted out-of-band; recreating it',
256
265
  NESTED_LOGSTORE_UPDATED: 'Logstore {{logstoreName}} attributes drifted; updating to match si defaults',
257
266
  NESTED_TLS_TOPIC_UPDATED: 'TLS topic {{topicId}} ttl drifted; updating to match si defaults',
@@ -895,7 +904,7 @@ exports.en = {
895
904
  TIMER_TRIGGER_DELETED: "Timer trigger '{{triggerName}}' deleted",
896
905
  TIMER_TRIGGER_NOT_FOUND: "Timer trigger '{{triggerName}}' not found in provider, skipping delete",
897
906
  TIMER_TRIGGER_ALREADY_ATTACHED: "Timer trigger '{{triggerName}}' is already attached to function '{{functionName}}', skipping create",
898
- PLAN_DRIFT_TIMER_TRIGGER: 'Timer triggers changed in the cloud',
907
+ PLAN_DRIFT_TIMER_TRIGGER: 'Timer triggers differ from the requested configuration',
899
908
  PLAN_TIMER_TRIGGER_PROBE_FAILED: "Failed to probe timer triggers for function '{{functionName}}': {{error}}",
900
909
  // si-cron messages (issue #258)
901
910
  SI_CRON_EMPTY: 'si-cron expression is empty',
@@ -1016,11 +1025,26 @@ exports.en = {
1016
1025
  OTS_ATTRIBUTE_NOT_FOUND: 'Attribute not found for key: {{key}}',
1017
1026
  LOCAL_HANDLER_NOT_FOUND: 'Handler "{{handlerMethod}}" not found or is not a function in {{handlerPath}}',
1018
1027
  LOCAL_EXECUTION_TIMEOUT: 'Function execution timed out after {{timeoutMs}}ms',
1028
+ LOCAL_FUNCTION_NOT_FOUND: 'Function not found',
1029
+ LOCAL_FUNCTION_CODE_MISSING: 'Function code configuration not found',
1030
+ LOCAL_FUNCTION_EXECUTION_FAILED: 'Function execution failed',
1031
+ LOCAL_HTTP_PROVIDER_UNSUPPORTED: 'Local HTTP invocation is not supported for provider {{provider}}',
1032
+ 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.',
1033
+ 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.',
1034
+ 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.',
1035
+ LOCAL_EVENT_TYPE_UNSUPPORTED: 'Local event endpoints support API_GATEWAY triggers only.',
1036
+ 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>.',
1037
+ LOCAL_SCF_MODE_UNSUPPORTED: 'Local SCF HTTP invocation supports {{runtimes}} code packages only (function: {{functionName}}). Containers, Web Functions and other languages are not simulated.',
1038
+ 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.',
1039
+ 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.',
1040
+ 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
1041
  LOCAL_PORT_CLOSED: 'Port closed before receiving response',
1020
1042
  LOCAL_WORKER_EXITED: 'Worker stopped with exit code {{code}}',
1021
1043
  REFRESH_STATE_BUCKET: 'Failed to refresh state for bucket: {{name}}',
1022
1044
  RESOURCE_SPACE_ID_NOT_FOUND: 'Space ID not found in state for {{logicalId}}',
1023
1045
  REFRESH_STATE_ES_SPACE: 'Failed to refresh state for ES space: {{spaceId}}',
1046
+ IAM_POLICY_READ_INVALID: 'Invalid policy document returned for: {{policyName}}',
1047
+ SCF_HTTP_TRIGGER_ID_UNAVAILABLE: 'Cannot record the cloud-assigned HTTP trigger identity for function: {{functionName}}',
1024
1048
  SCF_HTTP_TRIGGER_ALREADY_ATTACHED: 'HTTP trigger {{triggerName}} already attached to {{functionName}}, skipping creation',
1025
1049
  SCF_HTTP_TRIGGER_ALREADY_EXISTS: 'HTTP trigger {{triggerName}} already exists on {{functionName}}, continuing: {{error}}',
1026
1050
  SCF_HANDLER_IMMUTABLE: 'Handler is immutable in Tencent SCF and cannot be changed on update ({{oldHandler}} -> {{newHandler}}). Delete and recreate the function instead.',
@@ -2,6 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.zhCN = void 0;
4
4
  exports.zhCN = {
5
+ PLAN_SENSITIVE_VALUE: '(敏感值)',
6
+ PLAN_NAS_NETWORK_REQUIRED: '{{logicalId}} 的 NAS 存储需要声明 VPC 网络或已有挂载目标记录。计划已停止,尚未创建任何资源。',
7
+ APIGW_DOMAIN_READ_INVALID: '域名 {{domainId}} 的查询响应无效',
8
+ PLAN_DRIFT_EVENT_DOMAIN: '网关域名或证书与配置不一致或不存在',
9
+ PLAN_DRIFT_HTTP_TRIGGER: 'HTTP 触发器与请求配置不同或已丢失',
10
+ PLAN_DRIFT_FUNCTION_DOMAIN: '函数域名与请求配置不同或已丢失',
11
+ PLAN_REPLACEMENT_REQUIRED: '{{logicalId}} 的 {{fields}} 变更需要替换资源。暂不支持自动替换,请显式迁移或重建资源。',
12
+ PLAN_UPDATE_NOT_SUPPORTED: '无法更新 {{logicalId}} 的 {{fields}}:当前云厂商更新实现不支持这些属性。尚未执行任何变更。',
13
+ PLAN_STATE_ONLY: '{{logicalId}} 已与云端一致,仅更新保存的配置意图。',
5
14
  // Validation messages
6
15
  VALIDATING_YAML: '正在验证 yaml...',
7
16
  YAML_VALID: 'Yaml 有效! 🎉',
@@ -121,7 +130,7 @@ exports.zhCN = {
121
130
  PLAN_COMPUTED_VALUE: '(部署后可知)',
122
131
  PLAN_REVERT_ANNOTATION: '(云端已改,将按配置恢复)',
123
132
  PLAN_DRIFTED_MARKER: '(云端已漂移——与本配置不一致,将按配置纠正)',
124
- PLAN_LIVE_READ_FAILED: '读取 {{logicalId}} 云端状态失败,降级为创建计划: {{error}}',
133
+ PLAN_LIVE_READ_FAILED: '读取 {{logicalId}} 云端状态失败,计划已停止: {{error}}',
125
134
  PLAN_DRIFT_ROLE_MISSING: '云端 IAM 角色缺失',
126
135
  PLAN_DRIFT_ROLE_POLICY: '云端 IAM 角色策略被修改',
127
136
  PLAN_DRIFT_LOGSTORE: '云端函数日志资源被修改',
@@ -250,8 +259,8 @@ exports.zhCN = {
250
259
  SHARED_SLS_PROJECT_ADOPTED: '采用当前应用已有的共享 SLS 项目 {{projectName}}',
251
260
  REFRESH_CACHE_HIT: '刷新读缓存命中:{{key}}',
252
261
  PLAN_FUNCTION_ROLE_MISSING: '函数 {{functionName}} 的角色 {{roleName}} 在云端不存在;部署时将重建并重新绑定',
253
- PLAN_FUNCTION_ROLE_PROBE_FAILED: '函数 {{functionName}}(角色 {{roleName}})的实时角色策略检查失败:{{error}};本次计划跳过角色漂移检测',
254
- PLAN_FUNCTION_NESTED_PROBE_FAILED: '函数 {{functionName}} 的嵌套资源探测失败:{{error}};本次计划跳过嵌套漂移检测',
262
+ PLAN_FUNCTION_ROLE_PROBE_FAILED: '函数 {{functionName}}(角色 {{roleName}})的实时角色策略检查失败:{{error}};计划已停止',
263
+ PLAN_FUNCTION_NESTED_PROBE_FAILED: '函数 {{functionName}} 的嵌套资源探测失败:{{error}};计划已停止',
255
264
  NESTED_LOGSTORE_RECREATED: '日志库 {{logstoreName}} 被带外删除,正在重建',
256
265
  NESTED_LOGSTORE_UPDATED: '日志库 {{logstoreName}} 属性已漂移,正在按 si 默认值更新',
257
266
  NESTED_TLS_TOPIC_UPDATED: 'TLS 日志主题 {{topicId}} 的 ttl 已漂移,正在按 si 默认值更新',
@@ -887,7 +896,7 @@ exports.zhCN = {
887
896
  TIMER_TRIGGER_DELETED: "定时触发器 '{{triggerName}}' 已删除",
888
897
  TIMER_TRIGGER_NOT_FOUND: "定时触发器 '{{triggerName}}' 在云平台中不存在,跳过删除",
889
898
  TIMER_TRIGGER_ALREADY_ATTACHED: "定时触发器 '{{triggerName}}' 已挂在函数 '{{functionName}}' 上,跳过创建",
890
- PLAN_DRIFT_TIMER_TRIGGER: '云端定时触发器被修改',
899
+ PLAN_DRIFT_TIMER_TRIGGER: '定时触发器与请求配置不同',
891
900
  PLAN_TIMER_TRIGGER_PROBE_FAILED: "探测函数 '{{functionName}}' 的定时触发器失败:{{error}}",
892
901
  // si-cron messages (issue #258)
893
902
  SI_CRON_EMPTY: 'si-cron 表达式为空',
@@ -1008,11 +1017,26 @@ exports.zhCN = {
1008
1017
  OTS_ATTRIBUTE_NOT_FOUND: '找不到 key 对应的属性:{{key}}',
1009
1018
  LOCAL_HANDLER_NOT_FOUND: '在 {{handlerPath}} 中找不到 Handler "{{handlerMethod}}",或它不是函数',
1010
1019
  LOCAL_EXECUTION_TIMEOUT: '函数执行超时({{timeoutMs}}ms)',
1020
+ LOCAL_FUNCTION_NOT_FOUND: '找不到函数',
1021
+ LOCAL_FUNCTION_CODE_MISSING: '找不到函数代码配置',
1022
+ LOCAL_FUNCTION_EXECUTION_FAILED: '函数执行失败',
1023
+ LOCAL_HTTP_PROVIDER_UNSUPPORTED: '不支持 provider {{provider}} 的本地 HTTP 调用',
1024
+ LOCAL_VOLCENGINE_MODE_UNSUPPORTED: '本地 veFaaS HTTP 调用仅支持 node14/v1 和 node20/v1 代码包(函数:{{functionName}})。暂不模拟容器、原生运行时及其他语言。',
1025
+ LOCAL_VOLCENGINE_BINARY_UNSUPPORTED: '本地 veFaaS HTTP 调用仅支持 UTF-8 请求体。暂不模拟包含无效 UTF-8 的二进制请求体,也不假定 base64 事件协议。',
1026
+ LOCAL_VOLCENGINE_INVALID_RESPONSE: '本地 veFaaS 响应无效:请返回对象,可包含整数 statusCode(200-599)、字符串值的 headers 和字符串 body。暂不模拟二进制响应。',
1027
+ LOCAL_EVENT_TYPE_UNSUPPORTED: '本地事件端点仅支持 API_GATEWAY 触发器。',
1028
+ LOCAL_SCF_EVENT_UNSUPPORTED: '本地 SCF 模拟覆盖函数所属的函数 URL,而非 API Gateway 事件(未部署腾讯云 API 网关)。请在 /si_functions/<function-key>/<path> 调用函数 URL。',
1029
+ LOCAL_SCF_MODE_UNSUPPORTED: '本地 SCF HTTP 调用仅支持 {{runtimes}} 代码包(函数:{{functionName}})。暂不模拟容器、Web 函数及其他语言。',
1030
+ LOCAL_SCF_BINARY_REQUEST_UNSUPPORTED: '本地 SCF HTTP 调用仅支持 UTF-8 请求体。函数 URL 事件不含 isBase64Encoded 字段,因此不模拟二进制请求体。',
1031
+ LOCAL_SCF_BINARY_RESPONSE_UNSUPPORTED: '本地 SCF 响应不支持二进制响应体:函数 URL 响应不含 isBase64Encoded 字段,因此不模拟 isBase64Encoded 响应。',
1032
+ LOCAL_SCF_INVALID_RESPONSE: '本地 SCF 响应无效:请返回字符串或 JSON 对象,或返回包含可选整数 statusCode(200-599)、字符串值 headers 与字符串 body 的对象。',
1011
1033
  LOCAL_PORT_CLOSED: '端口在收到响应前已关闭',
1012
1034
  LOCAL_WORKER_EXITED: 'Worker 退出,退出码 {{code}}',
1013
1035
  REFRESH_STATE_BUCKET: '刷新存储桶状态失败:{{name}}',
1014
1036
  RESOURCE_SPACE_ID_NOT_FOUND: '状态中不存在 Space ID:{{logicalId}}',
1015
1037
  REFRESH_STATE_ES_SPACE: '刷新 ES 空间状态失败:{{spaceId}}',
1038
+ IAM_POLICY_READ_INVALID: '策略 {{policyName}} 返回了无效的策略文档',
1039
+ SCF_HTTP_TRIGGER_ID_UNAVAILABLE: '无法记录函数 {{functionName}} 的云端 HTTP 触发器标识',
1016
1040
  SCF_HTTP_TRIGGER_ALREADY_ATTACHED: 'HTTP 触发器 {{triggerName}} 已绑定到 {{functionName}},跳过创建',
1017
1041
  SCF_HTTP_TRIGGER_ALREADY_EXISTS: 'HTTP 触发器 {{triggerName}} 在 {{functionName}} 上已存在,继续:{{error}}',
1018
1042
  SCF_HANDLER_IMMUTABLE: '腾讯云 SCF 的 Handler 不可变,无法在更新时修改({{oldHandler}} -> {{newHandler}})。请删除后重建函数。',
@@ -16,6 +16,7 @@ const parseEvent = (events) => {
16
16
  domain: event.domain
17
17
  ? {
18
18
  ...event.domain,
19
+ protocol: event.domain.protocol ?? 'HTTP',
19
20
  www_bind_apex: (0, parseUtils_1.parseBooleanWithDefault)(event.domain.www_bind_apex, false),
20
21
  }
21
22
  : undefined,
@@ -129,7 +129,7 @@ const parseFunction = (functions) => {
129
129
  }
130
130
  : undefined,
131
131
  environment: func.environment,
132
- log: (0, parseUtils_1.parseBoolean)(func.log),
132
+ log: (0, parseUtils_1.parseBooleanWithDefault)(func.log, false),
133
133
  network: func.network,
134
134
  storage: {
135
135
  disk: (0, parseUtils_1.parseNumber)(func.storage?.disk),
@@ -28,7 +28,7 @@ const executeSingleItem = async (context, item, eventsMap, serviceName, resolveR
28
28
  throw new Error(lang_1.lang.__('RESOURCE_EVENT_NOT_FOUND', { logicalId: item.logicalId }));
29
29
  }
30
30
  common_1.logger.info(lang_1.lang.__('UPDATING_RESOURCE', { resourceType: 'API Gateway resources', name: event.name }));
31
- const newState = await (0, apigwResource_1.updateApigwResource)(context, event, serviceName, resolveRoleArn, currentState);
31
+ const newState = await (0, apigwResource_1.updateApigwResource)(context, event, serviceName, resolveRoleArn, currentState, { repairDomain: item.driftReasons?.includes('PLAN_DRIFT_EVENT_DOMAIN') });
32
32
  common_1.logger.info(lang_1.lang.__('RESOURCE_UPDATED', { resourceType: 'API Gateway resources', name: event.name }));
33
33
  return newState;
34
34
  }