@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.
- package/.serverlessinsight/state-cdn-flow-app-cdn-flow-service.json.backup +15 -0
- package/.serverlessinsight/state-iam-test-app-iam-test-service.json.backup +33 -0
- package/.serverlessinsight/state-insight-poc-deploy-app-insight-poc-deploy.json.backup +359 -0
- package/.serverlessinsight/state-insight-poc-destroy-app-insight-poc-destroy.json.backup +15 -0
- package/.serverlessinsight/state-insight-volc-app-insight-volc.json.backup +154 -0
- package/.serverlessinsight/state-insight-volc-destroy-app-insight-volc-destroy.json.backup +1 -0
- package/README.md +26 -18
- package/README.zh-CN.md +19 -6
- package/dist/package.json +5 -2
- package/dist/src/commands/deploy.js +87 -4
- package/dist/src/commands/destroy.js +61 -10
- package/dist/src/commands/forceUnlock.js +8 -0
- package/dist/src/commands/index.js +34 -2
- package/dist/src/commands/login.js +195 -0
- package/dist/src/commands/logout.js +17 -0
- package/dist/src/commands/show.js +15 -7
- package/dist/src/commands/whoami.js +20 -0
- package/dist/src/common/aliyunClient/apigwOperations.js +363 -30
- package/dist/src/common/aliyunClient/esOperations.js +43 -29
- package/dist/src/common/aliyunClient/fc3Operations.js +481 -207
- package/dist/src/common/aliyunClient/ossOperations.js +165 -13
- package/dist/src/common/aliyunClient/rdsOperations.js +143 -39
- package/dist/src/common/aliyunClient/slsOperations.js +90 -28
- package/dist/src/common/aliyunClient/tablestoreOperations.js +25 -22
- package/dist/src/common/apiClient.js +102 -0
- package/dist/src/common/constants.js +13 -4
- package/dist/src/common/credentialStore.js +94 -0
- package/dist/src/common/credentials.js +2 -0
- package/dist/src/common/eventQueue.js +208 -0
- package/dist/src/common/hashUtils.js +87 -11
- package/dist/src/common/imsClient.js +1 -0
- package/dist/src/common/index.js +3 -0
- package/dist/src/common/lockManager.js +61 -54
- package/dist/src/common/logger.js +2 -0
- package/dist/src/common/polling.js +54 -0
- package/dist/src/common/reportResourceEvent.js +8 -0
- package/dist/src/common/runtimeMapper.js +11 -12
- package/dist/src/common/stateBackend/index.js +10 -1
- package/dist/src/common/stateBackend/localStateBackend.js +4 -1
- package/dist/src/common/stateBackend/remoteStateBackend.js +10 -4
- package/dist/src/common/stateBackend/saasStateBackend.js +266 -0
- package/dist/src/common/stateManager.js +186 -14
- package/dist/src/common/tencentClient/clsOperations.js +137 -0
- package/dist/src/common/tencentClient/cosOperations.js +180 -3
- package/dist/src/common/tencentClient/esOperations.js +110 -46
- package/dist/src/common/tencentClient/index.js +43 -2
- package/dist/src/common/tencentClient/scfOperations.js +266 -133
- package/dist/src/common/tencentClient/tdsqlcClusterMapper.js +81 -0
- package/dist/src/common/tencentClient/tdsqlcOperations.js +93 -99
- package/dist/src/common/triggerMapper.js +36 -0
- package/dist/src/common/volcengineClient/apigwOperations.js +539 -159
- package/dist/src/common/volcengineClient/iamOperations.js +91 -48
- package/dist/src/common/volcengineClient/index.js +46 -21
- package/dist/src/common/volcengineClient/stsOperations.js +32 -0
- package/dist/src/common/volcengineClient/tlsOperations.js +305 -171
- package/dist/src/common/volcengineClient/tosOperations.js +78 -19
- package/dist/src/common/volcengineClient/vefaasOperations.js +272 -54
- package/dist/src/lang/en.js +107 -1
- package/dist/src/lang/zh-CN.js +107 -1
- package/dist/src/parser/eventParser.js +2 -0
- package/dist/src/parser/functionParser.js +96 -65
- package/dist/src/parser/index.js +7 -4
- package/dist/src/stack/aliyunStack/apigwExecutor.js +39 -1
- package/dist/src/stack/aliyunStack/apigwPlanner.js +16 -10
- package/dist/src/stack/aliyunStack/apigwResource.js +334 -125
- package/dist/src/stack/aliyunStack/apigwTypes.js +35 -4
- package/dist/src/stack/aliyunStack/databaseExecutor.js +39 -1
- package/dist/src/stack/aliyunStack/databasePlanner.js +13 -1
- package/dist/src/stack/aliyunStack/databaseResource.js +135 -40
- package/dist/src/stack/aliyunStack/deployer.js +2 -2
- package/dist/src/stack/aliyunStack/destroyer.js +27 -2
- package/dist/src/stack/aliyunStack/fc3Executor.js +25 -2
- package/dist/src/stack/aliyunStack/fc3Planner.js +11 -1
- package/dist/src/stack/aliyunStack/fc3Resource.js +416 -94
- package/dist/src/stack/aliyunStack/ossExecutor.js +39 -1
- package/dist/src/stack/aliyunStack/ossPlanner.js +15 -1
- package/dist/src/stack/aliyunStack/ossResource.js +267 -219
- package/dist/src/stack/aliyunStack/sharedLogProject.js +137 -0
- package/dist/src/stack/aliyunStack/tablestoreExecutor.js +39 -1
- package/dist/src/stack/aliyunStack/tablestorePlanner.js +13 -1
- package/dist/src/stack/aliyunStack/tablestoreResource.js +54 -20
- package/dist/src/stack/alreadyExists.js +26 -0
- package/dist/src/stack/ownershipTag.js +58 -0
- package/dist/src/stack/rfsStack/index.js +3 -1
- package/dist/src/stack/scfStack/cosExecutor.js +39 -1
- package/dist/src/stack/scfStack/cosPlanner.js +11 -1
- package/dist/src/stack/scfStack/cosResource.js +167 -64
- package/dist/src/stack/scfStack/deployer.js +2 -2
- package/dist/src/stack/scfStack/destroyer.js +15 -2
- package/dist/src/stack/scfStack/esServerlessExecutor.js +39 -1
- package/dist/src/stack/scfStack/esServerlessPlanner.js +11 -1
- package/dist/src/stack/scfStack/esServerlessResource.js +88 -23
- package/dist/src/stack/scfStack/scfExecutor.js +39 -1
- package/dist/src/stack/scfStack/scfPlanner.js +21 -3
- package/dist/src/stack/scfStack/scfResource.js +686 -24
- package/dist/src/stack/scfStack/scfTypes.js +6 -0
- package/dist/src/stack/scfStack/sharedLogset.js +126 -0
- package/dist/src/stack/scfStack/tdsqlcExecutor.js +39 -1
- package/dist/src/stack/scfStack/tdsqlcPlanner.js +12 -1
- package/dist/src/stack/scfStack/tdsqlcResource.js +95 -16
- package/dist/src/stack/scfStack/tdsqlcTypes.js +5 -1
- package/dist/src/stack/volcengineStack/apigwExecutor.js +39 -1
- package/dist/src/stack/volcengineStack/apigwPlanner.js +25 -53
- package/dist/src/stack/volcengineStack/apigwResource.js +434 -222
- package/dist/src/stack/volcengineStack/apigwTypes.js +85 -66
- package/dist/src/stack/volcengineStack/deployer.js +49 -14
- package/dist/src/stack/volcengineStack/destroyer.js +13 -1
- package/dist/src/stack/volcengineStack/index.js +1 -2
- package/dist/src/stack/volcengineStack/sharedLogProject.js +190 -0
- package/dist/src/stack/volcengineStack/tosExecutor.js +25 -2
- package/dist/src/stack/volcengineStack/tosPlanner.js +11 -1
- package/dist/src/stack/volcengineStack/tosResource.js +82 -27
- package/dist/src/stack/volcengineStack/tosTypes.js +12 -0
- package/dist/src/stack/volcengineStack/vefaasExecutor.js +25 -2
- package/dist/src/stack/volcengineStack/vefaasPlanner.js +78 -2
- package/dist/src/stack/volcengineStack/vefaasResource.js +194 -144
- package/dist/src/stack/volcengineStack/vefaasTypes.js +1 -3
- package/dist/src/types/domains/backend.js +1 -0
- package/dist/src/types/domains/state.js +32 -1
- package/dist/src/validator/eventSchema.js +10 -0
- package/dist/src/validator/functionSchema.js +37 -12
- package/dist/src/validator/iacSchema.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- 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
|
|
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: '
|
|
68
|
-
method: '
|
|
77
|
+
Version: '2018-01-01',
|
|
78
|
+
method: 'GET',
|
|
69
79
|
headers: { 'content-type': 'application/json' },
|
|
70
|
-
|
|
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
|
-
|
|
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: '
|
|
94
|
-
method: '
|
|
108
|
+
Version: '2018-01-01',
|
|
109
|
+
method: 'GET',
|
|
95
110
|
headers: { 'content-type': 'application/json' },
|
|
96
|
-
|
|
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
|
-
|
|
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: '
|
|
124
|
-
method: '
|
|
143
|
+
Version: '2018-01-01',
|
|
144
|
+
method: 'GET',
|
|
125
145
|
headers: { 'content-type': 'application/json' },
|
|
126
|
-
|
|
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: '
|
|
140
|
-
method: '
|
|
159
|
+
Version: '2018-01-01',
|
|
160
|
+
method: 'GET',
|
|
141
161
|
headers: { 'content-type': 'application/json' },
|
|
142
|
-
|
|
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: '
|
|
157
|
-
method: '
|
|
176
|
+
Version: '2018-01-01',
|
|
177
|
+
method: 'GET',
|
|
158
178
|
headers: { 'content-type': 'application/json' },
|
|
159
|
-
|
|
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: '
|
|
182
|
-
method: '
|
|
201
|
+
Version: '2018-01-01',
|
|
202
|
+
method: 'GET',
|
|
183
203
|
headers: { 'content-type': 'application/json' },
|
|
184
|
-
|
|
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: '
|
|
207
|
-
method: '
|
|
226
|
+
Version: '2018-01-01',
|
|
227
|
+
method: 'GET',
|
|
208
228
|
headers: { 'content-type': 'application/json' },
|
|
209
|
-
|
|
229
|
+
query: { RoleName: roleName },
|
|
210
230
|
});
|
|
211
231
|
const result = (response.Result || {});
|
|
212
|
-
const attachedPolicies = result.
|
|
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: '
|
|
232
|
-
method: '
|
|
251
|
+
Version: '2018-01-01',
|
|
252
|
+
method: 'GET',
|
|
233
253
|
headers: { 'content-type': 'application/json' },
|
|
234
|
-
|
|
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: '
|
|
271
|
-
method: '
|
|
290
|
+
Version: '2018-01-01',
|
|
291
|
+
method: 'GET',
|
|
272
292
|
headers: { 'content-type': 'application/json' },
|
|
273
|
-
|
|
293
|
+
query: { RoleName: roleName },
|
|
274
294
|
});
|
|
275
295
|
await iamClient.fetchOpenAPI({
|
|
276
|
-
Action: '
|
|
277
|
-
Version: '
|
|
278
|
-
method: '
|
|
296
|
+
Action: 'UpdateRole',
|
|
297
|
+
Version: '2018-01-01',
|
|
298
|
+
method: 'GET',
|
|
279
299
|
headers: { 'content-type': 'application/json' },
|
|
280
|
-
|
|
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: '
|
|
322
|
-
method: '
|
|
341
|
+
Version: '2018-01-01',
|
|
342
|
+
method: 'GET',
|
|
323
343
|
headers: { 'content-type': 'application/json' },
|
|
324
|
-
|
|
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: '
|
|
355
|
-
Version: '
|
|
356
|
-
method: '
|
|
374
|
+
Action: 'UpdateRole',
|
|
375
|
+
Version: '2018-01-01',
|
|
376
|
+
method: 'GET',
|
|
357
377
|
headers: { 'content-type': 'application/json' },
|
|
358
|
-
|
|
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: '
|
|
386
|
-
method: '
|
|
405
|
+
Version: '2018-01-01',
|
|
406
|
+
method: 'GET',
|
|
387
407
|
headers: { 'content-type': 'application/json' },
|
|
388
|
-
|
|
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
|
|
62
|
-
|
|
63
|
-
|
|
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;
|