Skip to content

Commit cbd491b

Browse files
committed
refactor(core): generalize fetch dependency type
1 parent 0a5a952 commit cbd491b

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/core/core.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
} from "@aws-sdk/client-bedrock-agentcore";
1313
import type { RuntimeInvokeRequest } from "../handlers/runtime/types";
1414
import { CoreClient } from "./index";
15-
import type { ClientConfig, RuntimeFetch } from "./types";
15+
import type { ClientConfig, CoreFetch } from "./types";
1616
import { toClientConfig } from "./utils";
1717
import { createSilentLogger } from "../testing";
1818

@@ -52,7 +52,7 @@ async function resolveRuntimeApplicationHeaders(
5252
return headers;
5353
}
5454

55-
function customJwtCore(fetch: RuntimeFetch, endpoint = "https://runtime.test"): CoreClient {
55+
function customJwtCore(fetch: CoreFetch, endpoint = "https://runtime.test"): CoreClient {
5656
return new CoreClient({
5757
createControlClient: fakeControl,
5858
createDataClient: (config) =>

src/core/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import { RuntimeClient } from "./runtime";
77
import type {
88
AwsClients,
99
ClientConfig,
10+
CoreFetch,
1011
CreateControlClient,
1112
CreateDataClient,
1213
CreateIamClient,
13-
RuntimeFetch,
1414
} from "./types";
1515
import type { Logger } from "../logging";
1616
import type { ProjectManager } from "../handlers/project/types";
@@ -19,18 +19,18 @@ import { FsProjectManager } from "./project";
1919
export type {
2020
AwsClients,
2121
ClientConfig,
22+
CoreFetch,
2223
CreateControlClient,
2324
CreateDataClient,
2425
CreateIamClient,
25-
RuntimeFetch,
2626
} from "./types";
2727

2828
type CoreClientConfig = {
2929
createControlClient: CreateControlClient;
3030
createDataClient: CreateDataClient;
3131
createIamClient: CreateIamClient;
3232
logger: Logger;
33-
fetch?: RuntimeFetch;
33+
fetch?: CoreFetch;
3434
};
3535

3636
// CoreClient is the single entry point to the Bedrock AgentCore APIs. It owns the

src/core/runtime.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import type {
1616
RuntimeInvokeRequest,
1717
RuntimeInvokeResponse,
1818
} from "../handlers/runtime/types";
19-
import type { AwsClients, CoreOptions, RuntimeFetch } from "./types";
19+
import type { AwsClients, CoreFetch, CoreOptions } from "./types";
2020
import { abortable } from "./abortable";
2121
import { toClientConfig } from "./utils";
2222

@@ -25,7 +25,7 @@ async function* emptyBody(): AsyncGenerator<Uint8Array> {}
2525
export class RuntimeClient implements CoreRuntimeClient {
2626
constructor(
2727
private readonly clients: AwsClients,
28-
private readonly fetch: RuntimeFetch,
28+
private readonly fetch: CoreFetch,
2929
) {}
3030

3131
async invokeRuntime(

src/core/types.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export interface ClientConfig {
2525
export type CreateControlClient = (config: ClientConfig) => BedrockAgentCoreControlClient;
2626
export type CreateDataClient = (config: ClientConfig) => BedrockAgentCoreClient;
2727
export type CreateIamClient = (config: ClientConfig) => IAMClient;
28-
export type RuntimeFetch = (
28+
export type CoreFetch = (
2929
...args: Parameters<typeof globalThis.fetch>
3030
) => ReturnType<typeof globalThis.fetch>;
3131

0 commit comments

Comments
 (0)