@geek-fun/serverlessinsight 0.8.2 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.serverlessinsight/state-cdn-flow-app-cdn-flow-service.json.backup +15 -0
- package/.serverlessinsight/state-iam-test-app-iam-test-service.json.backup +33 -0
- package/.serverlessinsight/state-insight-poc-deploy-app-insight-poc-deploy.json.backup +359 -0
- package/.serverlessinsight/state-insight-poc-destroy-app-insight-poc-destroy.json.backup +15 -0
- package/.serverlessinsight/state-insight-volc-app-insight-volc.json.backup +154 -0
- package/.serverlessinsight/state-insight-volc-destroy-app-insight-volc-destroy.json.backup +1 -0
- package/README.md +26 -18
- package/README.zh-CN.md +19 -6
- package/dist/package.json +5 -2
- package/dist/src/commands/deploy.js +87 -4
- package/dist/src/commands/destroy.js +61 -10
- package/dist/src/commands/forceUnlock.js +8 -0
- package/dist/src/commands/index.js +34 -2
- package/dist/src/commands/login.js +195 -0
- package/dist/src/commands/logout.js +17 -0
- package/dist/src/commands/show.js +15 -7
- package/dist/src/commands/whoami.js +20 -0
- package/dist/src/common/aliyunClient/apigwOperations.js +363 -30
- package/dist/src/common/aliyunClient/esOperations.js +43 -29
- package/dist/src/common/aliyunClient/fc3Operations.js +481 -207
- package/dist/src/common/aliyunClient/ossOperations.js +165 -13
- package/dist/src/common/aliyunClient/rdsOperations.js +143 -39
- package/dist/src/common/aliyunClient/slsOperations.js +90 -28
- package/dist/src/common/aliyunClient/tablestoreOperations.js +25 -22
- package/dist/src/common/apiClient.js +102 -0
- package/dist/src/common/constants.js +13 -4
- package/dist/src/common/credentialStore.js +94 -0
- package/dist/src/common/credentials.js +2 -0
- package/dist/src/common/eventQueue.js +208 -0
- package/dist/src/common/hashUtils.js +87 -11
- package/dist/src/common/imsClient.js +1 -0
- package/dist/src/common/index.js +3 -0
- package/dist/src/common/lockManager.js +61 -54
- package/dist/src/common/logger.js +2 -0
- package/dist/src/common/polling.js +54 -0
- package/dist/src/common/reportResourceEvent.js +8 -0
- package/dist/src/common/runtimeMapper.js +11 -12
- package/dist/src/common/stateBackend/index.js +10 -1
- package/dist/src/common/stateBackend/localStateBackend.js +4 -1
- package/dist/src/common/stateBackend/remoteStateBackend.js +10 -4
- package/dist/src/common/stateBackend/saasStateBackend.js +266 -0
- package/dist/src/common/stateManager.js +186 -14
- package/dist/src/common/tencentClient/clsOperations.js +137 -0
- package/dist/src/common/tencentClient/cosOperations.js +180 -3
- package/dist/src/common/tencentClient/esOperations.js +110 -46
- package/dist/src/common/tencentClient/index.js +43 -2
- package/dist/src/common/tencentClient/scfOperations.js +266 -133
- package/dist/src/common/tencentClient/tdsqlcClusterMapper.js +81 -0
- package/dist/src/common/tencentClient/tdsqlcOperations.js +93 -99
- package/dist/src/common/triggerMapper.js +36 -0
- package/dist/src/common/volcengineClient/apigwOperations.js +539 -159
- package/dist/src/common/volcengineClient/iamOperations.js +91 -48
- package/dist/src/common/volcengineClient/index.js +46 -21
- package/dist/src/common/volcengineClient/stsOperations.js +32 -0
- package/dist/src/common/volcengineClient/tlsOperations.js +305 -171
- package/dist/src/common/volcengineClient/tosOperations.js +78 -19
- package/dist/src/common/volcengineClient/vefaasOperations.js +272 -54
- package/dist/src/lang/en.js +107 -1
- package/dist/src/lang/zh-CN.js +107 -1
- package/dist/src/parser/eventParser.js +2 -0
- package/dist/src/parser/functionParser.js +96 -65
- package/dist/src/parser/index.js +7 -4
- package/dist/src/stack/aliyunStack/apigwExecutor.js +39 -1
- package/dist/src/stack/aliyunStack/apigwPlanner.js +16 -10
- package/dist/src/stack/aliyunStack/apigwResource.js +334 -125
- package/dist/src/stack/aliyunStack/apigwTypes.js +35 -4
- package/dist/src/stack/aliyunStack/databaseExecutor.js +39 -1
- package/dist/src/stack/aliyunStack/databasePlanner.js +13 -1
- package/dist/src/stack/aliyunStack/databaseResource.js +135 -40
- package/dist/src/stack/aliyunStack/deployer.js +2 -2
- package/dist/src/stack/aliyunStack/destroyer.js +27 -2
- package/dist/src/stack/aliyunStack/fc3Executor.js +25 -2
- package/dist/src/stack/aliyunStack/fc3Planner.js +11 -1
- package/dist/src/stack/aliyunStack/fc3Resource.js +416 -94
- package/dist/src/stack/aliyunStack/ossExecutor.js +39 -1
- package/dist/src/stack/aliyunStack/ossPlanner.js +15 -1
- package/dist/src/stack/aliyunStack/ossResource.js +267 -219
- package/dist/src/stack/aliyunStack/sharedLogProject.js +137 -0
- package/dist/src/stack/aliyunStack/tablestoreExecutor.js +39 -1
- package/dist/src/stack/aliyunStack/tablestorePlanner.js +13 -1
- package/dist/src/stack/aliyunStack/tablestoreResource.js +54 -20
- package/dist/src/stack/alreadyExists.js +26 -0
- package/dist/src/stack/ownershipTag.js +58 -0
- package/dist/src/stack/rfsStack/index.js +3 -1
- package/dist/src/stack/scfStack/cosExecutor.js +39 -1
- package/dist/src/stack/scfStack/cosPlanner.js +11 -1
- package/dist/src/stack/scfStack/cosResource.js +167 -64
- package/dist/src/stack/scfStack/deployer.js +2 -2
- package/dist/src/stack/scfStack/destroyer.js +15 -2
- package/dist/src/stack/scfStack/esServerlessExecutor.js +39 -1
- package/dist/src/stack/scfStack/esServerlessPlanner.js +11 -1
- package/dist/src/stack/scfStack/esServerlessResource.js +88 -23
- package/dist/src/stack/scfStack/scfExecutor.js +39 -1
- package/dist/src/stack/scfStack/scfPlanner.js +21 -3
- package/dist/src/stack/scfStack/scfResource.js +686 -24
- package/dist/src/stack/scfStack/scfTypes.js +6 -0
- package/dist/src/stack/scfStack/sharedLogset.js +126 -0
- package/dist/src/stack/scfStack/tdsqlcExecutor.js +39 -1
- package/dist/src/stack/scfStack/tdsqlcPlanner.js +12 -1
- package/dist/src/stack/scfStack/tdsqlcResource.js +95 -16
- package/dist/src/stack/scfStack/tdsqlcTypes.js +5 -1
- package/dist/src/stack/volcengineStack/apigwExecutor.js +39 -1
- package/dist/src/stack/volcengineStack/apigwPlanner.js +25 -53
- package/dist/src/stack/volcengineStack/apigwResource.js +434 -222
- package/dist/src/stack/volcengineStack/apigwTypes.js +85 -66
- package/dist/src/stack/volcengineStack/deployer.js +49 -14
- package/dist/src/stack/volcengineStack/destroyer.js +13 -1
- package/dist/src/stack/volcengineStack/index.js +1 -2
- package/dist/src/stack/volcengineStack/sharedLogProject.js +190 -0
- package/dist/src/stack/volcengineStack/tosExecutor.js +25 -2
- package/dist/src/stack/volcengineStack/tosPlanner.js +11 -1
- package/dist/src/stack/volcengineStack/tosResource.js +82 -27
- package/dist/src/stack/volcengineStack/tosTypes.js +12 -0
- package/dist/src/stack/volcengineStack/vefaasExecutor.js +25 -2
- package/dist/src/stack/volcengineStack/vefaasPlanner.js +78 -2
- package/dist/src/stack/volcengineStack/vefaasResource.js +194 -144
- package/dist/src/stack/volcengineStack/vefaasTypes.js +1 -3
- package/dist/src/types/domains/backend.js +1 -0
- package/dist/src/types/domains/state.js +32 -1
- package/dist/src/validator/eventSchema.js +10 -0
- package/dist/src/validator/functionSchema.js +37 -12
- package/dist/src/validator/iacSchema.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -2
|
@@ -272,11 +272,18 @@ const createCosOperations = (cosClient, region, dnsOps) => {
|
|
|
272
272
|
};
|
|
273
273
|
return {
|
|
274
274
|
createBucket: async (config) => {
|
|
275
|
+
// COS PutBucket accepts tags via the x-cos-tagging HTTP header, formatted
|
|
276
|
+
// as URL-encoded key=value pairs joined by '&'.
|
|
277
|
+
const headers = {};
|
|
278
|
+
if (config.Tags && config.Tags.length > 0) {
|
|
279
|
+
headers['x-cos-tagging'] = config.Tags.map((t) => `${encodeURIComponent(t.Key)}=${encodeURIComponent(t.Value)}`).join('&');
|
|
280
|
+
}
|
|
275
281
|
// Create bucket
|
|
276
282
|
await new Promise((resolve, reject) => {
|
|
277
283
|
cosClient.putBucket({
|
|
278
284
|
Bucket: config.Bucket,
|
|
279
285
|
Region: config.Region,
|
|
286
|
+
...(Object.keys(headers).length > 0 ? { Headers: headers } : {}),
|
|
280
287
|
}, (err) => {
|
|
281
288
|
if (err) {
|
|
282
289
|
reject(err);
|
|
@@ -324,8 +331,10 @@ const createCosOperations = (cosClient, region, dnsOps) => {
|
|
|
324
331
|
},
|
|
325
332
|
getBucket: async (bucketName, region) => {
|
|
326
333
|
try {
|
|
327
|
-
// Check if bucket exists
|
|
328
|
-
|
|
334
|
+
// Check if bucket exists. The HeadBucket response carries the bucket
|
|
335
|
+
// creation date in the x-cos-creation-date header — preserved so the
|
|
336
|
+
// state instance no longer reports creationDate: null.
|
|
337
|
+
const headBucketData = await new Promise((resolve, reject) => {
|
|
329
338
|
cosClient.headBucket({
|
|
330
339
|
Bucket: bucketName,
|
|
331
340
|
Region: region,
|
|
@@ -338,6 +347,7 @@ const createCosOperations = (cosClient, region, dnsOps) => {
|
|
|
338
347
|
}
|
|
339
348
|
});
|
|
340
349
|
});
|
|
350
|
+
const creationDate = headBucketData.headers?.['x-cos-creation-date'];
|
|
341
351
|
// Get ACL
|
|
342
352
|
let acl;
|
|
343
353
|
let accessControlPolicy;
|
|
@@ -481,18 +491,185 @@ const createCosOperations = (cosClient, region, dnsOps) => {
|
|
|
481
491
|
})),
|
|
482
492
|
};
|
|
483
493
|
}
|
|
494
|
+
catch (error) {
|
|
495
|
+
// A 404 or NoSuchTagSet means the bucket has no tagging config — not
|
|
496
|
+
// an error. Any other failure (auth, network) must surface loudly so
|
|
497
|
+
// it is not misread as "bucket not owned".
|
|
498
|
+
const err = error;
|
|
499
|
+
const isNoTags = err.statusCode === 404 ||
|
|
500
|
+
err.code === 'NoSuchTagSet' ||
|
|
501
|
+
String(err.message ?? '').includes('NoSuchTagSet');
|
|
502
|
+
if (!isNoTags) {
|
|
503
|
+
throw error;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
// Get lifecycle configuration
|
|
507
|
+
let lifecycleConfiguration;
|
|
508
|
+
try {
|
|
509
|
+
const lifecycleResult = await new Promise((resolve, reject) => {
|
|
510
|
+
cosClient.getBucketLifecycle({
|
|
511
|
+
Bucket: bucketName,
|
|
512
|
+
Region: region,
|
|
513
|
+
}, (err, data) => {
|
|
514
|
+
if (err) {
|
|
515
|
+
reject(err);
|
|
516
|
+
}
|
|
517
|
+
else {
|
|
518
|
+
resolve(data);
|
|
519
|
+
}
|
|
520
|
+
});
|
|
521
|
+
});
|
|
522
|
+
lifecycleConfiguration = {
|
|
523
|
+
rules: lifecycleResult.Rules?.map((r) => ({
|
|
524
|
+
id: r.ID,
|
|
525
|
+
status: r.Status,
|
|
526
|
+
prefix: typeof r.Filter?.Prefix === 'string' ? r.Filter.Prefix : undefined,
|
|
527
|
+
expiration: {
|
|
528
|
+
days: r.Expiration?.Days,
|
|
529
|
+
date: r.Expiration?.Date,
|
|
530
|
+
expiredObjectDeleteMarker: r.Expiration?.ExpiredObjectDeleteMarker,
|
|
531
|
+
},
|
|
532
|
+
transition: {
|
|
533
|
+
days: r.Transition?.Days,
|
|
534
|
+
date: r.Transition?.Date,
|
|
535
|
+
storageClass: r.Transition?.StorageClass,
|
|
536
|
+
},
|
|
537
|
+
})),
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
catch {
|
|
541
|
+
// Lifecycle might not be configured
|
|
542
|
+
}
|
|
543
|
+
// Get logging configuration
|
|
544
|
+
let loggingConfiguration;
|
|
545
|
+
try {
|
|
546
|
+
const loggingResult = await new Promise((resolve, reject) => {
|
|
547
|
+
cosClient.getBucketLogging({
|
|
548
|
+
Bucket: bucketName,
|
|
549
|
+
Region: region,
|
|
550
|
+
}, (err, data) => {
|
|
551
|
+
if (err) {
|
|
552
|
+
reject(err);
|
|
553
|
+
}
|
|
554
|
+
else {
|
|
555
|
+
resolve(data);
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
});
|
|
559
|
+
loggingConfiguration = {
|
|
560
|
+
targetBucket: loggingResult.BucketLoggingStatus?.LoggingEnabled?.TargetBucket,
|
|
561
|
+
targetPrefix: loggingResult.BucketLoggingStatus?.LoggingEnabled?.TargetPrefix,
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
catch {
|
|
565
|
+
// Logging might not be configured
|
|
566
|
+
}
|
|
567
|
+
// Get replication configuration
|
|
568
|
+
let replicationConfiguration;
|
|
569
|
+
try {
|
|
570
|
+
const replicationResult = await new Promise((resolve, reject) => {
|
|
571
|
+
cosClient.getBucketReplication({
|
|
572
|
+
Bucket: bucketName,
|
|
573
|
+
Region: region,
|
|
574
|
+
}, (err, data) => {
|
|
575
|
+
if (err) {
|
|
576
|
+
reject(err);
|
|
577
|
+
}
|
|
578
|
+
else {
|
|
579
|
+
resolve(data);
|
|
580
|
+
}
|
|
581
|
+
});
|
|
582
|
+
});
|
|
583
|
+
replicationConfiguration = {
|
|
584
|
+
role: replicationResult.ReplicationConfiguration?.Role,
|
|
585
|
+
rules: replicationResult.ReplicationConfiguration?.Rules?.map((r) => ({
|
|
586
|
+
id: r.ID,
|
|
587
|
+
status: r.Status,
|
|
588
|
+
prefix: r.Prefix,
|
|
589
|
+
destination: {
|
|
590
|
+
bucket: r.Destination?.Bucket,
|
|
591
|
+
storageClass: r.Destination?.StorageClass,
|
|
592
|
+
},
|
|
593
|
+
})),
|
|
594
|
+
};
|
|
595
|
+
}
|
|
484
596
|
catch {
|
|
485
|
-
//
|
|
597
|
+
// Replication might not be configured
|
|
598
|
+
}
|
|
599
|
+
// Get server-side encryption configuration
|
|
600
|
+
let sseConfiguration;
|
|
601
|
+
try {
|
|
602
|
+
const encryptionResult = await new Promise((resolve, reject) => {
|
|
603
|
+
cosClient.getBucketEncryption({
|
|
604
|
+
Bucket: bucketName,
|
|
605
|
+
Region: region,
|
|
606
|
+
}, (err, data) => {
|
|
607
|
+
if (err) {
|
|
608
|
+
reject(err);
|
|
609
|
+
}
|
|
610
|
+
else {
|
|
611
|
+
resolve(data);
|
|
612
|
+
}
|
|
613
|
+
});
|
|
614
|
+
});
|
|
615
|
+
const rule = encryptionResult.ServerSideEncryptionConfiguration?.Rule?.[0];
|
|
616
|
+
// SDK quirk: the type declares ApplySideEncryptionConfiguration, but the
|
|
617
|
+
// raw COS API returns ApplyServerSideEncryptionByDefault — read both.
|
|
618
|
+
const apply =
|
|
619
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
620
|
+
rule?.ApplyServerSideEncryptionByDefault ??
|
|
621
|
+
rule?.ApplySideEncryptionConfiguration;
|
|
622
|
+
sseConfiguration = {
|
|
623
|
+
sseAlgorithm: apply?.SSEAlgorithm,
|
|
624
|
+
sseKmsMasterKeyId: apply?.KMSMasterKeyID,
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
catch {
|
|
628
|
+
// Encryption might not be configured
|
|
629
|
+
}
|
|
630
|
+
// Get bucket policy (cloud-effective, may differ from the definition)
|
|
631
|
+
let policy = null;
|
|
632
|
+
try {
|
|
633
|
+
const policyResult = await new Promise((resolve, reject) => {
|
|
634
|
+
cosClient.getBucketPolicy({
|
|
635
|
+
Bucket: bucketName,
|
|
636
|
+
Region: region,
|
|
637
|
+
}, (err, data) => {
|
|
638
|
+
if (err)
|
|
639
|
+
reject(err);
|
|
640
|
+
else
|
|
641
|
+
resolve(data);
|
|
642
|
+
});
|
|
643
|
+
});
|
|
644
|
+
if (policyResult.Policy) {
|
|
645
|
+
policy =
|
|
646
|
+
typeof policyResult.Policy === 'string'
|
|
647
|
+
? JSON.parse(policyResult.Policy)
|
|
648
|
+
: policyResult.Policy;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
catch (err) {
|
|
652
|
+
const e = err;
|
|
653
|
+
if (e.statusCode !== 404 && e.statusCode !== 403 && e.code !== 'NoSuchBucketPolicy') {
|
|
654
|
+
throw err;
|
|
655
|
+
}
|
|
486
656
|
}
|
|
487
657
|
return {
|
|
488
658
|
Name: bucketName,
|
|
489
659
|
Location: region,
|
|
660
|
+
CreationDate: creationDate,
|
|
490
661
|
ACL: acl,
|
|
491
662
|
WebsiteConfiguration: websiteConfig,
|
|
492
663
|
AccessControlPolicy: accessControlPolicy,
|
|
493
664
|
CorsConfiguration: corsConfiguration,
|
|
494
665
|
VersioningConfiguration: versioningConfig,
|
|
495
666
|
TaggingConfiguration: taggingConfig,
|
|
667
|
+
Tags: taggingConfig?.tags?.map((t) => ({ Key: t.key ?? '', Value: t.value ?? '' })),
|
|
668
|
+
LifecycleConfiguration: lifecycleConfiguration,
|
|
669
|
+
LoggingConfiguration: loggingConfiguration,
|
|
670
|
+
ReplicationConfiguration: replicationConfiguration,
|
|
671
|
+
SseConfiguration: sseConfiguration,
|
|
672
|
+
Policy: policy,
|
|
496
673
|
};
|
|
497
674
|
}
|
|
498
675
|
catch (error) {
|
|
@@ -4,46 +4,86 @@ exports.createTencentEsOperations = void 0;
|
|
|
4
4
|
const types_1 = require("./types");
|
|
5
5
|
const logger_1 = require("../logger");
|
|
6
6
|
const lang_1 = require("../../lang");
|
|
7
|
+
const polling_1 = require("../polling");
|
|
7
8
|
const waitForSpaceReady = async (getSpace, spaceId) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
try {
|
|
10
|
+
await (0, polling_1.pollUntil)({
|
|
11
|
+
description: `Tencent ES space ${spaceId} to be ready`,
|
|
12
|
+
fetch: async () => {
|
|
13
|
+
const space = await getSpace(spaceId);
|
|
14
|
+
if (!space) {
|
|
15
|
+
throw new Error(lang_1.lang.__('TENCENT_ES_SPACE_NOT_FOUND', { spaceId }));
|
|
16
|
+
}
|
|
17
|
+
if (space.Status === types_1.TencentEsSpaceStatus.DELETED ||
|
|
18
|
+
space.Status === types_1.TencentEsSpaceStatus.DELETING) {
|
|
19
|
+
throw new Error(lang_1.lang.__('TENCENT_ES_SPACE_ERROR_STATE', { status: String(space.Status) }));
|
|
20
|
+
}
|
|
21
|
+
return space;
|
|
22
|
+
},
|
|
23
|
+
isDone: (space) => space?.Status === types_1.TencentEsSpaceStatus.NORMAL,
|
|
24
|
+
intervalMs: 10000,
|
|
25
|
+
maxAttempts: 60,
|
|
26
|
+
onProgress: (space) => {
|
|
27
|
+
if (space) {
|
|
28
|
+
logger_1.logger.info(lang_1.lang.__('TENCENT_ES_SPACE_WAITING', { spaceId, status: String(space.Status) }));
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
logger_1.logger.info(lang_1.lang.__('TENCENT_ES_SPACE_READY', { spaceId }));
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
if (e instanceof polling_1.PollingTimeoutError) {
|
|
36
|
+
throw new Error(lang_1.lang.__('TENCENT_ES_SPACE_TIMEOUT_READY', { spaceId }), { cause: e });
|
|
22
37
|
}
|
|
23
|
-
|
|
24
|
-
await new Promise((resolve) => setTimeout(resolve, 10000));
|
|
25
|
-
attempts++;
|
|
38
|
+
throw e;
|
|
26
39
|
}
|
|
27
|
-
throw new Error(lang_1.lang.__('TENCENT_ES_SPACE_TIMEOUT_READY', { spaceId }));
|
|
28
40
|
};
|
|
41
|
+
// Maps a DescribeServerlessSpaces entry (SDK ServerlessSpace) to the internal
|
|
42
|
+
// space info. The ES SDK reports tags as TagList of { TagKey, TagValue } while
|
|
43
|
+
// the ownership check (isOwnedByStack) consumes { Key, Value } — normalized here
|
|
44
|
+
// at the boundary so callers never see the provider shape.
|
|
45
|
+
const toSpaceInfo = (space) => ({
|
|
46
|
+
SpaceId: space.SpaceId || '',
|
|
47
|
+
SpaceName: space.SpaceName || '',
|
|
48
|
+
Status: space.Status ?? types_1.TencentEsSpaceStatus.CREATING,
|
|
49
|
+
CreateTime: space.CreateTime,
|
|
50
|
+
IndexCount: space.IndexCount,
|
|
51
|
+
KibanaUrl: space.KibanaUrl,
|
|
52
|
+
KibanaPrivateUrl: space.KibanaPrivateUrl,
|
|
53
|
+
IndexAccessUrl: space.IndexAccessUrl,
|
|
54
|
+
KibanaPublicAcl: space.KibanaPublicAcl,
|
|
55
|
+
KibanaEmbedUrl: space.KibanaEmbedUrl,
|
|
56
|
+
DiDataList: space.DiDataList,
|
|
57
|
+
VpcInfo: space.VpcInfo,
|
|
58
|
+
Region: space.Region,
|
|
59
|
+
Zone: space.Zone,
|
|
60
|
+
EnableKibanaPublicAccess: space.EnableKibanaPublicAccess,
|
|
61
|
+
EnableKibanaPrivateAccess: space.EnableKibanaPrivateAccess,
|
|
62
|
+
AppId: space.AppId,
|
|
63
|
+
KibanaLanguage: space.KibanaLanguage,
|
|
64
|
+
ClusterType: space.ClusterType,
|
|
65
|
+
EnableMcpAccess: space.EnableMcpAccess,
|
|
66
|
+
McpAccess: space.McpAccess,
|
|
67
|
+
Tags: (space.TagList ?? []).map((t) => ({ Key: t.TagKey, Value: t.TagValue })),
|
|
68
|
+
});
|
|
29
69
|
const waitForSpaceDeleted = async (getSpace, spaceId) => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
70
|
+
try {
|
|
71
|
+
await (0, polling_1.pollUntil)({
|
|
72
|
+
description: `Tencent ES space ${spaceId} to be deleted`,
|
|
73
|
+
fetch: () => getSpace(spaceId),
|
|
74
|
+
isDone: (space) => space === null || space?.Status === types_1.TencentEsSpaceStatus.DELETED,
|
|
75
|
+
intervalMs: 10000,
|
|
76
|
+
maxAttempts: 60,
|
|
77
|
+
onProgress: () => logger_1.logger.info(lang_1.lang.__('TENCENT_ES_SPACE_WAITING_DELETE', { spaceId })),
|
|
78
|
+
});
|
|
79
|
+
logger_1.logger.info(lang_1.lang.__('TENCENT_ES_SPACE_DELETED', { spaceId }));
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
if (e instanceof polling_1.PollingTimeoutError) {
|
|
83
|
+
throw new Error(lang_1.lang.__('TENCENT_ES_SPACE_TIMEOUT_DELETE', { spaceId }), { cause: e });
|
|
41
84
|
}
|
|
42
|
-
|
|
43
|
-
await new Promise((resolve) => setTimeout(resolve, 10000));
|
|
44
|
-
attempts++;
|
|
85
|
+
throw e;
|
|
45
86
|
}
|
|
46
|
-
throw new Error(lang_1.lang.__('TENCENT_ES_SPACE_TIMEOUT_DELETE', { spaceId }));
|
|
47
87
|
};
|
|
48
88
|
const createTencentEsOperations = (esClient, _context) => {
|
|
49
89
|
const operations = {
|
|
@@ -60,6 +100,9 @@ const createTencentEsOperations = (esClient, _context) => {
|
|
|
60
100
|
if (config.KibanaWhiteIpList && config.KibanaWhiteIpList.length > 0) {
|
|
61
101
|
params.KibanaWhiteIpList = config.KibanaWhiteIpList;
|
|
62
102
|
}
|
|
103
|
+
if (config.Tags && config.Tags.length > 0) {
|
|
104
|
+
params.TagList = config.Tags.map((t) => ({ TagKey: t.Key, TagValue: t.Value }));
|
|
105
|
+
}
|
|
63
106
|
try {
|
|
64
107
|
const response = await esClient.CreateServerlessSpaceV2(params);
|
|
65
108
|
logger_1.logger.info(lang_1.lang.__('TENCENT_ES_SPACE_CREATION_INITIATED'));
|
|
@@ -81,23 +124,44 @@ const createTencentEsOperations = (esClient, _context) => {
|
|
|
81
124
|
};
|
|
82
125
|
try {
|
|
83
126
|
const response = await esClient.DescribeServerlessSpaces(params);
|
|
84
|
-
|
|
127
|
+
const space = response.ServerlessSpaces?.[0];
|
|
128
|
+
return space ? toSpaceInfo(space) : null;
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
if (error &&
|
|
132
|
+
typeof error === 'object' &&
|
|
133
|
+
'code' in error &&
|
|
134
|
+
typeof error.code === 'string' &&
|
|
135
|
+
(error.code.startsWith('ResourceNotFound') ||
|
|
136
|
+
error.code === 'InvalidParameterValue' ||
|
|
137
|
+
error.code === 'ResourceNotFound.ServerlessSpaceNotFound')) {
|
|
85
138
|
return null;
|
|
86
139
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
getSpaceByName: async (spaceName) => {
|
|
144
|
+
const params = {
|
|
145
|
+
SpaceNames: [spaceName],
|
|
146
|
+
};
|
|
147
|
+
try {
|
|
148
|
+
const response = await esClient.DescribeServerlessSpaces(params);
|
|
149
|
+
const space = (response.ServerlessSpaces ?? []).find((s) => {
|
|
150
|
+
return s.SpaceName === spaceName;
|
|
151
|
+
});
|
|
152
|
+
return space ? toSpaceInfo(space) : null;
|
|
97
153
|
}
|
|
98
154
|
catch (error) {
|
|
99
|
-
|
|
100
|
-
|
|
155
|
+
if (error &&
|
|
156
|
+
typeof error === 'object' &&
|
|
157
|
+
'code' in error &&
|
|
158
|
+
typeof error.code === 'string' &&
|
|
159
|
+
(error.code.startsWith('ResourceNotFound') ||
|
|
160
|
+
error.code === 'InvalidParameterValue' ||
|
|
161
|
+
error.code === 'ResourceNotFound.ServerlessSpaceNotFound')) {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
throw error;
|
|
101
165
|
}
|
|
102
166
|
},
|
|
103
167
|
updateSpace: async (spaceId, config) => {
|
|
@@ -39,12 +39,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.createTencentClient = void 0;
|
|
42
|
+
exports.createTencentClient = exports.createClsOperations = void 0;
|
|
43
43
|
const tencentcloud = __importStar(require("tencentcloud-sdk-nodejs-scf"));
|
|
44
44
|
const cynosdb = __importStar(require("tencentcloud-sdk-nodejs-cynosdb"));
|
|
45
45
|
const tencentCam = __importStar(require("tencentcloud-sdk-nodejs-cam"));
|
|
46
46
|
const tencentEs = __importStar(require("tencentcloud-sdk-nodejs-es"));
|
|
47
47
|
const tencentSsl = __importStar(require("tencentcloud-sdk-nodejs-ssl"));
|
|
48
|
+
const tencentTag = __importStar(require("tencentcloud-sdk-nodejs-tag"));
|
|
49
|
+
const tencentCls = __importStar(require("tencentcloud-sdk-nodejs-cls"));
|
|
48
50
|
const cos_nodejs_sdk_v5_1 = __importDefault(require("cos-nodejs-sdk-v5"));
|
|
49
51
|
const scfOperations_1 = require("./scfOperations");
|
|
50
52
|
const cosOperations_1 = require("./cosOperations");
|
|
@@ -53,12 +55,17 @@ const tdsqlcOperations_1 = require("./tdsqlcOperations");
|
|
|
53
55
|
const esOperations_1 = require("./esOperations");
|
|
54
56
|
const dnspodOperations_1 = require("./dnspodOperations");
|
|
55
57
|
const sslOperations_1 = require("./sslOperations");
|
|
58
|
+
const clsOperations_1 = require("./clsOperations");
|
|
56
59
|
__exportStar(require("./types"), exports);
|
|
60
|
+
var clsOperations_2 = require("./clsOperations");
|
|
61
|
+
Object.defineProperty(exports, "createClsOperations", { enumerable: true, get: function () { return clsOperations_2.createClsOperations; } });
|
|
57
62
|
const ScfClient = tencentcloud.scf.v20180416.Client;
|
|
58
63
|
const CynosdbClient = cynosdb.cynosdb.v20190107.Client;
|
|
59
64
|
const CamClient = tencentCam.cam.v20190116.Client;
|
|
60
65
|
const EsClient = tencentEs.es.v20180416.Client;
|
|
61
66
|
const SslClient = tencentSsl.ssl.v20191205.Client;
|
|
67
|
+
const TagClient = tencentTag.tag.v20180813.Client;
|
|
68
|
+
const ClsClient = tencentCls.cls.v20201016.Client;
|
|
62
69
|
// Initialize SDK clients (internal)
|
|
63
70
|
const initializeSdkClients = (context) => {
|
|
64
71
|
const scfClientConfig = {
|
|
@@ -130,6 +137,32 @@ const initializeSdkClients = (context) => {
|
|
|
130
137
|
},
|
|
131
138
|
};
|
|
132
139
|
const camClient = new CamClient(camClientConfig);
|
|
140
|
+
const tagClientConfig = {
|
|
141
|
+
credential: {
|
|
142
|
+
secretId: context.accessKeyId,
|
|
143
|
+
secretKey: context.accessKeySecret,
|
|
144
|
+
},
|
|
145
|
+
region: context.region,
|
|
146
|
+
profile: {
|
|
147
|
+
httpProfile: {
|
|
148
|
+
endpoint: 'tag.tencentcloudapi.com',
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
const tagClient = new TagClient(tagClientConfig);
|
|
153
|
+
const clsClientConfig = {
|
|
154
|
+
credential: {
|
|
155
|
+
secretId: context.accessKeyId,
|
|
156
|
+
secretKey: context.accessKeySecret,
|
|
157
|
+
},
|
|
158
|
+
region: context.region,
|
|
159
|
+
profile: {
|
|
160
|
+
httpProfile: {
|
|
161
|
+
endpoint: 'cls.tencentcloudapi.com',
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
const clsClient = new ClsClient(clsClientConfig);
|
|
133
166
|
return {
|
|
134
167
|
scf: scfClient,
|
|
135
168
|
cos: cosClient,
|
|
@@ -138,18 +171,26 @@ const initializeSdkClients = (context) => {
|
|
|
138
171
|
ssl: sslClient,
|
|
139
172
|
dns: (0, dnspodOperations_1.createDnsClient)(context),
|
|
140
173
|
cam: camClient,
|
|
174
|
+
tag: tagClient,
|
|
175
|
+
cls: clsClient,
|
|
141
176
|
};
|
|
142
177
|
};
|
|
143
178
|
const createTencentClient = (context) => {
|
|
144
179
|
const sdkClients = initializeSdkClients(context);
|
|
145
180
|
const dnsOps = (0, dnspodOperations_1.createDnsOperations)(sdkClients.dns);
|
|
146
181
|
return {
|
|
147
|
-
scf: (0, scfOperations_1.createScfOperations)(sdkClients.scf
|
|
182
|
+
scf: (0, scfOperations_1.createScfOperations)(sdkClients.scf, {
|
|
183
|
+
tag: sdkClients.tag,
|
|
184
|
+
cam: sdkClients.cam,
|
|
185
|
+
region: context.region,
|
|
186
|
+
namespace: context.parameters?.find((p) => p.key === 'namespace')?.value ?? 'default',
|
|
187
|
+
}),
|
|
148
188
|
cos: (0, cosOperations_1.createCosOperations)(sdkClients.cos, context.region, dnsOps),
|
|
149
189
|
cam: (0, camOperations_1.createCamOperations)(sdkClients.cam),
|
|
150
190
|
tdsqlc: (0, tdsqlcOperations_1.createTdsqlcOperations)(sdkClients.cynosdb, context),
|
|
151
191
|
es: (0, esOperations_1.createTencentEsOperations)(sdkClients.es, context),
|
|
152
192
|
ssl: (0, sslOperations_1.createSslOperations)(sdkClients.ssl),
|
|
193
|
+
cls: (0, clsOperations_1.createClsOperations)(sdkClients.cls),
|
|
153
194
|
dns: dnsOps,
|
|
154
195
|
};
|
|
155
196
|
};
|