@geek-fun/serverlessinsight 0.9.1 → 0.9.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 +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 +132 -0
- 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 +51 -0
- package/README.md +103 -13
- package/README.zh-CN.md +73 -13
- package/codecov +0 -0
- package/codecov.SHA256SUM +1 -0
- package/codecov.SHA256SUM.sig +16 -0
- package/dist/package.json +1 -1
- package/dist/src/commands/index.js +92 -24
- package/dist/src/commands/local.js +16 -3
- package/dist/src/commands/plan.js +31 -4
- package/dist/src/commands/schema.js +24 -0
- package/dist/src/commands/show.js +64 -10
- package/dist/src/commands/validate.js +34 -2
- package/dist/src/common/aliyunClient/apigwOperations.js +17 -1
- package/dist/src/common/aliyunClient/fc3Operations.js +39 -2
- package/dist/src/common/aliyunClient/ossOperations.js +214 -221
- package/dist/src/common/bucketPolicy.js +63 -0
- package/dist/src/common/constants.js +7 -1
- 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 +82 -0
- package/dist/src/common/logger.js +6 -3
- package/dist/src/common/nameBuilder.js +3 -1
- package/dist/src/common/noColor.js +9 -0
- package/dist/src/common/planCapabilities.js +119 -0
- package/dist/src/common/planCompare.js +119 -66
- package/dist/src/common/planFormatter.js +34 -20
- package/dist/src/common/planRedaction.js +26 -0
- package/dist/src/common/refreshPlanner.js +66 -21
- package/dist/src/common/siCron.js +415 -0
- package/dist/src/common/stateBackend/saasStateBackend.js +5 -4
- package/dist/src/common/tencentClient/cosOperations.js +326 -322
- package/dist/src/common/tencentClient/scfOperations.js +11 -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/common/volcengineClient/vefaasOperations.js +45 -0
- package/dist/src/lang/en.js +70 -3
- package/dist/src/lang/index.js +36 -1
- package/dist/src/lang/zh-CN.js +70 -3
- package/dist/src/parser/eventParser.js +1 -0
- package/dist/src/parser/functionParser.js +48 -2
- package/dist/src/stack/aliyunStack/apigwExecutor.js +1 -1
- package/dist/src/stack/aliyunStack/apigwPlanner.js +103 -23
- package/dist/src/stack/aliyunStack/apigwResource.js +4 -3
- 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 +148 -153
- package/dist/src/stack/aliyunStack/fc3Resource.js +206 -53
- 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 -71
- package/dist/src/stack/localStack/function.js +25 -77
- 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/index.js +8 -1
- 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 +183 -0
- package/dist/src/stack/localStack/utils.js +19 -1
- 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 +114 -29
- package/dist/src/stack/scfStack/scfResource.js +329 -311
- 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 +186 -44
- package/dist/src/stack/volcengineStack/vefaasResource.js +232 -14
- package/dist/src/stack/volcengineStack/vefaasTypes.js +6 -3
- package/dist/src/validator/functionSchema.js +25 -2
- package/dist/src/validator/iacSchema.js +2 -1
- package/dist/src/validator/index.js +4 -1
- package/dist/src/validator/rootSchema.js +49 -18
- package/dist/src/validator/schemaExport.js +60 -0
- package/dist/src/validator/semanticValidation.js +79 -0
- package/dist/src/validator/templateRefSchema.js +9 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/release-notes.md +79 -0
- package/samples/aliyun-poc-timer.yml +39 -0
- 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
|
@@ -4,6 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.deleteBucketResource = exports.updateBucketResource = exports.readBucketResource = exports.createBucketResource = void 0;
|
|
7
|
+
const domainUtils_1 = require("../../common/domainUtils");
|
|
8
|
+
const planCompare_1 = require("../../common/planCompare");
|
|
9
|
+
const bucketPolicy_1 = require("../../common/bucketPolicy");
|
|
10
|
+
const functionDefinition_1 = require("../../common/functionDefinition");
|
|
7
11
|
const aliyunClient_1 = require("../../common/aliyunClient");
|
|
8
12
|
const common_1 = require("../../common");
|
|
9
13
|
const certUtils_1 = require("../../common/certUtils");
|
|
@@ -14,7 +18,7 @@ const alreadyExists_1 = require("../alreadyExists");
|
|
|
14
18
|
const logger_1 = require("../../common/logger");
|
|
15
19
|
const lang_1 = require("../../lang");
|
|
16
20
|
const node_path_1 = __importDefault(require("node:path"));
|
|
17
|
-
const
|
|
21
|
+
const domainUtils_2 = require("../../common/domainUtils");
|
|
18
22
|
// getBucket returns tags as { key, value } (BucketTag); the ownership helper
|
|
19
23
|
// expects { Key, Value }. Convert before verification.
|
|
20
24
|
const toOwnershipTags = (tags) => tags?.map((tag) => ({ Key: tag.key, Value: tag.value }));
|
|
@@ -136,43 +140,28 @@ const getIsCdnEnabled = (bucket) => {
|
|
|
136
140
|
const getIsAccelerateEnabled = (bucket) => {
|
|
137
141
|
return bucket.domain?.accelerate === true;
|
|
138
142
|
};
|
|
139
|
-
const buildOssBucketPolicyJson = (iam) =>
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const s = {
|
|
146
|
-
Effect: stmt.effect,
|
|
147
|
-
Principal: stmt.principal,
|
|
148
|
-
Action: stmt.action,
|
|
149
|
-
Resource: stmt.resource,
|
|
150
|
-
};
|
|
151
|
-
if (stmt.condition) {
|
|
152
|
-
s.Condition = stmt.condition;
|
|
153
|
-
}
|
|
154
|
-
return s;
|
|
155
|
-
}),
|
|
156
|
-
};
|
|
157
|
-
};
|
|
143
|
+
const buildOssBucketPolicyJson = (iam) => (0, bucketPolicy_1.buildBucketPolicy)(iam, 'aliyun');
|
|
144
|
+
const buildOssPolicyInstance = (context, bucketName) => ({
|
|
145
|
+
sid: (0, common_1.buildSid)('aliyun', 'oss-policy', context.stage, bucketName),
|
|
146
|
+
type: ossTypes_1.OSS_BUCKET_POLICY_INSTANCE_TYPE,
|
|
147
|
+
id: bucketName,
|
|
148
|
+
});
|
|
158
149
|
const applyBucketPolicy = async (client, bucket) => {
|
|
159
150
|
if (!bucket.iam)
|
|
160
151
|
return;
|
|
161
152
|
const policy = buildOssBucketPolicyJson(bucket.iam);
|
|
162
|
-
if (!policy)
|
|
153
|
+
if (!policy) {
|
|
154
|
+
if (bucket.iam.resource.statements.length === 0)
|
|
155
|
+
await deleteBucketPolicy(client, bucket.name);
|
|
163
156
|
return;
|
|
157
|
+
}
|
|
164
158
|
logger_1.logger.info(lang_1.lang.__('BUCKET_POLICY_APPLYING', { bucketName: bucket.name }));
|
|
165
159
|
await client.oss.putBucketPolicy(bucket.name, policy);
|
|
166
160
|
logger_1.logger.info(lang_1.lang.__('BUCKET_POLICY_APPLIED', { bucketName: bucket.name }));
|
|
167
161
|
};
|
|
168
162
|
const deleteBucketPolicy = async (client, bucketName) => {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
logger_1.logger.info(lang_1.lang.__('BUCKET_POLICY_DELETED', { bucketName }));
|
|
172
|
-
}
|
|
173
|
-
catch {
|
|
174
|
-
// Best effort cleanup
|
|
175
|
-
}
|
|
163
|
+
await client.oss.deleteBucketPolicy(bucketName);
|
|
164
|
+
logger_1.logger.info(lang_1.lang.__('BUCKET_POLICY_DELETED', { bucketName }));
|
|
176
165
|
};
|
|
177
166
|
const getDomainName = (bucket) => {
|
|
178
167
|
return bucket.domain?.domain_name || bucket.website?.domain;
|
|
@@ -289,8 +278,8 @@ const createBucketResource = async (context, bucket, state) => {
|
|
|
289
278
|
const certificate = await resolveBucketDomainCertificate(bucket, client);
|
|
290
279
|
const primaryDomain = domainName;
|
|
291
280
|
const wwwBindApex = bucket.domain?.www_bind_apex ?? bucket.website?.www_bind_apex ?? false;
|
|
292
|
-
const mainDomain = (0,
|
|
293
|
-
const hostRecord = (0,
|
|
281
|
+
const mainDomain = (0, domainUtils_2.extractMainDomain)(primaryDomain);
|
|
282
|
+
const hostRecord = (0, domainUtils_2.extractHostRecord)(primaryDomain, mainDomain);
|
|
294
283
|
logger_1.logger.info(lang_1.lang.__('BINDING_CUSTOM_DOMAIN_TO_BUCKET', {
|
|
295
284
|
domain: primaryDomain,
|
|
296
285
|
bucketName: config.bucketName,
|
|
@@ -416,7 +405,7 @@ const createBucketResource = async (context, bucket, state) => {
|
|
|
416
405
|
instances.push(dnsInstance);
|
|
417
406
|
}
|
|
418
407
|
}
|
|
419
|
-
const wwwDomain = wwwBindApex ? (0,
|
|
408
|
+
const wwwDomain = wwwBindApex ? (0, domainUtils_2.deriveWwwDomain)(primaryDomain) : null;
|
|
420
409
|
if (wwwDomain) {
|
|
421
410
|
logger_1.logger.info(lang_1.lang.__('BINDING_CUSTOM_DOMAIN_TO_BUCKET', {
|
|
422
411
|
domain: wwwDomain,
|
|
@@ -455,8 +444,8 @@ const createBucketResource = async (context, bucket, state) => {
|
|
|
455
444
|
});
|
|
456
445
|
}
|
|
457
446
|
if (wwwCdnInfo?.cname) {
|
|
458
|
-
const wwwMainDomain = (0,
|
|
459
|
-
const wwwHostRecord = (0,
|
|
447
|
+
const wwwMainDomain = (0, domainUtils_2.extractMainDomain)(wwwDomain);
|
|
448
|
+
const wwwHostRecord = (0, domainUtils_2.extractHostRecord)(wwwDomain, wwwMainDomain);
|
|
460
449
|
const wwwDnsRecordId = await client.dns.addDomainRecord({
|
|
461
450
|
domainName: wwwMainDomain,
|
|
462
451
|
rr: wwwHostRecord,
|
|
@@ -518,6 +507,9 @@ const createBucketResource = async (context, bucket, state) => {
|
|
|
518
507
|
}
|
|
519
508
|
// Apply IAM bucket policy if configured
|
|
520
509
|
await applyBucketPolicy(client, bucket);
|
|
510
|
+
if (buildOssBucketPolicyJson(bucket.iam)) {
|
|
511
|
+
instances.push(buildOssPolicyInstance(context, bucket.name));
|
|
512
|
+
}
|
|
521
513
|
}
|
|
522
514
|
catch (error) {
|
|
523
515
|
// Refusal/adoption errors already carry the tainted state — rethrow as-is
|
|
@@ -571,18 +563,24 @@ const updateBucketResource = async (context, bucket, state) => {
|
|
|
571
563
|
: undefined;
|
|
572
564
|
const existingState = state.resources[logicalId];
|
|
573
565
|
const domName = getDomainName(bucket);
|
|
574
|
-
const isCdnEnabled =
|
|
575
|
-
const isAccelerateEnabled =
|
|
566
|
+
const isCdnEnabled = config.cdnEnabled ?? existingState?.definition.cdnEnabled === true;
|
|
567
|
+
const isAccelerateEnabled = config.accelerateEnabled ?? existingState?.definition.accelerateEnabled === true;
|
|
576
568
|
const existingCdnInstances = existingState?.instances?.filter((i) => i.type === types_1.ResourceTypeEnum.ALIYUN_CDN_DISTRIBUTION);
|
|
577
569
|
const existingDnsInstances = existingState?.instances?.filter((i) => i.type === types_1.ResourceTypeEnum.ALIYUN_OSS_DNS_CNAME ||
|
|
578
570
|
i.type === types_1.ResourceTypeEnum.ALIYUN_CDN_DNS_CNAME);
|
|
579
571
|
const existingPrimaryDnsInstance = existingDnsInstances?.find((i) => !i.isWwwVariant);
|
|
580
|
-
const existingWwwDnsInstance = existingDnsInstances?.find((i) => i.isWwwVariant
|
|
572
|
+
const existingWwwDnsInstance = existingDnsInstances?.find((i) => i.isWwwVariant ||
|
|
573
|
+
i.domain === (0, domainUtils_2.deriveWwwDomain)(existingPrimaryDnsInstance?.domain ?? ''));
|
|
581
574
|
let cnameInfo;
|
|
582
|
-
|
|
575
|
+
const desiredDomainFields = Object.fromEntries(Object.entries((0, ossTypes_1.extractOssBucketDefinition)(config)).filter(([key]) => /^(domain|www|cdn|accelerate)/.test(key)));
|
|
576
|
+
const domainConfigChanged = (0, planCompare_1.definitionsDiffer)(existingState?.definition ?? {}, desiredDomainFields);
|
|
577
|
+
if (domName &&
|
|
578
|
+
(domainConfigChanged ||
|
|
579
|
+
!existingPrimaryDnsInstance ||
|
|
580
|
+
existingState?.definition.domainBound === false)) {
|
|
583
581
|
const primaryDomain = domName;
|
|
584
|
-
const wwwBindApex = bucket.domain?.www_bind_apex ?? bucket.website?.www_bind_apex ?? false;
|
|
585
582
|
const domainChanged = existingPrimaryDnsInstance?.domain !== primaryDomain;
|
|
583
|
+
const wwwAction = (0, domainUtils_1.resolveWwwBindingAction)(config.wwwBindApex);
|
|
586
584
|
if (domainChanged) {
|
|
587
585
|
// For CDN/accelerate buckets, don't delete old resources since we can't recreate them in update.
|
|
588
586
|
// The user must destroy+recreate to change the CDN domain.
|
|
@@ -649,7 +647,16 @@ const updateBucketResource = async (context, bucket, state) => {
|
|
|
649
647
|
bucketName: config.bucketName,
|
|
650
648
|
}));
|
|
651
649
|
}
|
|
652
|
-
const cdnConfig =
|
|
650
|
+
const cdnConfig = {
|
|
651
|
+
cdn_type: 'web',
|
|
652
|
+
scope: 'global',
|
|
653
|
+
cache_ttl: oldCacheTtl,
|
|
654
|
+
ignore_query_string: oldIgnoreQS,
|
|
655
|
+
origin_protocol: oldOriginProto,
|
|
656
|
+
compression: oldCompression,
|
|
657
|
+
force_redirect_https: oldHttpsRedirect,
|
|
658
|
+
...(typeof bucket.domain?.cdn === 'object' ? bucket.domain.cdn : {}),
|
|
659
|
+
};
|
|
653
660
|
const resolvedCdnType = cdnConfig?.cdn_type ?? 'web';
|
|
654
661
|
const resolvedScope = cdnConfig?.scope ?? 'global';
|
|
655
662
|
if (isCdnEnabled) {
|
|
@@ -685,22 +692,25 @@ const updateBucketResource = async (context, bucket, state) => {
|
|
|
685
692
|
}
|
|
686
693
|
const existingCdnDnsInstances = existingState?.instances?.filter((i) => i.type === types_1.ResourceTypeEnum.ALIYUN_CDN_DISTRIBUTION ||
|
|
687
694
|
i.type === types_1.ResourceTypeEnum.ALIYUN_CDN_DNS_CNAME);
|
|
688
|
-
const
|
|
689
|
-
|
|
690
|
-
|
|
695
|
+
const wwwDomainName = (0, domainUtils_2.deriveWwwDomain)(primaryDomain);
|
|
696
|
+
const removedInstances = wwwAction === 'remove'
|
|
697
|
+
? (existingCdnDnsInstances ?? []).filter((instance) => instance.isWwwVariant === true ||
|
|
698
|
+
(wwwDomainName !== null &&
|
|
699
|
+
(instance.domain === wwwDomainName || instance.domainName === wwwDomainName)))
|
|
700
|
+
: [];
|
|
701
|
+
await Promise.all(removedInstances.map(async (instance) => {
|
|
702
|
+
if (instance.type === types_1.ResourceTypeEnum.ALIYUN_CDN_DISTRIBUTION) {
|
|
703
|
+
await client.cdn.deleteCdnDomain(instance.domainName);
|
|
704
|
+
}
|
|
705
|
+
else if (instance.dnsRecordId) {
|
|
706
|
+
await client.dns.deleteDomainRecord(instance.dnsRecordId);
|
|
707
|
+
}
|
|
708
|
+
}));
|
|
709
|
+
const removedIds = new Set(removedInstances.map((instance) => instance.sid));
|
|
710
|
+
const filteredInstances = (existingCdnDnsInstances ?? []).filter((instance) => !removedIds.has(instance.sid));
|
|
691
711
|
if (filteredInstances.length > 0) {
|
|
692
712
|
instances.push(...filteredInstances);
|
|
693
713
|
}
|
|
694
|
-
return (0, common_1.setResource)(state, logicalId, {
|
|
695
|
-
mode: 'managed',
|
|
696
|
-
region: context.region,
|
|
697
|
-
definition: {
|
|
698
|
-
...(0, ossTypes_1.extractOssBucketDefinition)(config, websiteCodeHash),
|
|
699
|
-
...(domName != null ? { domainBound: cnameInfo?.bucketCnameBound ?? null } : {}),
|
|
700
|
-
},
|
|
701
|
-
instances,
|
|
702
|
-
lastUpdated: new Date().toISOString(),
|
|
703
|
-
});
|
|
704
714
|
}
|
|
705
715
|
else {
|
|
706
716
|
cnameInfo = await client.oss.bindCustomDomain(config.bucketName, primaryDomain, certificate);
|
|
@@ -718,71 +728,72 @@ const updateBucketResource = async (context, bucket, state) => {
|
|
|
718
728
|
instances.push(dnsInstance);
|
|
719
729
|
}
|
|
720
730
|
}
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
bucketName: config.bucketName,
|
|
726
|
-
}));
|
|
727
|
-
const wwwCnameInfo = await client.oss.bindCustomDomain(config.bucketName, wwwDomain, certificate);
|
|
728
|
-
if (wwwCnameInfo) {
|
|
729
|
-
const wwwInstanceId = wwwCnameInfo.dnsRecordId ?? wwwDomain;
|
|
730
|
-
const wwwDnsInstance = {
|
|
731
|
-
sid: (0, common_1.buildSid)('aliyun', 'alidns', context.stage, wwwInstanceId),
|
|
732
|
-
id: wwwInstanceId,
|
|
733
|
-
type: types_1.ResourceTypeEnum.ALIYUN_OSS_DNS_CNAME,
|
|
731
|
+
if (!isCdnEnabled && !isAccelerateEnabled) {
|
|
732
|
+
const wwwDomain = wwwAction === 'ensure' ? (0, domainUtils_2.deriveWwwDomain)(primaryDomain) : null;
|
|
733
|
+
if (wwwDomain) {
|
|
734
|
+
logger_1.logger.info(lang_1.lang.__('BINDING_CUSTOM_DOMAIN_TO_BUCKET', {
|
|
734
735
|
domain: wwwDomain,
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
736
|
+
bucketName: config.bucketName,
|
|
737
|
+
}));
|
|
738
|
+
const wwwCnameInfo = await client.oss.bindCustomDomain(config.bucketName, wwwDomain, certificate);
|
|
739
|
+
if (wwwCnameInfo) {
|
|
740
|
+
const wwwInstanceId = wwwCnameInfo.dnsRecordId ?? wwwDomain;
|
|
741
|
+
const wwwDnsInstance = {
|
|
742
|
+
sid: (0, common_1.buildSid)('aliyun', 'alidns', context.stage, wwwInstanceId),
|
|
743
|
+
id: wwwInstanceId,
|
|
744
|
+
type: types_1.ResourceTypeEnum.ALIYUN_OSS_DNS_CNAME,
|
|
745
|
+
domain: wwwDomain,
|
|
746
|
+
cname: wwwCnameInfo.cname,
|
|
747
|
+
isWwwVariant: true,
|
|
748
|
+
...(wwwCnameInfo.dnsRecordId ? { dnsRecordId: wwwCnameInfo.dnsRecordId } : {}),
|
|
749
|
+
...(wwwCnameInfo.txtRecordId ? { txtRecordId: wwwCnameInfo.txtRecordId } : {}),
|
|
750
|
+
};
|
|
751
|
+
instances.push(wwwDnsInstance);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
else if (existingWwwDnsInstance && !domainChanged && wwwAction === 'remove') {
|
|
755
|
+
const wwwInstance = existingWwwDnsInstance;
|
|
756
|
+
await client.oss.unbindCustomDomain(config.bucketName, wwwInstance.domain, wwwInstance.dnsRecordId, wwwInstance.txtRecordId);
|
|
741
757
|
}
|
|
742
|
-
}
|
|
743
|
-
else if (existingWwwDnsInstance && !wwwBindApex) {
|
|
744
|
-
const wwwInstance = existingWwwDnsInstance;
|
|
745
|
-
await client.oss.unbindCustomDomain(config.bucketName, wwwInstance.domain, wwwInstance.dnsRecordId, wwwInstance.txtRecordId);
|
|
746
758
|
}
|
|
747
759
|
const refreshedInfo = await client.oss.getBucket(config.bucketName);
|
|
748
760
|
if (refreshedInfo) {
|
|
749
761
|
instances[0] = buildOssInstanceFromProvider(refreshedInfo, sid);
|
|
750
762
|
}
|
|
751
763
|
}
|
|
752
|
-
else
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
await client.oss.unbindCustomDomain(config.bucketName, ossInstance.domain, ossInstance.dnsRecordId, ossInstance.txtRecordId);
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
// Apply IAM bucket policy if configured (update or remove)
|
|
759
|
-
const existingDef = existingState?.definition;
|
|
760
|
-
const oldPolicyJson = existingDef?.policy;
|
|
761
|
-
const newPolicyJson = bucket.iam ? JSON.stringify(bucket.iam) : null;
|
|
762
|
-
if (newPolicyJson !== (oldPolicyJson ?? null)) {
|
|
763
|
-
if (newPolicyJson) {
|
|
764
|
-
logger_1.logger.info(lang_1.lang.__('BUCKET_POLICY_APPLYING', { bucketName: config.bucketName }));
|
|
765
|
-
const policyObj = buildOssBucketPolicyJson(bucket.iam);
|
|
766
|
-
if (policyObj) {
|
|
767
|
-
await client.oss.putBucketPolicy(config.bucketName, policyObj);
|
|
768
|
-
logger_1.logger.info(lang_1.lang.__('BUCKET_POLICY_APPLIED', { bucketName: config.bucketName }));
|
|
769
|
-
}
|
|
770
|
-
else {
|
|
771
|
-
// iam exists but has no statements — delete any existing policy
|
|
772
|
-
await deleteBucketPolicy(client, config.bucketName);
|
|
773
|
-
}
|
|
764
|
+
else {
|
|
765
|
+
if (domName) {
|
|
766
|
+
instances.push(...(existingDnsInstances ?? []));
|
|
774
767
|
}
|
|
775
768
|
else {
|
|
776
|
-
|
|
769
|
+
for (const instance of existingDnsInstances ?? []) {
|
|
770
|
+
const ossInstance = instance;
|
|
771
|
+
await client.oss.unbindCustomDomain(config.bucketName, ossInstance.domain, ossInstance.dnsRecordId, ossInstance.txtRecordId);
|
|
772
|
+
}
|
|
777
773
|
}
|
|
774
|
+
instances.push(...(existingCdnInstances ?? []));
|
|
775
|
+
}
|
|
776
|
+
const policy = buildOssBucketPolicyJson(bucket.iam);
|
|
777
|
+
const policyOwned = (0, bucketPolicy_1.isOwnedBucketPolicy)(ossTypes_1.OSS_BUCKET_POLICY_INSTANCE_TYPE, existingState?.instances, existingState?.definition);
|
|
778
|
+
if (policy) {
|
|
779
|
+
await client.oss.putBucketPolicy(config.bucketName, policy);
|
|
780
|
+
instances.push(buildOssPolicyInstance(context, config.bucketName));
|
|
781
|
+
}
|
|
782
|
+
else if (policyOwned || bucket.iam?.resource?.statements !== undefined) {
|
|
783
|
+
await deleteBucketPolicy(client, config.bucketName);
|
|
778
784
|
}
|
|
785
|
+
const definitionIntent = {
|
|
786
|
+
...(0, ossTypes_1.extractOssBucketDefinition)(config, websiteCodeHash),
|
|
787
|
+
...(domName != null
|
|
788
|
+
? {
|
|
789
|
+
domainBound: cnameInfo?.bucketCnameBound ?? existingState?.definition.domainBound ?? null,
|
|
790
|
+
}
|
|
791
|
+
: {}),
|
|
792
|
+
};
|
|
779
793
|
const resourceState = {
|
|
780
794
|
mode: 'managed',
|
|
781
795
|
region: context.region,
|
|
782
|
-
definition: {
|
|
783
|
-
...(0, ossTypes_1.extractOssBucketDefinition)(config, websiteCodeHash),
|
|
784
|
-
...(domName != null ? { domainBound: cnameInfo?.bucketCnameBound ?? null } : {}),
|
|
785
|
-
},
|
|
796
|
+
definition: (0, functionDefinition_1.withLifecycleIntent)((0, planCompare_1.mergeManagedIntent)(existingState?.definition ?? {}, definitionIntent), definitionIntent, ['policy']),
|
|
786
797
|
instances,
|
|
787
798
|
lastUpdated: new Date().toISOString(),
|
|
788
799
|
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cloudOssToDefinition = exports.extractOssBucketDefinition = exports.bucketToOssBucketConfig = void 0;
|
|
3
|
+
exports.cloudOssToDefinition = exports.extractOssBucketDefinition = exports.bucketToOssBucketConfig = exports.OSS_BUCKET_POLICY_INSTANCE_TYPE = void 0;
|
|
4
|
+
const bucketPolicy_1 = require("../../common/bucketPolicy");
|
|
4
5
|
const types_1 = require("../../types");
|
|
5
6
|
const bucketTypes_1 = require("../bucketTypes");
|
|
7
|
+
exports.OSS_BUCKET_POLICY_INSTANCE_TYPE = 'ALIYUN_OSS_BUCKET_POLICY';
|
|
6
8
|
const aclMap = {
|
|
7
9
|
[types_1.BucketAccessEnum.PRIVATE]: bucketTypes_1.BucketACL.PRIVATE,
|
|
8
10
|
[types_1.BucketAccessEnum.PUBLIC_READ]: bucketTypes_1.BucketACL.PUBLIC_READ,
|
|
@@ -80,11 +82,6 @@ const bucketToOssBucketConfig = (bucket) => {
|
|
|
80
82
|
};
|
|
81
83
|
exports.bucketToOssBucketConfig = bucketToOssBucketConfig;
|
|
82
84
|
/* istanbul ignore next */
|
|
83
|
-
const serializeBucketPolicy = (iam) => {
|
|
84
|
-
if (!iam?.resource?.statements || iam.resource.statements.length === 0)
|
|
85
|
-
return null;
|
|
86
|
-
return JSON.stringify(iam);
|
|
87
|
-
};
|
|
88
85
|
const extractOssBucketDefinition = (config, websiteCodeHash) => {
|
|
89
86
|
const def = {
|
|
90
87
|
bucketName: config.bucketName,
|
|
@@ -98,7 +95,7 @@ const extractOssBucketDefinition = (config, websiteCodeHash) => {
|
|
|
98
95
|
websiteCodeHash: websiteCodeHash ?? null,
|
|
99
96
|
storageClass: config.storageClass ?? null,
|
|
100
97
|
domain: config.domain ?? null,
|
|
101
|
-
wwwBindApex: config.wwwBindApex ?? false,
|
|
98
|
+
wwwBindApex: config.domain ? (config.wwwBindApex ?? false) : null,
|
|
102
99
|
domainCertificateId: config.domainCertificateId ?? null,
|
|
103
100
|
domainCertificateBody: config.domainCertificateBody ?? null,
|
|
104
101
|
domainCertificatePrivateKey: config.domainCertificatePrivateKey ? '(managed)' : null,
|
|
@@ -106,15 +103,15 @@ const extractOssBucketDefinition = (config, websiteCodeHash) => {
|
|
|
106
103
|
versioningStatus: config.versioningStatus ?? null,
|
|
107
104
|
sseAlgorithm: config.sseAlgorithm ?? null,
|
|
108
105
|
sseKmsMasterKeyId: config.sseKmsMasterKeyId ?? null,
|
|
109
|
-
policy: serializeBucketPolicy(config.iam),
|
|
106
|
+
policy: (0, bucketPolicy_1.serializeBucketPolicy)(config.iam, 'aliyun'),
|
|
110
107
|
};
|
|
111
108
|
// Only include CDN/accelerate fields when they're actually enabled
|
|
112
|
-
if (config.cdnEnabled) {
|
|
113
|
-
def.cdnEnabled =
|
|
114
|
-
if (config.
|
|
115
|
-
def.cdnType = config.cdnType;
|
|
116
|
-
if (config.
|
|
117
|
-
def.cdnScope = config.cdnScope;
|
|
109
|
+
if (config.cdnEnabled !== undefined) {
|
|
110
|
+
def.cdnEnabled = config.cdnEnabled;
|
|
111
|
+
if (config.cdnEnabled)
|
|
112
|
+
def.cdnType = config.cdnType ?? 'web';
|
|
113
|
+
if (config.cdnEnabled)
|
|
114
|
+
def.cdnScope = config.cdnScope ?? 'global';
|
|
118
115
|
if (config.cdnCacheTtl != null)
|
|
119
116
|
def.cdnCacheTtl = config.cdnCacheTtl;
|
|
120
117
|
if (config.cdnIgnoreQueryString != null)
|
|
@@ -126,8 +123,8 @@ const extractOssBucketDefinition = (config, websiteCodeHash) => {
|
|
|
126
123
|
if (config.cdnForceRedirectHttps != null)
|
|
127
124
|
def.cdnForceRedirectHttps = config.cdnForceRedirectHttps;
|
|
128
125
|
}
|
|
129
|
-
if (config.accelerateEnabled) {
|
|
130
|
-
def.accelerateEnabled =
|
|
126
|
+
if (config.accelerateEnabled !== undefined) {
|
|
127
|
+
def.accelerateEnabled = config.accelerateEnabled;
|
|
131
128
|
}
|
|
132
129
|
return def;
|
|
133
130
|
};
|
|
@@ -142,15 +139,18 @@ const cloudOssToDefinition = (info) => ({
|
|
|
142
139
|
errorDocument: info.websiteConfig.errorDocument ?? null,
|
|
143
140
|
},
|
|
144
141
|
}
|
|
145
|
-
: {}),
|
|
142
|
+
: { websiteConfiguration: info.websiteConfig }),
|
|
146
143
|
...(info.storageClass !== undefined ? { storageClass: info.storageClass } : {}),
|
|
147
144
|
...(info.versioningConfig?.status !== undefined
|
|
148
145
|
? { versioningStatus: info.versioningConfig.status }
|
|
149
|
-
: {}),
|
|
146
|
+
: { versioningStatus: info.versioningConfig === null ? null : undefined }),
|
|
150
147
|
...(info.encryptionConfig?.sseAlgorithm !== undefined
|
|
151
148
|
? { sseAlgorithm: info.encryptionConfig.sseAlgorithm }
|
|
152
|
-
: {}),
|
|
153
|
-
|
|
149
|
+
: { sseAlgorithm: info.encryptionConfig === null ? null : undefined }),
|
|
150
|
+
sseKmsMasterKeyId: info.encryptionConfig === undefined
|
|
151
|
+
? undefined
|
|
152
|
+
: (info.encryptionConfig?.kmsMasterKeyId ?? null),
|
|
153
|
+
policy: info.policy,
|
|
154
154
|
...(typeof info.transferAccelerationStatus === 'boolean'
|
|
155
155
|
? { accelerateEnabled: info.transferAccelerationStatus }
|
|
156
156
|
: {}),
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const crypto_1 = require("crypto");
|
|
3
|
+
exports.logApiGatewayRequest = exports.transformFCResponse = exports.addFCHeaders = exports.createAliyunContext = exports.createAliyunContextSerializable = exports.transformToAliyunEvent = void 0;
|
|
5
4
|
const common_1 = require("../../common");
|
|
6
5
|
const createFCLogger = (requestId) => {
|
|
7
6
|
const formatLog = (level, message) => {
|
|
@@ -154,7 +153,3 @@ const formatDateTime = (date) => {
|
|
|
154
153
|
const seconds = String(date.getSeconds()).padStart(2, '0');
|
|
155
154
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
156
155
|
};
|
|
157
|
-
const generateRequestId = () => {
|
|
158
|
-
return (0, crypto_1.randomUUID)().replace(/-/g, '');
|
|
159
|
-
};
|
|
160
|
-
exports.generateRequestId = generateRequestId;
|
|
@@ -1,23 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.eventsHandler = void 0;
|
|
7
4
|
const types_1 = require("../../types");
|
|
8
5
|
const lodash_1 = require("lodash");
|
|
6
|
+
const localStack_1 = require("../../types/localStack");
|
|
9
7
|
const common_1 = require("../../common");
|
|
10
8
|
const function_1 = require("./function");
|
|
11
9
|
const aliyunFc_1 = require("./aliyunFc");
|
|
12
|
-
const
|
|
13
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
14
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
15
|
-
const utils_1 = require("./utils");
|
|
10
|
+
const requestId_1 = require("./requestId");
|
|
16
11
|
const lang_1 = require("../../lang");
|
|
17
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Route matching shared by every provider; the `exact` mode mirrors how the
|
|
14
|
+
* provider actually deploys the route:
|
|
15
|
+
* - Aliyun: gateway routes support `[param]` segments and a trailing `*`
|
|
16
|
+
* prefix wildcard, so paths are compared segment-wise after trimming
|
|
17
|
+
* slashes.
|
|
18
|
+
* - Volcengine: si creates API Gateway routes with `MatchType: 'Exact'`
|
|
19
|
+
* (see `createRoute` in volcengineClient/apigwOperations.ts), so the path
|
|
20
|
+
* is compared byte-for-byte and `[param]` / `*` carry no wildcard meaning.
|
|
21
|
+
*/
|
|
22
|
+
const matchTrigger = (req, trigger, options = { exact: false }) => {
|
|
18
23
|
if (trigger.method !== 'ANY' && req.method !== trigger.method) {
|
|
19
24
|
return false;
|
|
20
25
|
}
|
|
26
|
+
if (options.exact) {
|
|
27
|
+
return trigger.path === req.path;
|
|
28
|
+
}
|
|
21
29
|
const normalize = (s) => s.replace(/^\/+|\/+$/g, '');
|
|
22
30
|
const [pathSegments, triggerSegments] = [
|
|
23
31
|
normalize(req.path).split('/'),
|
|
@@ -38,22 +46,33 @@ const matchTrigger = (req, trigger) => {
|
|
|
38
46
|
};
|
|
39
47
|
const servEvent = async (req, parsed, iac) => {
|
|
40
48
|
const startTime = new Date();
|
|
41
|
-
const requestId = (0,
|
|
49
|
+
const requestId = (0, requestId_1.generateProviderRequestId)(iac.provider.name);
|
|
42
50
|
const sourceIp = req.socket?.remoteAddress || '127.0.0.1';
|
|
43
51
|
const isAliyun = iac.provider.name === common_1.ProviderEnum.ALIYUN;
|
|
44
|
-
const event = iac.events?.find((event) => event.
|
|
52
|
+
const event = iac.events?.find((event) => event.key === parsed.identifier &&
|
|
53
|
+
(event.type === types_1.EventTypes.API_GATEWAY || iac.provider.name === common_1.ProviderEnum.VOLCENGINE));
|
|
45
54
|
if ((0, lodash_1.isEmpty)(event)) {
|
|
46
55
|
return {
|
|
47
56
|
statusCode: 404,
|
|
48
57
|
body: { error: 'API Gateway event not found', event: parsed.identifier },
|
|
49
58
|
};
|
|
50
59
|
}
|
|
60
|
+
if (event.type !== types_1.EventTypes.API_GATEWAY) {
|
|
61
|
+
return { statusCode: 501, body: { error: lang_1.lang.__('LOCAL_EVENT_TYPE_UNSUPPORTED') } };
|
|
62
|
+
}
|
|
63
|
+
// si deploys Tencent HTTP access as a function-owned function URL, not as an
|
|
64
|
+
// API Gateway service, so a gateway event has no SCF-native local equivalent.
|
|
65
|
+
if (iac.provider.name === common_1.ProviderEnum.TENCENT) {
|
|
66
|
+
return { statusCode: 501, body: { error: lang_1.lang.__('LOCAL_SCF_EVENT_UNSUPPORTED') } };
|
|
67
|
+
}
|
|
51
68
|
common_1.logger.info(lang_1.lang.__('EVENT_TRIGGER', {
|
|
52
69
|
triggers: JSON.stringify(event.triggers),
|
|
53
70
|
method: req.method || '',
|
|
54
71
|
url: req.url || '',
|
|
55
72
|
}));
|
|
56
|
-
const matchedTrigger = event.triggers.find((trigger) => matchTrigger({ method: parsed.method, path: parsed.url }, trigger
|
|
73
|
+
const matchedTrigger = event.triggers.find((trigger) => matchTrigger({ method: parsed.method, path: parsed.url }, trigger, {
|
|
74
|
+
exact: iac.provider.name === common_1.ProviderEnum.VOLCENGINE,
|
|
75
|
+
}));
|
|
57
76
|
if (!matchedTrigger) {
|
|
58
77
|
const endTime = new Date();
|
|
59
78
|
if (isAliyun) {
|
|
@@ -73,66 +92,7 @@ const servEvent = async (req, parsed, iac) => {
|
|
|
73
92
|
body: { error: 'Backend definition missing', backend: matchedTrigger.backend },
|
|
74
93
|
};
|
|
75
94
|
}
|
|
76
|
-
|
|
77
|
-
if (isAliyun && backendDef.code) {
|
|
78
|
-
let tempDir = null;
|
|
79
|
-
try {
|
|
80
|
-
const { event: aliyunEvent } = await (0, aliyunFc_1.transformToAliyunEvent)(req, parsed.url, parsed.query);
|
|
81
|
-
const codePath = node_path_1.default.resolve(process.cwd(), backendDef.code.path);
|
|
82
|
-
let codeDir;
|
|
83
|
-
if (codePath.endsWith('.zip') && node_fs_1.default.existsSync(codePath)) {
|
|
84
|
-
tempDir = await (0, utils_1.extractZipFile)(codePath);
|
|
85
|
-
codeDir = tempDir;
|
|
86
|
-
}
|
|
87
|
-
else if (node_fs_1.default.existsSync(codePath) && node_fs_1.default.statSync(codePath).isDirectory()) {
|
|
88
|
-
codeDir = codePath;
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
codeDir = node_path_1.default.dirname(codePath);
|
|
92
|
-
}
|
|
93
|
-
const funOptions = {
|
|
94
|
-
codeDir,
|
|
95
|
-
functionKey: backendDef.key,
|
|
96
|
-
handler: backendDef.code.handler,
|
|
97
|
-
servicePath: '',
|
|
98
|
-
timeout: (backendDef.timeout ?? 3) * 1000,
|
|
99
|
-
};
|
|
100
|
-
const aliyunContext = (0, aliyunFc_1.createAliyunContextSerializable)(iac, backendDef.name, backendDef.code.handler, backendDef.memory ?? 128, backendDef.timeout ?? 3, requestId);
|
|
101
|
-
const env = {
|
|
102
|
-
...backendDef.environment,
|
|
103
|
-
};
|
|
104
|
-
common_1.logger.debug(lang_1.lang.__('INVOKING_FC_FUNCTION_WITH_ALIYUN_EVENT'));
|
|
105
|
-
const result = await (0, functionRunner_1.invokeFunction)(funOptions, env, aliyunEvent, aliyunContext);
|
|
106
|
-
const endTime = new Date();
|
|
107
|
-
const transformed = (0, aliyunFc_1.transformFCResponse)(result);
|
|
108
|
-
// Log API Gateway request
|
|
109
|
-
(0, aliyunFc_1.logApiGatewayRequest)(requestId, parsed.url, transformed.statusCode, startTime, endTime, sourceIp);
|
|
110
|
-
return {
|
|
111
|
-
statusCode: transformed.statusCode,
|
|
112
|
-
headers: transformed.headers,
|
|
113
|
-
body: transformed.body,
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
catch (error) {
|
|
117
|
-
const endTime = new Date();
|
|
118
|
-
(0, aliyunFc_1.logApiGatewayRequest)(requestId, parsed.url, 500, startTime, endTime, sourceIp);
|
|
119
|
-
common_1.logger.error(lang_1.lang.__('FUNCTION_EXECUTION_ERROR', { error: String(error) }));
|
|
120
|
-
return {
|
|
121
|
-
statusCode: 500,
|
|
122
|
-
body: {
|
|
123
|
-
error: 'Function execution failed',
|
|
124
|
-
message: error instanceof Error ? error.message : String(error),
|
|
125
|
-
},
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
finally {
|
|
129
|
-
if (tempDir && node_fs_1.default.existsSync(tempDir)) {
|
|
130
|
-
node_fs_1.default.rmSync(tempDir, { recursive: true, force: true });
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
// For non-Aliyun or when using functionsHandler
|
|
135
|
-
const result = await (0, function_1.functionsHandler)(req, { ...parsed, identifier: backendDef?.key }, iac);
|
|
95
|
+
const result = await (0, function_1.functionsHandler)(req, { ...parsed, kind: localStack_1.RouteKind.SI_EVENTS, identifier: backendDef.key }, iac, requestId);
|
|
136
96
|
const endTime = new Date();
|
|
137
97
|
if (isAliyun) {
|
|
138
98
|
(0, aliyunFc_1.logApiGatewayRequest)(requestId, parsed.url, result.statusCode, startTime, endTime, sourceIp);
|