@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;
package/dist/esm/index.js CHANGED
@@ -967,11 +967,14 @@ class JaypieEnvSecret extends Construct {
967
967
  get secretArn() {
968
968
  return this._secret.secretArn;
969
969
  }
970
+ get secretFullArn() {
971
+ return this._secret.secretFullArn;
972
+ }
970
973
  get secretName() {
971
974
  return this._secret.secretName;
972
975
  }
973
- get secretFullArn() {
974
- return this._secret.secretFullArn;
976
+ get secretRef() {
977
+ return this._secret.secretRef;
975
978
  }
976
979
  get encryptionKey() {
977
980
  return this._secret.encryptionKey;
@@ -2128,6 +2131,9 @@ class JaypieCertificate extends Construct {
2128
2131
  this.certificate.applyRemovalPolicy(policy);
2129
2132
  }
2130
2133
  // ICertificate implementation
2134
+ get certificateRef() {
2135
+ return this.certificate.certificateRef;
2136
+ }
2131
2137
  metricDaysToExpiry(props) {
2132
2138
  return this.certificate.metricDaysToExpiry(props);
2133
2139
  }
@@ -2793,6 +2799,9 @@ class JaypieDynamoDb extends Construct {
2793
2799
  get tableName() {
2794
2800
  return this._table.tableName;
2795
2801
  }
2802
+ get tableRef() {
2803
+ return this._table.tableRef;
2804
+ }
2796
2805
  get tableStreamArn() {
2797
2806
  return this._table.tableStreamArn;
2798
2807
  }
@@ -3176,13 +3185,19 @@ class JaypieMongoDbSecret extends JaypieEnvSecret {
3176
3185
  class JaypieNextJs extends Construct {
3177
3186
  constructor(scope, id, props) {
3178
3187
  super(scope, id);
3179
- const domainName = typeof props?.domainName === "string"
3180
- ? props.domainName
3181
- : envHostname(props?.domainName);
3188
+ // Determine if we should use a custom domain
3189
+ const useDomain = props?.domainProps !== false;
3190
+ // Resolve domain name only if using a custom domain
3191
+ const domainName = useDomain
3192
+ ? typeof props?.domainName === "string"
3193
+ ? props.domainName
3194
+ : envHostname(props?.domainName)
3195
+ : undefined;
3182
3196
  this.domainName = domainName;
3183
- const domainNameSanitized = domainName
3184
- .replace(/\./g, "-")
3185
- .replace(/[^a-zA-Z0-9]/g, "_");
3197
+ // Use domain name or construct ID for cache policy naming
3198
+ const cachePolicyIdentifier = domainName
3199
+ ? domainName.replace(/\./g, "-").replace(/[^a-zA-Z0-9]/g, "_")
3200
+ : id.replace(/[^a-zA-Z0-9]/g, "_");
3186
3201
  // Resolve environment from array or object syntax
3187
3202
  const environment = resolveEnvironment(props?.environment);
3188
3203
  const envSecrets = props?.envSecrets || {};
@@ -3219,27 +3234,32 @@ class JaypieNextJs extends Construct {
3219
3234
  }, {});
3220
3235
  const nextjs = new Nextjs(this, "NextJsApp", {
3221
3236
  nextjsPath,
3222
- domainProps: {
3223
- domainName,
3224
- hostedZone: resolveHostedZone(this, {
3225
- zone: props?.hostedZone,
3226
- }),
3227
- },
3237
+ // Only configure custom domain if useDomain is true
3238
+ ...(useDomain &&
3239
+ domainName && {
3240
+ domainProps: {
3241
+ domainName,
3242
+ hostedZone: resolveHostedZone(this, {
3243
+ zone: props?.hostedZone,
3244
+ }),
3245
+ },
3246
+ }),
3228
3247
  environment: {
3229
3248
  ...jaypieLambdaEnv(),
3230
3249
  ...environment,
3231
3250
  ...secretsEnvironment,
3232
3251
  ...jaypieSecretsEnvironment,
3233
3252
  ...nextPublicEnv,
3234
- NEXT_PUBLIC_SITE_URL: `https://${domainName}`,
3253
+ // NEXT_PUBLIC_SITE_URL will be set after construct creation for CloudFront URL
3254
+ ...(domainName && { NEXT_PUBLIC_SITE_URL: `https://${domainName}` }),
3235
3255
  },
3236
3256
  overrides: {
3237
3257
  nextjsDistribution: {
3238
3258
  imageCachePolicyProps: {
3239
- cachePolicyName: `NextJsImageCachePolicy-${domainNameSanitized}`,
3259
+ cachePolicyName: `NextJsImageCachePolicy-${cachePolicyIdentifier}`,
3240
3260
  },
3241
3261
  serverCachePolicyProps: {
3242
- cachePolicyName: `NextJsServerCachePolicy-${domainNameSanitized}`,
3262
+ cachePolicyName: `NextJsServerCachePolicy-${cachePolicyIdentifier}`,
3243
3263
  },
3244
3264
  },
3245
3265
  nextjsImage: {
@@ -3254,6 +3274,10 @@ class JaypieNextJs extends Construct {
3254
3274
  },
3255
3275
  },
3256
3276
  });
3277
+ // Set NEXT_PUBLIC_SITE_URL to CloudFront URL when no custom domain
3278
+ if (!domainName) {
3279
+ nextjs.serverFunction.lambdaFunction.addEnvironment("NEXT_PUBLIC_SITE_URL", `https://${nextjs.distribution.distributionDomain}`);
3280
+ }
3257
3281
  addDatadogLayers(nextjs.imageOptimizationFunction);
3258
3282
  addDatadogLayers(nextjs.serverFunction.lambdaFunction);
3259
3283
  // Grant secret read permissions
@@ -3887,6 +3911,10 @@ class JaypieWebDeploymentBucket extends Construct {
3887
3911
  new CfnOutput(this, "DestinationBucketDeployRoleArn", {
3888
3912
  value: bucketDeployRole.roleArn,
3889
3913
  });
3914
+ // Output the bucket name for workflows
3915
+ new CfnOutput(this, "DestinationBucketName", {
3916
+ value: this.bucket.bucketName,
3917
+ });
3890
3918
  }
3891
3919
  // Create CloudFront distribution and certificate if host and zone are provided
3892
3920
  if (host && zone) {
@@ -3940,6 +3968,10 @@ class JaypieWebDeploymentBucket extends Construct {
3940
3968
  });
3941
3969
  Tags.of(record).add(CDK$2.TAG.ROLE, CDK$2.ROLE.NETWORKING);
3942
3970
  this.distributionDomainName = this.distribution.distributionDomainName;
3971
+ // Output the distribution ID for cache invalidation
3972
+ new CfnOutput(this, "DistributionId", {
3973
+ value: this.distribution.distributionId,
3974
+ });
3943
3975
  }
3944
3976
  }
3945
3977
  // Implement remaining IBucket methods by delegating to the bucket