@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.
- package/dist/cjs/JaypieApiGateway.d.ts +18 -1
- package/dist/cjs/JaypieDistribution.d.ts +17 -2
- package/dist/cjs/JaypieDynamoDb.d.ts +3 -3
- package/dist/cjs/JaypieNextJs.d.ts +5 -7
- package/dist/cjs/helpers/envHostname.d.ts +7 -2
- package/dist/cjs/helpers/index.d.ts +1 -1
- package/dist/cjs/index.cjs +34 -17
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/esm/JaypieApiGateway.d.ts +18 -1
- package/dist/esm/JaypieDistribution.d.ts +17 -2
- package/dist/esm/JaypieDynamoDb.d.ts +3 -3
- package/dist/esm/JaypieNextJs.d.ts +5 -7
- package/dist/esm/helpers/envHostname.d.ts +7 -2
- package/dist/esm/helpers/index.d.ts +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +34 -17
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -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
|
-
|
|
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,
|
|
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.
|
|
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
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
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
|
-
}
|
|
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";
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1159,15 +1159,20 @@ class JaypieApiGateway extends constructs.Construct {
|
|
|
1159
1159
|
zone = process.env.CDK_ENV_API_HOSTED_ZONE;
|
|
1160
1160
|
}
|
|
1161
1161
|
// Determine host from props or environment
|
|
1162
|
-
let host
|
|
1163
|
-
if (
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1162
|
+
let host;
|
|
1163
|
+
if (typeof propsHost === "string") {
|
|
1164
|
+
host = propsHost;
|
|
1165
|
+
}
|
|
1166
|
+
else if (typeof propsHost === "object") {
|
|
1167
|
+
// Resolve host from HostConfig using envHostname()
|
|
1168
|
+
host = envHostname(propsHost);
|
|
1169
|
+
}
|
|
1170
|
+
else if (process.env.CDK_ENV_API_HOST_NAME) {
|
|
1171
|
+
host = process.env.CDK_ENV_API_HOST_NAME;
|
|
1172
|
+
}
|
|
1173
|
+
else if (process.env.CDK_ENV_API_SUBDOMAIN &&
|
|
1174
|
+
process.env.CDK_ENV_API_HOSTED_ZONE) {
|
|
1175
|
+
host = mergeDomain(process.env.CDK_ENV_API_SUBDOMAIN, process.env.CDK_ENV_API_HOSTED_ZONE);
|
|
1171
1176
|
}
|
|
1172
1177
|
const apiGatewayName = name || constructEnvName("ApiGateway");
|
|
1173
1178
|
const apiDomainName = constructEnvName("ApiDomainName");
|
|
@@ -2372,8 +2377,20 @@ class JaypieDistribution extends constructs.Construct {
|
|
|
2372
2377
|
throw new Error("CDK_ENV_HOSTED_ZONE is not a valid hostname");
|
|
2373
2378
|
}
|
|
2374
2379
|
// Determine host from props or environment
|
|
2375
|
-
let host
|
|
2376
|
-
if (
|
|
2380
|
+
let host;
|
|
2381
|
+
if (typeof propsHost === "string") {
|
|
2382
|
+
host = propsHost;
|
|
2383
|
+
}
|
|
2384
|
+
else if (typeof propsHost === "object") {
|
|
2385
|
+
// Resolve host from HostConfig using envHostname()
|
|
2386
|
+
try {
|
|
2387
|
+
host = envHostname(propsHost);
|
|
2388
|
+
}
|
|
2389
|
+
catch {
|
|
2390
|
+
host = undefined;
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
else {
|
|
2377
2394
|
try {
|
|
2378
2395
|
if (process.env.CDK_ENV_API_HOST_NAME) {
|
|
2379
2396
|
host = process.env.CDK_ENV_API_HOST_NAME;
|
|
@@ -2704,7 +2721,7 @@ class JaypieDnsRecord extends constructs.Construct {
|
|
|
2704
2721
|
const GSI_NAMES = {
|
|
2705
2722
|
ALIAS: "indexAlias",
|
|
2706
2723
|
CLASS: "indexClass",
|
|
2707
|
-
|
|
2724
|
+
SCOPE: "indexScope",
|
|
2708
2725
|
TYPE: "indexType",
|
|
2709
2726
|
XID: "indexXid",
|
|
2710
2727
|
};
|
|
@@ -2731,9 +2748,9 @@ const GlobalSecondaryIndex = {
|
|
|
2731
2748
|
projectionType: dynamodb__namespace.ProjectionType.ALL,
|
|
2732
2749
|
sortKey: { name: "sequence", type: dynamodb__namespace.AttributeType.NUMBER },
|
|
2733
2750
|
},
|
|
2734
|
-
|
|
2735
|
-
indexName: GSI_NAMES.
|
|
2736
|
-
partitionKey: { name: GSI_NAMES.
|
|
2751
|
+
Scope: {
|
|
2752
|
+
indexName: GSI_NAMES.SCOPE,
|
|
2753
|
+
partitionKey: { name: GSI_NAMES.SCOPE, type: dynamodb__namespace.AttributeType.STRING },
|
|
2737
2754
|
projectionType: dynamodb__namespace.ProjectionType.ALL,
|
|
2738
2755
|
sortKey: { name: "sequence", type: dynamodb__namespace.AttributeType.NUMBER },
|
|
2739
2756
|
},
|
|
@@ -2757,7 +2774,7 @@ const GlobalSecondaryIndex = {
|
|
|
2757
2774
|
const GlobalSecondaryIndexes = [
|
|
2758
2775
|
GlobalSecondaryIndex.Alias,
|
|
2759
2776
|
GlobalSecondaryIndex.Class,
|
|
2760
|
-
GlobalSecondaryIndex.
|
|
2777
|
+
GlobalSecondaryIndex.Scope,
|
|
2761
2778
|
GlobalSecondaryIndex.Type,
|
|
2762
2779
|
GlobalSecondaryIndex.Xid,
|
|
2763
2780
|
];
|
|
@@ -2790,7 +2807,7 @@ const GlobalSecondaryIndexes = [
|
|
|
2790
2807
|
* // Use only specific GSIs
|
|
2791
2808
|
* const table = new JaypieDynamoDb(this, "MyTable", {
|
|
2792
2809
|
* globalSecondaryIndexes: [
|
|
2793
|
-
* JaypieDynamoDb.GlobalSecondaryIndex.
|
|
2810
|
+
* JaypieDynamoDb.GlobalSecondaryIndex.Scope,
|
|
2794
2811
|
* JaypieDynamoDb.GlobalSecondaryIndex.Type,
|
|
2795
2812
|
* ],
|
|
2796
2813
|
* });
|