@geek-fun/serverlessinsight 0.7.8 → 0.8.0
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/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geek-fun/serverlessinsight",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Full life cycle cross providers serverless application management for your fast-growing business.",
|
|
5
5
|
"homepage": "https://serverlessinsight.geekfun.club",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -54,14 +54,14 @@
|
|
|
54
54
|
],
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@alicloud/alidns20150109": "^4.4.1",
|
|
57
|
-
"@alicloud/cas20200407": "^3.2.
|
|
57
|
+
"@alicloud/cas20200407": "^3.2.9",
|
|
58
58
|
"@alicloud/cdn20180510": "^9.2.0",
|
|
59
59
|
"@alicloud/cloudapi20160714": "^4.8.0",
|
|
60
|
-
"@alicloud/ecs20140526": "^7.
|
|
60
|
+
"@alicloud/ecs20140526": "^7.9.0",
|
|
61
61
|
"@alicloud/es-serverless20230627": "^2.3.1",
|
|
62
|
-
"@alicloud/fc20230330": "^4.7.
|
|
63
|
-
"@alicloud/ims20190815": "^2.
|
|
64
|
-
"@alicloud/nas20170626": "^3.
|
|
62
|
+
"@alicloud/fc20230330": "^4.7.8",
|
|
63
|
+
"@alicloud/ims20190815": "^2.4.1",
|
|
64
|
+
"@alicloud/nas20170626": "^3.5.0",
|
|
65
65
|
"@alicloud/openapi-client": "^0.4.15",
|
|
66
66
|
"@alicloud/ram20150501": "^1.2.1",
|
|
67
67
|
"@alicloud/rds20140815": "^15.9.0",
|
|
@@ -73,16 +73,16 @@
|
|
|
73
73
|
"commander": "^15.0.0",
|
|
74
74
|
"cos-nodejs-sdk-v5": "^2.16.0-beta.8",
|
|
75
75
|
"i18n": "^0.15.3",
|
|
76
|
-
"iconv-lite": "^0.7.
|
|
76
|
+
"iconv-lite": "^0.7.3",
|
|
77
77
|
"jszip": "^3.10.1",
|
|
78
78
|
"lodash": "^4.18.1",
|
|
79
79
|
"pino": "^10.3.1",
|
|
80
80
|
"pino-pretty": "^13.1.3",
|
|
81
81
|
"tablestore": "^5.6.5",
|
|
82
|
-
"tencentcloud-sdk-nodejs-cam": "^4.1.
|
|
83
|
-
"tencentcloud-sdk-nodejs-cynosdb": "^4.1.
|
|
84
|
-
"tencentcloud-sdk-nodejs-dnspod": "^4.1.
|
|
85
|
-
"tencentcloud-sdk-nodejs-es": "^4.1.
|
|
82
|
+
"tencentcloud-sdk-nodejs-cam": "^4.1.265",
|
|
83
|
+
"tencentcloud-sdk-nodejs-cynosdb": "^4.1.265",
|
|
84
|
+
"tencentcloud-sdk-nodejs-dnspod": "^4.1.265",
|
|
85
|
+
"tencentcloud-sdk-nodejs-es": "^4.1.263",
|
|
86
86
|
"tencentcloud-sdk-nodejs-scf": "^4.1.168",
|
|
87
87
|
"tencentcloud-sdk-nodejs-ssl": "^4.1.239",
|
|
88
88
|
"yaml": "^2.9.0"
|
|
@@ -94,9 +94,9 @@
|
|
|
94
94
|
"@types/i18n": "^0.13.12",
|
|
95
95
|
"@types/jest": "^30.0.0",
|
|
96
96
|
"@types/lodash": "^4.17.24",
|
|
97
|
-
"@types/node": "^26.
|
|
98
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
99
|
-
"@typescript-eslint/parser": "^8.
|
|
97
|
+
"@types/node": "^26.1.1",
|
|
98
|
+
"@typescript-eslint/eslint-plugin": "^8.63.0",
|
|
99
|
+
"@typescript-eslint/parser": "^8.63.0",
|
|
100
100
|
"cross-env": "^10.1.0",
|
|
101
101
|
"eslint": "^10.6.0",
|
|
102
102
|
"eslint-config-prettier": "^10.1.8",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"globals": "^17.7.0",
|
|
105
105
|
"husky": "^9.1.7",
|
|
106
106
|
"jest": "^30.4.2",
|
|
107
|
-
"prettier": "^3.
|
|
107
|
+
"prettier": "^3.9.5",
|
|
108
108
|
"ts-jest": "^29.4.11",
|
|
109
109
|
"ts-node": "^10.9.2",
|
|
110
110
|
"typescript": "^6.0.3"
|
|
@@ -626,6 +626,25 @@ const createApigwOperations = (apigwClient, dnsClient, _context) => {
|
|
|
626
626
|
});
|
|
627
627
|
await apigwClient.modifyApi(request);
|
|
628
628
|
},
|
|
629
|
+
/**
|
|
630
|
+
* List all APIs in a group
|
|
631
|
+
*/
|
|
632
|
+
listApisByGroup: async (groupId) => {
|
|
633
|
+
const request = new cloudapi.DescribeApisRequest({
|
|
634
|
+
groupId,
|
|
635
|
+
pageSize: 100,
|
|
636
|
+
pageNumber: 1,
|
|
637
|
+
});
|
|
638
|
+
const response = await apigwClient.describeApis(request);
|
|
639
|
+
const apiSummaries = response.body?.apiSummarys?.apiSummary ?? [];
|
|
640
|
+
const results = [];
|
|
641
|
+
for (const api of apiSummaries) {
|
|
642
|
+
if (api.apiId && api.apiName) {
|
|
643
|
+
results.push({ apiId: api.apiId, apiName: api.apiName });
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
return results;
|
|
647
|
+
},
|
|
629
648
|
/**
|
|
630
649
|
* Delete API
|
|
631
650
|
*/
|
|
@@ -45,6 +45,7 @@ const getIamInfo = async (context) => {
|
|
|
45
45
|
const imsConfig = new openApi.Config({
|
|
46
46
|
accessKeyId: context.accessKeyId,
|
|
47
47
|
accessKeySecret: context.accessKeySecret,
|
|
48
|
+
regionId: context.region,
|
|
48
49
|
});
|
|
49
50
|
imsConfig.connectTimeout = constants_1.ALIYUN_FC3_CONNECT_TIMEOUT_MS;
|
|
50
51
|
imsConfig.readTimeout = constants_1.ALIYUN_FC3_READ_TIMEOUT_MS;
|
|
@@ -444,15 +444,93 @@ const updateApigwResource = async (context, event, serviceName, roleArn, state)
|
|
|
444
444
|
const logicalId = `events.${event.key}`;
|
|
445
445
|
const existingState = (0, stateManager_1.getResource)(state, logicalId);
|
|
446
446
|
const client = (0, aliyunClient_1.createAliyunClient)(context);
|
|
447
|
-
|
|
447
|
+
let existingInstances;
|
|
448
|
+
let groupId;
|
|
449
|
+
// Precompute expected API names from triggers to safely filter cloud APIs
|
|
450
|
+
const expectedApiNames = new Set(event.triggers.map((trigger) => {
|
|
451
|
+
const apiConfig = (0, apigwTypes_1.triggerToApigwApiConfig)(event, trigger, 'placeholder', serviceName, context.region, context.stage, roleArn);
|
|
452
|
+
return apiConfig.apiName;
|
|
453
|
+
}));
|
|
454
|
+
const buildCloudInstance = (cloudGroup, cloudApis) => {
|
|
455
|
+
const gId = cloudGroup.groupId;
|
|
456
|
+
return {
|
|
457
|
+
groupId: gId,
|
|
458
|
+
instances: [
|
|
459
|
+
buildApigwGroupInstanceFromProvider(cloudGroup, context.stage),
|
|
460
|
+
// Only include cloud APIs whose name matches our expected set.
|
|
461
|
+
// This prevents accidentally managing or deleting APIs created
|
|
462
|
+
// by other processes within the same group.
|
|
463
|
+
...cloudApis
|
|
464
|
+
.filter((api) => expectedApiNames.has(api.apiName))
|
|
465
|
+
.map((api) => ({
|
|
466
|
+
type: 'ALIYUN_APIGW_API',
|
|
467
|
+
sid: (0, common_1.buildSid)('aliyun', 'apigateway', context.stage, `${gId}/${api.apiId}`),
|
|
468
|
+
id: api.apiId,
|
|
469
|
+
apiId: api.apiId,
|
|
470
|
+
apiName: api.apiName,
|
|
471
|
+
groupId: gId,
|
|
472
|
+
})),
|
|
473
|
+
],
|
|
474
|
+
};
|
|
475
|
+
};
|
|
476
|
+
// Shared helper: try to find the group from cloud. On any error (or not found),
|
|
477
|
+
// fall back to full creation since there's nothing to update.
|
|
478
|
+
const findCloudGroupOrCreate = async () => {
|
|
448
479
|
return (0, exports.createApigwResource)(context, event, serviceName, roleArn, state);
|
|
480
|
+
};
|
|
481
|
+
if (existingState) {
|
|
482
|
+
existingInstances = existingState.instances;
|
|
483
|
+
const groupInstance = existingInstances.find((i) => i.type === 'ALIYUN_APIGW_GROUP');
|
|
484
|
+
if (groupInstance) {
|
|
485
|
+
groupId = groupInstance.id;
|
|
486
|
+
}
|
|
487
|
+
else {
|
|
488
|
+
const groupConfig = (0, apigwTypes_1.eventToApigwGroupConfig)(event, serviceName, context.stage);
|
|
489
|
+
try {
|
|
490
|
+
const cloudGroup = await client.apigw.findApiGroupByName(groupConfig.groupName);
|
|
491
|
+
if (!cloudGroup?.groupId) {
|
|
492
|
+
return findCloudGroupOrCreate();
|
|
493
|
+
}
|
|
494
|
+
const cloudApis = await client.apigw.listApisByGroup(cloudGroup.groupId);
|
|
495
|
+
const built = buildCloudInstance(cloudGroup, cloudApis);
|
|
496
|
+
groupId = built.groupId;
|
|
497
|
+
existingInstances = built.instances;
|
|
498
|
+
state = (0, stateManager_1.setResource)(state, logicalId, {
|
|
499
|
+
mode: 'managed',
|
|
500
|
+
region: context.region,
|
|
501
|
+
definition: {},
|
|
502
|
+
instances: existingInstances,
|
|
503
|
+
lastUpdated: new Date().toISOString(),
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
catch {
|
|
507
|
+
return findCloudGroupOrCreate();
|
|
508
|
+
}
|
|
509
|
+
}
|
|
449
510
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
511
|
+
else {
|
|
512
|
+
const groupConfig = (0, apigwTypes_1.eventToApigwGroupConfig)(event, serviceName, context.stage);
|
|
513
|
+
try {
|
|
514
|
+
const cloudGroup = await client.apigw.findApiGroupByName(groupConfig.groupName);
|
|
515
|
+
if (!cloudGroup?.groupId) {
|
|
516
|
+
return findCloudGroupOrCreate();
|
|
517
|
+
}
|
|
518
|
+
const cloudApis = await client.apigw.listApisByGroup(cloudGroup.groupId);
|
|
519
|
+
const built = buildCloudInstance(cloudGroup, cloudApis);
|
|
520
|
+
groupId = built.groupId;
|
|
521
|
+
existingInstances = built.instances;
|
|
522
|
+
state = (0, stateManager_1.setResource)(state, logicalId, {
|
|
523
|
+
mode: 'managed',
|
|
524
|
+
region: context.region,
|
|
525
|
+
definition: {},
|
|
526
|
+
instances: existingInstances,
|
|
527
|
+
lastUpdated: new Date().toISOString(),
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
catch {
|
|
531
|
+
return findCloudGroupOrCreate();
|
|
532
|
+
}
|
|
454
533
|
}
|
|
455
|
-
const groupId = groupInstance.id;
|
|
456
534
|
const groupConfig = (0, apigwTypes_1.eventToApigwGroupConfig)(event, serviceName, context.stage);
|
|
457
535
|
await client.apigw.updateApiGroup(groupId, groupConfig);
|
|
458
536
|
const groupInfo = await client.apigw.getApiGroup(groupId);
|
|
@@ -515,7 +593,7 @@ const updateApigwResource = async (context, event, serviceName, roleArn, state)
|
|
|
515
593
|
const wwwBindApex = event.domain.www_bind_apex === true;
|
|
516
594
|
const wwwDomain = wwwBindApex ? (0, domainUtils_1.deriveWwwDomain)(primaryDomain) : null;
|
|
517
595
|
const isCdnEnabled = getIsCdnEnabled(event);
|
|
518
|
-
const existingDomain = existingState
|
|
596
|
+
const existingDomain = existingState?.definition?.domain;
|
|
519
597
|
const previousWwwBindApex = existingDomain?.wwwBindApex === true;
|
|
520
598
|
const previousDomainName = existingDomain?.domainName;
|
|
521
599
|
const previousCdnEnabled = existingDomain?.cdnEnabled === true;
|
|
@@ -585,7 +663,7 @@ const updateApigwResource = async (context, event, serviceName, roleArn, state)
|
|
|
585
663
|
}
|
|
586
664
|
}
|
|
587
665
|
else {
|
|
588
|
-
const existingDomain = existingState
|
|
666
|
+
const existingDomain = existingState?.definition?.domain;
|
|
589
667
|
if (existingDomain?.domainName) {
|
|
590
668
|
const previousDomain = existingDomain.domainName;
|
|
591
669
|
const previousCdnEnabled = existingDomain.cdnEnabled === true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geek-fun/serverlessinsight",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Full life cycle cross providers serverless application management for your fast-growing business.",
|
|
5
5
|
"homepage": "https://serverlessinsight.geekfun.club",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -54,14 +54,14 @@
|
|
|
54
54
|
],
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@alicloud/alidns20150109": "^4.4.1",
|
|
57
|
-
"@alicloud/cas20200407": "^3.2.
|
|
57
|
+
"@alicloud/cas20200407": "^3.2.9",
|
|
58
58
|
"@alicloud/cdn20180510": "^9.2.0",
|
|
59
59
|
"@alicloud/cloudapi20160714": "^4.8.0",
|
|
60
|
-
"@alicloud/ecs20140526": "^7.
|
|
60
|
+
"@alicloud/ecs20140526": "^7.9.0",
|
|
61
61
|
"@alicloud/es-serverless20230627": "^2.3.1",
|
|
62
|
-
"@alicloud/fc20230330": "^4.7.
|
|
63
|
-
"@alicloud/ims20190815": "^2.
|
|
64
|
-
"@alicloud/nas20170626": "^3.
|
|
62
|
+
"@alicloud/fc20230330": "^4.7.8",
|
|
63
|
+
"@alicloud/ims20190815": "^2.4.1",
|
|
64
|
+
"@alicloud/nas20170626": "^3.5.0",
|
|
65
65
|
"@alicloud/openapi-client": "^0.4.15",
|
|
66
66
|
"@alicloud/ram20150501": "^1.2.1",
|
|
67
67
|
"@alicloud/rds20140815": "^15.9.0",
|
|
@@ -73,16 +73,16 @@
|
|
|
73
73
|
"commander": "^15.0.0",
|
|
74
74
|
"cos-nodejs-sdk-v5": "^2.16.0-beta.8",
|
|
75
75
|
"i18n": "^0.15.3",
|
|
76
|
-
"iconv-lite": "^0.7.
|
|
76
|
+
"iconv-lite": "^0.7.3",
|
|
77
77
|
"jszip": "^3.10.1",
|
|
78
78
|
"lodash": "^4.18.1",
|
|
79
79
|
"pino": "^10.3.1",
|
|
80
80
|
"pino-pretty": "^13.1.3",
|
|
81
81
|
"tablestore": "^5.6.5",
|
|
82
|
-
"tencentcloud-sdk-nodejs-cam": "^4.1.
|
|
83
|
-
"tencentcloud-sdk-nodejs-cynosdb": "^4.1.
|
|
84
|
-
"tencentcloud-sdk-nodejs-dnspod": "^4.1.
|
|
85
|
-
"tencentcloud-sdk-nodejs-es": "^4.1.
|
|
82
|
+
"tencentcloud-sdk-nodejs-cam": "^4.1.265",
|
|
83
|
+
"tencentcloud-sdk-nodejs-cynosdb": "^4.1.265",
|
|
84
|
+
"tencentcloud-sdk-nodejs-dnspod": "^4.1.265",
|
|
85
|
+
"tencentcloud-sdk-nodejs-es": "^4.1.263",
|
|
86
86
|
"tencentcloud-sdk-nodejs-scf": "^4.1.168",
|
|
87
87
|
"tencentcloud-sdk-nodejs-ssl": "^4.1.239",
|
|
88
88
|
"yaml": "^2.9.0"
|
|
@@ -94,9 +94,9 @@
|
|
|
94
94
|
"@types/i18n": "^0.13.12",
|
|
95
95
|
"@types/jest": "^30.0.0",
|
|
96
96
|
"@types/lodash": "^4.17.24",
|
|
97
|
-
"@types/node": "^26.
|
|
98
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
99
|
-
"@typescript-eslint/parser": "^8.
|
|
97
|
+
"@types/node": "^26.1.1",
|
|
98
|
+
"@typescript-eslint/eslint-plugin": "^8.63.0",
|
|
99
|
+
"@typescript-eslint/parser": "^8.63.0",
|
|
100
100
|
"cross-env": "^10.1.0",
|
|
101
101
|
"eslint": "^10.6.0",
|
|
102
102
|
"eslint-config-prettier": "^10.1.8",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"globals": "^17.7.0",
|
|
105
105
|
"husky": "^9.1.7",
|
|
106
106
|
"jest": "^30.4.2",
|
|
107
|
-
"prettier": "^3.
|
|
107
|
+
"prettier": "^3.9.5",
|
|
108
108
|
"ts-jest": "^29.4.11",
|
|
109
109
|
"ts-node": "^10.9.2",
|
|
110
110
|
"typescript": "^6.0.3"
|