@geek-fun/serverlessinsight 0.8.2 → 0.8.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.
Files changed (124) hide show
  1. package/.serverlessinsight/state-cdn-flow-app-cdn-flow-service.json.backup +15 -0
  2. package/.serverlessinsight/state-iam-test-app-iam-test-service.json.backup +33 -0
  3. package/.serverlessinsight/state-insight-poc-deploy-app-insight-poc-deploy.json.backup +359 -0
  4. package/.serverlessinsight/state-insight-poc-destroy-app-insight-poc-destroy.json.backup +15 -0
  5. package/.serverlessinsight/state-insight-volc-app-insight-volc.json.backup +154 -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 +5 -2
  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 +363 -30
  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 +90 -28
  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 +13 -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 +10 -4
  41. package/dist/src/common/stateBackend/saasStateBackend.js +266 -0
  42. package/dist/src/common/stateManager.js +186 -14
  43. package/dist/src/common/tencentClient/clsOperations.js +137 -0
  44. package/dist/src/common/tencentClient/cosOperations.js +180 -3
  45. package/dist/src/common/tencentClient/esOperations.js +110 -46
  46. package/dist/src/common/tencentClient/index.js +43 -2
  47. package/dist/src/common/tencentClient/scfOperations.js +266 -133
  48. package/dist/src/common/tencentClient/tdsqlcClusterMapper.js +81 -0
  49. package/dist/src/common/tencentClient/tdsqlcOperations.js +93 -99
  50. package/dist/src/common/triggerMapper.js +36 -0
  51. package/dist/src/common/volcengineClient/apigwOperations.js +539 -159
  52. package/dist/src/common/volcengineClient/iamOperations.js +91 -48
  53. package/dist/src/common/volcengineClient/index.js +46 -21
  54. package/dist/src/common/volcengineClient/stsOperations.js +32 -0
  55. package/dist/src/common/volcengineClient/tlsOperations.js +305 -171
  56. package/dist/src/common/volcengineClient/tosOperations.js +78 -19
  57. package/dist/src/common/volcengineClient/vefaasOperations.js +272 -54
  58. package/dist/src/lang/en.js +107 -1
  59. package/dist/src/lang/zh-CN.js +107 -1
  60. package/dist/src/parser/eventParser.js +2 -0
  61. package/dist/src/parser/functionParser.js +96 -65
  62. package/dist/src/parser/index.js +7 -4
  63. package/dist/src/stack/aliyunStack/apigwExecutor.js +39 -1
  64. package/dist/src/stack/aliyunStack/apigwPlanner.js +16 -10
  65. package/dist/src/stack/aliyunStack/apigwResource.js +334 -125
  66. package/dist/src/stack/aliyunStack/apigwTypes.js +35 -4
  67. package/dist/src/stack/aliyunStack/databaseExecutor.js +39 -1
  68. package/dist/src/stack/aliyunStack/databasePlanner.js +13 -1
  69. package/dist/src/stack/aliyunStack/databaseResource.js +135 -40
  70. package/dist/src/stack/aliyunStack/deployer.js +2 -2
  71. package/dist/src/stack/aliyunStack/destroyer.js +27 -2
  72. package/dist/src/stack/aliyunStack/fc3Executor.js +25 -2
  73. package/dist/src/stack/aliyunStack/fc3Planner.js +11 -1
  74. package/dist/src/stack/aliyunStack/fc3Resource.js +416 -94
  75. package/dist/src/stack/aliyunStack/ossExecutor.js +39 -1
  76. package/dist/src/stack/aliyunStack/ossPlanner.js +15 -1
  77. package/dist/src/stack/aliyunStack/ossResource.js +267 -219
  78. package/dist/src/stack/aliyunStack/sharedLogProject.js +137 -0
  79. package/dist/src/stack/aliyunStack/tablestoreExecutor.js +39 -1
  80. package/dist/src/stack/aliyunStack/tablestorePlanner.js +13 -1
  81. package/dist/src/stack/aliyunStack/tablestoreResource.js +54 -20
  82. package/dist/src/stack/alreadyExists.js +26 -0
  83. package/dist/src/stack/ownershipTag.js +58 -0
  84. package/dist/src/stack/rfsStack/index.js +3 -1
  85. package/dist/src/stack/scfStack/cosExecutor.js +39 -1
  86. package/dist/src/stack/scfStack/cosPlanner.js +11 -1
  87. package/dist/src/stack/scfStack/cosResource.js +167 -64
  88. package/dist/src/stack/scfStack/deployer.js +2 -2
  89. package/dist/src/stack/scfStack/destroyer.js +15 -2
  90. package/dist/src/stack/scfStack/esServerlessExecutor.js +39 -1
  91. package/dist/src/stack/scfStack/esServerlessPlanner.js +11 -1
  92. package/dist/src/stack/scfStack/esServerlessResource.js +88 -23
  93. package/dist/src/stack/scfStack/scfExecutor.js +39 -1
  94. package/dist/src/stack/scfStack/scfPlanner.js +21 -3
  95. package/dist/src/stack/scfStack/scfResource.js +686 -24
  96. package/dist/src/stack/scfStack/scfTypes.js +6 -0
  97. package/dist/src/stack/scfStack/sharedLogset.js +126 -0
  98. package/dist/src/stack/scfStack/tdsqlcExecutor.js +39 -1
  99. package/dist/src/stack/scfStack/tdsqlcPlanner.js +12 -1
  100. package/dist/src/stack/scfStack/tdsqlcResource.js +95 -16
  101. package/dist/src/stack/scfStack/tdsqlcTypes.js +5 -1
  102. package/dist/src/stack/volcengineStack/apigwExecutor.js +39 -1
  103. package/dist/src/stack/volcengineStack/apigwPlanner.js +25 -53
  104. package/dist/src/stack/volcengineStack/apigwResource.js +434 -222
  105. package/dist/src/stack/volcengineStack/apigwTypes.js +85 -66
  106. package/dist/src/stack/volcengineStack/deployer.js +49 -14
  107. package/dist/src/stack/volcengineStack/destroyer.js +13 -1
  108. package/dist/src/stack/volcengineStack/index.js +1 -2
  109. package/dist/src/stack/volcengineStack/sharedLogProject.js +190 -0
  110. package/dist/src/stack/volcengineStack/tosExecutor.js +25 -2
  111. package/dist/src/stack/volcengineStack/tosPlanner.js +11 -1
  112. package/dist/src/stack/volcengineStack/tosResource.js +82 -27
  113. package/dist/src/stack/volcengineStack/tosTypes.js +12 -0
  114. package/dist/src/stack/volcengineStack/vefaasExecutor.js +25 -2
  115. package/dist/src/stack/volcengineStack/vefaasPlanner.js +78 -2
  116. package/dist/src/stack/volcengineStack/vefaasResource.js +194 -144
  117. package/dist/src/stack/volcengineStack/vefaasTypes.js +1 -3
  118. package/dist/src/types/domains/backend.js +1 -0
  119. package/dist/src/types/domains/state.js +32 -1
  120. package/dist/src/validator/eventSchema.js +10 -0
  121. package/dist/src/validator/functionSchema.js +37 -12
  122. package/dist/src/validator/iacSchema.js +1 -0
  123. package/dist/tsconfig.tsbuildinfo +1 -1
  124. package/package.json +5 -2
@@ -1,143 +1,276 @@
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.ClsLogsetId && { ClsLogsetId: config.ClsLogsetId }),
59
+ ...(config.ClsTopicId && { ClsTopicId: config.ClsTopicId }),
60
+ ...(config.Environment && { Environment: config.Environment }),
24
61
  };
25
- const response = await scfClient.GetFunction(params);
26
- if (!response || !response.FunctionName) {
27
- return null;
62
+ await scfClient.CreateFunction(params);
63
+ // CreateFunction is async on Tencent SCF — the function stays in 'Creating'
64
+ // until the platform finishes provisioning. Follow-up calls (e.g.
65
+ // CreateTrigger) fail with "Status is Creating, unsupport operate" if issued
66
+ // too early, so poll until Active before returning.
67
+ await operations.waitForFunctionActive(params.FunctionName);
68
+ // CreateFunction's Tags param is silently dropped by the API (verified
69
+ // empirically — GetFunction returns [] even when Tags was sent). Ownership
70
+ // tags must be attached via the tag service's TagResources with the
71
+ // namespace-qualified ARN, otherwise adoption can never verify ownership.
72
+ if (config.Tags && config.Tags.length > 0) {
73
+ await tagFunction(params.FunctionName, config.Tags);
28
74
  }
29
- const environment = response.Environment?.Variables
30
- ? {
31
- Variables: response.Environment.Variables.map((v) => ({
32
- Key: v.Key || '',
33
- Value: v.Value || '',
34
- })),
75
+ },
76
+ getFunction: async (functionName) => {
77
+ try {
78
+ const params = {
79
+ FunctionName: functionName,
80
+ };
81
+ const response = await scfClient.GetFunction(params);
82
+ if (!response || !response.FunctionName) {
83
+ return null;
84
+ }
85
+ const environment = response.Environment?.Variables
86
+ ? {
87
+ Variables: response.Environment.Variables.map((v) => ({
88
+ Key: v.Key || '',
89
+ Value: v.Value || '',
90
+ })),
91
+ }
92
+ : undefined;
93
+ const triggers = response.Triggers?.map((t) => ({
94
+ ModTime: t.ModTime || '',
95
+ Type: t.Type || '',
96
+ TriggerDesc: t.TriggerDesc || '',
97
+ TriggerName: t.TriggerName || '',
98
+ AddTime: t.AddTime || '',
99
+ Enable: t.Enable || 0,
100
+ CustomArgument: t.CustomArgument,
101
+ AvailableStatus: t.AvailableStatus,
102
+ ResourceId: t.ResourceId,
103
+ BindStatus: t.BindStatus,
104
+ TriggerAttribute: t.TriggerAttribute,
105
+ Qualifier: t.Qualifier,
106
+ Description: t.Description,
107
+ }));
108
+ const tags = response.Tags?.map((t) => ({
109
+ Key: t.Key || '',
110
+ Value: t.Value || '',
111
+ }));
112
+ return {
113
+ FunctionName: response.FunctionName || '',
114
+ Runtime: response.Runtime || '',
115
+ Handler: response.Handler || '',
116
+ MemorySize: response.MemorySize || 128,
117
+ Timeout: response.Timeout || 3,
118
+ Environment: environment,
119
+ ModTime: response.ModTime,
120
+ CodeSha256: undefined,
121
+ CodeInfo: response.CodeInfo,
122
+ Description: response.Description,
123
+ Triggers: triggers,
124
+ CodeSize: response.CodeSize,
125
+ FunctionVersion: response.FunctionVersion,
126
+ VpcConfig: response.VpcConfig,
127
+ UseGpu: response.UseGpu,
128
+ CodeResult: response.CodeResult,
129
+ CodeError: response.CodeError,
130
+ ErrNo: response.ErrNo,
131
+ Namespace: response.Namespace,
132
+ Role: response.Role,
133
+ InstallDependency: response.InstallDependency,
134
+ Status: response.Status,
135
+ StatusDesc: response.StatusDesc,
136
+ ClsLogsetId: response.ClsLogsetId,
137
+ ClsTopicId: response.ClsTopicId,
138
+ FunctionId: response.FunctionId,
139
+ Tags: tags,
140
+ EipConfig: response.EipConfig,
141
+ AccessInfo: response.AccessInfo,
142
+ Type: response.Type,
143
+ L5Enable: response.L5Enable,
144
+ Layers: response.Layers,
145
+ DeadLetterConfig: response.DeadLetterConfig,
146
+ AddTime: response.AddTime,
147
+ PublicNetConfig: response.PublicNetConfig,
148
+ OnsEnable: response.OnsEnable,
149
+ CfsConfig: response.CfsConfig,
150
+ AvailableStatus: response.AvailableStatus,
151
+ Qualifier: response.Qualifier,
152
+ InitTimeout: response.InitTimeout,
153
+ StatusReasons: response.StatusReasons,
154
+ AsyncRunEnable: response.AsyncRunEnable,
155
+ TraceEnable: response.TraceEnable,
156
+ ImageConfig: response.ImageConfig,
157
+ ProtocolType: response.ProtocolType,
158
+ ProtocolParams: response.ProtocolParams,
159
+ InstanceConcurrencyConfig: response.InstanceConcurrencyConfig,
160
+ DnsCache: response.DnsCache,
161
+ IntranetConfig: response.IntranetConfig,
162
+ };
163
+ }
164
+ catch (error) {
165
+ if (error &&
166
+ typeof error === 'object' &&
167
+ 'code' in error &&
168
+ (error.code === 'ResourceNotFound.FunctionName' ||
169
+ error.code === 'ResourceNotFound.Function')) {
170
+ return null;
35
171
  }
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,
172
+ throw error;
173
+ }
174
+ },
175
+ updateFunctionConfiguration: async (config) => {
176
+ // Handler and Runtime are set at creation time and CANNOT be changed via
177
+ // UpdateFunctionConfiguration (Tencent rejects them with
178
+ // InvalidParameterValue.Handler / .Runtime) — omit them here.
179
+ //
180
+ // Tencent requires Role whenever the Cls* destination changes, else
181
+ // UpdateFunctionConfiguration fails with InvalidParameterValue.ClsRole —
182
+ // so Role is forwarded here whenever an si-managed role is present.
183
+ //
184
+ // Cls ids are forwarded whenever present — including '' — because
185
+ // passing ClsLogsetId/ClsTopicId as '' is Tencent's unbind contract.
186
+ const params = {
187
+ FunctionName: config.FunctionName,
188
+ MemorySize: config.MemorySize,
189
+ Timeout: config.Timeout,
190
+ ...(config.Role && { Role: config.Role }),
191
+ ...(config.ClsLogsetId !== undefined ? { ClsLogsetId: config.ClsLogsetId } : {}),
192
+ ...(config.ClsTopicId !== undefined ? { ClsTopicId: config.ClsTopicId } : {}),
193
+ ...(config.Environment && { Environment: config.Environment }),
105
194
  };
106
- }
107
- catch (error) {
108
- if (error &&
109
- typeof error === 'object' &&
110
- 'code' in error &&
111
- error.code === 'ResourceNotFound.FunctionName') {
112
- return null;
195
+ await operations.waitForFunctionActive(config.FunctionName);
196
+ await scfClient.UpdateFunctionConfiguration(params);
197
+ },
198
+ updateFunctionCode: async (functionName, codeBase64) => {
199
+ const params = {
200
+ FunctionName: functionName,
201
+ ZipFile: codeBase64,
202
+ };
203
+ await operations.waitForFunctionActive(functionName);
204
+ await scfClient.UpdateFunctionCode(params);
205
+ },
206
+ createTrigger: async (params) => {
207
+ await scfClient.CreateTrigger({
208
+ FunctionName: params.FunctionName,
209
+ TriggerName: params.TriggerName,
210
+ Type: params.Type,
211
+ ...(params.TriggerDesc ? { TriggerDesc: params.TriggerDesc } : {}),
212
+ ...(params.Qualifier ? { Qualifier: params.Qualifier } : {}),
213
+ ...(params.Enable ? { Enable: params.Enable } : {}),
214
+ });
215
+ },
216
+ deleteTrigger: async (params) => {
217
+ await scfClient.DeleteTrigger({
218
+ FunctionName: params.FunctionName,
219
+ TriggerName: params.TriggerName,
220
+ Type: params.Type,
221
+ });
222
+ },
223
+ createCustomDomain: async (params) => {
224
+ await scfClient.CreateCustomDomain({
225
+ Domain: params.Domain,
226
+ Protocol: params.Protocol,
227
+ EndpointsConfig: params.EndpointsConfig.map((ep) => ({
228
+ Namespace: ep.Namespace,
229
+ FunctionName: ep.FunctionName,
230
+ Qualifier: ep.Qualifier,
231
+ PathMatch: ep.PathMatch,
232
+ })),
233
+ ...(params.CertConfig ? { CertConfig: params.CertConfig } : {}),
234
+ });
235
+ },
236
+ getCustomDomain: async (domain) => {
237
+ try {
238
+ const response = await scfClient.GetCustomDomain({ Domain: domain });
239
+ if (!response)
240
+ return null;
241
+ return {
242
+ Domain: response.Domain,
243
+ Protocol: response.Protocol,
244
+ EndpointsConfig: response.EndpointsConfig?.map((ep) => ({
245
+ FunctionName: ep.FunctionName,
246
+ Qualifier: ep.Qualifier,
247
+ PathMatch: ep.PathMatch,
248
+ })),
249
+ };
113
250
  }
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
- });
251
+ catch (error) {
252
+ if (error &&
253
+ typeof error === 'object' &&
254
+ 'code' in error &&
255
+ error.code === 'ResourceNotFound') {
256
+ return null;
257
+ }
258
+ throw error;
259
+ }
260
+ },
261
+ deleteCustomDomain: async (domain) => {
262
+ await scfClient.DeleteCustomDomain({ Domain: domain });
263
+ },
264
+ deleteFunction: async (functionName) => {
265
+ const params = {
266
+ FunctionName: functionName,
267
+ };
268
+ await scfClient.DeleteFunction(params);
269
+ // DeleteFunction returns immediately — wait for the function to be gone so
270
+ // a subsequent create (retry) does not collide with a still-deleting function.
271
+ await operations.waitForFunctionDeleted(functionName);
272
+ },
273
+ };
274
+ return operations;
275
+ };
143
276
  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;