@inkeep/ai-api
Advanced tools
Comparing version 0.6.2 to 0.7.2
@@ -36,2 +36,5 @@ # ChatSession | ||
], | ||
tags: [ | ||
"<value>", | ||
], | ||
}, | ||
@@ -38,0 +41,0 @@ chatMode: ChatModeOptions.Auto, |
@@ -1,4 +0,6 @@ | ||
import { AfterErrorContext, AfterErrorHook, AfterSuccessContext, AfterSuccessHook, BeforeRequestContext, BeforeRequestHook, Hooks, SDKInitHook, SDKInitOptions } from "./types"; | ||
import { RequestInput } from "../lib/http"; | ||
import { AfterErrorContext, AfterErrorHook, AfterSuccessContext, AfterSuccessHook, BeforeRequestContext, BeforeRequestHook, BeforeCreateRequestHook, BeforeCreateRequestContext, Hooks, SDKInitHook, SDKInitOptions } from "./types"; | ||
export declare class SDKHooks implements Hooks { | ||
sdkInitHooks: SDKInitHook[]; | ||
beforeCreateRequestHooks: BeforeCreateRequestHook[]; | ||
beforeRequestHooks: BeforeRequestHook[]; | ||
@@ -9,2 +11,3 @@ afterSuccessHooks: AfterSuccessHook[]; | ||
registerSDKInitHook(hook: SDKInitHook): void; | ||
registerBeforeCreateRequestHook(hook: BeforeCreateRequestHook): void; | ||
registerBeforeRequestHook(hook: BeforeRequestHook): void; | ||
@@ -14,2 +17,3 @@ registerAfterSuccessHook(hook: AfterSuccessHook): void; | ||
sdkInit(opts: SDKInitOptions): SDKInitOptions; | ||
beforeCreateRequest(hookCtx: BeforeCreateRequestContext, input: RequestInput): RequestInput; | ||
beforeRequest(hookCtx: BeforeRequestContext, request: Request): Promise<Request>; | ||
@@ -16,0 +20,0 @@ afterSuccess(hookCtx: AfterSuccessContext, response: Response): Promise<Response>; |
@@ -10,2 +10,3 @@ "use strict"; | ||
this.sdkInitHooks = []; | ||
this.beforeCreateRequestHooks = []; | ||
this.beforeRequestHooks = []; | ||
@@ -18,2 +19,5 @@ this.afterSuccessHooks = []; | ||
} | ||
registerBeforeCreateRequestHook(hook) { | ||
this.beforeCreateRequestHooks.push(hook); | ||
} | ||
registerBeforeRequestHook(hook) { | ||
@@ -31,2 +35,9 @@ this.beforeRequestHooks.push(hook); | ||
} | ||
beforeCreateRequest(hookCtx, input) { | ||
let inp = input; | ||
for (const hook of this.beforeCreateRequestHooks) { | ||
inp = hook.beforeCreateRequest(hookCtx, inp); | ||
} | ||
return inp; | ||
} | ||
async beforeRequest(hookCtx, request) { | ||
@@ -33,0 +44,0 @@ let req = request; |
@@ -1,2 +0,2 @@ | ||
import { HTTPClient } from "../lib/http"; | ||
import { HTTPClient, RequestInput } from "../lib/http"; | ||
export type HookContext = { | ||
@@ -12,2 +12,3 @@ operationID: string; | ||
}; | ||
export type BeforeCreateRequestContext = HookContext & {}; | ||
export type BeforeRequestContext = HookContext & {}; | ||
@@ -23,24 +24,34 @@ export type AfterSuccessContext = HookContext & {}; | ||
} | ||
/** | ||
* BeforeRequestHook is called before the SDK sends a request. The hook can | ||
* modify the request before it is sent or throw an error to stop the request | ||
* from being sent. | ||
*/ | ||
export interface BeforeCreateRequestHook { | ||
/** | ||
* A hook that is called before the SDK creates a `Request` object. The hook | ||
* can modify how a request is constructed since certain modifications, like | ||
* changing the request URL, cannot be done on a request object directly. | ||
*/ | ||
beforeCreateRequest: (hookCtx: BeforeCreateRequestContext, input: RequestInput) => RequestInput; | ||
} | ||
export interface BeforeRequestHook { | ||
/** | ||
* A hook that is called before the SDK sends a request. The hook can | ||
* introduce instrumentation code such as logging, tracing and metrics or | ||
* replace the request before it is sent or throw an error to stop the | ||
* request from being sent. | ||
*/ | ||
beforeRequest: (hookCtx: BeforeRequestContext, request: Request) => Awaitable<Request>; | ||
} | ||
/** | ||
* AfterSuccessHook is called after the SDK receives a response. The hook can | ||
* modify the response before it is handled or throw an error to stop the | ||
* response from being handled. | ||
*/ | ||
export interface AfterSuccessHook { | ||
/** | ||
* A hook that is called after the SDK receives a response. The hook can | ||
* introduce instrumentation code such as logging, tracing and metrics or | ||
* modify the response before it is handled or throw an error to stop the | ||
* response from being handled. | ||
*/ | ||
afterSuccess: (hookCtx: AfterSuccessContext, response: Response) => Awaitable<Response>; | ||
} | ||
/** | ||
* AfterErrorHook is called after the SDK encounters an error, or a | ||
* non-successful response. The hook can modify the response if available | ||
* otherwise modify the error. | ||
*/ | ||
export interface AfterErrorHook { | ||
/** | ||
* A hook that is called after the SDK encounters an error, or a | ||
* non-successful response. The hook can introduce instrumentation code such | ||
* as logging, tracing and metrics or modify the response or error values. | ||
*/ | ||
afterError: (hookCtx: AfterErrorContext, response: Response | null, error: unknown) => Awaitable<{ | ||
@@ -54,2 +65,4 @@ response: Response | null; | ||
registerSDKInitHook(hook: SDKInitHook): void; | ||
/** Registers a hook to be used by the SDK for to modify `Request` construction. */ | ||
registerBeforeCreateRequestHook(hook: BeforeCreateRequestHook): void; | ||
/** Registers a hook to be used by the SDK for the before request event. */ | ||
@@ -56,0 +69,0 @@ registerBeforeRequestHook(hook: BeforeRequestHook): void; |
@@ -24,9 +24,9 @@ import { HTTPClient } from "./http"; | ||
export declare function serverURLFromOptions(options: SDKOptions): URL | null; | ||
export declare const SDK_METADATA: Readonly<{ | ||
language: "typescript"; | ||
openapiDocVersion: "0.1.0"; | ||
sdkVersion: "0.6.2"; | ||
genVersion: "2.306.0"; | ||
userAgent: "speakeasy-sdk/typescript 0.6.2 2.306.0 0.1.0 @inkeep/ai-api"; | ||
}>; | ||
export declare const SDK_METADATA: { | ||
readonly language: "typescript"; | ||
readonly openapiDocVersion: "0.1.0"; | ||
readonly sdkVersion: "0.7.2"; | ||
readonly genVersion: "2.314.0"; | ||
readonly userAgent: "speakeasy-sdk/typescript 0.7.2 2.314.0 0.1.0 @inkeep/ai-api"; | ||
}; | ||
//# sourceMappingURL=config.d.ts.map |
@@ -32,9 +32,9 @@ "use strict"; | ||
exports.serverURLFromOptions = serverURLFromOptions; | ||
exports.SDK_METADATA = Object.freeze({ | ||
exports.SDK_METADATA = { | ||
language: "typescript", | ||
openapiDocVersion: "0.1.0", | ||
sdkVersion: "0.6.2", | ||
genVersion: "2.306.0", | ||
userAgent: "speakeasy-sdk/typescript 0.6.2 2.306.0 0.1.0 @inkeep/ai-api", | ||
}); | ||
sdkVersion: "0.7.2", | ||
genVersion: "2.314.0", | ||
userAgent: "speakeasy-sdk/typescript 0.7.2 2.314.0 0.1.0 @inkeep/ai-api", | ||
}; | ||
//# sourceMappingURL=config.js.map |
@@ -12,14 +12,9 @@ export declare class EncodingError extends Error { | ||
}): string; | ||
export declare const encodeForm: (key: string, value: unknown, options?: { | ||
type FormEncoder = (key: string, value: unknown, options?: { | ||
explode?: boolean; | ||
charEncoding?: "percent" | "none"; | ||
}) => string; | ||
export declare const encodeSpaceDelimited: (key: string, value: unknown, options?: { | ||
explode?: boolean; | ||
charEncoding?: "percent" | "none"; | ||
}) => string; | ||
export declare const encodePipeDelimited: (key: string, value: unknown, options?: { | ||
explode?: boolean; | ||
charEncoding?: "percent" | "none"; | ||
}) => string; | ||
export declare const encodeForm: FormEncoder; | ||
export declare const encodeSpaceDelimited: FormEncoder; | ||
export declare const encodePipeDelimited: FormEncoder; | ||
export declare function encodeBodyForm(key: string, value: unknown, options?: { | ||
@@ -40,4 +35,3 @@ explode?: boolean; | ||
}) => string; | ||
declare function explode(key: string, value: unknown): [string, unknown][]; | ||
export {}; | ||
//# sourceMappingURL=encodings.d.ts.map |
export type Fetcher = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>; | ||
type Awaitable<T> = T | Promise<T>; | ||
export type Awaitable<T> = T | Promise<T>; | ||
export type RequestInput = { | ||
/** | ||
* The URL the request will use. | ||
*/ | ||
url: URL; | ||
/** | ||
* Options used to create a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request). | ||
*/ | ||
options?: RequestInit | undefined; | ||
}; | ||
export interface HTTPClientOptions { | ||
fetcher?: Fetcher; | ||
} | ||
type BeforeRequestHook = (req: Request) => Awaitable<Request | void>; | ||
type RequestErrorHook = (err: unknown, req: Request) => Awaitable<void>; | ||
type ResponseHook = (res: Response, req: Request) => Awaitable<void>; | ||
export type BeforeRequestHook = (req: Request) => Awaitable<Request | void>; | ||
export type RequestErrorHook = (err: unknown, req: Request) => Awaitable<void>; | ||
export type ResponseHook = (res: Response, req: Request) => Awaitable<void>; | ||
export declare class HTTPClient { | ||
@@ -45,3 +55,2 @@ private options; | ||
export declare function unpackHeaders(headers: Headers): Record<string, string[]>; | ||
export {}; | ||
//# sourceMappingURL=http.d.ts.map |
@@ -26,3 +26,3 @@ import { HTTPClient, matchResponse, matchStatusCode, unpackHeaders } from "./http"; | ||
}); | ||
protected createRequest$(conf: RequestConfig, options?: RequestOptions): Request; | ||
protected createRequest$(context: HookContext, conf: RequestConfig, options?: RequestOptions): Request; | ||
protected do$(req: Request, options: { | ||
@@ -29,0 +29,0 @@ context: HookContext; |
@@ -29,3 +29,3 @@ "use strict"; | ||
} | ||
createRequest$(conf, options) { | ||
createRequest$(context, conf, options) { | ||
var _a, _b, _c; | ||
@@ -75,8 +75,12 @@ const { method, path, query, headers: opHeaders, security } = conf; | ||
} | ||
return new Request(reqURL, { | ||
...options === null || options === void 0 ? void 0 : options.fetchOptions, | ||
body: (_c = conf.body) !== null && _c !== void 0 ? _c : null, | ||
headers, | ||
method, | ||
const input = this.hooks$.beforeCreateRequest(context, { | ||
url: reqURL, | ||
options: { | ||
...options === null || options === void 0 ? void 0 : options.fetchOptions, | ||
body: (_c = conf.body) !== null && _c !== void 0 ? _c : null, | ||
headers, | ||
method, | ||
}, | ||
}); | ||
return new Request(input.url, input.options); | ||
} | ||
@@ -83,0 +87,0 @@ async do$(req, options) { |
@@ -0,4 +1,5 @@ | ||
export type Params = Partial<Record<string, string | number>>; | ||
export declare function pathToFunc(pathPattern: string, options?: { | ||
charEncoding?: "percent" | "none"; | ||
}): (params?: Record<string, string | number>) => string; | ||
}): (params?: Params) => string; | ||
//# sourceMappingURL=url.d.ts.map |
@@ -7,2 +7,3 @@ import { Message, Message$ } from "./message"; | ||
messages: Array<Message>; | ||
tags?: Array<string> | undefined; | ||
}; | ||
@@ -15,2 +16,3 @@ /** @internal */ | ||
messages: Array<Message$.Inbound>; | ||
tags?: Array<string> | undefined; | ||
}; | ||
@@ -22,2 +24,3 @@ const inboundSchema: z.ZodType<ChatSessionInput, z.ZodTypeDef, Inbound>; | ||
messages: Array<Message$.Outbound>; | ||
tags?: Array<string> | undefined; | ||
}; | ||
@@ -24,0 +27,0 @@ const outboundSchema: z.ZodType<Outbound, z.ZodTypeDef, ChatSessionInput>; |
@@ -40,2 +40,3 @@ "use strict"; | ||
messages: z.array(message_1.Message$.inboundSchema), | ||
tags: z.array(z.string()).optional(), | ||
}) | ||
@@ -47,2 +48,3 @@ .transform((v) => { | ||
messages: v.messages, | ||
...(v.tags === undefined ? null : { tags: v.tags }), | ||
}; | ||
@@ -55,2 +57,3 @@ }); | ||
messages: z.array(message_1.Message$.outboundSchema), | ||
tags: z.array(z.string()).optional(), | ||
}) | ||
@@ -62,2 +65,3 @@ .transform((v) => { | ||
messages: v.messages, | ||
...(v.tags === undefined ? null : { tags: v.tags }), | ||
}; | ||
@@ -64,0 +68,0 @@ }); |
{ | ||
"name": "@inkeep/ai-api", | ||
"version": "0.6.2", | ||
"author": "Nick Gomez", | ||
"version": "0.7.2", | ||
"author": "Nick Gomez", | ||
"main": "./index.js", | ||
@@ -17,3 +17,2 @@ "sideEffects": false, | ||
}, | ||
"keywords": [], | ||
"peerDependencies": { | ||
@@ -24,9 +23,9 @@ "zod": ">= 3" | ||
"@types/jsonpath": "^0.2.4", | ||
"@typescript-eslint/eslint-plugin": "^6.13.2", | ||
"@typescript-eslint/parser": "^6.13.2", | ||
"eslint": "^8.55.0", | ||
"@typescript-eslint/eslint-plugin": "^7.7.1", | ||
"@typescript-eslint/parser": "^7.7.1", | ||
"eslint": "^8.57.0", | ||
"eslint-import-resolver-typescript": "^3.6.1", | ||
"eslint-plugin-import": "^2.29.0", | ||
"typescript": "^5.3.3", | ||
"zod": "^3.22.4" | ||
"eslint-plugin-import": "^2.29.1", | ||
"typescript": "^5.4.5", | ||
"zod": "^3.23.4" | ||
}, | ||
@@ -33,0 +32,0 @@ "dependencies": { |
@@ -54,2 +54,3 @@ <div align="center"> | ||
], | ||
tags: ["<value>"], | ||
}, | ||
@@ -108,2 +109,3 @@ chatMode: ChatModeOptions.Auto, | ||
], | ||
tags: ["<value>"], | ||
}, | ||
@@ -163,2 +165,3 @@ chatMode: ChatModeOptions.Auto, | ||
], | ||
tags: ["<value>"], | ||
}, | ||
@@ -229,2 +232,3 @@ chatMode: ChatModeOptions.Auto, | ||
], | ||
tags: ["<value>"], | ||
}, | ||
@@ -270,2 +274,3 @@ chatMode: ChatModeOptions.Auto, | ||
], | ||
tags: ["<value>"], | ||
}, | ||
@@ -367,2 +372,3 @@ chatMode: ChatModeOptions.Auto, | ||
], | ||
tags: ["<value>"], | ||
}, | ||
@@ -369,0 +375,0 @@ chatMode: ChatModeOptions.Auto, |
@@ -101,3 +101,3 @@ "use strict"; | ||
const doOptions = { context, errorCodes: ["422", "4XX", "5XX"] }; | ||
const request = this.createRequest$({ | ||
const request = this.createRequest$(context, { | ||
security: securitySettings$, | ||
@@ -193,3 +193,3 @@ method: "POST", | ||
const doOptions = { context, errorCodes: ["422", "4XX", "5XX"] }; | ||
const request = this.createRequest$({ | ||
const request = this.createRequest$(context, { | ||
security: securitySettings$, | ||
@@ -196,0 +196,0 @@ method: "POST", |
@@ -5,2 +5,3 @@ /* | ||
import { RequestInput } from "../lib/http"; | ||
import { | ||
@@ -13,2 +14,4 @@ AfterErrorContext, | ||
BeforeRequestHook, | ||
BeforeCreateRequestHook, | ||
BeforeCreateRequestContext, | ||
Hooks, | ||
@@ -21,2 +24,3 @@ SDKInitHook, | ||
sdkInitHooks: SDKInitHook[] = []; | ||
beforeCreateRequestHooks: BeforeCreateRequestHook[] = []; | ||
beforeRequestHooks: BeforeRequestHook[] = []; | ||
@@ -32,2 +36,6 @@ afterSuccessHooks: AfterSuccessHook[] = []; | ||
registerBeforeCreateRequestHook(hook: BeforeCreateRequestHook) { | ||
this.beforeCreateRequestHooks.push(hook); | ||
} | ||
registerBeforeRequestHook(hook: BeforeRequestHook) { | ||
@@ -49,2 +57,12 @@ this.beforeRequestHooks.push(hook); | ||
beforeCreateRequest(hookCtx: BeforeCreateRequestContext, input: RequestInput): RequestInput { | ||
let inp = input; | ||
for (const hook of this.beforeCreateRequestHooks) { | ||
inp = hook.beforeCreateRequest(hookCtx, inp); | ||
} | ||
return inp; | ||
} | ||
async beforeRequest(hookCtx: BeforeRequestContext, request: Request): Promise<Request> { | ||
@@ -51,0 +69,0 @@ let req = request; |
@@ -5,3 +5,3 @@ /* | ||
import { HTTPClient } from "../lib/http"; | ||
import { HTTPClient, RequestInput } from "../lib/http"; | ||
@@ -20,2 +20,4 @@ export type HookContext = { | ||
}; | ||
export type BeforeCreateRequestContext = HookContext & {}; | ||
export type BeforeRequestContext = HookContext & {}; | ||
@@ -33,26 +35,37 @@ export type AfterSuccessContext = HookContext & {}; | ||
/** | ||
* BeforeRequestHook is called before the SDK sends a request. The hook can | ||
* modify the request before it is sent or throw an error to stop the request | ||
* from being sent. | ||
*/ | ||
export interface BeforeCreateRequestHook { | ||
/** | ||
* A hook that is called before the SDK creates a `Request` object. The hook | ||
* can modify how a request is constructed since certain modifications, like | ||
* changing the request URL, cannot be done on a request object directly. | ||
*/ | ||
beforeCreateRequest: (hookCtx: BeforeCreateRequestContext, input: RequestInput) => RequestInput; | ||
} | ||
export interface BeforeRequestHook { | ||
/** | ||
* A hook that is called before the SDK sends a request. The hook can | ||
* introduce instrumentation code such as logging, tracing and metrics or | ||
* replace the request before it is sent or throw an error to stop the | ||
* request from being sent. | ||
*/ | ||
beforeRequest: (hookCtx: BeforeRequestContext, request: Request) => Awaitable<Request>; | ||
} | ||
/** | ||
* AfterSuccessHook is called after the SDK receives a response. The hook can | ||
* modify the response before it is handled or throw an error to stop the | ||
* response from being handled. | ||
*/ | ||
export interface AfterSuccessHook { | ||
/** | ||
* A hook that is called after the SDK receives a response. The hook can | ||
* introduce instrumentation code such as logging, tracing and metrics or | ||
* modify the response before it is handled or throw an error to stop the | ||
* response from being handled. | ||
*/ | ||
afterSuccess: (hookCtx: AfterSuccessContext, response: Response) => Awaitable<Response>; | ||
} | ||
/** | ||
* AfterErrorHook is called after the SDK encounters an error, or a | ||
* non-successful response. The hook can modify the response if available | ||
* otherwise modify the error. | ||
*/ | ||
export interface AfterErrorHook { | ||
/** | ||
* A hook that is called after the SDK encounters an error, or a | ||
* non-successful response. The hook can introduce instrumentation code such | ||
* as logging, tracing and metrics or modify the response or error values. | ||
*/ | ||
afterError: ( | ||
@@ -71,2 +84,4 @@ hookCtx: AfterErrorContext, | ||
registerSDKInitHook(hook: SDKInitHook): void; | ||
/** Registers a hook to be used by the SDK for to modify `Request` construction. */ | ||
registerBeforeCreateRequestHook(hook: BeforeCreateRequestHook): void; | ||
/** Registers a hook to be used by the SDK for the before request event. */ | ||
@@ -73,0 +88,0 @@ registerBeforeRequestHook(hook: BeforeRequestHook): void; |
@@ -7,3 +7,3 @@ /* | ||
import { RetryConfig } from "./retries"; | ||
import { pathToFunc } from "./url"; | ||
import { Params, pathToFunc } from "./url"; | ||
@@ -41,3 +41,3 @@ /** | ||
const params: Record<string, string> = {}; | ||
const params: Params = {}; | ||
@@ -56,8 +56,8 @@ if (!serverURL) { | ||
export const SDK_METADATA = Object.freeze({ | ||
export const SDK_METADATA = { | ||
language: "typescript", | ||
openapiDocVersion: "0.1.0", | ||
sdkVersion: "0.6.2", | ||
genVersion: "2.306.0", | ||
userAgent: "speakeasy-sdk/typescript 0.6.2 2.306.0 0.1.0 @inkeep/ai-api", | ||
}); | ||
sdkVersion: "0.7.2", | ||
genVersion: "2.314.0", | ||
userAgent: "speakeasy-sdk/typescript 0.7.2 2.314.0 0.1.0 @inkeep/ai-api", | ||
} as const; |
@@ -18,3 +18,3 @@ /* | ||
options?: { explode?: boolean; charEncoding?: "percent" | "none" }, | ||
) { | ||
): string { | ||
let out = ""; | ||
@@ -69,3 +69,3 @@ const pairs: [string, unknown][] = options?.explode | ||
options?: { explode?: boolean; charEncoding?: "percent" | "none" }, | ||
) { | ||
): string { | ||
let out = ""; | ||
@@ -105,3 +105,9 @@ const pairs: [string, unknown][] = options?.explode | ||
function formEncoder(sep: string) { | ||
type FormEncoder = ( | ||
key: string, | ||
value: unknown, | ||
options?: { explode?: boolean; charEncoding?: "percent" | "none" }, | ||
) => string; | ||
function formEncoder(sep: string): FormEncoder { | ||
return ( | ||
@@ -163,3 +169,3 @@ key: string, | ||
options?: { explode?: boolean; charEncoding?: "percent" | "none" }, | ||
) { | ||
): string { | ||
let out = ""; | ||
@@ -207,3 +213,3 @@ const pairs: [string, unknown][] = options?.explode | ||
options?: { charEncoding?: "percent" | "none" }, | ||
) { | ||
): string { | ||
if (value == null) { | ||
@@ -255,3 +261,3 @@ return ""; | ||
options?: { explode?: boolean; charEncoding?: "percent" | "none" }, | ||
) { | ||
): string { | ||
if (typeof value === "undefined") { | ||
@@ -274,3 +280,3 @@ return ""; | ||
options?: { explode?: boolean; charEncoding?: "percent" | "none" }, | ||
) => { | ||
): string => { | ||
let out = ""; | ||
@@ -347,3 +353,3 @@ const pairs: [string, unknown][] = options?.explode | ||
function jsonReplacer(_: string, value: unknown) { | ||
function jsonReplacer(_: string, value: unknown): unknown { | ||
if (value instanceof Uint8Array) { | ||
@@ -350,0 +356,0 @@ return bytesToBase64(value); |
@@ -32,3 +32,3 @@ /* | ||
async *[Symbol.asyncIterator]() { | ||
async *[Symbol.asyncIterator](): AsyncGenerator<Event, void, unknown> { | ||
const reader = this.stream.getReader(); | ||
@@ -35,0 +35,0 @@ let buffer = new Uint8Array([]); |
@@ -10,6 +10,17 @@ /* | ||
type Awaitable<T> = T | Promise<T>; | ||
export type Awaitable<T> = T | Promise<T>; | ||
const DEFAULT_FETCHER: Fetcher = (input, init) => fetch(input, init); | ||
export type RequestInput = { | ||
/** | ||
* The URL the request will use. | ||
*/ | ||
url: URL; | ||
/** | ||
* Options used to create a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request). | ||
*/ | ||
options?: RequestInit | undefined; | ||
}; | ||
export interface HTTPClientOptions { | ||
@@ -19,5 +30,5 @@ fetcher?: Fetcher; | ||
type BeforeRequestHook = (req: Request) => Awaitable<Request | void>; | ||
type RequestErrorHook = (err: unknown, req: Request) => Awaitable<void>; | ||
type ResponseHook = (res: Response, req: Request) => Awaitable<void>; | ||
export type BeforeRequestHook = (req: Request) => Awaitable<Request | void>; | ||
export type RequestErrorHook = (err: unknown, req: Request) => Awaitable<void>; | ||
export type ResponseHook = (res: Response, req: Request) => Awaitable<void>; | ||
@@ -105,3 +116,3 @@ export class HTTPClient { | ||
| [hook: "response", fn: ResponseHook] | ||
) { | ||
): this { | ||
let target: unknown[]; | ||
@@ -126,3 +137,3 @@ if (args[0] === "beforeRequest") { | ||
clone() { | ||
clone(): HTTPClient { | ||
const child = new HTTPClient(this.options); | ||
@@ -167,3 +178,3 @@ child.requestHooks = this.requestHooks.slice(); | ||
codes: number | string | (number | string)[], | ||
) { | ||
): boolean { | ||
const actual = `${response.status}`; | ||
@@ -170,0 +181,0 @@ const expectedCodes = Array.isArray(codes) ? codes : [codes]; |
@@ -43,3 +43,7 @@ /* | ||
protected createRequest$(conf: RequestConfig, options?: RequestOptions) { | ||
protected createRequest$( | ||
context: HookContext, | ||
conf: RequestConfig, | ||
options?: RequestOptions | ||
): Request { | ||
const { method, path, query, headers: opHeaders, security } = conf; | ||
@@ -99,8 +103,13 @@ | ||
return new Request(reqURL, { | ||
...options?.fetchOptions, | ||
body: conf.body ?? null, | ||
headers, | ||
method, | ||
const input = this.hooks$.beforeCreateRequest(context, { | ||
url: reqURL, | ||
options: { | ||
...options?.fetchOptions, | ||
body: conf.body ?? null, | ||
headers, | ||
method, | ||
}, | ||
}); | ||
return new Request(input.url, input.options); | ||
} | ||
@@ -114,3 +123,3 @@ | ||
} | ||
) { | ||
): Promise<Response> { | ||
const { context, errorCodes } = options; | ||
@@ -117,0 +126,0 @@ |
@@ -172,3 +172,5 @@ /* | ||
} | ||
export function resolveGlobalSecurity(security: Partial<components.Security> | null | undefined) { | ||
export function resolveGlobalSecurity( | ||
security: Partial<components.Security> | null | undefined | ||
): SecurityState | null { | ||
return resolveSecurity([ | ||
@@ -175,0 +177,0 @@ { |
@@ -7,6 +7,8 @@ /* | ||
export type Params = Partial<Record<string, string | number>>; | ||
export function pathToFunc( | ||
pathPattern: string, | ||
options?: { charEncoding?: "percent" | "none" }, | ||
): (params?: Record<string, string | number>) => string { | ||
): (params?: Params) => string { | ||
const paramRE = /\{([a-zA-Z0-9_]+?)\}/g; | ||
@@ -13,0 +15,0 @@ |
@@ -12,2 +12,3 @@ /* | ||
messages: Array<Message>; | ||
tags?: Array<string> | undefined; | ||
}; | ||
@@ -21,2 +22,3 @@ | ||
messages: Array<Message$.Inbound>; | ||
tags?: Array<string> | undefined; | ||
}; | ||
@@ -29,2 +31,3 @@ | ||
messages: z.array(Message$.inboundSchema), | ||
tags: z.array(z.string()).optional(), | ||
}) | ||
@@ -36,2 +39,3 @@ .transform((v) => { | ||
messages: v.messages, | ||
...(v.tags === undefined ? null : { tags: v.tags }), | ||
}; | ||
@@ -44,2 +48,3 @@ }); | ||
messages: Array<Message$.Outbound>; | ||
tags?: Array<string> | undefined; | ||
}; | ||
@@ -52,2 +57,3 @@ | ||
messages: z.array(Message$.outboundSchema), | ||
tags: z.array(z.string()).optional(), | ||
}) | ||
@@ -59,4 +65,5 @@ .transform((v) => { | ||
messages: v.messages, | ||
...(v.tags === undefined ? null : { tags: v.tags }), | ||
}; | ||
}); | ||
} |
@@ -23,3 +23,4 @@ /* | ||
/** @internal */ | ||
export const ChatModeOptions$ = z.nativeEnum(ChatModeOptions); | ||
export const ChatModeOptions$: z.ZodNativeEnum<typeof ChatModeOptions> = | ||
z.nativeEnum(ChatModeOptions); | ||
@@ -26,0 +27,0 @@ /** @internal */ |
@@ -20,3 +20,3 @@ /* | ||
/** @internal */ | ||
export const Four$ = z.nativeEnum(Four); | ||
export const Four$: z.ZodNativeEnum<typeof Four> = z.nativeEnum(Four); | ||
@@ -23,0 +23,0 @@ /** @internal */ |
@@ -25,3 +25,4 @@ /* | ||
/** @internal */ | ||
export const RecordTypeEnumerated$ = z.nativeEnum(RecordTypeEnumerated); | ||
export const RecordTypeEnumerated$: z.ZodNativeEnum<typeof RecordTypeEnumerated> = | ||
z.nativeEnum(RecordTypeEnumerated); | ||
@@ -28,0 +29,0 @@ /** @internal */ |
@@ -20,3 +20,3 @@ /* | ||
public override toString() { | ||
public override toString(): string { | ||
return `${this.message}: ${this.cause}`; | ||
@@ -30,3 +30,3 @@ } | ||
*/ | ||
public pretty() { | ||
public pretty(): string { | ||
if (this.cause instanceof z.ZodError) { | ||
@@ -33,0 +33,0 @@ return `${this.message}\n${formatZodError(this.cause)}`; |
@@ -96,2 +96,3 @@ /* | ||
const request = this.createRequest$( | ||
context, | ||
{ | ||
@@ -218,2 +219,3 @@ security: securitySettings$, | ||
const request = this.createRequest$( | ||
context, | ||
{ | ||
@@ -220,0 +222,0 @@ security: securitySettings$, |
@@ -39,5 +39,5 @@ /* | ||
private _chatSession?: ChatSession; | ||
get chatSession() { | ||
get chatSession(): ChatSession { | ||
return (this._chatSession ??= new ChatSession(this.options$)); | ||
} | ||
} |
@@ -7,6 +7,7 @@ /* | ||
export const blobLikeSchema = z.custom<Blob>(isBlobLike, { | ||
message: "expected a Blob, File or Blob-like object", | ||
fatal: true, | ||
}); | ||
export const blobLikeSchema: z.ZodType<Blob, z.ZodTypeDef, Blob> = | ||
z.custom<Blob>(isBlobLike, { | ||
message: "expected a Blob, File or Blob-like object", | ||
fatal: true, | ||
}); | ||
@@ -13,0 +14,0 @@ export function isBlobLike(val: unknown): val is Blob { |
@@ -14,3 +14,3 @@ /* | ||
page: Result & { next: Paginator<Result> }, | ||
) { | ||
): { [Symbol.asyncIterator]: () => AsyncIterableIterator<Result> } { | ||
return { | ||
@@ -17,0 +17,0 @@ [Symbol.asyncIterator]: async function* paginator() { |
@@ -13,3 +13,3 @@ /* | ||
*/ | ||
static today() { | ||
static today(): RFCDate { | ||
return new RFCDate(new Date()); | ||
@@ -16,0 +16,0 @@ } |
@@ -9,6 +9,4 @@ export type Paginator<Result> = () => Promise<PageIterator<Result>> | null; | ||
}): { | ||
[Symbol.asyncIterator]: () => AsyncGenerator<Result & { | ||
next: Paginator<Result>; | ||
}, void, unknown>; | ||
[Symbol.asyncIterator]: () => AsyncIterableIterator<Result>; | ||
}; | ||
//# sourceMappingURL=operations.d.ts.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
411103
7345
402
240