@jaypie/constructs 1.1.39 → 1.1.40
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/JaypieWebDeploymentBucket.d.ts +1 -0
- package/dist/cjs/helpers/__tests__/envHostname.spec.d.ts +1 -0
- package/dist/cjs/helpers/constructTagger.d.ts +4 -0
- package/dist/cjs/helpers/envHostname.d.ts +6 -0
- package/dist/cjs/helpers/index.d.ts +2 -1
- package/dist/cjs/index.cjs +155 -134
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/JaypieWebDeploymentBucket.d.ts +1 -0
- package/dist/esm/helpers/__tests__/envHostname.spec.d.ts +1 -0
- package/dist/esm/helpers/constructTagger.d.ts +4 -0
- package/dist/esm/helpers/envHostname.d.ts +6 -0
- package/dist/esm/helpers/index.d.ts +2 -1
- package/dist/esm/index.js +57 -37
- package/dist/esm/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/cjs/helpers/stackTagger.d.ts +0 -4
- package/dist/esm/helpers/stackTagger.d.ts +0 -4
|
@@ -62,6 +62,7 @@ export declare class JaypieWebDeploymentBucket extends Construct implements s3.I
|
|
|
62
62
|
grantRead(identity: any, objectsKeyPattern?: any): any;
|
|
63
63
|
grantReadWrite(identity: any, objectsKeyPattern?: any): any;
|
|
64
64
|
grantWrite(identity: any, objectsKeyPattern?: any): any;
|
|
65
|
+
grantReplicationPermission(identity: any, props: any): any;
|
|
65
66
|
s3UrlForObject(key?: string): string;
|
|
66
67
|
urlForObject(key?: string): string;
|
|
67
68
|
virtualHostedUrlForObject(key?: string, options?: s3.VirtualHostedStyleUrlOptions): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { constructEnvName } from "./constructEnvName";
|
|
2
2
|
export { constructStackName } from "./constructStackName";
|
|
3
|
+
export { constructTagger } from "./constructTagger";
|
|
4
|
+
export { envHostname } from "./envHostname";
|
|
3
5
|
export { isEnv, isProductionEnv, isSandboxEnv } from "./isEnv";
|
|
4
|
-
export { stackTagger } from "./stackTagger";
|
package/dist/esm/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import * as apiGateway from 'aws-cdk-lib/aws-apigateway';
|
|
|
6
6
|
import * as route53 from 'aws-cdk-lib/aws-route53';
|
|
7
7
|
import { HostedZone } from 'aws-cdk-lib/aws-route53';
|
|
8
8
|
import * as route53Targets from 'aws-cdk-lib/aws-route53-targets';
|
|
9
|
-
import { CDK as CDK$2, mergeDomain, isValidSubdomain,
|
|
9
|
+
import { ConfigurationError, CDK as CDK$2, mergeDomain, isValidSubdomain, isValidHostname } from '@jaypie/cdk';
|
|
10
10
|
import * as s3 from 'aws-cdk-lib/aws-s3';
|
|
11
11
|
import * as s3n from 'aws-cdk-lib/aws-s3-notifications';
|
|
12
12
|
import * as lambda from 'aws-cdk-lib/aws-lambda';
|
|
@@ -22,7 +22,7 @@ import * as origins from 'aws-cdk-lib/aws-cloudfront-origins';
|
|
|
22
22
|
function constructEnvName(name, opts) {
|
|
23
23
|
const env = opts?.env ?? process.env.PROJECT_ENV ?? "build";
|
|
24
24
|
const key = opts?.key ?? process.env.PROJECT_KEY ?? "project";
|
|
25
|
-
const nonce = opts?.nonce ?? process.env.PROJECT_NONCE ?? "cfe2";
|
|
25
|
+
const nonce = opts?.nonce ?? process.env.PROJECT_NONCE ?? "cfe2"; // This default is intentionally short. It is not a special value but should not be changed.
|
|
26
26
|
return `${env}-${key}-${name}-${nonce}`;
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -35,25 +35,6 @@ function constructStackName(key) {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
/**
|
|
39
|
-
* Check if the current environment matches the given environment
|
|
40
|
-
*/
|
|
41
|
-
function isEnv(env) {
|
|
42
|
-
return process.env.PROJECT_ENV === env;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Check if the current environment is production
|
|
46
|
-
*/
|
|
47
|
-
function isProductionEnv() {
|
|
48
|
-
return isEnv(CDK$2.ENV.PRODUCTION);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Check if the current environment is sandbox
|
|
52
|
-
*/
|
|
53
|
-
function isSandboxEnv() {
|
|
54
|
-
return isEnv(CDK$2.ENV.SANDBOX);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
38
|
const CDK$1 = {
|
|
58
39
|
CREATION: {
|
|
59
40
|
CDK: "cdk",
|
|
@@ -77,35 +58,71 @@ const CDK$1 = {
|
|
|
77
58
|
VERSION: "version",
|
|
78
59
|
},
|
|
79
60
|
};
|
|
80
|
-
function
|
|
61
|
+
function constructTagger(construct, { name } = {}) {
|
|
81
62
|
const stackName = name || constructStackName();
|
|
82
63
|
const version = process.env.npm_package_version || process.env.PROJECT_VERSION || null;
|
|
83
64
|
if (process.env.PROJECT_COMMIT && process.env.PROJECT_COMMIT.length > 8) {
|
|
84
|
-
Tags.of(
|
|
65
|
+
Tags.of(construct).add(CDK$1.TAG.BUILD_HEX, process.env.PROJECT_COMMIT.slice(0, 8));
|
|
85
66
|
}
|
|
86
|
-
Tags.of(
|
|
87
|
-
Tags.of(
|
|
67
|
+
Tags.of(construct).add(CDK$1.TAG.BUILD_DATE, new Date().toISOString());
|
|
68
|
+
Tags.of(construct).add(CDK$1.TAG.BUILD_TIME, Date.now().toString());
|
|
88
69
|
if (process.env.PROJECT_COMMIT)
|
|
89
|
-
Tags.of(
|
|
90
|
-
Tags.of(
|
|
70
|
+
Tags.of(construct).add(CDK$1.TAG.COMMIT, process.env.PROJECT_COMMIT);
|
|
71
|
+
Tags.of(construct).add(CDK$1.TAG.CREATION, CDK$1.CREATION.CDK);
|
|
91
72
|
if (process.env.PROJECT_ENV)
|
|
92
|
-
Tags.of(
|
|
73
|
+
Tags.of(construct).add(CDK$1.TAG.ENV, process.env.PROJECT_ENV);
|
|
93
74
|
if (process.env.PROJECT_NONCE)
|
|
94
|
-
Tags.of(
|
|
75
|
+
Tags.of(construct).add(CDK$1.TAG.NONCE, process.env.PROJECT_NONCE);
|
|
95
76
|
if (process.env.PROJECT_KEY)
|
|
96
|
-
Tags.of(
|
|
97
|
-
Tags.of(
|
|
77
|
+
Tags.of(construct).add(CDK$1.TAG.PROJECT, process.env.PROJECT_KEY);
|
|
78
|
+
Tags.of(construct).add(CDK$1.TAG.ROLE, CDK$1.ROLE.STACK);
|
|
98
79
|
if (process.env.PROJECT_SERVICE)
|
|
99
|
-
Tags.of(
|
|
80
|
+
Tags.of(construct).add(CDK$1.TAG.SERVICE, process.env.PROJECT_SERVICE);
|
|
100
81
|
if (process.env.PROJECT_SPONSOR)
|
|
101
|
-
Tags.of(
|
|
82
|
+
Tags.of(construct).add(CDK$1.TAG.SPONSOR, process.env.PROJECT_SPONSOR);
|
|
102
83
|
if (stackName)
|
|
103
|
-
Tags.of(
|
|
84
|
+
Tags.of(construct).add(CDK$1.TAG.STACK, stackName);
|
|
104
85
|
if (version)
|
|
105
|
-
Tags.of(
|
|
86
|
+
Tags.of(construct).add(CDK$1.TAG.VERSION, version);
|
|
106
87
|
return true;
|
|
107
88
|
}
|
|
108
89
|
|
|
90
|
+
function envHostname({ component, domain, env, subdomain, }) {
|
|
91
|
+
const resolvedDomain = domain || process.env.CDK_ENV_DOMAIN || process.env.CDK_ENV_HOSTED_ZONE;
|
|
92
|
+
if (!resolvedDomain) {
|
|
93
|
+
throw new ConfigurationError("No hostname `domain` provided. Set CDK_ENV_DOMAIN or CDK_ENV_HOSTED_ZONE to use environment domain");
|
|
94
|
+
}
|
|
95
|
+
const resolvedComponent = component === "@" || component === "" ? undefined : component;
|
|
96
|
+
const resolvedSubdomain = subdomain || process.env.CDK_ENV_SUBDOMAIN;
|
|
97
|
+
const resolvedEnv = env || process.env.PROJECT_ENV;
|
|
98
|
+
const parts = [
|
|
99
|
+
resolvedComponent,
|
|
100
|
+
resolvedSubdomain,
|
|
101
|
+
resolvedEnv,
|
|
102
|
+
resolvedDomain,
|
|
103
|
+
].filter((part) => part);
|
|
104
|
+
return parts.join(".");
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Check if the current environment matches the given environment
|
|
109
|
+
*/
|
|
110
|
+
function isEnv(env) {
|
|
111
|
+
return process.env.PROJECT_ENV === env;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Check if the current environment is production
|
|
115
|
+
*/
|
|
116
|
+
function isProductionEnv() {
|
|
117
|
+
return isEnv(CDK$2.ENV.PRODUCTION);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Check if the current environment is sandbox
|
|
121
|
+
*/
|
|
122
|
+
function isSandboxEnv() {
|
|
123
|
+
return isEnv(CDK$2.ENV.SANDBOX);
|
|
124
|
+
}
|
|
125
|
+
|
|
109
126
|
class JaypieApiGateway extends Construct {
|
|
110
127
|
constructor(scope, id, props) {
|
|
111
128
|
super(scope, id);
|
|
@@ -271,7 +288,7 @@ class JaypieStack extends Stack {
|
|
|
271
288
|
};
|
|
272
289
|
super(scope, id, stackProps);
|
|
273
290
|
// Apply tags
|
|
274
|
-
|
|
291
|
+
constructTagger(this, { name: stackProps.stackName });
|
|
275
292
|
}
|
|
276
293
|
}
|
|
277
294
|
|
|
@@ -1702,6 +1719,9 @@ class JaypieWebDeploymentBucket extends Construct {
|
|
|
1702
1719
|
grantWrite(identity, objectsKeyPattern) {
|
|
1703
1720
|
return this.bucket.grantWrite(identity, objectsKeyPattern);
|
|
1704
1721
|
}
|
|
1722
|
+
grantReplicationPermission(identity, props) {
|
|
1723
|
+
return this.bucket.grantReplicationPermission(identity, props);
|
|
1724
|
+
}
|
|
1705
1725
|
s3UrlForObject(key) {
|
|
1706
1726
|
return this.bucket.s3UrlForObject(key);
|
|
1707
1727
|
}
|
|
@@ -1752,5 +1772,5 @@ class JaypieWebDeploymentBucket extends Construct {
|
|
|
1752
1772
|
}
|
|
1753
1773
|
}
|
|
1754
1774
|
|
|
1755
|
-
export { JaypieApiGateway, JaypieAppStack, JaypieBucketQueuedLambda, JaypieDatadogSecret, JaypieEnvSecret, JaypieExpressLambda, JaypieHostedZone, JaypieInfrastructureStack, JaypieLambda, JaypieMongoDbSecret, JaypieOpenAiSecret, JaypieQueuedLambda, JaypieSsoGroups, JaypieStack, JaypieTraceSigningKeySecret, JaypieWebDeploymentBucket, PermissionSetType, constructEnvName, constructStackName, isEnv, isProductionEnv, isSandboxEnv
|
|
1775
|
+
export { JaypieApiGateway, JaypieAppStack, JaypieBucketQueuedLambda, JaypieDatadogSecret, JaypieEnvSecret, JaypieExpressLambda, JaypieHostedZone, JaypieInfrastructureStack, JaypieLambda, JaypieMongoDbSecret, JaypieOpenAiSecret, JaypieQueuedLambda, JaypieSsoGroups, JaypieStack, JaypieTraceSigningKeySecret, JaypieWebDeploymentBucket, PermissionSetType, constructEnvName, constructStackName, constructTagger, envHostname, isEnv, isProductionEnv, isSandboxEnv };
|
|
1756
1776
|
//# sourceMappingURL=index.js.map
|