Skip to content

Commit 9fa89eb

Browse files
authored
chore(middleware-recursion-detection): update version of lambda invoke store (#7462)
* chore(middleware-recursion-detection): update version of lambda invoke store * chore: update types tsconfig to node16 module resolution * chore: compilation fixes
1 parent 45f629d commit 9fa89eb

File tree

7 files changed

+46
-25
lines changed

7 files changed

+46
-25
lines changed

.eslintrc.js

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,32 @@ module.exports = {
2828
/** Errors */
2929
"simple-import-sort/imports": "error",
3030
"sort-export-all/sort-export-all": "error",
31-
"no-restricted-imports": [
32-
"error",
33-
{
34-
patterns: [
35-
{
36-
group: ["*src*", "!*CsrC*", "*dist-*"],
37-
},
38-
],
39-
},
40-
],
4131
},
4232
ignorePatterns: [
4333
"packages/nested-clients/src/submodules/**/protocols/*.ts",
4434
"packages/nested-clients/src/submodules/**/models/*.ts",
4535
],
36+
overrides: [
37+
{
38+
files: ["lib/*/src/**/*.ts", "clients/*/src/**/*.ts", "packages/*/src/**/*.ts", "private/*/src/**/*.ts"],
39+
excludedFiles: [
40+
"lib/*/src/**/*.spec.ts",
41+
"clients/*/src/**/*.spec.ts",
42+
"packages/*/src/**/*.spec.ts",
43+
"private/*/src/**/*.spec.ts",
44+
],
45+
rules: {
46+
"no-restricted-imports": [
47+
"error",
48+
{
49+
patterns: [
50+
{
51+
group: ["*src*", "*dist-*"],
52+
},
53+
],
54+
},
55+
],
56+
},
57+
},
58+
],
4659
};

packages/middleware-flexible-checksums/src/getCrc32ChecksumAlgorithmFunction.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe(getCrc32ChecksumAlgorithmFunction.name, () => {
1515
const mockData = new Uint8Array([1, 2, 3]);
1616
const mockChecksum = 42;
1717

18-
// @ts-expect-error crc32 is defined only for Node.js >=v20.15.0 and >=v22.2.0.
18+
// @ts-ignore
1919
zlib.crc32 = vi
2020
.fn()
2121
.mockReturnValueOnce(mockChecksum)
@@ -24,20 +24,20 @@ describe(getCrc32ChecksumAlgorithmFunction.name, () => {
2424
const crc32Fn = getCrc32ChecksumAlgorithmFunction();
2525
expect(crc32Fn).not.toBe(AwsCrc32);
2626

27-
// @ts-expect-error crc32 is defined only for Node.js >=v20.15.0 and >=v22.2.0.
27+
// @ts-ignore
2828
expect(zlib.crc32).not.toHaveBeenCalled();
2929
const crc32 = new crc32Fn();
30-
// @ts-expect-error crc32 is defined only for Node.js >=v20.15.0 and >=v22.2.0.
30+
// @ts-ignore
3131
expect(zlib.crc32).not.toHaveBeenCalled();
3232
expect(await crc32.digest()).toEqual(numToUint8(0));
3333

3434
crc32.update(mockData);
35-
// @ts-expect-error crc32 is defined only for Node.js >=v20.15.0 and >=v22.2.0.
35+
// @ts-ignore
3636
expect(zlib.crc32).toHaveBeenCalledWith(mockData, 0);
3737
expect(await crc32.digest()).toEqual(numToUint8(mockChecksum));
3838

3939
crc32.update(mockData);
40-
// @ts-expect-error crc32 is defined only for Node.js >=v20.15.0 and >=v22.2.0.
40+
// @ts-ignore
4141
expect(zlib.crc32).toHaveBeenCalledWith(mockData, mockChecksum);
4242
expect(await crc32.digest()).toEqual(numToUint8(2 * mockChecksum));
4343

packages/middleware-flexible-checksums/src/getCrc32ChecksumAlgorithmFunction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class NodeCrc32 implements Checksum {
77
private checksum = 0;
88

99
update(data: Uint8Array) {
10-
// @ts-expect-error crc32 is defined only for Node.js >=v20.15.0 and >=v22.2.0.
10+
// @ts-ignore
1111
this.checksum = zlib.crc32(data, this.checksum);
1212
}
1313

@@ -21,7 +21,7 @@ class NodeCrc32 implements Checksum {
2121
}
2222

2323
export const getCrc32ChecksumAlgorithmFunction = () => {
24-
// @ts-expect-error crc32 is defined only for Node.js >=v20.15.0 and >=v22.2.0.
24+
// @ts-ignore
2525
if (typeof zlib.crc32 === "undefined") {
2626
return AwsCrc32;
2727
}

packages/middleware-recursion-detection/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"license": "Apache-2.0",
2626
"dependencies": {
2727
"@aws-sdk/types": "*",
28-
"@aws/lambda-invoke-store": "^0.0.1",
28+
"@aws/lambda-invoke-store": "^0.1.1",
2929
"@smithy/protocol-http": "^5.3.3",
3030
"@smithy/types": "^4.8.0",
3131
"tslib": "^2.6.2"

packages/middleware-recursion-detection/src/recursionDetectionMiddleware.spec.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
import { InvokeStore } from "@aws/lambda-invoke-store";
1+
// @ts-ignore
2+
import { InvokeStore as InvokeStoreImpl } from "@aws/lambda-invoke-store";
3+
// eslint-disable-next-line no-restricted-imports
4+
import type { InvokeStore as InvokeStoreType } from "@aws/lambda-invoke-store/dist-types/invoke-store.d";
25
import { HttpRequest } from "@smithy/protocol-http";
36
import { afterAll, beforeEach, describe, expect, test as it, vi } from "vitest";
47

58
import { recursionDetectionMiddleware } from "./recursionDetectionMiddleware";
69

10+
const InvokeStore = InvokeStoreImpl as typeof InvokeStoreType;
11+
712
describe(recursionDetectionMiddleware.name, () => {
813
const mockNextHandler = vi.fn();
914
const originEnv = process.env;

packages/middleware-recursion-detection/src/recursionDetectionMiddleware.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
// @ts-ignore
12
import { InvokeStore } from "@aws/lambda-invoke-store";
3+
// eslint-disable-next-line no-restricted-imports
4+
import type { InvokeStore as InvokeStoreType } from "@aws/lambda-invoke-store/dist-types/invoke-store.d";
25
import { HttpRequest } from "@smithy/protocol-http";
36
import {
47
BuildHandler,
@@ -34,7 +37,7 @@ export const recursionDetectionMiddleware =
3437
const functionName = process.env[ENV_LAMBDA_FUNCTION_NAME];
3538

3639
const traceIdFromEnv = process.env[ENV_TRACE_ID];
37-
const traceIdFromInvokeStore = InvokeStore.getXRayTraceId();
40+
const traceIdFromInvokeStore = (InvokeStore as typeof InvokeStoreType).getXRayTraceId();
3841
const traceId = traceIdFromInvokeStore ?? traceIdFromEnv;
3942

4043
const nonEmptyString = (str: unknown): str is string => typeof str === "string" && str.length > 0;

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23610,7 +23610,7 @@ __metadata:
2361023610
resolution: "@aws-sdk/middleware-recursion-detection@workspace:packages/middleware-recursion-detection"
2361123611
dependencies:
2361223612
"@aws-sdk/types": "npm:*"
23613-
"@aws/lambda-invoke-store": "npm:^0.0.1"
23613+
"@aws/lambda-invoke-store": "npm:^0.1.1"
2361423614
"@smithy/protocol-http": "npm:^5.3.3"
2361523615
"@smithy/types": "npm:^4.8.0"
2361623616
"@tsconfig/recommended": "npm:1.0.1"
@@ -24532,10 +24532,10 @@ __metadata:
2453224532
languageName: node
2453324533
linkType: hard
2453424534

24535-
"@aws/lambda-invoke-store@npm:^0.0.1":
24536-
version: 0.0.1
24537-
resolution: "@aws/lambda-invoke-store@npm:0.0.1"
24538-
checksum: 10c0/0bbf3060014a462177fb743e132e9b106a6743ad9cd905df4bd26e9ca8bfe2cc90473b03a79938fa908934e45e43f366f57af56a697991abda71d9ac92f5018f
24535+
"@aws/lambda-invoke-store@npm:^0.1.1":
24536+
version: 0.1.1
24537+
resolution: "@aws/lambda-invoke-store@npm:0.1.1"
24538+
checksum: 10c0/27c90d9af7cca7ff4870e87dc303516e6d09ebe18f5fa13813397cd6a37fd26cf3ff1715469e3c5323fea0404a55c110f35e21bcc3ea595a4f6ba6406ea1f103
2453924539
languageName: node
2454024540
linkType: hard
2454124541

0 commit comments

Comments
 (0)