@geek-fun/serverlessinsight 0.5.7 → 0.5.10

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 (37) hide show
  1. package/AGENTS.md +372 -0
  2. package/README.md +2 -2
  3. package/README.zh-CN.md +11 -8
  4. package/dist/package.json +1 -1
  5. package/dist/src/commands/index.js +5 -4
  6. package/dist/src/common/aliyunClient/apigwOperations.js +96 -9
  7. package/dist/src/common/aliyunClient/ossOperations.js +68 -0
  8. package/dist/src/common/aliyunClient/ramOperations.js +65 -20
  9. package/dist/src/common/tencentClient/cosOperations.js +123 -0
  10. package/dist/src/lang/en.js +137 -0
  11. package/dist/src/lang/index.js +6 -0
  12. package/dist/src/lang/zh-CN.js +136 -0
  13. package/dist/src/stack/aliyunStack/apigwExecutor.js +15 -9
  14. package/dist/src/stack/aliyunStack/apigwPlanner.js +15 -2
  15. package/dist/src/stack/aliyunStack/apigwResource.js +3 -3
  16. package/dist/src/stack/aliyunStack/apigwTypes.js +4 -3
  17. package/dist/src/stack/aliyunStack/databaseExecutor.js +24 -9
  18. package/dist/src/stack/aliyunStack/databaseResource.js +5 -1
  19. package/dist/src/stack/aliyunStack/deployer.js +11 -2
  20. package/dist/src/stack/aliyunStack/destroyer.js +5 -1
  21. package/dist/src/stack/aliyunStack/fc3Executor.js +10 -9
  22. package/dist/src/stack/aliyunStack/fc3Resource.js +36 -27
  23. package/dist/src/stack/aliyunStack/ossExecutor.js +9 -9
  24. package/dist/src/stack/aliyunStack/ossResource.js +19 -3
  25. package/dist/src/stack/aliyunStack/tablestoreExecutor.js +21 -9
  26. package/dist/src/stack/scfStack/cosExecutor.js +9 -9
  27. package/dist/src/stack/scfStack/cosResource.js +20 -3
  28. package/dist/src/stack/scfStack/deployer.js +5 -1
  29. package/dist/src/stack/scfStack/destroyer.js +5 -1
  30. package/dist/src/stack/scfStack/esServerlessExecutor.js +21 -9
  31. package/dist/src/stack/scfStack/esServerlessResource.js +2 -1
  32. package/dist/src/stack/scfStack/scfExecutor.js +9 -9
  33. package/dist/src/stack/scfStack/scfResource.js +2 -1
  34. package/dist/src/stack/scfStack/tdsqlcExecutor.js +9 -9
  35. package/dist/src/stack/scfStack/tdsqlcResource.js +5 -1
  36. package/dist/src/validator/bucketSchema.js +4 -0
  37. package/package.json +1 -1
@@ -82,11 +82,78 @@ const createOssOperations = (ossClient, region, dnsOps) => {
82
82
  return false;
83
83
  }
84
84
  };
85
+ const buildCorsRuleForDomain = (domain) => ({
86
+ allowedOrigin: [`https://${domain}`, `http://${domain}`],
87
+ allowedMethod: ['GET', 'HEAD'],
88
+ allowedHeader: ['*'],
89
+ exposeHeader: ['ETag', 'Content-Length'],
90
+ maxAgeSeconds: '3600',
91
+ });
92
+ const isDomainCorsRule = (rule, domain) => {
93
+ const origins = Array.isArray(rule.allowedOrigin) ? rule.allowedOrigin : [rule.allowedOrigin];
94
+ const expected = new Set([`https://${domain}`, `http://${domain}`]);
95
+ return origins.length === expected.size && origins.every((o) => expected.has(o));
96
+ };
97
+ const addCorsRuleForDomain = async (bucketName, domain) => {
98
+ try {
99
+ useBucket(bucketName);
100
+ let existingRules = [];
101
+ try {
102
+ const corsResult = await ossClient.getBucketCORS(bucketName);
103
+ if (corsResult.rules && corsResult.rules.length > 0) {
104
+ existingRules = corsResult.rules;
105
+ }
106
+ }
107
+ catch {
108
+ // no existing CORS config
109
+ }
110
+ if (existingRules.some((rule) => isDomainCorsRule(rule, domain))) {
111
+ logger_1.logger.info(lang_1.lang.__('OSS_CORS_RULE_EXISTS', { domain }));
112
+ return;
113
+ }
114
+ const allRules = [...existingRules, buildCorsRuleForDomain(domain)];
115
+ await ossClient.putBucketCORS(bucketName, allRules);
116
+ logger_1.logger.info(lang_1.lang.__('OSS_CORS_RULE_ADDED', { domain }));
117
+ }
118
+ catch (error) {
119
+ logger_1.logger.warn(lang_1.lang.__('OSS_CORS_RULE_ADD_FAILED', { domain, error: String(error) }));
120
+ }
121
+ };
122
+ const removeCorsRuleForDomain = async (bucketName, domain) => {
123
+ try {
124
+ useBucket(bucketName);
125
+ let existingRules = [];
126
+ try {
127
+ const corsResult = await ossClient.getBucketCORS(bucketName);
128
+ if (corsResult.rules && corsResult.rules.length > 0) {
129
+ existingRules = corsResult.rules;
130
+ }
131
+ }
132
+ catch {
133
+ return;
134
+ }
135
+ const remainingRules = existingRules.filter((rule) => !isDomainCorsRule(rule, domain));
136
+ if (remainingRules.length === existingRules.length) {
137
+ return;
138
+ }
139
+ if (remainingRules.length > 0) {
140
+ await ossClient.putBucketCORS(bucketName, remainingRules);
141
+ }
142
+ else {
143
+ await ossClient.deleteBucketCORS(bucketName);
144
+ }
145
+ logger_1.logger.info(lang_1.lang.__('OSS_CORS_RULE_REMOVED', { domain }));
146
+ }
147
+ catch (error) {
148
+ logger_1.logger.warn(lang_1.lang.__('OSS_CORS_RULE_REMOVE_FAILED', { domain, error: String(error) }));
149
+ }
150
+ };
85
151
  const bindCustomDomain = async (bucketName, domain) => {
86
152
  const mainDomain = (0, domainUtils_1.extractMainDomain)(domain);
87
153
  const hostRecord = (0, domainUtils_1.extractHostRecord)(domain, mainDomain);
88
154
  const ossEndpoint = getOssEndpoint(bucketName);
89
155
  const bucketCnameBound = await putBucketCname(bucketName, domain);
156
+ await addCorsRuleForDomain(bucketName, domain);
90
157
  if (!dnsOps) {
91
158
  logger_1.logger.warn(lang_1.lang.__('OSS_DNS_MANUAL_CONFIG_REQUIRED', { domain, cname: ossEndpoint }));
92
159
  return { domain, cname: ossEndpoint, bucketCnameBound };
@@ -120,6 +187,7 @@ const createOssOperations = (ossClient, region, dnsOps) => {
120
187
  }
121
188
  };
122
189
  const unbindCustomDomain = async (bucketName, domain, dnsRecordId) => {
190
+ await removeCorsRuleForDomain(bucketName, domain);
123
191
  await deleteBucketCname(bucketName, domain);
124
192
  if (!dnsOps || !dnsRecordId || dnsRecordId === 'existing') {
125
193
  return;
@@ -35,6 +35,8 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.createRamOperations = void 0;
37
37
  const ram = __importStar(require("@alicloud/ram20150501"));
38
+ const lang_1 = require("../../lang");
39
+ const logger_1 = require("../logger");
38
40
  const buildAssumeRolePolicy = (trustedServices) => JSON.stringify({
39
41
  Version: '1',
40
42
  Statement: [
@@ -50,6 +52,11 @@ const buildAssumeRolePolicy = (trustedServices) => JSON.stringify({
50
52
  const FC_EXECUTION_POLICY = JSON.stringify({
51
53
  Version: '1',
52
54
  Statement: [
55
+ {
56
+ Effect: 'Allow',
57
+ Action: ['fc:InvokeFunction'],
58
+ Resource: '*',
59
+ },
53
60
  {
54
61
  Effect: 'Allow',
55
62
  Action: [
@@ -127,7 +134,6 @@ const createRamOperations = (ramClient) => {
127
134
  };
128
135
  return {
129
136
  createRole: async (roleName, trustedServices, description) => {
130
- let roleInfo;
131
137
  const assumeRolePolicy = buildAssumeRolePolicy(trustedServices);
132
138
  try {
133
139
  const request = new ram.CreateRoleRequest({
@@ -136,40 +142,79 @@ const createRamOperations = (ramClient) => {
136
142
  description: description ?? `ServerlessInsight FC execution role for ${roleName}`,
137
143
  });
138
144
  const response = await ramClient.createRole(request);
139
- roleInfo = {
145
+ const roleInfo = {
140
146
  roleName,
141
147
  roleId: response.body?.role?.roleId,
142
148
  arn: response.body?.role?.arn,
143
149
  description: response.body?.role?.description,
144
150
  createDate: response.body?.role?.createDate,
145
151
  };
152
+ await attachRolePolicyForFc(roleName);
153
+ return roleInfo;
146
154
  }
147
155
  catch (error) {
148
156
  if (error &&
149
157
  typeof error === 'object' &&
150
158
  'code' in error &&
151
159
  error.code === 'EntityAlreadyExists.Role') {
152
- const getRequest = new ram.GetRoleRequest({ roleName });
153
- const getResponse = await ramClient.getRole(getRequest);
154
- roleInfo = {
155
- roleName,
156
- roleId: getResponse.body?.role?.roleId,
157
- arn: getResponse.body?.role?.arn,
158
- description: getResponse.body?.role?.description,
159
- createDate: getResponse.body?.role?.createDate,
160
- };
161
- const updateRequest = new ram.UpdateRoleRequest({
162
- roleName,
163
- newAssumeRolePolicyDocument: assumeRolePolicy,
164
- });
165
- await ramClient.updateRole(updateRequest);
160
+ logger_1.logger.warn(lang_1.lang.__('RAM_ROLE_ALREADY_EXISTS', { roleName }));
161
+ try {
162
+ const getRequest = new ram.GetRoleRequest({ roleName });
163
+ const getResponse = await ramClient.getRole(getRequest);
164
+ const updateRequest = new ram.UpdateRoleRequest({
165
+ roleName,
166
+ newAssumeRolePolicyDocument: assumeRolePolicy,
167
+ });
168
+ await ramClient.updateRole(updateRequest);
169
+ await attachRolePolicyForFc(roleName);
170
+ return {
171
+ roleName,
172
+ roleId: getResponse.body?.role?.roleId,
173
+ arn: getResponse.body?.role?.arn,
174
+ description: getResponse.body?.role?.description,
175
+ createDate: getResponse.body?.role?.createDate,
176
+ };
177
+ }
178
+ catch (recoveryError) {
179
+ // eslint-disable-next-line preserve-caught-error
180
+ throw new Error(lang_1.lang.__('RAM_ROLE_DRIFT_RECOVERY_FAILED', {
181
+ roleName,
182
+ error: recoveryError instanceof Error ? recoveryError.message : String(recoveryError),
183
+ }));
184
+ }
166
185
  }
167
- else {
168
- throw error;
186
+ throw error;
187
+ }
188
+ },
189
+ updateRoleTrustPolicy: async (roleName, trustedServices) => {
190
+ const assumeRolePolicy = buildAssumeRolePolicy(trustedServices);
191
+ try {
192
+ const getRequest = new ram.GetRoleRequest({ roleName });
193
+ const getResponse = await ramClient.getRole(getRequest);
194
+ const roleInfo = {
195
+ roleName,
196
+ roleId: getResponse.body?.role?.roleId,
197
+ arn: getResponse.body?.role?.arn,
198
+ description: getResponse.body?.role?.description,
199
+ createDate: getResponse.body?.role?.createDate,
200
+ };
201
+ const updateRequest = new ram.UpdateRoleRequest({
202
+ roleName,
203
+ newAssumeRolePolicyDocument: assumeRolePolicy,
204
+ });
205
+ await ramClient.updateRole(updateRequest);
206
+ return roleInfo;
207
+ }
208
+ catch (error) {
209
+ if (error &&
210
+ typeof error === 'object' &&
211
+ 'code' in error &&
212
+ error.code === 'EntityNotExist.Role') {
213
+ // eslint-disable-next-line preserve-caught-error
214
+ throw new Error(lang_1.lang.__('RAM_ROLE_NOT_FOUND_IN_CLOUD', { roleName }));
169
215
  }
216
+ throw error;
170
217
  }
171
- await attachRolePolicyForFc(roleName);
172
- return roleInfo;
173
218
  },
174
219
  getRole: async (roleName) => {
175
220
  try {
@@ -8,6 +8,127 @@ const createCosOperations = (cosClient, region, dnsOps) => {
8
8
  const getCosEndpoint = (bucketName) => {
9
9
  return `${bucketName}.cos.${region}.myqcloud.com`;
10
10
  };
11
+ const buildCorsRuleForDomain = (domain) => ({
12
+ AllowedOrigin: [`https://${domain}`, `http://${domain}`],
13
+ AllowedMethod: ['GET', 'HEAD'],
14
+ AllowedHeader: ['*'],
15
+ ExposeHeader: ['ETag', 'Content-Length'],
16
+ MaxAgeSeconds: 3600,
17
+ });
18
+ const isDomainCorsRule = (rule, domain) => {
19
+ const origins = rule.AllowedOrigin || [];
20
+ const expected = new Set([`https://${domain}`, `http://${domain}`]);
21
+ return origins.length === expected.size && origins.every((o) => expected.has(o));
22
+ };
23
+ const addCorsRuleForDomain = async (bucketName, domain) => {
24
+ try {
25
+ let existingRules = [];
26
+ try {
27
+ const corsResult = await new Promise((resolve, reject) => {
28
+ cosClient.getBucketCors({ Bucket: bucketName, Region: region }, (err, data) => {
29
+ if (err)
30
+ reject(err);
31
+ else
32
+ resolve(data);
33
+ });
34
+ });
35
+ if (corsResult.CORSRules && corsResult.CORSRules.length > 0) {
36
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
+ existingRules = corsResult.CORSRules;
38
+ }
39
+ }
40
+ catch {
41
+ // no existing CORS config
42
+ }
43
+ if (existingRules.some((rule) => isDomainCorsRule(rule, domain))) {
44
+ logger_1.logger.info(lang_1.lang.__('COS_CORS_RULE_EXISTS', { domain }));
45
+ return;
46
+ }
47
+ const allRules = [...existingRules, buildCorsRuleForDomain(domain)];
48
+ await new Promise((resolve, reject) => {
49
+ cosClient.putBucketCors({
50
+ Bucket: bucketName,
51
+ Region: region,
52
+ CORSRules: allRules.map((r) => ({
53
+ AllowedOrigin: r.AllowedOrigin,
54
+ AllowedMethod: r.AllowedMethod,
55
+ AllowedHeader: r.AllowedHeader || [],
56
+ ExposeHeader: r.ExposeHeader || [],
57
+ MaxAgeSeconds: r.MaxAgeSeconds || 0,
58
+ })),
59
+ }, (err) => {
60
+ if (err)
61
+ reject(err);
62
+ else
63
+ resolve();
64
+ });
65
+ });
66
+ logger_1.logger.info(lang_1.lang.__('COS_CORS_RULE_ADDED', { domain }));
67
+ }
68
+ catch (error) {
69
+ logger_1.logger.warn(lang_1.lang.__('COS_CORS_RULE_ADD_FAILED', { domain, error: String(error) }));
70
+ }
71
+ };
72
+ const removeCorsRuleForDomain = async (bucketName, domain) => {
73
+ try {
74
+ let existingRules = [];
75
+ try {
76
+ const corsResult = await new Promise((resolve, reject) => {
77
+ cosClient.getBucketCors({ Bucket: bucketName, Region: region }, (err, data) => {
78
+ if (err)
79
+ reject(err);
80
+ else
81
+ resolve(data);
82
+ });
83
+ });
84
+ if (corsResult.CORSRules && corsResult.CORSRules.length > 0) {
85
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
86
+ existingRules = corsResult.CORSRules;
87
+ }
88
+ }
89
+ catch {
90
+ return;
91
+ }
92
+ const remainingRules = existingRules.filter((rule) => !isDomainCorsRule(rule, domain));
93
+ if (remainingRules.length === existingRules.length) {
94
+ return;
95
+ }
96
+ if (remainingRules.length > 0) {
97
+ await new Promise((resolve, reject) => {
98
+ cosClient.putBucketCors({
99
+ Bucket: bucketName,
100
+ Region: region,
101
+ CORSRules: remainingRules.map((r) => ({
102
+ AllowedOrigin: r.AllowedOrigin,
103
+ AllowedMethod: r.AllowedMethod,
104
+ AllowedHeader: r.AllowedHeader || [],
105
+ ExposeHeader: r.ExposeHeader || [],
106
+ MaxAgeSeconds: r.MaxAgeSeconds || 0,
107
+ })),
108
+ }, (err) => {
109
+ if (err)
110
+ reject(err);
111
+ else
112
+ resolve();
113
+ });
114
+ });
115
+ }
116
+ else {
117
+ await new Promise((resolve, reject) => {
118
+ cosClient.deleteBucketCors({ Bucket: bucketName, Region: region }, (err) => {
119
+ if (err)
120
+ reject(err);
121
+ else
122
+ resolve();
123
+ });
124
+ });
125
+ }
126
+ logger_1.logger.info(lang_1.lang.__('COS_CORS_RULE_REMOVED', { domain }));
127
+ }
128
+ catch (error) {
129
+ logger_1.logger.warn(lang_1.lang.__('COS_CORS_RULE_REMOVE_FAILED', { domain, error: String(error) }));
130
+ }
131
+ };
11
132
  const bindCustomDomain = async (bucketName, domain) => {
12
133
  const mainDomain = (0, domainUtils_1.extractMainDomain)(domain);
13
134
  const hostRecord = (0, domainUtils_1.extractHostRecord)(domain, mainDomain);
@@ -40,6 +161,7 @@ const createCosOperations = (cosClient, region, dnsOps) => {
40
161
  catch (error) {
41
162
  logger_1.logger.warn(lang_1.lang.__('COS_BUCKET_DOMAIN_BIND_FAILED', { error: String(error) }));
42
163
  }
164
+ await addCorsRuleForDomain(bucketName, domain);
43
165
  if (!dnsOps) {
44
166
  logger_1.logger.warn(lang_1.lang.__('COS_DNS_MANUAL_CONFIG_REQUIRED', { domain, cname: cosEndpoint }));
45
167
  return { domain, cname: cosEndpoint, bucketDomainBound };
@@ -73,6 +195,7 @@ const createCosOperations = (cosClient, region, dnsOps) => {
73
195
  }
74
196
  };
75
197
  const unbindCustomDomain = async (bucketName, domain, dnsRecordId) => {
198
+ await removeCorsRuleForDomain(bucketName, domain);
76
199
  try {
77
200
  const existingRules = await new Promise((resolve, reject) => {
78
201
  cosClient.getBucketDomain({
@@ -240,6 +240,10 @@ exports.en = {
240
240
  APIGW_DOMAIN_BIND_RETRY: 'Retrying domain binding (attempt {{attempt}}/{{max}}, waiting for DNS propagation)...',
241
241
  APIGW_DOMAIN_BIND_RETRY_FAILED: 'Domain binding retry {{attempt}} failed: {{error}}',
242
242
  APIGW_DOMAIN_BOUND_AFTER_VERIFICATION: 'Successfully bound domain after verification: {{domain}}',
243
+ APIGW_DOMAIN_BIND_TIMEOUT_RETRY: 'Domain binding request timed out, retrying (attempt {{attempt}}/{{max}})...',
244
+ APIGW_DOMAIN_BIND_TIMEOUT_RETRY_FAILED: 'Domain binding timeout retry {{attempt}} failed: {{error}}',
245
+ APIGW_DOMAIN_BIND_TIMEOUT_ALL_FAILED: 'Domain binding failed after {{max}} timeout retries: {{error}}',
246
+ APIGW_DOMAIN_BIND_ALREADY_BOUND: 'Domain {{domain}} is already bound (previous request likely succeeded), proceeding with certificate setup',
243
247
  APIGW_VERIFICATION_HEADER: 'Domain Ownership Verification Required',
244
248
  APIGW_VERIFICATION_DOMAIN: 'Domain: {{domain}}',
245
249
  APIGW_VERIFICATION_INSTRUCTIONS: 'To verify domain ownership, add ONE of the following DNS records:',
@@ -272,6 +276,11 @@ exports.en = {
272
276
  OSS_BUCKET_CNAME_BIND_FAILED: 'Failed to bind bucket CNAME: {{error}}',
273
277
  OSS_BUCKET_CNAME_UNBIND_FAILED: 'Failed to unbind bucket CNAME: {{error}}',
274
278
  OSS_BUCKET_CNAME_NEED_VERIFY: 'Domain ownership verification required. Please add TXT record in DNS console, then retry.',
279
+ OSS_CORS_RULE_ADDED: 'Added CORS rule for custom domain: {{domain}}',
280
+ OSS_CORS_RULE_EXISTS: 'CORS rule already exists for custom domain: {{domain}}',
281
+ OSS_CORS_RULE_ADD_FAILED: 'Failed to add CORS rule for {{domain}}: {{error}}',
282
+ OSS_CORS_RULE_REMOVED: 'Removed CORS rule for custom domain: {{domain}}',
283
+ OSS_CORS_RULE_REMOVE_FAILED: 'Failed to remove CORS rule for {{domain}}: {{error}}',
275
284
  // Tencent COS DNS messages
276
285
  COS_DNS_CNAME_CREATED: 'Created DNS CNAME record: {{domain}} -> {{cname}}',
277
286
  COS_DNS_CNAME_EXISTS: 'DNS CNAME record already exists: {{domain}} -> {{cname}}',
@@ -284,9 +293,137 @@ exports.en = {
284
293
  COS_BUCKET_DOMAIN_BIND_FAILED: 'Failed to bind bucket domain: {{error}}',
285
294
  COS_BUCKET_DOMAIN_UNBOUND: 'Unbound custom domain from bucket: {{domain}}',
286
295
  COS_BUCKET_DOMAIN_UNBIND_FAILED: 'Failed to unbind bucket domain: {{error}}',
296
+ COS_CORS_RULE_ADDED: 'Added CORS rule for custom domain: {{domain}}',
297
+ COS_CORS_RULE_EXISTS: 'CORS rule already exists for custom domain: {{domain}}',
298
+ COS_CORS_RULE_ADD_FAILED: 'Failed to add CORS rule for {{domain}}: {{error}}',
299
+ COS_CORS_RULE_REMOVED: 'Removed CORS rule for custom domain: {{domain}}',
300
+ COS_CORS_RULE_REMOVE_FAILED: 'Failed to remove CORS rule for {{domain}}: {{error}}',
287
301
  // Dependency graph messages
288
302
  DEPENDENCY_GRAPH_GENERATED: 'Dependency graph generated',
289
303
  EXECUTION_ORDER: 'Execution order',
290
304
  DOT_GRAPH_OUTPUT: 'DOT graph output',
291
305
  CYCLE_DETECTED: 'Circular dependency detected',
306
+ // Generic executor messages
307
+ CREATING_RESOURCE: 'Creating {{resourceType}}: {{name}}',
308
+ RESOURCE_CREATED: 'Successfully created {{resourceType}}: {{name}}',
309
+ UPDATING_RESOURCE: 'Updating {{resourceType}}: {{name}}',
310
+ RESOURCE_UPDATED: 'Successfully updated {{resourceType}}: {{name}}',
311
+ DELETING_RESOURCE: 'Deleting {{resourceType}}: {{name}}',
312
+ RESOURCE_DELETED: 'Successfully deleted {{resourceType}}: {{name}}',
313
+ NO_CHANGESForResource: 'No changes for {{logicalId}}',
314
+ STATE_NOT_FOUND_SKIPPING: 'State not found for {{logicalId}}, skipping deletion',
315
+ UNKNOWN_ACTION_FOR_RESOURCE: 'Unknown action: {{action}} for {{logicalId}}',
316
+ RESOURCE_NOT_FOUND_PROVIDER: '{{resourceType}} {{name}} not found in provider, skipping deletion',
317
+ // FC3 Resource bootstrap messages
318
+ CREATING_BOOTSTRAP_BUCKET: 'Creating bootstrap OSS bucket: {{bucketName}}',
319
+ UPLOADED_CODE_TO_OSS: 'Uploaded code to oss://{{bucketName}}/{{objectName}}',
320
+ CREATING_SLS_PROJECT: 'Creating SLS project: {{projectName}}',
321
+ CREATING_SLS_LOGSTORE: 'Creating SLS logstore: {{logstoreName}}',
322
+ CREATING_SLS_INDEX: 'Creating SLS index for: {{logstoreName}}',
323
+ CREATING_RAM_ROLE: 'Creating RAM role: {{roleName}}',
324
+ CREATING_SECURITY_GROUP: 'Creating security group: {{sgName}}',
325
+ CREATING_NAS_ACCESS_GROUP: 'Creating NAS access group: {{accessGroupName}}',
326
+ CREATING_NAS_ACCESS_RULE: 'Creating NAS access rule for: {{accessGroupName}}',
327
+ CREATING_NAS_FILE_SYSTEM: 'Creating NAS file system for: {{name}}',
328
+ CREATING_NAS_MOUNT_TARGET: 'Creating NAS mount target for: {{fileSystemId}}',
329
+ DELETING_NAS_MOUNT_TARGET: 'Deleting NAS mount target: {{id}}',
330
+ DELETING_NAS_FILE_SYSTEM: 'Deleting NAS file system: {{id}}',
331
+ DELETING_NAS_ACCESS_GROUP: 'Deleting NAS access group: {{id}}',
332
+ DELETING_SECURITY_GROUP: 'Deleting security group: {{id}}',
333
+ DELETING_RAM_ROLE: 'Deleting RAM role: {{id}}',
334
+ DELETING_SLS_INDEX: 'Deleting SLS index: {{id}}',
335
+ DELETING_SLS_LOGSTORE: 'Deleting SLS logstore: {{id}}',
336
+ DELETING_SLS_PROJECT: 'Deleting SLS project: {{id}}',
337
+ UNKNOWN_RESOURCE_TYPE: 'Unknown resource type: {{type}}',
338
+ FAILED_TO_DELETE_RESOURCE: 'Failed to delete resource {{type}}:{{id}}: {{error}}',
339
+ // OSS Resource messages
340
+ BINDING_CUSTOM_DOMAIN_TO_BUCKET: 'Binding custom domain {{domain}} to bucket {{bucketName}}',
341
+ // API Gateway Resource messages
342
+ COULD_NOT_FIND_GROUP_CREATING: 'Could not find existing group, creating new: {{error}}',
343
+ DELETING_DNS_RECORD: 'Deleting DNS record: {{recordId}}',
344
+ DNS_RECORD_DELETED: 'Successfully deleted DNS record: {{recordId}}',
345
+ FAILED_TO_DELETE_DNS_RECORD: 'Failed to delete DNS record {{recordId}}: {{error}}',
346
+ // API Gateway Types messages
347
+ CANNOT_RESOLVE_FUNCTION_REF: 'Cannot resolve function reference {{backendRef}}: IAC not available in context',
348
+ FUNCTION_REF_NOT_RESOLVED: 'Function reference {{backendRef}} could not be resolved from IAC',
349
+ RESOLVED_FUNCTION_REF: 'Resolved function reference {{backendRef}} to function name: {{functionName}}',
350
+ // Show command messages
351
+ LOADING_STATE_FOR: 'Loading state for app: {{app}}, service: {{service}}, stage: {{stage}}...',
352
+ NO_RESOURCES_FOUND: 'No resources found in state.',
353
+ STATE_LOCATION: 'State location: {{location}}',
354
+ BACKEND_REMOTE: 'Backend: Remote',
355
+ DEPLOYED_RESOURCES: 'DEPLOYED RESOURCES',
356
+ SUMMARY: 'SUMMARY',
357
+ PROVIDER_LABEL: 'Provider',
358
+ APP_LABEL: 'App',
359
+ SERVICE_LABEL: 'Service',
360
+ STAGE_LABEL: 'Stage',
361
+ RESOURCES_LABEL: 'Resources',
362
+ LAST_UPDATED_LABEL: 'Last Updated',
363
+ LOCK_STATUS_LOCKED: 'Lock Status: LOCKED by {{user}}',
364
+ LOCK_STATUS_UNLOCKED: 'Lock Status: UNLOCKED',
365
+ TO_DEPLOY_RESOURCES: 'To deploy resources, run: si deploy',
366
+ REMOTE_BACKEND_FALLBACK: 'Remote backend configured but credentials not available. Falling back to local state.',
367
+ FAILED_TO_LOAD_REMOTE_STATE: 'Failed to load state from remote backend, falling back to local state: {{error}}',
368
+ // Show command category labels
369
+ FUNCTIONS_LABEL: 'Functions',
370
+ API_GATEWAY_LABEL: 'API Gateway',
371
+ STORAGE_LABEL: 'Storage',
372
+ DATABASES_LABEL: 'Databases',
373
+ DNS_RECORDS_LABEL: 'DNS Records',
374
+ OTHER_RESOURCES_LABEL: 'Other Resources',
375
+ // Show command resource output labels
376
+ RUNTIME_LABEL: 'Runtime',
377
+ HANDLER_LABEL: 'Handler',
378
+ MEMORY_TIMEOUT_LABEL: 'Memory: {{memory}}MB, Timeout: {{timeout}}s',
379
+ INTERNET_ACCESS_LABEL: 'Internet Access: {{value}}',
380
+ API_GROUP_LABEL: 'API Group',
381
+ SUB_DOMAIN_LABEL: 'Sub-domain',
382
+ BASE_PATH_LABEL: 'Base Path',
383
+ API_LABEL: 'API',
384
+ GROUP_ID_LABEL: 'Group ID',
385
+ BUCKET_LABEL: 'Bucket',
386
+ REGION_LABEL: 'Region',
387
+ ENDPOINT_LABEL: 'Endpoint',
388
+ CUSTOM_DOMAIN_LABEL: 'Custom Domain',
389
+ CNAME_TARGET_LABEL: 'CNAME Target',
390
+ ENGINE_LABEL: 'Engine',
391
+ STATUS_LABEL: 'Status',
392
+ CNAME_LABEL: 'CNAME',
393
+ // Time ago format
394
+ TIME_DAYS_AGO: '{{count}} day(s) ago',
395
+ TIME_HOURS_AGO: '{{count}} hour(s) ago',
396
+ TIME_MINUTES_AGO: '{{count}} minute(s) ago',
397
+ TIME_JUST_NOW: 'just now',
398
+ // Deployer/Destroyer execution plan
399
+ EXECUTION_PLAN_ITEM: ' - {{action}}: {{logicalId}} ({{resourceType}})',
400
+ EXECUTION_ORDER_ITEM: ' {{index}}. {{logicalId}} ({{resourceType}}) - {{action}}',
401
+ // Tablestore operations
402
+ TABLE_IS_READY: 'Table {{tableName}} is ready',
403
+ FAILED_TO_CREATE_TABLE: 'Failed to create table {{tableName}}: {{error}}',
404
+ TABLE_CREATED_SUCCESS: 'Successfully created table {{tableName}}',
405
+ FAILED_TO_DESCRIBE_TABLE: 'Failed to describe table {{tableName}}: {{error}}',
406
+ FAILED_TO_UPDATE_TABLE: 'Failed to update table {{tableName}}: {{error}}',
407
+ TABLE_UPDATED_SUCCESS: 'Successfully updated table {{tableName}}',
408
+ TABLE_ALREADY_DELETED: 'Table {{tableName}} already deleted or does not exist',
409
+ FAILED_TO_DELETE_TABLE: 'Failed to delete table {{tableName}}: {{error}}',
410
+ TABLE_DELETED_SUCCESS: 'Successfully deleted table {{tableName}}',
411
+ // ECS operations
412
+ SKIPPING_INVALID_INGRESS_RULE: 'Skipping invalid ingress rule: {{rule}}. {{error}}',
413
+ INGRESS_RULE_EXISTS_SKIPPING: 'Ingress rule already exists, skipping: {{rule}}',
414
+ FAILED_TO_ADD_INGRESS_RULE: 'Failed to add ingress rule: {{rule}}. {{error}}',
415
+ SKIPPING_INVALID_EGRESS_RULE: 'Skipping invalid egress rule: {{rule}}. {{error}}',
416
+ EGRESS_RULE_EXISTS_SKIPPING: 'Egress rule already exists, skipping: {{rule}}',
417
+ FAILED_TO_ADD_EGRESS_RULE: 'Failed to add egress rule: {{rule}}. {{error}}',
418
+ // DNS error
419
+ DNS_ERROR: 'DNS error: {{error}}',
420
+ // RAM operations
421
+ RAM_ROLE_ALREADY_EXISTS: 'RAM role "{{roleName}}" already exists in cloud (state drift detected). ' +
422
+ 'Updating trust policy and reusing existing role.',
423
+ RAM_ROLE_NOT_FOUND_IN_CLOUD: 'RAM role "{{roleName}}" does not exist in the cloud provider. ' +
424
+ 'The role may have been deleted manually. ' +
425
+ 'To fix: remove the role from state and redeploy.',
426
+ RAM_ROLE_DRIFT_RECOVERY_FAILED: 'Failed to recover from RAM role state drift for "{{roleName}}": {{error}}. ' +
427
+ 'The role existed in the cloud but recovery operations failed. ' +
428
+ 'To fix: manually verify the role in the cloud console, remove it from state, and redeploy.',
292
429
  };
@@ -5,6 +5,12 @@ const child_process_1 = require("child_process");
5
5
  const i18n_1 = require("i18n");
6
6
  const en_1 = require("./en");
7
7
  const zh_CN_1 = require("./zh-CN");
8
+ // Disable Mustache's default HTML escaping — i18n uses Mustache internally for
9
+ // template interpolation ({{var}}), which HTML-encodes values (/ → / etc.).
10
+ // This is correct for web output but wrong for CLI terminal output.
11
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
12
+ const mustache = require('mustache');
13
+ mustache.escape = (text) => text;
8
14
  const getSystemLanguage = (defaultLang) => {
9
15
  const langMatch = (process.env.LANG || process.env.LC_ALL || '').match(/([a-z]{2})[-_]?([A-Z]{2})?/);
10
16
  if (langMatch) {