@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.
- package/.serverlessinsight/state-cdn-flow-app-cdn-flow-service.json.backup +14 -0
- package/.serverlessinsight/state-iam-test-app-iam-test-service.json.backup +14 -0
- package/.serverlessinsight/state-insight-poc-deploy-app-insight-poc-deploy.json.backup +348 -0
- package/.serverlessinsight/state-insight-poc-destroy-app-insight-poc-destroy.json.backup +14 -0
- package/.serverlessinsight/state-insight-volc-app-insight-volc.json.backup +114 -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 +3 -1
- 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 +332 -32
- 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 +56 -26
- package/dist/src/common/aliyunClient/tablestoreOperations.js +25 -22
- package/dist/src/common/apiClient.js +102 -0
- package/dist/src/common/constants.js +9 -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 +6 -3
- package/dist/src/common/stateBackend/saasStateBackend.js +266 -0
- package/dist/src/common/stateManager.js +135 -13
- 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 +22 -1
- package/dist/src/common/tencentClient/scfOperations.js +255 -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 +58 -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 +229 -178
- package/dist/src/common/volcengineClient/tosOperations.js +78 -19
- package/dist/src/common/volcengineClient/vefaasOperations.js +272 -54
- package/dist/src/lang/en.js +84 -0
- package/dist/src/lang/zh-CN.js +84 -0
- 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 +14 -10
- package/dist/src/stack/aliyunStack/apigwResource.js +230 -125
- package/dist/src/stack/aliyunStack/apigwTypes.js +16 -3
- 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 +2 -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 +327 -64
- 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/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 +40 -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 +2 -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 +12 -2
- package/dist/src/stack/scfStack/scfResource.js +484 -14
- 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 +418 -222
- package/dist/src/stack/volcengineStack/apigwTypes.js +76 -66
- package/dist/src/stack/volcengineStack/deployer.js +49 -14
- package/dist/src/stack/volcengineStack/destroyer.js +1 -1
- package/dist/src/stack/volcengineStack/index.js +1 -2
- 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 +71 -2
- package/dist/src/stack/volcengineStack/vefaasResource.js +148 -98
- 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 +29 -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 +3 -1
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.createApigwOperations = exports.isDomainAlreadyBoundError = exports.isNetworkTimeoutError = void 0;
|
|
36
|
+
exports.createApigwOperations = exports.isApigwNotFoundError = exports.isDomainAlreadyBoundError = exports.isNetworkTimeoutError = void 0;
|
|
37
37
|
const cloudapi = __importStar(require("@alicloud/cloudapi20160714"));
|
|
38
38
|
const node_dns_1 = require("node:dns");
|
|
39
39
|
const dnsOperations_1 = require("./dnsOperations");
|
|
@@ -71,6 +71,14 @@ const isDomainAlreadyBoundError = (error) => {
|
|
|
71
71
|
(err.message?.toLowerCase().includes('domain bindedbyother') ?? false));
|
|
72
72
|
};
|
|
73
73
|
exports.isDomainAlreadyBoundError = isDomainAlreadyBoundError;
|
|
74
|
+
const isApigwNotFoundError = (error) => {
|
|
75
|
+
if (!error || typeof error !== 'object')
|
|
76
|
+
return false;
|
|
77
|
+
const err = error;
|
|
78
|
+
return ((typeof err.code === 'string' && err.code.includes('NotFound')) ||
|
|
79
|
+
(typeof err.message === 'string' && err.message.includes('NotFound')));
|
|
80
|
+
};
|
|
81
|
+
exports.isApigwNotFoundError = isApigwNotFoundError;
|
|
74
82
|
/* istanbul ignore next */
|
|
75
83
|
const createApigwOperations = (apigwClient, dnsClient, _context) => {
|
|
76
84
|
const dnsOps = (0, dnsOperations_1.createDnsOperations)(dnsClient);
|
|
@@ -151,7 +159,9 @@ const createApigwOperations = (apigwClient, dnsClient, _context) => {
|
|
|
151
159
|
// For CNAME verification: point the domain directly to the group subdomain
|
|
152
160
|
const verificationHost = domainName;
|
|
153
161
|
const verificationValue = groupSubdomain;
|
|
154
|
-
|
|
162
|
+
// Use domain-specific key so primary and www don't collide
|
|
163
|
+
const domainKey = domainName.replace(/[^a-zA-Z0-9]/g, '_');
|
|
164
|
+
const dnsResourceId = `${eventLogicalId}.dns_verification.${domainKey}`;
|
|
155
165
|
try {
|
|
156
166
|
// Check if DNS record is tracked in state
|
|
157
167
|
const existingDnsResource = (0, stateManager_1.getResource)(state, dnsResourceId);
|
|
@@ -262,7 +272,8 @@ const createApigwOperations = (apigwClient, dnsClient, _context) => {
|
|
|
262
272
|
const addTxtVerificationRecord = async (groupId, domainName, groupSubdomain, region, state, eventLogicalId) => {
|
|
263
273
|
const mainDomain = (0, domainUtils_1.extractMainDomain)(domainName);
|
|
264
274
|
const txtRecord = buildTxtVerificationRecord(groupId, domainName, groupSubdomain, mainDomain);
|
|
265
|
-
const
|
|
275
|
+
const txtDomainKey = domainName.replace(/[^a-zA-Z0-9]/g, '_');
|
|
276
|
+
const txtResourceId = `${eventLogicalId}.dns_txt_verification.${txtDomainKey}`;
|
|
266
277
|
logger_1.logger.info(lang_1.lang.__('APIGW_TXT_ADDING_RECORD', { rr: txtRecord.rr, value: txtRecord.value }));
|
|
267
278
|
try {
|
|
268
279
|
const existingRecords = await dnsOps.describeDomainRecords(mainDomain, txtRecord.rr);
|
|
@@ -346,7 +357,7 @@ const createApigwOperations = (apigwClient, dnsClient, _context) => {
|
|
|
346
357
|
logger_1.logger.error(`\n${separator}\n${lang_1.lang.__('APIGW_VERIFICATION_HEADER')}\n${separator}\n${lang_1.lang.__('APIGW_VERIFICATION_DOMAIN', { domain: domainName })}\n\n${lang_1.lang.__('APIGW_VERIFICATION_INSTRUCTIONS')}\n\n${lang_1.lang.__('APIGW_VERIFICATION_OPTION1')}\n${lang_1.lang.__('APIGW_VERIFICATION_RECORD_NAME', { name: domainName })}\n${lang_1.lang.__('APIGW_VERIFICATION_RECORD_TYPE', { type: 'CNAME' })}\n${lang_1.lang.__('APIGW_VERIFICATION_RECORD_VALUE', { value: groupSubdomain })}\n\n${lang_1.lang.__('APIGW_VERIFICATION_OPTION2')}\n${lang_1.lang.__('APIGW_VERIFICATION_RECORD_NAME', { name: txtRecord.rr })}\n${lang_1.lang.__('APIGW_VERIFICATION_RECORD_TYPE', { type: 'TXT' })}\n${lang_1.lang.__('APIGW_VERIFICATION_RECORD_VALUE', { value: txtRecord.value })}`);
|
|
347
358
|
logger_1.logger.error(`\n${separator}\n${lang_1.lang.__('APIGW_VERIFICATION_NEXT_STEPS')}\n${lang_1.lang.__('APIGW_VERIFICATION_STEP1')}\n${lang_1.lang.__('APIGW_VERIFICATION_STEP2')}\n${separator}\n`);
|
|
348
359
|
};
|
|
349
|
-
|
|
360
|
+
const operations = {
|
|
350
361
|
/**
|
|
351
362
|
* Create an API Gateway group
|
|
352
363
|
*/
|
|
@@ -376,28 +387,103 @@ const createApigwOperations = (apigwClient, dnsClient, _context) => {
|
|
|
376
387
|
if (!response.body) {
|
|
377
388
|
return null;
|
|
378
389
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
390
|
+
const body = response.body;
|
|
391
|
+
const groupInfo = {
|
|
392
|
+
groupId: body.groupId,
|
|
393
|
+
groupName: body.groupName,
|
|
394
|
+
description: body.description,
|
|
395
|
+
basePath: body.basePath,
|
|
396
|
+
subDomain: body.subDomain,
|
|
397
|
+
instanceId: body.instanceId,
|
|
398
|
+
instanceType: body.instanceType,
|
|
399
|
+
regionId: body.regionId,
|
|
400
|
+
status: body.status,
|
|
401
|
+
createdTime: body.createdTime,
|
|
402
|
+
modifiedTime: body.modifiedTime,
|
|
403
|
+
billingStatus: body.billingStatus,
|
|
404
|
+
illegalStatus: body.illegalStatus,
|
|
405
|
+
trafficLimit: body.trafficLimit,
|
|
406
|
+
// Maximum-detail fields — retain everything DescribeApiGroup returns.
|
|
407
|
+
customDomains: body.customDomains?.domainItem?.map((d) => ({
|
|
408
|
+
bindStageAlias: d.bindStageAlias,
|
|
409
|
+
bindStageName: d.bindStageName,
|
|
410
|
+
certificateId: d.certificateId,
|
|
411
|
+
certificateName: d.certificateName,
|
|
412
|
+
certificateValidEnd: d.certificateValidEnd,
|
|
413
|
+
certificateValidStart: d.certificateValidStart,
|
|
414
|
+
clientCertSDnPassThrough: d.clientCertSDnPassThrough,
|
|
415
|
+
customDomainType: d.customDomainType,
|
|
416
|
+
domainBindingStatus: d.domainBindingStatus,
|
|
417
|
+
domainCNAMEStatus: d.domainCNAMEStatus,
|
|
418
|
+
domainLegalStatus: d.domainLegalStatus,
|
|
419
|
+
domainName: d.domainName,
|
|
420
|
+
domainRemark: d.domainRemark,
|
|
421
|
+
domainWebSocketStatus: d.domainWebSocketStatus,
|
|
422
|
+
isHttpRedirectToHttps: d.isHttpRedirectToHttps,
|
|
423
|
+
sslOcspCacheEnable: d.sslOcspCacheEnable,
|
|
424
|
+
sslOcspEnable: d.sslOcspEnable,
|
|
425
|
+
sslVerifyDepth: d.sslVerifyDepth,
|
|
426
|
+
wildcardDomainPatterns: d.wildcardDomainPatterns,
|
|
427
|
+
})),
|
|
428
|
+
stageItems: body.stageItems?.stageInfo?.map((s) => ({
|
|
429
|
+
description: s.description,
|
|
430
|
+
stageId: s.stageId,
|
|
431
|
+
stageName: s.stageName,
|
|
432
|
+
})),
|
|
433
|
+
defaultDomain: body.defaultDomain,
|
|
434
|
+
vpcDomain: body.vpcDomain,
|
|
435
|
+
vpcSlbIntranetDomain: body.vpcSlbIntranetDomain,
|
|
436
|
+
httpsPolicy: body.httpsPolicy,
|
|
437
|
+
ipv6Status: body.ipv6Status,
|
|
438
|
+
migrationStatus: body.migrationStatus,
|
|
439
|
+
migrationError: body.migrationError,
|
|
440
|
+
passthroughHeaders: body.passthroughHeaders,
|
|
441
|
+
userLogConfig: body.userLogConfig,
|
|
442
|
+
customTraceConfig: body.customTraceConfig,
|
|
443
|
+
customerConfigs: body.customerConfigs,
|
|
444
|
+
customAppCodeConfig: body.customAppCodeConfig,
|
|
445
|
+
dedicatedInstanceType: body.dedicatedInstanceType,
|
|
446
|
+
disableInnerDomain: body.disableInnerDomain,
|
|
447
|
+
cloudMarketCommodity: body.cloudMarketCommodity,
|
|
448
|
+
cmsMonitorGroup: body.cmsMonitorGroup,
|
|
449
|
+
compatibleFlags: body.compatibleFlags,
|
|
394
450
|
};
|
|
451
|
+
try {
|
|
452
|
+
const tags = await operations.getGroupTags(groupId);
|
|
453
|
+
if (tags) {
|
|
454
|
+
groupInfo.tags = tags;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
catch {
|
|
458
|
+
// Tags are best-effort; group detail is still returned without them.
|
|
459
|
+
}
|
|
460
|
+
return groupInfo;
|
|
395
461
|
}
|
|
396
462
|
catch (error) {
|
|
397
|
-
if (error
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
463
|
+
if ((0, exports.isApigwNotFoundError)(error)) {
|
|
464
|
+
return null;
|
|
465
|
+
}
|
|
466
|
+
throw error;
|
|
467
|
+
}
|
|
468
|
+
},
|
|
469
|
+
/**
|
|
470
|
+
* Fetch resource tags for an API group (ListTagResources).
|
|
471
|
+
*/
|
|
472
|
+
getGroupTags: async (groupId) => {
|
|
473
|
+
try {
|
|
474
|
+
const request = new cloudapi.ListTagResourcesRequest({
|
|
475
|
+
resourceType: 'apiGroup',
|
|
476
|
+
resourceId: [groupId],
|
|
477
|
+
});
|
|
478
|
+
const response = await apigwClient.listTagResources(request);
|
|
479
|
+
const tagResources = response.body?.tagResources?.tagResource ?? [];
|
|
480
|
+
if (tagResources.length === 0) {
|
|
481
|
+
return null;
|
|
482
|
+
}
|
|
483
|
+
return tagResources.map((t) => ({ Key: t.tagKey, Value: t.tagValue }));
|
|
484
|
+
}
|
|
485
|
+
catch (error) {
|
|
486
|
+
if ((0, exports.isApigwNotFoundError)(error)) {
|
|
401
487
|
return null;
|
|
402
488
|
}
|
|
403
489
|
throw error;
|
|
@@ -430,9 +516,13 @@ const createApigwOperations = (apigwClient, dnsClient, _context) => {
|
|
|
430
516
|
instanceId: group.instanceId,
|
|
431
517
|
instanceType: group.instanceType,
|
|
432
518
|
regionId: group.regionId,
|
|
519
|
+
httpsPolicy: group.httpsPolicy,
|
|
520
|
+
createdTime: group.createdTime,
|
|
521
|
+
modifiedTime: group.modifiedTime,
|
|
433
522
|
billingStatus: group.billingStatus,
|
|
434
523
|
illegalStatus: group.illegalStatus,
|
|
435
524
|
trafficLimit: group.trafficLimit,
|
|
525
|
+
tags: group.tags?.tagInfo?.map((t) => ({ Key: t.key, Value: t.value })),
|
|
436
526
|
};
|
|
437
527
|
},
|
|
438
528
|
/**
|
|
@@ -454,7 +544,19 @@ const createApigwOperations = (apigwClient, dnsClient, _context) => {
|
|
|
454
544
|
const request = new cloudapi.DeleteApiGroupRequest({
|
|
455
545
|
groupId,
|
|
456
546
|
});
|
|
457
|
-
|
|
547
|
+
try {
|
|
548
|
+
await apigwClient.deleteApiGroup(request);
|
|
549
|
+
}
|
|
550
|
+
catch (error) {
|
|
551
|
+
if ((0, exports.isApigwNotFoundError)(error)) {
|
|
552
|
+
logger_1.logger.warn(lang_1.lang.__('RESOURCE_NOT_FOUND_PROVIDER', {
|
|
553
|
+
resourceType: 'API Gateway group',
|
|
554
|
+
name: groupId,
|
|
555
|
+
}));
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
throw error;
|
|
559
|
+
}
|
|
458
560
|
},
|
|
459
561
|
/**
|
|
460
562
|
* Create an API in API Gateway
|
|
@@ -525,7 +627,7 @@ const createApigwOperations = (apigwClient, dnsClient, _context) => {
|
|
|
525
627
|
return null;
|
|
526
628
|
}
|
|
527
629
|
const body = response.body;
|
|
528
|
-
|
|
630
|
+
const apiInfo = {
|
|
529
631
|
apiId: body.apiId,
|
|
530
632
|
apiName: body.apiName,
|
|
531
633
|
groupId: body.groupId,
|
|
@@ -540,6 +642,9 @@ const createApigwOperations = (apigwClient, dnsClient, _context) => {
|
|
|
540
642
|
requestPath: body.requestConfig.requestPath,
|
|
541
643
|
requestMode: body.requestConfig.requestMode,
|
|
542
644
|
bodyFormat: body.requestConfig.bodyFormat,
|
|
645
|
+
bodyModel: body.requestConfig.bodyModel,
|
|
646
|
+
escapePathParam: body.requestConfig.escapePathParam,
|
|
647
|
+
postBodyDescription: body.requestConfig.postBodyDescription,
|
|
543
648
|
}
|
|
544
649
|
: undefined,
|
|
545
650
|
serviceConfig: body.serviceConfig
|
|
@@ -549,6 +654,41 @@ const createApigwOperations = (apigwClient, dnsClient, _context) => {
|
|
|
549
654
|
serviceHttpMethod: body.serviceConfig.serviceHttpMethod,
|
|
550
655
|
servicePath: body.serviceConfig.servicePath,
|
|
551
656
|
serviceTimeout: body.serviceConfig.serviceTimeout,
|
|
657
|
+
aoneAppName: body.serviceConfig.aoneAppName,
|
|
658
|
+
contentTypeCatagory: body.serviceConfig.contentTypeCatagory,
|
|
659
|
+
contentTypeValue: body.serviceConfig.contentTypeValue,
|
|
660
|
+
eventBridgeConfig: body.serviceConfig.eventBridgeConfig
|
|
661
|
+
? {
|
|
662
|
+
eventBridgeRegionId: body.serviceConfig.eventBridgeConfig.eventBridgeRegionId,
|
|
663
|
+
eventBus: body.serviceConfig.eventBridgeConfig.eventBus,
|
|
664
|
+
eventSource: body.serviceConfig.eventBridgeConfig.eventSource,
|
|
665
|
+
roleArn: body.serviceConfig.eventBridgeConfig.roleArn,
|
|
666
|
+
}
|
|
667
|
+
: undefined,
|
|
668
|
+
mock: body.serviceConfig.mock,
|
|
669
|
+
mockHeaders: body.serviceConfig.mockHeaders?.mockHeader?.map((h) => ({
|
|
670
|
+
headerName: h.headerName,
|
|
671
|
+
headerValue: h.headerValue,
|
|
672
|
+
})),
|
|
673
|
+
mockStatusCode: body.serviceConfig.mockStatusCode,
|
|
674
|
+
ossConfig: body.serviceConfig.ossConfig
|
|
675
|
+
? {
|
|
676
|
+
action: body.serviceConfig.ossConfig.action,
|
|
677
|
+
bucketName: body.serviceConfig.ossConfig.bucketName,
|
|
678
|
+
key: body.serviceConfig.ossConfig.key,
|
|
679
|
+
ossRegionId: body.serviceConfig.ossConfig.ossRegionId,
|
|
680
|
+
}
|
|
681
|
+
: undefined,
|
|
682
|
+
serviceVpcEnable: body.serviceConfig.serviceVpcEnable,
|
|
683
|
+
vpcConfig: body.serviceConfig.vpcConfig
|
|
684
|
+
? {
|
|
685
|
+
instanceId: body.serviceConfig.vpcConfig.instanceId,
|
|
686
|
+
name: body.serviceConfig.vpcConfig.name,
|
|
687
|
+
port: body.serviceConfig.vpcConfig.port,
|
|
688
|
+
vpcId: body.serviceConfig.vpcConfig.vpcId,
|
|
689
|
+
vpcScheme: body.serviceConfig.vpcConfig.vpcScheme,
|
|
690
|
+
}
|
|
691
|
+
: undefined,
|
|
552
692
|
functionComputeConfig: body.serviceConfig.functionComputeConfig
|
|
553
693
|
? {
|
|
554
694
|
fcRegionId: body.serviceConfig.functionComputeConfig.fcRegionId,
|
|
@@ -556,6 +696,16 @@ const createApigwOperations = (apigwClient, dnsClient, _context) => {
|
|
|
556
696
|
roleArn: body.serviceConfig.functionComputeConfig.roleArn,
|
|
557
697
|
fcVersion: body.serviceConfig.functionComputeConfig.fcVersion,
|
|
558
698
|
method: body.serviceConfig.functionComputeConfig.method,
|
|
699
|
+
contentTypeCatagory: body.serviceConfig.functionComputeConfig.contentTypeCatagory,
|
|
700
|
+
contentTypeValue: body.serviceConfig.functionComputeConfig.contentTypeValue,
|
|
701
|
+
fcBaseUrl: body.serviceConfig.functionComputeConfig.fcBaseUrl,
|
|
702
|
+
fcType: body.serviceConfig.functionComputeConfig.fcType,
|
|
703
|
+
onlyBusinessPath: body.serviceConfig.functionComputeConfig.onlyBusinessPath,
|
|
704
|
+
path: body.serviceConfig.functionComputeConfig.path,
|
|
705
|
+
qualifier: body.serviceConfig.functionComputeConfig.qualifier,
|
|
706
|
+
regionId: body.serviceConfig.functionComputeConfig.regionId,
|
|
707
|
+
serviceName: body.serviceConfig.functionComputeConfig.serviceName,
|
|
708
|
+
triggerName: body.serviceConfig.functionComputeConfig.triggerName,
|
|
559
709
|
}
|
|
560
710
|
: undefined,
|
|
561
711
|
mockResult: body.serviceConfig.mockResult,
|
|
@@ -563,6 +713,87 @@ const createApigwOperations = (apigwClient, dnsClient, _context) => {
|
|
|
563
713
|
: undefined,
|
|
564
714
|
resultType: body.resultType,
|
|
565
715
|
resultSample: body.resultSample,
|
|
716
|
+
failResultSample: body.failResultSample,
|
|
717
|
+
regionId: body.regionId,
|
|
718
|
+
tagList: body.tagList?.tag?.map((t) => ({ tagKey: t.tagKey, tagValue: t.tagValue })),
|
|
719
|
+
backendConfig: body.backendConfig
|
|
720
|
+
? {
|
|
721
|
+
backendId: body.backendConfig.backendId,
|
|
722
|
+
backendName: body.backendConfig.backendName,
|
|
723
|
+
backendType: body.backendConfig.backendType,
|
|
724
|
+
}
|
|
725
|
+
: undefined,
|
|
726
|
+
backendEnable: body.backendEnable,
|
|
727
|
+
openIdConnectConfig: body.openIdConnectConfig
|
|
728
|
+
? {
|
|
729
|
+
idTokenParamName: body.openIdConnectConfig.idTokenParamName,
|
|
730
|
+
openIdApiType: body.openIdConnectConfig.openIdApiType,
|
|
731
|
+
publicKey: body.openIdConnectConfig.publicKey,
|
|
732
|
+
publicKeyId: body.openIdConnectConfig.publicKeyId,
|
|
733
|
+
}
|
|
734
|
+
: undefined,
|
|
735
|
+
requestParameters: body.requestParameters?.requestParameter?.map((p) => ({
|
|
736
|
+
apiParameterName: p.apiParameterName,
|
|
737
|
+
arrayItemsType: p.arrayItemsType,
|
|
738
|
+
defaultValue: p.defaultValue,
|
|
739
|
+
demoValue: p.demoValue,
|
|
740
|
+
description: p.description,
|
|
741
|
+
docOrder: p.docOrder,
|
|
742
|
+
docShow: p.docShow,
|
|
743
|
+
enumValue: p.enumValue,
|
|
744
|
+
jsonScheme: p.jsonScheme,
|
|
745
|
+
location: p.location,
|
|
746
|
+
maxLength: p.maxLength,
|
|
747
|
+
maxValue: p.maxValue,
|
|
748
|
+
minLength: p.minLength,
|
|
749
|
+
minValue: p.minValue,
|
|
750
|
+
parameterType: p.parameterType,
|
|
751
|
+
regularExpression: p.regularExpression,
|
|
752
|
+
required: p.required,
|
|
753
|
+
})),
|
|
754
|
+
serviceParameters: body.serviceParameters?.serviceParameter?.map((p) => ({
|
|
755
|
+
location: p.location,
|
|
756
|
+
parameterType: p.parameterType,
|
|
757
|
+
serviceParameterName: p.serviceParameterName,
|
|
758
|
+
})),
|
|
759
|
+
serviceParametersMap: body.serviceParametersMap?.serviceParameterMap?.map((p) => ({
|
|
760
|
+
requestParameterName: p.requestParameterName,
|
|
761
|
+
serviceParameterName: p.serviceParameterName,
|
|
762
|
+
})),
|
|
763
|
+
systemParameters: body.systemParameters?.systemParameter?.map((p) => ({
|
|
764
|
+
demoValue: p.demoValue,
|
|
765
|
+
description: p.description,
|
|
766
|
+
location: p.location,
|
|
767
|
+
parameterName: p.parameterName,
|
|
768
|
+
serviceParameterName: p.serviceParameterName,
|
|
769
|
+
})),
|
|
770
|
+
customSystemParameters: body.customSystemParameters?.customSystemParameter?.map((p) => ({
|
|
771
|
+
demoValue: p.demoValue,
|
|
772
|
+
description: p.description,
|
|
773
|
+
location: p.location,
|
|
774
|
+
parameterName: p.parameterName,
|
|
775
|
+
serviceParameterName: p.serviceParameterName,
|
|
776
|
+
})),
|
|
777
|
+
constantParameters: body.constantParameters?.constantParameter?.map((p) => ({
|
|
778
|
+
constantValue: p.constantValue,
|
|
779
|
+
description: p.description,
|
|
780
|
+
location: p.location,
|
|
781
|
+
serviceParameterName: p.serviceParameterName,
|
|
782
|
+
})),
|
|
783
|
+
errorCodeSamples: body.errorCodeSamples?.errorCodeSample?.map((e) => ({
|
|
784
|
+
code: e.code,
|
|
785
|
+
description: e.description,
|
|
786
|
+
message: e.message,
|
|
787
|
+
model: e.model,
|
|
788
|
+
})),
|
|
789
|
+
resultBodyModel: body.resultBodyModel,
|
|
790
|
+
mock: body.mock,
|
|
791
|
+
mockResult: body.mockResult,
|
|
792
|
+
disableInternet: body.disableInternet,
|
|
793
|
+
forceNonceCheck: body.forceNonceCheck,
|
|
794
|
+
allowSignatureMethod: body.allowSignatureMethod,
|
|
795
|
+
appCodeAuthType: body.appCodeAuthType,
|
|
796
|
+
webSocketApiType: body.webSocketApiType,
|
|
566
797
|
createdTime: body.createdTime,
|
|
567
798
|
modifiedTime: body.modifiedTime,
|
|
568
799
|
deployedInfos: body.deployedInfos?.deployedInfo?.map((info) => ({
|
|
@@ -571,12 +802,44 @@ const createApigwOperations = (apigwClient, dnsClient, _context) => {
|
|
|
571
802
|
effectiveVersion: info.effectiveVersion,
|
|
572
803
|
})),
|
|
573
804
|
};
|
|
805
|
+
if (!apiInfo.tagList || apiInfo.tagList.length === 0) {
|
|
806
|
+
try {
|
|
807
|
+
const tags = await operations.getApiTags(groupId, apiId);
|
|
808
|
+
if (tags) {
|
|
809
|
+
apiInfo.tagList = tags;
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
catch {
|
|
813
|
+
// Tags are best-effort; API detail is still returned without them.
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
return apiInfo;
|
|
817
|
+
}
|
|
818
|
+
catch (error) {
|
|
819
|
+
if ((0, exports.isApigwNotFoundError)(error)) {
|
|
820
|
+
return null;
|
|
821
|
+
}
|
|
822
|
+
throw error;
|
|
823
|
+
}
|
|
824
|
+
},
|
|
825
|
+
/**
|
|
826
|
+
* Fetch resource tags for an API (ListTagResources).
|
|
827
|
+
*/
|
|
828
|
+
getApiTags: async (groupId, apiId) => {
|
|
829
|
+
try {
|
|
830
|
+
const request = new cloudapi.ListTagResourcesRequest({
|
|
831
|
+
resourceType: 'api',
|
|
832
|
+
resourceId: [apiId],
|
|
833
|
+
});
|
|
834
|
+
const response = await apigwClient.listTagResources(request);
|
|
835
|
+
const tagResources = response.body?.tagResources?.tagResource ?? [];
|
|
836
|
+
if (tagResources.length === 0) {
|
|
837
|
+
return null;
|
|
838
|
+
}
|
|
839
|
+
return tagResources.map((t) => ({ tagKey: t.tagKey, tagValue: t.tagValue }));
|
|
574
840
|
}
|
|
575
841
|
catch (error) {
|
|
576
|
-
if (error
|
|
577
|
-
typeof error === 'object' &&
|
|
578
|
-
'code' in error &&
|
|
579
|
-
(error.code === 'NotFoundApi' || error.code === 'InvalidApiId.NotFound')) {
|
|
842
|
+
if ((0, exports.isApigwNotFoundError)(error)) {
|
|
580
843
|
return null;
|
|
581
844
|
}
|
|
582
845
|
throw error;
|
|
@@ -653,7 +916,19 @@ const createApigwOperations = (apigwClient, dnsClient, _context) => {
|
|
|
653
916
|
groupId,
|
|
654
917
|
apiId,
|
|
655
918
|
});
|
|
656
|
-
|
|
919
|
+
try {
|
|
920
|
+
await apigwClient.deleteApi(request);
|
|
921
|
+
}
|
|
922
|
+
catch (error) {
|
|
923
|
+
if ((0, exports.isApigwNotFoundError)(error)) {
|
|
924
|
+
logger_1.logger.warn(lang_1.lang.__('RESOURCE_NOT_FOUND_PROVIDER', {
|
|
925
|
+
resourceType: 'API',
|
|
926
|
+
name: apiId,
|
|
927
|
+
}));
|
|
928
|
+
return;
|
|
929
|
+
}
|
|
930
|
+
throw error;
|
|
931
|
+
}
|
|
657
932
|
},
|
|
658
933
|
/**
|
|
659
934
|
* Deploy API to a stage
|
|
@@ -676,7 +951,19 @@ const createApigwOperations = (apigwClient, dnsClient, _context) => {
|
|
|
676
951
|
apiId,
|
|
677
952
|
stageName,
|
|
678
953
|
});
|
|
679
|
-
|
|
954
|
+
try {
|
|
955
|
+
await apigwClient.abolishApi(request);
|
|
956
|
+
}
|
|
957
|
+
catch (error) {
|
|
958
|
+
if ((0, exports.isApigwNotFoundError)(error)) {
|
|
959
|
+
logger_1.logger.warn(lang_1.lang.__('RESOURCE_NOT_FOUND_PROVIDER', {
|
|
960
|
+
resourceType: `API deployment ${apiId}`,
|
|
961
|
+
name: stageName,
|
|
962
|
+
}));
|
|
963
|
+
return;
|
|
964
|
+
}
|
|
965
|
+
throw error;
|
|
966
|
+
}
|
|
680
967
|
},
|
|
681
968
|
/**
|
|
682
969
|
* Per Aliyun docs: CNAME must exist BEFORE calling SetDomain.
|
|
@@ -811,8 +1098,21 @@ const createApigwOperations = (apigwClient, dnsClient, _context) => {
|
|
|
811
1098
|
groupId,
|
|
812
1099
|
domainName,
|
|
813
1100
|
});
|
|
814
|
-
|
|
1101
|
+
try {
|
|
1102
|
+
await apigwClient.deleteDomain(request);
|
|
1103
|
+
}
|
|
1104
|
+
catch (error) {
|
|
1105
|
+
if ((0, exports.isApigwNotFoundError)(error)) {
|
|
1106
|
+
logger_1.logger.warn(lang_1.lang.__('RESOURCE_NOT_FOUND_PROVIDER', {
|
|
1107
|
+
resourceType: 'custom domain',
|
|
1108
|
+
name: domainName,
|
|
1109
|
+
}));
|
|
1110
|
+
return;
|
|
1111
|
+
}
|
|
1112
|
+
throw error;
|
|
1113
|
+
}
|
|
815
1114
|
},
|
|
816
1115
|
};
|
|
1116
|
+
return operations;
|
|
817
1117
|
};
|
|
818
1118
|
exports.createApigwOperations = createApigwOperations;
|
|
@@ -37,6 +37,7 @@ exports.createEsOperations = exports.EsAppStatus = void 0;
|
|
|
37
37
|
const EsModels = __importStar(require("@alicloud/es-serverless20230627"));
|
|
38
38
|
const logger_1 = require("../logger");
|
|
39
39
|
const lang_1 = require("../../lang");
|
|
40
|
+
const polling_1 = require("../polling");
|
|
40
41
|
var EsAppStatus;
|
|
41
42
|
(function (EsAppStatus) {
|
|
42
43
|
EsAppStatus["ACTIVE"] = "ACTIVE";
|
|
@@ -46,25 +47,35 @@ var EsAppStatus;
|
|
|
46
47
|
EsAppStatus["FAILED"] = "FAILED";
|
|
47
48
|
})(EsAppStatus || (exports.EsAppStatus = EsAppStatus = {}));
|
|
48
49
|
const waitForEsAppReady = async (getApp, appId) => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
50
|
+
try {
|
|
51
|
+
await (0, polling_1.pollUntil)({
|
|
52
|
+
description: `ES app ${appId} to be ready`,
|
|
53
|
+
fetch: async () => {
|
|
54
|
+
const app = await getApp(appId);
|
|
55
|
+
if (!app) {
|
|
56
|
+
throw new Error(lang_1.lang.__('ES_APP_NOT_FOUND', { appId }));
|
|
57
|
+
}
|
|
58
|
+
if (app.status === EsAppStatus.DELETED || app.status === EsAppStatus.FAILED) {
|
|
59
|
+
throw new Error(lang_1.lang.__('ES_APP_ERROR_STATE', { status: app.status }));
|
|
60
|
+
}
|
|
61
|
+
return app;
|
|
62
|
+
},
|
|
63
|
+
isDone: (app) => app?.status === EsAppStatus.ACTIVE,
|
|
64
|
+
intervalMs: 10000,
|
|
65
|
+
maxAttempts: 60,
|
|
66
|
+
onProgress: (app) => {
|
|
67
|
+
if (app)
|
|
68
|
+
logger_1.logger.info(lang_1.lang.__('ES_APP_WAITING', { appId, status: app.status ?? 'unknown' }));
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
logger_1.logger.info(lang_1.lang.__('ES_APP_READY', { appId }));
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
if (e instanceof polling_1.PollingTimeoutError) {
|
|
75
|
+
throw new Error(lang_1.lang.__('ES_APP_TIMEOUT_READY', { appId }), { cause: e });
|
|
62
76
|
}
|
|
63
|
-
|
|
64
|
-
await new Promise((resolve) => setTimeout(resolve, 10000));
|
|
65
|
-
attempts++;
|
|
77
|
+
throw e;
|
|
66
78
|
}
|
|
67
|
-
throw new Error(lang_1.lang.__('ES_APP_TIMEOUT_READY', { appId }));
|
|
68
79
|
};
|
|
69
80
|
const createEsOperations = (esClient, context) => {
|
|
70
81
|
const operations = {
|
|
@@ -185,20 +196,23 @@ const createEsOperations = (esClient, context) => {
|
|
|
185
196
|
try {
|
|
186
197
|
await esClient.deleteApp(appName);
|
|
187
198
|
logger_1.logger.info(lang_1.lang.__('ES_APP_DELETION_INITIATED', { appName }));
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
199
|
+
try {
|
|
200
|
+
await (0, polling_1.pollUntil)({
|
|
201
|
+
description: `ES app ${appName} to be deleted`,
|
|
202
|
+
fetch: () => operations.getApp(appName),
|
|
203
|
+
isDone: (app) => app === null,
|
|
204
|
+
intervalMs: 10000,
|
|
205
|
+
maxAttempts: 60,
|
|
206
|
+
onProgress: () => logger_1.logger.info(lang_1.lang.__('ES_APP_WAITING_DELETE', { appName })),
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
catch (e) {
|
|
210
|
+
if (e instanceof polling_1.PollingTimeoutError) {
|
|
211
|
+
throw new Error(lang_1.lang.__('ES_APP_TIMEOUT_DELETE', { appName }), { cause: e });
|
|
196
212
|
}
|
|
197
|
-
|
|
198
|
-
await new Promise((resolve) => setTimeout(resolve, 10000));
|
|
199
|
-
attempts++;
|
|
213
|
+
throw e;
|
|
200
214
|
}
|
|
201
|
-
|
|
215
|
+
logger_1.logger.info(lang_1.lang.__('ES_APP_DELETED', { appName }));
|
|
202
216
|
}
|
|
203
217
|
catch (error) {
|
|
204
218
|
// If app is not found, consider it deleted
|