Skip to content

Commit 49ad573

Browse files
committed
fix: use object for identifiers
1 parent 316b8b6 commit 49ad573

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

packages/middleware-endpoint-discovery/src/getCacheKey.spec.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,15 @@ describe(getCacheKey.name, () => {
1717
});
1818

1919
it("returns commandName and identifiers if passed", async () => {
20-
const identifiers = new Map().set("key", "value");
21-
const identifiersObj = { key: "value" };
20+
const identifiers = { key: "value" };
2221
const cacheKey = await getCacheKey(commandName, config, { identifiers });
23-
expect(cacheKey).toEqual(
24-
JSON.stringify({ accessKeyId: mockCredentials.accessKeyId, commandName, identifiers: identifiersObj })
25-
);
22+
expect(cacheKey).toEqual(JSON.stringify({ accessKeyId: mockCredentials.accessKeyId, commandName, identifiers }));
2623
});
2724

2825
it("returns same cache key irrespective of key order in identifiers", async () => {
29-
const identifiers1 = new Map().set("key1", "value1").set("key2", "value2");
26+
const identifiers1 = { key1: "value1", key2: "value2" };
3027
const cacheKey1 = await getCacheKey(commandName, config, { identifiers: identifiers1 });
31-
const identifiers2 = new Map().set("key2", "value2").set("key1", "value1");
28+
const identifiers2 = { key2: "value2", key1: "value1" };
3229
const cacheKey2 = await getCacheKey(commandName, config, { identifiers: identifiers2 });
3330
expect(cacheKey1).toStrictEqual(cacheKey2);
3431
});

packages/middleware-endpoint-discovery/src/getCacheKey.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const getCacheKey = async (
77
commandName: string,
88
config: { credentials: Provider<Credentials> },
99
options: {
10-
identifiers?: Map<string, string>;
10+
identifiers?: { [key: string]: string };
1111
}
1212
) => {
1313
const { accessKeyId } = await config.credentials();
@@ -16,7 +16,7 @@ export const getCacheKey = async (
1616
...(accessKeyId && { accessKeyId }),
1717
...(identifiers && {
1818
commandName,
19-
identifiers: Array.from(identifiers)
19+
identifiers: Object.entries(identifiers)
2020
.sort()
2121
.reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {}),
2222
}),

packages/middleware-endpoint-discovery/src/getEndpointDiscoveryCommandPlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const endpointDiscoveryMiddlewareOptions: FinalizeRequestHandlerOptions =
1212

1313
export type EndpointDiscoveryMiddlewareConfig = {
1414
isDiscoveredEndpointRequired: boolean;
15-
identifiers?: Map<string, string>;
15+
identifiers?: { [key: string]: string };
1616
};
1717

1818
export const getEndpointDiscoveryCommandPlugin = (

0 commit comments

Comments
 (0)