@jaypie/constructs 1.2.12 → 1.2.13

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.
@@ -1,6 +1,6 @@
1
1
  export { CDK, LAMBDA_WEB_ADAPTER } from "./constants";
2
2
  export { JaypieAccountLoggingBucket, JaypieAccountLoggingBucketProps, } from "./JaypieAccountLoggingBucket";
3
- export { JaypieApiGateway } from "./JaypieApiGateway";
3
+ export { JaypieApiGateway, JaypieApiGatewayProps, } from "./JaypieApiGateway";
4
4
  export { JaypieAppStack } from "./JaypieAppStack";
5
5
  export { JaypieBucketQueuedLambda } from "./JaypieBucketQueuedLambda";
6
6
  export { JaypieCertificate, JaypieCertificateProps, } from "./JaypieCertificate";
@@ -3,9 +3,26 @@ import { RemovalPolicy, Stack } from "aws-cdk-lib";
3
3
  import * as acm from "aws-cdk-lib/aws-certificatemanager";
4
4
  import * as apiGateway from "aws-cdk-lib/aws-apigateway";
5
5
  import * as route53 from "aws-cdk-lib/aws-route53";
6
+ import { HostConfig } from "./helpers";
6
7
  export interface JaypieApiGatewayProps extends apiGateway.LambdaRestApiProps {
7
8
  certificate?: boolean | acm.ICertificate;
8
- host?: string;
9
+ /**
10
+ * The domain name for the API Gateway.
11
+ *
12
+ * Supports both string and config object:
13
+ * - String: used directly as the domain name (e.g., "api.example.com")
14
+ * - Object: passed to envHostname() to construct the domain name
15
+ * - { subdomain, domain, env, component }
16
+ *
17
+ * @example
18
+ * // Direct string
19
+ * host: "api.example.com"
20
+ *
21
+ * @example
22
+ * // Config object - resolves using envHostname()
23
+ * host: { subdomain: "api" }
24
+ */
25
+ host?: string | HostConfig;
9
26
  name?: string;
10
27
  roleTag?: string;
11
28
  zone?: string | route53.IHostedZone;
@@ -6,6 +6,7 @@ import * as route53 from "aws-cdk-lib/aws-route53";
6
6
  import * as s3 from "aws-cdk-lib/aws-s3";
7
7
  import { LambdaDestination } from "aws-cdk-lib/aws-s3-notifications";
8
8
  import { Construct } from "constructs";
9
+ import { HostConfig } from "./helpers";
9
10
  export interface JaypieDistributionProps extends Omit<cloudfront.DistributionProps, "certificate" | "defaultBehavior" | "logBucket"> {
10
11
  /**
11
12
  * SSL certificate for the CloudFront distribution
@@ -41,10 +42,24 @@ export interface JaypieDistributionProps extends Omit<cloudfront.DistributionPro
41
42
  */
42
43
  handler?: cloudfront.IOrigin | lambda.IFunctionUrl | lambda.IFunction;
43
44
  /**
44
- * The domain name for the distribution
45
+ * The domain name for the distribution.
46
+ *
47
+ * Supports both string and config object:
48
+ * - String: used directly as the domain name (e.g., "api.example.com")
49
+ * - Object: passed to envHostname() to construct the domain name
50
+ * - { subdomain, domain, env, component }
51
+ *
45
52
  * @default mergeDomain(CDK_ENV_API_SUBDOMAIN, CDK_ENV_API_HOSTED_ZONE || CDK_ENV_HOSTED_ZONE)
53
+ *
54
+ * @example
55
+ * // Direct string
56
+ * host: "api.example.com"
57
+ *
58
+ * @example
59
+ * // Config object - resolves using envHostname()
60
+ * host: { subdomain: "api" }
46
61
  */
47
- host?: string;
62
+ host?: string | HostConfig;
48
63
  /**
49
64
  * Invoke mode for Lambda Function URLs.
50
65
  * If not provided, auto-detects from handler if it has an invokeMode property
@@ -4,7 +4,7 @@ import * as dynamodb from "aws-cdk-lib/aws-dynamodb";
4
4
  export interface JaypieDynamoDbProps extends Omit<dynamodb.TablePropsV2, "globalSecondaryIndexes" | "partitionKey" | "sortKey"> {
5
5
  /**
6
6
  * Configure GSIs for the table.
7
- * - `undefined` or `true`: Creates all five Jaypie GSIs (Alias, Class, Ou, Type, Xid)
7
+ * - `undefined` or `true`: Creates all five Jaypie GSIs (Alias, Class, Scope, Type, Xid)
8
8
  * - `false`: No GSIs
9
9
  * - Array: Use the specified GSIs
10
10
  */
@@ -61,7 +61,7 @@ export interface JaypieDynamoDbProps extends Omit<dynamodb.TablePropsV2, "global
61
61
  * // Use only specific GSIs
62
62
  * const table = new JaypieDynamoDb(this, "MyTable", {
63
63
  * globalSecondaryIndexes: [
64
- * JaypieDynamoDb.GlobalSecondaryIndex.Ou,
64
+ * JaypieDynamoDb.GlobalSecondaryIndex.Scope,
65
65
  * JaypieDynamoDb.GlobalSecondaryIndex.Type,
66
66
  * ],
67
67
  * });
@@ -73,7 +73,7 @@ export declare class JaypieDynamoDb extends Construct implements dynamodb.ITable
73
73
  static readonly GlobalSecondaryIndex: {
74
74
  readonly Alias: dynamodb.GlobalSecondaryIndexPropsV2;
75
75
  readonly Class: dynamodb.GlobalSecondaryIndexPropsV2;
76
- readonly Ou: dynamodb.GlobalSecondaryIndexPropsV2;
76
+ readonly Scope: dynamodb.GlobalSecondaryIndexPropsV2;
77
77
  readonly Type: dynamodb.GlobalSecondaryIndexPropsV2;
78
78
  readonly Xid: dynamodb.GlobalSecondaryIndexPropsV2;
79
79
  };
@@ -2,13 +2,11 @@ import * as dynamodb from "aws-cdk-lib/aws-dynamodb";
2
2
  import { IHostedZone } from "aws-cdk-lib/aws-route53";
3
3
  import * as secretsmanager from "aws-cdk-lib/aws-secretsmanager";
4
4
  import { Construct } from "constructs";
5
- import { EnvironmentInput, SecretsArrayItem } from "./helpers";
6
- export interface DomainNameConfig {
7
- component?: string;
8
- domain?: string;
9
- env?: string;
10
- subdomain?: string;
11
- }
5
+ import { EnvironmentInput, HostConfig, SecretsArrayItem } from "./helpers";
6
+ /**
7
+ * @deprecated Use HostConfig instead. This alias is kept for backwards compatibility.
8
+ */
9
+ export type DomainNameConfig = HostConfig;
12
10
  export interface JaypieNextjsProps {
13
11
  datadogApiKeyArn?: string;
14
12
  /**
@@ -1,6 +1,11 @@
1
- export declare function envHostname({ component, domain, env, subdomain, }?: {
1
+ /**
2
+ * Configuration for resolving a hostname from parts.
3
+ * Used by envHostname() to construct domain names from environment and config.
4
+ */
5
+ export interface HostConfig {
2
6
  component?: string;
3
7
  domain?: string;
4
8
  env?: string;
5
9
  subdomain?: string;
6
- }): string;
10
+ }
11
+ export declare function envHostname({ component, domain, env, subdomain, }?: HostConfig): string;
@@ -2,7 +2,7 @@ export { addDatadogLayers } from "./addDatadogLayers";
2
2
  export { constructEnvName } from "./constructEnvName";
3
3
  export { constructStackName } from "./constructStackName";
4
4
  export { constructTagger } from "./constructTagger";
5
- export { envHostname } from "./envHostname";
5
+ export { envHostname, HostConfig } from "./envHostname";
6
6
  export { extendDatadogRole, ExtendDatadogRoleOptions, } from "./extendDatadogRole";
7
7
  export { clearAllCertificateCaches, clearCertificateCache, resolveCertificate, ResolveCertificateOptions, } from "./resolveCertificate";
8
8
  export { isEnv, isProductionEnv, isSandboxEnv } from "./isEnv";
@@ -1,6 +1,6 @@
1
1
  export { CDK, LAMBDA_WEB_ADAPTER } from "./constants";
2
2
  export { JaypieAccountLoggingBucket, JaypieAccountLoggingBucketProps, } from "./JaypieAccountLoggingBucket";
3
- export { JaypieApiGateway } from "./JaypieApiGateway";
3
+ export { JaypieApiGateway, JaypieApiGatewayProps, } from "./JaypieApiGateway";
4
4
  export { JaypieAppStack } from "./JaypieAppStack";
5
5
  export { JaypieBucketQueuedLambda } from "./JaypieBucketQueuedLambda";
6
6
  export { JaypieCertificate, JaypieCertificateProps, } from "./JaypieCertificate";
package/dist/esm/index.js CHANGED
@@ -1127,15 +1127,20 @@ class JaypieApiGateway extends Construct {
1127
1127
  zone = process.env.CDK_ENV_API_HOSTED_ZONE;
1128
1128
  }
1129
1129
  // Determine host from props or environment
1130
- let host = propsHost;
1131
- if (!host) {
1132
- if (process.env.CDK_ENV_API_HOST_NAME) {
1133
- host = process.env.CDK_ENV_API_HOST_NAME;
1134
- }
1135
- else if (process.env.CDK_ENV_API_SUBDOMAIN &&
1136
- process.env.CDK_ENV_API_HOSTED_ZONE) {
1137
- host = mergeDomain(process.env.CDK_ENV_API_SUBDOMAIN, process.env.CDK_ENV_API_HOSTED_ZONE);
1138
- }
1130
+ let host;
1131
+ if (typeof propsHost === "string") {
1132
+ host = propsHost;
1133
+ }
1134
+ else if (typeof propsHost === "object") {
1135
+ // Resolve host from HostConfig using envHostname()
1136
+ host = envHostname(propsHost);
1137
+ }
1138
+ else if (process.env.CDK_ENV_API_HOST_NAME) {
1139
+ host = process.env.CDK_ENV_API_HOST_NAME;
1140
+ }
1141
+ else if (process.env.CDK_ENV_API_SUBDOMAIN &&
1142
+ process.env.CDK_ENV_API_HOSTED_ZONE) {
1143
+ host = mergeDomain(process.env.CDK_ENV_API_SUBDOMAIN, process.env.CDK_ENV_API_HOSTED_ZONE);
1139
1144
  }
1140
1145
  const apiGatewayName = name || constructEnvName("ApiGateway");
1141
1146
  const apiDomainName = constructEnvName("ApiDomainName");
@@ -2340,8 +2345,20 @@ class JaypieDistribution extends Construct {
2340
2345
  throw new Error("CDK_ENV_HOSTED_ZONE is not a valid hostname");
2341
2346
  }
2342
2347
  // Determine host from props or environment
2343
- let host = propsHost;
2344
- if (!host) {
2348
+ let host;
2349
+ if (typeof propsHost === "string") {
2350
+ host = propsHost;
2351
+ }
2352
+ else if (typeof propsHost === "object") {
2353
+ // Resolve host from HostConfig using envHostname()
2354
+ try {
2355
+ host = envHostname(propsHost);
2356
+ }
2357
+ catch {
2358
+ host = undefined;
2359
+ }
2360
+ }
2361
+ else {
2345
2362
  try {
2346
2363
  if (process.env.CDK_ENV_API_HOST_NAME) {
2347
2364
  host = process.env.CDK_ENV_API_HOST_NAME;
@@ -2672,7 +2689,7 @@ class JaypieDnsRecord extends Construct {
2672
2689
  const GSI_NAMES = {
2673
2690
  ALIAS: "indexAlias",
2674
2691
  CLASS: "indexClass",
2675
- OU: "indexOu",
2692
+ SCOPE: "indexScope",
2676
2693
  TYPE: "indexType",
2677
2694
  XID: "indexXid",
2678
2695
  };
@@ -2699,9 +2716,9 @@ const GlobalSecondaryIndex = {
2699
2716
  projectionType: dynamodb.ProjectionType.ALL,
2700
2717
  sortKey: { name: "sequence", type: dynamodb.AttributeType.NUMBER },
2701
2718
  },
2702
- Ou: {
2703
- indexName: GSI_NAMES.OU,
2704
- partitionKey: { name: GSI_NAMES.OU, type: dynamodb.AttributeType.STRING },
2719
+ Scope: {
2720
+ indexName: GSI_NAMES.SCOPE,
2721
+ partitionKey: { name: GSI_NAMES.SCOPE, type: dynamodb.AttributeType.STRING },
2705
2722
  projectionType: dynamodb.ProjectionType.ALL,
2706
2723
  sortKey: { name: "sequence", type: dynamodb.AttributeType.NUMBER },
2707
2724
  },
@@ -2725,7 +2742,7 @@ const GlobalSecondaryIndex = {
2725
2742
  const GlobalSecondaryIndexes = [
2726
2743
  GlobalSecondaryIndex.Alias,
2727
2744
  GlobalSecondaryIndex.Class,
2728
- GlobalSecondaryIndex.Ou,
2745
+ GlobalSecondaryIndex.Scope,
2729
2746
  GlobalSecondaryIndex.Type,
2730
2747
  GlobalSecondaryIndex.Xid,
2731
2748
  ];
@@ -2758,7 +2775,7 @@ const GlobalSecondaryIndexes = [
2758
2775
  * // Use only specific GSIs
2759
2776
  * const table = new JaypieDynamoDb(this, "MyTable", {
2760
2777
  * globalSecondaryIndexes: [
2761
- * JaypieDynamoDb.GlobalSecondaryIndex.Ou,
2778
+ * JaypieDynamoDb.GlobalSecondaryIndex.Scope,
2762
2779
  * JaypieDynamoDb.GlobalSecondaryIndex.Type,
2763
2780
  * ],
2764
2781
  * });