@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
|
@@ -36,6 +36,37 @@ const parseXmlResponse = (xml, tagName) => {
|
|
|
36
36
|
return null;
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
|
+
// GetBucketReplication XML → list of BucketReplicationRule. The ali-oss SDK has
|
|
40
|
+
// no typed getBucketReplication, so we parse the raw XML response instead.
|
|
41
|
+
const parseReplicationRules = (xml) => {
|
|
42
|
+
const ruleRegex = /<Rule>([\s\S]*?)<\/Rule>/g;
|
|
43
|
+
const rules = [];
|
|
44
|
+
let ruleMatch;
|
|
45
|
+
while ((ruleMatch = ruleRegex.exec(xml)) !== null) {
|
|
46
|
+
const ruleXml = ruleMatch[1];
|
|
47
|
+
const read = (tag) => {
|
|
48
|
+
const m = new RegExp(`<${tag}>([\\s\\S]*?)<\\/${tag}>`).exec(ruleXml);
|
|
49
|
+
return m ? m[1].trim() : undefined;
|
|
50
|
+
};
|
|
51
|
+
const destinationXml = /<Destination>([\s\S]*?)<\/Destination>/.exec(ruleXml);
|
|
52
|
+
const readDest = (tag) => {
|
|
53
|
+
if (!destinationXml)
|
|
54
|
+
return undefined;
|
|
55
|
+
const m = new RegExp(`<${tag}>([\\s\\S]*?)<\\/${tag}>`).exec(destinationXml[1]);
|
|
56
|
+
return m ? m[1].trim() : undefined;
|
|
57
|
+
};
|
|
58
|
+
rules.push({
|
|
59
|
+
id: read('ID'),
|
|
60
|
+
status: read('Status'),
|
|
61
|
+
prefix: read('Prefix'),
|
|
62
|
+
destination: {
|
|
63
|
+
bucket: readDest('Bucket'),
|
|
64
|
+
storageClass: readDest('StorageClass'),
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return rules;
|
|
69
|
+
};
|
|
39
70
|
/* istanbul ignore next */ const createOssOperations = (ossClient, region, dnsOps) => {
|
|
40
71
|
const useBucket = (bucketName) => {
|
|
41
72
|
ossClient.useBucket(bucketName);
|
|
@@ -481,12 +512,21 @@ const parseXmlResponse = (xml, tagName) => {
|
|
|
481
512
|
}
|
|
482
513
|
}
|
|
483
514
|
};
|
|
484
|
-
|
|
515
|
+
const operations = {
|
|
485
516
|
createBucket: async (config) => {
|
|
517
|
+
const putBucketOptions = {};
|
|
486
518
|
if (config.storageClass) {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
519
|
+
putBucketOptions.storageClass = config.storageClass;
|
|
520
|
+
}
|
|
521
|
+
if (config.Tags && config.Tags.length > 0) {
|
|
522
|
+
// OSS accepts bucket tags at create time via the x-oss-bucket-tagging
|
|
523
|
+
// header: URL-encoded `key1=value1&key2=value2`.
|
|
524
|
+
putBucketOptions.headers = {
|
|
525
|
+
'x-oss-bucket-tagging': config.Tags.map((tag) => `${encodeURIComponent(tag.Key)}=${encodeURIComponent(tag.Value)}`).join('&'),
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
if (putBucketOptions.storageClass || putBucketOptions.headers) {
|
|
529
|
+
await ossClient.putBucket(config.bucketName, putBucketOptions);
|
|
490
530
|
}
|
|
491
531
|
else {
|
|
492
532
|
await ossClient.putBucket(config.bucketName);
|
|
@@ -593,25 +633,130 @@ const parseXmlResponse = (xml, tagName) => {
|
|
|
593
633
|
try {
|
|
594
634
|
const lifecycleResult = await ossClient.getBucketLifecycle(bucketName);
|
|
595
635
|
if (lifecycleResult.rules && lifecycleResult.rules.length > 0) {
|
|
596
|
-
lifecycleRules = lifecycleResult.rules.map((rule) =>
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
636
|
+
lifecycleRules = lifecycleResult.rules.map((rule) => {
|
|
637
|
+
const rawRule = rule;
|
|
638
|
+
const rawTransition = Array.isArray(rawRule.transition)
|
|
639
|
+
? rawRule.transition[0]
|
|
640
|
+
: rawRule.transition;
|
|
641
|
+
const transition = (rawTransition ?? undefined);
|
|
642
|
+
const expirationDays = rawRule.expiration?.days ?? rule.days;
|
|
643
|
+
const expirationDate = rawRule.expiration?.date ?? rule.date;
|
|
644
|
+
const expiredObjectDeleteMarker = rawRule.expiration?.expiredObjectDeleteMarker;
|
|
645
|
+
const expiration = expirationDays !== undefined
|
|
601
646
|
? {
|
|
602
|
-
days: typeof
|
|
647
|
+
days: typeof expirationDays === 'number'
|
|
648
|
+
? expirationDays
|
|
649
|
+
: parseInt(expirationDays, 10),
|
|
650
|
+
...(expiredObjectDeleteMarker ? { expiredObjectDeleteMarker: true } : {}),
|
|
603
651
|
}
|
|
604
|
-
:
|
|
652
|
+
: expirationDate
|
|
653
|
+
? {
|
|
654
|
+
date: expirationDate,
|
|
655
|
+
...(expiredObjectDeleteMarker ? { expiredObjectDeleteMarker: true } : {}),
|
|
656
|
+
}
|
|
657
|
+
: expiredObjectDeleteMarker
|
|
658
|
+
? { expiredObjectDeleteMarker: true }
|
|
659
|
+
: undefined;
|
|
660
|
+
return {
|
|
661
|
+
id: rule.id,
|
|
662
|
+
status: rule.status,
|
|
663
|
+
prefix: rule.prefix,
|
|
664
|
+
expiration,
|
|
665
|
+
transition: transition
|
|
605
666
|
? {
|
|
606
|
-
|
|
667
|
+
days: typeof transition.days === 'number'
|
|
668
|
+
? transition.days
|
|
669
|
+
: transition.days !== undefined
|
|
670
|
+
? parseInt(transition.days, 10)
|
|
671
|
+
: undefined,
|
|
672
|
+
date: transition.date,
|
|
673
|
+
storageClass: transition.storageClass,
|
|
607
674
|
}
|
|
608
675
|
: undefined,
|
|
609
|
-
|
|
676
|
+
};
|
|
677
|
+
});
|
|
610
678
|
}
|
|
611
679
|
}
|
|
612
680
|
catch {
|
|
613
681
|
// Lifecycle config might not exist
|
|
614
682
|
}
|
|
683
|
+
// Get versioning status (GetBucketVersioning)
|
|
684
|
+
let versioningConfig;
|
|
685
|
+
try {
|
|
686
|
+
const versioningResult = await ossClient.getBucketVersioning(bucketName);
|
|
687
|
+
if (versioningResult?.versionStatus === 'Enabled' ||
|
|
688
|
+
versioningResult?.versionStatus === 'Suspended') {
|
|
689
|
+
versioningConfig = { status: versioningResult.versionStatus };
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
catch {
|
|
693
|
+
// Versioning config might not exist
|
|
694
|
+
}
|
|
695
|
+
// Get server-side encryption (GetBucketEncryption)
|
|
696
|
+
let encryptionConfig;
|
|
697
|
+
try {
|
|
698
|
+
const encryptionResult = await ossClient.getBucketEncryption(bucketName);
|
|
699
|
+
const enc = encryptionResult?.encryption;
|
|
700
|
+
if (enc?.SSEAlgorithm) {
|
|
701
|
+
encryptionConfig = {
|
|
702
|
+
sseAlgorithm: enc.SSEAlgorithm,
|
|
703
|
+
kmsMasterKeyId: enc.KMSMasterKeyID,
|
|
704
|
+
kmsDataEncryption: enc.KMSDataEncryption,
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
catch {
|
|
709
|
+
// Encryption config might not exist
|
|
710
|
+
}
|
|
711
|
+
// Get transfer acceleration status (GetBucketTransferAcceleration)
|
|
712
|
+
let transferAccelerationStatus;
|
|
713
|
+
try {
|
|
714
|
+
const enabled = await operations.getTransferAccelerationStatus(bucketName);
|
|
715
|
+
transferAccelerationStatus = enabled ? 'Enabled' : 'Disabled';
|
|
716
|
+
}
|
|
717
|
+
catch {
|
|
718
|
+
// Transfer acceleration might not be configured
|
|
719
|
+
}
|
|
720
|
+
// Get replication rules (GetBucketReplication)
|
|
721
|
+
let replicationRules;
|
|
722
|
+
try {
|
|
723
|
+
const replicationResponse = await ossRequest(ossClient, {
|
|
724
|
+
method: 'GET',
|
|
725
|
+
bucket: bucketName,
|
|
726
|
+
subres: { replication: '' },
|
|
727
|
+
successStatuses: [200],
|
|
728
|
+
});
|
|
729
|
+
const replicationXml = replicationResponse.data || '';
|
|
730
|
+
const parsedRules = parseReplicationRules(replicationXml);
|
|
731
|
+
if (parsedRules.length > 0) {
|
|
732
|
+
replicationRules = parsedRules;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
catch {
|
|
736
|
+
// Replication config might not exist
|
|
737
|
+
}
|
|
738
|
+
// Get bucket policy (GetBucketPolicy)
|
|
739
|
+
let policy;
|
|
740
|
+
try {
|
|
741
|
+
const policyResult = await operations.getBucketPolicy(bucketName);
|
|
742
|
+
if (policyResult) {
|
|
743
|
+
policy = JSON.stringify(policyResult);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
catch {
|
|
747
|
+
// No bucket policy configured
|
|
748
|
+
}
|
|
749
|
+
// Get bucket tags
|
|
750
|
+
let tags;
|
|
751
|
+
try {
|
|
752
|
+
const tagsResult = await ossClient.getBucketTags(bucketName);
|
|
753
|
+
if (tagsResult.tag) {
|
|
754
|
+
tags = Object.entries(tagsResult.tag).map(([key, value]) => ({ key, value }));
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
catch {
|
|
758
|
+
// No bucket tags configured
|
|
759
|
+
}
|
|
615
760
|
// Build owner info
|
|
616
761
|
const owner = bucket?.Owner
|
|
617
762
|
? {
|
|
@@ -635,6 +780,12 @@ const parseXmlResponse = (xml, tagName) => {
|
|
|
635
780
|
loggingConfig,
|
|
636
781
|
corsRules,
|
|
637
782
|
lifecycleRules,
|
|
783
|
+
versioningConfig,
|
|
784
|
+
encryptionConfig,
|
|
785
|
+
transferAccelerationStatus,
|
|
786
|
+
replicationRules,
|
|
787
|
+
tags,
|
|
788
|
+
policy,
|
|
638
789
|
};
|
|
639
790
|
}
|
|
640
791
|
catch (error) {
|
|
@@ -814,5 +965,6 @@ const parseXmlResponse = (xml, tagName) => {
|
|
|
814
965
|
}
|
|
815
966
|
},
|
|
816
967
|
};
|
|
968
|
+
return operations;
|
|
817
969
|
};
|
|
818
970
|
exports.createOssOperations = createOssOperations;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createRdsOperations = exports.RdsInstanceStatus = void 0;
|
|
4
4
|
const logger_1 = require("../logger");
|
|
5
5
|
const lang_1 = require("../../lang");
|
|
6
|
+
const polling_1 = require("../polling");
|
|
6
7
|
var RdsInstanceStatus;
|
|
7
8
|
(function (RdsInstanceStatus) {
|
|
8
9
|
RdsInstanceStatus["RUNNING"] = "Running";
|
|
@@ -12,29 +13,40 @@ var RdsInstanceStatus;
|
|
|
12
13
|
RdsInstanceStatus["RESTARTING"] = "Restarting";
|
|
13
14
|
})(RdsInstanceStatus || (exports.RdsInstanceStatus = RdsInstanceStatus = {}));
|
|
14
15
|
const waitForRdsInstanceReady = async (getInstance, instanceId) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
try {
|
|
17
|
+
await (0, polling_1.pollUntil)({
|
|
18
|
+
description: `RDS instance ${instanceId} to be ready`,
|
|
19
|
+
fetch: async () => {
|
|
20
|
+
const instance = await getInstance(instanceId);
|
|
21
|
+
if (!instance) {
|
|
22
|
+
throw new Error(lang_1.lang.__('RDS_INSTANCE_NOT_FOUND', { instanceId }));
|
|
23
|
+
}
|
|
24
|
+
if (instance.dbInstanceStatus === RdsInstanceStatus.DELETED ||
|
|
25
|
+
instance.dbInstanceStatus === RdsInstanceStatus.DELETE_FAILED) {
|
|
26
|
+
throw new Error(lang_1.lang.__('RDS_INSTANCE_ERROR_STATE', { status: instance.dbInstanceStatus }));
|
|
27
|
+
}
|
|
28
|
+
return instance;
|
|
29
|
+
},
|
|
30
|
+
isDone: (instance) => instance?.dbInstanceStatus === RdsInstanceStatus.RUNNING,
|
|
31
|
+
intervalMs: 10000,
|
|
32
|
+
maxAttempts: 60,
|
|
33
|
+
onProgress: (instance) => {
|
|
34
|
+
if (instance) {
|
|
35
|
+
logger_1.logger.info(lang_1.lang.__('RDS_INSTANCE_WAITING', {
|
|
36
|
+
instanceId,
|
|
37
|
+
status: instance.dbInstanceStatus ?? 'unknown',
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
logger_1.logger.info(lang_1.lang.__('RDS_INSTANCE_READY', { instanceId }));
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
if (e instanceof polling_1.PollingTimeoutError) {
|
|
46
|
+
throw new Error(lang_1.lang.__('RDS_INSTANCE_TIMEOUT_READY', { instanceId }), { cause: e });
|
|
29
47
|
}
|
|
30
|
-
|
|
31
|
-
instanceId,
|
|
32
|
-
status: instance.dbInstanceStatus ?? 'unknown',
|
|
33
|
-
}));
|
|
34
|
-
await new Promise((resolve) => setTimeout(resolve, 10000));
|
|
35
|
-
attempts++;
|
|
48
|
+
throw e;
|
|
36
49
|
}
|
|
37
|
-
throw new Error(lang_1.lang.__('RDS_INSTANCE_TIMEOUT_READY', { instanceId }));
|
|
38
50
|
};
|
|
39
51
|
const createRdsOperations = (rdsClient, context) => {
|
|
40
52
|
const operations = {
|
|
@@ -65,6 +77,8 @@ const createRdsOperations = (rdsClient, context) => {
|
|
|
65
77
|
}
|
|
66
78
|
: undefined,
|
|
67
79
|
BurstingEnabled: config.burstingEnabled,
|
|
80
|
+
// SDK serializes Tag as Tag.1.Key / Tag.1.Value (ownership tag for idempotent adoption)
|
|
81
|
+
Tag: config.tags,
|
|
68
82
|
};
|
|
69
83
|
try {
|
|
70
84
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -95,7 +109,7 @@ const createRdsOperations = (rdsClient, context) => {
|
|
|
95
109
|
return null;
|
|
96
110
|
}
|
|
97
111
|
const instance = response.body.Items.DBInstanceAttribute[0];
|
|
98
|
-
|
|
112
|
+
const info = {
|
|
99
113
|
dbInstanceId: instance.DBInstanceId,
|
|
100
114
|
dbInstanceDescription: instance.DBInstanceDescription,
|
|
101
115
|
engine: instance.Engine,
|
|
@@ -104,12 +118,14 @@ const createRdsOperations = (rdsClient, context) => {
|
|
|
104
118
|
dbInstanceStorage: instance.DBInstanceStorage,
|
|
105
119
|
category: instance.Category,
|
|
106
120
|
dbInstanceStorageType: instance.DBInstanceStorageType,
|
|
107
|
-
serverlessConfig: instance.
|
|
121
|
+
serverlessConfig: instance.serverlessConfig
|
|
108
122
|
? {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
123
|
+
// DescribeDBInstanceAttribute returns scaleMin/scaleMax (not
|
|
124
|
+
// MinCapacity/MaxCapacity) — map the actual cloud field names.
|
|
125
|
+
minCapacity: instance.serverlessConfig.scaleMin,
|
|
126
|
+
maxCapacity: instance.serverlessConfig.scaleMax,
|
|
127
|
+
autoPause: instance.serverlessConfig.autoPause,
|
|
128
|
+
switchForce: instance.serverlessConfig.switchForce,
|
|
113
129
|
}
|
|
114
130
|
: undefined,
|
|
115
131
|
masterUsername: instance.MasterUsername,
|
|
@@ -119,11 +135,95 @@ const createRdsOperations = (rdsClient, context) => {
|
|
|
119
135
|
connectionString: instance.ConnectionString,
|
|
120
136
|
port: instance.Port,
|
|
121
137
|
dbInstanceStatus: instance.DBInstanceStatus,
|
|
122
|
-
createTime: instance.CreateTime,
|
|
138
|
+
createTime: instance.CreateTime ?? instance.CreationTime,
|
|
123
139
|
regionId: instance.RegionId,
|
|
124
140
|
securityIPList: instance.SecurityIPList,
|
|
125
141
|
multiAZ: instance.MultiAZ === 'true',
|
|
142
|
+
// Maximum-detail fields — retain everything DescribeDBInstanceAttribute
|
|
143
|
+
// returns so state keeps the full cloud resource detail.
|
|
144
|
+
dbInstanceCpu: instance.DBInstanceCPU,
|
|
145
|
+
dbInstanceMemory: instance.DBInstanceMemory,
|
|
146
|
+
payType: instance.PayType,
|
|
147
|
+
expireTime: instance.ExpireTime,
|
|
148
|
+
maintainTime: instance.MaintainTime,
|
|
149
|
+
maxConnections: instance.MaxConnections,
|
|
150
|
+
maxIOPS: instance.MaxIOPS,
|
|
151
|
+
resourceGroupId: instance.ResourceGroupId,
|
|
152
|
+
deletionProtection: instance.DeletionProtection,
|
|
153
|
+
lockMode: instance.LockMode,
|
|
154
|
+
lockReason: instance.LockReason,
|
|
155
|
+
connectionMode: instance.ConnectionMode,
|
|
156
|
+
dbInstanceDiskUsed: instance.DBInstanceDiskUsed,
|
|
157
|
+
dbInstanceType: instance.DBInstanceType,
|
|
158
|
+
instanceNetworkType: instance.InstanceNetworkType,
|
|
159
|
+
timeZone: instance.TimeZone,
|
|
160
|
+
currentKernelVersion: instance.CurrentKernelVersion,
|
|
161
|
+
latestKernelVersion: instance.LatestKernelVersion,
|
|
162
|
+
masterZone: instance.MasterZone,
|
|
163
|
+
masterInstanceId: instance.MasterInstanceId,
|
|
164
|
+
slaveZones: instance.SlaveZones?.slaveZone?.map((z) => ({ zoneId: z.zoneId })),
|
|
165
|
+
readOnlyDBInstanceIds: instance.ReadOnlyDBInstanceIds?.readOnlyDBInstanceId
|
|
166
|
+
?.map((r) => r.DBInstanceId)
|
|
167
|
+
.filter((id) => !!id),
|
|
168
|
+
burstingEnabled: instance.BurstingEnabled,
|
|
169
|
+
computeBurstEnabled: instance.ComputeBurstEnabled,
|
|
126
170
|
};
|
|
171
|
+
try {
|
|
172
|
+
const tags = await operations.getInstanceTags(instanceId);
|
|
173
|
+
if (tags.length > 0) {
|
|
174
|
+
info.tags = tags;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
catch {
|
|
178
|
+
// Tags are best-effort; instance detail is still returned without them.
|
|
179
|
+
}
|
|
180
|
+
return info;
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
logger_1.logger.error(lang_1.lang.__('RDS_INSTANCE_GET_FAILED', { error: String(error) }));
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
getInstanceTags: async (instanceId) => {
|
|
188
|
+
const params = {
|
|
189
|
+
RegionId: context.region,
|
|
190
|
+
ResourceType: 'INSTANCE',
|
|
191
|
+
ResourceId: [instanceId],
|
|
192
|
+
};
|
|
193
|
+
try {
|
|
194
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
195
|
+
const response = await rdsClient.listTagResources(params);
|
|
196
|
+
return (response.body?.tagResources?.tagResource ?? []).map((t) => ({
|
|
197
|
+
key: t.tagKey,
|
|
198
|
+
value: t.tagValue,
|
|
199
|
+
}));
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
logger_1.logger.error(lang_1.lang.__('RDS_INSTANCE_GET_FAILED', { error: String(error) }));
|
|
203
|
+
return [];
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
getInstanceByName: async (name) => {
|
|
207
|
+
const params = {
|
|
208
|
+
RegionId: context.region,
|
|
209
|
+
SearchKey: name,
|
|
210
|
+
PageSize: 100,
|
|
211
|
+
};
|
|
212
|
+
try {
|
|
213
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
214
|
+
const response = await rdsClient.describeDBInstances(params);
|
|
215
|
+
// SearchKey fuzzy-matches DBInstanceId OR DBInstanceDescription, so filter
|
|
216
|
+
// to an exact description match to avoid adopting an unrelated instance.
|
|
217
|
+
const match = (response.body?.items?.DBInstance ?? []).find((i) => i.DBInstanceDescription === name);
|
|
218
|
+
if (!match?.DBInstanceId) {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
const instance = await operations.getInstance(match.DBInstanceId);
|
|
222
|
+
if (!instance) {
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
const tags = await operations.getInstanceTags(match.DBInstanceId);
|
|
226
|
+
return { ...instance, tags };
|
|
127
227
|
}
|
|
128
228
|
catch (error) {
|
|
129
229
|
logger_1.logger.error(lang_1.lang.__('RDS_INSTANCE_GET_FAILED', { error: String(error) }));
|
|
@@ -173,19 +273,23 @@ const createRdsOperations = (rdsClient, context) => {
|
|
|
173
273
|
await rdsClient.deleteDBInstance(params);
|
|
174
274
|
logger_1.logger.info(lang_1.lang.__('RDS_INSTANCE_DELETION_INITIATED', { instanceId }));
|
|
175
275
|
// Wait for instance to be deleted
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
276
|
+
try {
|
|
277
|
+
await (0, polling_1.pollUntil)({
|
|
278
|
+
description: `RDS instance ${instanceId} to be deleted`,
|
|
279
|
+
fetch: () => operations.getInstance(instanceId),
|
|
280
|
+
isDone: (instance) => instance === null,
|
|
281
|
+
intervalMs: 10000,
|
|
282
|
+
maxAttempts: 60,
|
|
283
|
+
onProgress: () => logger_1.logger.info(lang_1.lang.__('RDS_INSTANCE_WAITING_DELETE', { instanceId })),
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
catch (e) {
|
|
287
|
+
if (e instanceof polling_1.PollingTimeoutError) {
|
|
288
|
+
throw new Error(lang_1.lang.__('RDS_INSTANCE_TIMEOUT_DELETE', { instanceId }), { cause: e });
|
|
183
289
|
}
|
|
184
|
-
|
|
185
|
-
await new Promise((resolve) => setTimeout(resolve, 10000));
|
|
186
|
-
attempts++;
|
|
290
|
+
throw e;
|
|
187
291
|
}
|
|
188
|
-
|
|
292
|
+
logger_1.logger.info(lang_1.lang.__('RDS_INSTANCE_DELETED', { instanceId }));
|
|
189
293
|
}
|
|
190
294
|
catch (error) {
|
|
191
295
|
// If instance is not found, consider it deleted
|
|
@@ -35,39 +35,69 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.createSlsOperations = void 0;
|
|
37
37
|
const sls = __importStar(require("@alicloud/sls20201230"));
|
|
38
|
+
const logger_1 = require("../logger");
|
|
39
|
+
const polling_1 = require("../polling");
|
|
38
40
|
const waitForSlsProject = async (getProject, projectName) => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
try {
|
|
42
|
+
const project = await (0, polling_1.pollUntil)({
|
|
43
|
+
description: `SLS project ${projectName} to be ready`,
|
|
44
|
+
fetch: async () => {
|
|
45
|
+
try {
|
|
46
|
+
return await getProject(projectName);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// Project not ready yet
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
isDone: (project) => project?.status === 'Normal',
|
|
54
|
+
intervalMs: 3000,
|
|
55
|
+
maxAttempts: 30,
|
|
56
|
+
onProgress: (project) => {
|
|
57
|
+
if (project) {
|
|
58
|
+
logger_1.logger.info(`Waiting for SLS project ${projectName} to be ready (current status: ${project.status ?? 'unknown'})`);
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
return project;
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
if (e instanceof polling_1.PollingTimeoutError) {
|
|
66
|
+
return { projectName };
|
|
49
67
|
}
|
|
50
|
-
|
|
51
|
-
retries++;
|
|
68
|
+
throw e;
|
|
52
69
|
}
|
|
53
|
-
return { projectName };
|
|
54
70
|
};
|
|
55
71
|
const waitForSlsLogstore = async (getLogstore, projectName, logstoreName, ttl) => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
72
|
+
try {
|
|
73
|
+
const logstore = await (0, polling_1.pollUntil)({
|
|
74
|
+
description: `SLS logstore ${projectName}/${logstoreName} to be ready`,
|
|
75
|
+
fetch: async () => {
|
|
76
|
+
try {
|
|
77
|
+
return await getLogstore(projectName, logstoreName);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
// Logstore not ready yet
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
isDone: (logstore) => logstore != null,
|
|
85
|
+
intervalMs: 3000,
|
|
86
|
+
maxAttempts: 30,
|
|
87
|
+
onProgress: (logstore) => {
|
|
88
|
+
if (logstore) {
|
|
89
|
+
logger_1.logger.info(`Waiting for SLS logstore ${projectName}/${logstoreName} to be ready...`);
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
return logstore;
|
|
94
|
+
}
|
|
95
|
+
catch (e) {
|
|
96
|
+
if (e instanceof polling_1.PollingTimeoutError) {
|
|
97
|
+
return { logstoreName, projectName, ttl };
|
|
66
98
|
}
|
|
67
|
-
|
|
68
|
-
retries++;
|
|
99
|
+
throw e;
|
|
69
100
|
}
|
|
70
|
-
return { logstoreName, projectName, ttl };
|
|
71
101
|
};
|
|
72
102
|
const createSlsOperations = (slsClient) => {
|
|
73
103
|
const operations = {
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.createTablestoreOperations = exports.TableStoreInstanceStatus = void 0;
|
|
7
7
|
const tablestore_1 = __importDefault(require("tablestore"));
|
|
8
8
|
const logger_1 = require("../logger");
|
|
9
|
+
const polling_1 = require("../polling");
|
|
9
10
|
var TableStoreInstanceStatus;
|
|
10
11
|
(function (TableStoreInstanceStatus) {
|
|
11
12
|
TableStoreInstanceStatus["RUNNING"] = "RUNNING";
|
|
@@ -14,30 +15,27 @@ var TableStoreInstanceStatus;
|
|
|
14
15
|
TableStoreInstanceStatus["DISABLED"] = "DISABLED";
|
|
15
16
|
})(TableStoreInstanceStatus || (exports.TableStoreInstanceStatus = TableStoreInstanceStatus = {}));
|
|
16
17
|
const waitForTableReady = async (describeTable, tableName) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
throw error;
|
|
18
|
+
try {
|
|
19
|
+
await (0, polling_1.pollUntil)({
|
|
20
|
+
description: `table ${tableName} to be ready`,
|
|
21
|
+
fetch: () => describeTable(tableName),
|
|
22
|
+
isDone: (table) => table !== null,
|
|
23
|
+
intervalMs: 5000,
|
|
24
|
+
maxAttempts: 60,
|
|
25
|
+
onProgress: (table, attempt, maxAttempts) => {
|
|
26
|
+
if (!table) {
|
|
27
|
+
logger_1.logger.info(`Waiting for table ${tableName} to be ready... (attempt ${attempt}/${maxAttempts})`);
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
logger_1.logger.info(`Table ${tableName} is ready`);
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
if (e instanceof polling_1.PollingTimeoutError) {
|
|
35
|
+
throw new Error(`Timeout waiting for table ${tableName} to be ready`, { cause: e });
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
attempts++;
|
|
37
|
+
throw e;
|
|
39
38
|
}
|
|
40
|
-
throw new Error(`Timeout waiting for table ${tableName} to be ready`);
|
|
41
39
|
};
|
|
42
40
|
const createTablestoreOperations = (endpoint, instanceName, context) => {
|
|
43
41
|
const client = new tablestore_1.default.Client({
|
|
@@ -110,6 +108,11 @@ const createTablestoreOperations = (endpoint, instanceName, context) => {
|
|
|
110
108
|
reservedThroughputDetails: result.reservedThroughputDetails,
|
|
111
109
|
tableOptions: result.tableOptions,
|
|
112
110
|
streamDetails: result.streamDetails,
|
|
111
|
+
// Maximum-detail fields — retain everything DescribeTable returns.
|
|
112
|
+
tableStatus: result.tableStatus,
|
|
113
|
+
definedColumn: result.tableMeta.definedColumn,
|
|
114
|
+
indexMetas: result.indexMetas ?? result.tableMeta.indexMeta,
|
|
115
|
+
shardSplits: result.shardSplits,
|
|
113
116
|
});
|
|
114
117
|
}
|
|
115
118
|
}
|