@jaypie/constructs 1.2.1 → 1.2.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.
@@ -16,7 +16,7 @@ export { JaypieHostedZone, JaypieHostedZoneRecordProps, } from "./JaypieHostedZo
16
16
  export { JaypieInfrastructureStack } from "./JaypieInfrastructureStack";
17
17
  export { JaypieLambda, JaypieLambdaProps } from "./JaypieLambda";
18
18
  export { JaypieMongoDbSecret } from "./JaypieMongoDbSecret";
19
- export { JaypieNextJs, JaypieNextjsProps } from "./JaypieNextJs";
19
+ export { DomainNameConfig, JaypieNextJs, JaypieNextjsProps, } from "./JaypieNextJs";
20
20
  export { JaypieOpenAiSecret } from "./JaypieOpenAiSecret";
21
21
  export { JaypieOrganizationTrail, JaypieOrganizationTrailProps, } from "./JaypieOrganizationTrail";
22
22
  export { AccountAssignments, JaypieSsoPermissions, JaypieSsoPermissionsProps, } from "./JaypieSsoPermissions";
@@ -2,9 +2,23 @@ import { IHostedZone } from "aws-cdk-lib/aws-route53";
2
2
  import * as secretsmanager from "aws-cdk-lib/aws-secretsmanager";
3
3
  import { Construct } from "constructs";
4
4
  import { EnvironmentInput, SecretsArrayItem } from "./helpers";
5
+ export interface DomainNameConfig {
6
+ component?: string;
7
+ domain?: string;
8
+ env?: string;
9
+ subdomain?: string;
10
+ }
5
11
  export interface JaypieNextjsProps {
6
12
  datadogApiKeyArn?: string;
7
- domainName?: string;
13
+ /**
14
+ * Domain name for the Next.js application.
15
+ *
16
+ * Supports both string and config object:
17
+ * - String: used directly as the domain name
18
+ * - Object: passed to envHostname() to construct the domain name
19
+ * - { component, domain, env, subdomain }
20
+ */
21
+ domainName?: string | DomainNameConfig;
8
22
  /**
9
23
  * Environment variables for the Next.js application.
10
24
  *
@@ -16,7 +16,7 @@ export { JaypieHostedZone, JaypieHostedZoneRecordProps, } from "./JaypieHostedZo
16
16
  export { JaypieInfrastructureStack } from "./JaypieInfrastructureStack";
17
17
  export { JaypieLambda, JaypieLambdaProps } from "./JaypieLambda";
18
18
  export { JaypieMongoDbSecret } from "./JaypieMongoDbSecret";
19
- export { JaypieNextJs, JaypieNextjsProps } from "./JaypieNextJs";
19
+ export { DomainNameConfig, JaypieNextJs, JaypieNextjsProps, } from "./JaypieNextJs";
20
20
  export { JaypieOpenAiSecret } from "./JaypieOpenAiSecret";
21
21
  export { JaypieOrganizationTrail, JaypieOrganizationTrailProps, } from "./JaypieOrganizationTrail";
22
22
  export { AccountAssignments, JaypieSsoPermissions, JaypieSsoPermissionsProps, } from "./JaypieSsoPermissions";
package/dist/esm/index.js CHANGED
@@ -359,7 +359,8 @@ function envHostname({ component, domain, env, subdomain, } = {}) {
359
359
  throw new ConfigurationError("No hostname `domain` provided. Set CDK_ENV_DOMAIN or CDK_ENV_HOSTED_ZONE to use environment domain");
360
360
  }
361
361
  const resolvedComponent = component === "@" || component === "" ? undefined : component;
362
- const resolvedSubdomain = subdomain || process.env.CDK_ENV_SUBDOMAIN;
362
+ const providedSubdomain = subdomain === "@" || subdomain === "" ? undefined : subdomain;
363
+ const resolvedSubdomain = providedSubdomain || process.env.CDK_ENV_SUBDOMAIN;
363
364
  const resolvedEnv = env || process.env.PROJECT_ENV;
364
365
  const filteredEnv = resolvedEnv === CDK$2.ENV.PRODUCTION ? undefined : resolvedEnv;
365
366
  const parts = [
@@ -2564,7 +2565,9 @@ class JaypieMongoDbSecret extends JaypieEnvSecret {
2564
2565
  class JaypieNextJs extends Construct {
2565
2566
  constructor(scope, id, props) {
2566
2567
  super(scope, id);
2567
- const domainName = props?.domainName || envHostname();
2568
+ const domainName = typeof props?.domainName === "string"
2569
+ ? props.domainName
2570
+ : envHostname(props?.domainName);
2568
2571
  this.domainName = domainName;
2569
2572
  const domainNameSanitized = domainName
2570
2573
  .replace(/\./g, "-")