@geek-fun/serverlessinsight 0.8.1 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/.serverlessinsight/state-cdn-flow-app-cdn-flow-service.json.backup +14 -0
  2. package/.serverlessinsight/state-iam-test-app-iam-test-service.json.backup +14 -0
  3. package/.serverlessinsight/state-insight-poc-deploy-app-insight-poc-deploy.json.backup +348 -0
  4. package/.serverlessinsight/state-insight-poc-destroy-app-insight-poc-destroy.json.backup +14 -0
  5. package/.serverlessinsight/state-insight-volc-app-insight-volc.json.backup +114 -0
  6. package/.serverlessinsight/state-insight-volc-destroy-app-insight-volc-destroy.json.backup +1 -0
  7. package/README.md +26 -18
  8. package/README.zh-CN.md +19 -6
  9. package/dist/package.json +3 -1
  10. package/dist/src/commands/deploy.js +87 -4
  11. package/dist/src/commands/destroy.js +61 -10
  12. package/dist/src/commands/forceUnlock.js +8 -0
  13. package/dist/src/commands/index.js +34 -2
  14. package/dist/src/commands/login.js +195 -0
  15. package/dist/src/commands/logout.js +17 -0
  16. package/dist/src/commands/show.js +15 -7
  17. package/dist/src/commands/whoami.js +20 -0
  18. package/dist/src/common/aliyunClient/apigwOperations.js +332 -32
  19. package/dist/src/common/aliyunClient/esOperations.js +43 -29
  20. package/dist/src/common/aliyunClient/fc3Operations.js +481 -207
  21. package/dist/src/common/aliyunClient/ossOperations.js +165 -13
  22. package/dist/src/common/aliyunClient/rdsOperations.js +143 -39
  23. package/dist/src/common/aliyunClient/slsOperations.js +56 -26
  24. package/dist/src/common/aliyunClient/tablestoreOperations.js +25 -22
  25. package/dist/src/common/apiClient.js +102 -0
  26. package/dist/src/common/constants.js +9 -4
  27. package/dist/src/common/credentialStore.js +94 -0
  28. package/dist/src/common/credentials.js +2 -0
  29. package/dist/src/common/eventQueue.js +208 -0
  30. package/dist/src/common/hashUtils.js +87 -11
  31. package/dist/src/common/imsClient.js +1 -0
  32. package/dist/src/common/index.js +3 -0
  33. package/dist/src/common/lockManager.js +61 -54
  34. package/dist/src/common/logger.js +2 -0
  35. package/dist/src/common/polling.js +54 -0
  36. package/dist/src/common/reportResourceEvent.js +8 -0
  37. package/dist/src/common/runtimeMapper.js +11 -12
  38. package/dist/src/common/stateBackend/index.js +10 -1
  39. package/dist/src/common/stateBackend/localStateBackend.js +4 -1
  40. package/dist/src/common/stateBackend/remoteStateBackend.js +6 -3
  41. package/dist/src/common/stateBackend/saasStateBackend.js +266 -0
  42. package/dist/src/common/stateManager.js +135 -13
  43. package/dist/src/common/tencentClient/cosOperations.js +180 -3
  44. package/dist/src/common/tencentClient/esOperations.js +110 -46
  45. package/dist/src/common/tencentClient/index.js +22 -1
  46. package/dist/src/common/tencentClient/scfOperations.js +255 -133
  47. package/dist/src/common/tencentClient/tdsqlcClusterMapper.js +81 -0
  48. package/dist/src/common/tencentClient/tdsqlcOperations.js +93 -99
  49. package/dist/src/common/triggerMapper.js +36 -0
  50. package/dist/src/common/volcengineClient/apigwOperations.js +539 -159
  51. package/dist/src/common/volcengineClient/iamOperations.js +58 -48
  52. package/dist/src/common/volcengineClient/index.js +46 -21
  53. package/dist/src/common/volcengineClient/stsOperations.js +32 -0
  54. package/dist/src/common/volcengineClient/tlsOperations.js +229 -178
  55. package/dist/src/common/volcengineClient/tosOperations.js +78 -19
  56. package/dist/src/common/volcengineClient/vefaasOperations.js +272 -54
  57. package/dist/src/lang/en.js +84 -0
  58. package/dist/src/lang/zh-CN.js +84 -0
  59. package/dist/src/parser/eventParser.js +2 -0
  60. package/dist/src/parser/functionParser.js +96 -65
  61. package/dist/src/parser/index.js +7 -4
  62. package/dist/src/stack/aliyunStack/apigwExecutor.js +39 -1
  63. package/dist/src/stack/aliyunStack/apigwPlanner.js +14 -10
  64. package/dist/src/stack/aliyunStack/apigwResource.js +230 -125
  65. package/dist/src/stack/aliyunStack/apigwTypes.js +16 -3
  66. package/dist/src/stack/aliyunStack/databaseExecutor.js +39 -1
  67. package/dist/src/stack/aliyunStack/databasePlanner.js +13 -1
  68. package/dist/src/stack/aliyunStack/databaseResource.js +135 -40
  69. package/dist/src/stack/aliyunStack/deployer.js +2 -2
  70. package/dist/src/stack/aliyunStack/destroyer.js +2 -2
  71. package/dist/src/stack/aliyunStack/fc3Executor.js +25 -2
  72. package/dist/src/stack/aliyunStack/fc3Planner.js +11 -1
  73. package/dist/src/stack/aliyunStack/fc3Resource.js +327 -64
  74. package/dist/src/stack/aliyunStack/ossExecutor.js +39 -1
  75. package/dist/src/stack/aliyunStack/ossPlanner.js +15 -1
  76. package/dist/src/stack/aliyunStack/ossResource.js +267 -219
  77. package/dist/src/stack/aliyunStack/tablestoreExecutor.js +39 -1
  78. package/dist/src/stack/aliyunStack/tablestorePlanner.js +13 -1
  79. package/dist/src/stack/aliyunStack/tablestoreResource.js +54 -20
  80. package/dist/src/stack/alreadyExists.js +26 -0
  81. package/dist/src/stack/ownershipTag.js +40 -0
  82. package/dist/src/stack/rfsStack/index.js +3 -1
  83. package/dist/src/stack/scfStack/cosExecutor.js +39 -1
  84. package/dist/src/stack/scfStack/cosPlanner.js +11 -1
  85. package/dist/src/stack/scfStack/cosResource.js +167 -64
  86. package/dist/src/stack/scfStack/deployer.js +2 -2
  87. package/dist/src/stack/scfStack/destroyer.js +2 -2
  88. package/dist/src/stack/scfStack/esServerlessExecutor.js +39 -1
  89. package/dist/src/stack/scfStack/esServerlessPlanner.js +11 -1
  90. package/dist/src/stack/scfStack/esServerlessResource.js +88 -23
  91. package/dist/src/stack/scfStack/scfExecutor.js +39 -1
  92. package/dist/src/stack/scfStack/scfPlanner.js +12 -2
  93. package/dist/src/stack/scfStack/scfResource.js +484 -14
  94. package/dist/src/stack/scfStack/tdsqlcExecutor.js +39 -1
  95. package/dist/src/stack/scfStack/tdsqlcPlanner.js +12 -1
  96. package/dist/src/stack/scfStack/tdsqlcResource.js +95 -16
  97. package/dist/src/stack/scfStack/tdsqlcTypes.js +5 -1
  98. package/dist/src/stack/volcengineStack/apigwExecutor.js +39 -1
  99. package/dist/src/stack/volcengineStack/apigwPlanner.js +25 -53
  100. package/dist/src/stack/volcengineStack/apigwResource.js +418 -222
  101. package/dist/src/stack/volcengineStack/apigwTypes.js +76 -66
  102. package/dist/src/stack/volcengineStack/deployer.js +49 -14
  103. package/dist/src/stack/volcengineStack/destroyer.js +1 -1
  104. package/dist/src/stack/volcengineStack/index.js +1 -2
  105. package/dist/src/stack/volcengineStack/tosExecutor.js +25 -2
  106. package/dist/src/stack/volcengineStack/tosPlanner.js +11 -1
  107. package/dist/src/stack/volcengineStack/tosResource.js +82 -27
  108. package/dist/src/stack/volcengineStack/tosTypes.js +12 -0
  109. package/dist/src/stack/volcengineStack/vefaasExecutor.js +25 -2
  110. package/dist/src/stack/volcengineStack/vefaasPlanner.js +71 -2
  111. package/dist/src/stack/volcengineStack/vefaasResource.js +148 -98
  112. package/dist/src/stack/volcengineStack/vefaasTypes.js +1 -3
  113. package/dist/src/types/domains/backend.js +1 -0
  114. package/dist/src/types/domains/state.js +29 -1
  115. package/dist/src/validator/eventSchema.js +10 -0
  116. package/dist/src/validator/functionSchema.js +37 -12
  117. package/dist/src/validator/iacSchema.js +1 -0
  118. package/dist/tsconfig.tsbuildinfo +1 -1
  119. package/package.json +3 -1
@@ -1,143 +1,265 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createScfOperations = void 0;
4
- const createScfOperations = (scfClient) => ({
5
- createFunction: async (config, codeBase64) => {
6
- const params = {
7
- FunctionName: config.FunctionName,
8
- Code: {
9
- ZipFile: codeBase64,
10
- },
11
- Handler: config.Handler,
12
- Runtime: config.Runtime,
13
- MemorySize: config.MemorySize,
14
- Timeout: config.Timeout,
15
- ...(config.Role && { Role: config.Role }),
16
- ...(config.Environment && { Environment: config.Environment }),
17
- };
18
- await scfClient.CreateFunction(params);
19
- },
20
- getFunction: async (functionName) => {
21
- try {
4
+ const polling_1 = require("../polling");
5
+ const constants_1 = require("../constants");
6
+ const createScfOperations = (scfClient, deps) => {
7
+ const { tag: tagClient, cam: camClient, region, namespace } = deps;
8
+ const getAccountUin = async () => {
9
+ // Tag-service ARNs address the resource by its owning account. For
10
+ // sub-account (CAM key) callers, Uin is the sub-account while OwnerUin is
11
+ // the main account that actually owns the resources — the tag service
12
+ // validates against OwnerUin (verified empirically).
13
+ const res = await camClient.GetUserAppId(null);
14
+ const uin = res?.OwnerUin || res?.Uin;
15
+ if (!uin) {
16
+ throw new Error('Failed to resolve Tencent Cloud account Uin for resource tagging');
17
+ }
18
+ return uin;
19
+ };
20
+ const tagFunction = async (functionName, tags) => {
21
+ if (tags.length === 0)
22
+ return;
23
+ const uin = await getAccountUin();
24
+ const resource = `qcs::scf:${region}:uin/${uin}:namespace/${namespace}/function/${functionName}`;
25
+ await tagClient.TagResources({
26
+ ResourceList: [resource],
27
+ Tags: tags.map((t) => ({ TagKey: t.Key, TagValue: t.Value })),
28
+ });
29
+ };
30
+ const operations = {
31
+ waitForFunctionActive: async (functionName) => (0, polling_1.pollUntil)({
32
+ description: `SCF function ${functionName} to become Active`,
33
+ fetch: () => operations.getFunction(functionName),
34
+ isDone: (info) => info?.Status === 'Active',
35
+ intervalMs: constants_1.SCF_STATUS_POLL_INTERVAL_MS,
36
+ maxAttempts: constants_1.SCF_STATUS_POLL_MAX_ATTEMPTS,
37
+ }),
38
+ waitForFunctionDeleted: async (functionName) => {
39
+ await (0, polling_1.pollUntil)({
40
+ description: `SCF function ${functionName} to be deleted`,
41
+ fetch: () => operations.getFunction(functionName),
42
+ isDone: (info) => info === null,
43
+ intervalMs: constants_1.SCF_STATUS_POLL_INTERVAL_MS,
44
+ maxAttempts: constants_1.SCF_STATUS_POLL_MAX_ATTEMPTS,
45
+ });
46
+ },
47
+ createFunction: async (config, codeBase64) => {
22
48
  const params = {
23
- FunctionName: functionName,
49
+ FunctionName: config.FunctionName,
50
+ Code: {
51
+ ZipFile: codeBase64,
52
+ },
53
+ Handler: config.Handler,
54
+ Runtime: config.Runtime,
55
+ MemorySize: config.MemorySize,
56
+ Timeout: config.Timeout,
57
+ ...(config.Role && { Role: config.Role }),
58
+ ...(config.Environment && { Environment: config.Environment }),
24
59
  };
25
- const response = await scfClient.GetFunction(params);
26
- if (!response || !response.FunctionName) {
27
- return null;
60
+ await scfClient.CreateFunction(params);
61
+ // CreateFunction is async on Tencent SCF — the function stays in 'Creating'
62
+ // until the platform finishes provisioning. Follow-up calls (e.g.
63
+ // CreateTrigger) fail with "Status is Creating, unsupport operate" if issued
64
+ // too early, so poll until Active before returning.
65
+ await operations.waitForFunctionActive(params.FunctionName);
66
+ // CreateFunction's Tags param is silently dropped by the API (verified
67
+ // empirically — GetFunction returns [] even when Tags was sent). Ownership
68
+ // tags must be attached via the tag service's TagResources with the
69
+ // namespace-qualified ARN, otherwise adoption can never verify ownership.
70
+ if (config.Tags && config.Tags.length > 0) {
71
+ await tagFunction(params.FunctionName, config.Tags);
28
72
  }
29
- const environment = response.Environment?.Variables
30
- ? {
31
- Variables: response.Environment.Variables.map((v) => ({
32
- Key: v.Key || '',
33
- Value: v.Value || '',
34
- })),
73
+ },
74
+ getFunction: async (functionName) => {
75
+ try {
76
+ const params = {
77
+ FunctionName: functionName,
78
+ };
79
+ const response = await scfClient.GetFunction(params);
80
+ if (!response || !response.FunctionName) {
81
+ return null;
82
+ }
83
+ const environment = response.Environment?.Variables
84
+ ? {
85
+ Variables: response.Environment.Variables.map((v) => ({
86
+ Key: v.Key || '',
87
+ Value: v.Value || '',
88
+ })),
89
+ }
90
+ : undefined;
91
+ const triggers = response.Triggers?.map((t) => ({
92
+ ModTime: t.ModTime || '',
93
+ Type: t.Type || '',
94
+ TriggerDesc: t.TriggerDesc || '',
95
+ TriggerName: t.TriggerName || '',
96
+ AddTime: t.AddTime || '',
97
+ Enable: t.Enable || 0,
98
+ CustomArgument: t.CustomArgument,
99
+ AvailableStatus: t.AvailableStatus,
100
+ ResourceId: t.ResourceId,
101
+ BindStatus: t.BindStatus,
102
+ TriggerAttribute: t.TriggerAttribute,
103
+ Qualifier: t.Qualifier,
104
+ Description: t.Description,
105
+ }));
106
+ const tags = response.Tags?.map((t) => ({
107
+ Key: t.Key || '',
108
+ Value: t.Value || '',
109
+ }));
110
+ return {
111
+ FunctionName: response.FunctionName || '',
112
+ Runtime: response.Runtime || '',
113
+ Handler: response.Handler || '',
114
+ MemorySize: response.MemorySize || 128,
115
+ Timeout: response.Timeout || 3,
116
+ Environment: environment,
117
+ ModTime: response.ModTime,
118
+ CodeSha256: undefined,
119
+ CodeInfo: response.CodeInfo,
120
+ Description: response.Description,
121
+ Triggers: triggers,
122
+ CodeSize: response.CodeSize,
123
+ FunctionVersion: response.FunctionVersion,
124
+ VpcConfig: response.VpcConfig,
125
+ UseGpu: response.UseGpu,
126
+ CodeResult: response.CodeResult,
127
+ CodeError: response.CodeError,
128
+ ErrNo: response.ErrNo,
129
+ Namespace: response.Namespace,
130
+ Role: response.Role,
131
+ InstallDependency: response.InstallDependency,
132
+ Status: response.Status,
133
+ StatusDesc: response.StatusDesc,
134
+ ClsLogsetId: response.ClsLogsetId,
135
+ ClsTopicId: response.ClsTopicId,
136
+ FunctionId: response.FunctionId,
137
+ Tags: tags,
138
+ EipConfig: response.EipConfig,
139
+ AccessInfo: response.AccessInfo,
140
+ Type: response.Type,
141
+ L5Enable: response.L5Enable,
142
+ Layers: response.Layers,
143
+ DeadLetterConfig: response.DeadLetterConfig,
144
+ AddTime: response.AddTime,
145
+ PublicNetConfig: response.PublicNetConfig,
146
+ OnsEnable: response.OnsEnable,
147
+ CfsConfig: response.CfsConfig,
148
+ AvailableStatus: response.AvailableStatus,
149
+ Qualifier: response.Qualifier,
150
+ InitTimeout: response.InitTimeout,
151
+ StatusReasons: response.StatusReasons,
152
+ AsyncRunEnable: response.AsyncRunEnable,
153
+ TraceEnable: response.TraceEnable,
154
+ ImageConfig: response.ImageConfig,
155
+ ProtocolType: response.ProtocolType,
156
+ ProtocolParams: response.ProtocolParams,
157
+ InstanceConcurrencyConfig: response.InstanceConcurrencyConfig,
158
+ DnsCache: response.DnsCache,
159
+ IntranetConfig: response.IntranetConfig,
160
+ };
161
+ }
162
+ catch (error) {
163
+ if (error &&
164
+ typeof error === 'object' &&
165
+ 'code' in error &&
166
+ (error.code === 'ResourceNotFound.FunctionName' ||
167
+ error.code === 'ResourceNotFound.Function')) {
168
+ return null;
35
169
  }
36
- : undefined;
37
- const triggers = response.Triggers?.map((t) => ({
38
- ModTime: t.ModTime || '',
39
- Type: t.Type || '',
40
- TriggerDesc: t.TriggerDesc || '',
41
- TriggerName: t.TriggerName || '',
42
- AddTime: t.AddTime || '',
43
- Enable: t.Enable || 0,
44
- CustomArgument: t.CustomArgument,
45
- AvailableStatus: t.AvailableStatus,
46
- ResourceId: t.ResourceId,
47
- BindStatus: t.BindStatus,
48
- TriggerAttribute: t.TriggerAttribute,
49
- Qualifier: t.Qualifier,
50
- Description: t.Description,
51
- }));
52
- const tags = response.Tags?.map((t) => ({
53
- Key: t.Key || '',
54
- Value: t.Value || '',
55
- }));
56
- return {
57
- FunctionName: response.FunctionName || '',
58
- Runtime: response.Runtime || '',
59
- Handler: response.Handler || '',
60
- MemorySize: response.MemorySize || 128,
61
- Timeout: response.Timeout || 3,
62
- Environment: environment,
63
- ModTime: response.ModTime,
64
- CodeSha256: undefined,
65
- CodeInfo: response.CodeInfo,
66
- Description: response.Description,
67
- Triggers: triggers,
68
- CodeSize: response.CodeSize,
69
- FunctionVersion: response.FunctionVersion,
70
- VpcConfig: response.VpcConfig,
71
- UseGpu: response.UseGpu,
72
- CodeResult: response.CodeResult,
73
- CodeError: response.CodeError,
74
- ErrNo: response.ErrNo,
75
- Namespace: response.Namespace,
76
- Role: response.Role,
77
- InstallDependency: response.InstallDependency,
78
- Status: response.Status,
79
- StatusDesc: response.StatusDesc,
80
- ClsLogsetId: response.ClsLogsetId,
81
- ClsTopicId: response.ClsTopicId,
82
- FunctionId: response.FunctionId,
83
- Tags: tags,
84
- EipConfig: response.EipConfig,
85
- AccessInfo: response.AccessInfo,
86
- Type: response.Type,
87
- L5Enable: response.L5Enable,
88
- Layers: response.Layers,
89
- DeadLetterConfig: response.DeadLetterConfig,
90
- AddTime: response.AddTime,
91
- PublicNetConfig: response.PublicNetConfig,
92
- OnsEnable: response.OnsEnable,
93
- CfsConfig: response.CfsConfig,
94
- AvailableStatus: response.AvailableStatus,
95
- Qualifier: response.Qualifier,
96
- InitTimeout: response.InitTimeout,
97
- StatusReasons: response.StatusReasons,
98
- AsyncRunEnable: response.AsyncRunEnable,
99
- TraceEnable: response.TraceEnable,
100
- ImageConfig: response.ImageConfig,
101
- ProtocolType: response.ProtocolType,
102
- ProtocolParams: response.ProtocolParams,
103
- DnsCache: response.DnsCache,
104
- IntranetConfig: response.IntranetConfig,
170
+ throw error;
171
+ }
172
+ },
173
+ updateFunctionConfiguration: async (config) => {
174
+ // Handler and Runtime are set at creation time and CANNOT be changed via
175
+ // UpdateFunctionConfiguration (Tencent rejects them with
176
+ // InvalidParameterValue.Handler / .Runtime) — omit them here.
177
+ const params = {
178
+ FunctionName: config.FunctionName,
179
+ MemorySize: config.MemorySize,
180
+ Timeout: config.Timeout,
181
+ ...(config.Role && { Role: config.Role }),
182
+ ...(config.Environment && { Environment: config.Environment }),
105
183
  };
106
- }
107
- catch (error) {
108
- if (error &&
109
- typeof error === 'object' &&
110
- 'code' in error &&
111
- error.code === 'ResourceNotFound.FunctionName') {
112
- return null;
184
+ await operations.waitForFunctionActive(config.FunctionName);
185
+ await scfClient.UpdateFunctionConfiguration(params);
186
+ },
187
+ updateFunctionCode: async (functionName, codeBase64) => {
188
+ const params = {
189
+ FunctionName: functionName,
190
+ ZipFile: codeBase64,
191
+ };
192
+ await operations.waitForFunctionActive(functionName);
193
+ await scfClient.UpdateFunctionCode(params);
194
+ },
195
+ createTrigger: async (params) => {
196
+ await scfClient.CreateTrigger({
197
+ FunctionName: params.FunctionName,
198
+ TriggerName: params.TriggerName,
199
+ Type: params.Type,
200
+ ...(params.TriggerDesc ? { TriggerDesc: params.TriggerDesc } : {}),
201
+ ...(params.Qualifier ? { Qualifier: params.Qualifier } : {}),
202
+ ...(params.Enable ? { Enable: params.Enable } : {}),
203
+ });
204
+ },
205
+ deleteTrigger: async (params) => {
206
+ await scfClient.DeleteTrigger({
207
+ FunctionName: params.FunctionName,
208
+ TriggerName: params.TriggerName,
209
+ Type: params.Type,
210
+ });
211
+ },
212
+ createCustomDomain: async (params) => {
213
+ await scfClient.CreateCustomDomain({
214
+ Domain: params.Domain,
215
+ Protocol: params.Protocol,
216
+ EndpointsConfig: params.EndpointsConfig.map((ep) => ({
217
+ Namespace: ep.Namespace,
218
+ FunctionName: ep.FunctionName,
219
+ Qualifier: ep.Qualifier,
220
+ PathMatch: ep.PathMatch,
221
+ })),
222
+ ...(params.CertConfig ? { CertConfig: params.CertConfig } : {}),
223
+ });
224
+ },
225
+ getCustomDomain: async (domain) => {
226
+ try {
227
+ const response = await scfClient.GetCustomDomain({ Domain: domain });
228
+ if (!response)
229
+ return null;
230
+ return {
231
+ Domain: response.Domain,
232
+ Protocol: response.Protocol,
233
+ EndpointsConfig: response.EndpointsConfig?.map((ep) => ({
234
+ FunctionName: ep.FunctionName,
235
+ Qualifier: ep.Qualifier,
236
+ PathMatch: ep.PathMatch,
237
+ })),
238
+ };
113
239
  }
114
- throw error;
115
- }
116
- },
117
- updateFunctionConfiguration: async (config) => {
118
- const params = {
119
- FunctionName: config.FunctionName,
120
- Handler: config.Handler,
121
- Runtime: config.Runtime,
122
- MemorySize: config.MemorySize,
123
- Timeout: config.Timeout,
124
- ...(config.Role && { Role: config.Role }),
125
- ...(config.Environment && { Environment: config.Environment }),
126
- };
127
- await scfClient.UpdateFunctionConfiguration(params);
128
- },
129
- updateFunctionCode: async (functionName, codeBase64) => {
130
- const params = {
131
- FunctionName: functionName,
132
- ZipFile: codeBase64,
133
- };
134
- await scfClient.UpdateFunctionCode(params);
135
- },
136
- deleteFunction: async (functionName) => {
137
- const params = {
138
- FunctionName: functionName,
139
- };
140
- await scfClient.DeleteFunction(params);
141
- },
142
- });
240
+ catch (error) {
241
+ if (error &&
242
+ typeof error === 'object' &&
243
+ 'code' in error &&
244
+ error.code === 'ResourceNotFound') {
245
+ return null;
246
+ }
247
+ throw error;
248
+ }
249
+ },
250
+ deleteCustomDomain: async (domain) => {
251
+ await scfClient.DeleteCustomDomain({ Domain: domain });
252
+ },
253
+ deleteFunction: async (functionName) => {
254
+ const params = {
255
+ FunctionName: functionName,
256
+ };
257
+ await scfClient.DeleteFunction(params);
258
+ // DeleteFunction returns immediately — wait for the function to be gone so
259
+ // a subsequent create (retry) does not collide with a still-deleting function.
260
+ await operations.waitForFunctionDeleted(functionName);
261
+ },
262
+ };
263
+ return operations;
264
+ };
143
265
  exports.createScfOperations = createScfOperations;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapClusterToInfo = void 0;
4
+ // Maps a raw DescribeClusters SDK record into the normalized TdsqlcClusterInfo
5
+ // shape shared by getCluster / getClusterByName probes.
6
+ const mapClusterToInfo = (cluster, region) => {
7
+ return {
8
+ ClusterId: cluster.ClusterId || '',
9
+ ClusterName: cluster.ClusterName || '',
10
+ Region: cluster.Region || region,
11
+ Uin: cluster.Uin,
12
+ AppId: cluster.AppId,
13
+ Zone: cluster.Zone,
14
+ PhysicalZone: cluster.PhysicalZone,
15
+ DbType: cluster.DbType || '',
16
+ DbVersion: cluster.DbVersion || '',
17
+ DbMode: cluster.DbMode,
18
+ Status: cluster.Status || '',
19
+ StatusDesc: cluster.StatusDesc,
20
+ ServerlessStatus: cluster.ServerlessStatus,
21
+ VpcId: cluster.VpcId,
22
+ VpcName: undefined,
23
+ SubnetId: cluster.SubnetId,
24
+ SubnetName: undefined,
25
+ Charset: undefined,
26
+ Vip: cluster.Vip,
27
+ Vport: cluster.Vport,
28
+ WanDomain: undefined,
29
+ WanIP: undefined,
30
+ WanPort: undefined,
31
+ WanStatus: undefined,
32
+ MinCpu: undefined,
33
+ MaxCpu: undefined,
34
+ MinStorageSize: cluster.MinStorageSize,
35
+ MaxStorageSize: cluster.MaxStorageSize,
36
+ StorageId: cluster.StorageId,
37
+ Storage: cluster.Storage,
38
+ StorageLimit: cluster.StorageLimit,
39
+ StoragePayMode: cluster.StoragePayMode,
40
+ // DescribeClusters returns ServerlessStatus as 'resume'/'pause' — that is
41
+ // the cluster's running state, NOT the AutoPause idle-stall switch, so it
42
+ // must not be mis-mapped here (AutoPause comes from the create/update config).
43
+ AutoPause: undefined,
44
+ AutoPauseDelay: undefined,
45
+ CreateTime: cluster.CreateTime,
46
+ UpdateTime: cluster.UpdateTime,
47
+ ProjectId: cluster.ProjectID,
48
+ PayMode: cluster.PayMode,
49
+ PeriodEndTime: cluster.PeriodEndTime,
50
+ AutoRenewFlag: cluster.RenewFlag,
51
+ InstanceCount: cluster.InstanceNum,
52
+ ProcessingTask: cluster.ProcessingTask,
53
+ Tasks: cluster.Tasks,
54
+ NetAddrs: cluster.NetAddrs,
55
+ HasSlaveZone: cluster.HasSlaveZone,
56
+ ResourcePackages: cluster.ResourcePackages,
57
+ GdnId: cluster.GdnId,
58
+ GdnRole: cluster.GdnRole,
59
+ SupportedFeatures: undefined,
60
+ RollbackSupport: undefined,
61
+ NetworkType: undefined,
62
+ ResourcePackageId: undefined,
63
+ ResourcePackageType: undefined,
64
+ ResourcePackageState: undefined,
65
+ PhysicalRegion: undefined,
66
+ ProxyStatus: undefined,
67
+ RwGroupId: undefined,
68
+ MasterZone: cluster.MasterZone,
69
+ SlaveZones: cluster.SlaveZones,
70
+ BusinessType: cluster.BusinessType,
71
+ IsFreeze: cluster.IsFreeze,
72
+ OrderSource: cluster.OrderSource,
73
+ Ability: cluster.Ability,
74
+ ResourceTags: cluster.ResourceTags,
75
+ CynosVersion: cluster.CynosVersion,
76
+ CynosVersionTag: cluster.CynosVersionTag,
77
+ CynosVersionStatus: undefined,
78
+ IsLatestVersion: undefined,
79
+ };
80
+ };
81
+ exports.mapClusterToInfo = mapClusterToInfo;