@reverbia/sdk 1.0.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.
Files changed (83) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +45 -0
  3. package/dist/cjs/client/client/client.gen.d.ts +2 -0
  4. package/dist/cjs/client/client/client.gen.js +203 -0
  5. package/dist/cjs/client/client/index.d.ts +8 -0
  6. package/dist/cjs/client/client/index.js +16 -0
  7. package/dist/cjs/client/client/types.gen.d.ts +99 -0
  8. package/dist/cjs/client/client/types.gen.js +3 -0
  9. package/dist/cjs/client/client/utils.gen.d.ts +40 -0
  10. package/dist/cjs/client/client/utils.gen.js +314 -0
  11. package/dist/cjs/client/client.gen.d.ts +12 -0
  12. package/dist/cjs/client/client.gen.js +6 -0
  13. package/dist/cjs/client/core/auth.gen.d.ts +18 -0
  14. package/dist/cjs/client/core/auth.gen.js +18 -0
  15. package/dist/cjs/client/core/bodySerializer.gen.d.ts +25 -0
  16. package/dist/cjs/client/core/bodySerializer.gen.js +60 -0
  17. package/dist/cjs/client/core/params.gen.d.ts +43 -0
  18. package/dist/cjs/client/core/params.gen.js +104 -0
  19. package/dist/cjs/client/core/pathSerializer.gen.d.ts +33 -0
  20. package/dist/cjs/client/core/pathSerializer.gen.js +123 -0
  21. package/dist/cjs/client/core/queryKeySerializer.gen.d.ts +18 -0
  22. package/dist/cjs/client/core/queryKeySerializer.gen.js +105 -0
  23. package/dist/cjs/client/core/serverSentEvents.gen.d.ts +71 -0
  24. package/dist/cjs/client/core/serverSentEvents.gen.js +139 -0
  25. package/dist/cjs/client/core/types.gen.d.ts +78 -0
  26. package/dist/cjs/client/core/types.gen.js +3 -0
  27. package/dist/cjs/client/core/utils.gen.d.ts +19 -0
  28. package/dist/cjs/client/core/utils.gen.js +93 -0
  29. package/dist/cjs/client/index.d.ts +2 -0
  30. package/dist/cjs/client/index.js +18 -0
  31. package/dist/cjs/client/sdk.gen.d.ts +27 -0
  32. package/dist/cjs/client/sdk.gen.js +33 -0
  33. package/dist/cjs/client/types.gen.d.ts +120 -0
  34. package/dist/cjs/client/types.gen.js +3 -0
  35. package/dist/esm/client/client/client.gen.d.ts +2 -0
  36. package/dist/esm/client/client/client.gen.js +199 -0
  37. package/dist/esm/client/client/index.d.ts +8 -0
  38. package/dist/esm/client/client/index.js +6 -0
  39. package/dist/esm/client/client/types.gen.d.ts +99 -0
  40. package/dist/esm/client/client/types.gen.js +2 -0
  41. package/dist/esm/client/client/utils.gen.d.ts +40 -0
  42. package/dist/esm/client/client/utils.gen.js +302 -0
  43. package/dist/esm/client/client.gen.d.ts +12 -0
  44. package/dist/esm/client/client.gen.js +3 -0
  45. package/dist/esm/client/core/auth.gen.d.ts +18 -0
  46. package/dist/esm/client/core/auth.gen.js +14 -0
  47. package/dist/esm/client/core/bodySerializer.gen.d.ts +25 -0
  48. package/dist/esm/client/core/bodySerializer.gen.js +57 -0
  49. package/dist/esm/client/core/params.gen.d.ts +43 -0
  50. package/dist/esm/client/core/params.gen.js +100 -0
  51. package/dist/esm/client/core/pathSerializer.gen.d.ts +33 -0
  52. package/dist/esm/client/core/pathSerializer.gen.js +114 -0
  53. package/dist/esm/client/core/queryKeySerializer.gen.d.ts +18 -0
  54. package/dist/esm/client/core/queryKeySerializer.gen.js +99 -0
  55. package/dist/esm/client/core/serverSentEvents.gen.d.ts +71 -0
  56. package/dist/esm/client/core/serverSentEvents.gen.js +135 -0
  57. package/dist/esm/client/core/types.gen.d.ts +78 -0
  58. package/dist/esm/client/core/types.gen.js +2 -0
  59. package/dist/esm/client/core/utils.gen.d.ts +19 -0
  60. package/dist/esm/client/core/utils.gen.js +87 -0
  61. package/dist/esm/client/index.d.ts +2 -0
  62. package/dist/esm/client/index.js +2 -0
  63. package/dist/esm/client/sdk.gen.d.ts +27 -0
  64. package/dist/esm/client/sdk.gen.js +28 -0
  65. package/dist/esm/client/types.gen.d.ts +120 -0
  66. package/dist/esm/client/types.gen.js +2 -0
  67. package/dist/types/client/client/client.gen.d.ts +2 -0
  68. package/dist/types/client/client/index.d.ts +8 -0
  69. package/dist/types/client/client/types.gen.d.ts +99 -0
  70. package/dist/types/client/client/utils.gen.d.ts +40 -0
  71. package/dist/types/client/client.gen.d.ts +12 -0
  72. package/dist/types/client/core/auth.gen.d.ts +18 -0
  73. package/dist/types/client/core/bodySerializer.gen.d.ts +25 -0
  74. package/dist/types/client/core/params.gen.d.ts +43 -0
  75. package/dist/types/client/core/pathSerializer.gen.d.ts +33 -0
  76. package/dist/types/client/core/queryKeySerializer.gen.d.ts +18 -0
  77. package/dist/types/client/core/serverSentEvents.gen.d.ts +71 -0
  78. package/dist/types/client/core/types.gen.d.ts +78 -0
  79. package/dist/types/client/core/utils.gen.d.ts +19 -0
  80. package/dist/types/client/index.d.ts +2 -0
  81. package/dist/types/client/sdk.gen.d.ts +27 -0
  82. package/dist/types/client/types.gen.d.ts +120 -0
  83. package/package.json +48 -0
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ // This file is auto-generated by @hey-api/openapi-ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.serializeObjectParam = exports.serializePrimitiveParam = exports.serializeArrayParam = exports.separatorObjectExplode = exports.separatorArrayNoExplode = exports.separatorArrayExplode = void 0;
5
+ const separatorArrayExplode = (style) => {
6
+ switch (style) {
7
+ case 'label':
8
+ return '.';
9
+ case 'matrix':
10
+ return ';';
11
+ case 'simple':
12
+ return ',';
13
+ default:
14
+ return '&';
15
+ }
16
+ };
17
+ exports.separatorArrayExplode = separatorArrayExplode;
18
+ const separatorArrayNoExplode = (style) => {
19
+ switch (style) {
20
+ case 'form':
21
+ return ',';
22
+ case 'pipeDelimited':
23
+ return '|';
24
+ case 'spaceDelimited':
25
+ return '%20';
26
+ default:
27
+ return ',';
28
+ }
29
+ };
30
+ exports.separatorArrayNoExplode = separatorArrayNoExplode;
31
+ const separatorObjectExplode = (style) => {
32
+ switch (style) {
33
+ case 'label':
34
+ return '.';
35
+ case 'matrix':
36
+ return ';';
37
+ case 'simple':
38
+ return ',';
39
+ default:
40
+ return '&';
41
+ }
42
+ };
43
+ exports.separatorObjectExplode = separatorObjectExplode;
44
+ const serializeArrayParam = ({ allowReserved, explode, name, style, value, }) => {
45
+ if (!explode) {
46
+ const joinedValues = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join((0, exports.separatorArrayNoExplode)(style));
47
+ switch (style) {
48
+ case 'label':
49
+ return `.${joinedValues}`;
50
+ case 'matrix':
51
+ return `;${name}=${joinedValues}`;
52
+ case 'simple':
53
+ return joinedValues;
54
+ default:
55
+ return `${name}=${joinedValues}`;
56
+ }
57
+ }
58
+ const separator = (0, exports.separatorArrayExplode)(style);
59
+ const joinedValues = value
60
+ .map((v) => {
61
+ if (style === 'label' || style === 'simple') {
62
+ return allowReserved ? v : encodeURIComponent(v);
63
+ }
64
+ return (0, exports.serializePrimitiveParam)({
65
+ allowReserved,
66
+ name,
67
+ value: v,
68
+ });
69
+ })
70
+ .join(separator);
71
+ return style === 'label' || style === 'matrix'
72
+ ? separator + joinedValues
73
+ : joinedValues;
74
+ };
75
+ exports.serializeArrayParam = serializeArrayParam;
76
+ const serializePrimitiveParam = ({ allowReserved, name, value, }) => {
77
+ if (value === undefined || value === null) {
78
+ return '';
79
+ }
80
+ if (typeof value === 'object') {
81
+ throw new Error('Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.');
82
+ }
83
+ return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
84
+ };
85
+ exports.serializePrimitiveParam = serializePrimitiveParam;
86
+ const serializeObjectParam = ({ allowReserved, explode, name, style, value, valueOnly, }) => {
87
+ if (value instanceof Date) {
88
+ return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
89
+ }
90
+ if (style !== 'deepObject' && !explode) {
91
+ let values = [];
92
+ Object.entries(value).forEach(([key, v]) => {
93
+ values = [
94
+ ...values,
95
+ key,
96
+ allowReserved ? v : encodeURIComponent(v),
97
+ ];
98
+ });
99
+ const joinedValues = values.join(',');
100
+ switch (style) {
101
+ case 'form':
102
+ return `${name}=${joinedValues}`;
103
+ case 'label':
104
+ return `.${joinedValues}`;
105
+ case 'matrix':
106
+ return `;${name}=${joinedValues}`;
107
+ default:
108
+ return joinedValues;
109
+ }
110
+ }
111
+ const separator = (0, exports.separatorObjectExplode)(style);
112
+ const joinedValues = Object.entries(value)
113
+ .map(([key, v]) => (0, exports.serializePrimitiveParam)({
114
+ allowReserved,
115
+ name: style === 'deepObject' ? `${name}[${key}]` : key,
116
+ value: v,
117
+ }))
118
+ .join(separator);
119
+ return style === 'label' || style === 'matrix'
120
+ ? separator + joinedValues
121
+ : joinedValues;
122
+ };
123
+ exports.serializeObjectParam = serializeObjectParam;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * JSON-friendly union that mirrors what Pinia Colada can hash.
3
+ */
4
+ export type JsonValue = null | string | number | boolean | JsonValue[] | {
5
+ [key: string]: JsonValue;
6
+ };
7
+ /**
8
+ * Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
9
+ */
10
+ export declare const queryKeyJsonReplacer: (_key: string, value: unknown) => {} | null | undefined;
11
+ /**
12
+ * Safely stringifies a value and parses it back into a JsonValue.
13
+ */
14
+ export declare const stringifyToJsonValue: (input: unknown) => JsonValue | undefined;
15
+ /**
16
+ * Normalizes any accepted value into a JSON-friendly shape for query keys.
17
+ */
18
+ export declare const serializeQueryKeyValue: (value: unknown) => JsonValue | undefined;
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ // This file is auto-generated by @hey-api/openapi-ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.serializeQueryKeyValue = exports.stringifyToJsonValue = exports.queryKeyJsonReplacer = void 0;
5
+ /**
6
+ * Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
7
+ */
8
+ const queryKeyJsonReplacer = (_key, value) => {
9
+ if (value === undefined ||
10
+ typeof value === 'function' ||
11
+ typeof value === 'symbol') {
12
+ return undefined;
13
+ }
14
+ if (typeof value === 'bigint') {
15
+ return value.toString();
16
+ }
17
+ if (value instanceof Date) {
18
+ return value.toISOString();
19
+ }
20
+ return value;
21
+ };
22
+ exports.queryKeyJsonReplacer = queryKeyJsonReplacer;
23
+ /**
24
+ * Safely stringifies a value and parses it back into a JsonValue.
25
+ */
26
+ const stringifyToJsonValue = (input) => {
27
+ try {
28
+ const json = JSON.stringify(input, exports.queryKeyJsonReplacer);
29
+ if (json === undefined) {
30
+ return undefined;
31
+ }
32
+ return JSON.parse(json);
33
+ }
34
+ catch {
35
+ return undefined;
36
+ }
37
+ };
38
+ exports.stringifyToJsonValue = stringifyToJsonValue;
39
+ /**
40
+ * Detects plain objects (including objects with a null prototype).
41
+ */
42
+ const isPlainObject = (value) => {
43
+ if (value === null || typeof value !== 'object') {
44
+ return false;
45
+ }
46
+ const prototype = Object.getPrototypeOf(value);
47
+ return prototype === Object.prototype || prototype === null;
48
+ };
49
+ /**
50
+ * Turns URLSearchParams into a sorted JSON object for deterministic keys.
51
+ */
52
+ const serializeSearchParams = (params) => {
53
+ const entries = Array.from(params.entries()).sort(([a], [b]) => a.localeCompare(b));
54
+ const result = {};
55
+ for (const [key, value] of entries) {
56
+ const existing = result[key];
57
+ if (existing === undefined) {
58
+ result[key] = value;
59
+ continue;
60
+ }
61
+ if (Array.isArray(existing)) {
62
+ existing.push(value);
63
+ }
64
+ else {
65
+ result[key] = [existing, value];
66
+ }
67
+ }
68
+ return result;
69
+ };
70
+ /**
71
+ * Normalizes any accepted value into a JSON-friendly shape for query keys.
72
+ */
73
+ const serializeQueryKeyValue = (value) => {
74
+ if (value === null) {
75
+ return null;
76
+ }
77
+ if (typeof value === 'string' ||
78
+ typeof value === 'number' ||
79
+ typeof value === 'boolean') {
80
+ return value;
81
+ }
82
+ if (value === undefined ||
83
+ typeof value === 'function' ||
84
+ typeof value === 'symbol') {
85
+ return undefined;
86
+ }
87
+ if (typeof value === 'bigint') {
88
+ return value.toString();
89
+ }
90
+ if (value instanceof Date) {
91
+ return value.toISOString();
92
+ }
93
+ if (Array.isArray(value)) {
94
+ return (0, exports.stringifyToJsonValue)(value);
95
+ }
96
+ if (typeof URLSearchParams !== 'undefined' &&
97
+ value instanceof URLSearchParams) {
98
+ return serializeSearchParams(value);
99
+ }
100
+ if (isPlainObject(value)) {
101
+ return (0, exports.stringifyToJsonValue)(value);
102
+ }
103
+ return undefined;
104
+ };
105
+ exports.serializeQueryKeyValue = serializeQueryKeyValue;
@@ -0,0 +1,71 @@
1
+ import type { Config } from './types.gen';
2
+ export type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method'> & Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & {
3
+ /**
4
+ * Fetch API implementation. You can use this option to provide a custom
5
+ * fetch instance.
6
+ *
7
+ * @default globalThis.fetch
8
+ */
9
+ fetch?: typeof fetch;
10
+ /**
11
+ * Implementing clients can call request interceptors inside this hook.
12
+ */
13
+ onRequest?: (url: string, init: RequestInit) => Promise<Request>;
14
+ /**
15
+ * Callback invoked when a network or parsing error occurs during streaming.
16
+ *
17
+ * This option applies only if the endpoint returns a stream of events.
18
+ *
19
+ * @param error The error that occurred.
20
+ */
21
+ onSseError?: (error: unknown) => void;
22
+ /**
23
+ * Callback invoked when an event is streamed from the server.
24
+ *
25
+ * This option applies only if the endpoint returns a stream of events.
26
+ *
27
+ * @param event Event streamed from the server.
28
+ * @returns Nothing (void).
29
+ */
30
+ onSseEvent?: (event: StreamEvent<TData>) => void;
31
+ serializedBody?: RequestInit['body'];
32
+ /**
33
+ * Default retry delay in milliseconds.
34
+ *
35
+ * This option applies only if the endpoint returns a stream of events.
36
+ *
37
+ * @default 3000
38
+ */
39
+ sseDefaultRetryDelay?: number;
40
+ /**
41
+ * Maximum number of retry attempts before giving up.
42
+ */
43
+ sseMaxRetryAttempts?: number;
44
+ /**
45
+ * Maximum retry delay in milliseconds.
46
+ *
47
+ * Applies only when exponential backoff is used.
48
+ *
49
+ * This option applies only if the endpoint returns a stream of events.
50
+ *
51
+ * @default 30000
52
+ */
53
+ sseMaxRetryDelay?: number;
54
+ /**
55
+ * Optional sleep function for retry backoff.
56
+ *
57
+ * Defaults to using `setTimeout`.
58
+ */
59
+ sseSleepFn?: (ms: number) => Promise<void>;
60
+ url: string;
61
+ };
62
+ export interface StreamEvent<TData = unknown> {
63
+ data: TData;
64
+ event?: string;
65
+ id?: string;
66
+ retry?: number;
67
+ }
68
+ export type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = {
69
+ stream: AsyncGenerator<TData extends Record<string, unknown> ? TData[keyof TData] : TData, TReturn, TNext>;
70
+ };
71
+ export declare const createSseClient: <TData = unknown>({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }: ServerSentEventsOptions) => ServerSentEventsResult<TData>;
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ // This file is auto-generated by @hey-api/openapi-ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.createSseClient = void 0;
5
+ const createSseClient = ({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) => {
6
+ let lastEventId;
7
+ const sleep = sseSleepFn ??
8
+ ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
9
+ const createStream = async function* () {
10
+ let retryDelay = sseDefaultRetryDelay ?? 3000;
11
+ let attempt = 0;
12
+ const signal = options.signal ?? new AbortController().signal;
13
+ while (true) {
14
+ if (signal.aborted)
15
+ break;
16
+ attempt++;
17
+ const headers = options.headers instanceof Headers
18
+ ? options.headers
19
+ : new Headers(options.headers);
20
+ if (lastEventId !== undefined) {
21
+ headers.set('Last-Event-ID', lastEventId);
22
+ }
23
+ try {
24
+ const requestInit = {
25
+ redirect: 'follow',
26
+ ...options,
27
+ body: options.serializedBody,
28
+ headers,
29
+ signal,
30
+ };
31
+ let request = new Request(url, requestInit);
32
+ if (onRequest) {
33
+ request = await onRequest(url, requestInit);
34
+ }
35
+ // fetch must be assigned here, otherwise it would throw the error:
36
+ // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
37
+ const _fetch = options.fetch ?? globalThis.fetch;
38
+ const response = await _fetch(request);
39
+ if (!response.ok)
40
+ throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
41
+ if (!response.body)
42
+ throw new Error('No body in SSE response');
43
+ const reader = response.body
44
+ .pipeThrough(new TextDecoderStream())
45
+ .getReader();
46
+ let buffer = '';
47
+ const abortHandler = () => {
48
+ try {
49
+ reader.cancel();
50
+ }
51
+ catch {
52
+ // noop
53
+ }
54
+ };
55
+ signal.addEventListener('abort', abortHandler);
56
+ try {
57
+ while (true) {
58
+ const { done, value } = await reader.read();
59
+ if (done)
60
+ break;
61
+ buffer += value;
62
+ const chunks = buffer.split('\n\n');
63
+ buffer = chunks.pop() ?? '';
64
+ for (const chunk of chunks) {
65
+ const lines = chunk.split('\n');
66
+ const dataLines = [];
67
+ let eventName;
68
+ for (const line of lines) {
69
+ if (line.startsWith('data:')) {
70
+ dataLines.push(line.replace(/^data:\s*/, ''));
71
+ }
72
+ else if (line.startsWith('event:')) {
73
+ eventName = line.replace(/^event:\s*/, '');
74
+ }
75
+ else if (line.startsWith('id:')) {
76
+ lastEventId = line.replace(/^id:\s*/, '');
77
+ }
78
+ else if (line.startsWith('retry:')) {
79
+ const parsed = Number.parseInt(line.replace(/^retry:\s*/, ''), 10);
80
+ if (!Number.isNaN(parsed)) {
81
+ retryDelay = parsed;
82
+ }
83
+ }
84
+ }
85
+ let data;
86
+ let parsedJson = false;
87
+ if (dataLines.length) {
88
+ const rawData = dataLines.join('\n');
89
+ try {
90
+ data = JSON.parse(rawData);
91
+ parsedJson = true;
92
+ }
93
+ catch {
94
+ data = rawData;
95
+ }
96
+ }
97
+ if (parsedJson) {
98
+ if (responseValidator) {
99
+ await responseValidator(data);
100
+ }
101
+ if (responseTransformer) {
102
+ data = await responseTransformer(data);
103
+ }
104
+ }
105
+ onSseEvent?.({
106
+ data,
107
+ event: eventName,
108
+ id: lastEventId,
109
+ retry: retryDelay,
110
+ });
111
+ if (dataLines.length) {
112
+ yield data;
113
+ }
114
+ }
115
+ }
116
+ }
117
+ finally {
118
+ signal.removeEventListener('abort', abortHandler);
119
+ reader.releaseLock();
120
+ }
121
+ break; // exit loop on normal completion
122
+ }
123
+ catch (error) {
124
+ // connection failed or aborted; retry after delay
125
+ onSseError?.(error);
126
+ if (sseMaxRetryAttempts !== undefined &&
127
+ attempt >= sseMaxRetryAttempts) {
128
+ break; // stop after firing error
129
+ }
130
+ // exponential backoff: double retry each attempt, cap at 30s
131
+ const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 30000);
132
+ await sleep(backoff);
133
+ }
134
+ }
135
+ };
136
+ const stream = createStream();
137
+ return { stream };
138
+ };
139
+ exports.createSseClient = createSseClient;
@@ -0,0 +1,78 @@
1
+ import type { Auth, AuthToken } from './auth.gen';
2
+ import type { BodySerializer, QuerySerializer, QuerySerializerOptions } from './bodySerializer.gen';
3
+ export type HttpMethod = 'connect' | 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace';
4
+ export type Client<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never, SseFn = never> = {
5
+ /**
6
+ * Returns the final request URL.
7
+ */
8
+ buildUrl: BuildUrlFn;
9
+ getConfig: () => Config;
10
+ request: RequestFn;
11
+ setConfig: (config: Config) => Config;
12
+ } & {
13
+ [K in HttpMethod]: MethodFn;
14
+ } & ([SseFn] extends [never] ? {
15
+ sse?: never;
16
+ } : {
17
+ sse: {
18
+ [K in HttpMethod]: SseFn;
19
+ };
20
+ });
21
+ export interface Config {
22
+ /**
23
+ * Auth token or a function returning auth token. The resolved value will be
24
+ * added to the request payload as defined by its `security` array.
25
+ */
26
+ auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
27
+ /**
28
+ * A function for serializing request body parameter. By default,
29
+ * {@link JSON.stringify()} will be used.
30
+ */
31
+ bodySerializer?: BodySerializer | null;
32
+ /**
33
+ * An object containing any HTTP headers that you want to pre-populate your
34
+ * `Headers` object with.
35
+ *
36
+ * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
37
+ */
38
+ headers?: RequestInit['headers'] | Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>;
39
+ /**
40
+ * The request method.
41
+ *
42
+ * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
43
+ */
44
+ method?: Uppercase<HttpMethod>;
45
+ /**
46
+ * A function for serializing request query parameters. By default, arrays
47
+ * will be exploded in form style, objects will be exploded in deepObject
48
+ * style, and reserved characters are percent-encoded.
49
+ *
50
+ * This method will have no effect if the native `paramsSerializer()` Axios
51
+ * API function is used.
52
+ *
53
+ * {@link https://swagger.io/docs/specification/serialization/#query View examples}
54
+ */
55
+ querySerializer?: QuerySerializer | QuerySerializerOptions;
56
+ /**
57
+ * A function validating request data. This is useful if you want to ensure
58
+ * the request conforms to the desired shape, so it can be safely sent to
59
+ * the server.
60
+ */
61
+ requestValidator?: (data: unknown) => Promise<unknown>;
62
+ /**
63
+ * A function transforming response data before it's returned. This is useful
64
+ * for post-processing data, e.g. converting ISO strings into Date objects.
65
+ */
66
+ responseTransformer?: (data: unknown) => Promise<unknown>;
67
+ /**
68
+ * A function validating response data. This is useful if you want to ensure
69
+ * the response conforms to the desired shape, so it can be safely passed to
70
+ * the transformers and returned to the user.
71
+ */
72
+ responseValidator?: (data: unknown) => Promise<unknown>;
73
+ }
74
+ type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never] ? true : [T] extends [never | undefined] ? [undefined] extends [T] ? false : true : false;
75
+ export type OmitNever<T extends Record<string, unknown>> = {
76
+ [K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true ? never : K]: T[K];
77
+ };
78
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file is auto-generated by @hey-api/openapi-ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,19 @@
1
+ import type { BodySerializer, QuerySerializer } from './bodySerializer.gen';
2
+ export interface PathSerializer {
3
+ path: Record<string, unknown>;
4
+ url: string;
5
+ }
6
+ export declare const PATH_PARAM_RE: RegExp;
7
+ export declare const defaultPathSerializer: ({ path, url: _url }: PathSerializer) => string;
8
+ export declare const getUrl: ({ baseUrl, path, query, querySerializer, url: _url, }: {
9
+ baseUrl?: string;
10
+ path?: Record<string, unknown>;
11
+ query?: Record<string, unknown>;
12
+ querySerializer: QuerySerializer;
13
+ url: string;
14
+ }) => string;
15
+ export declare function getValidRequestBody(options: {
16
+ body?: unknown;
17
+ bodySerializer?: BodySerializer | null;
18
+ serializedBody?: unknown;
19
+ }): unknown;
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ // This file is auto-generated by @hey-api/openapi-ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.getUrl = exports.defaultPathSerializer = exports.PATH_PARAM_RE = void 0;
5
+ exports.getValidRequestBody = getValidRequestBody;
6
+ const pathSerializer_gen_1 = require("./pathSerializer.gen");
7
+ exports.PATH_PARAM_RE = /\{[^{}]+\}/g;
8
+ const defaultPathSerializer = ({ path, url: _url }) => {
9
+ let url = _url;
10
+ const matches = _url.match(exports.PATH_PARAM_RE);
11
+ if (matches) {
12
+ for (const match of matches) {
13
+ let explode = false;
14
+ let name = match.substring(1, match.length - 1);
15
+ let style = 'simple';
16
+ if (name.endsWith('*')) {
17
+ explode = true;
18
+ name = name.substring(0, name.length - 1);
19
+ }
20
+ if (name.startsWith('.')) {
21
+ name = name.substring(1);
22
+ style = 'label';
23
+ }
24
+ else if (name.startsWith(';')) {
25
+ name = name.substring(1);
26
+ style = 'matrix';
27
+ }
28
+ const value = path[name];
29
+ if (value === undefined || value === null) {
30
+ continue;
31
+ }
32
+ if (Array.isArray(value)) {
33
+ url = url.replace(match, (0, pathSerializer_gen_1.serializeArrayParam)({ explode, name, style, value }));
34
+ continue;
35
+ }
36
+ if (typeof value === 'object') {
37
+ url = url.replace(match, (0, pathSerializer_gen_1.serializeObjectParam)({
38
+ explode,
39
+ name,
40
+ style,
41
+ value: value,
42
+ valueOnly: true,
43
+ }));
44
+ continue;
45
+ }
46
+ if (style === 'matrix') {
47
+ url = url.replace(match, `;${(0, pathSerializer_gen_1.serializePrimitiveParam)({
48
+ name,
49
+ value: value,
50
+ })}`);
51
+ continue;
52
+ }
53
+ const replaceValue = encodeURIComponent(style === 'label' ? `.${value}` : value);
54
+ url = url.replace(match, replaceValue);
55
+ }
56
+ }
57
+ return url;
58
+ };
59
+ exports.defaultPathSerializer = defaultPathSerializer;
60
+ const getUrl = ({ baseUrl, path, query, querySerializer, url: _url, }) => {
61
+ const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
62
+ let url = (baseUrl ?? '') + pathUrl;
63
+ if (path) {
64
+ url = (0, exports.defaultPathSerializer)({ path, url });
65
+ }
66
+ let search = query ? querySerializer(query) : '';
67
+ if (search.startsWith('?')) {
68
+ search = search.substring(1);
69
+ }
70
+ if (search) {
71
+ url += `?${search}`;
72
+ }
73
+ return url;
74
+ };
75
+ exports.getUrl = getUrl;
76
+ function getValidRequestBody(options) {
77
+ const hasBody = options.body !== undefined;
78
+ const isSerializedBody = hasBody && options.bodySerializer;
79
+ if (isSerializedBody) {
80
+ if ('serializedBody' in options) {
81
+ const hasSerializedBody = options.serializedBody !== undefined && options.serializedBody !== '';
82
+ return hasSerializedBody ? options.serializedBody : null;
83
+ }
84
+ // not all clients implement a serializedBody property (i.e. client-axios)
85
+ return options.body !== '' ? options.body : null;
86
+ }
87
+ // plain/text body
88
+ if (hasBody) {
89
+ return options.body;
90
+ }
91
+ // no body was provided
92
+ return undefined;
93
+ }
@@ -0,0 +1,2 @@
1
+ export type * from './types.gen';
2
+ export * from './sdk.gen';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ // This file is auto-generated by @hey-api/openapi-ts
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ __exportStar(require("./sdk.gen"), exports);