@jaypie/constructs 1.2.16 → 1.2.18

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.
@@ -113,5 +113,6 @@ export declare class JaypieCertificate extends Construct implements acm.ICertifi
113
113
  region: string;
114
114
  };
115
115
  applyRemovalPolicy(policy: RemovalPolicy): void;
116
+ get certificateRef(): acm.CertificateReference;
116
117
  metricDaysToExpiry(props?: import("aws-cdk-lib/aws-cloudwatch").MetricOptions): import("aws-cdk-lib/aws-cloudwatch").Metric;
117
118
  }
@@ -105,6 +105,7 @@ export declare class JaypieDynamoDb extends Construct implements dynamodb.ITable
105
105
  get tableArn(): string;
106
106
  get tableId(): string | undefined;
107
107
  get tableName(): string;
108
+ get tableRef(): dynamodb.TableReference;
108
109
  get tableStreamArn(): string | undefined;
109
110
  get encryptionKey(): import("aws-cdk-lib/aws-kms").IKey | undefined;
110
111
  applyRemovalPolicy(policy: RemovalPolicy): void;
@@ -25,8 +25,9 @@ export declare class JaypieEnvSecret extends Construct implements ISecret {
25
25
  };
26
26
  applyRemovalPolicy(policy: RemovalPolicy): void;
27
27
  get secretArn(): string;
28
- get secretName(): string;
29
28
  get secretFullArn(): string | undefined;
29
+ get secretName(): string;
30
+ get secretRef(): secretsmanager.SecretReference;
30
31
  get encryptionKey(): IKey | undefined;
31
32
  get secretValue(): SecretValue;
32
33
  secretValueFromJson(key: string): SecretValue;
@@ -16,8 +16,16 @@ export interface JaypieNextjsProps {
16
16
  * - String: used directly as the domain name
17
17
  * - Object: passed to envHostname() to construct the domain name
18
18
  * - { component, domain, env, subdomain }
19
+ *
20
+ * To deploy without a domain (CloudFront URL only), set domainProps: false
19
21
  */
20
22
  domainName?: string | DomainNameConfig;
23
+ /**
24
+ * Set to false to deploy without a custom domain.
25
+ * When false, the application will only be accessible via CloudFront URL.
26
+ * This overrides any domainName configuration.
27
+ */
28
+ domainProps?: false;
21
29
  /**
22
30
  * DynamoDB tables to grant read/write access to the Next.js server function.
23
31
  * Each table is granted read/write access and if exactly one table is provided,
@@ -51,7 +59,7 @@ export interface JaypieNextjsProps {
51
59
  }
52
60
  export declare class JaypieNextJs extends Construct {
53
61
  private readonly _nextjs;
54
- readonly domainName: string;
62
+ readonly domainName?: string;
55
63
  constructor(scope: Construct, id: string, props?: JaypieNextjsProps);
56
64
  /** S3 bucket for static assets */
57
65
  get bucket(): import("aws-cdk-lib/aws-s3").IBucket;
@@ -999,11 +999,14 @@ class JaypieEnvSecret extends constructs.Construct {
999
999
  get secretArn() {
1000
1000
  return this._secret.secretArn;
1001
1001
  }
1002
+ get secretFullArn() {
1003
+ return this._secret.secretFullArn;
1004
+ }
1002
1005
  get secretName() {
1003
1006
  return this._secret.secretName;
1004
1007
  }
1005
- get secretFullArn() {
1006
- return this._secret.secretFullArn;
1008
+ get secretRef() {
1009
+ return this._secret.secretRef;
1007
1010
  }
1008
1011
  get encryptionKey() {
1009
1012
  return this._secret.encryptionKey;
@@ -2160,6 +2163,9 @@ class JaypieCertificate extends constructs.Construct {
2160
2163
  this.certificate.applyRemovalPolicy(policy);
2161
2164
  }
2162
2165
  // ICertificate implementation
2166
+ get certificateRef() {
2167
+ return this.certificate.certificateRef;
2168
+ }
2163
2169
  metricDaysToExpiry(props) {
2164
2170
  return this.certificate.metricDaysToExpiry(props);
2165
2171
  }
@@ -2825,6 +2831,9 @@ class JaypieDynamoDb extends constructs.Construct {
2825
2831
  get tableName() {
2826
2832
  return this._table.tableName;
2827
2833
  }
2834
+ get tableRef() {
2835
+ return this._table.tableRef;
2836
+ }
2828
2837
  get tableStreamArn() {
2829
2838
  return this._table.tableStreamArn;
2830
2839
  }
@@ -3208,13 +3217,19 @@ class JaypieMongoDbSecret extends JaypieEnvSecret {
3208
3217
  class JaypieNextJs extends constructs.Construct {
3209
3218
  constructor(scope, id, props) {
3210
3219
  super(scope, id);
3211
- const domainName = typeof props?.domainName === "string"
3212
- ? props.domainName
3213
- : envHostname(props?.domainName);
3220
+ // Determine if we should use a custom domain
3221
+ const useDomain = props?.domainProps !== false;
3222
+ // Resolve domain name only if using a custom domain
3223
+ const domainName = useDomain
3224
+ ? typeof props?.domainName === "string"
3225
+ ? props.domainName
3226
+ : envHostname(props?.domainName)
3227
+ : undefined;
3214
3228
  this.domainName = domainName;
3215
- const domainNameSanitized = domainName
3216
- .replace(/\./g, "-")
3217
- .replace(/[^a-zA-Z0-9]/g, "_");
3229
+ // Use domain name or construct ID for cache policy naming
3230
+ const cachePolicyIdentifier = domainName
3231
+ ? domainName.replace(/\./g, "-").replace(/[^a-zA-Z0-9]/g, "_")
3232
+ : id.replace(/[^a-zA-Z0-9]/g, "_");
3218
3233
  // Resolve environment from array or object syntax
3219
3234
  const environment = resolveEnvironment(props?.environment);
3220
3235
  const envSecrets = props?.envSecrets || {};
@@ -3251,27 +3266,32 @@ class JaypieNextJs extends constructs.Construct {
3251
3266
  }, {});
3252
3267
  const nextjs = new cdkNextjsStandalone.Nextjs(this, "NextJsApp", {
3253
3268
  nextjsPath,
3254
- domainProps: {
3255
- domainName,
3256
- hostedZone: resolveHostedZone(this, {
3257
- zone: props?.hostedZone,
3258
- }),
3259
- },
3269
+ // Only configure custom domain if useDomain is true
3270
+ ...(useDomain &&
3271
+ domainName && {
3272
+ domainProps: {
3273
+ domainName,
3274
+ hostedZone: resolveHostedZone(this, {
3275
+ zone: props?.hostedZone,
3276
+ }),
3277
+ },
3278
+ }),
3260
3279
  environment: {
3261
3280
  ...jaypieLambdaEnv(),
3262
3281
  ...environment,
3263
3282
  ...secretsEnvironment,
3264
3283
  ...jaypieSecretsEnvironment,
3265
3284
  ...nextPublicEnv,
3266
- NEXT_PUBLIC_SITE_URL: `https://${domainName}`,
3285
+ // NEXT_PUBLIC_SITE_URL will be set after construct creation for CloudFront URL
3286
+ ...(domainName && { NEXT_PUBLIC_SITE_URL: `https://${domainName}` }),
3267
3287
  },
3268
3288
  overrides: {
3269
3289
  nextjsDistribution: {
3270
3290
  imageCachePolicyProps: {
3271
- cachePolicyName: `NextJsImageCachePolicy-${domainNameSanitized}`,
3291
+ cachePolicyName: `NextJsImageCachePolicy-${cachePolicyIdentifier}`,
3272
3292
  },
3273
3293
  serverCachePolicyProps: {
3274
- cachePolicyName: `NextJsServerCachePolicy-${domainNameSanitized}`,
3294
+ cachePolicyName: `NextJsServerCachePolicy-${cachePolicyIdentifier}`,
3275
3295
  },
3276
3296
  },
3277
3297
  nextjsImage: {
@@ -3286,6 +3306,10 @@ class JaypieNextJs extends constructs.Construct {
3286
3306
  },
3287
3307
  },
3288
3308
  });
3309
+ // Set NEXT_PUBLIC_SITE_URL to CloudFront URL when no custom domain
3310
+ if (!domainName) {
3311
+ nextjs.serverFunction.lambdaFunction.addEnvironment("NEXT_PUBLIC_SITE_URL", `https://${nextjs.distribution.distributionDomain}`);
3312
+ }
3289
3313
  addDatadogLayers(nextjs.imageOptimizationFunction);
3290
3314
  addDatadogLayers(nextjs.serverFunction.lambdaFunction);
3291
3315
  // Grant secret read permissions
@@ -3919,6 +3943,10 @@ class JaypieWebDeploymentBucket extends constructs.Construct {
3919
3943
  new cdk.CfnOutput(this, "DestinationBucketDeployRoleArn", {
3920
3944
  value: bucketDeployRole.roleArn,
3921
3945
  });
3946
+ // Output the bucket name for workflows
3947
+ new cdk.CfnOutput(this, "DestinationBucketName", {
3948
+ value: this.bucket.bucketName,
3949
+ });
3922
3950
  }
3923
3951
  // Create CloudFront distribution and certificate if host and zone are provided
3924
3952
  if (host && zone) {
@@ -3972,6 +4000,10 @@ class JaypieWebDeploymentBucket extends constructs.Construct {
3972
4000
  });
3973
4001
  cdk.Tags.of(record).add(CDK$2.TAG.ROLE, CDK$2.ROLE.NETWORKING);
3974
4002
  this.distributionDomainName = this.distribution.distributionDomainName;
4003
+ // Output the distribution ID for cache invalidation
4004
+ new cdk.CfnOutput(this, "DistributionId", {
4005
+ value: this.distribution.distributionId,
4006
+ });
3975
4007
  }
3976
4008
  }
3977
4009
  // Implement remaining IBucket methods by delegating to the bucket