@digitraffic/common 2023.10.18-1 → 2023.11.21-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.
- package/dist/aws/infra/stack/monitoredfunction.js +14 -3
- package/dist/aws/infra/stack/rest_apis.js +5 -2
- package/dist/aws/infra/stack/stack-checking-aspect.js +6 -2
- package/package.json +28 -30
- package/src/aws/infra/stack/monitoredfunction.ts +12 -3
- package/src/aws/infra/stack/rest_apis.ts +4 -4
- package/src/aws/infra/stack/stack-checking-aspect.ts +3 -2
@@ -1,12 +1,15 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
6
|
exports.MonitoredDBFunction = exports.MonitoredFunction = void 0;
|
4
7
|
const aws_lambda_1 = require("aws-cdk-lib/aws-lambda");
|
5
8
|
const aws_cloudwatch_actions_1 = require("aws-cdk-lib/aws-cloudwatch-actions");
|
6
9
|
const aws_cloudwatch_1 = require("aws-cdk-lib/aws-cloudwatch");
|
7
10
|
const lambda_configs_1 = require("../stack/lambda-configs");
|
8
|
-
const change_case_1 = require("change-case");
|
9
11
|
const subscription_1 = require("../stack/subscription");
|
12
|
+
const lodash_1 = __importDefault(require("lodash"));
|
10
13
|
/**
|
11
14
|
* Creates a Lambda function that monitors default CloudWatch Lambda metrics with CloudWatch Alarms.
|
12
15
|
*/
|
@@ -40,7 +43,11 @@ class MonitoredFunction extends aws_lambda_1.Function {
|
|
40
43
|
*/
|
41
44
|
static createV2(stack, name, environment, functionParameters) {
|
42
45
|
const functionName = functionParameters?.functionName ??
|
43
|
-
`${stack.configuration.shortName}-${
|
46
|
+
`${stack.configuration.shortName}-${lodash_1.default.chain(name)
|
47
|
+
.camelCase()
|
48
|
+
.startCase()
|
49
|
+
.replace(/\s/g, "")
|
50
|
+
.value()}`;
|
44
51
|
const functionProps = (0, lambda_configs_1.databaseFunctionProps)(stack, environment, functionName, name, functionParameters);
|
45
52
|
return MonitoredFunction.create(stack, functionName, functionProps, functionParameters);
|
46
53
|
}
|
@@ -130,7 +137,11 @@ class MonitoredDBFunction {
|
|
130
137
|
*/
|
131
138
|
static create(stack, name, environment, functionParameters) {
|
132
139
|
const functionName = functionParameters?.functionName ??
|
133
|
-
`${stack.configuration.shortName}-${
|
140
|
+
`${stack.configuration.shortName}-${lodash_1.default.chain(name)
|
141
|
+
.camelCase()
|
142
|
+
.startCase()
|
143
|
+
.replace(/\s/g, "")
|
144
|
+
.value()}`;
|
134
145
|
const env = environment ? environment : stack.createLambdaEnvironment();
|
135
146
|
const functionProps = (0, lambda_configs_1.databaseFunctionProps)(stack, env, functionName, name, functionParameters);
|
136
147
|
const mf = MonitoredFunction.create(stack, functionName, functionProps, functionParameters);
|
@@ -1,4 +1,7 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
6
|
exports.createIpRestrictionPolicyDocument = exports.createDefaultPolicyDocument = exports.createRestApi = exports.setReturnCodeForMissingAuthenticationToken = exports.add401Support = exports.add404Support = exports.DigitrafficRestApi = void 0;
|
4
7
|
const aws_apigateway_1 = require("aws-cdk-lib/aws-apigateway");
|
@@ -6,7 +9,7 @@ const aws_iam_1 = require("aws-cdk-lib/aws-iam");
|
|
6
9
|
const api_model_1 = require("../../../utils/api-model");
|
7
10
|
const mediatypes_1 = require("../../types/mediatypes");
|
8
11
|
const usage_plans_1 = require("../usage-plans");
|
9
|
-
const
|
12
|
+
const lodash_1 = __importDefault(require("lodash"));
|
10
13
|
class DigitrafficRestApi extends aws_apigateway_1.RestApi {
|
11
14
|
constructor(stack, apiId, apiName, allowFromIpAddresses, config) {
|
12
15
|
const policyDocument = allowFromIpAddresses == null
|
@@ -58,7 +61,7 @@ class DigitrafficRestApi extends aws_apigateway_1.RestApi {
|
|
58
61
|
}));
|
59
62
|
}
|
60
63
|
getModelWithReference(model) {
|
61
|
-
return
|
64
|
+
return lodash_1.default.set(model, "modelReference", (0, api_model_1.getModelReference)(model.modelId, this.restApiId));
|
62
65
|
}
|
63
66
|
addDocumentationPart(resource, parameterName, resourceName, type, properties) {
|
64
67
|
const location = {
|
@@ -1,4 +1,7 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
6
|
exports.StackCheckingAspect = void 0;
|
4
7
|
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
@@ -6,9 +9,10 @@ const aws_lambda_1 = require("aws-cdk-lib/aws-lambda");
|
|
6
9
|
const aws_s3_1 = require("aws-cdk-lib/aws-s3");
|
7
10
|
const stack_1 = require("./stack");
|
8
11
|
const aws_apigateway_1 = require("aws-cdk-lib/aws-apigateway");
|
9
|
-
const change_case_1 = require("change-case");
|
10
12
|
const aws_sqs_1 = require("aws-cdk-lib/aws-sqs");
|
11
13
|
const aws_logs_1 = require("aws-cdk-lib/aws-logs");
|
14
|
+
const change_case_1 = require("change-case");
|
15
|
+
const lodash_1 = __importDefault(require("lodash"));
|
12
16
|
const MAX_CONCURRENCY_LIMIT = 100;
|
13
17
|
const NODE_RUNTIMES = [aws_lambda_1.Runtime.NODEJS_16_X.name, aws_lambda_1.Runtime.NODEJS_18_X.name];
|
14
18
|
var ResourceType;
|
@@ -130,7 +134,7 @@ class StackCheckingAspect {
|
|
130
134
|
return (0, change_case_1.paramCase)(path) === path;
|
131
135
|
}
|
132
136
|
static isValidQueryString(name) {
|
133
|
-
return
|
137
|
+
return lodash_1.default.snakeCase(name) === name;
|
134
138
|
}
|
135
139
|
checkResourceCasing(node) {
|
136
140
|
if (node instanceof aws_apigateway_1.CfnResource) {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@digitraffic/common",
|
3
|
-
"version": "2023.
|
3
|
+
"version": "2023.11.21-1",
|
4
4
|
"description": "",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -17,11 +17,11 @@
|
|
17
17
|
"src/**/*.ts"
|
18
18
|
],
|
19
19
|
"peerDependencies": {
|
20
|
-
"@types/geojson": "^7946.0.
|
21
|
-
"aws-cdk-lib": "^2.
|
22
|
-
"aws-sdk": "^2.
|
20
|
+
"@types/geojson": "^7946.0.12",
|
21
|
+
"aws-cdk-lib": "^2.103.0",
|
22
|
+
"aws-sdk": "^2.1481.0",
|
23
23
|
"axios": "^1.5.1",
|
24
|
-
"change-case": "
|
24
|
+
"change-case": "4.1.2",
|
25
25
|
"constructs": "^10.3.0",
|
26
26
|
"date-fns-tz": "~2.0.0",
|
27
27
|
"date-fns": "~2.30.0",
|
@@ -29,44 +29,42 @@
|
|
29
29
|
"geojson-validation": "^1.0.2",
|
30
30
|
"node-ttl": "^0.2.0",
|
31
31
|
"pg-native": "^3.0.1",
|
32
|
-
"pg-promise": "^11.5.
|
32
|
+
"pg-promise": "^11.5.4"
|
33
33
|
},
|
34
34
|
"devDependencies": {
|
35
|
-
"@types/aws-lambda": "
|
36
|
-
"@types/geojson": "
|
37
|
-
"@types/etag": "
|
38
|
-
"@types/jest": "
|
39
|
-
"@types/lodash": "
|
40
|
-
"@types/node": "20.8.
|
41
|
-
"@types/
|
42
|
-
"@
|
43
|
-
"@typescript-eslint/
|
44
|
-
"
|
45
|
-
"aws-
|
46
|
-
"
|
47
|
-
"
|
48
|
-
"change-case": "^4.1.2",
|
35
|
+
"@types/aws-lambda": "8.10.125",
|
36
|
+
"@types/geojson": "7946.0.12",
|
37
|
+
"@types/etag": "1.8.2",
|
38
|
+
"@types/jest": "29.5.6",
|
39
|
+
"@types/lodash": "4.14.200",
|
40
|
+
"@types/node": "20.8.9",
|
41
|
+
"@types/sinon": "10.0.20",
|
42
|
+
"@typescript-eslint/eslint-plugin": "~6.9.0",
|
43
|
+
"@typescript-eslint/parser": "^6.9.0",
|
44
|
+
"aws-cdk-lib": "~2.103.1",
|
45
|
+
"aws-sdk": "~2.1482.0",
|
46
|
+
"axios": "^1.6.0",
|
47
|
+
"change-case": "4.1.2",
|
49
48
|
"constructs": "10.3.0",
|
50
49
|
"date-fns-tz": "~2.0.0",
|
51
50
|
"date-fns": "~2.30.0",
|
52
|
-
"eslint": "~8.
|
53
|
-
"eslint-config-prettier": "^
|
51
|
+
"eslint": "~8.52.0",
|
52
|
+
"eslint-config-prettier": "^9.0.0",
|
54
53
|
"eslint-plugin-deprecation": "~2.0.0",
|
55
54
|
"etag": "^1.8.1",
|
56
55
|
"geojson-validation": "^1.0.2",
|
57
56
|
"husky": "^8.0.3",
|
58
|
-
"jest": "^29.
|
57
|
+
"jest": "^29.7.0",
|
59
58
|
"jest-junit": "^16.0.0",
|
60
|
-
"lint-staged": "^
|
61
|
-
"lodash": "
|
59
|
+
"lint-staged": "^15.0.2",
|
60
|
+
"lodash": "~4.17.21",
|
62
61
|
"node-ttl": "^0.2.0",
|
63
62
|
"pg-native": "^3.0.1",
|
64
|
-
"pg-promise": "^11.5.
|
63
|
+
"pg-promise": "^11.5.4",
|
65
64
|
"prettier": "^2.8.8",
|
66
|
-
"
|
67
|
-
"
|
68
|
-
"
|
69
|
-
"ts-jest": "^29.1.0",
|
65
|
+
"rimraf": "^5.0.5",
|
66
|
+
"sinon": "17.0.0",
|
67
|
+
"ts-jest": "^29.1.1",
|
70
68
|
"typescript": "~4.9.5",
|
71
69
|
"velocityjs": "2.0.6"
|
72
70
|
},
|
@@ -9,10 +9,11 @@ import {
|
|
9
9
|
LambdaEnvironment,
|
10
10
|
MonitoredFunctionParameters,
|
11
11
|
} from "../stack/lambda-configs";
|
12
|
-
import { pascalCase } from "change-case";
|
13
12
|
import { DigitrafficLogSubscriptions } from "../stack/subscription";
|
14
13
|
import { TrafficType } from "../../../types/traffictype";
|
15
14
|
|
15
|
+
import _ from "lodash";
|
16
|
+
|
16
17
|
/**
|
17
18
|
* Allows customization of CloudWatch Alarm properties
|
18
19
|
*/
|
@@ -117,7 +118,11 @@ export class MonitoredFunction extends Function {
|
|
117
118
|
): MonitoredFunction {
|
118
119
|
const functionName =
|
119
120
|
functionParameters?.functionName ??
|
120
|
-
`${stack.configuration.shortName}-${
|
121
|
+
`${stack.configuration.shortName}-${_.chain(name)
|
122
|
+
.camelCase()
|
123
|
+
.startCase()
|
124
|
+
.replace(/\s/g, "")
|
125
|
+
.value()}`;
|
121
126
|
const functionProps = databaseFunctionProps(
|
122
127
|
stack,
|
123
128
|
environment,
|
@@ -315,7 +320,11 @@ export class MonitoredDBFunction {
|
|
315
320
|
): MonitoredFunction {
|
316
321
|
const functionName =
|
317
322
|
functionParameters?.functionName ??
|
318
|
-
`${stack.configuration.shortName}-${
|
323
|
+
`${stack.configuration.shortName}-${_.chain(name)
|
324
|
+
.camelCase()
|
325
|
+
.startCase()
|
326
|
+
.replace(/\s/g, "")
|
327
|
+
.value()}`;
|
319
328
|
const env = environment ? environment : stack.createLambdaEnvironment();
|
320
329
|
const functionProps = databaseFunctionProps(
|
321
330
|
stack,
|
@@ -26,7 +26,7 @@ import { DocumentationPart, DocumentationProperties } from "../documentation";
|
|
26
26
|
import { createDefaultUsagePlan, createUsagePlan } from "../usage-plans";
|
27
27
|
import { DigitrafficStack } from "./stack";
|
28
28
|
|
29
|
-
import
|
29
|
+
import _ from "lodash";
|
30
30
|
|
31
31
|
export class DigitrafficRestApi extends RestApi {
|
32
32
|
readonly apiKeyIds: string[];
|
@@ -109,10 +109,10 @@ export class DigitrafficRestApi extends RestApi {
|
|
109
109
|
}
|
110
110
|
|
111
111
|
private getModelWithReference(model: Model): ModelWithReference {
|
112
|
-
return
|
112
|
+
return _.set(
|
113
|
+
model,
|
113
114
|
"modelReference",
|
114
|
-
getModelReference(model.modelId, this.restApiId)
|
115
|
-
model
|
115
|
+
getModelReference(model.modelId, this.restApiId)
|
116
116
|
) as ModelWithReference;
|
117
117
|
}
|
118
118
|
|
@@ -4,9 +4,10 @@ import { CfnBucket } from "aws-cdk-lib/aws-s3";
|
|
4
4
|
import { DigitrafficStack, SOLUTION_KEY } from "./stack";
|
5
5
|
import { IConstruct } from "constructs";
|
6
6
|
import { CfnMethod, CfnResource } from "aws-cdk-lib/aws-apigateway";
|
7
|
-
import { paramCase, snakeCase } from "change-case";
|
8
7
|
import { CfnQueue } from "aws-cdk-lib/aws-sqs";
|
9
8
|
import { LogRetention } from "aws-cdk-lib/aws-logs";
|
9
|
+
import { paramCase } from "change-case";
|
10
|
+
import _ from "lodash";
|
10
11
|
import IntegrationProperty = CfnMethod.IntegrationProperty;
|
11
12
|
|
12
13
|
const MAX_CONCURRENCY_LIMIT = 100;
|
@@ -214,7 +215,7 @@ export class StackCheckingAspect implements IAspect {
|
|
214
215
|
}
|
215
216
|
|
216
217
|
private static isValidQueryString(name: string) {
|
217
|
-
return snakeCase(name) === name;
|
218
|
+
return _.snakeCase(name) === name;
|
218
219
|
}
|
219
220
|
|
220
221
|
private checkResourceCasing(node: IConstruct) {
|