@digitraffic/common 2022.12.22-3 → 2023.1.18-1

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.
@@ -110,10 +110,11 @@ class StackCheckingAspect {
110
110
  checkBucket(node) {
111
111
  if (node instanceof aws_s3_1.CfnBucket) {
112
112
  const c = node.publicAccessBlockConfiguration;
113
- if (c && (!c.blockPublicAcls ||
114
- !c.blockPublicPolicy ||
115
- !c.ignorePublicAcls ||
116
- !c.restrictPublicBuckets)) {
113
+ if (c &&
114
+ (!c.blockPublicAcls ||
115
+ !c.blockPublicPolicy ||
116
+ !c.ignorePublicAcls ||
117
+ !c.restrictPublicBuckets)) {
117
118
  this.addAnnotation(node, ResourceType.bucketPublicity, "Check bucket publicity");
118
119
  }
119
120
  }
@@ -38,8 +38,8 @@ class DbStack extends aws_cdk_lib_1.Stack {
38
38
  }),
39
39
  parameters: {
40
40
  "pg_stat_statements.track": "ALL",
41
- "random_page_cost": "1",
42
- "work_mem": "512MB"
41
+ random_page_cost: "1",
42
+ work_mem: "512MB",
43
43
  },
44
44
  })
45
45
  : aws_rds_1.ParameterGroup.fromParameterGroupName(this, "ParameterGroup", `default.aurora-postgresql${configuration.dbVersion.auroraPostgresMajorVersion}`);
@@ -72,4 +72,27 @@ function getEnvVariableSafe(key) {
72
72
  return { result: "ok", value };
73
73
  }
74
74
  exports.getEnvVariableSafe = getEnvVariableSafe;
75
+ /**
76
+ * Gets environment variable. If environment variable is undefined, returns value of given function.
77
+ *
78
+ * @param key Environment key
79
+ * @param fn Alternative function
80
+ */
81
+ function getEnvVariableOr(key, fn) {
82
+ const either = getEnvVariableSafe(key);
83
+ if (either.result === "ok") {
84
+ return either.value;
85
+ }
86
+ return fn();
87
+ }
88
+ /**
89
+ * Gets environment variable. If environment variable is undefined, returns given value.
90
+ * Use to return an explicit alternative value e.g. in cases where environment variable may be undefined.
91
+ *
92
+ * @param key Environment key
93
+ * @param orElse Alternative value
94
+ */
95
+ function getEnvVariableOrElse(key, orElse) {
96
+ return getEnvVariableOr(key, () => orElse);
97
+ }
75
98
  //# sourceMappingURL=utils.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitraffic/common",
3
- "version": "2022.12.22-3",
3
+ "version": "2023.01.18-1",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,38 +32,38 @@
32
32
  "spex": "^3.0.0"
33
33
  },
34
34
  "devDependencies": {
35
- "@aws-cdk/aws-synthetics-alpha": "2.50.0-alpha.0",
36
- "@types/aws-lambda": "^8.10.106",
35
+ "@aws-cdk/aws-synthetics-alpha": "2.60.0-alpha.0",
36
+ "@types/aws-lambda": "^8.10.109",
37
37
  "@types/geojson": "^7946.0.10",
38
- "@types/jest": "^29.0.3",
39
- "@types/node": "^18.7.23",
40
- "@types/ramda": "^0.28.15",
38
+ "@types/jest": "^29.2.5",
39
+ "@types/node": "^18.11.18",
40
+ "@types/ramda": "^0.28.21",
41
41
  "@types/sinon": "^10.0.13",
42
- "@typescript-eslint/eslint-plugin": "^5.39.0",
43
- "@typescript-eslint/parser": "^5.39.0",
44
- "aws-cdk-lib": "^2.50.0",
45
- "aws-sdk": "^2.1241.0",
46
- "axios": "^0.21.1",
42
+ "@typescript-eslint/eslint-plugin": "^5.48.2",
43
+ "@typescript-eslint/parser": "^5.48.2",
44
+ "aws-cdk-lib": "^2.60.0",
45
+ "aws-sdk": "^2.1295.0",
46
+ "axios": "^1.2.2",
47
47
  "change-case": "^4.1.2",
48
- "constructs": "^10.1.131",
49
- "eslint": "^8.24.0",
50
- "eslint-config-prettier": "^8.5.0",
48
+ "constructs": "^10.1.222",
49
+ "eslint": "^8.32.0",
50
+ "eslint-config-prettier": "^8.6.0",
51
51
  "eslint-plugin-deprecation": "1.3.3",
52
52
  "geojson-validation": "^1.0.2",
53
- "husky": ">=6",
53
+ "husky": "^8.0.3",
54
54
  "jest": "^29.1.1",
55
- "jest-junit": "^14.0.1",
56
- "lint-staged": ">=10",
55
+ "jest-junit": "^15.0.0",
56
+ "lint-staged": "^13.1.0",
57
57
  "moment": "^2.29.4",
58
58
  "node-ttl": "^0.2.0",
59
59
  "pg-native": "^3.0.1",
60
60
  "pg-promise": "^10.12.0",
61
- "prettier": "^2.7.1",
61
+ "prettier": "^2.8.3",
62
62
  "ramda": "^0.28.0",
63
- "rimraf": "^3.0.2",
64
- "sinon": "^14.0.0",
65
- "ts-jest": "^29.0.3",
66
- "typescript": "^4.7.4"
63
+ "rimraf": "^4.1.0",
64
+ "sinon": "^15.0.1",
65
+ "ts-jest": "^29.0.5",
66
+ "typescript": "^4.9.4"
67
67
  },
68
68
  "externals": [
69
69
  "aws-sdk",
@@ -180,15 +180,17 @@ export class StackCheckingAspect implements IAspect {
180
180
 
181
181
  private checkBucket(node: IConstruct) {
182
182
  if (node instanceof CfnBucket) {
183
- const c =
184
- node.publicAccessBlockConfiguration as CfnBucket.PublicAccessBlockConfigurationProperty | undefined;
183
+ const c = node.publicAccessBlockConfiguration as
184
+ | CfnBucket.PublicAccessBlockConfigurationProperty
185
+ | undefined;
185
186
 
186
- if (c && (
187
- !c.blockPublicAcls ||
188
- !c.blockPublicPolicy ||
189
- !c.ignorePublicAcls ||
190
- !c.restrictPublicBuckets
191
- )) {
187
+ if (
188
+ c &&
189
+ (!c.blockPublicAcls ||
190
+ !c.blockPublicPolicy ||
191
+ !c.ignorePublicAcls ||
192
+ !c.restrictPublicBuckets)
193
+ ) {
192
194
  this.addAnnotation(
193
195
  node,
194
196
  ResourceType.bucketPublicity,
@@ -104,8 +104,8 @@ export class DbStack extends Stack {
104
104
  }),
105
105
  parameters: {
106
106
  "pg_stat_statements.track": "ALL",
107
- "random_page_cost": "1",
108
- "work_mem": "512MB"
107
+ random_page_cost: "1",
108
+ work_mem: "512MB",
109
109
  },
110
110
  }
111
111
  )
@@ -157,9 +157,7 @@ export class DbStack extends Stack {
157
157
  "Couldn't pull CfnDBInstances from the L1 constructs!"
158
158
  );
159
159
  }
160
- cfnInstances.forEach(
161
- (cfnInstance) => delete cfnInstance.engineVersion
162
- );
160
+ cfnInstances.forEach((cfnInstance) => delete cfnInstance.engineVersion);
163
161
 
164
162
  return cluster;
165
163
  }
@@ -103,3 +103,28 @@ export function getEnvVariableSafe(key: string): Either<string> {
103
103
  }
104
104
  return { result: "ok", value };
105
105
  }
106
+
107
+ /**
108
+ * Gets environment variable. If environment variable is undefined, returns value of given function.
109
+ *
110
+ * @param key Environment key
111
+ * @param fn Alternative function
112
+ */
113
+ function getEnvVariableOr<T>(key: string, fn: () => T): string | T {
114
+ const either = getEnvVariableSafe(key);
115
+ if (either.result === "ok") {
116
+ return either.value;
117
+ }
118
+ return fn();
119
+ }
120
+
121
+ /**
122
+ * Gets environment variable. If environment variable is undefined, returns given value.
123
+ * Use to return an explicit alternative value e.g. in cases where environment variable may be undefined.
124
+ *
125
+ * @param key Environment key
126
+ * @param orElse Alternative value
127
+ */
128
+ function getEnvVariableOrElse<T>(key: string, orElse: T): string | T {
129
+ return getEnvVariableOr(key, () => orElse);
130
+ }