@neon/sdk 0.0.0 → 0.1.0
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/LICENSE.md +178 -0
- package/README.md +349 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/client/client/client.gen.d.ts +7 -0
- package/dist/client/client/client.gen.d.ts.map +1 -0
- package/dist/client/client/client.gen.js +176 -0
- package/dist/client/client/client.gen.js.map +1 -0
- package/dist/client/client/index.d.ts +10 -0
- package/dist/client/client/index.js +6 -0
- package/dist/client/client/types.gen.d.ts +124 -0
- package/dist/client/client/types.gen.d.ts.map +1 -0
- package/dist/client/client/types.gen.js +1 -0
- package/dist/client/client/utils.gen.d.ts +42 -0
- package/dist/client/client/utils.gen.d.ts.map +1 -0
- package/dist/client/client/utils.gen.js +179 -0
- package/dist/client/client/utils.gen.js.map +1 -0
- package/dist/client/client.gen.d.ts +18 -0
- package/dist/client/client.gen.d.ts.map +1 -0
- package/dist/client/client.gen.js +8 -0
- package/dist/client/client.gen.js.map +1 -0
- package/dist/client/core/auth.gen.d.ts +29 -0
- package/dist/client/core/auth.gen.d.ts.map +1 -0
- package/dist/client/core/auth.gen.js +12 -0
- package/dist/client/core/auth.gen.js.map +1 -0
- package/dist/client/core/bodySerializer.gen.d.ts +29 -0
- package/dist/client/core/bodySerializer.gen.d.ts.map +1 -0
- package/dist/client/core/bodySerializer.gen.js +33 -0
- package/dist/client/core/bodySerializer.gen.js.map +1 -0
- package/dist/client/core/params.gen.d.ts +46 -0
- package/dist/client/core/params.gen.d.ts.map +1 -0
- package/dist/client/core/params.gen.js +65 -0
- package/dist/client/core/params.gen.js.map +1 -0
- package/dist/client/core/pathSerializer.gen.d.ts +52 -0
- package/dist/client/core/pathSerializer.gen.d.ts.map +1 -0
- package/dist/client/core/pathSerializer.gen.js +82 -0
- package/dist/client/core/pathSerializer.gen.js.map +1 -0
- package/dist/client/core/queryKeySerializer.gen.d.ts +22 -0
- package/dist/client/core/queryKeySerializer.gen.d.ts.map +1 -0
- package/dist/client/core/queryKeySerializer.gen.js +64 -0
- package/dist/client/core/queryKeySerializer.gen.js.map +1 -0
- package/dist/client/core/serverSentEvents.gen.d.ts +88 -0
- package/dist/client/core/serverSentEvents.gen.d.ts.map +1 -0
- package/dist/client/core/serverSentEvents.gen.js +95 -0
- package/dist/client/core/serverSentEvents.gen.js.map +1 -0
- package/dist/client/core/types.gen.d.ts +80 -0
- package/dist/client/core/types.gen.d.ts.map +1 -0
- package/dist/client/core/types.gen.js +1 -0
- package/dist/client/core/utils.gen.d.ts +33 -0
- package/dist/client/core/utils.gen.d.ts.map +1 -0
- package/dist/client/core/utils.gen.js +78 -0
- package/dist/client/core/utils.gen.js.map +1 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.js +2 -0
- package/dist/client/sdk.gen.d.ts +1362 -0
- package/dist/client/sdk.gen.d.ts.map +1 -0
- package/dist/client/sdk.gen.js +4315 -0
- package/dist/client/sdk.gen.js.map +1 -0
- package/dist/client/types.gen.d.ts +9938 -0
- package/dist/client/types.gen.d.ts.map +1 -0
- package/dist/client/types.gen.js +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +4 -0
- package/dist/neon/client.d.ts +52 -0
- package/dist/neon/client.d.ts.map +1 -0
- package/dist/neon/client.js +40 -0
- package/dist/neon/client.js.map +1 -0
- package/dist/neon/config.d.ts +40 -0
- package/dist/neon/config.d.ts.map +1 -0
- package/dist/neon/config.js +23 -0
- package/dist/neon/config.js.map +1 -0
- package/dist/neon/connection.d.ts +22 -0
- package/dist/neon/connection.d.ts.map +1 -0
- package/dist/neon/connection.js +33 -0
- package/dist/neon/connection.js.map +1 -0
- package/dist/neon/context.d.ts +50 -0
- package/dist/neon/context.d.ts.map +1 -0
- package/dist/neon/context.js +59 -0
- package/dist/neon/context.js.map +1 -0
- package/dist/neon/coverage.d.ts +26 -0
- package/dist/neon/coverage.d.ts.map +1 -0
- package/dist/neon/coverage.js +229 -0
- package/dist/neon/coverage.js.map +1 -0
- package/dist/neon/errors.d.ts +78 -0
- package/dist/neon/errors.d.ts.map +1 -0
- package/dist/neon/errors.js +116 -0
- package/dist/neon/errors.js.map +1 -0
- package/dist/neon/paginate.d.ts +34 -0
- package/dist/neon/paginate.d.ts.map +1 -0
- package/dist/neon/paginate.js +51 -0
- package/dist/neon/paginate.js.map +1 -0
- package/dist/neon/resources/account.d.ts +45 -0
- package/dist/neon/resources/account.d.ts.map +1 -0
- package/dist/neon/resources/account.js +65 -0
- package/dist/neon/resources/account.js.map +1 -0
- package/dist/neon/resources/branches.d.ts +84 -0
- package/dist/neon/resources/branches.d.ts.map +1 -0
- package/dist/neon/resources/branches.js +132 -0
- package/dist/neon/resources/branches.js.map +1 -0
- package/dist/neon/resources/consumption.d.ts +22 -0
- package/dist/neon/resources/consumption.d.ts.map +1 -0
- package/dist/neon/resources/consumption.js +59 -0
- package/dist/neon/resources/consumption.js.map +1 -0
- package/dist/neon/resources/dataapi.d.ts +25 -0
- package/dist/neon/resources/dataapi.d.ts.map +1 -0
- package/dist/neon/resources/dataapi.js +59 -0
- package/dist/neon/resources/dataapi.js.map +1 -0
- package/dist/neon/resources/databases.d.ts +30 -0
- package/dist/neon/resources/databases.d.ts.map +1 -0
- package/dist/neon/resources/databases.js +68 -0
- package/dist/neon/resources/databases.js.map +1 -0
- package/dist/neon/resources/endpoints.d.ts +39 -0
- package/dist/neon/resources/endpoints.d.ts.map +1 -0
- package/dist/neon/resources/endpoints.js +89 -0
- package/dist/neon/resources/endpoints.js.map +1 -0
- package/dist/neon/resources/operations.d.ts +27 -0
- package/dist/neon/resources/operations.d.ts.map +1 -0
- package/dist/neon/resources/operations.js +50 -0
- package/dist/neon/resources/operations.js.map +1 -0
- package/dist/neon/resources/postgres.d.ts +45 -0
- package/dist/neon/resources/postgres.d.ts.map +1 -0
- package/dist/neon/resources/postgres.js +104 -0
- package/dist/neon/resources/postgres.js.map +1 -0
- package/dist/neon/resources/projects.d.ts +84 -0
- package/dist/neon/resources/projects.d.ts.map +1 -0
- package/dist/neon/resources/projects.js +111 -0
- package/dist/neon/resources/projects.js.map +1 -0
- package/dist/neon/resources/roles.d.ts +40 -0
- package/dist/neon/resources/roles.d.ts.map +1 -0
- package/dist/neon/resources/roles.js +78 -0
- package/dist/neon/resources/roles.js.map +1 -0
- package/dist/neon/resources/snapshots.d.ts +86 -0
- package/dist/neon/resources/snapshots.d.ts.map +1 -0
- package/dist/neon/resources/snapshots.js +125 -0
- package/dist/neon/resources/snapshots.js.map +1 -0
- package/dist/neon/result.d.ts +32 -0
- package/dist/neon/result.d.ts.map +1 -0
- package/dist/neon/result.js +26 -0
- package/dist/neon/result.js.map +1 -0
- package/dist/neon/retry.d.ts +17 -0
- package/dist/neon/retry.d.ts.map +1 -0
- package/dist/neon/retry.js +42 -0
- package/dist/neon/retry.js.map +1 -0
- package/dist/neon/wait.d.ts +27 -0
- package/dist/neon/wait.d.ts.map +1 -0
- package/dist/neon/wait.js +70 -0
- package/dist/neon/wait.js.map +1 -0
- package/dist/raw.d.ts +13 -0
- package/dist/raw.d.ts.map +1 -0
- package/dist/raw.js +159 -0
- package/dist/raw.js.map +1 -0
- package/package.json +57 -16
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.gen.js","names":[],"sources":["../../src/client/client.gen.ts"],"sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\nimport { type Client, type ClientOptions, type Config, createClient, createConfig } from './client/index.js';\nimport type { ClientOptions as ClientOptions2 } from './types.gen.js';\n\n/**\n * The `createClientConfig()` function will be called on client initialization\n * and the returned object will become the client's initial configuration.\n *\n * You may want to initialize your client this way instead of calling\n * `setConfig()`. This is useful for example if you're using Next.js\n * to ensure your client always has the correct values.\n */\nexport type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;\n\nexport const client: Client = createClient(createConfig<ClientOptions2>({ baseUrl: 'https://console.neon.tech/api/v2' }));\n"],"mappings":";;;AAeA,MAAa,SAAiB,aAAa,aAA6B,EAAE,SAAS,mCAAmC,CAAC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/client/core/auth.gen.d.ts
|
|
2
|
+
type AuthToken = string | undefined;
|
|
3
|
+
interface Auth {
|
|
4
|
+
/**
|
|
5
|
+
* Which part of the request do we use to send the auth?
|
|
6
|
+
*
|
|
7
|
+
* @default 'header'
|
|
8
|
+
*/
|
|
9
|
+
in?: 'header' | 'query' | 'cookie';
|
|
10
|
+
/**
|
|
11
|
+
* A unique identifier for the security scheme.
|
|
12
|
+
*
|
|
13
|
+
* Defined only when there are multiple security schemes whose `Auth`
|
|
14
|
+
* shape would otherwise be identical.
|
|
15
|
+
*/
|
|
16
|
+
key?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Header or query parameter name.
|
|
19
|
+
*
|
|
20
|
+
* @default 'Authorization'
|
|
21
|
+
*/
|
|
22
|
+
name?: string;
|
|
23
|
+
scheme?: 'basic' | 'bearer';
|
|
24
|
+
type: 'apiKey' | 'http';
|
|
25
|
+
}
|
|
26
|
+
declare const getAuthToken: (auth: Auth, callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken) => Promise<string | undefined>;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { Auth, AuthToken, getAuthToken };
|
|
29
|
+
//# sourceMappingURL=auth.gen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.gen.d.ts","names":[],"sources":["../../../src/client/core/auth.gen.ts"],"mappings":";KAEY,SAAA;AAAA,UAEK,IAAA,CAFI;EAEJ;AAwBjB;;;;KAEqC,EAAA,QAAA,GAAA,OAAA,GAAA,QAAA;;;;;AAC3B;;;;;;;;;;;;cAHG,qBACL,wBACY,SAAS,QAAQ,aAAa,aAAa,cAC5D"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/client/core/auth.gen.ts
|
|
2
|
+
const getAuthToken = async (auth, callback) => {
|
|
3
|
+
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
4
|
+
if (!token) return;
|
|
5
|
+
if (auth.scheme === "bearer") return `Bearer ${token}`;
|
|
6
|
+
if (auth.scheme === "basic") return `Basic ${btoa(token)}`;
|
|
7
|
+
return token;
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { getAuthToken };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=auth.gen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.gen.js","names":[],"sources":["../../../src/client/core/auth.gen.ts"],"sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\nexport type AuthToken = string | undefined;\n\nexport interface Auth {\n /**\n * Which part of the request do we use to send the auth?\n *\n * @default 'header'\n */\n in?: 'header' | 'query' | 'cookie';\n /**\n * A unique identifier for the security scheme.\n *\n * Defined only when there are multiple security schemes whose `Auth`\n * shape would otherwise be identical.\n */\n key?: string;\n /**\n * Header or query parameter name.\n *\n * @default 'Authorization'\n */\n name?: string;\n scheme?: 'basic' | 'bearer';\n type: 'apiKey' | 'http';\n}\n\nexport const getAuthToken = async (\n auth: Auth,\n callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken,\n): Promise<string | undefined> => {\n const token = typeof callback === 'function' ? await callback(auth) : callback;\n\n if (!token) {\n return;\n }\n\n if (auth.scheme === 'bearer') {\n return `Bearer ${token}`;\n }\n\n if (auth.scheme === 'basic') {\n return `Basic ${btoa(token)}`;\n }\n\n return token;\n};\n"],"mappings":";AA4BA,MAAa,eAAe,OAC1B,MACA,aACgC;CAChC,MAAM,QAAQ,OAAO,aAAa,aAAa,MAAM,SAAS,IAAI,IAAI;CAEtE,IAAI,CAAC,OACH;CAGF,IAAI,KAAK,WAAW,UAClB,OAAO,UAAU;CAGnB,IAAI,KAAK,WAAW,SAClB,OAAO,SAAS,KAAK,KAAK;CAG5B,OAAO;AACT"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ArrayStyle, ObjectStyle, SerializerOptions } from "./pathSerializer.gen.js";
|
|
2
|
+
|
|
3
|
+
//#region src/client/core/bodySerializer.gen.d.ts
|
|
4
|
+
type QuerySerializer = (query: Record<string, unknown>) => string;
|
|
5
|
+
type BodySerializer = (body: unknown) => unknown;
|
|
6
|
+
type QuerySerializerOptionsObject = {
|
|
7
|
+
allowReserved?: boolean;
|
|
8
|
+
array?: Partial<SerializerOptions<ArrayStyle>>;
|
|
9
|
+
object?: Partial<SerializerOptions<ObjectStyle>>;
|
|
10
|
+
};
|
|
11
|
+
type QuerySerializerOptions = QuerySerializerOptionsObject & {
|
|
12
|
+
/**
|
|
13
|
+
* Per-parameter serialization overrides. When provided, these settings
|
|
14
|
+
* override the global array/object settings for specific parameter names.
|
|
15
|
+
*/
|
|
16
|
+
parameters?: Record<string, QuerySerializerOptionsObject>;
|
|
17
|
+
};
|
|
18
|
+
declare const formDataBodySerializer: {
|
|
19
|
+
bodySerializer: (body: unknown) => FormData;
|
|
20
|
+
};
|
|
21
|
+
declare const jsonBodySerializer: {
|
|
22
|
+
bodySerializer: (body: unknown) => string;
|
|
23
|
+
};
|
|
24
|
+
declare const urlSearchParamsBodySerializer: {
|
|
25
|
+
bodySerializer: (body: unknown) => string;
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
export { BodySerializer, QuerySerializer, QuerySerializerOptions, formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer };
|
|
29
|
+
//# sourceMappingURL=bodySerializer.gen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bodySerializer.gen.d.ts","names":[],"sources":["../../../src/client/core/bodySerializer.gen.ts"],"mappings":";;;KAIY,eAAA,WAA0B;KAE1B,cAAA;AAFZ,KAIK,4BAAA,GAJiC;EAE1B,aAAA,CAAA,EAAA,OAAc;EAErB,KAAA,CAAA,EAEK,OAFL,CAEa,iBAFe,CAEG,UAFH,CAAA,CAAA;EAAA,MAAA,CAAA,EAGtB,OAHsB,CAGd,iBAHc,CAGI,WAHJ,CAAA,CAAA;;AAEf,KAIN,sBAAA,GAAyB,4BAJnB,GAAA;;;;;EACA,UAAA,CAAA,EAQH,MARG,CAAA,MAAA,EAQY,4BARZ,CAAA;AAGlB,CAAA;AAAkC,cA0BrB,sBA1BqB,EAAA;gBAAG,EAAA,CAAA,IAAA,EAAA,OAAA,EAAA,GA2BF,QA3BE;;AAKtB,cAwCF,kBAxCE,EAAA;EAAM,cAAA,EAAA,CAAA,IAAA,EAAA,OAAA,EAAA,GAAA,MAAA;AAqBrB,CAAA;AAmBa,cAKA,6BAFZ,EAAA;EAEY,cAAA,EAAA,CAAA,IAAA,EAAA,OAAA,EAiBZ,GAAA,MAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region src/client/core/bodySerializer.gen.ts
|
|
2
|
+
const serializeFormDataPair = (data, key, value) => {
|
|
3
|
+
if (typeof value === "string" || value instanceof Blob) data.append(key, value);
|
|
4
|
+
else if (value instanceof Date) data.append(key, value.toISOString());
|
|
5
|
+
else data.append(key, JSON.stringify(value));
|
|
6
|
+
};
|
|
7
|
+
const serializeUrlSearchParamsPair = (data, key, value) => {
|
|
8
|
+
if (typeof value === "string") data.append(key, value);
|
|
9
|
+
else data.append(key, JSON.stringify(value));
|
|
10
|
+
};
|
|
11
|
+
const formDataBodySerializer = { bodySerializer: (body) => {
|
|
12
|
+
const data = new FormData();
|
|
13
|
+
Object.entries(body).forEach(([key, value]) => {
|
|
14
|
+
if (value === void 0 || value === null) return;
|
|
15
|
+
if (Array.isArray(value)) value.forEach((v) => serializeFormDataPair(data, key, v));
|
|
16
|
+
else serializeFormDataPair(data, key, value);
|
|
17
|
+
});
|
|
18
|
+
return data;
|
|
19
|
+
} };
|
|
20
|
+
const jsonBodySerializer = { bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value) };
|
|
21
|
+
const urlSearchParamsBodySerializer = { bodySerializer: (body) => {
|
|
22
|
+
const data = new URLSearchParams();
|
|
23
|
+
Object.entries(body).forEach(([key, value]) => {
|
|
24
|
+
if (value === void 0 || value === null) return;
|
|
25
|
+
if (Array.isArray(value)) value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));
|
|
26
|
+
else serializeUrlSearchParamsPair(data, key, value);
|
|
27
|
+
});
|
|
28
|
+
return data.toString();
|
|
29
|
+
} };
|
|
30
|
+
//#endregion
|
|
31
|
+
export { formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=bodySerializer.gen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bodySerializer.gen.js","names":[],"sources":["../../../src/client/core/bodySerializer.gen.ts"],"sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\nimport type { ArrayStyle, ObjectStyle, SerializerOptions } from './pathSerializer.gen.js';\n\nexport type QuerySerializer = (query: Record<string, unknown>) => string;\n\nexport type BodySerializer = (body: unknown) => unknown;\n\ntype QuerySerializerOptionsObject = {\n allowReserved?: boolean;\n array?: Partial<SerializerOptions<ArrayStyle>>;\n object?: Partial<SerializerOptions<ObjectStyle>>;\n};\n\nexport type QuerySerializerOptions = QuerySerializerOptionsObject & {\n /**\n * Per-parameter serialization overrides. When provided, these settings\n * override the global array/object settings for specific parameter names.\n */\n parameters?: Record<string, QuerySerializerOptionsObject>;\n};\n\nconst serializeFormDataPair = (data: FormData, key: string, value: unknown): void => {\n if (typeof value === 'string' || value instanceof Blob) {\n data.append(key, value);\n } else if (value instanceof Date) {\n data.append(key, value.toISOString());\n } else {\n data.append(key, JSON.stringify(value));\n }\n};\n\nconst serializeUrlSearchParamsPair = (data: URLSearchParams, key: string, value: unknown): void => {\n if (typeof value === 'string') {\n data.append(key, value);\n } else {\n data.append(key, JSON.stringify(value));\n }\n};\n\nexport const formDataBodySerializer = {\n bodySerializer: (body: unknown): FormData => {\n const data = new FormData();\n\n Object.entries(body as Record<string, unknown>).forEach(([key, value]) => {\n if (value === undefined || value === null) {\n return;\n }\n if (Array.isArray(value)) {\n value.forEach((v) => serializeFormDataPair(data, key, v));\n } else {\n serializeFormDataPair(data, key, value);\n }\n });\n\n return data;\n },\n};\n\nexport const jsonBodySerializer = {\n bodySerializer: (body: unknown): string =>\n JSON.stringify(body, (_key, value) => (typeof value === 'bigint' ? value.toString() : value)),\n};\n\nexport const urlSearchParamsBodySerializer = {\n bodySerializer: (body: unknown): string => {\n const data = new URLSearchParams();\n\n Object.entries(body as Record<string, unknown>).forEach(([key, value]) => {\n if (value === undefined || value === null) {\n return;\n }\n if (Array.isArray(value)) {\n value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));\n } else {\n serializeUrlSearchParamsPair(data, key, value);\n }\n });\n\n return data.toString();\n },\n};\n"],"mappings":";AAsBA,MAAM,yBAAyB,MAAgB,KAAa,UAAyB;CACnF,IAAI,OAAO,UAAU,YAAY,iBAAiB,MAChD,KAAK,OAAO,KAAK,KAAK;MACjB,IAAI,iBAAiB,MAC1B,KAAK,OAAO,KAAK,MAAM,YAAY,CAAC;MAEpC,KAAK,OAAO,KAAK,KAAK,UAAU,KAAK,CAAC;AAE1C;AAEA,MAAM,gCAAgC,MAAuB,KAAa,UAAyB;CACjG,IAAI,OAAO,UAAU,UACnB,KAAK,OAAO,KAAK,KAAK;MAEtB,KAAK,OAAO,KAAK,KAAK,UAAU,KAAK,CAAC;AAE1C;AAEA,MAAa,yBAAyB,EACpC,iBAAiB,SAA4B;CAC3C,MAAM,OAAO,IAAI,SAAS;CAE1B,OAAO,QAAQ,IAA+B,CAAC,CAAC,SAAS,CAAC,KAAK,WAAW;EACxE,IAAI,UAAU,KAAA,KAAa,UAAU,MACnC;EAEF,IAAI,MAAM,QAAQ,KAAK,GACrB,MAAM,SAAS,MAAM,sBAAsB,MAAM,KAAK,CAAC,CAAC;OAExD,sBAAsB,MAAM,KAAK,KAAK;CAE1C,CAAC;CAED,OAAO;AACT,EACF;AAEA,MAAa,qBAAqB,EAChC,iBAAiB,SACf,KAAK,UAAU,OAAO,MAAM,UAAW,OAAO,UAAU,WAAW,MAAM,SAAS,IAAI,KAAM,EAChG;AAEA,MAAa,gCAAgC,EAC3C,iBAAiB,SAA0B;CACzC,MAAM,OAAO,IAAI,gBAAgB;CAEjC,OAAO,QAAQ,IAA+B,CAAC,CAAC,SAAS,CAAC,KAAK,WAAW;EACxE,IAAI,UAAU,KAAA,KAAa,UAAU,MACnC;EAEF,IAAI,MAAM,QAAQ,KAAK,GACrB,MAAM,SAAS,MAAM,6BAA6B,MAAM,KAAK,CAAC,CAAC;OAE/D,6BAA6B,MAAM,KAAK,KAAK;CAEjD,CAAC;CAED,OAAO,KAAK,SAAS;AACvB,EACF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//#region src/client/core/params.gen.d.ts
|
|
2
|
+
type Slot = 'body' | 'headers' | 'path' | 'query';
|
|
3
|
+
type Field = {
|
|
4
|
+
in: Exclude<Slot, 'body'>;
|
|
5
|
+
/**
|
|
6
|
+
* Field name. This is the name we want the user to see and use.
|
|
7
|
+
*/
|
|
8
|
+
key: string;
|
|
9
|
+
/**
|
|
10
|
+
* Field mapped name. This is the name we want to use in the request.
|
|
11
|
+
* If omitted, we use the same value as `key`.
|
|
12
|
+
*/
|
|
13
|
+
map?: string;
|
|
14
|
+
} | {
|
|
15
|
+
in: Extract<Slot, 'body'>;
|
|
16
|
+
/**
|
|
17
|
+
* Key isn't required for bodies.
|
|
18
|
+
*/
|
|
19
|
+
key?: string;
|
|
20
|
+
map?: string;
|
|
21
|
+
} | {
|
|
22
|
+
/**
|
|
23
|
+
* Field name. This is the name we want the user to see and use.
|
|
24
|
+
*/
|
|
25
|
+
key: string;
|
|
26
|
+
/**
|
|
27
|
+
* Field mapped name. This is the name we want to use in the request.
|
|
28
|
+
* If `in` is omitted, `map` aliases `key` to the transport layer.
|
|
29
|
+
*/
|
|
30
|
+
map: Slot;
|
|
31
|
+
};
|
|
32
|
+
interface Fields {
|
|
33
|
+
allowExtra?: Partial<Record<Slot, boolean>>;
|
|
34
|
+
args?: ReadonlyArray<Field>;
|
|
35
|
+
}
|
|
36
|
+
type FieldsConfig = ReadonlyArray<Field | Fields>;
|
|
37
|
+
interface Params {
|
|
38
|
+
body: unknown;
|
|
39
|
+
headers: Record<string, unknown>;
|
|
40
|
+
path: Record<string, unknown>;
|
|
41
|
+
query: Record<string, unknown>;
|
|
42
|
+
}
|
|
43
|
+
declare function buildClientParams(args: ReadonlyArray<unknown>, fields: FieldsConfig): Params;
|
|
44
|
+
//#endregion
|
|
45
|
+
export { Field, Fields, FieldsConfig, buildClientParams };
|
|
46
|
+
//# sourceMappingURL=params.gen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"params.gen.d.ts","names":[],"sources":["../../../src/client/core/params.gen.ts"],"mappings":";KAEK,IAAA;AAAA,KAEO,KAAA,GAFH;EAEG,EAAA,EAEF,OAFO,CAEC,IAFD,EAAA,MAAA,CAAA;EAAA;;;KAcC,EAAA,MAAA;;;AAgBH;AAGf;EAAuB,GAAA,CAAA,EAAA,MAAA;;MAnBb,OAoBa,CApBL,IAoBK,EAAA,MAAA,CAAA;;;;EACD,GAAA,CAAA,EAAA,MAAA;EAGV,GAAA,CAAA,EAAA,MAAA;CAAY,GAAA;;;;EAAgB,GAAA,EAAA,MAAA;EA+C9B;;;;KAID,EA3DE,IA2DF;AAAM,CAAA;AAaC,UArEC,MAAA,CAqEgB;EAAA,UAAA,CAAA,EApElB,OAoEkB,CApEV,MAoEU,CApEH,IAoEG,EAAA,OAAA,CAAA,CAAA;MAAO,CAAA,EAnE/B,aAmE+B,CAnEjB,KAmEiB,CAAA;;AAA+C,KAhE3E,YAAA,GAAe,aAgE4D,CAhE9C,KAgE8C,GAhEtC,MAgEsC,CAAA;AAAM,UAjBnF,MAAA,CAiBmF;;WAflF;QACH;SACC;;iBAaO,iBAAA,OAAwB,gCAAgC,eAAe"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
//#region src/client/core/params.gen.ts
|
|
2
|
+
const extraPrefixes = Object.entries({
|
|
3
|
+
$body_: "body",
|
|
4
|
+
$headers_: "headers",
|
|
5
|
+
$path_: "path",
|
|
6
|
+
$query_: "query"
|
|
7
|
+
});
|
|
8
|
+
function buildKeyMap(fields, map) {
|
|
9
|
+
if (!map) map = /* @__PURE__ */ new Map();
|
|
10
|
+
for (const config of fields) if ("in" in config) {
|
|
11
|
+
if (config.key) map.set(config.key, {
|
|
12
|
+
in: config.in,
|
|
13
|
+
map: config.map
|
|
14
|
+
});
|
|
15
|
+
} else if ("key" in config) map.set(config.key, { map: config.map });
|
|
16
|
+
else if (config.args) buildKeyMap(config.args, map);
|
|
17
|
+
return map;
|
|
18
|
+
}
|
|
19
|
+
function stripEmptySlots(params) {
|
|
20
|
+
for (const [slot, value] of Object.entries(params)) if (value && typeof value === "object" && !Array.isArray(value) && !Object.keys(value).length) delete params[slot];
|
|
21
|
+
}
|
|
22
|
+
function buildClientParams(args, fields) {
|
|
23
|
+
const params = {
|
|
24
|
+
body: Object.create(null),
|
|
25
|
+
headers: Object.create(null),
|
|
26
|
+
path: Object.create(null),
|
|
27
|
+
query: Object.create(null)
|
|
28
|
+
};
|
|
29
|
+
const map = buildKeyMap(fields);
|
|
30
|
+
let config;
|
|
31
|
+
for (const [index, arg] of args.entries()) {
|
|
32
|
+
if (fields[index]) config = fields[index];
|
|
33
|
+
if (!config) continue;
|
|
34
|
+
if ("in" in config) if (config.key) {
|
|
35
|
+
const field = map.get(config.key);
|
|
36
|
+
const name = field.map || config.key;
|
|
37
|
+
if (field.in) params[field.in][name] = arg;
|
|
38
|
+
} else params.body = arg;
|
|
39
|
+
else for (const [key, value] of Object.entries(arg ?? {})) {
|
|
40
|
+
const field = map.get(key);
|
|
41
|
+
if (field) if (field.in) {
|
|
42
|
+
const name = field.map || key;
|
|
43
|
+
params[field.in][name] = value;
|
|
44
|
+
} else params[field.map] = value;
|
|
45
|
+
else {
|
|
46
|
+
const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
|
|
47
|
+
if (extra) {
|
|
48
|
+
const [prefix, slot] = extra;
|
|
49
|
+
params[slot][key.slice(prefix.length)] = value;
|
|
50
|
+
} else if ("allowExtra" in config && config.allowExtra) {
|
|
51
|
+
for (const [slot, allowed] of Object.entries(config.allowExtra)) if (allowed) {
|
|
52
|
+
params[slot][key] = value;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
stripEmptySlots(params);
|
|
60
|
+
return params;
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { buildClientParams };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=params.gen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"params.gen.js","names":[],"sources":["../../../src/client/core/params.gen.ts"],"sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\ntype Slot = 'body' | 'headers' | 'path' | 'query';\n\nexport type Field =\n | {\n in: Exclude<Slot, 'body'>;\n /**\n * Field name. This is the name we want the user to see and use.\n */\n key: string;\n /**\n * Field mapped name. This is the name we want to use in the request.\n * If omitted, we use the same value as `key`.\n */\n map?: string;\n }\n | {\n in: Extract<Slot, 'body'>;\n /**\n * Key isn't required for bodies.\n */\n key?: string;\n map?: string;\n }\n | {\n /**\n * Field name. This is the name we want the user to see and use.\n */\n key: string;\n /**\n * Field mapped name. This is the name we want to use in the request.\n * If `in` is omitted, `map` aliases `key` to the transport layer.\n */\n map: Slot;\n };\n\nexport interface Fields {\n allowExtra?: Partial<Record<Slot, boolean>>;\n args?: ReadonlyArray<Field>;\n}\n\nexport type FieldsConfig = ReadonlyArray<Field | Fields>;\n\nconst extraPrefixesMap: Record<string, Slot> = {\n $body_: 'body',\n $headers_: 'headers',\n $path_: 'path',\n $query_: 'query',\n};\nconst extraPrefixes = Object.entries(extraPrefixesMap);\n\ntype KeyMap = Map<\n string,\n | {\n in: Slot;\n map?: string;\n }\n | {\n in?: never;\n map: Slot;\n }\n>;\n\nfunction buildKeyMap(fields: FieldsConfig, map?: KeyMap): KeyMap {\n if (!map) {\n map = new Map();\n }\n\n for (const config of fields) {\n if ('in' in config) {\n if (config.key) {\n map.set(config.key, {\n in: config.in,\n map: config.map,\n });\n }\n } else if ('key' in config) {\n map.set(config.key, {\n map: config.map,\n });\n } else if (config.args) {\n buildKeyMap(config.args, map);\n }\n }\n\n return map;\n}\n\ninterface Params {\n body: unknown;\n headers: Record<string, unknown>;\n path: Record<string, unknown>;\n query: Record<string, unknown>;\n}\n\ntype ParamsSlotMap = Record<Slot, unknown>;\n\nfunction stripEmptySlots(params: ParamsSlotMap): void {\n for (const [slot, value] of Object.entries(params)) {\n if (value && typeof value === 'object' && !Array.isArray(value) && !Object.keys(value).length) {\n delete params[slot as Slot];\n }\n }\n}\n\nexport function buildClientParams(args: ReadonlyArray<unknown>, fields: FieldsConfig): Params {\n const params: ParamsSlotMap = {\n body: Object.create(null),\n headers: Object.create(null),\n path: Object.create(null),\n query: Object.create(null),\n };\n\n const map = buildKeyMap(fields);\n\n let config: FieldsConfig[number] | undefined;\n\n for (const [index, arg] of args.entries()) {\n if (fields[index]) {\n config = fields[index];\n }\n\n if (!config) {\n continue;\n }\n\n if ('in' in config) {\n if (config.key) {\n const field = map.get(config.key)!;\n const name = field.map || config.key;\n if (field.in) {\n (params[field.in] as Record<string, unknown>)[name] = arg;\n }\n } else {\n params.body = arg;\n }\n } else {\n for (const [key, value] of Object.entries(arg ?? {})) {\n const field = map.get(key);\n\n if (field) {\n if (field.in) {\n const name = field.map || key;\n (params[field.in] as Record<string, unknown>)[name] = value;\n } else {\n params[field.map] = value;\n }\n } else {\n const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));\n\n if (extra) {\n const [prefix, slot] = extra;\n (params[slot] as Record<string, unknown>)[key.slice(prefix.length)] = value;\n } else if ('allowExtra' in config && config.allowExtra) {\n for (const [slot, allowed] of Object.entries(config.allowExtra)) {\n if (allowed) {\n (params[slot as Slot] as Record<string, unknown>)[key] = value;\n break;\n }\n }\n }\n }\n }\n }\n }\n\n stripEmptySlots(params);\n\n return params as Params;\n}\n"],"mappings":";AAkDA,MAAM,gBAAgB,OAAO,QAAQ;CALnC,QAAQ;CACR,WAAW;CACX,QAAQ;CACR,SAAS;AAEyC,CAAC;AAcrD,SAAS,YAAY,QAAsB,KAAsB;CAC/D,IAAI,CAAC,KACH,sBAAM,IAAI,IAAI;CAGhB,KAAK,MAAM,UAAU,QACnB,IAAI,QAAQ;MACN,OAAO,KACT,IAAI,IAAI,OAAO,KAAK;GAClB,IAAI,OAAO;GACX,KAAK,OAAO;EACd,CAAC;CAAA,OAEE,IAAI,SAAS,QAClB,IAAI,IAAI,OAAO,KAAK,EAClB,KAAK,OAAO,IACd,CAAC;MACI,IAAI,OAAO,MAChB,YAAY,OAAO,MAAM,GAAG;CAIhC,OAAO;AACT;AAWA,SAAS,gBAAgB,QAA6B;CACpD,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,MAAM,GAC/C,IAAI,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,CAAC,QACrF,OAAO,OAAO;AAGpB;AAEA,SAAgB,kBAAkB,MAA8B,QAA8B;CAC5F,MAAM,SAAwB;EAC5B,MAAM,OAAO,OAAO,IAAI;EACxB,SAAS,OAAO,OAAO,IAAI;EAC3B,MAAM,OAAO,OAAO,IAAI;EACxB,OAAO,OAAO,OAAO,IAAI;CAC3B;CAEA,MAAM,MAAM,YAAY,MAAM;CAE9B,IAAI;CAEJ,KAAK,MAAM,CAAC,OAAO,QAAQ,KAAK,QAAQ,GAAG;EACzC,IAAI,OAAO,QACT,SAAS,OAAO;EAGlB,IAAI,CAAC,QACH;EAGF,IAAI,QAAQ,QACV,IAAI,OAAO,KAAK;GACd,MAAM,QAAQ,IAAI,IAAI,OAAO,GAAG;GAChC,MAAM,OAAO,MAAM,OAAO,OAAO;GACjC,IAAI,MAAM,IACR,OAAQ,MAAM,GAAG,CAA6B,QAAQ;EAE1D,OACE,OAAO,OAAO;OAGhB,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,CAAC,CAAC,GAAG;GACpD,MAAM,QAAQ,IAAI,IAAI,GAAG;GAEzB,IAAI,OACF,IAAI,MAAM,IAAI;IACZ,MAAM,OAAO,MAAM,OAAO;IAC1B,OAAQ,MAAM,GAAG,CAA6B,QAAQ;GACxD,OACE,OAAO,MAAM,OAAO;QAEjB;IACL,MAAM,QAAQ,cAAc,MAAM,CAAC,YAAY,IAAI,WAAW,MAAM,CAAC;IAErE,IAAI,OAAO;KACT,MAAM,CAAC,QAAQ,QAAQ;KACvB,OAAQ,KAAK,CAA6B,IAAI,MAAM,OAAO,MAAM,KAAK;IACxE,OAAO,IAAI,gBAAgB,UAAU,OAAO;UACrC,MAAM,CAAC,MAAM,YAAY,OAAO,QAAQ,OAAO,UAAU,GAC5D,IAAI,SAAS;MACX,OAAQ,KAAa,CAA6B,OAAO;MACzD;KACF;;GAGN;EACF;CAEJ;CAEA,gBAAgB,MAAM;CAEtB,OAAO;AACT"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//#region src/client/core/pathSerializer.gen.d.ts
|
|
2
|
+
interface SerializeOptions<T> extends SerializePrimitiveOptions, SerializerOptions<T> {}
|
|
3
|
+
interface SerializePrimitiveOptions {
|
|
4
|
+
allowReserved?: boolean;
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
interface SerializerOptions<T> {
|
|
8
|
+
/**
|
|
9
|
+
* @default true
|
|
10
|
+
*/
|
|
11
|
+
explode: boolean;
|
|
12
|
+
style: T;
|
|
13
|
+
}
|
|
14
|
+
type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
|
|
15
|
+
type ArraySeparatorStyle = ArrayStyle | MatrixStyle;
|
|
16
|
+
type MatrixStyle = 'label' | 'matrix' | 'simple';
|
|
17
|
+
type ObjectStyle = 'form' | 'deepObject';
|
|
18
|
+
type ObjectSeparatorStyle = ObjectStyle | MatrixStyle;
|
|
19
|
+
interface SerializePrimitiveParam extends SerializePrimitiveOptions {
|
|
20
|
+
value: string;
|
|
21
|
+
}
|
|
22
|
+
declare const separatorArrayExplode: (style: ArraySeparatorStyle) => "." | ";" | "," | "&";
|
|
23
|
+
declare const separatorArrayNoExplode: (style: ArraySeparatorStyle) => "," | "|" | "%20";
|
|
24
|
+
declare const separatorObjectExplode: (style: ObjectSeparatorStyle) => "." | ";" | "," | "&";
|
|
25
|
+
declare const serializeArrayParam: ({
|
|
26
|
+
allowReserved,
|
|
27
|
+
explode,
|
|
28
|
+
name,
|
|
29
|
+
style,
|
|
30
|
+
value
|
|
31
|
+
}: SerializeOptions<ArraySeparatorStyle> & {
|
|
32
|
+
value: unknown[];
|
|
33
|
+
}) => string;
|
|
34
|
+
declare const serializePrimitiveParam: ({
|
|
35
|
+
allowReserved,
|
|
36
|
+
name,
|
|
37
|
+
value
|
|
38
|
+
}: SerializePrimitiveParam) => string;
|
|
39
|
+
declare const serializeObjectParam: ({
|
|
40
|
+
allowReserved,
|
|
41
|
+
explode,
|
|
42
|
+
name,
|
|
43
|
+
style,
|
|
44
|
+
value,
|
|
45
|
+
valueOnly
|
|
46
|
+
}: SerializeOptions<ObjectSeparatorStyle> & {
|
|
47
|
+
value: Record<string, unknown> | Date;
|
|
48
|
+
valueOnly?: boolean;
|
|
49
|
+
}) => string;
|
|
50
|
+
//#endregion
|
|
51
|
+
export { ArraySeparatorStyle, ArrayStyle, ObjectStyle, SerializerOptions, separatorArrayExplode, separatorArrayNoExplode, separatorObjectExplode, serializeArrayParam, serializeObjectParam, serializePrimitiveParam };
|
|
52
|
+
//# sourceMappingURL=pathSerializer.gen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pathSerializer.gen.d.ts","names":[],"sources":["../../../src/client/core/pathSerializer.gen.ts"],"mappings":";UAEU,4BAA4B,2BAA2B,kBAAkB;UAEzE,yBAAA,CAFgB;eAAyD,CAAA,EAAA,OAAA;MAA7C,EAAA,MAAA;;AAA4C,UAOjE,iBAPiE,CAAA,CAAA,CAAA,CAAA;EAExE;AAKV;AAQA;EACY,OAAA,EAAA,OAAA;EAAmB,KAAA,EAJtB,CAIsB;;AAAgB,KADnC,UAAA,GACmC,MAAA,GAAA,gBAAA,GAAA,eAAA;AAAW,KAA9C,mBAAA,GAAsB,UAAwB,GAAX,WAAW;AAAC,KACtD,WAAA,GAAW,OAAA,GAAA,QAAA,GAAA,QAAA;AACJ,KAAA,WAAA,GAAW,MAAA,GAAA,YAAA;AAAyB,KAC3C,oBAAA,GAAuB,WAAH,GAAiB,WAAjB;UAEf,uBAAA,SAAgC,yBAFjB,CAAA;OAAG,EAAA,MAAA;;AAAyB,cAMxC,qBANwC,EAAA,CAAA,KAAA,EAMR,mBANQ,EAAA,GAAA,GAAA,GAAA,GAAA,GAAA,GAAA,GAAA,GAAA;AAE3C,cAiBG,uBAjB6B,EAAA,CAAA,KAAA,EAiBK,mBAjBoB,EAAA,GAAA,GAAA,GAAA,GAAA,GAAA,KAAA;AAItD,cA0BA,sBA1BgC,EAAA,CAAA,KAAA,EA0BC,oBA1BkB,EAAA,GAAA,GAAA,GAAA,GAAA,GAAA,GAAA,GAAA,GAAA;AAanD,cA0BA,mBAfZ,EAAA,CAX8C;EAAA,aAAA;EAAA,OAAmB;EAAA,IAAA;EAAA,KAAA;EAAA;AA0BlE,CA1BkE,EAgC/D,gBAhC+D,CAgC9C,mBAhC8C,CAAA,GAAA;EAarD,KAAA,EAAA,OAAA,EAAA;AAab,CAAA,EAAA,GAAa,MAAA;AAwCZ,cAEY,uBAFZ,EAAA,CAAA;EAAA,aAAA;EAAA,IAAA;EAAA;AAAA,CAAA,EAME,uBANF,EAAA,GAAA,MAAA;AAxCmC,cA4DvB,oBA5DuB,EAAA,CAAA;EAAA,aAAA;EAAA,OAAA;EAAA,IAAA;EAAA,KAAA;EAAA,KAAA;EAAA;CAAA,EAmEjC,gBAnEiC,CAmEhB,oBAnEgB,CAAA,GAAA;OAAA,EAoE3B,MApE2B,CAAA,MAAA,EAAA,OAAA,CAAA,GAoED,IApEC;WAAA,CAAA,EAAA,OAAA;YAAA"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
//#region src/client/core/pathSerializer.gen.ts
|
|
2
|
+
const separatorArrayExplode = (style) => {
|
|
3
|
+
switch (style) {
|
|
4
|
+
case "label": return ".";
|
|
5
|
+
case "matrix": return ";";
|
|
6
|
+
case "simple": return ",";
|
|
7
|
+
default: return "&";
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
const separatorArrayNoExplode = (style) => {
|
|
11
|
+
switch (style) {
|
|
12
|
+
case "form": return ",";
|
|
13
|
+
case "pipeDelimited": return "|";
|
|
14
|
+
case "spaceDelimited": return "%20";
|
|
15
|
+
default: return ",";
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const separatorObjectExplode = (style) => {
|
|
19
|
+
switch (style) {
|
|
20
|
+
case "label": return ".";
|
|
21
|
+
case "matrix": return ";";
|
|
22
|
+
case "simple": return ",";
|
|
23
|
+
default: return "&";
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const serializeArrayParam = ({ allowReserved, explode, name, style, value }) => {
|
|
27
|
+
if (!explode) {
|
|
28
|
+
const joinedValues = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
|
|
29
|
+
switch (style) {
|
|
30
|
+
case "label": return `.${joinedValues}`;
|
|
31
|
+
case "matrix": return `;${name}=${joinedValues}`;
|
|
32
|
+
case "simple": return joinedValues;
|
|
33
|
+
default: return `${name}=${joinedValues}`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const separator = separatorArrayExplode(style);
|
|
37
|
+
const joinedValues = value.map((v) => {
|
|
38
|
+
if (style === "label" || style === "simple") return allowReserved ? v : encodeURIComponent(v);
|
|
39
|
+
return serializePrimitiveParam({
|
|
40
|
+
allowReserved,
|
|
41
|
+
name,
|
|
42
|
+
value: v
|
|
43
|
+
});
|
|
44
|
+
}).join(separator);
|
|
45
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
46
|
+
};
|
|
47
|
+
const serializePrimitiveParam = ({ allowReserved, name, value }) => {
|
|
48
|
+
if (value === void 0 || value === null) return "";
|
|
49
|
+
if (typeof value === "object") throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");
|
|
50
|
+
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
51
|
+
};
|
|
52
|
+
const serializeObjectParam = ({ allowReserved, explode, name, style, value, valueOnly }) => {
|
|
53
|
+
if (value instanceof Date) return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
54
|
+
if (style !== "deepObject" && !explode) {
|
|
55
|
+
let values = [];
|
|
56
|
+
Object.entries(value).forEach(([key, v]) => {
|
|
57
|
+
values = [
|
|
58
|
+
...values,
|
|
59
|
+
key,
|
|
60
|
+
allowReserved ? v : encodeURIComponent(v)
|
|
61
|
+
];
|
|
62
|
+
});
|
|
63
|
+
const joinedValues = values.join(",");
|
|
64
|
+
switch (style) {
|
|
65
|
+
case "form": return `${name}=${joinedValues}`;
|
|
66
|
+
case "label": return `.${joinedValues}`;
|
|
67
|
+
case "matrix": return `;${name}=${joinedValues}`;
|
|
68
|
+
default: return joinedValues;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const separator = separatorObjectExplode(style);
|
|
72
|
+
const joinedValues = Object.entries(value).map(([key, v]) => serializePrimitiveParam({
|
|
73
|
+
allowReserved,
|
|
74
|
+
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
75
|
+
value: v
|
|
76
|
+
})).join(separator);
|
|
77
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
78
|
+
};
|
|
79
|
+
//#endregion
|
|
80
|
+
export { separatorArrayExplode, separatorArrayNoExplode, separatorObjectExplode, serializeArrayParam, serializeObjectParam, serializePrimitiveParam };
|
|
81
|
+
|
|
82
|
+
//# sourceMappingURL=pathSerializer.gen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pathSerializer.gen.js","names":[],"sources":["../../../src/client/core/pathSerializer.gen.ts"],"sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\ninterface SerializeOptions<T> extends SerializePrimitiveOptions, SerializerOptions<T> {}\n\ninterface SerializePrimitiveOptions {\n allowReserved?: boolean;\n name: string;\n}\n\nexport interface SerializerOptions<T> {\n /**\n * @default true\n */\n explode: boolean;\n style: T;\n}\n\nexport type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';\nexport type ArraySeparatorStyle = ArrayStyle | MatrixStyle;\ntype MatrixStyle = 'label' | 'matrix' | 'simple';\nexport type ObjectStyle = 'form' | 'deepObject';\ntype ObjectSeparatorStyle = ObjectStyle | MatrixStyle;\n\ninterface SerializePrimitiveParam extends SerializePrimitiveOptions {\n value: string;\n}\n\nexport const separatorArrayExplode = (style: ArraySeparatorStyle): '.' | ';' | ',' | '&' => {\n switch (style) {\n case 'label':\n return '.';\n case 'matrix':\n return ';';\n case 'simple':\n return ',';\n default:\n return '&';\n }\n};\n\nexport const separatorArrayNoExplode = (style: ArraySeparatorStyle): ',' | '|' | '%20' => {\n switch (style) {\n case 'form':\n return ',';\n case 'pipeDelimited':\n return '|';\n case 'spaceDelimited':\n return '%20';\n default:\n return ',';\n }\n};\n\nexport const separatorObjectExplode = (style: ObjectSeparatorStyle): '.' | ';' | ',' | '&' => {\n switch (style) {\n case 'label':\n return '.';\n case 'matrix':\n return ';';\n case 'simple':\n return ',';\n default:\n return '&';\n }\n};\n\nexport const serializeArrayParam = ({\n allowReserved,\n explode,\n name,\n style,\n value,\n}: SerializeOptions<ArraySeparatorStyle> & {\n value: unknown[];\n}): string => {\n if (!explode) {\n const joinedValues = (\n allowReserved ? value : value.map((v) => encodeURIComponent(v as string))\n ).join(separatorArrayNoExplode(style));\n switch (style) {\n case 'label':\n return `.${joinedValues}`;\n case 'matrix':\n return `;${name}=${joinedValues}`;\n case 'simple':\n return joinedValues;\n default:\n return `${name}=${joinedValues}`;\n }\n }\n\n const separator = separatorArrayExplode(style);\n const joinedValues = value\n .map((v) => {\n if (style === 'label' || style === 'simple') {\n return allowReserved ? v : encodeURIComponent(v as string);\n }\n\n return serializePrimitiveParam({\n allowReserved,\n name,\n value: v as string,\n });\n })\n .join(separator);\n return style === 'label' || style === 'matrix' ? separator + joinedValues : joinedValues;\n};\n\nexport const serializePrimitiveParam = ({\n allowReserved,\n name,\n value,\n}: SerializePrimitiveParam): string => {\n if (value === undefined || value === null) {\n return '';\n }\n\n if (typeof value === 'object') {\n throw new Error(\n 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.',\n );\n }\n\n return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;\n};\n\nexport const serializeObjectParam = ({\n allowReserved,\n explode,\n name,\n style,\n value,\n valueOnly,\n}: SerializeOptions<ObjectSeparatorStyle> & {\n value: Record<string, unknown> | Date;\n valueOnly?: boolean;\n}): string => {\n if (value instanceof Date) {\n return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;\n }\n\n if (style !== 'deepObject' && !explode) {\n let values: string[] = [];\n Object.entries(value).forEach(([key, v]) => {\n values = [...values, key, allowReserved ? (v as string) : encodeURIComponent(v as string)];\n });\n const joinedValues = values.join(',');\n switch (style) {\n case 'form':\n return `${name}=${joinedValues}`;\n case 'label':\n return `.${joinedValues}`;\n case 'matrix':\n return `;${name}=${joinedValues}`;\n default:\n return joinedValues;\n }\n }\n\n const separator = separatorObjectExplode(style);\n const joinedValues = Object.entries(value)\n .map(([key, v]) =>\n serializePrimitiveParam({\n allowReserved,\n name: style === 'deepObject' ? `${name}[${key}]` : key,\n value: v as string,\n }),\n )\n .join(separator);\n return style === 'label' || style === 'matrix' ? separator + joinedValues : joinedValues;\n};\n"],"mappings":";AA2BA,MAAa,yBAAyB,UAAsD;CAC1F,QAAQ,OAAR;EACE,KAAK,SACH,OAAO;EACT,KAAK,UACH,OAAO;EACT,KAAK,UACH,OAAO;EACT,SACE,OAAO;CACX;AACF;AAEA,MAAa,2BAA2B,UAAkD;CACxF,QAAQ,OAAR;EACE,KAAK,QACH,OAAO;EACT,KAAK,iBACH,OAAO;EACT,KAAK,kBACH,OAAO;EACT,SACE,OAAO;CACX;AACF;AAEA,MAAa,0BAA0B,UAAuD;CAC5F,QAAQ,OAAR;EACE,KAAK,SACH,OAAO;EACT,KAAK,UACH,OAAO;EACT,KAAK,UACH,OAAO;EACT,SACE,OAAO;CACX;AACF;AAEA,MAAa,uBAAuB,EAClC,eACA,SACA,MACA,OACA,YAGY;CACZ,IAAI,CAAC,SAAS;EACZ,MAAM,gBACJ,gBAAgB,QAAQ,MAAM,KAAK,MAAM,mBAAmB,CAAW,CAAC,EAAA,CACxE,KAAK,wBAAwB,KAAK,CAAC;EACrC,QAAQ,OAAR;GACE,KAAK,SACH,OAAO,IAAI;GACb,KAAK,UACH,OAAO,IAAI,KAAK,GAAG;GACrB,KAAK,UACH,OAAO;GACT,SACE,OAAO,GAAG,KAAK,GAAG;EACtB;CACF;CAEA,MAAM,YAAY,sBAAsB,KAAK;CAC7C,MAAM,eAAe,MAClB,KAAK,MAAM;EACV,IAAI,UAAU,WAAW,UAAU,UACjC,OAAO,gBAAgB,IAAI,mBAAmB,CAAW;EAG3D,OAAO,wBAAwB;GAC7B;GACA;GACA,OAAO;EACT,CAAC;CACH,CAAC,CAAC,CACD,KAAK,SAAS;CACjB,OAAO,UAAU,WAAW,UAAU,WAAW,YAAY,eAAe;AAC9E;AAEA,MAAa,2BAA2B,EACtC,eACA,MACA,YACqC;CACrC,IAAI,UAAU,KAAA,KAAa,UAAU,MACnC,OAAO;CAGT,IAAI,OAAO,UAAU,UACnB,MAAM,IAAI,MACR,sGACF;CAGF,OAAO,GAAG,KAAK,GAAG,gBAAgB,QAAQ,mBAAmB,KAAK;AACpE;AAEA,MAAa,wBAAwB,EACnC,eACA,SACA,MACA,OACA,OACA,gBAIY;CACZ,IAAI,iBAAiB,MACnB,OAAO,YAAY,MAAM,YAAY,IAAI,GAAG,KAAK,GAAG,MAAM,YAAY;CAGxE,IAAI,UAAU,gBAAgB,CAAC,SAAS;EACtC,IAAI,SAAmB,CAAC;EACxB,OAAO,QAAQ,KAAK,CAAC,CAAC,SAAS,CAAC,KAAK,OAAO;GAC1C,SAAS;IAAC,GAAG;IAAQ;IAAK,gBAAiB,IAAe,mBAAmB,CAAW;GAAC;EAC3F,CAAC;EACD,MAAM,eAAe,OAAO,KAAK,GAAG;EACpC,QAAQ,OAAR;GACE,KAAK,QACH,OAAO,GAAG,KAAK,GAAG;GACpB,KAAK,SACH,OAAO,IAAI;GACb,KAAK,UACH,OAAO,IAAI,KAAK,GAAG;GACrB,SACE,OAAO;EACX;CACF;CAEA,MAAM,YAAY,uBAAuB,KAAK;CAC9C,MAAM,eAAe,OAAO,QAAQ,KAAK,CAAC,CACvC,KAAK,CAAC,KAAK,OACV,wBAAwB;EACtB;EACA,MAAM,UAAU,eAAe,GAAG,KAAK,GAAG,IAAI,KAAK;EACnD,OAAO;CACT,CAAC,CACH,CAAC,CACA,KAAK,SAAS;CACjB,OAAO,UAAU,WAAW,UAAU,WAAW,YAAY,eAAe;AAC9E"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/client/core/queryKeySerializer.gen.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* JSON-friendly union that mirrors what Pinia Colada can hash.
|
|
4
|
+
*/
|
|
5
|
+
type JsonValue = null | string | number | boolean | JsonValue[] | {
|
|
6
|
+
[key: string]: JsonValue;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
|
|
10
|
+
*/
|
|
11
|
+
declare const queryKeyJsonReplacer: (_key: string, value: unknown) => unknown | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Safely stringifies a value and parses it back into a JsonValue.
|
|
14
|
+
*/
|
|
15
|
+
declare const stringifyToJsonValue: (input: unknown) => JsonValue | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Normalizes any accepted value into a JSON-friendly shape for query keys.
|
|
18
|
+
*/
|
|
19
|
+
declare const serializeQueryKeyValue: (value: unknown) => JsonValue | undefined;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { JsonValue, queryKeyJsonReplacer, serializeQueryKeyValue, stringifyToJsonValue };
|
|
22
|
+
//# sourceMappingURL=queryKeySerializer.gen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryKeySerializer.gen.d.ts","names":[],"sources":["../../../src/client/core/queryKeySerializer.gen.ts"],"mappings":";;AAKA;;AAKI,KALQ,SAAA,GAKR,IAAA,GAAA,MAAA,GAAA,MAAA,GAAA,OAAA,GAAA,SAAA,EAAA,GAAA;MACiB,EAAA,MAAA,CAAA,EAAA,SAAA;AAAS,CAAA;AAK9B;AAgBA;AAkDA;cAlEa;;;;cAgBA,0CAAyC;;;;cAkDzC,4CAA2C"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
//#region src/client/core/queryKeySerializer.gen.ts
|
|
2
|
+
/**
|
|
3
|
+
* Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
|
|
4
|
+
*/
|
|
5
|
+
const queryKeyJsonReplacer = (_key, value) => {
|
|
6
|
+
if (value === void 0 || typeof value === "function" || typeof value === "symbol") return;
|
|
7
|
+
if (typeof value === "bigint") return value.toString();
|
|
8
|
+
if (value instanceof Date) return value.toISOString();
|
|
9
|
+
return value;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Safely stringifies a value and parses it back into a JsonValue.
|
|
13
|
+
*/
|
|
14
|
+
const stringifyToJsonValue = (input) => {
|
|
15
|
+
try {
|
|
16
|
+
const json = JSON.stringify(input, queryKeyJsonReplacer);
|
|
17
|
+
if (json === void 0) return;
|
|
18
|
+
return JSON.parse(json);
|
|
19
|
+
} catch {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Detects plain objects (including objects with a null prototype).
|
|
25
|
+
*/
|
|
26
|
+
const isPlainObject = (value) => {
|
|
27
|
+
if (value === null || typeof value !== "object") return false;
|
|
28
|
+
const prototype = Object.getPrototypeOf(value);
|
|
29
|
+
return prototype === Object.prototype || prototype === null;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Turns URLSearchParams into a sorted JSON object for deterministic keys.
|
|
33
|
+
*/
|
|
34
|
+
const serializeSearchParams = (params) => {
|
|
35
|
+
const entries = Array.from(params.entries()).sort(([a], [b]) => a.localeCompare(b));
|
|
36
|
+
const result = {};
|
|
37
|
+
for (const [key, value] of entries) {
|
|
38
|
+
const existing = result[key];
|
|
39
|
+
if (existing === void 0) {
|
|
40
|
+
result[key] = value;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (Array.isArray(existing)) existing.push(value);
|
|
44
|
+
else result[key] = [existing, value];
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Normalizes any accepted value into a JSON-friendly shape for query keys.
|
|
50
|
+
*/
|
|
51
|
+
const serializeQueryKeyValue = (value) => {
|
|
52
|
+
if (value === null) return null;
|
|
53
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return value;
|
|
54
|
+
if (value === void 0 || typeof value === "function" || typeof value === "symbol") return;
|
|
55
|
+
if (typeof value === "bigint") return value.toString();
|
|
56
|
+
if (value instanceof Date) return value.toISOString();
|
|
57
|
+
if (Array.isArray(value)) return stringifyToJsonValue(value);
|
|
58
|
+
if (typeof URLSearchParams !== "undefined" && value instanceof URLSearchParams) return serializeSearchParams(value);
|
|
59
|
+
if (isPlainObject(value)) return stringifyToJsonValue(value);
|
|
60
|
+
};
|
|
61
|
+
//#endregion
|
|
62
|
+
export { queryKeyJsonReplacer, serializeQueryKeyValue, stringifyToJsonValue };
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=queryKeySerializer.gen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryKeySerializer.gen.js","names":[],"sources":["../../../src/client/core/queryKeySerializer.gen.ts"],"sourcesContent":["// This file is auto-generated by @hey-api/openapi-ts\n\n/**\n * JSON-friendly union that mirrors what Pinia Colada can hash.\n */\nexport type JsonValue =\n | null\n | string\n | number\n | boolean\n | JsonValue[]\n | { [key: string]: JsonValue };\n\n/**\n * Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.\n */\nexport const queryKeyJsonReplacer = (_key: string, value: unknown): unknown | undefined => {\n if (value === undefined || typeof value === 'function' || typeof value === 'symbol') {\n return undefined;\n }\n if (typeof value === 'bigint') {\n return value.toString();\n }\n if (value instanceof Date) {\n return value.toISOString();\n }\n return value;\n};\n\n/**\n * Safely stringifies a value and parses it back into a JsonValue.\n */\nexport const stringifyToJsonValue = (input: unknown): JsonValue | undefined => {\n try {\n const json = JSON.stringify(input, queryKeyJsonReplacer);\n if (json === undefined) {\n return undefined;\n }\n return JSON.parse(json) as JsonValue;\n } catch {\n return undefined;\n }\n};\n\n/**\n * Detects plain objects (including objects with a null prototype).\n */\nconst isPlainObject = (value: unknown): value is Record<string, unknown> => {\n if (value === null || typeof value !== 'object') {\n return false;\n }\n const prototype = Object.getPrototypeOf(value as object);\n return prototype === Object.prototype || prototype === null;\n};\n\n/**\n * Turns URLSearchParams into a sorted JSON object for deterministic keys.\n */\nconst serializeSearchParams = (params: URLSearchParams): JsonValue => {\n const entries = Array.from(params.entries()).sort(([a], [b]) => a.localeCompare(b));\n const result: Record<string, JsonValue> = {};\n\n for (const [key, value] of entries) {\n const existing = result[key];\n if (existing === undefined) {\n result[key] = value;\n continue;\n }\n\n if (Array.isArray(existing)) {\n (existing as string[]).push(value);\n } else {\n result[key] = [existing, value];\n }\n }\n\n return result;\n};\n\n/**\n * Normalizes any accepted value into a JSON-friendly shape for query keys.\n */\nexport const serializeQueryKeyValue = (value: unknown): JsonValue | undefined => {\n if (value === null) {\n return null;\n }\n\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n return value;\n }\n\n if (value === undefined || typeof value === 'function' || typeof value === 'symbol') {\n return undefined;\n }\n\n if (typeof value === 'bigint') {\n return value.toString();\n }\n\n if (value instanceof Date) {\n return value.toISOString();\n }\n\n if (Array.isArray(value)) {\n return stringifyToJsonValue(value);\n }\n\n if (typeof URLSearchParams !== 'undefined' && value instanceof URLSearchParams) {\n return serializeSearchParams(value);\n }\n\n if (isPlainObject(value)) {\n return stringifyToJsonValue(value);\n }\n\n return undefined;\n};\n"],"mappings":";;;;AAgBA,MAAa,wBAAwB,MAAc,UAAwC;CACzF,IAAI,UAAU,KAAA,KAAa,OAAO,UAAU,cAAc,OAAO,UAAU,UACzE;CAEF,IAAI,OAAO,UAAU,UACnB,OAAO,MAAM,SAAS;CAExB,IAAI,iBAAiB,MACnB,OAAO,MAAM,YAAY;CAE3B,OAAO;AACT;;;;AAKA,MAAa,wBAAwB,UAA0C;CAC7E,IAAI;EACF,MAAM,OAAO,KAAK,UAAU,OAAO,oBAAoB;EACvD,IAAI,SAAS,KAAA,GACX;EAEF,OAAO,KAAK,MAAM,IAAI;CACxB,QAAQ;EACN;CACF;AACF;;;;AAKA,MAAM,iBAAiB,UAAqD;CAC1E,IAAI,UAAU,QAAQ,OAAO,UAAU,UACrC,OAAO;CAET,MAAM,YAAY,OAAO,eAAe,KAAe;CACvD,OAAO,cAAc,OAAO,aAAa,cAAc;AACzD;;;;AAKA,MAAM,yBAAyB,WAAuC;CACpE,MAAM,UAAU,MAAM,KAAK,OAAO,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;CAClF,MAAM,SAAoC,CAAC;CAE3C,KAAK,MAAM,CAAC,KAAK,UAAU,SAAS;EAClC,MAAM,WAAW,OAAO;EACxB,IAAI,aAAa,KAAA,GAAW;GAC1B,OAAO,OAAO;GACd;EACF;EAEA,IAAI,MAAM,QAAQ,QAAQ,GACxB,SAAuB,KAAK,KAAK;OAEjC,OAAO,OAAO,CAAC,UAAU,KAAK;CAElC;CAEA,OAAO;AACT;;;;AAKA,MAAa,0BAA0B,UAA0C;CAC/E,IAAI,UAAU,MACZ,OAAO;CAGT,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,YAAY,OAAO,UAAU,WAC7E,OAAO;CAGT,IAAI,UAAU,KAAA,KAAa,OAAO,UAAU,cAAc,OAAO,UAAU,UACzE;CAGF,IAAI,OAAO,UAAU,UACnB,OAAO,MAAM,SAAS;CAGxB,IAAI,iBAAiB,MACnB,OAAO,MAAM,YAAY;CAG3B,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,qBAAqB,KAAK;CAGnC,IAAI,OAAO,oBAAoB,eAAe,iBAAiB,iBAC7D,OAAO,sBAAsB,KAAK;CAGpC,IAAI,cAAc,KAAK,GACrB,OAAO,qBAAqB,KAAK;AAIrC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Config } from "./types.gen.js";
|
|
2
|
+
|
|
3
|
+
//#region src/client/core/serverSentEvents.gen.d.ts
|
|
4
|
+
type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method'> & Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & {
|
|
5
|
+
/**
|
|
6
|
+
* Fetch API implementation. You can use this option to provide a custom
|
|
7
|
+
* fetch instance.
|
|
8
|
+
*
|
|
9
|
+
* @default globalThis.fetch
|
|
10
|
+
*/
|
|
11
|
+
fetch?: typeof fetch;
|
|
12
|
+
/**
|
|
13
|
+
* Implementing clients can call request interceptors inside this hook.
|
|
14
|
+
*/
|
|
15
|
+
onRequest?: (url: string, init: RequestInit) => Promise<Request>;
|
|
16
|
+
/**
|
|
17
|
+
* Callback invoked when a network or parsing error occurs during streaming.
|
|
18
|
+
*
|
|
19
|
+
* This option applies only if the endpoint returns a stream of events.
|
|
20
|
+
*
|
|
21
|
+
* @param error The error that occurred.
|
|
22
|
+
*/
|
|
23
|
+
onSseError?: (error: unknown) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Callback invoked when an event is streamed from the server.
|
|
26
|
+
*
|
|
27
|
+
* This option applies only if the endpoint returns a stream of events.
|
|
28
|
+
*
|
|
29
|
+
* @param event Event streamed from the server.
|
|
30
|
+
* @returns Nothing (void).
|
|
31
|
+
*/
|
|
32
|
+
onSseEvent?: (event: StreamEvent<TData>) => void;
|
|
33
|
+
serializedBody?: RequestInit['body'];
|
|
34
|
+
/**
|
|
35
|
+
* Default retry delay in milliseconds.
|
|
36
|
+
*
|
|
37
|
+
* This option applies only if the endpoint returns a stream of events.
|
|
38
|
+
*
|
|
39
|
+
* @default 3000
|
|
40
|
+
*/
|
|
41
|
+
sseDefaultRetryDelay?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Maximum number of retry attempts before giving up.
|
|
44
|
+
*/
|
|
45
|
+
sseMaxRetryAttempts?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Maximum retry delay in milliseconds.
|
|
48
|
+
*
|
|
49
|
+
* Applies only when exponential backoff is used.
|
|
50
|
+
*
|
|
51
|
+
* This option applies only if the endpoint returns a stream of events.
|
|
52
|
+
*
|
|
53
|
+
* @default 30000
|
|
54
|
+
*/
|
|
55
|
+
sseMaxRetryDelay?: number;
|
|
56
|
+
/**
|
|
57
|
+
* Optional sleep function for retry backoff.
|
|
58
|
+
*
|
|
59
|
+
* Defaults to using `setTimeout`.
|
|
60
|
+
*/
|
|
61
|
+
sseSleepFn?: (ms: number) => Promise<void>;
|
|
62
|
+
url: string;
|
|
63
|
+
};
|
|
64
|
+
interface StreamEvent<TData = unknown> {
|
|
65
|
+
data: TData;
|
|
66
|
+
event?: string;
|
|
67
|
+
id?: string;
|
|
68
|
+
retry?: number;
|
|
69
|
+
}
|
|
70
|
+
type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = {
|
|
71
|
+
stream: AsyncGenerator<TData extends Record<string, unknown> ? TData[keyof TData] : TData, TReturn, TNext>;
|
|
72
|
+
};
|
|
73
|
+
declare function createSseClient<TData = unknown>({
|
|
74
|
+
onRequest,
|
|
75
|
+
onSseError,
|
|
76
|
+
onSseEvent,
|
|
77
|
+
responseTransformer,
|
|
78
|
+
responseValidator,
|
|
79
|
+
sseDefaultRetryDelay,
|
|
80
|
+
sseMaxRetryAttempts,
|
|
81
|
+
sseMaxRetryDelay,
|
|
82
|
+
sseSleepFn,
|
|
83
|
+
url,
|
|
84
|
+
...options
|
|
85
|
+
}: ServerSentEventsOptions): ServerSentEventsResult<TData>;
|
|
86
|
+
//#endregion
|
|
87
|
+
export { ServerSentEventsOptions, ServerSentEventsResult, StreamEvent, createSseClient };
|
|
88
|
+
//# sourceMappingURL=serverSentEvents.gen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serverSentEvents.gen.d.ts","names":[],"sources":["../../../src/client/core/serverSentEvents.gen.ts"],"mappings":";;;KAIY,2CAA2C,KAAK,yBAC1D,KAAK;;AADP;;;;;OACE,CAAA,EAAA,OAOiB,KAPjB;;;;WAWkD,CAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,IAAA,EAAhB,WAAgB,EAAA,GAAA,OAAA,CAAQ,OAAR,CAAA;;;;;AA8CZ;AAIxC;AAOA;EAAkC,UAAA,CAAA,EAAA,CAAA,KAAA,EAAA,OAAA,EAAA,GAAA,IAAA;;;;;;;;;EACV,UAAA,CAAA,EAAA,CAAA,KAAA,EAzCC,WAyCD,CAzCa,KAyCb,CAAA,EAAA,GAAA,IAAA;EAOR,cAAA,CAAA,EA/CK,WA+CU,CAAA,MAAA,CAAA;EAAA;;;;;;;sBAO7B,CAAA,EAAA,MAAA;;;;qBAKC,CAAA,EAAA,MAAA;;;AAAgD;;;;;;;;;;;;;+BA/BlB;;;UAIhB;QACT;;;;;KAMI;UACF,eACN,cAAc,0BAA0B,YAAY,SAAS,OAC7D,SACA;;iBAIY;;;;;;;;;;;;GAYb,0BAA0B,uBAAuB"}
|