@jaypie/constructs 1.1.57 → 1.1.59
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/JaypieNextJs.d.ts +17 -0
- package/dist/cjs/JaypieNextJs.test.d.ts +1 -0
- package/dist/cjs/helpers/resolveParamsAndSecrets.d.ts +1 -1
- package/dist/cjs/index.cjs +83 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/esm/JaypieNextJs.d.ts +17 -0
- package/dist/esm/JaypieNextJs.test.d.ts +1 -0
- package/dist/esm/helpers/resolveParamsAndSecrets.d.ts +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +82 -3
- package/dist/esm/index.js.map +1 -1
- package/package.json +3 -2
package/dist/cjs/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export { JaypieHostedZone, JaypieHostedZoneRecordProps, } from "./JaypieHostedZo
|
|
|
15
15
|
export { JaypieInfrastructureStack } from "./JaypieInfrastructureStack";
|
|
16
16
|
export { JaypieLambda } from "./JaypieLambda";
|
|
17
17
|
export { JaypieMongoDbSecret } from "./JaypieMongoDbSecret";
|
|
18
|
+
export { JaypieNextJs } from "./JaypieNextJs";
|
|
18
19
|
export { JaypieOpenAiSecret } from "./JaypieOpenAiSecret";
|
|
19
20
|
export { JaypieOrganizationTrail, JaypieOrganizationTrailProps, } from "./JaypieOrganizationTrail";
|
|
20
21
|
export { AccountAssignments, JaypieSsoPermissions, JaypieSsoPermissionsProps, } from "./JaypieSsoPermissions";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IHostedZone } from "aws-cdk-lib/aws-route53";
|
|
2
|
+
import * as secretsmanager from "aws-cdk-lib/aws-secretsmanager";
|
|
3
|
+
import { Construct } from "constructs";
|
|
4
|
+
import { JaypieEnvSecret } from "./JaypieEnvSecret.js";
|
|
5
|
+
export interface JaypieNextjsProps {
|
|
6
|
+
datadogApiKeyArn?: string;
|
|
7
|
+
domainName?: string;
|
|
8
|
+
envSecrets?: {
|
|
9
|
+
[key: string]: secretsmanager.ISecret;
|
|
10
|
+
};
|
|
11
|
+
hostedZone?: IHostedZone | string;
|
|
12
|
+
nextjsPath?: string;
|
|
13
|
+
secrets?: JaypieEnvSecret[];
|
|
14
|
+
}
|
|
15
|
+
export declare class JaypieNextJs extends Construct {
|
|
16
|
+
constructor(scope: Construct, id: string, props?: JaypieNextjsProps);
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -6,7 +6,7 @@ export interface ResolveParamsAndSecretsOptions {
|
|
|
6
6
|
parameterStoreTtl?: Duration;
|
|
7
7
|
secretsManagerTtl?: Duration;
|
|
8
8
|
}
|
|
9
|
-
export declare const resolveParamsAndSecrets: ({ paramsAndSecrets, options, }
|
|
9
|
+
export declare const resolveParamsAndSecrets: ({ paramsAndSecrets, options, }?: {
|
|
10
10
|
paramsAndSecrets?: lambda.ParamsAndSecretsLayerVersion | boolean;
|
|
11
11
|
options?: ResolveParamsAndSecretsOptions;
|
|
12
12
|
}) => lambda.ParamsAndSecretsLayerVersion | undefined;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export { JaypieHostedZone, JaypieHostedZoneRecordProps, } from "./JaypieHostedZo
|
|
|
15
15
|
export { JaypieInfrastructureStack } from "./JaypieInfrastructureStack";
|
|
16
16
|
export { JaypieLambda } from "./JaypieLambda";
|
|
17
17
|
export { JaypieMongoDbSecret } from "./JaypieMongoDbSecret";
|
|
18
|
+
export { JaypieNextJs } from "./JaypieNextJs";
|
|
18
19
|
export { JaypieOpenAiSecret } from "./JaypieOpenAiSecret";
|
|
19
20
|
export { JaypieOrganizationTrail, JaypieOrganizationTrailProps, } from "./JaypieOrganizationTrail";
|
|
20
21
|
export { AccountAssignments, JaypieSsoPermissions, JaypieSsoPermissionsProps, } from "./JaypieSsoPermissions";
|
package/dist/esm/index.js
CHANGED
|
@@ -21,6 +21,9 @@ import * as lambdaEventSources from 'aws-cdk-lib/aws-lambda-event-sources';
|
|
|
21
21
|
import { Rule, RuleTargetInput } from 'aws-cdk-lib/aws-events';
|
|
22
22
|
import { LambdaFunction } from 'aws-cdk-lib/aws-events-targets';
|
|
23
23
|
import { LogGroup, RetentionDays, FilterPattern } from 'aws-cdk-lib/aws-logs';
|
|
24
|
+
import { envHostname as envHostname$1, jaypieLambdaEnv as jaypieLambdaEnv$1, resolveHostedZone as resolveHostedZone$1 } from '@jaypie/constructs';
|
|
25
|
+
import { Nextjs } from 'cdk-nextjs-standalone';
|
|
26
|
+
import * as path from 'path';
|
|
24
27
|
import { Trail, ReadWriteType } from 'aws-cdk-lib/aws-cloudtrail';
|
|
25
28
|
import { CfnPermissionSet, CfnAssignment } from 'aws-cdk-lib/aws-sso';
|
|
26
29
|
import { CfnApplication } from 'aws-cdk-lib/aws-sam';
|
|
@@ -359,10 +362,11 @@ function envHostname({ component, domain, env, subdomain, } = {}) {
|
|
|
359
362
|
const resolvedComponent = component === "@" || component === "" ? undefined : component;
|
|
360
363
|
const resolvedSubdomain = subdomain || process.env.CDK_ENV_SUBDOMAIN;
|
|
361
364
|
const resolvedEnv = env || process.env.PROJECT_ENV;
|
|
365
|
+
const filteredEnv = resolvedEnv === CDK$2.ENV.PRODUCTION ? undefined : resolvedEnv;
|
|
362
366
|
const parts = [
|
|
363
367
|
resolvedComponent,
|
|
364
368
|
resolvedSubdomain,
|
|
365
|
-
|
|
369
|
+
filteredEnv,
|
|
366
370
|
resolvedDomain,
|
|
367
371
|
].filter((part) => part);
|
|
368
372
|
return parts.join(".");
|
|
@@ -665,7 +669,7 @@ function resolveHostedZone(scope, { name = "HostedZone", zone = process.env.CDK_
|
|
|
665
669
|
return zone;
|
|
666
670
|
}
|
|
667
671
|
|
|
668
|
-
const resolveParamsAndSecrets = ({ paramsAndSecrets, options, }) => {
|
|
672
|
+
const resolveParamsAndSecrets = ({ paramsAndSecrets, options, } = {}) => {
|
|
669
673
|
if (paramsAndSecrets === false) {
|
|
670
674
|
return;
|
|
671
675
|
}
|
|
@@ -2161,6 +2165,81 @@ class JaypieMongoDbSecret extends JaypieEnvSecret {
|
|
|
2161
2165
|
}
|
|
2162
2166
|
}
|
|
2163
2167
|
|
|
2168
|
+
class JaypieNextJs extends Construct {
|
|
2169
|
+
constructor(scope, id, props) {
|
|
2170
|
+
super(scope, id);
|
|
2171
|
+
const domainName = props?.domainName || envHostname$1();
|
|
2172
|
+
const domainNameSanitized = domainName
|
|
2173
|
+
.replace(/\./g, "-")
|
|
2174
|
+
.replace(/[^a-zA-Z0-9]/g, "_");
|
|
2175
|
+
const envSecrets = props?.envSecrets || {};
|
|
2176
|
+
const nextjsPath = props?.nextjsPath?.startsWith("..")
|
|
2177
|
+
? path.join(process.cwd(), props.nextjsPath)
|
|
2178
|
+
: props?.nextjsPath || path.join(process.cwd(), "..", "nextjs");
|
|
2179
|
+
const paramsAndSecrets = resolveParamsAndSecrets();
|
|
2180
|
+
const secrets = props?.secrets || [];
|
|
2181
|
+
// Process secrets environment variables
|
|
2182
|
+
const secretsEnvironment = Object.entries(envSecrets).reduce((acc, [key, secret]) => ({
|
|
2183
|
+
...acc,
|
|
2184
|
+
[`SECRET_${key}`]: secret.secretName,
|
|
2185
|
+
}), {});
|
|
2186
|
+
// Process JaypieEnvSecret array
|
|
2187
|
+
const jaypieSecretsEnvironment = secrets.reduce((acc, secret) => {
|
|
2188
|
+
if (secret.envKey) {
|
|
2189
|
+
return {
|
|
2190
|
+
...acc,
|
|
2191
|
+
[`SECRET_${secret.envKey}`]: secret.secretName,
|
|
2192
|
+
};
|
|
2193
|
+
}
|
|
2194
|
+
return acc;
|
|
2195
|
+
}, {});
|
|
2196
|
+
const nextjs = new Nextjs(this, "NextJsApp", {
|
|
2197
|
+
nextjsPath,
|
|
2198
|
+
domainProps: {
|
|
2199
|
+
domainName,
|
|
2200
|
+
hostedZone: resolveHostedZone$1(this, {
|
|
2201
|
+
zone: props?.hostedZone,
|
|
2202
|
+
}),
|
|
2203
|
+
},
|
|
2204
|
+
environment: {
|
|
2205
|
+
...jaypieLambdaEnv$1(),
|
|
2206
|
+
...secretsEnvironment,
|
|
2207
|
+
...jaypieSecretsEnvironment,
|
|
2208
|
+
},
|
|
2209
|
+
overrides: {
|
|
2210
|
+
nextjsDistribution: {
|
|
2211
|
+
imageCachePolicyProps: {
|
|
2212
|
+
cachePolicyName: `NextJsImageCachePolicy-${domainNameSanitized}`,
|
|
2213
|
+
},
|
|
2214
|
+
serverCachePolicyProps: {
|
|
2215
|
+
cachePolicyName: `NextJsServerCachePolicy-${domainNameSanitized}`,
|
|
2216
|
+
},
|
|
2217
|
+
},
|
|
2218
|
+
nextjsImage: {
|
|
2219
|
+
functionProps: {
|
|
2220
|
+
paramsAndSecrets,
|
|
2221
|
+
},
|
|
2222
|
+
},
|
|
2223
|
+
nextjsServer: {
|
|
2224
|
+
functionProps: {
|
|
2225
|
+
paramsAndSecrets,
|
|
2226
|
+
},
|
|
2227
|
+
},
|
|
2228
|
+
},
|
|
2229
|
+
});
|
|
2230
|
+
addDatadogLayers(nextjs.imageOptimizationFunction);
|
|
2231
|
+
addDatadogLayers(nextjs.serverFunction.lambdaFunction);
|
|
2232
|
+
// Grant secret read permissions
|
|
2233
|
+
Object.values(envSecrets).forEach((secret) => {
|
|
2234
|
+
secret.grantRead(nextjs.serverFunction.lambdaFunction);
|
|
2235
|
+
});
|
|
2236
|
+
// Grant read permissions for JaypieEnvSecrets
|
|
2237
|
+
secrets.forEach((secret) => {
|
|
2238
|
+
secret.grantRead(nextjs.serverFunction.lambdaFunction);
|
|
2239
|
+
});
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2164
2243
|
class JaypieOpenAiSecret extends JaypieEnvSecret {
|
|
2165
2244
|
constructor(scope, id = "OpenAiApiKey", props) {
|
|
2166
2245
|
const defaultProps = {
|
|
@@ -2882,5 +2961,5 @@ class JaypieWebDeploymentBucket extends Construct {
|
|
|
2882
2961
|
}
|
|
2883
2962
|
}
|
|
2884
2963
|
|
|
2885
|
-
export { CDK$2 as CDK, JaypieAccountLoggingBucket, JaypieApiGateway, JaypieAppStack, JaypieBucketQueuedLambda, JaypieDatadogBucket, JaypieDatadogForwarder, JaypieDatadogSecret, JaypieDnsRecord, JaypieEnvSecret, JaypieEventsRule, JaypieExpressLambda, JaypieGitHubDeployRole, JaypieHostedZone, JaypieInfrastructureStack, JaypieLambda, JaypieMongoDbSecret, JaypieOpenAiSecret, JaypieOrganizationTrail, JaypieQueuedLambda, JaypieSsoPermissions, JaypieSsoSyncApplication, JaypieStack, JaypieTraceSigningKeySecret, JaypieWebDeploymentBucket, addDatadogLayers, constructEnvName, constructStackName, constructTagger, envHostname, extendDatadogRole, isEnv, isProductionEnv, isSandboxEnv, isValidHostname$1 as isValidHostname, isValidSubdomain, jaypieLambdaEnv, mergeDomain, resolveDatadogForwarderFunction, resolveDatadogLayers, resolveDatadogLoggingDestination, resolveHostedZone, resolveParamsAndSecrets };
|
|
2964
|
+
export { CDK$2 as CDK, JaypieAccountLoggingBucket, JaypieApiGateway, JaypieAppStack, JaypieBucketQueuedLambda, JaypieDatadogBucket, JaypieDatadogForwarder, JaypieDatadogSecret, JaypieDnsRecord, JaypieEnvSecret, JaypieEventsRule, JaypieExpressLambda, JaypieGitHubDeployRole, JaypieHostedZone, JaypieInfrastructureStack, JaypieLambda, JaypieMongoDbSecret, JaypieNextJs, JaypieOpenAiSecret, JaypieOrganizationTrail, JaypieQueuedLambda, JaypieSsoPermissions, JaypieSsoSyncApplication, JaypieStack, JaypieTraceSigningKeySecret, JaypieWebDeploymentBucket, addDatadogLayers, constructEnvName, constructStackName, constructTagger, envHostname, extendDatadogRole, isEnv, isProductionEnv, isSandboxEnv, isValidHostname$1 as isValidHostname, isValidSubdomain, jaypieLambdaEnv, mergeDomain, resolveDatadogForwarderFunction, resolveDatadogLayers, resolveDatadogLoggingDestination, resolveHostedZone, resolveParamsAndSecrets };
|
|
2886
2965
|
//# sourceMappingURL=index.js.map
|