@digitraffic/common 2024.7.8-1 → 2024.8.14-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.
@@ -11,10 +11,10 @@ export type AWSManagedWafRule = "CommonRuleSet" | "AmazonIpReputationList" | "Kn
11
11
  export declare class AclBuilder {
12
12
  readonly _construct: Construct;
13
13
  readonly _rules: CfnWebACL.RuleProperty[];
14
+ readonly _name: string;
14
15
  _scope: string;
15
- _name: string;
16
16
  _customResponseBodies: Record<string, CfnWebACL.CustomResponseBodyProperty>;
17
- constructor(construct: Construct);
17
+ constructor(construct: Construct, name?: string);
18
18
  isRuleDefined(rules: AWSManagedWafRule[] | "all", rule: AWSManagedWafRule): boolean;
19
19
  withAWSManagedRules(rules?: AWSManagedWafRule[] | "all"): AclBuilder;
20
20
  withIpRestrictionRule(addresses: string[]): AclBuilder;
@@ -10,11 +10,12 @@ import { logger } from "../runtime/dt-logger-default.mjs";
10
10
  export class AclBuilder {
11
11
  _construct;
12
12
  _rules = [];
13
+ _name;
13
14
  _scope = "CLOUDFRONT";
14
- _name = "WebACL";
15
15
  _customResponseBodies = {};
16
- constructor(construct) {
16
+ constructor(construct, name = "WebACL") {
17
17
  this._construct = construct;
18
+ this._name = name;
18
19
  }
19
20
  isRuleDefined(rules, rule) {
20
21
  return rules === "all" || rules.includes(rule);
@@ -82,7 +83,7 @@ export class AclBuilder {
82
83
  if (key in this._customResponseBodies) {
83
84
  logger.warn({
84
85
  method: "acl-builder.withCustomResponseBody",
85
- message: `Overriding custom response body with key ${key}`,
86
+ message: `Overriding custom response body with key ${key} for distribution ${this._name}`,
86
87
  });
87
88
  }
88
89
  this._customResponseBodies[key] = customResponseBody;
@@ -138,7 +139,7 @@ export class AclBuilder {
138
139
  _logMissingLimit(method) {
139
140
  logger.warn({
140
141
  method: `acl-builder.${method}`,
141
- message: `'limit' was not defined. Not setting a throttle rule`,
142
+ message: `'limit' was not defined. Not setting a throttle rule for ${this._name}`,
142
143
  });
143
144
  }
144
145
  build() {
@@ -5,7 +5,7 @@ import { ComparisonOperator, Metric } from "aws-cdk-lib/aws-cloudwatch";
5
5
  import { DigitrafficStack } from "./stack.mjs";
6
6
  import { databaseFunctionProps, } from "./lambda-configs.mjs";
7
7
  import { TrafficType } from "../../../types/traffictype.mjs";
8
- import _ from "lodash";
8
+ import { chain } from "lodash-es";
9
9
  /**
10
10
  * Creates a Lambda function that monitors default CloudWatch Lambda metrics with CloudWatch Alarms.
11
11
  */
@@ -54,7 +54,7 @@ export class MonitoredFunction extends Function {
54
54
  */
55
55
  static createV2(stack, name, environment, functionParameters) {
56
56
  const functionName = functionParameters?.functionName ??
57
- `${stack.configuration.shortName}-${_.chain(name)
57
+ `${stack.configuration.shortName}-${chain(name)
58
58
  .camelCase()
59
59
  .startCase()
60
60
  .replace(/\s/g, "")
@@ -140,7 +140,7 @@ export class MonitoredDBFunction {
140
140
  */
141
141
  static create(stack, name, environment, functionParameters) {
142
142
  const functionName = functionParameters?.functionName ??
143
- `${stack.configuration.shortName}-${_.chain(name)
143
+ `${stack.configuration.shortName}-${chain(name)
144
144
  .camelCase()
145
145
  .startCase()
146
146
  .replace(/\s/g, "")
@@ -6,7 +6,7 @@ import { MediaType } from "../../types/mediatypes.mjs";
6
6
  import { DocumentationPart } from "../documentation.mjs";
7
7
  import { createDefaultUsagePlan, createUsagePlan } from "../usage-plans.mjs";
8
8
  import { DigitrafficStack } from "./stack.mjs";
9
- import _ from "lodash";
9
+ import { set } from "lodash-es";
10
10
  export class DigitrafficRestApi extends RestApi {
11
11
  apiKeyIds;
12
12
  enableDocumentation;
@@ -59,7 +59,7 @@ export class DigitrafficRestApi extends RestApi {
59
59
  }));
60
60
  }
61
61
  getModelWithReference(model) {
62
- return _.set(model, "modelReference", getModelReference(model.modelId, this.restApiId));
62
+ return set(model, "modelReference", getModelReference(model.modelId, this.restApiId));
63
63
  }
64
64
  addDocumentationPart(resource, parameterName, resourceName, type, properties) {
65
65
  const location = {
@@ -6,7 +6,7 @@ import { CfnMethod, CfnResource } from "aws-cdk-lib/aws-apigateway";
6
6
  import { CfnQueue } from "aws-cdk-lib/aws-sqs";
7
7
  import { LogRetention } from "aws-cdk-lib/aws-logs";
8
8
  import { kebabCase } from "change-case";
9
- import _ from "lodash";
9
+ import { snakeCase } from "lodash-es";
10
10
  const MAX_CONCURRENCY_LIMIT = 100;
11
11
  const NODE_RUNTIMES = [Runtime.NODEJS_20_X.name, Runtime.NODEJS_18_X.name];
12
12
  var ResourceType;
@@ -124,7 +124,7 @@ export class StackCheckingAspect {
124
124
  return kebabCase(path) === path;
125
125
  }
126
126
  static isValidQueryString(name) {
127
- return _.snakeCase(name) === name;
127
+ return snakeCase(name) === name;
128
128
  }
129
129
  checkResourceCasing(node) {
130
130
  if (node instanceof CfnResource) {
@@ -1,4 +1,4 @@
1
- import { Writable } from "stream";
1
+ import type { Writable } from "stream";
2
2
  /** Logging level */
3
3
  export type LOG_LEVEL = "DEBUG" | "INFO" | "WARN" | "ERROR";
4
4
  export type LoggerMethodType = `${string}.${string}`;
@@ -1,5 +1,4 @@
1
- import { Writable } from "stream";
2
- import _ from "lodash";
1
+ import { mapKeys, lowerFirst } from "lodash-es";
3
2
  /**
4
3
  * Helper class for json-logging.
5
4
  *
@@ -19,9 +18,8 @@ export class DtLogger {
19
18
  * @param {LoggerConfiguration?} [config] - Accepts configuration options @see {@link LoggerConfiguration}
20
19
  */
21
20
  constructor(config) {
22
- this.lambdaName =
23
- config?.lambdaName ?? process.env['AWS_LAMBDA_FUNCTION_NAME'];
24
- this.runtime = config?.runTime ?? process.env['AWS_EXECUTION_ENV'];
21
+ this.lambdaName = config?.lambdaName ?? process.env["AWS_LAMBDA_FUNCTION_NAME"];
22
+ this.runtime = config?.runTime ?? process.env["AWS_EXECUTION_ENV"];
25
23
  this.writeStream = config?.writeStream ?? process.stdout;
26
24
  }
27
25
  /**
@@ -99,6 +97,6 @@ export class DtLogger {
99
97
  }
100
98
  }
101
99
  function removePrefix(prefix, loggable) {
102
- return _.mapKeys(loggable, (_index, key) => key.startsWith(prefix) ? _.lowerFirst(key.replace(prefix, "")) : key);
100
+ return mapKeys(loggable, (_index, key) => key.startsWith(prefix) ? lowerFirst(key.replace(prefix, "")) : key);
103
101
  }
104
102
  //# sourceMappingURL=dt-logger.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitraffic/common",
3
- "version": "2024.7.8-1",
3
+ "version": "2024.8.14-1",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "repository": {
@@ -117,7 +117,7 @@
117
117
  "etag": "^1.8.1",
118
118
  "geojson-validation": "^1.0.2",
119
119
  "ky": "^1.5.0",
120
- "lodash": "^4.17.21",
120
+ "lodash-es": "^4.17.21",
121
121
  "node-ttl": "^0.2.0",
122
122
  "pg-native": "^3.1.0",
123
123
  "pg-promise": "^11.9.1"
@@ -136,7 +136,7 @@
136
136
  "etag": "^1.8.1",
137
137
  "geojson-validation": "^1.0.2",
138
138
  "ky": "^1.5.0",
139
- "lodash": "^4.17.21",
139
+ "lodash-es": "^4.17.21",
140
140
  "node-ttl": "^0.2.0",
141
141
  "pg-promise": "^11.9.1",
142
142
  "@jest/globals": "^29.7.0",
@@ -151,7 +151,7 @@
151
151
  "@types/geojson": "^7946.0.14",
152
152
  "@types/geojson-validation": "^1.0.3",
153
153
  "@types/jest": "^29.5.12",
154
- "@types/lodash": "^4.17.7",
154
+ "@types/lodash-es": "^4.17.7",
155
155
  "@types/madge": "^5.0.3",
156
156
  "@types/node": "^20.14.9",
157
157
  "@typescript-eslint/eslint-plugin": "^7.14.1",
@@ -162,7 +162,7 @@
162
162
  "eslint-plugin-deprecation": "^3.0.0",
163
163
  "jest": "^29.7.0",
164
164
  "jest-junit": "^16.0.0",
165
- "madge": "^7.0.0",
165
+ "madge": "^8.0.0",
166
166
  "prettier": "^3.3.3",
167
167
  "rimraf": "^6.0.1",
168
168
  "ts-jest": "^29.2.4",