@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
@@ -4,7 +4,7 @@ exports.createIamOperations = void 0;
4
4
  const iamStatements_1 = require("../iamStatements");
5
5
  const logger_1 = require("../logger");
6
6
  const lang_1 = require("../../lang");
7
- const DEFAULT_TRUST_POLICY_SERVICES = ['vefaas.volcengine.com'];
7
+ const DEFAULT_TRUST_POLICY_SERVICES = ['vefaas'];
8
8
  const buildTrustPolicyDocument = (trustedServices) => {
9
9
  return JSON.stringify({
10
10
  Statement: [
@@ -58,16 +58,26 @@ const buildExecutionPolicy = (customStatements) => {
58
58
  const merged = (0, iamStatements_1.mergePolicyStatements)(VEFAAS_EXECUTION_STATEMENTS, customStatements, mapToVolcengineStatement);
59
59
  return (0, iamStatements_1.buildPolicyDocument)(merged);
60
60
  };
61
+ // TagResources expects flat numbered query params (ResourceIds.1, Tags.1.Key, ...).
62
+ // ResourceIds.1 carries the ROLE NAME (consistent with DeleteRole using RoleName).
63
+ const buildTagResourceQuery = (roleName, tags) => {
64
+ return tags.reduce((query, tag, index) => {
65
+ const n = index + 1;
66
+ query[`Tags.${n}.Key`] = tag.key;
67
+ query[`Tags.${n}.Value`] = tag.value;
68
+ return query;
69
+ }, { ResourceType: 'role', 'ResourceIds.1': roleName });
70
+ };
61
71
  const createIamOperations = (iamClient) => {
62
72
  const createAndAttachPolicy = async (roleName, customStatements) => {
63
73
  const policyName = `${roleName}-policy`;
64
74
  try {
65
75
  await iamClient.fetchOpenAPI({
66
76
  Action: 'CreatePolicy',
67
- Version: '2024-01-01',
68
- method: 'POST',
77
+ Version: '2018-01-01',
78
+ method: 'GET',
69
79
  headers: { 'content-type': 'application/json' },
70
- data: {
80
+ query: {
71
81
  PolicyName: policyName,
72
82
  PolicyDocument: buildExecutionPolicy(customStatements),
73
83
  Description: `veFaaS execution policy for ${roleName}`,
@@ -76,7 +86,12 @@ const createIamOperations = (iamClient) => {
76
86
  }
77
87
  catch (error) {
78
88
  if (error && typeof error === 'object' && 'code' in error) {
79
- if (error.code === 'PolicyAlreadyExists' || error.code === 'Conflict') {
89
+ const code = String(error.code);
90
+ // volcengine uses the singular PolicyAlreadyExist (observed live)
91
+ if (code === 'PolicyAlreadyExists' ||
92
+ code === 'PolicyAlreadyExist' ||
93
+ code === 'Conflict' ||
94
+ code.startsWith('PolicyAlready')) {
80
95
  logger_1.logger.info(lang_1.lang.__('IAM_POLICY_ALREADY_EXISTS', { policyName }));
81
96
  }
82
97
  else {
@@ -90,10 +105,10 @@ const createIamOperations = (iamClient) => {
90
105
  try {
91
106
  await iamClient.fetchOpenAPI({
92
107
  Action: 'AttachRolePolicy',
93
- Version: '2024-01-01',
94
- method: 'POST',
108
+ Version: '2018-01-01',
109
+ method: 'GET',
95
110
  headers: { 'content-type': 'application/json' },
96
- data: {
111
+ query: {
97
112
  RoleName: roleName,
98
113
  PolicyName: policyName,
99
114
  PolicyType: 'Custom',
@@ -102,7 +117,12 @@ const createIamOperations = (iamClient) => {
102
117
  }
103
118
  catch (error) {
104
119
  if (error && typeof error === 'object' && 'code' in error) {
105
- if (error.code === 'PolicyAlreadyAttached' || error.code === 'Conflict') {
120
+ const code = String(error.code);
121
+ // volcengine reports PolicyAttachConflict when the policy is already attached
122
+ if (code === 'PolicyAlreadyAttached' ||
123
+ code === 'PolicyAttachConflict' ||
124
+ code === 'Conflict' ||
125
+ code.startsWith('PolicyAttach')) {
106
126
  logger_1.logger.info(lang_1.lang.__('IAM_POLICY_ALREADY_ATTACHED', { policyName, roleName }));
107
127
  }
108
128
  else {
@@ -120,10 +140,10 @@ const createIamOperations = (iamClient) => {
120
140
  try {
121
141
  await iamClient.fetchOpenAPI({
122
142
  Action: 'DetachRolePolicy',
123
- Version: '2024-01-01',
124
- method: 'POST',
143
+ Version: '2018-01-01',
144
+ method: 'GET',
125
145
  headers: { 'content-type': 'application/json' },
126
- data: {
146
+ query: {
127
147
  RoleName: roleName,
128
148
  PolicyName: policyName,
129
149
  PolicyType: 'Custom',
@@ -136,10 +156,10 @@ const createIamOperations = (iamClient) => {
136
156
  try {
137
157
  await iamClient.fetchOpenAPI({
138
158
  Action: 'DeletePolicy',
139
- Version: '2024-01-01',
140
- method: 'POST',
159
+ Version: '2018-01-01',
160
+ method: 'GET',
141
161
  headers: { 'content-type': 'application/json' },
142
- data: {
162
+ query: {
143
163
  PolicyName: policyName,
144
164
  PolicyType: 'Custom',
145
165
  },
@@ -153,10 +173,10 @@ const createIamOperations = (iamClient) => {
153
173
  try {
154
174
  await iamClient.fetchOpenAPI({
155
175
  Action: 'AttachRolePolicy',
156
- Version: '2024-01-01',
157
- method: 'POST',
176
+ Version: '2018-01-01',
177
+ method: 'GET',
158
178
  headers: { 'content-type': 'application/json' },
159
- data: {
179
+ query: {
160
180
  RoleName: roleName,
161
181
  PolicyName: policyName,
162
182
  PolicyType: policyType,
@@ -178,10 +198,10 @@ const createIamOperations = (iamClient) => {
178
198
  try {
179
199
  await iamClient.fetchOpenAPI({
180
200
  Action: 'DetachRolePolicy',
181
- Version: '2024-01-01',
182
- method: 'POST',
201
+ Version: '2018-01-01',
202
+ method: 'GET',
183
203
  headers: { 'content-type': 'application/json' },
184
- data: {
204
+ query: {
185
205
  RoleName: roleName,
186
206
  PolicyName: policyName,
187
207
  PolicyType: policyType,
@@ -203,13 +223,13 @@ const createIamOperations = (iamClient) => {
203
223
  try {
204
224
  const response = await iamClient.fetchOpenAPI({
205
225
  Action: 'ListAttachedRolePolicies',
206
- Version: '2024-01-01',
207
- method: 'POST',
226
+ Version: '2018-01-01',
227
+ method: 'GET',
208
228
  headers: { 'content-type': 'application/json' },
209
- data: { RoleName: roleName },
229
+ query: { RoleName: roleName },
210
230
  });
211
231
  const result = (response.Result || {});
212
- const attachedPolicies = result.AttachedRolePolicies;
232
+ const attachedPolicies = result.AttachedPolicyMetadata;
213
233
  if (!attachedPolicies) {
214
234
  return [];
215
235
  }
@@ -228,10 +248,10 @@ const createIamOperations = (iamClient) => {
228
248
  try {
229
249
  const response = await iamClient.fetchOpenAPI({
230
250
  Action: 'CreateRole',
231
- Version: '2024-01-01',
232
- method: 'POST',
251
+ Version: '2018-01-01',
252
+ method: 'GET',
233
253
  headers: { 'content-type': 'application/json' },
234
- data: {
254
+ query: {
235
255
  RoleName: roleName,
236
256
  TrustPolicyDocument: trustPolicyDocument,
237
257
  DisplayName: config.displayName,
@@ -251,7 +271,7 @@ const createIamOperations = (iamClient) => {
251
271
  return {
252
272
  roleName: roleData.RoleName,
253
273
  roleId: roleData.RoleId,
254
- trn: roleData.TRN,
274
+ trn: (roleData.TRN ?? roleData.trn ?? roleData.Trn),
255
275
  description: roleData.Description,
256
276
  createdTime: roleData.CreateTime,
257
277
  maxSessionDuration: roleData.MaxSessionDuration,
@@ -267,17 +287,17 @@ const createIamOperations = (iamClient) => {
267
287
  try {
268
288
  const existingRole = await iamClient.fetchOpenAPI({
269
289
  Action: 'GetRole',
270
- Version: '2024-01-01',
271
- method: 'POST',
290
+ Version: '2018-01-01',
291
+ method: 'GET',
272
292
  headers: { 'content-type': 'application/json' },
273
- data: { RoleName: roleName },
293
+ query: { RoleName: roleName },
274
294
  });
275
295
  await iamClient.fetchOpenAPI({
276
- Action: 'UpdateTrustPolicy',
277
- Version: '2024-01-01',
278
- method: 'POST',
296
+ Action: 'UpdateRole',
297
+ Version: '2018-01-01',
298
+ method: 'GET',
279
299
  headers: { 'content-type': 'application/json' },
280
- data: {
300
+ query: {
281
301
  RoleName: roleName,
282
302
  TrustPolicyDocument: trustPolicyDocument,
283
303
  },
@@ -293,7 +313,7 @@ const createIamOperations = (iamClient) => {
293
313
  return {
294
314
  roleName: roleData?.RoleName,
295
315
  roleId: roleData?.RoleId,
296
- trn: roleData?.TRN,
316
+ trn: (roleData?.TRN ?? roleData?.trn ?? roleData?.Trn),
297
317
  description: roleData?.Description,
298
318
  createdTime: roleData?.CreateTime,
299
319
  maxSessionDuration: roleData?.MaxSessionDuration,
@@ -318,10 +338,10 @@ const createIamOperations = (iamClient) => {
318
338
  try {
319
339
  const response = await iamClient.fetchOpenAPI({
320
340
  Action: 'GetRole',
321
- Version: '2024-01-01',
322
- method: 'POST',
341
+ Version: '2018-01-01',
342
+ method: 'GET',
323
343
  headers: { 'content-type': 'application/json' },
324
- data: { RoleName: roleName },
344
+ query: { RoleName: roleName },
325
345
  });
326
346
  const roleData = (response.Result || {}).Role;
327
347
  if (!roleData) {
@@ -330,7 +350,7 @@ const createIamOperations = (iamClient) => {
330
350
  return {
331
351
  roleName: roleData.RoleName,
332
352
  roleId: roleData.RoleId,
333
- trn: roleData.TRN,
353
+ trn: (roleData.TRN ?? roleData.trn ?? roleData.Trn),
334
354
  description: roleData.Description,
335
355
  createdTime: roleData.CreateTime,
336
356
  maxSessionDuration: roleData.MaxSessionDuration,
@@ -351,11 +371,11 @@ const createIamOperations = (iamClient) => {
351
371
  const trustPolicyDocument = JSON.stringify(trustPolicy);
352
372
  try {
353
373
  await iamClient.fetchOpenAPI({
354
- Action: 'UpdateTrustPolicy',
355
- Version: '2024-01-01',
356
- method: 'POST',
374
+ Action: 'UpdateRole',
375
+ Version: '2018-01-01',
376
+ method: 'GET',
357
377
  headers: { 'content-type': 'application/json' },
358
- data: {
378
+ query: {
359
379
  RoleName: roleName,
360
380
  TrustPolicyDocument: trustPolicyDocument,
361
381
  },
@@ -382,10 +402,10 @@ const createIamOperations = (iamClient) => {
382
402
  try {
383
403
  await iamClient.fetchOpenAPI({
384
404
  Action: 'DeleteRole',
385
- Version: '2024-01-01',
386
- method: 'POST',
405
+ Version: '2018-01-01',
406
+ method: 'GET',
387
407
  headers: { 'content-type': 'application/json' },
388
- data: { RoleName: roleName },
408
+ query: { RoleName: roleName },
389
409
  });
390
410
  logger_1.logger.info(lang_1.lang.__('IAM_ROLE_DELETED', { roleName }));
391
411
  }
@@ -430,6 +450,29 @@ const createIamOperations = (iamClient) => {
430
450
  logger_1.logger.info(lang_1.lang.__('MANAGED_POLICY_ATTACHED', { policyArn: policyName, roleName }));
431
451
  }
432
452
  },
453
+ tagRole: async (roleName, tags) => {
454
+ try {
455
+ await iamClient.fetchOpenAPI({
456
+ Action: 'TagResources',
457
+ Version: '2018-01-01',
458
+ method: 'GET',
459
+ headers: { 'content-type': 'application/json' },
460
+ query: buildTagResourceQuery(roleName, tags),
461
+ });
462
+ }
463
+ catch (error) {
464
+ if (error && typeof error === 'object' && 'code' in error) {
465
+ const code = String(error.code);
466
+ if (code.startsWith('ResourceNotFound.Role') ||
467
+ code === 'RoleNotFound' ||
468
+ code === 'NoSuchEntity') {
469
+ logger_1.logger.warn(lang_1.lang.__('VOLCENGINE_ROLE_NOT_FOUND_FOR_TAG', { roleName }));
470
+ return;
471
+ }
472
+ }
473
+ throw error;
474
+ }
475
+ },
433
476
  };
434
477
  };
435
478
  exports.createIamOperations = createIamOperations;
@@ -16,10 +16,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.createVolcengineClient = void 0;
18
18
  const openapi_1 = require("@volcengine/openapi");
19
+ const tls_1 = require("@volcengine/openapi/lib/services/tls");
19
20
  const vefaasOperations_1 = require("./vefaasOperations");
20
21
  const tosOperations_1 = require("./tosOperations");
21
22
  const iamOperations_1 = require("./iamOperations");
22
23
  const apigwOperations_1 = require("./apigwOperations");
24
+ const stsOperations_1 = require("./stsOperations");
23
25
  const tlsOperations_1 = require("./tlsOperations");
24
26
  __exportStar(require("./types"), exports);
25
27
  __exportStar(require("./vefaasOperations"), exports);
@@ -27,63 +29,85 @@ __exportStar(require("./tosOperations"), exports);
27
29
  __exportStar(require("./iamOperations"), exports);
28
30
  __exportStar(require("./apigwOperations"), exports);
29
31
  __exportStar(require("./tlsOperations"), exports);
32
+ /**
33
+ * fetchOpenAPI resolves with { ResponseMetadata: { Error } } on API errors
34
+ * (validateStatus: null) — rethrow with .code so callers' error.code checks work.
35
+ */
36
+ const wrapService = (service) => {
37
+ const fetchOpenAPI = service.fetchOpenAPI.bind(service);
38
+ service.fetchOpenAPI = async (params, options) => {
39
+ const response = await fetchOpenAPI(params, options);
40
+ const apiError = response?.ResponseMetadata?.Error;
41
+ if (apiError?.Code) {
42
+ const requestId = response?.ResponseMetadata?.RequestId;
43
+ const action = params.Action || '';
44
+ const error = new Error(`Volcengine ${action} failed: ${apiError.Code}: ${apiError.Message ?? ''}` +
45
+ (requestId ? ` (RequestId: ${requestId})` : ''));
46
+ error.code = apiError.Code;
47
+ error.requestId = requestId;
48
+ error.action = action;
49
+ throw error;
50
+ }
51
+ return response;
52
+ };
53
+ return service;
54
+ };
30
55
  const initializeSdkClients = (context) => {
31
- const vefaasService = new openapi_1.Service({
56
+ const vefaasService = wrapService(new openapi_1.Service({
32
57
  serviceName: 'vefaas',
33
58
  defaultVersion: '2024-06-06',
34
- protocol: 'https',
35
- host: 'vefaas.volcengineapi.com',
36
59
  accessKeyId: context.accessKeyId,
37
60
  secretKey: context.accessKeySecret,
38
61
  region: context.region,
39
62
  ...(context.securityToken && { sessionToken: context.securityToken }),
40
- });
41
- const tosService = new openapi_1.Service({
63
+ }));
64
+ const tosService = wrapService(new openapi_1.Service({
42
65
  serviceName: 'tos',
43
66
  defaultVersion: '2018-08-01',
44
- protocol: 'https',
45
67
  host: `tos-${context.region}.volces.com`,
46
68
  accessKeyId: context.accessKeyId,
47
69
  secretKey: context.accessKeySecret,
48
70
  region: context.region,
49
71
  ...(context.securityToken && { sessionToken: context.securityToken }),
50
- });
51
- const iamService = new openapi_1.Service({
72
+ }));
73
+ const iamService = wrapService(new openapi_1.Service({
52
74
  serviceName: 'iam',
53
75
  defaultVersion: '2024-01-01',
54
- protocol: 'https',
55
- host: 'iam.volcengineapi.com',
56
76
  accessKeyId: context.accessKeyId,
57
77
  secretKey: context.accessKeySecret,
58
78
  region: context.region,
59
79
  ...(context.securityToken && { sessionToken: context.securityToken }),
60
- });
61
- const tlsService = new openapi_1.Service({
62
- serviceName: 'tls',
63
- defaultVersion: '2024-01-01',
64
- protocol: 'https',
65
- host: `tls.${context.region}.volces.com`,
80
+ }));
81
+ const tlsService = new tls_1.TlsService({
82
+ region: context.region,
83
+ host: `tls-${context.region}.volces.com`,
66
84
  accessKeyId: context.accessKeyId,
67
85
  secretKey: context.accessKeySecret,
68
- region: context.region,
69
86
  ...(context.securityToken && { sessionToken: context.securityToken }),
70
87
  });
71
- const apigwService = new openapi_1.Service({
88
+ const apigwService = wrapService(new openapi_1.Service({
72
89
  serviceName: 'apig',
73
90
  defaultVersion: '2021-03-03',
74
- protocol: 'https',
75
- host: 'apig.volcengineapi.com',
76
91
  accessKeyId: context.accessKeyId,
77
92
  secretKey: context.accessKeySecret,
78
93
  region: context.region,
79
94
  ...(context.securityToken && { sessionToken: context.securityToken }),
80
- });
95
+ }));
96
+ const stsService = wrapService(new openapi_1.Service({
97
+ serviceName: 'sts',
98
+ defaultVersion: '2018-01-01',
99
+ accessKeyId: context.accessKeyId,
100
+ secretKey: context.accessKeySecret,
101
+ region: context.region,
102
+ ...(context.securityToken && { sessionToken: context.securityToken }),
103
+ }));
81
104
  return {
82
105
  vefaas: vefaasService,
83
106
  tos: tosService,
84
107
  iam: iamService,
85
108
  tls: tlsService,
86
109
  apigw: apigwService,
110
+ sts: stsService,
87
111
  };
88
112
  };
89
113
  const createVolcengineClient = (context) => {
@@ -94,6 +118,7 @@ const createVolcengineClient = (context) => {
94
118
  iam: (0, iamOperations_1.createIamOperations)(sdkClients.iam),
95
119
  tls: (0, tlsOperations_1.createTlsOperations)(sdkClients.tls),
96
120
  apigw: (0, apigwOperations_1.createApigwOperations)(sdkClients.apigw),
121
+ sts: (0, stsOperations_1.createStsOperations)(sdkClients.sts),
97
122
  };
98
123
  };
99
124
  exports.createVolcengineClient = createVolcengineClient;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createStsOperations = void 0;
4
+ /* istanbul ignore next */ const createStsOperations = (client) => {
5
+ if (!client) {
6
+ return {
7
+ getAccountId: async () => undefined,
8
+ };
9
+ }
10
+ return {
11
+ getAccountId: async () => {
12
+ try {
13
+ const response = await client.fetchOpenAPI({
14
+ Action: 'GetCallerIdentity',
15
+ Version: '2018-01-01',
16
+ method: 'GET',
17
+ query: {},
18
+ });
19
+ const data = (response.Result || {});
20
+ const accountId = data.AccountId;
21
+ if (typeof accountId === 'number') {
22
+ return String(accountId);
23
+ }
24
+ return accountId ?? undefined;
25
+ }
26
+ catch {
27
+ return undefined;
28
+ }
29
+ },
30
+ };
31
+ };
32
+ exports.createStsOperations = createStsOperations;