@digitraffic/common 2024.10.9-1 → 2024.11.13-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/__test__/utils/date-utils.test.js +5 -1
- package/dist/aws/infra/acl-builder.d.ts +1 -1
- package/dist/aws/infra/acl-builder.js +13 -11
- package/dist/aws/infra/api/integration.js +1 -2
- package/dist/utils/date-utils.d.ts +1 -1
- package/dist/utils/date-utils.js +4 -3
- package/package.json +18 -17
@@ -19,9 +19,13 @@ describe("CommonDateUtilsTest", () => {
|
|
19
19
|
const end = new Date(start.getTime() + 1234 * 1000);
|
20
20
|
expect(CommonDateUtils.countDiffInSeconds(start, end)).toEqual(1234);
|
21
21
|
});
|
22
|
-
test("
|
22
|
+
test("dateToUTCString - preserves UTC from parsed string", () => {
|
23
23
|
const date = parseISO("2023-01-01T00:00Z");
|
24
24
|
expect(CommonDateUtils.dateToUTCString(date, CommonDateUtils.MYSQL_DATETIME_FORMAT)).toEqual("2023-01-01 00:00");
|
25
25
|
});
|
26
|
+
test("dateToUTCString - +02:00 to UTC from parsed string", () => {
|
27
|
+
const date = parseISO("2023-01-01T00:00+02:00");
|
28
|
+
expect(CommonDateUtils.dateToUTCString(date, CommonDateUtils.MYSQL_DATETIME_FORMAT)).toEqual("2022-12-31 22:00");
|
29
|
+
});
|
26
30
|
});
|
27
31
|
//# sourceMappingURL=date-utils.test.js.map
|
@@ -5,7 +5,7 @@ export type ExcludedAWSRules = {
|
|
5
5
|
[key in AWSManagedWafRule]?: string[];
|
6
6
|
};
|
7
7
|
export type CfnWebAclRuleProperty = {
|
8
|
-
[P in keyof CfnWebACL.RuleProperty as Exclude<P, "priority">]:
|
8
|
+
[P in keyof CfnWebACL.RuleProperty as Exclude<P, "priority">]: CfnWebACL.RuleProperty[P];
|
9
9
|
};
|
10
10
|
/**
|
11
11
|
* Builder class for building CfnWebACL.
|
@@ -62,16 +62,18 @@ export class AclBuilder {
|
|
62
62
|
withThrottleRule(name, limit, isHeaderRequired, isBasedOnIpAndUriPath, customResponseBodyKey) {
|
63
63
|
const isBlockRule = !!customResponseBodyKey;
|
64
64
|
const rules = isBlockRule ? this._blockRules : this._countRules;
|
65
|
-
const action = isBlockRule
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
65
|
+
const action = isBlockRule
|
66
|
+
? {
|
67
|
+
block: {
|
68
|
+
customResponse: {
|
69
|
+
responseCode: 429,
|
70
|
+
customResponseBodyKey,
|
71
|
+
},
|
70
72
|
},
|
71
|
-
}
|
72
|
-
|
73
|
-
|
74
|
-
|
73
|
+
}
|
74
|
+
: {
|
75
|
+
count: {},
|
76
|
+
};
|
75
77
|
rules.push({
|
76
78
|
name,
|
77
79
|
visibilityConfig: {
|
@@ -164,9 +166,9 @@ export class AclBuilder {
|
|
164
166
|
build() {
|
165
167
|
const addPriority = (rule, priority) => ({
|
166
168
|
...rule,
|
167
|
-
priority
|
169
|
+
priority,
|
168
170
|
});
|
169
|
-
const rules = concat(zipWith(this._countRules, range(this._countRules.length), addPriority), zipWith(this._blockRules, range(this._blockRules.length).map(n => n + this._countRules.length), addPriority));
|
171
|
+
const rules = concat(zipWith(this._countRules, range(this._countRules.length), addPriority), zipWith(this._blockRules, range(this._blockRules.length).map((n) => n + this._countRules.length), addPriority));
|
170
172
|
if (rules.length === 0) {
|
171
173
|
throw new Error("No rules defined for WebACL");
|
172
174
|
}
|
@@ -17,9 +17,8 @@ export class DigitrafficIntegration {
|
|
17
17
|
this._passAllQueryParameters = false;
|
18
18
|
}
|
19
19
|
passAllQueryParameters() {
|
20
|
-
if (this.parameters.some((p) => p.type === "querystring"))
|
20
|
+
if (this.parameters.some((p) => p.type === "querystring"))
|
21
21
|
throw new Error("Can't add query parameters with pass all");
|
22
|
-
}
|
23
22
|
this._passAllQueryParameters = true;
|
24
23
|
return this;
|
25
24
|
}
|
@@ -24,4 +24,4 @@ export declare function dateFromIsoString(isoString: string): Date;
|
|
24
24
|
/**
|
25
25
|
* Formats a date in UTC in the given format, regardless of system time zone
|
26
26
|
*/
|
27
|
-
export declare function dateToUTCString(date: Date,
|
27
|
+
export declare function dateToUTCString(date: Date, formatString: string): string;
|
package/dist/utils/date-utils.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
import {
|
1
|
+
import { TZDate } from "@date-fns/tz";
|
2
|
+
import { format } from "date-fns";
|
2
3
|
/**
|
3
4
|
* Constant for the 1970-01-01T00:00:00Z epoch Date.
|
4
5
|
*/
|
@@ -38,7 +39,7 @@ function isValidDate(d) {
|
|
38
39
|
/**
|
39
40
|
* Formats a date in UTC in the given format, regardless of system time zone
|
40
41
|
*/
|
41
|
-
export function dateToUTCString(date,
|
42
|
-
return
|
42
|
+
export function dateToUTCString(date, formatString) {
|
43
|
+
return format(new TZDate(date, UTC), formatString);
|
43
44
|
}
|
44
45
|
//# sourceMappingURL=date-utils.js.map
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@digitraffic/common",
|
3
|
-
"version": "2024.
|
3
|
+
"version": "2024.11.13-1",
|
4
4
|
"description": "",
|
5
5
|
"type": "module",
|
6
6
|
"repository": {
|
@@ -113,8 +113,8 @@
|
|
113
113
|
"aws-cdk-lib": "^2.161.1",
|
114
114
|
"change-case": "^5.4.4",
|
115
115
|
"constructs": "~10.3.0",
|
116
|
-
"date-fns": "
|
117
|
-
"date-fns
|
116
|
+
"date-fns": "~4.1.0",
|
117
|
+
"@date-fns/tz": "1.1.2",
|
118
118
|
"etag": "^1.8.1",
|
119
119
|
"geojson-validation": "^1.0.2",
|
120
120
|
"ky": "^1.7.2",
|
@@ -125,18 +125,18 @@
|
|
125
125
|
"zod": "~3.23.8"
|
126
126
|
},
|
127
127
|
"devDependencies": {
|
128
|
-
"@aws-sdk/client-api-gateway": "^3.
|
129
|
-
"@aws-sdk/client-s3": "^3.
|
130
|
-
"@aws-sdk/client-secrets-manager": "^3.
|
131
|
-
"@aws-sdk/client-sns": "^3.
|
132
|
-
"@aws-sdk/lib-storage": "^3.
|
128
|
+
"@aws-sdk/client-api-gateway": "^3.669.0",
|
129
|
+
"@aws-sdk/client-s3": "^3.669.0",
|
130
|
+
"@aws-sdk/client-secrets-manager": "^3.669.0",
|
131
|
+
"@aws-sdk/client-sns": "^3.669.0",
|
132
|
+
"@aws-sdk/lib-storage": "^3.669.0",
|
133
133
|
"@digitraffic/eslint-config": "^3.0.1",
|
134
134
|
"@jest/globals": "^29.7.0",
|
135
135
|
"@rushstack/eslint-config": "^3.7.1",
|
136
|
-
"@rushstack/heft": "^0.
|
137
|
-
"@rushstack/heft-jest-plugin": "^0.12.
|
138
|
-
"@rushstack/heft-lint-plugin": "^0.
|
139
|
-
"@rushstack/heft-typescript-plugin": "^0.5.
|
136
|
+
"@rushstack/heft": "^0.68.2",
|
137
|
+
"@rushstack/heft-jest-plugin": "^0.12.18",
|
138
|
+
"@rushstack/heft-lint-plugin": "^0.5.0",
|
139
|
+
"@rushstack/heft-typescript-plugin": "^0.5.35",
|
140
140
|
"@smithy/fetch-http-handler": "3.2.9",
|
141
141
|
"@smithy/types": "^3.5.0",
|
142
142
|
"@types/aws-lambda": "8.10.145",
|
@@ -149,11 +149,12 @@
|
|
149
149
|
"@types/node": "20.14.9",
|
150
150
|
"@typescript-eslint/eslint-plugin": "~7.14.1",
|
151
151
|
"@typescript-eslint/parser": "^7.18.0",
|
152
|
-
"aws-cdk-lib": "^2.
|
152
|
+
"aws-cdk-lib": "^2.162.0",
|
153
|
+
"aws-sdk": "^2.1691.0",
|
153
154
|
"change-case": "^5.4.4",
|
154
|
-
"constructs": "~10.3.
|
155
|
-
"date-fns": "
|
156
|
-
"date-fns
|
155
|
+
"constructs": "~10.3.1",
|
156
|
+
"date-fns": "~4.1.0",
|
157
|
+
"@date-fns/tz": "1.1.2",
|
157
158
|
"eslint": "^8.57.1",
|
158
159
|
"eslint-config-prettier": "^9.1.0",
|
159
160
|
"eslint-plugin-deprecation": "~3.0.0",
|
@@ -171,7 +172,7 @@
|
|
171
172
|
"prettier": "^3.3.3",
|
172
173
|
"rimraf": "^6.0.1",
|
173
174
|
"ts-jest": "^29.2.5",
|
174
|
-
"typescript": "~5.
|
175
|
+
"typescript": "~5.6.3",
|
175
176
|
"velocityjs": "^2.0.6",
|
176
177
|
"zod": "~3.23.8"
|
177
178
|
},
|