@geek-fun/serverlessinsight 0.9.2 → 0.9.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 +1 -1
- package/.serverlessinsight/state-iam-test-app-iam-test-service.json.backup +2 -2
- package/.serverlessinsight/state-insight-poc-app-insight-poc-tencent.json.backup +4 -8
- package/.serverlessinsight/state-insight-poc-app-log-insight-poc-tencent-log.json.backup +3 -8
- package/.serverlessinsight/state-insight-poc-deploy-app-insight-poc-deploy.json.backup +4 -4
- package/.serverlessinsight/state-insight-poc-destroy-app-insight-poc-destroy.json.backup +1 -1
- package/.serverlessinsight/state-insight-poc-timer-app-insight-poc-timer.json.backup +28 -5
- package/.serverlessinsight/state-insight-volc-app-insight-volc.json.backup +2 -2
- package/.serverlessinsight/state-insight-volc-nested-app-insight-volc-nested.json.backup +3 -3
- package/.serverlessinsight/state-nested-drift-app-nested-drift-service.json.backup +20 -5
- package/.serverlessinsight/state-role-reconcile-test-app-role-reconcile-test-service.json.backup +3 -3
- package/AGENTS.md +10 -0
- package/CHANGELOG.md +62 -0
- package/README.md +256 -175
- package/README.zh-CN.md +249 -159
- package/dist/package.json +22 -19
- package/dist/src/commands/index.js +21 -52
- package/dist/src/commands/local.js +16 -3
- package/dist/src/commands/plan.js +35 -4
- package/dist/src/common/aliyunClient/apigwOperations.js +48 -9
- package/dist/src/common/aliyunClient/fc3Operations.js +7 -1
- package/dist/src/common/aliyunClient/ossOperations.js +214 -221
- package/dist/src/common/bucketPolicy.js +63 -0
- package/dist/src/common/domainUtils.js +4 -1
- package/dist/src/common/functionDefinition.js +25 -0
- package/dist/src/common/index.js +4 -0
- package/dist/src/common/jsonOutput.js +6 -1
- package/dist/src/common/nameBuilder.js +3 -1
- package/dist/src/common/planCapabilities.js +119 -0
- package/dist/src/common/planCompare.js +119 -66
- package/dist/src/common/planFormatter.js +22 -14
- package/dist/src/common/planRedaction.js +26 -0
- package/dist/src/common/refreshPlanner.js +66 -21
- package/dist/src/common/tencentClient/cosOperations.js +326 -322
- package/dist/src/common/tencentClient/scfOperations.js +9 -2
- package/dist/src/common/tencentClient/tdsqlcOperations.js +6 -11
- package/dist/src/common/triggerMapper.js +16 -1
- package/dist/src/common/volcengineClient/apigwOperations.js +82 -0
- package/dist/src/common/volcengineClient/iamOperations.js +27 -3
- package/dist/src/common/volcengineClient/tosOperations.js +62 -56
- package/dist/src/lang/en.js +33 -8
- package/dist/src/lang/index.js +28 -14
- package/dist/src/lang/zh-CN.js +33 -8
- package/dist/src/parser/eventParser.js +1 -0
- package/dist/src/parser/functionParser.js +1 -1
- package/dist/src/stack/aliyunStack/apigwDomainPlan.js +82 -0
- package/dist/src/stack/aliyunStack/apigwExecutor.js +4 -1
- package/dist/src/stack/aliyunStack/apigwPlanner.js +165 -25
- package/dist/src/stack/aliyunStack/apigwResource.js +172 -126
- package/dist/src/stack/aliyunStack/apigwTypes.js +3 -7
- package/dist/src/stack/aliyunStack/deployer.js +2 -0
- package/dist/src/stack/aliyunStack/esServerlessTypes.js +8 -4
- package/dist/src/stack/aliyunStack/fc3Executor.js +7 -3
- package/dist/src/stack/aliyunStack/fc3Planner.js +124 -155
- package/dist/src/stack/aliyunStack/fc3Resource.js +48 -52
- package/dist/src/stack/aliyunStack/fc3Types.js +30 -16
- package/dist/src/stack/aliyunStack/ossPlanner.js +15 -1
- package/dist/src/stack/aliyunStack/ossResource.js +113 -102
- package/dist/src/stack/aliyunStack/ossTypes.js +20 -20
- package/dist/src/stack/localStack/aliyunFc.js +1 -6
- package/dist/src/stack/localStack/event.js +31 -60
- package/dist/src/stack/localStack/function.js +24 -65
- package/dist/src/stack/localStack/functionRunner.js +10 -2
- package/dist/src/stack/localStack/httpAdapter.js +54 -0
- package/dist/src/stack/localStack/httpError.js +5 -0
- package/dist/src/stack/localStack/legacyLambda.js +26 -0
- package/dist/src/stack/localStack/localContext.js +29 -0
- package/dist/src/stack/localStack/localRoute.js +12 -0
- package/dist/src/stack/localStack/localRuntimes.js +22 -0
- package/dist/src/stack/localStack/localServer.js +8 -3
- package/dist/src/stack/localStack/requestBody.js +24 -0
- package/dist/src/stack/localStack/requestId.js +18 -0
- package/dist/src/stack/localStack/tencent.js +147 -0
- package/dist/src/stack/localStack/timer.js +23 -2
- package/dist/src/stack/localStack/volcengine.js +68 -0
- package/dist/src/stack/scfStack/cosPlanner.js +9 -14
- package/dist/src/stack/scfStack/cosResource.js +42 -50
- package/dist/src/stack/scfStack/cosTypes.js +19 -14
- package/dist/src/stack/scfStack/deployer.js +2 -0
- package/dist/src/stack/scfStack/scfExecutor.js +7 -3
- package/dist/src/stack/scfStack/scfHttpTrigger.js +106 -0
- package/dist/src/stack/scfStack/scfPlanner.js +67 -16
- package/dist/src/stack/scfStack/scfResource.js +170 -321
- package/dist/src/stack/scfStack/scfTypes.js +4 -3
- package/dist/src/stack/scfStack/tdsqlcPlanner.js +10 -13
- package/dist/src/stack/volcengineStack/apigwDomains.js +64 -0
- package/dist/src/stack/volcengineStack/apigwPlanner.js +71 -15
- package/dist/src/stack/volcengineStack/apigwResource.js +60 -24
- package/dist/src/stack/volcengineStack/apigwTypes.js +5 -1
- package/dist/src/stack/volcengineStack/deployer.js +6 -0
- package/dist/src/stack/volcengineStack/tosPlanner.js +8 -13
- package/dist/src/stack/volcengineStack/tosResource.js +22 -35
- package/dist/src/stack/volcengineStack/tosTypes.js +5 -8
- package/dist/src/stack/volcengineStack/vefaasPlanner.js +142 -49
- package/dist/src/stack/volcengineStack/vefaasResource.js +17 -12
- package/dist/src/stack/volcengineStack/vefaasTypes.js +6 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +22 -19
- package/release-notes.md +53 -0
- package/samples/README_TENCENT_COS.md +3 -3
- package/samples/README_TENCENT_SCF.md +3 -3
- package/samples/tencent-local/index.js +13 -0
- package/samples/tencent-local/serverlessinsight.yml +23 -0
- package/samples/volcengine-local/index.js +13 -0
- package/samples/volcengine-local/serverlessinsight.yml +28 -0
|
@@ -602,245 +602,238 @@ const parseReplicationRules = (xml) => {
|
|
|
602
602
|
};
|
|
603
603
|
},
|
|
604
604
|
getBucket: async (bucketName) => {
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
// Get bucket info
|
|
608
|
-
const infoResult = await ossClient.getBucketInfo(bucketName);
|
|
609
|
-
const bucket = infoResult.bucket;
|
|
610
|
-
// Get ACL
|
|
611
|
-
let acl;
|
|
612
|
-
try {
|
|
613
|
-
const aclResult = await ossClient.getBucketACL(bucketName);
|
|
614
|
-
acl = aclResult.acl;
|
|
615
|
-
}
|
|
616
|
-
catch {
|
|
617
|
-
// ACL might not be accessible
|
|
618
|
-
}
|
|
619
|
-
// Get website config
|
|
620
|
-
let websiteConfig;
|
|
605
|
+
useBucket(bucketName);
|
|
606
|
+
const infoResult = await (async () => {
|
|
621
607
|
try {
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
websiteConfig = {
|
|
625
|
-
indexDocument: websiteResult.index,
|
|
626
|
-
errorDocument: websiteResult.error,
|
|
627
|
-
};
|
|
628
|
-
}
|
|
608
|
+
// Get bucket info
|
|
609
|
+
return await ossClient.getBucketInfo(bucketName);
|
|
629
610
|
}
|
|
630
|
-
catch {
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
const loggingResult = await ossClient.getBucketLogging(bucketName);
|
|
637
|
-
if (loggingResult.enable && loggingResult.prefix) {
|
|
638
|
-
loggingConfig = {
|
|
639
|
-
targetPrefix: loggingResult.prefix,
|
|
640
|
-
};
|
|
611
|
+
catch (error) {
|
|
612
|
+
if (error &&
|
|
613
|
+
typeof error === 'object' &&
|
|
614
|
+
'code' in error &&
|
|
615
|
+
error.code === 'NoSuchBucket') {
|
|
616
|
+
return null;
|
|
641
617
|
}
|
|
618
|
+
throw error;
|
|
642
619
|
}
|
|
643
|
-
|
|
644
|
-
|
|
620
|
+
})();
|
|
621
|
+
if (infoResult === null)
|
|
622
|
+
return null;
|
|
623
|
+
const bucket = infoResult.bucket;
|
|
624
|
+
// Get ACL
|
|
625
|
+
let acl;
|
|
626
|
+
try {
|
|
627
|
+
const aclResult = await ossClient.getBucketACL(bucketName);
|
|
628
|
+
acl = aclResult.acl;
|
|
629
|
+
}
|
|
630
|
+
catch {
|
|
631
|
+
// ACL might not be accessible
|
|
632
|
+
}
|
|
633
|
+
// Get website config
|
|
634
|
+
let websiteConfig = null;
|
|
635
|
+
try {
|
|
636
|
+
const websiteResult = await ossClient.getBucketWebsite(bucketName);
|
|
637
|
+
if (websiteResult.index) {
|
|
638
|
+
websiteConfig = {
|
|
639
|
+
indexDocument: websiteResult.index,
|
|
640
|
+
errorDocument: websiteResult.error,
|
|
641
|
+
};
|
|
645
642
|
}
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
? rule.allowedHeader
|
|
661
|
-
: [rule.allowedHeader]
|
|
662
|
-
: undefined,
|
|
663
|
-
exposeHeaders: rule.exposeHeader
|
|
664
|
-
? Array.isArray(rule.exposeHeader)
|
|
665
|
-
? rule.exposeHeader
|
|
666
|
-
: [rule.exposeHeader]
|
|
667
|
-
: undefined,
|
|
668
|
-
maxAgeSeconds: typeof rule.maxAgeSeconds === 'number' ? rule.maxAgeSeconds : undefined,
|
|
669
|
-
}));
|
|
670
|
-
}
|
|
643
|
+
}
|
|
644
|
+
catch (error) {
|
|
645
|
+
const code = error?.code;
|
|
646
|
+
if (code !== 'NoSuchWebsiteConfiguration' && code !== 'NoSuchConfiguration')
|
|
647
|
+
throw error;
|
|
648
|
+
}
|
|
649
|
+
// Get logging config
|
|
650
|
+
let loggingConfig;
|
|
651
|
+
try {
|
|
652
|
+
const loggingResult = await ossClient.getBucketLogging(bucketName);
|
|
653
|
+
if (loggingResult.enable && loggingResult.prefix) {
|
|
654
|
+
loggingConfig = {
|
|
655
|
+
targetPrefix: loggingResult.prefix,
|
|
656
|
+
};
|
|
671
657
|
}
|
|
672
|
-
|
|
673
|
-
|
|
658
|
+
}
|
|
659
|
+
catch {
|
|
660
|
+
// Logging config might not exist
|
|
661
|
+
}
|
|
662
|
+
// Get CORS rules
|
|
663
|
+
let corsRules;
|
|
664
|
+
try {
|
|
665
|
+
const corsResult = await ossClient.getBucketCORS(bucketName);
|
|
666
|
+
if (corsResult.rules && corsResult.rules.length > 0) {
|
|
667
|
+
corsRules = corsResult.rules.map((rule) => ({
|
|
668
|
+
allowedOrigins: Array.isArray(rule.allowedOrigin)
|
|
669
|
+
? rule.allowedOrigin
|
|
670
|
+
: [rule.allowedOrigin],
|
|
671
|
+
allowedMethods: Array.isArray(rule.allowedMethod)
|
|
672
|
+
? rule.allowedMethod
|
|
673
|
+
: [rule.allowedMethod],
|
|
674
|
+
allowedHeaders: rule.allowedHeader
|
|
675
|
+
? Array.isArray(rule.allowedHeader)
|
|
676
|
+
? rule.allowedHeader
|
|
677
|
+
: [rule.allowedHeader]
|
|
678
|
+
: undefined,
|
|
679
|
+
exposeHeaders: rule.exposeHeader
|
|
680
|
+
? Array.isArray(rule.exposeHeader)
|
|
681
|
+
? rule.exposeHeader
|
|
682
|
+
: [rule.exposeHeader]
|
|
683
|
+
: undefined,
|
|
684
|
+
maxAgeSeconds: typeof rule.maxAgeSeconds === 'number' ? rule.maxAgeSeconds : undefined,
|
|
685
|
+
}));
|
|
674
686
|
}
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
687
|
+
}
|
|
688
|
+
catch {
|
|
689
|
+
// CORS config might not exist
|
|
690
|
+
}
|
|
691
|
+
// Get lifecycle rules
|
|
692
|
+
let lifecycleRules;
|
|
693
|
+
try {
|
|
694
|
+
const lifecycleResult = await ossClient.getBucketLifecycle(bucketName);
|
|
695
|
+
if (lifecycleResult.rules && lifecycleResult.rules.length > 0) {
|
|
696
|
+
lifecycleRules = lifecycleResult.rules.map((rule) => {
|
|
697
|
+
const rawRule = rule;
|
|
698
|
+
const rawTransition = Array.isArray(rawRule.transition)
|
|
699
|
+
? rawRule.transition[0]
|
|
700
|
+
: rawRule.transition;
|
|
701
|
+
const transition = (rawTransition ?? undefined);
|
|
702
|
+
const expirationDays = rawRule.expiration?.days ?? rule.days;
|
|
703
|
+
const expirationDate = rawRule.expiration?.date ?? rule.date;
|
|
704
|
+
const expiredObjectDeleteMarker = rawRule.expiration?.expiredObjectDeleteMarker;
|
|
705
|
+
const expiration = expirationDays !== undefined
|
|
706
|
+
? {
|
|
707
|
+
days: typeof expirationDays === 'number'
|
|
708
|
+
? expirationDays
|
|
709
|
+
: parseInt(expirationDays, 10),
|
|
710
|
+
...(expiredObjectDeleteMarker ? { expiredObjectDeleteMarker: true } : {}),
|
|
711
|
+
}
|
|
712
|
+
: expirationDate
|
|
690
713
|
? {
|
|
691
|
-
|
|
692
|
-
? expirationDays
|
|
693
|
-
: parseInt(expirationDays, 10),
|
|
714
|
+
date: expirationDate,
|
|
694
715
|
...(expiredObjectDeleteMarker ? { expiredObjectDeleteMarker: true } : {}),
|
|
695
716
|
}
|
|
696
|
-
:
|
|
697
|
-
? {
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
: undefined,
|
|
716
|
-
date: transition.date,
|
|
717
|
-
storageClass: transition.storageClass,
|
|
718
|
-
}
|
|
719
|
-
: undefined,
|
|
720
|
-
};
|
|
721
|
-
});
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
catch {
|
|
725
|
-
// Lifecycle config might not exist
|
|
726
|
-
}
|
|
727
|
-
// Get versioning status (GetBucketVersioning)
|
|
728
|
-
let versioningConfig;
|
|
729
|
-
try {
|
|
730
|
-
const versioningResult = await ossClient.getBucketVersioning(bucketName);
|
|
731
|
-
if (versioningResult?.versionStatus === 'Enabled' ||
|
|
732
|
-
versioningResult?.versionStatus === 'Suspended') {
|
|
733
|
-
versioningConfig = { status: versioningResult.versionStatus };
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
catch {
|
|
737
|
-
// Versioning config might not exist
|
|
738
|
-
}
|
|
739
|
-
// Get server-side encryption (GetBucketEncryption)
|
|
740
|
-
let encryptionConfig;
|
|
741
|
-
try {
|
|
742
|
-
const encryptionResult = await ossClient.getBucketEncryption(bucketName);
|
|
743
|
-
const enc = encryptionResult?.encryption;
|
|
744
|
-
if (enc?.SSEAlgorithm) {
|
|
745
|
-
encryptionConfig = {
|
|
746
|
-
sseAlgorithm: enc.SSEAlgorithm,
|
|
747
|
-
kmsMasterKeyId: enc.KMSMasterKeyID,
|
|
748
|
-
kmsDataEncryption: enc.KMSDataEncryption,
|
|
717
|
+
: expiredObjectDeleteMarker
|
|
718
|
+
? { expiredObjectDeleteMarker: true }
|
|
719
|
+
: undefined;
|
|
720
|
+
return {
|
|
721
|
+
id: rule.id,
|
|
722
|
+
status: rule.status,
|
|
723
|
+
prefix: rule.prefix,
|
|
724
|
+
expiration,
|
|
725
|
+
transition: transition
|
|
726
|
+
? {
|
|
727
|
+
days: typeof transition.days === 'number'
|
|
728
|
+
? transition.days
|
|
729
|
+
: transition.days !== undefined
|
|
730
|
+
? parseInt(transition.days, 10)
|
|
731
|
+
: undefined,
|
|
732
|
+
date: transition.date,
|
|
733
|
+
storageClass: transition.storageClass,
|
|
734
|
+
}
|
|
735
|
+
: undefined,
|
|
749
736
|
};
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
catch {
|
|
753
|
-
// Encryption config might not exist
|
|
754
|
-
}
|
|
755
|
-
// Get transfer acceleration status (GetBucketTransferAcceleration)
|
|
756
|
-
let transferAccelerationStatus;
|
|
757
|
-
try {
|
|
758
|
-
const enabled = await operations.getTransferAccelerationStatus(bucketName);
|
|
759
|
-
transferAccelerationStatus = enabled ? 'Enabled' : 'Disabled';
|
|
760
|
-
}
|
|
761
|
-
catch {
|
|
762
|
-
// Transfer acceleration might not be configured
|
|
763
|
-
}
|
|
764
|
-
// Get replication rules (GetBucketReplication)
|
|
765
|
-
let replicationRules;
|
|
766
|
-
try {
|
|
767
|
-
const replicationResponse = await ossRequest(ossClient, {
|
|
768
|
-
method: 'GET',
|
|
769
|
-
bucket: bucketName,
|
|
770
|
-
subres: { replication: '' },
|
|
771
|
-
successStatuses: [200],
|
|
772
737
|
});
|
|
773
|
-
const replicationXml = replicationResponse.data || '';
|
|
774
|
-
const parsedRules = parseReplicationRules(replicationXml);
|
|
775
|
-
if (parsedRules.length > 0) {
|
|
776
|
-
replicationRules = parsedRules;
|
|
777
|
-
}
|
|
778
738
|
}
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
catch {
|
|
802
|
-
// No bucket tags configured
|
|
739
|
+
}
|
|
740
|
+
catch {
|
|
741
|
+
// Lifecycle config might not exist
|
|
742
|
+
}
|
|
743
|
+
// Get versioning status (GetBucketVersioning)
|
|
744
|
+
let versioningConfig = null;
|
|
745
|
+
const versioningResult = await ossClient.getBucketVersioning(bucketName);
|
|
746
|
+
if (versioningResult?.versionStatus === 'Enabled' ||
|
|
747
|
+
versioningResult?.versionStatus === 'Suspended') {
|
|
748
|
+
versioningConfig = { status: versioningResult.versionStatus };
|
|
749
|
+
}
|
|
750
|
+
// Get server-side encryption (GetBucketEncryption)
|
|
751
|
+
let encryptionConfig = null;
|
|
752
|
+
try {
|
|
753
|
+
const encryptionResult = await ossClient.getBucketEncryption(bucketName);
|
|
754
|
+
const enc = encryptionResult?.encryption;
|
|
755
|
+
if (enc?.SSEAlgorithm) {
|
|
756
|
+
encryptionConfig = {
|
|
757
|
+
sseAlgorithm: enc.SSEAlgorithm,
|
|
758
|
+
kmsMasterKeyId: enc.KMSMasterKeyID,
|
|
759
|
+
kmsDataEncryption: enc.KMSDataEncryption,
|
|
760
|
+
};
|
|
803
761
|
}
|
|
804
|
-
// Build owner info
|
|
805
|
-
const owner = bucket?.Owner
|
|
806
|
-
? {
|
|
807
|
-
id: bucket.Owner.ID,
|
|
808
|
-
displayName: bucket.Owner.DisplayName,
|
|
809
|
-
}
|
|
810
|
-
: undefined;
|
|
811
|
-
return {
|
|
812
|
-
name: bucketName,
|
|
813
|
-
location: bucket?.Location,
|
|
814
|
-
creationDate: bucket?.CreationDate,
|
|
815
|
-
storageClass: bucket?.StorageClass,
|
|
816
|
-
dataRedundancyType: bucket?.DataRedundancyType,
|
|
817
|
-
resourceGroupId: bucket?.ResourceGroupId,
|
|
818
|
-
comment: bucket?.Comment,
|
|
819
|
-
owner,
|
|
820
|
-
blockPublicAccess: bucket?.BlockPublicAccess,
|
|
821
|
-
accessMonitorStatus: bucket?.AccessMonitor,
|
|
822
|
-
acl,
|
|
823
|
-
websiteConfig,
|
|
824
|
-
loggingConfig,
|
|
825
|
-
corsRules,
|
|
826
|
-
lifecycleRules,
|
|
827
|
-
versioningConfig,
|
|
828
|
-
encryptionConfig,
|
|
829
|
-
transferAccelerationStatus,
|
|
830
|
-
replicationRules,
|
|
831
|
-
tags,
|
|
832
|
-
policy,
|
|
833
|
-
};
|
|
834
762
|
}
|
|
835
763
|
catch (error) {
|
|
836
|
-
if (error
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
764
|
+
if (error?.code !== 'NoSuchServerSideEncryptionRule')
|
|
765
|
+
throw error;
|
|
766
|
+
}
|
|
767
|
+
// Get transfer acceleration status (GetBucketTransferAcceleration)
|
|
768
|
+
let transferAccelerationStatus;
|
|
769
|
+
try {
|
|
770
|
+
const enabled = await operations.getTransferAccelerationStatus(bucketName);
|
|
771
|
+
transferAccelerationStatus = enabled ? 'Enabled' : 'Disabled';
|
|
772
|
+
}
|
|
773
|
+
catch {
|
|
774
|
+
// Transfer acceleration might not be configured
|
|
775
|
+
}
|
|
776
|
+
// Get replication rules (GetBucketReplication)
|
|
777
|
+
let replicationRules;
|
|
778
|
+
try {
|
|
779
|
+
const replicationResponse = await ossRequest(ossClient, {
|
|
780
|
+
method: 'GET',
|
|
781
|
+
bucket: bucketName,
|
|
782
|
+
subres: { replication: '' },
|
|
783
|
+
successStatuses: [200],
|
|
784
|
+
});
|
|
785
|
+
const replicationXml = replicationResponse.data || '';
|
|
786
|
+
const parsedRules = parseReplicationRules(replicationXml);
|
|
787
|
+
if (parsedRules.length > 0) {
|
|
788
|
+
replicationRules = parsedRules;
|
|
841
789
|
}
|
|
842
|
-
throw error;
|
|
843
790
|
}
|
|
791
|
+
catch {
|
|
792
|
+
// Replication config might not exist
|
|
793
|
+
}
|
|
794
|
+
const policyResult = await operations.getBucketPolicy(bucketName);
|
|
795
|
+
const policy = policyResult === null ? null : JSON.stringify(policyResult);
|
|
796
|
+
// Get bucket tags
|
|
797
|
+
let tags;
|
|
798
|
+
try {
|
|
799
|
+
const tagsResult = await ossClient.getBucketTags(bucketName);
|
|
800
|
+
if (tagsResult.tag) {
|
|
801
|
+
tags = Object.entries(tagsResult.tag).map(([key, value]) => ({ key, value }));
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
catch {
|
|
805
|
+
// No bucket tags configured
|
|
806
|
+
}
|
|
807
|
+
// Build owner info
|
|
808
|
+
const owner = bucket?.Owner
|
|
809
|
+
? {
|
|
810
|
+
id: bucket.Owner.ID,
|
|
811
|
+
displayName: bucket.Owner.DisplayName,
|
|
812
|
+
}
|
|
813
|
+
: undefined;
|
|
814
|
+
return {
|
|
815
|
+
name: bucketName,
|
|
816
|
+
location: bucket?.Location,
|
|
817
|
+
creationDate: bucket?.CreationDate,
|
|
818
|
+
storageClass: bucket?.StorageClass,
|
|
819
|
+
dataRedundancyType: bucket?.DataRedundancyType,
|
|
820
|
+
resourceGroupId: bucket?.ResourceGroupId,
|
|
821
|
+
comment: bucket?.Comment,
|
|
822
|
+
owner,
|
|
823
|
+
blockPublicAccess: bucket?.BlockPublicAccess,
|
|
824
|
+
accessMonitorStatus: bucket?.AccessMonitor,
|
|
825
|
+
acl,
|
|
826
|
+
websiteConfig,
|
|
827
|
+
loggingConfig,
|
|
828
|
+
corsRules,
|
|
829
|
+
lifecycleRules,
|
|
830
|
+
versioningConfig,
|
|
831
|
+
encryptionConfig,
|
|
832
|
+
transferAccelerationStatus,
|
|
833
|
+
replicationRules,
|
|
834
|
+
tags,
|
|
835
|
+
policy,
|
|
836
|
+
};
|
|
844
837
|
},
|
|
845
838
|
updateBucketAcl: async (bucketName, acl) => {
|
|
846
839
|
if (isPublicAcl(acl)) {
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeBucketPolicyDefinition = exports.removedBucketPolicy = exports.isOwnedBucketPolicy = exports.serializeBucketPolicy = exports.buildBucketPolicy = void 0;
|
|
4
|
+
/** The exact provider document used by both comparison and write requests. */
|
|
5
|
+
const buildBucketPolicy = (iam, provider) => {
|
|
6
|
+
if (!iam?.resource?.statements?.length)
|
|
7
|
+
return null;
|
|
8
|
+
if (provider === 'tencent') {
|
|
9
|
+
return {
|
|
10
|
+
version: '2.0',
|
|
11
|
+
statement: iam.resource.statements.map((statement) => ({
|
|
12
|
+
effect: statement.effect.toLowerCase(),
|
|
13
|
+
principal: statement.principal,
|
|
14
|
+
action: statement.action,
|
|
15
|
+
resource: statement.resource,
|
|
16
|
+
...(statement.condition ? { condition: statement.condition } : {}),
|
|
17
|
+
})),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
...(provider === 'aliyun' ? { Version: '1' } : {}),
|
|
22
|
+
Statement: iam.resource.statements.map((statement) => ({
|
|
23
|
+
Effect: statement.effect,
|
|
24
|
+
Principal: statement.principal,
|
|
25
|
+
Action: statement.action,
|
|
26
|
+
Resource: statement.resource,
|
|
27
|
+
...(statement.condition ? { Condition: statement.condition } : {}),
|
|
28
|
+
})),
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
exports.buildBucketPolicy = buildBucketPolicy;
|
|
32
|
+
const serializeBucketPolicy = (iam, provider) => {
|
|
33
|
+
const policy = (0, exports.buildBucketPolicy)(iam, provider);
|
|
34
|
+
return policy ? JSON.stringify(policy) : iam?.resource?.statements !== undefined ? 'null' : null;
|
|
35
|
+
};
|
|
36
|
+
exports.serializeBucketPolicy = serializeBucketPolicy;
|
|
37
|
+
/** A policy is ours when state records its instance, or when pre-instance state stored a policy document. */
|
|
38
|
+
const isOwnedBucketPolicy = (policyInstanceType, instances, definition) => (instances ?? []).some((instance) => instance.type === policyInstanceType) ||
|
|
39
|
+
(typeof definition?.policy === 'string' && definition.policy !== 'null');
|
|
40
|
+
exports.isOwnedBucketPolicy = isOwnedBucketPolicy;
|
|
41
|
+
/** A recorded policy the YAML no longer declares (omitted or emptied statements) is removed. */
|
|
42
|
+
const removedBucketPolicy = (policyInstanceType, currentState, desired) => currentState &&
|
|
43
|
+
(0, exports.isOwnedBucketPolicy)(policyInstanceType, currentState.instances, currentState.definition) &&
|
|
44
|
+
(desired.policy === null || desired.policy === 'null')
|
|
45
|
+
? { policy: currentState.definition.policy ?? null }
|
|
46
|
+
: {};
|
|
47
|
+
exports.removedBucketPolicy = removedBucketPolicy;
|
|
48
|
+
/** Read older saved intent without treating the DSL-to-wire migration as drift. */
|
|
49
|
+
const normalizeBucketPolicyDefinition = (definition, provider) => {
|
|
50
|
+
if (typeof definition.policy !== 'string')
|
|
51
|
+
return definition;
|
|
52
|
+
try {
|
|
53
|
+
const value = JSON.parse(definition.policy);
|
|
54
|
+
if (value?.resource && Array.isArray(value.resource.statements)) {
|
|
55
|
+
return { ...definition, policy: (0, exports.serializeBucketPolicy)(value, provider) };
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// Invalid documents are preserved so comparison cannot silently erase them.
|
|
60
|
+
}
|
|
61
|
+
return definition;
|
|
62
|
+
};
|
|
63
|
+
exports.normalizeBucketPolicyDefinition = normalizeBucketPolicyDefinition;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deriveWwwDomain = exports.extractHostRecord = exports.extractMainDomain = exports.normalizeDomain = void 0;
|
|
3
|
+
exports.resolveWwwBindingAction = exports.deriveWwwDomain = exports.extractHostRecord = exports.extractMainDomain = exports.normalizeDomain = void 0;
|
|
4
4
|
const MULTI_LEVEL_TLDS = new Set([
|
|
5
5
|
// United Kingdom
|
|
6
6
|
'co.uk',
|
|
@@ -144,3 +144,6 @@ const deriveWwwDomain = (domain) => {
|
|
|
144
144
|
return `www.${domain}`;
|
|
145
145
|
};
|
|
146
146
|
exports.deriveWwwDomain = deriveWwwDomain;
|
|
147
|
+
/** Omission restores the framework default: no www binding. */
|
|
148
|
+
const resolveWwwBindingAction = (declared) => declared === true ? 'ensure' : 'remove';
|
|
149
|
+
exports.resolveWwwBindingAction = resolveWwwBindingAction;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withStoredFunctionIam = exports.withLifecycleIntent = exports.withFunctionLifecycle = void 0;
|
|
4
|
+
const planCompare_1 = require("./planCompare");
|
|
5
|
+
/** Persist lifecycle intent alongside function configuration, using the same shape on every provider. */
|
|
6
|
+
const withFunctionLifecycle = (definition, fn, support = {}) => ({
|
|
7
|
+
...definition,
|
|
8
|
+
...(fn?.log !== undefined && !definition.logConfig ? { logEnabled: fn.log } : {}),
|
|
9
|
+
...(support.http !== false && fn?.triggers?.http ? { http: fn.triggers.http } : {}),
|
|
10
|
+
...(support.domain !== false && fn?.domain ? { domain: fn.domain } : {}),
|
|
11
|
+
...(fn?.triggers?.timer !== undefined ? { timers: fn.triggers.timer } : {}),
|
|
12
|
+
});
|
|
13
|
+
exports.withFunctionLifecycle = withFunctionLifecycle;
|
|
14
|
+
/** Lifecycle fields follow the YAML on write: a removed field is dropped, not merged back from stored intent. */
|
|
15
|
+
const withLifecycleIntent = (merged, desired, keys) => ({
|
|
16
|
+
...Object.fromEntries(Object.entries(merged).filter(([key]) => !keys.includes(key))),
|
|
17
|
+
...Object.fromEntries(keys.filter((key) => key in desired).map((key) => [key, desired[key]])),
|
|
18
|
+
});
|
|
19
|
+
exports.withLifecycleIntent = withLifecycleIntent;
|
|
20
|
+
/** An omitted IAM block must not revoke a previously managed grant on an unrelated update. */
|
|
21
|
+
const withStoredFunctionIam = (fn, stored = {}) => {
|
|
22
|
+
const iam = (0, planCompare_1.mergeManagedIntent)({ iam: stored.iam }, { iam: fn.iam }).iam;
|
|
23
|
+
return iam ? { ...fn, iam } : fn;
|
|
24
|
+
};
|
|
25
|
+
exports.withStoredFunctionIam = withStoredFunctionIam;
|
package/dist/src/common/index.js
CHANGED
|
@@ -43,3 +43,7 @@ __exportStar(require("./concurrency"), exports);
|
|
|
43
43
|
__exportStar(require("./throttleRetry"), exports);
|
|
44
44
|
__exportStar(require("./planCompare"), exports);
|
|
45
45
|
__exportStar(require("./refreshPlanner"), exports);
|
|
46
|
+
__exportStar(require("./planCapabilities"), exports);
|
|
47
|
+
__exportStar(require("./bucketPolicy"), exports);
|
|
48
|
+
__exportStar(require("./functionDefinition"), exports);
|
|
49
|
+
__exportStar(require("./planRedaction"), exports);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildPlanJson = exports.buildPlanChange = exports.buildPlanSummary = exports.writeJson = exports.isJsonMode = exports.setJsonMode = exports.SHOW_JSON_VERSION = exports.VALIDATE_JSON_VERSION = exports.PLAN_JSON_VERSION = void 0;
|
|
4
|
+
const planRedaction_1 = require("./planRedaction");
|
|
4
5
|
const planFormatter_1 = require("./planFormatter");
|
|
5
6
|
/**
|
|
6
7
|
* Machine-readable output channel (issue #250): the `--json` surface of the CLI.
|
|
@@ -57,7 +58,8 @@ const buildPlanChange = (item) => {
|
|
|
57
58
|
logicalId: item.logicalId,
|
|
58
59
|
type: item.resourceType,
|
|
59
60
|
action: toPlanJsonAction(item),
|
|
60
|
-
attributes,
|
|
61
|
+
attributes: (0, planRedaction_1.redactAttributeDiffs)(attributes),
|
|
62
|
+
...(item.revertKeys?.length ? { revertKeys: item.revertKeys } : {}),
|
|
61
63
|
...(item.drifted ? { drifted: true } : {}),
|
|
62
64
|
...(item.driftReasons && item.driftReasons.length > 0
|
|
63
65
|
? { driftReasons: item.driftReasons }
|
|
@@ -68,6 +70,9 @@ exports.buildPlanChange = buildPlanChange;
|
|
|
68
70
|
const buildPlanJson = (planResult, identity) => {
|
|
69
71
|
const items = planResult.items ?? [];
|
|
70
72
|
return {
|
|
73
|
+
...(items.some((item) => item.stateUpdate)
|
|
74
|
+
? { stateUpdates: items.filter((item) => item.stateUpdate).map((item) => item.logicalId) }
|
|
75
|
+
: {}),
|
|
71
76
|
planVersion: exports.PLAN_JSON_VERSION,
|
|
72
77
|
...identity,
|
|
73
78
|
changes: items.filter((item) => item.action !== 'noop').map(exports.buildPlanChange),
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* deploy set are additionally rejected up-front by semantic validation.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.buildNasAccessGroupName = exports.buildRolePolicyName = exports.buildFunctionRoleName = exports.CONSTRAINT_NAME_LIMITS = exports.buildConstrainedName = exports.stableHash = exports.DEFAULT_HASH_LENGTH = void 0;
|
|
19
|
+
exports.buildFunctionHttpTriggerName = exports.buildNasAccessGroupName = exports.buildRolePolicyName = exports.buildFunctionRoleName = exports.CONSTRAINT_NAME_LIMITS = exports.buildConstrainedName = exports.stableHash = exports.DEFAULT_HASH_LENGTH = void 0;
|
|
20
20
|
const FNV_OFFSET_BASIS = 0x811c9dc5;
|
|
21
21
|
const FNV_PRIME = 0x01000193;
|
|
22
22
|
const SANITISERS = {
|
|
@@ -101,3 +101,5 @@ exports.buildRolePolicyName = buildRolePolicyName;
|
|
|
101
101
|
*/
|
|
102
102
|
const buildNasAccessGroupName = (fnName, stage, mountPath) => `${fnName}-${stage}-nas-access-${mountPath.replace(/\//g, '-').replace(/^-/, '')}`;
|
|
103
103
|
exports.buildNasAccessGroupName = buildNasAccessGroupName;
|
|
104
|
+
const buildFunctionHttpTriggerName = (functionKey) => `${functionKey}-http-trigger`;
|
|
105
|
+
exports.buildFunctionHttpTriggerName = buildFunctionHttpTriggerName;
|