@openrouter/sdk 0.0.1-beta.12 → 0.0.1-beta.16
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/FUNCTIONS.md +15 -16
- package/REACT_QUERY.md +15 -16
- package/README.md +138 -110
- package/esm/funcs/betaResponsesSend.d.ts +2 -2
- package/esm/funcs/betaResponsesSend.js +3 -3
- package/esm/funcs/chatSend.d.ts +1 -1
- package/esm/funcs/modelsList.d.ts +2 -1
- package/esm/funcs/modelsList.js +3 -6
- package/esm/funcs/oAuthCreateAuthCode.d.ts +18 -0
- package/esm/funcs/oAuthCreateAuthCode.js +82 -0
- package/esm/funcs/oAuthCreateAuthorizationUrl.d.ts +2 -2
- package/esm/funcs/oAuthExchangeAuthCodeForAPIKey.d.ts +18 -0
- package/esm/funcs/oAuthExchangeAuthCodeForAPIKey.js +82 -0
- package/esm/lib/config.d.ts +2 -2
- package/esm/lib/config.js +2 -2
- package/esm/lib/event-streams.d.ts +1 -1
- package/esm/models/chatgenerationtokenusage.d.ts +2 -2
- package/esm/models/chatgenerationtokenusage.js +2 -4
- package/esm/models/operations/createauthkeyscode.d.ts +145 -0
- package/esm/models/operations/createauthkeyscode.js +146 -0
- package/esm/models/operations/createresponses.d.ts +58 -0
- package/esm/models/operations/createresponses.js +80 -0
- package/esm/models/operations/exchangeauthcodeforapikey.d.ts +104 -0
- package/esm/models/operations/exchangeauthcodeforapikey.js +111 -0
- package/esm/models/operations/getmodels.d.ts +0 -26
- package/esm/models/operations/getmodels.js +0 -30
- package/esm/models/operations/index.d.ts +3 -1
- package/esm/models/operations/index.js +3 -1
- package/esm/models/operations/sendchatcompletionrequest.d.ts +1 -1
- package/esm/models/operations/sendchatcompletionrequest.js +2 -1
- package/esm/react-query/betaResponsesSend.d.ts +1 -1
- package/esm/react-query/index.d.ts +2 -0
- package/esm/react-query/index.js +2 -0
- package/esm/react-query/modelsList.d.ts +2 -7
- package/esm/react-query/modelsList.js +0 -2
- package/esm/react-query/oAuthCreateAuthCode.d.ts +23 -0
- package/esm/react-query/oAuthCreateAuthCode.js +42 -0
- package/esm/react-query/oAuthExchangeAuthCodeForAPIKey.d.ts +23 -0
- package/esm/react-query/oAuthExchangeAuthCodeForAPIKey.js +42 -0
- package/esm/sdk/chat.d.ts +1 -1
- package/esm/sdk/models.d.ts +1 -1
- package/esm/sdk/oauth.d.ts +46 -0
- package/esm/sdk/oauth.js +67 -0
- package/esm/sdk/responses.d.ts +2 -2
- package/esm/sdk/sdk.d.ts +3 -0
- package/esm/sdk/sdk.js +4 -0
- package/jsr.json +1 -1
- package/package.json +3 -1
- package/vitest.config.ts +16 -1
- package/esm/models/operations/createapialpharesponses.d.ts +0 -58
- package/esm/models/operations/createapialpharesponses.js +0 -81
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { MutationKey, UseMutationResult } from "@tanstack/react-query";
|
|
2
|
+
import { OpenRouterCore } from "../core.js";
|
|
3
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
4
|
+
import * as operations from "../models/operations/index.js";
|
|
5
|
+
import { MutationHookOptions } from "./_types.js";
|
|
6
|
+
export type OAuthExchangeAuthCodeForAPIKeyMutationVariables = {
|
|
7
|
+
request: operations.ExchangeAuthCodeForAPIKeyRequest;
|
|
8
|
+
options?: RequestOptions;
|
|
9
|
+
};
|
|
10
|
+
export type OAuthExchangeAuthCodeForAPIKeyMutationData = operations.ExchangeAuthCodeForAPIKeyResponse;
|
|
11
|
+
/**
|
|
12
|
+
* Exchange authorization code for API key
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* Exchange an authorization code from the PKCE flow for a user-controlled API key
|
|
16
|
+
*/
|
|
17
|
+
export declare function useOAuthExchangeAuthCodeForAPIKeyMutation(options?: MutationHookOptions<OAuthExchangeAuthCodeForAPIKeyMutationData, Error, OAuthExchangeAuthCodeForAPIKeyMutationVariables>): UseMutationResult<OAuthExchangeAuthCodeForAPIKeyMutationData, Error, OAuthExchangeAuthCodeForAPIKeyMutationVariables>;
|
|
18
|
+
export declare function mutationKeyOAuthExchangeAuthCodeForAPIKey(): MutationKey;
|
|
19
|
+
export declare function buildOAuthExchangeAuthCodeForAPIKeyMutation(client$: OpenRouterCore, hookOptions?: RequestOptions): {
|
|
20
|
+
mutationKey: MutationKey;
|
|
21
|
+
mutationFn: (variables: OAuthExchangeAuthCodeForAPIKeyMutationVariables) => Promise<OAuthExchangeAuthCodeForAPIKeyMutationData>;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=oAuthExchangeAuthCodeForAPIKey.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
import { useMutation, } from "@tanstack/react-query";
|
|
5
|
+
import { oAuthExchangeAuthCodeForAPIKey } from "../funcs/oAuthExchangeAuthCodeForAPIKey.js";
|
|
6
|
+
import { combineSignals } from "../lib/primitives.js";
|
|
7
|
+
import { unwrapAsync } from "../types/fp.js";
|
|
8
|
+
import { useOpenRouterContext } from "./_context.js";
|
|
9
|
+
/**
|
|
10
|
+
* Exchange authorization code for API key
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* Exchange an authorization code from the PKCE flow for a user-controlled API key
|
|
14
|
+
*/
|
|
15
|
+
export function useOAuthExchangeAuthCodeForAPIKeyMutation(options) {
|
|
16
|
+
const client = useOpenRouterContext();
|
|
17
|
+
return useMutation({
|
|
18
|
+
...buildOAuthExchangeAuthCodeForAPIKeyMutation(client, options),
|
|
19
|
+
...options,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
export function mutationKeyOAuthExchangeAuthCodeForAPIKey() {
|
|
23
|
+
return ["@openrouter/sdk", "OAuth", "exchangeAuthCodeForAPIKey"];
|
|
24
|
+
}
|
|
25
|
+
export function buildOAuthExchangeAuthCodeForAPIKeyMutation(client$, hookOptions) {
|
|
26
|
+
return {
|
|
27
|
+
mutationKey: mutationKeyOAuthExchangeAuthCodeForAPIKey(),
|
|
28
|
+
mutationFn: function oAuthExchangeAuthCodeForAPIKeyMutationFn({ request, options, }) {
|
|
29
|
+
const mergedOptions = {
|
|
30
|
+
...hookOptions,
|
|
31
|
+
...options,
|
|
32
|
+
fetchOptions: {
|
|
33
|
+
...hookOptions?.fetchOptions,
|
|
34
|
+
...options?.fetchOptions,
|
|
35
|
+
signal: combineSignals(hookOptions?.fetchOptions?.signal, options?.fetchOptions?.signal),
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
return unwrapAsync(oAuthExchangeAuthCodeForAPIKey(client$, request, mergedOptions));
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=oAuthExchangeAuthCodeForAPIKey.js.map
|
package/esm/sdk/chat.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare class Chat extends ClientSDK {
|
|
|
14
14
|
}, options?: RequestOptions): Promise<models.ChatResponse>;
|
|
15
15
|
send(request: models.ChatGenerationParams & {
|
|
16
16
|
stream: true;
|
|
17
|
-
}, options?: RequestOptions): Promise<EventStream<models.
|
|
17
|
+
}, options?: RequestOptions): Promise<EventStream<models.ChatStreamingResponseChunkData>>;
|
|
18
18
|
send(request: models.ChatGenerationParams, options?: RequestOptions): Promise<operations.SendChatCompletionRequestResponse>;
|
|
19
19
|
}
|
|
20
20
|
//# sourceMappingURL=chat.d.ts.map
|
package/esm/sdk/models.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare class Models extends ClientSDK {
|
|
|
9
9
|
/**
|
|
10
10
|
* List all models and their properties
|
|
11
11
|
*/
|
|
12
|
-
list(request?: operations.GetModelsRequest | undefined, options?: RequestOptions): Promise<
|
|
12
|
+
list(request?: operations.GetModelsRequest | undefined, options?: RequestOptions): Promise<models.ModelsListResponse>;
|
|
13
13
|
/**
|
|
14
14
|
* List models filtered by user provider preferences
|
|
15
15
|
*/
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
|
|
2
|
+
import * as operations from "../models/operations/index.js";
|
|
3
|
+
import { CreateAuthorizationUrlRequest } from "../funcs/oAuthCreateAuthorizationUrl.js";
|
|
4
|
+
import { CreateSHA256CodeChallengeResponse } from "../funcs/oAuthCreateSHA256CodeChallenge.js";
|
|
5
|
+
export declare class OAuth extends ClientSDK {
|
|
6
|
+
/**
|
|
7
|
+
* Generate a OAuth2 authorization URL
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* Generates a URL to redirect users to for authorizing your application. The
|
|
11
|
+
* URL includes the provided callback URL and, if applicable, the code
|
|
12
|
+
* challenge parameters for PKCE.
|
|
13
|
+
*
|
|
14
|
+
* @see {@link https://openrouter.ai/docs/use-cases/oauth-pkce}
|
|
15
|
+
*/
|
|
16
|
+
createAuthorizationUrl(request: CreateAuthorizationUrlRequest): Promise<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Generate a SHA-256 code challenge for PKCE
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* Generates a SHA-256 code challenge and corresponding code verifier for use
|
|
22
|
+
* in the PKCE extension to OAuth2. If no code verifier is provided, a random
|
|
23
|
+
* one will be generated according to RFC 7636 (32 random bytes, base64url
|
|
24
|
+
* encoded). If a code verifier is provided, it must be 43-128 characters and
|
|
25
|
+
* contain only unreserved characters [A-Za-z0-9-._~].
|
|
26
|
+
*
|
|
27
|
+
* @see {@link https://openrouter.ai/docs/use-cases/oauth-pkce}
|
|
28
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc7636}
|
|
29
|
+
*/
|
|
30
|
+
createSHA256CodeChallenge(): Promise<CreateSHA256CodeChallengeResponse>;
|
|
31
|
+
/**
|
|
32
|
+
* Exchange authorization code for API key
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* Exchange an authorization code from the PKCE flow for a user-controlled API key
|
|
36
|
+
*/
|
|
37
|
+
exchangeAuthCodeForAPIKey(request: operations.ExchangeAuthCodeForAPIKeyRequest, options?: RequestOptions): Promise<operations.ExchangeAuthCodeForAPIKeyResponse>;
|
|
38
|
+
/**
|
|
39
|
+
* Create authorization code
|
|
40
|
+
*
|
|
41
|
+
* @remarks
|
|
42
|
+
* Create an authorization code for the PKCE flow to generate a user-controlled API key
|
|
43
|
+
*/
|
|
44
|
+
createAuthCode(request: operations.CreateAuthKeysCodeRequest, options?: RequestOptions): Promise<operations.CreateAuthKeysCodeResponse>;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=oauth.d.ts.map
|
package/esm/sdk/oauth.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
import { oAuthCreateAuthCode } from "../funcs/oAuthCreateAuthCode.js";
|
|
5
|
+
import { oAuthExchangeAuthCodeForAPIKey } from "../funcs/oAuthExchangeAuthCodeForAPIKey.js";
|
|
6
|
+
import { ClientSDK } from "../lib/sdks.js";
|
|
7
|
+
import { unwrapAsync } from "../types/fp.js";
|
|
8
|
+
// #region imports
|
|
9
|
+
import { oAuthCreateAuthorizationUrl, } from "../funcs/oAuthCreateAuthorizationUrl.js";
|
|
10
|
+
import { oAuthCreateSHA256CodeChallenge, } from "../funcs/oAuthCreateSHA256CodeChallenge.js";
|
|
11
|
+
// #endregion imports
|
|
12
|
+
export class OAuth extends ClientSDK {
|
|
13
|
+
// #region sdk-class-body
|
|
14
|
+
/**
|
|
15
|
+
* Generate a OAuth2 authorization URL
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* Generates a URL to redirect users to for authorizing your application. The
|
|
19
|
+
* URL includes the provided callback URL and, if applicable, the code
|
|
20
|
+
* challenge parameters for PKCE.
|
|
21
|
+
*
|
|
22
|
+
* @see {@link https://openrouter.ai/docs/use-cases/oauth-pkce}
|
|
23
|
+
*/
|
|
24
|
+
async createAuthorizationUrl(request) {
|
|
25
|
+
const result = oAuthCreateAuthorizationUrl(this, request);
|
|
26
|
+
if (!result.ok) {
|
|
27
|
+
throw result.error;
|
|
28
|
+
}
|
|
29
|
+
return result.value;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Generate a SHA-256 code challenge for PKCE
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* Generates a SHA-256 code challenge and corresponding code verifier for use
|
|
36
|
+
* in the PKCE extension to OAuth2. If no code verifier is provided, a random
|
|
37
|
+
* one will be generated according to RFC 7636 (32 random bytes, base64url
|
|
38
|
+
* encoded). If a code verifier is provided, it must be 43-128 characters and
|
|
39
|
+
* contain only unreserved characters [A-Za-z0-9-._~].
|
|
40
|
+
*
|
|
41
|
+
* @see {@link https://openrouter.ai/docs/use-cases/oauth-pkce}
|
|
42
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc7636}
|
|
43
|
+
*/
|
|
44
|
+
async createSHA256CodeChallenge() {
|
|
45
|
+
return unwrapAsync(oAuthCreateSHA256CodeChallenge());
|
|
46
|
+
}
|
|
47
|
+
// #endregion sdk-class-body
|
|
48
|
+
/**
|
|
49
|
+
* Exchange authorization code for API key
|
|
50
|
+
*
|
|
51
|
+
* @remarks
|
|
52
|
+
* Exchange an authorization code from the PKCE flow for a user-controlled API key
|
|
53
|
+
*/
|
|
54
|
+
async exchangeAuthCodeForAPIKey(request, options) {
|
|
55
|
+
return unwrapAsync(oAuthExchangeAuthCodeForAPIKey(this, request, options));
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Create authorization code
|
|
59
|
+
*
|
|
60
|
+
* @remarks
|
|
61
|
+
* Create an authorization code for the PKCE flow to generate a user-controlled API key
|
|
62
|
+
*/
|
|
63
|
+
async createAuthCode(request, options) {
|
|
64
|
+
return unwrapAsync(oAuthCreateAuthCode(this, request, options));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=oauth.js.map
|
package/esm/sdk/responses.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare class Responses extends ClientSDK {
|
|
|
14
14
|
}, options?: RequestOptions): Promise<models.OpenResponsesNonStreamingResponse>;
|
|
15
15
|
send(request: models.OpenResponsesRequest & {
|
|
16
16
|
stream: true;
|
|
17
|
-
}, options?: RequestOptions): Promise<EventStream<
|
|
18
|
-
send(request: models.OpenResponsesRequest, options?: RequestOptions): Promise<operations.
|
|
17
|
+
}, options?: RequestOptions): Promise<EventStream<models.OpenResponsesStreamEvent>>;
|
|
18
|
+
send(request: models.OpenResponsesRequest, options?: RequestOptions): Promise<operations.CreateResponsesResponse>;
|
|
19
19
|
}
|
|
20
20
|
//# sourceMappingURL=responses.d.ts.map
|
package/esm/sdk/sdk.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { Credits } from "./credits.js";
|
|
|
8
8
|
import { Endpoints } from "./endpoints.js";
|
|
9
9
|
import { Generations } from "./generations.js";
|
|
10
10
|
import { Models } from "./models.js";
|
|
11
|
+
import { OAuth } from "./oauth.js";
|
|
11
12
|
import { ParametersT } from "./parameters.js";
|
|
12
13
|
import { Providers } from "./providers.js";
|
|
13
14
|
export declare class OpenRouter extends ClientSDK {
|
|
@@ -29,6 +30,8 @@ export declare class OpenRouter extends ClientSDK {
|
|
|
29
30
|
get providers(): Providers;
|
|
30
31
|
private _apiKeys?;
|
|
31
32
|
get apiKeys(): APIKeys;
|
|
33
|
+
private _oAuth?;
|
|
34
|
+
get oAuth(): OAuth;
|
|
32
35
|
private _chat?;
|
|
33
36
|
get chat(): Chat;
|
|
34
37
|
private _completions?;
|
package/esm/sdk/sdk.js
CHANGED
|
@@ -11,6 +11,7 @@ import { Credits } from "./credits.js";
|
|
|
11
11
|
import { Endpoints } from "./endpoints.js";
|
|
12
12
|
import { Generations } from "./generations.js";
|
|
13
13
|
import { Models } from "./models.js";
|
|
14
|
+
import { OAuth } from "./oauth.js";
|
|
14
15
|
import { ParametersT } from "./parameters.js";
|
|
15
16
|
import { Providers } from "./providers.js";
|
|
16
17
|
export class OpenRouter extends ClientSDK {
|
|
@@ -41,6 +42,9 @@ export class OpenRouter extends ClientSDK {
|
|
|
41
42
|
get apiKeys() {
|
|
42
43
|
return (this._apiKeys ?? (this._apiKeys = new APIKeys(this._options)));
|
|
43
44
|
}
|
|
45
|
+
get oAuth() {
|
|
46
|
+
return (this._oAuth ?? (this._oAuth = new OAuth(this._options)));
|
|
47
|
+
}
|
|
44
48
|
get chat() {
|
|
45
49
|
return (this._chat ?? (this._chat = new Chat(this._options)));
|
|
46
50
|
}
|
package/jsr.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openrouter/sdk",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.16",
|
|
4
4
|
"author": "OpenRouter",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./esm/index.js",
|
|
@@ -70,7 +70,9 @@
|
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@eslint/js": "^9.19.0",
|
|
72
72
|
"@tanstack/react-query": "^5.61.4",
|
|
73
|
+
"@types/node": "^22.13.12",
|
|
73
74
|
"@types/react": "^18.3.12",
|
|
75
|
+
"dotenv": "^16.4.7",
|
|
74
76
|
"eslint": "^9.19.0",
|
|
75
77
|
"globals": "^15.14.0",
|
|
76
78
|
"typescript": "~5.8.3",
|
package/vitest.config.ts
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
|
+
import { config } from "dotenv";
|
|
1
2
|
import { defineConfig } from "vitest/config";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
import { dirname, join } from "path";
|
|
5
|
+
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = dirname(__filename);
|
|
8
|
+
|
|
9
|
+
// Load environment variables from .env file if it exists
|
|
10
|
+
// This will not override existing environment variables
|
|
11
|
+
config({ path: join(__dirname, ".env") });
|
|
2
12
|
|
|
3
13
|
export default defineConfig({
|
|
4
14
|
test: {
|
|
5
15
|
globals: true,
|
|
6
16
|
environment: "node",
|
|
7
|
-
|
|
17
|
+
// Don't override env vars - just let them pass through from the system
|
|
18
|
+
// The env object here will be merged with process.env
|
|
19
|
+
env: {
|
|
20
|
+
OPENROUTER_API_KEY: process.env.OPENROUTER_API_KEY,
|
|
21
|
+
},
|
|
22
|
+
include: ["tests/**/*.test.ts"],
|
|
8
23
|
hookTimeout: 30000,
|
|
9
24
|
testTimeout: 30000,
|
|
10
25
|
},
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import * as z from "zod/v4";
|
|
2
|
-
import { EventStream } from "../../lib/event-streams.js";
|
|
3
|
-
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
4
|
-
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
5
|
-
import * as models from "../index.js";
|
|
6
|
-
/**
|
|
7
|
-
* Successful response
|
|
8
|
-
*/
|
|
9
|
-
export type CreateApiAlphaResponsesResponseBody = {
|
|
10
|
-
/**
|
|
11
|
-
* Union of all possible event types emitted during response streaming
|
|
12
|
-
*/
|
|
13
|
-
data: models.OpenResponsesStreamEvent;
|
|
14
|
-
};
|
|
15
|
-
export type CreateApiAlphaResponsesResponse = models.OpenResponsesNonStreamingResponse | EventStream<CreateApiAlphaResponsesResponseBody>;
|
|
16
|
-
/** @internal */
|
|
17
|
-
export declare const CreateApiAlphaResponsesResponseBody$inboundSchema: z.ZodType<CreateApiAlphaResponsesResponseBody, unknown>;
|
|
18
|
-
/** @internal */
|
|
19
|
-
export type CreateApiAlphaResponsesResponseBody$Outbound = {
|
|
20
|
-
data: models.OpenResponsesStreamEvent$Outbound;
|
|
21
|
-
};
|
|
22
|
-
/** @internal */
|
|
23
|
-
export declare const CreateApiAlphaResponsesResponseBody$outboundSchema: z.ZodType<CreateApiAlphaResponsesResponseBody$Outbound, CreateApiAlphaResponsesResponseBody>;
|
|
24
|
-
/**
|
|
25
|
-
* @internal
|
|
26
|
-
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
|
|
27
|
-
*/
|
|
28
|
-
export declare namespace CreateApiAlphaResponsesResponseBody$ {
|
|
29
|
-
/** @deprecated use `CreateApiAlphaResponsesResponseBody$inboundSchema` instead. */
|
|
30
|
-
const inboundSchema: z.ZodType<CreateApiAlphaResponsesResponseBody, unknown, z.core.$ZodTypeInternals<CreateApiAlphaResponsesResponseBody, unknown>>;
|
|
31
|
-
/** @deprecated use `CreateApiAlphaResponsesResponseBody$outboundSchema` instead. */
|
|
32
|
-
const outboundSchema: z.ZodType<CreateApiAlphaResponsesResponseBody$Outbound, CreateApiAlphaResponsesResponseBody, z.core.$ZodTypeInternals<CreateApiAlphaResponsesResponseBody$Outbound, CreateApiAlphaResponsesResponseBody>>;
|
|
33
|
-
/** @deprecated use `CreateApiAlphaResponsesResponseBody$Outbound` instead. */
|
|
34
|
-
type Outbound = CreateApiAlphaResponsesResponseBody$Outbound;
|
|
35
|
-
}
|
|
36
|
-
export declare function createApiAlphaResponsesResponseBodyToJSON(createApiAlphaResponsesResponseBody: CreateApiAlphaResponsesResponseBody): string;
|
|
37
|
-
export declare function createApiAlphaResponsesResponseBodyFromJSON(jsonString: string): SafeParseResult<CreateApiAlphaResponsesResponseBody, SDKValidationError>;
|
|
38
|
-
/** @internal */
|
|
39
|
-
export declare const CreateApiAlphaResponsesResponse$inboundSchema: z.ZodType<CreateApiAlphaResponsesResponse, unknown>;
|
|
40
|
-
/** @internal */
|
|
41
|
-
export type CreateApiAlphaResponsesResponse$Outbound = models.OpenResponsesNonStreamingResponse$Outbound | never;
|
|
42
|
-
/** @internal */
|
|
43
|
-
export declare const CreateApiAlphaResponsesResponse$outboundSchema: z.ZodType<CreateApiAlphaResponsesResponse$Outbound, CreateApiAlphaResponsesResponse>;
|
|
44
|
-
/**
|
|
45
|
-
* @internal
|
|
46
|
-
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
|
|
47
|
-
*/
|
|
48
|
-
export declare namespace CreateApiAlphaResponsesResponse$ {
|
|
49
|
-
/** @deprecated use `CreateApiAlphaResponsesResponse$inboundSchema` instead. */
|
|
50
|
-
const inboundSchema: z.ZodType<CreateApiAlphaResponsesResponse, unknown, z.core.$ZodTypeInternals<CreateApiAlphaResponsesResponse, unknown>>;
|
|
51
|
-
/** @deprecated use `CreateApiAlphaResponsesResponse$outboundSchema` instead. */
|
|
52
|
-
const outboundSchema: z.ZodType<models.OpenResponsesNonStreamingResponse$Outbound, CreateApiAlphaResponsesResponse, z.core.$ZodTypeInternals<models.OpenResponsesNonStreamingResponse$Outbound, CreateApiAlphaResponsesResponse>>;
|
|
53
|
-
/** @deprecated use `CreateApiAlphaResponsesResponse$Outbound` instead. */
|
|
54
|
-
type Outbound = CreateApiAlphaResponsesResponse$Outbound;
|
|
55
|
-
}
|
|
56
|
-
export declare function createApiAlphaResponsesResponseToJSON(createApiAlphaResponsesResponse: CreateApiAlphaResponsesResponse): string;
|
|
57
|
-
export declare function createApiAlphaResponsesResponseFromJSON(jsonString: string): SafeParseResult<CreateApiAlphaResponsesResponse, SDKValidationError>;
|
|
58
|
-
//# sourceMappingURL=createapialpharesponses.d.ts.map
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
-
*/
|
|
4
|
-
import * as z from "zod/v4";
|
|
5
|
-
import { EventStream } from "../../lib/event-streams.js";
|
|
6
|
-
import { safeParse } from "../../lib/schemas.js";
|
|
7
|
-
import * as models from "../index.js";
|
|
8
|
-
/** @internal */
|
|
9
|
-
export const CreateApiAlphaResponsesResponseBody$inboundSchema = z.object({
|
|
10
|
-
data: z.string().transform((v, ctx) => {
|
|
11
|
-
try {
|
|
12
|
-
return JSON.parse(v);
|
|
13
|
-
}
|
|
14
|
-
catch (err) {
|
|
15
|
-
ctx.addIssue({
|
|
16
|
-
code: z.ZodIssueCode.custom,
|
|
17
|
-
message: `malformed json: ${err}`,
|
|
18
|
-
});
|
|
19
|
-
return z.NEVER;
|
|
20
|
-
}
|
|
21
|
-
}).pipe(models.OpenResponsesStreamEvent$inboundSchema),
|
|
22
|
-
});
|
|
23
|
-
/** @internal */
|
|
24
|
-
export const CreateApiAlphaResponsesResponseBody$outboundSchema = z.object({
|
|
25
|
-
data: models.OpenResponsesStreamEvent$outboundSchema,
|
|
26
|
-
});
|
|
27
|
-
/**
|
|
28
|
-
* @internal
|
|
29
|
-
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
|
|
30
|
-
*/
|
|
31
|
-
export var CreateApiAlphaResponsesResponseBody$;
|
|
32
|
-
(function (CreateApiAlphaResponsesResponseBody$) {
|
|
33
|
-
/** @deprecated use `CreateApiAlphaResponsesResponseBody$inboundSchema` instead. */
|
|
34
|
-
CreateApiAlphaResponsesResponseBody$.inboundSchema = CreateApiAlphaResponsesResponseBody$inboundSchema;
|
|
35
|
-
/** @deprecated use `CreateApiAlphaResponsesResponseBody$outboundSchema` instead. */
|
|
36
|
-
CreateApiAlphaResponsesResponseBody$.outboundSchema = CreateApiAlphaResponsesResponseBody$outboundSchema;
|
|
37
|
-
})(CreateApiAlphaResponsesResponseBody$ || (CreateApiAlphaResponsesResponseBody$ = {}));
|
|
38
|
-
export function createApiAlphaResponsesResponseBodyToJSON(createApiAlphaResponsesResponseBody) {
|
|
39
|
-
return JSON.stringify(CreateApiAlphaResponsesResponseBody$outboundSchema.parse(createApiAlphaResponsesResponseBody));
|
|
40
|
-
}
|
|
41
|
-
export function createApiAlphaResponsesResponseBodyFromJSON(jsonString) {
|
|
42
|
-
return safeParse(jsonString, (x) => CreateApiAlphaResponsesResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateApiAlphaResponsesResponseBody' from JSON`);
|
|
43
|
-
}
|
|
44
|
-
/** @internal */
|
|
45
|
-
export const CreateApiAlphaResponsesResponse$inboundSchema = z.union([
|
|
46
|
-
models.OpenResponsesNonStreamingResponse$inboundSchema,
|
|
47
|
-
z.custom(x => x instanceof ReadableStream)
|
|
48
|
-
.transform(stream => {
|
|
49
|
-
return new EventStream(stream, rawEvent => {
|
|
50
|
-
if (rawEvent.data === "[DONE]")
|
|
51
|
-
return { done: true };
|
|
52
|
-
return {
|
|
53
|
-
value: z.lazy(() => CreateApiAlphaResponsesResponseBody$inboundSchema)
|
|
54
|
-
.parse(rawEvent),
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
}),
|
|
58
|
-
]);
|
|
59
|
-
/** @internal */
|
|
60
|
-
export const CreateApiAlphaResponsesResponse$outboundSchema = z.union([
|
|
61
|
-
models.OpenResponsesNonStreamingResponse$outboundSchema,
|
|
62
|
-
z.never(),
|
|
63
|
-
]);
|
|
64
|
-
/**
|
|
65
|
-
* @internal
|
|
66
|
-
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
|
|
67
|
-
*/
|
|
68
|
-
export var CreateApiAlphaResponsesResponse$;
|
|
69
|
-
(function (CreateApiAlphaResponsesResponse$) {
|
|
70
|
-
/** @deprecated use `CreateApiAlphaResponsesResponse$inboundSchema` instead. */
|
|
71
|
-
CreateApiAlphaResponsesResponse$.inboundSchema = CreateApiAlphaResponsesResponse$inboundSchema;
|
|
72
|
-
/** @deprecated use `CreateApiAlphaResponsesResponse$outboundSchema` instead. */
|
|
73
|
-
CreateApiAlphaResponsesResponse$.outboundSchema = CreateApiAlphaResponsesResponse$outboundSchema;
|
|
74
|
-
})(CreateApiAlphaResponsesResponse$ || (CreateApiAlphaResponsesResponse$ = {}));
|
|
75
|
-
export function createApiAlphaResponsesResponseToJSON(createApiAlphaResponsesResponse) {
|
|
76
|
-
return JSON.stringify(CreateApiAlphaResponsesResponse$outboundSchema.parse(createApiAlphaResponsesResponse));
|
|
77
|
-
}
|
|
78
|
-
export function createApiAlphaResponsesResponseFromJSON(jsonString) {
|
|
79
|
-
return safeParse(jsonString, (x) => CreateApiAlphaResponsesResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateApiAlphaResponsesResponse' from JSON`);
|
|
80
|
-
}
|
|
81
|
-
//# sourceMappingURL=createapialpharesponses.js.map
|