@geek-fun/serverlessinsight 0.8.0 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geek-fun/serverlessinsight",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "description": "Full life cycle cross providers serverless application management for your fast-growing business.",
5
5
  "homepage": "https://serverlessinsight.geekfun.club",
6
6
  "main": "dist/src/index.js",
@@ -151,7 +151,9 @@ const createApigwOperations = (apigwClient, dnsClient, _context) => {
151
151
  // For CNAME verification: point the domain directly to the group subdomain
152
152
  const verificationHost = domainName;
153
153
  const verificationValue = groupSubdomain;
154
- const dnsResourceId = `${eventLogicalId}.dns_verification`;
154
+ // Use domain-specific key so primary and www don't collide
155
+ const domainKey = domainName.replace(/[^a-zA-Z0-9]/g, '_');
156
+ const dnsResourceId = `${eventLogicalId}.dns_verification.${domainKey}`;
155
157
  try {
156
158
  // Check if DNS record is tracked in state
157
159
  const existingDnsResource = (0, stateManager_1.getResource)(state, dnsResourceId);
@@ -262,7 +264,8 @@ const createApigwOperations = (apigwClient, dnsClient, _context) => {
262
264
  const addTxtVerificationRecord = async (groupId, domainName, groupSubdomain, region, state, eventLogicalId) => {
263
265
  const mainDomain = (0, domainUtils_1.extractMainDomain)(domainName);
264
266
  const txtRecord = buildTxtVerificationRecord(groupId, domainName, groupSubdomain, mainDomain);
265
- const txtResourceId = `${eventLogicalId}.dns_txt_verification`;
267
+ const txtDomainKey = domainName.replace(/[^a-zA-Z0-9]/g, '_');
268
+ const txtResourceId = `${eventLogicalId}.dns_txt_verification.${txtDomainKey}`;
266
269
  logger_1.logger.info(lang_1.lang.__('APIGW_TXT_ADDING_RECORD', { rr: txtRecord.rr, value: txtRecord.value }));
267
270
  try {
268
271
  const existingRecords = await dnsOps.describeDomainRecords(mainDomain, txtRecord.rr);
@@ -10,6 +10,7 @@ const certUtils_1 = require("../../common/certUtils");
10
10
  const logger_1 = require("../../common/logger");
11
11
  const lang_1 = require("../../lang");
12
12
  const domainUtils_1 = require("../../common/domainUtils");
13
+ const hashUtils_1 = require("../../common/hashUtils");
13
14
  const getCdnConfig = (event) => {
14
15
  const domainCdn = event.domain?.cdn;
15
16
  if (domainCdn == null) {
@@ -589,14 +590,44 @@ const updateApigwResource = async (context, event, serviceName, roleArn, state)
589
590
  }
590
591
  }
591
592
  if (event.domain) {
593
+ const desiredDomainDef = (0, apigwTypes_1.extractEventDomainDefinition)(event.domain);
594
+ const previousDomainDef = existingState?.definition?.domain;
595
+ // Skip domain binding when the domain configuration hasn't changed AND
596
+ // the domain was previously successfully bound (DNS records exist in state).
597
+ // This avoids unnecessary DNS verification (minutes-long) on every deploy.
598
+ // We check DNS sub-resources to avoid skipping after a previously failed binding.
599
+ // Check for ANY DNS sub-resource — covers both primary and www domains.
600
+ // If any domain was previously bound, its DNS record exists in state.
601
+ const hasBoundDomains = (0, stateManager_1.getResource)(state, `${logicalId}.dns_verification`) !== undefined ||
602
+ (0, stateManager_1.getResource)(state, `${logicalId}.dns_txt_verification`) !== undefined ||
603
+ Object.keys(state.resources ?? {}).some((k) => k.startsWith(`${logicalId}.dns_`) &&
604
+ k !== `${logicalId}.dns_verification` &&
605
+ k !== `${logicalId}.dns_txt_verification`);
606
+ if (previousDomainDef &&
607
+ desiredDomainDef &&
608
+ hasBoundDomains &&
609
+ (0, hashUtils_1.attributesEqual)(previousDomainDef, desiredDomainDef)) {
610
+ logger_1.logger.info('Domain configuration unchanged and previously bound, skipping DNS verification');
611
+ // Still include existing domain instances for state consistency
612
+ const existingDomainInstances = existingState?.instances?.filter((i) => i.type === 'ALIYUN_APIGW_GROUP' ||
613
+ i.type === 'ALIYUN_APIGW_API' ||
614
+ i.type === 'ALIYUN_APIGW_DEPLOYMENT') ?? [];
615
+ instances.push(...existingDomainInstances);
616
+ return (0, stateManager_1.setResource)(state, logicalId, {
617
+ mode: 'managed',
618
+ region: context.region,
619
+ definition: { ...(existingState?.definition ?? {}), domain: desiredDomainDef },
620
+ instances: [...instances, ...existingDomainInstances],
621
+ lastUpdated: new Date().toISOString(),
622
+ });
623
+ }
592
624
  const primaryDomain = event.domain.domain_name;
593
625
  const wwwBindApex = event.domain.www_bind_apex === true;
594
626
  const wwwDomain = wwwBindApex ? (0, domainUtils_1.deriveWwwDomain)(primaryDomain) : null;
595
627
  const isCdnEnabled = getIsCdnEnabled(event);
596
- const existingDomain = existingState?.definition?.domain;
597
- const previousWwwBindApex = existingDomain?.wwwBindApex === true;
598
- const previousDomainName = existingDomain?.domainName;
599
- const previousCdnEnabled = existingDomain?.cdnEnabled === true;
628
+ const previousWwwBindApex = previousDomainDef?.wwwBindApex === true;
629
+ const previousDomainName = previousDomainDef?.domainName;
630
+ const previousCdnEnabled = previousDomainDef?.cdnEnabled === true;
600
631
  const previousTrackedDomains = getApigwTrackedDomains(previousDomainName, previousWwwBindApex);
601
632
  const originDomain = groupInfo.subDomain;
602
633
  if (isCdnEnabled && !originDomain) {
@@ -789,10 +820,18 @@ exports.deleteApigwResource = deleteApigwResource;
789
820
  */
790
821
  const cleanupDnsRecords = async (context, eventLogicalId, state) => {
791
822
  const client = (0, aliyunClient_1.createAliyunClient)(context);
823
+ // Backward-compatible: always check old-style fixed keys, then scan for
824
+ // domain-specific keys (primary + www + any) created by the new code.
792
825
  const dnsResourceIds = [
793
826
  `${eventLogicalId}.dns_verification`,
794
827
  `${eventLogicalId}.dns_txt_verification`,
795
828
  ];
829
+ const dnsPrefix = `${eventLogicalId}.dns_`;
830
+ for (const key of Object.keys(state.resources ?? {})) {
831
+ if (key.startsWith(dnsPrefix) && !dnsResourceIds.includes(key)) {
832
+ dnsResourceIds.push(key);
833
+ }
834
+ }
796
835
  for (const dnsResourceId of dnsResourceIds) {
797
836
  const dnsState = (0, stateManager_1.getResource)(state, dnsResourceId);
798
837
  if (!dnsState) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geek-fun/serverlessinsight",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "description": "Full life cycle cross providers serverless application management for your fast-growing business.",
5
5
  "homepage": "https://serverlessinsight.geekfun.club",
6
6
  "main": "dist/src/index.js",