@gradientedge/cdk-utils 8.135.0 → 8.137.0

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.
Files changed (47) hide show
  1. package/dist/src/lib/azure/services/storage/main.d.ts +3 -1
  2. package/dist/src/lib/azure/services/storage/main.js +12 -10
  3. package/dist/src/lib/azure/services/storage/types.d.ts +3 -3
  4. package/dist/src/lib/azure/types/index.d.ts +1 -1
  5. package/dist/src/lib/azure/utils/index.d.ts +1 -1
  6. package/dist/src/lib/azure/utils/index.js +3 -3
  7. package/dist/src/lib/cloudflare/common/construct.d.ts +35 -0
  8. package/dist/src/lib/cloudflare/common/construct.js +49 -0
  9. package/dist/src/lib/cloudflare/common/index.d.ts +3 -0
  10. package/dist/src/lib/cloudflare/common/index.js +19 -0
  11. package/dist/src/lib/cloudflare/common/stack.d.ts +52 -0
  12. package/dist/src/lib/cloudflare/common/stack.js +134 -0
  13. package/dist/src/lib/cloudflare/common/types.d.ts +7 -0
  14. package/dist/src/lib/cloudflare/common/types.js +2 -0
  15. package/dist/src/lib/cloudflare/index.d.ts +4 -0
  16. package/dist/src/lib/cloudflare/index.js +20 -0
  17. package/dist/src/lib/cloudflare/services/index.d.ts +1 -0
  18. package/dist/src/lib/cloudflare/services/index.js +17 -0
  19. package/dist/src/lib/cloudflare/services/zone/index.d.ts +2 -0
  20. package/dist/src/lib/cloudflare/services/zone/index.js +18 -0
  21. package/dist/src/lib/cloudflare/services/zone/main.d.ts +86 -0
  22. package/dist/src/lib/cloudflare/services/zone/main.js +188 -0
  23. package/dist/src/lib/cloudflare/services/zone/types.d.ts +25 -0
  24. package/dist/src/lib/cloudflare/services/zone/types.js +2 -0
  25. package/dist/src/lib/cloudflare/types/index.d.ts +3 -0
  26. package/dist/src/lib/cloudflare/types/index.js +2 -0
  27. package/dist/src/lib/cloudflare/utils/index.d.ts +3 -0
  28. package/dist/src/lib/cloudflare/utils/index.js +20 -0
  29. package/dist/src/lib/index.d.ts +1 -0
  30. package/dist/src/lib/index.js +1 -0
  31. package/package.json +14 -12
  32. package/src/lib/azure/services/storage/main.ts +13 -11
  33. package/src/lib/azure/services/storage/types.ts +3 -3
  34. package/src/lib/azure/types/index.ts +1 -1
  35. package/src/lib/azure/utils/index.ts +1 -1
  36. package/src/lib/cloudflare/common/construct.ts +57 -0
  37. package/src/lib/cloudflare/common/index.ts +3 -0
  38. package/src/lib/cloudflare/common/stack.ts +143 -0
  39. package/src/lib/cloudflare/common/types.ts +8 -0
  40. package/src/lib/cloudflare/index.ts +4 -0
  41. package/src/lib/cloudflare/services/index.ts +1 -0
  42. package/src/lib/cloudflare/services/zone/index.ts +2 -0
  43. package/src/lib/cloudflare/services/zone/main.ts +218 -0
  44. package/src/lib/cloudflare/services/zone/types.ts +19 -0
  45. package/src/lib/cloudflare/types/index.ts +3 -0
  46. package/src/lib/cloudflare/utils/index.ts +23 -0
  47. package/src/lib/index.ts +1 -0
@@ -15,7 +15,6 @@ import { StorageAccountProps, StorageBlobProps, StorageContainerProps } from './
15
15
  * this.storageManager.createStorageAccount('MyAccount', this, props)
16
16
  * }
17
17
  * }
18
- * @see [CDKTF S3 Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3-readme.html}
19
18
  * ```
20
19
  */
21
20
  export declare class AzureStorageManager {
@@ -24,6 +23,7 @@ export declare class AzureStorageManager {
24
23
  * @param id scoped id of the resource
25
24
  * @param scope scope in which this resource is defined
26
25
  * @param props storage account properties
26
+ * @see [CDKTF Storage Account Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/storageAccount.typescript.md}
27
27
  */
28
28
  createStorageAccount(id: string, scope: CommonAzureConstruct, props: StorageAccountProps): void;
29
29
  /**
@@ -31,6 +31,7 @@ export declare class AzureStorageManager {
31
31
  * @param id scoped id of the resource
32
32
  * @param scope scope in which this resource is defined
33
33
  * @param props storage container properties
34
+ * @see [CDKTF Storage Container Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/storageContainer.typescript.md}
34
35
  */
35
36
  createStorageContainer(id: string, scope: CommonAzureConstruct, props: StorageContainerProps): void;
36
37
  /**
@@ -38,6 +39,7 @@ export declare class AzureStorageManager {
38
39
  * @param id scoped id of the resource
39
40
  * @param scope scope in which this resource is defined
40
41
  * @param props storage blob properties
42
+ * @see [CDKTF Storage Blob Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/storageBlob.typescript.md}
41
43
  */
42
44
  createStorageBlob(id: string, scope: CommonAzureConstruct, props: StorageBlobProps): void;
43
45
  }
@@ -23,7 +23,6 @@ const utils_1 = require("../../utils");
23
23
  * this.storageManager.createStorageAccount('MyAccount', this, props)
24
24
  * }
25
25
  * }
26
- * @see [CDKTF S3 Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3-readme.html}
27
26
  * ```
28
27
  */
29
28
  class AzureStorageManager {
@@ -32,6 +31,7 @@ class AzureStorageManager {
32
31
  * @param id scoped id of the resource
33
32
  * @param scope scope in which this resource is defined
34
33
  * @param props storage account properties
34
+ * @see [CDKTF Storage Account Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/storageAccount.typescript.md}
35
35
  */
36
36
  createStorageAccount(id, scope, props) {
37
37
  if (!props)
@@ -53,15 +53,16 @@ class AzureStorageManager {
53
53
  environment: scope.props.stage,
54
54
  },
55
55
  });
56
- (0, utils_1.createTfOutput)(`${id}-storageAccountName`, scope, storageAccount.name);
57
- (0, utils_1.createTfOutput)(`${id}-storageAccountFriendlyUniqueId`, scope, storageAccount.friendlyUniqueId);
58
- (0, utils_1.createTfOutput)(`${id}-storageAccountId`, scope, storageAccount.id);
56
+ (0, utils_1.createAzureTfOutput)(`${id}-storageAccountName`, scope, storageAccount.name);
57
+ (0, utils_1.createAzureTfOutput)(`${id}-storageAccountFriendlyUniqueId`, scope, storageAccount.friendlyUniqueId);
58
+ (0, utils_1.createAzureTfOutput)(`${id}-storageAccountId`, scope, storageAccount.id);
59
59
  }
60
60
  /**
61
61
  * @summary Method to create a new storage container
62
62
  * @param id scoped id of the resource
63
63
  * @param scope scope in which this resource is defined
64
64
  * @param props storage container properties
65
+ * @see [CDKTF Storage Container Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/storageContainer.typescript.md}
65
66
  */
66
67
  createStorageContainer(id, scope, props) {
67
68
  if (!props)
@@ -82,15 +83,16 @@ class AzureStorageManager {
82
83
  name: `${props.name}-${scope.props.stage}`,
83
84
  storageAccountName: storageAccount.name,
84
85
  });
85
- (0, utils_1.createTfOutput)(`${id}-storageContainerName`, scope, storageContainer.name);
86
- (0, utils_1.createTfOutput)(`${id}-storageContainerFriendlyUniqueId`, scope, storageContainer.friendlyUniqueId);
87
- (0, utils_1.createTfOutput)(`${id}-storageContainerId`, scope, storageContainer.id);
86
+ (0, utils_1.createAzureTfOutput)(`${id}-storageContainerName`, scope, storageContainer.name);
87
+ (0, utils_1.createAzureTfOutput)(`${id}-storageContainerFriendlyUniqueId`, scope, storageContainer.friendlyUniqueId);
88
+ (0, utils_1.createAzureTfOutput)(`${id}-storageContainerId`, scope, storageContainer.id);
88
89
  }
89
90
  /**
90
91
  * @summary Method to create a new storage blob
91
92
  * @param id scoped id of the resource
92
93
  * @param scope scope in which this resource is defined
93
94
  * @param props storage blob properties
95
+ * @see [CDKTF Storage Blob Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/storageBlob.typescript.md}
94
96
  */
95
97
  createStorageBlob(id, scope, props) {
96
98
  if (!props)
@@ -116,9 +118,9 @@ class AzureStorageManager {
116
118
  storageAccountName: storageAccount.name,
117
119
  storageContainerName: storageContainer.name,
118
120
  });
119
- (0, utils_1.createTfOutput)(`${id}-storageBlobName`, scope, storageBlob.name);
120
- (0, utils_1.createTfOutput)(`${id}-storageBlobFriendlyUniqueId`, scope, storageBlob.friendlyUniqueId);
121
- (0, utils_1.createTfOutput)(`${id}-storageBlobId`, scope, storageBlob.id);
121
+ (0, utils_1.createAzureTfOutput)(`${id}-storageBlobName`, scope, storageBlob.name);
122
+ (0, utils_1.createAzureTfOutput)(`${id}-storageBlobFriendlyUniqueId`, scope, storageBlob.friendlyUniqueId);
123
+ (0, utils_1.createAzureTfOutput)(`${id}-storageBlobId`, scope, storageBlob.id);
122
124
  }
123
125
  }
124
126
  exports.AzureStorageManager = AzureStorageManager;
@@ -1,10 +1,10 @@
1
1
  import { StorageAccountConfig } from '@cdktf/provider-azurerm/lib/storage-account';
2
2
  import { StorageBlobConfig } from '@cdktf/provider-azurerm/lib/storage-blob';
3
3
  import { StorageContainerConfig } from '@cdktf/provider-azurerm/lib/storage-container';
4
- import { BaseConfigProps } from '../../types';
4
+ import { BaseAzureConfigProps } from '../../types';
5
5
  export interface StorageAccountProps extends StorageAccountConfig {
6
6
  }
7
- export interface StorageContainerProps extends BaseConfigProps, StorageContainerConfig {
7
+ export interface StorageContainerProps extends BaseAzureConfigProps, StorageContainerConfig {
8
8
  }
9
- export interface StorageBlobProps extends BaseConfigProps, StorageBlobConfig {
9
+ export interface StorageBlobProps extends BaseAzureConfigProps, StorageBlobConfig {
10
10
  }
@@ -1,3 +1,3 @@
1
- export interface BaseConfigProps {
1
+ export interface BaseAzureConfigProps {
2
2
  resourceGroupName: string;
3
3
  }
@@ -1,3 +1,3 @@
1
1
  import { TerraformOutput } from 'cdktf';
2
2
  import { CommonAzureConstruct } from '../common';
3
- export declare const createTfOutput: (id: string, scope: CommonAzureConstruct, value?: string, description?: string, sensitive?: boolean, overrideId?: boolean) => TerraformOutput;
3
+ export declare const createAzureTfOutput: (id: string, scope: CommonAzureConstruct, value?: string, description?: string, sensitive?: boolean, overrideId?: boolean) => TerraformOutput;
@@ -3,10 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createTfOutput = void 0;
6
+ exports.createAzureTfOutput = void 0;
7
7
  const cdktf_1 = require("cdktf");
8
8
  const lodash_1 = __importDefault(require("lodash"));
9
- const createTfOutput = (id, scope, value, description, sensitive, overrideId = true) => {
9
+ const createAzureTfOutput = (id, scope, value, description, sensitive, overrideId = true) => {
10
10
  const output = new cdktf_1.TerraformOutput(scope, id, {
11
11
  description,
12
12
  sensitive,
@@ -17,4 +17,4 @@ const createTfOutput = (id, scope, value, description, sensitive, overrideId = t
17
17
  }
18
18
  return output;
19
19
  };
20
- exports.createTfOutput = createTfOutput;
20
+ exports.createAzureTfOutput = createAzureTfOutput;
@@ -0,0 +1,35 @@
1
+ import { TerraformStack } from 'cdktf';
2
+ import { Construct } from 'constructs';
3
+ import { CloudflareZoneManager } from '../services';
4
+ import { CommonCloudflareStackProps } from './types';
5
+ export declare class CommonCloudflareConstruct extends TerraformStack {
6
+ props: CommonCloudflareStackProps;
7
+ id: string;
8
+ fullyQualifiedDomainName: string;
9
+ zoneManager: CloudflareZoneManager;
10
+ constructor(scope: Construct, id: string, props: CommonCloudflareStackProps);
11
+ /**
12
+ * @summary Determine the fully qualified domain name based on domainName & subDomain
13
+ */
14
+ protected determineFullyQualifiedDomain(): void;
15
+ /**
16
+ * @summary Utility method to determine if the initialisation is in development (dev) stage
17
+ * This is determined by the stage property injected via cdk context
18
+ */
19
+ isDevelopmentStage: () => boolean;
20
+ /**
21
+ * @summary Utility method to determine if the initialisation is in test (tst) stage
22
+ * This is determined by the stage property injected via cdk context
23
+ */
24
+ isTestStage: () => boolean;
25
+ /**
26
+ * @summary Utility method to determine if the initialisation is in uat (uat) stage
27
+ * This is determined by the stage property injected via cdk context
28
+ */
29
+ isUatStage: () => boolean;
30
+ /**
31
+ * @summary Utility method to determine if the initialisation is in production (prd) stage
32
+ * This is determined by the stage property injected via cdk context
33
+ */
34
+ isProductionStage: () => boolean;
35
+ }
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CommonCloudflareConstruct = void 0;
4
+ const provider_1 = require("@cdktf/provider-cloudflare/lib/provider");
5
+ const cdktf_1 = require("cdktf");
6
+ const common_1 = require("../../common");
7
+ const services_1 = require("../services");
8
+ class CommonCloudflareConstruct extends cdktf_1.TerraformStack {
9
+ id;
10
+ fullyQualifiedDomainName;
11
+ zoneManager;
12
+ constructor(scope, id, props) {
13
+ super(scope, id);
14
+ this.props = props;
15
+ this.id = id;
16
+ this.zoneManager = new services_1.CloudflareZoneManager();
17
+ this.determineFullyQualifiedDomain();
18
+ new provider_1.CloudflareProvider(this, `${this.id}-provider`, this.props);
19
+ }
20
+ /**
21
+ * @summary Determine the fully qualified domain name based on domainName & subDomain
22
+ */
23
+ determineFullyQualifiedDomain() {
24
+ this.fullyQualifiedDomainName = this.props.subDomain
25
+ ? `${this.props.subDomain}.${this.props.domainName}`
26
+ : this.props.domainName;
27
+ }
28
+ /**
29
+ * @summary Utility method to determine if the initialisation is in development (dev) stage
30
+ * This is determined by the stage property injected via cdk context
31
+ */
32
+ isDevelopmentStage = () => (0, common_1.isDevStage)(this.props.stage);
33
+ /**
34
+ * @summary Utility method to determine if the initialisation is in test (tst) stage
35
+ * This is determined by the stage property injected via cdk context
36
+ */
37
+ isTestStage = () => (0, common_1.isTestStage)(this.props.stage);
38
+ /**
39
+ * @summary Utility method to determine if the initialisation is in uat (uat) stage
40
+ * This is determined by the stage property injected via cdk context
41
+ */
42
+ isUatStage = () => (0, common_1.isUatStage)(this.props.stage);
43
+ /**
44
+ * @summary Utility method to determine if the initialisation is in production (prd) stage
45
+ * This is determined by the stage property injected via cdk context
46
+ */
47
+ isProductionStage = () => (0, common_1.isPrdStage)(this.props.stage);
48
+ }
49
+ exports.CommonCloudflareConstruct = CommonCloudflareConstruct;
@@ -0,0 +1,3 @@
1
+ export * from './construct';
2
+ export * from './stack';
3
+ export * from './types';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./construct"), exports);
18
+ __exportStar(require("./stack"), exports);
19
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,52 @@
1
+ import { CommonCloudflareConstruct } from './construct';
2
+ import { CommonCloudflareStackProps } from './types';
3
+ import { TerraformStack } from 'cdktf';
4
+ import { Construct } from 'constructs';
5
+ /**
6
+ * @classdesc Common stack to use as a base for all higher level constructs.
7
+ * @example
8
+ * import { CommonCloudflareStack } from '@gradientedge/cdk-utils'
9
+ *
10
+ * class CustomStack extends CommonCloudflareStack {
11
+ * constructor(parent: App, name: string, props: StackProps) {
12
+ * super(parent, name, props)
13
+ * // provision resources
14
+ * }
15
+ * }
16
+ */
17
+ export declare class CommonCloudflareStack extends TerraformStack {
18
+ construct: CommonCloudflareConstruct;
19
+ props: CommonCloudflareStackProps;
20
+ constructor(parent: Construct, name: string, props: CommonCloudflareStackProps);
21
+ /**
22
+ * @summary Method to determine the core CDK construct properties injected via context cdktf.json
23
+ * @param props The stack properties
24
+ * @returns The stack properties
25
+ */
26
+ protected determineConstructProps(props: CommonCloudflareStackProps): {
27
+ accountId: any;
28
+ domainName: any;
29
+ extraContexts: any;
30
+ features: any;
31
+ name: any;
32
+ skipStageForARecords: any;
33
+ stage: any;
34
+ subDomain: any;
35
+ };
36
+ /**
37
+ * @summary Method to determine extra cdk contexts apart from the main cdktf.json
38
+ * - Sets the properties from the extra contexts into cdk node context
39
+ * - Primary use is to have layered config in separate files to enable easier maintenance and readability
40
+ */
41
+ protected determineExtraContexts(): void;
42
+ /**
43
+ * @summary Method to determine extra cdk stage contexts apart from the main cdktf.json
44
+ * - Sets the properties from the extra stage contexts into cdk node context
45
+ * - Primary use is to have layered config for each environment which is injected into the context
46
+ */
47
+ protected determineStageContexts(): void;
48
+ /**
49
+ * @summary Determine the fully qualified domain name based on domainName & subDomain
50
+ */
51
+ protected fullyQualifiedDomain(): any;
52
+ }
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CommonCloudflareStack = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const construct_1 = require("./construct");
9
+ const app_root_path_1 = __importDefault(require("app-root-path"));
10
+ const cdktf_1 = require("cdktf");
11
+ const lodash_1 = __importDefault(require("lodash"));
12
+ const common_1 = require("../../common");
13
+ /**
14
+ * @classdesc Common stack to use as a base for all higher level constructs.
15
+ * @example
16
+ * import { CommonCloudflareStack } from '@gradientedge/cdk-utils'
17
+ *
18
+ * class CustomStack extends CommonCloudflareStack {
19
+ * constructor(parent: App, name: string, props: StackProps) {
20
+ * super(parent, name, props)
21
+ * // provision resources
22
+ * }
23
+ * }
24
+ */
25
+ class CommonCloudflareStack extends cdktf_1.TerraformStack {
26
+ construct;
27
+ props;
28
+ constructor(parent, name, props) {
29
+ super(parent, name);
30
+ /* determine extra cdk contexts */
31
+ this.determineExtraContexts();
32
+ /* determine extra cdk stage contexts */
33
+ this.determineStageContexts();
34
+ this.props = this.determineConstructProps(props);
35
+ /* initialise the construct */
36
+ this.construct = new construct_1.CommonCloudflareConstruct(this, 'cdk-utils', this.props);
37
+ }
38
+ /**
39
+ * @summary Method to determine the core CDK construct properties injected via context cdktf.json
40
+ * @param props The stack properties
41
+ * @returns The stack properties
42
+ */
43
+ determineConstructProps(props) {
44
+ return {
45
+ accountId: this.node.tryGetContext('accountId'),
46
+ domainName: this.node.tryGetContext('domainName'),
47
+ extraContexts: this.node.tryGetContext('extraContexts'),
48
+ features: this.node.tryGetContext('features'),
49
+ name: this.node.tryGetContext('resourceGroupName'),
50
+ skipStageForARecords: this.node.tryGetContext('skipStageForARecords'),
51
+ stage: this.node.tryGetContext('stage'),
52
+ subDomain: this.node.tryGetContext('subDomain'),
53
+ };
54
+ }
55
+ /**
56
+ * @summary Method to determine extra cdk contexts apart from the main cdktf.json
57
+ * - Sets the properties from the extra contexts into cdk node context
58
+ * - Primary use is to have layered config in separate files to enable easier maintenance and readability
59
+ */
60
+ determineExtraContexts() {
61
+ const extraContexts = this.node.tryGetContext('extraContexts');
62
+ const debug = this.node.tryGetContext('debug');
63
+ if (!extraContexts) {
64
+ if (debug)
65
+ console.debug(`No additional contexts provided. Using default context properties from cdktf.json`);
66
+ return;
67
+ }
68
+ lodash_1.default.forEach(extraContexts, (context) => {
69
+ const extraContextPath = `${app_root_path_1.default.path}/${context}`;
70
+ /* scenario where extra context is configured in cdk.json but absent in file system */
71
+ if (!fs_1.default.existsSync(extraContextPath))
72
+ throw `Extra context properties unavailable in path:${extraContextPath}`;
73
+ /* read the extra properties */
74
+ const extraContextPropsBuffer = fs_1.default.readFileSync(extraContextPath);
75
+ if (debug)
76
+ console.debug(`Adding additional contexts provided in ${extraContextPath}`);
77
+ /* parse as JSON properties */
78
+ const extraContextProps = JSON.parse(extraContextPropsBuffer.toString('utf-8'));
79
+ /* set each of the property into the cdk node context */
80
+ lodash_1.default.keys(extraContextProps).forEach((propKey) => {
81
+ this.node.setContext(propKey, extraContextProps[propKey]);
82
+ });
83
+ });
84
+ }
85
+ /**
86
+ * @summary Method to determine extra cdk stage contexts apart from the main cdktf.json
87
+ * - Sets the properties from the extra stage contexts into cdk node context
88
+ * - Primary use is to have layered config for each environment which is injected into the context
89
+ */
90
+ determineStageContexts() {
91
+ const stage = this.node.tryGetContext('stage');
92
+ const stageContextPath = this.node.tryGetContext('stageContextPath') || 'cdkEnv';
93
+ const stageContextFilePath = `${app_root_path_1.default.path}/${stageContextPath}/${stage}.json`;
94
+ const debug = this.node.tryGetContext('debug');
95
+ if ((0, common_1.isDevStage)(stage)) {
96
+ if (debug)
97
+ console.debug(`Development stage. Using default stage context properties`);
98
+ }
99
+ /* alert default context usage when extra stage config is missing */
100
+ if (!fs_1.default.existsSync(stageContextFilePath)) {
101
+ if (debug)
102
+ console.debug(`Stage specific context properties unavailable in path:${stageContextFilePath}`);
103
+ if (debug)
104
+ console.debug(`Using default stage context properties for ${stage} stage`);
105
+ return;
106
+ }
107
+ /* read the extra properties */
108
+ const stageContextPropsBuffer = fs_1.default.readFileSync(stageContextFilePath);
109
+ if (debug)
110
+ console.debug(`Adding additional stage contexts provided in ${stageContextFilePath}`);
111
+ /* parse as JSON properties */
112
+ const stageContextProps = JSON.parse(stageContextPropsBuffer.toString('utf-8'));
113
+ /* set each of the property into the cdk node context */
114
+ lodash_1.default.keys(stageContextProps).forEach((propKey) => {
115
+ /* handle object, array properties */
116
+ if (typeof stageContextProps[propKey] === 'object' && !Array.isArray(stageContextProps[propKey])) {
117
+ this.node.setContext(propKey, lodash_1.default.merge(this.node.tryGetContext(propKey), stageContextProps[propKey]));
118
+ }
119
+ else {
120
+ /* handle all other primitive properties */
121
+ this.node.setContext(propKey, stageContextProps[propKey]);
122
+ }
123
+ });
124
+ }
125
+ /**
126
+ * @summary Determine the fully qualified domain name based on domainName & subDomain
127
+ */
128
+ fullyQualifiedDomain() {
129
+ const domainName = this.node.tryGetContext('domainName');
130
+ const subDomain = this.node.tryGetContext('subDomain');
131
+ return subDomain ? `${subDomain}.${domainName}` : domainName;
132
+ }
133
+ }
134
+ exports.CommonCloudflareStack = CommonCloudflareStack;
@@ -0,0 +1,7 @@
1
+ import { CloudflareProviderConfig } from '@cdktf/provider-cloudflare/lib/provider';
2
+ import { BaseProps } from '../../common';
3
+ /**
4
+ */
5
+ export interface CommonCloudflareStackProps extends BaseProps, CloudflareProviderConfig {
6
+ accountId: string;
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ export * from './common';
2
+ export * from './services';
3
+ export * from './types';
4
+ export * from './utils';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./common"), exports);
18
+ __exportStar(require("./services"), exports);
19
+ __exportStar(require("./types"), exports);
20
+ __exportStar(require("./utils"), exports);
@@ -0,0 +1 @@
1
+ export * from './zone';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./zone"), exports);
@@ -0,0 +1,2 @@
1
+ export * from './main';
2
+ export * from './types';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./main"), exports);
18
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,86 @@
1
+ import { DataCloudflareZone } from '@cdktf/provider-cloudflare/lib/data-cloudflare-zone';
2
+ import { Zone } from '@cdktf/provider-cloudflare/lib/zone';
3
+ import { ZoneCacheReserve } from '@cdktf/provider-cloudflare/lib/zone-cache-reserve';
4
+ import { ZoneCacheVariants } from '@cdktf/provider-cloudflare/lib/zone-cache-variants';
5
+ import { ZoneDnssec } from '@cdktf/provider-cloudflare/lib/zone-dnssec';
6
+ import { ZoneHold } from '@cdktf/provider-cloudflare/lib/zone-hold';
7
+ import { ZoneLockdown } from '@cdktf/provider-cloudflare/lib/zone-lockdown';
8
+ import { ZoneSettingsOverride } from '@cdktf/provider-cloudflare/lib/zone-settings-override';
9
+ import { CommonCloudflareConstruct } from '../../common';
10
+ import { ZoneCacheReserveProps, ZoneCacheVariantsProps, ZoneDnssecProps, ZoneHoldProps, ZoneLockdownProps, ZoneOptions, ZoneProps, ZoneSettingsOverrideProps } from './types';
11
+ /**
12
+ * @classdesc Provides operations on Cloudflare Zone
13
+ * - A new instance of this class is injected into {@link CommonCloudflareConstruct} constructor.
14
+ * - If a custom construct extends {@link CommonCloudflareConstruct}, an instance is available within the context.
15
+ * @example
16
+ * ```
17
+ * import { CommonCloudflareConstruct, CommonCloudflareConstruct } from '@gradientedge/cdk-utils'
18
+ *
19
+ * class CustomConstruct extends CommonCloudflareConstruct {
20
+ * constructor(parent: Construct, id: string, props: CommonCloudflareStackProps) {
21
+ * super(parent, id, props)
22
+ * this.props = props
23
+ * this.zoneManager.createZone('MyZone', this, props)
24
+ * }
25
+ * }
26
+ * ```
27
+ */
28
+ export declare class CloudflareZoneManager {
29
+ /**
30
+ * @summary Method to create a new zone
31
+ * @param id scoped id of the resource
32
+ * @param scope scope in which this resource is defined
33
+ * @param props zone properties
34
+ * @see [CDKTF Zone Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/zone.typescript.md}
35
+ */
36
+ createZone(id: string, scope: CommonCloudflareConstruct, props: ZoneProps): Zone;
37
+ resolveZone(id: string, scope: CommonCloudflareConstruct, options: ZoneOptions): DataCloudflareZone;
38
+ /**
39
+ * @summary Method to create a new zone cache reserve
40
+ * @param id scoped id of the resource
41
+ * @param scope scope in which this resource is defined
42
+ * @param props zone cache reserve properties
43
+ * @see [CDKTF Zone Cache Reserve Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/zoneCacheReserve.typescript.md}
44
+ */
45
+ createZoneCacheReserve(id: string, scope: CommonCloudflareConstruct, props: ZoneCacheReserveProps): ZoneCacheReserve;
46
+ /**
47
+ * @summary Method to create a new zone cache variants
48
+ * @param id scoped id of the resource
49
+ * @param scope scope in which this resource is defined
50
+ * @param props zone cache variants properties
51
+ * @see [CDKTF Zone Cache Variants Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/zoneCacheVariants.typescript.md}
52
+ */
53
+ createZoneCacheVariants(id: string, scope: CommonCloudflareConstruct, props: ZoneCacheVariantsProps): ZoneCacheVariants;
54
+ /**
55
+ * @summary Method to create a new zone dnssec
56
+ * @param id scoped id of the resource
57
+ * @param scope scope in which this resource is defined
58
+ * @param props zone dnssec properties
59
+ * @see [CDKTF Zone DNS Security Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/zoneDnssec.typescript.md}
60
+ */
61
+ createZoneDnssec(id: string, scope: CommonCloudflareConstruct, props: ZoneDnssecProps): ZoneDnssec;
62
+ /**
63
+ * @summary Method to create a new zone hold
64
+ * @param id scoped id of the resource
65
+ * @param scope scope in which this resource is defined
66
+ * @param props zone hold properties
67
+ * @see [CDKTF Zone Hold Security Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/zoneHold.typescript.md}
68
+ */
69
+ createZoneHold(id: string, scope: CommonCloudflareConstruct, props: ZoneHoldProps): ZoneHold;
70
+ /**
71
+ * @summary Method to create a new zone lockdown
72
+ * @param id scoped id of the resource
73
+ * @param scope scope in which this resource is defined
74
+ * @param props zone lockdown properties
75
+ * @see [CDKTF Zone Lockdown Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/zoneLockdown.typescript.md}
76
+ */
77
+ createZoneLockdown(id: string, scope: CommonCloudflareConstruct, props: ZoneLockdownProps): ZoneLockdown;
78
+ /**
79
+ * @summary Method to create a new zone settings override
80
+ * @param id scoped id of the resource
81
+ * @param scope scope in which this resource is defined
82
+ * @param props zone settings override properties
83
+ * @see [CDKTF Zone Settings Override Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/zoneSettingsOverride.typescript.md}
84
+ */
85
+ createZoneSettingsOverride(id: string, scope: CommonCloudflareConstruct, props: ZoneSettingsOverrideProps): ZoneSettingsOverride;
86
+ }