@touhidrahman/auditlog-sdk 1.0.4 → 1.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/index.cjs.js CHANGED
@@ -1,250 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  // This file is auto-generated by @hey-api/openapi-ts
4
- const serializeFormDataPair = (data, key, value) => {
5
- if (typeof value === 'string' || value instanceof Blob) {
6
- data.append(key, value);
7
- } else if (value instanceof Date) {
8
- data.append(key, value.toISOString());
9
- } else {
10
- data.append(key, JSON.stringify(value));
11
- }
12
- };
13
- const serializeUrlSearchParamsPair = (data, key, value) => {
14
- if (typeof value === 'string') {
15
- data.append(key, value);
16
- } else {
17
- data.append(key, JSON.stringify(value));
18
- }
19
- };
20
- const formDataBodySerializer = {
21
- bodySerializer: body => {
22
- const data = new FormData();
23
- Object.entries(body).forEach(([key, value]) => {
24
- if (value === undefined || value === null) {
25
- return;
26
- }
27
- if (Array.isArray(value)) {
28
- value.forEach(v => serializeFormDataPair(data, key, v));
29
- } else {
30
- serializeFormDataPair(data, key, value);
31
- }
32
- });
33
- return data;
34
- }
35
- };
36
4
  const jsonBodySerializer = {
37
5
  bodySerializer: body => JSON.stringify(body, (_key, value) => typeof value === 'bigint' ? value.toString() : value)
38
6
  };
39
- const urlSearchParamsBodySerializer = {
40
- bodySerializer: body => {
41
- const data = new URLSearchParams();
42
- Object.entries(body).forEach(([key, value]) => {
43
- if (value === undefined || value === null) {
44
- return;
45
- }
46
- if (Array.isArray(value)) {
47
- value.forEach(v => serializeUrlSearchParamsPair(data, key, v));
48
- } else {
49
- serializeUrlSearchParamsPair(data, key, value);
50
- }
51
- });
52
- return data.toString();
53
- }
54
- };
55
-
56
- // This file is auto-generated by @hey-api/openapi-ts
57
- const extraPrefixesMap = {
58
- $body_: 'body',
59
- $headers_: 'headers',
60
- $path_: 'path',
61
- $query_: 'query'
62
- };
63
- const extraPrefixes = Object.entries(extraPrefixesMap);
64
- function buildKeyMap(fields, map) {
65
- if (!map) {
66
- map = new Map();
67
- }
68
- for (const config of fields) {
69
- if ('in' in config) {
70
- if (config.key) {
71
- map.set(config.key, {
72
- in: config.in,
73
- map: config.map
74
- });
75
- }
76
- } else if ('key' in config) {
77
- map.set(config.key, {
78
- map: config.map
79
- });
80
- } else if (config.args) {
81
- buildKeyMap(config.args, map);
82
- }
83
- }
84
- return map;
85
- }
86
- function stripEmptySlots(params) {
87
- for (const [slot, value] of Object.entries(params)) {
88
- if (slot === 'body') continue;
89
- if (value && typeof value === 'object' && !Array.isArray(value) && !Object.keys(value).length) {
90
- delete params[slot];
91
- }
92
- }
93
- }
94
- function buildClientParams(args, fields) {
95
- const params = {
96
- headers: Object.create(null),
97
- path: Object.create(null),
98
- query: Object.create(null)
99
- };
100
- const map = buildKeyMap(fields);
101
- function writeSlot(slot, key, value) {
102
- let record = params[slot];
103
- if (record === undefined) {
104
- record = Object.create(null);
105
- params[slot] = record;
106
- }
107
- record[key] = value;
108
- }
109
- let config;
110
- for (const [index, arg] of args.entries()) {
111
- if (fields[index]) {
112
- config = fields[index];
113
- }
114
- if (!config) {
115
- continue;
116
- }
117
- if ('in' in config) {
118
- if (config.key) {
119
- const field = map.get(config.key);
120
- const name = field.map || config.key;
121
- if (field.in) {
122
- writeSlot(field.in, name, arg);
123
- }
124
- } else {
125
- params.body = arg;
126
- }
127
- } else {
128
- for (const [key, value] of Object.entries(arg ?? {})) {
129
- const field = map.get(key);
130
- if (field) {
131
- if (field.in) {
132
- const name = field.map || key;
133
- writeSlot(field.in, name, value);
134
- } else {
135
- params[field.map] = value;
136
- }
137
- } else {
138
- const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
139
- if (extra) {
140
- const [prefix, slot] = extra;
141
- writeSlot(slot, key.slice(prefix.length), value);
142
- } else if ('allowExtra' in config && config.allowExtra) {
143
- for (const [slot, allowed] of Object.entries(config.allowExtra)) {
144
- if (allowed) {
145
- writeSlot(slot, key, value);
146
- break;
147
- }
148
- }
149
- }
150
- }
151
- }
152
- }
153
- }
154
- stripEmptySlots(params);
155
- return params;
156
- }
157
-
158
- // This file is auto-generated by @hey-api/openapi-ts
159
- /**
160
- * Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
161
- */
162
- const queryKeyJsonReplacer = (_key, value) => {
163
- if (value === undefined || typeof value === 'function' || typeof value === 'symbol') {
164
- return undefined;
165
- }
166
- if (typeof value === 'bigint') {
167
- return value.toString();
168
- }
169
- if (value instanceof Date) {
170
- return value.toISOString();
171
- }
172
- return value;
173
- };
174
- /**
175
- * Safely stringifies a value and parses it back into a JsonValue.
176
- */
177
- const stringifyToJsonValue = input => {
178
- try {
179
- const json = JSON.stringify(input, queryKeyJsonReplacer);
180
- if (json === undefined) {
181
- return undefined;
182
- }
183
- return JSON.parse(json);
184
- } catch {
185
- return undefined;
186
- }
187
- };
188
- /**
189
- * Detects plain objects (including objects with a null prototype).
190
- */
191
- const isPlainObject = value => {
192
- if (value === null || typeof value !== 'object') {
193
- return false;
194
- }
195
- const prototype = Object.getPrototypeOf(value);
196
- return prototype === Object.prototype || prototype === null;
197
- };
198
- /**
199
- * Turns URLSearchParams into a sorted JSON object for deterministic keys.
200
- */
201
- const serializeSearchParams = params => {
202
- const entries = Array.from(params.entries()).sort(([a], [b]) => a.localeCompare(b));
203
- const result = {};
204
- for (const [key, value] of entries) {
205
- const existing = result[key];
206
- if (existing === undefined) {
207
- result[key] = value;
208
- continue;
209
- }
210
- if (Array.isArray(existing)) {
211
- existing.push(value);
212
- } else {
213
- result[key] = [existing, value];
214
- }
215
- }
216
- return result;
217
- };
218
- /**
219
- * Normalizes any accepted value into a JSON-friendly shape for query keys.
220
- */
221
- const serializeQueryKeyValue = value => {
222
- if (value === null) {
223
- return null;
224
- }
225
- if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
226
- return value;
227
- }
228
- if (value === undefined || typeof value === 'function' || typeof value === 'symbol') {
229
- return undefined;
230
- }
231
- if (typeof value === 'bigint') {
232
- return value.toString();
233
- }
234
- if (value instanceof Date) {
235
- return value.toISOString();
236
- }
237
- if (Array.isArray(value)) {
238
- return stringifyToJsonValue(value);
239
- }
240
- if (typeof URLSearchParams !== 'undefined' && value instanceof URLSearchParams) {
241
- return serializeSearchParams(value);
242
- }
243
- if (isPlainObject(value)) {
244
- return stringifyToJsonValue(value);
245
- }
246
- return undefined;
247
- };
248
7
 
249
8
  // This file is auto-generated by @hey-api/openapi-ts
250
9
  function createSseClient({
@@ -1317,14 +1076,11 @@ const deleteLogsEntityEntityId = options => (options.client ?? client).delete({
1317
1076
  ...options
1318
1077
  });
1319
1078
 
1320
- exports.buildClientParams = buildClientParams;
1321
- exports.createClient = createClient;
1322
- exports.createConfig = createConfig;
1079
+ exports.client = client;
1323
1080
  exports.deleteLogsEntityEntityId = deleteLogsEntityEntityId;
1324
1081
  exports.deleteLogsId = deleteLogsId;
1325
1082
  exports.deleteProjectsByProjectId = deleteProjectsByProjectId;
1326
1083
  exports.deleteSecretKeysById = deleteSecretKeysById;
1327
- exports.formDataBodySerializer = formDataBodySerializer;
1328
1084
  exports.get = get;
1329
1085
  exports.getLogs = getLogs;
1330
1086
  exports.getLogsExportCsv = getLogsExportCsv;
@@ -1333,8 +1089,6 @@ exports.getProjects = getProjects;
1333
1089
  exports.getProjectsByProjectId = getProjectsByProjectId;
1334
1090
  exports.getSecretKeys = getSecretKeys;
1335
1091
  exports.getSecretKeysById = getSecretKeysById;
1336
- exports.jsonBodySerializer = jsonBodySerializer;
1337
- exports.mergeHeaders = mergeHeaders;
1338
1092
  exports.postAdminLogin = postAdminLogin;
1339
1093
  exports.postAdminNewToken = postAdminNewToken;
1340
1094
  exports.postLogs = postLogs;
@@ -1342,5 +1096,3 @@ exports.postProjects = postProjects;
1342
1096
  exports.postSecretKeys = postSecretKeys;
1343
1097
  exports.putProjectsByProjectId = putProjectsByProjectId;
1344
1098
  exports.putProjectsByProjectIdChangeId = putProjectsByProjectIdChangeId;
1345
- exports.serializeQueryKeyValue = serializeQueryKeyValue;
1346
- exports.urlSearchParamsBodySerializer = urlSearchParamsBodySerializer;
package/index.esm.js CHANGED
@@ -1,248 +1,7 @@
1
1
  // This file is auto-generated by @hey-api/openapi-ts
2
- const serializeFormDataPair = (data, key, value) => {
3
- if (typeof value === 'string' || value instanceof Blob) {
4
- data.append(key, value);
5
- } else if (value instanceof Date) {
6
- data.append(key, value.toISOString());
7
- } else {
8
- data.append(key, JSON.stringify(value));
9
- }
10
- };
11
- const serializeUrlSearchParamsPair = (data, key, value) => {
12
- if (typeof value === 'string') {
13
- data.append(key, value);
14
- } else {
15
- data.append(key, JSON.stringify(value));
16
- }
17
- };
18
- const formDataBodySerializer = {
19
- bodySerializer: body => {
20
- const data = new FormData();
21
- Object.entries(body).forEach(([key, value]) => {
22
- if (value === undefined || value === null) {
23
- return;
24
- }
25
- if (Array.isArray(value)) {
26
- value.forEach(v => serializeFormDataPair(data, key, v));
27
- } else {
28
- serializeFormDataPair(data, key, value);
29
- }
30
- });
31
- return data;
32
- }
33
- };
34
2
  const jsonBodySerializer = {
35
3
  bodySerializer: body => JSON.stringify(body, (_key, value) => typeof value === 'bigint' ? value.toString() : value)
36
4
  };
37
- const urlSearchParamsBodySerializer = {
38
- bodySerializer: body => {
39
- const data = new URLSearchParams();
40
- Object.entries(body).forEach(([key, value]) => {
41
- if (value === undefined || value === null) {
42
- return;
43
- }
44
- if (Array.isArray(value)) {
45
- value.forEach(v => serializeUrlSearchParamsPair(data, key, v));
46
- } else {
47
- serializeUrlSearchParamsPair(data, key, value);
48
- }
49
- });
50
- return data.toString();
51
- }
52
- };
53
-
54
- // This file is auto-generated by @hey-api/openapi-ts
55
- const extraPrefixesMap = {
56
- $body_: 'body',
57
- $headers_: 'headers',
58
- $path_: 'path',
59
- $query_: 'query'
60
- };
61
- const extraPrefixes = Object.entries(extraPrefixesMap);
62
- function buildKeyMap(fields, map) {
63
- if (!map) {
64
- map = new Map();
65
- }
66
- for (const config of fields) {
67
- if ('in' in config) {
68
- if (config.key) {
69
- map.set(config.key, {
70
- in: config.in,
71
- map: config.map
72
- });
73
- }
74
- } else if ('key' in config) {
75
- map.set(config.key, {
76
- map: config.map
77
- });
78
- } else if (config.args) {
79
- buildKeyMap(config.args, map);
80
- }
81
- }
82
- return map;
83
- }
84
- function stripEmptySlots(params) {
85
- for (const [slot, value] of Object.entries(params)) {
86
- if (slot === 'body') continue;
87
- if (value && typeof value === 'object' && !Array.isArray(value) && !Object.keys(value).length) {
88
- delete params[slot];
89
- }
90
- }
91
- }
92
- function buildClientParams(args, fields) {
93
- const params = {
94
- headers: Object.create(null),
95
- path: Object.create(null),
96
- query: Object.create(null)
97
- };
98
- const map = buildKeyMap(fields);
99
- function writeSlot(slot, key, value) {
100
- let record = params[slot];
101
- if (record === undefined) {
102
- record = Object.create(null);
103
- params[slot] = record;
104
- }
105
- record[key] = value;
106
- }
107
- let config;
108
- for (const [index, arg] of args.entries()) {
109
- if (fields[index]) {
110
- config = fields[index];
111
- }
112
- if (!config) {
113
- continue;
114
- }
115
- if ('in' in config) {
116
- if (config.key) {
117
- const field = map.get(config.key);
118
- const name = field.map || config.key;
119
- if (field.in) {
120
- writeSlot(field.in, name, arg);
121
- }
122
- } else {
123
- params.body = arg;
124
- }
125
- } else {
126
- for (const [key, value] of Object.entries(arg ?? {})) {
127
- const field = map.get(key);
128
- if (field) {
129
- if (field.in) {
130
- const name = field.map || key;
131
- writeSlot(field.in, name, value);
132
- } else {
133
- params[field.map] = value;
134
- }
135
- } else {
136
- const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
137
- if (extra) {
138
- const [prefix, slot] = extra;
139
- writeSlot(slot, key.slice(prefix.length), value);
140
- } else if ('allowExtra' in config && config.allowExtra) {
141
- for (const [slot, allowed] of Object.entries(config.allowExtra)) {
142
- if (allowed) {
143
- writeSlot(slot, key, value);
144
- break;
145
- }
146
- }
147
- }
148
- }
149
- }
150
- }
151
- }
152
- stripEmptySlots(params);
153
- return params;
154
- }
155
-
156
- // This file is auto-generated by @hey-api/openapi-ts
157
- /**
158
- * Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
159
- */
160
- const queryKeyJsonReplacer = (_key, value) => {
161
- if (value === undefined || typeof value === 'function' || typeof value === 'symbol') {
162
- return undefined;
163
- }
164
- if (typeof value === 'bigint') {
165
- return value.toString();
166
- }
167
- if (value instanceof Date) {
168
- return value.toISOString();
169
- }
170
- return value;
171
- };
172
- /**
173
- * Safely stringifies a value and parses it back into a JsonValue.
174
- */
175
- const stringifyToJsonValue = input => {
176
- try {
177
- const json = JSON.stringify(input, queryKeyJsonReplacer);
178
- if (json === undefined) {
179
- return undefined;
180
- }
181
- return JSON.parse(json);
182
- } catch {
183
- return undefined;
184
- }
185
- };
186
- /**
187
- * Detects plain objects (including objects with a null prototype).
188
- */
189
- const isPlainObject = value => {
190
- if (value === null || typeof value !== 'object') {
191
- return false;
192
- }
193
- const prototype = Object.getPrototypeOf(value);
194
- return prototype === Object.prototype || prototype === null;
195
- };
196
- /**
197
- * Turns URLSearchParams into a sorted JSON object for deterministic keys.
198
- */
199
- const serializeSearchParams = params => {
200
- const entries = Array.from(params.entries()).sort(([a], [b]) => a.localeCompare(b));
201
- const result = {};
202
- for (const [key, value] of entries) {
203
- const existing = result[key];
204
- if (existing === undefined) {
205
- result[key] = value;
206
- continue;
207
- }
208
- if (Array.isArray(existing)) {
209
- existing.push(value);
210
- } else {
211
- result[key] = [existing, value];
212
- }
213
- }
214
- return result;
215
- };
216
- /**
217
- * Normalizes any accepted value into a JSON-friendly shape for query keys.
218
- */
219
- const serializeQueryKeyValue = value => {
220
- if (value === null) {
221
- return null;
222
- }
223
- if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
224
- return value;
225
- }
226
- if (value === undefined || typeof value === 'function' || typeof value === 'symbol') {
227
- return undefined;
228
- }
229
- if (typeof value === 'bigint') {
230
- return value.toString();
231
- }
232
- if (value instanceof Date) {
233
- return value.toISOString();
234
- }
235
- if (Array.isArray(value)) {
236
- return stringifyToJsonValue(value);
237
- }
238
- if (typeof URLSearchParams !== 'undefined' && value instanceof URLSearchParams) {
239
- return serializeSearchParams(value);
240
- }
241
- if (isPlainObject(value)) {
242
- return stringifyToJsonValue(value);
243
- }
244
- return undefined;
245
- };
246
5
 
247
6
  // This file is auto-generated by @hey-api/openapi-ts
248
7
  function createSseClient({
@@ -1315,4 +1074,4 @@ const deleteLogsEntityEntityId = options => (options.client ?? client).delete({
1315
1074
  ...options
1316
1075
  });
1317
1076
 
1318
- export { buildClientParams, createClient, createConfig, deleteLogsEntityEntityId, deleteLogsId, deleteProjectsByProjectId, deleteSecretKeysById, formDataBodySerializer, get, getLogs, getLogsExportCsv, getLogsId, getProjects, getProjectsByProjectId, getSecretKeys, getSecretKeysById, jsonBodySerializer, mergeHeaders, postAdminLogin, postAdminNewToken, postLogs, postProjects, postSecretKeys, putProjectsByProjectId, putProjectsByProjectIdChangeId, serializeQueryKeyValue, urlSearchParamsBodySerializer };
1077
+ export { client, deleteLogsEntityEntityId, deleteLogsId, deleteProjectsByProjectId, deleteSecretKeysById, get, getLogs, getLogsExportCsv, getLogsId, getProjects, getProjectsByProjectId, getSecretKeys, getSecretKeysById, postAdminLogin, postAdminNewToken, postLogs, postProjects, postSecretKeys, putProjectsByProjectId, putProjectsByProjectIdChangeId };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@touhidrahman/auditlog-sdk",
3
- "version": "1.0.4",
3
+ "version": "1.1.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -0,0 +1,2 @@
1
+ import type { Client, Config } from './types.gen';
2
+ export declare const createClient: (config?: Config) => Client;
@@ -0,0 +1,10 @@
1
+ export type { Auth } from '../core/auth.gen';
2
+ export type { QuerySerializerOptions } from '../core/bodySerializer.gen';
3
+ export { formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer, } from '../core/bodySerializer.gen';
4
+ export { buildClientParams } from '../core/params.gen';
5
+ export { serializeQueryKeyValue } from '../core/queryKeySerializer.gen';
6
+ export type { ServerSentEventsResult } from '../core/serverSentEvents.gen';
7
+ export type { ClientMeta } from '../core/types.gen';
8
+ export { createClient } from './client.gen';
9
+ export type { Client, ClientOptions, Config, CreateClientConfig, Options, RequestOptions, RequestResult, ResolvedRequestOptions, ResponseStyle, TDataShape, } from './types.gen';
10
+ export { createConfig, mergeHeaders } from './utils.gen';
@@ -0,0 +1,120 @@
1
+ import type { Auth } from '../core/auth.gen';
2
+ import type { ServerSentEventsOptions, ServerSentEventsResult } from '../core/serverSentEvents.gen';
3
+ import type { Client as CoreClient, Config as CoreConfig } from '../core/types.gen';
4
+ import type { Middleware } from './utils.gen';
5
+ export type ResponseStyle = 'data' | 'fields';
6
+ export interface Config<T extends ClientOptions = ClientOptions> extends Omit<RequestInit, 'body' | 'headers' | 'method'>, CoreConfig {
7
+ /**
8
+ * Base URL for all requests made by this client.
9
+ */
10
+ baseUrl?: T['baseUrl'];
11
+ /**
12
+ * Fetch API implementation. You can use this option to provide a custom
13
+ * fetch instance.
14
+ *
15
+ * @default globalThis.fetch
16
+ */
17
+ fetch?: typeof fetch;
18
+ /**
19
+ * Please don't use the Fetch client for Next.js applications. The `next`
20
+ * options won't have any effect.
21
+ *
22
+ * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
23
+ */
24
+ next?: never;
25
+ /**
26
+ * Return the response data parsed in a specified format. By default, `auto`
27
+ * will infer the appropriate method from the `Content-Type` response header.
28
+ * You can override this behavior with any of the {@link Body} methods.
29
+ * Select `stream` if you don't want to parse response data at all.
30
+ *
31
+ * @default 'auto'
32
+ */
33
+ parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text';
34
+ /**
35
+ * Should we return only data or multiple fields (data, error, response, etc.)?
36
+ *
37
+ * @default 'fields'
38
+ */
39
+ responseStyle?: ResponseStyle;
40
+ /**
41
+ * Throw an error instead of returning it in the response?
42
+ *
43
+ * @default false
44
+ */
45
+ throwOnError?: T['throwOnError'];
46
+ }
47
+ export interface RequestOptions<TData = unknown, TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{
48
+ responseStyle: TResponseStyle;
49
+ throwOnError: ThrowOnError;
50
+ }>, Pick<ServerSentEventsOptions<TData>, 'onRequest' | 'onSseError' | 'onSseEvent' | 'sseDefaultRetryDelay' | 'sseMaxRetryAttempts' | 'sseMaxRetryDelay'> {
51
+ /**
52
+ * Any body that you want to add to your request.
53
+ *
54
+ * {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
55
+ */
56
+ body?: unknown;
57
+ path?: Record<string, unknown>;
58
+ query?: Record<string, unknown>;
59
+ /**
60
+ * Security mechanism(s) to use for the request.
61
+ */
62
+ security?: ReadonlyArray<Auth>;
63
+ url: Url;
64
+ }
65
+ export interface ResolvedRequestOptions<TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
66
+ headers: Headers;
67
+ serializedBody?: string;
68
+ }
69
+ export type RequestResult<TData = unknown, TError = unknown, ThrowOnError extends boolean = boolean, TResponseStyle extends ResponseStyle = 'fields'> = ThrowOnError extends true ? Promise<TResponseStyle extends 'data' ? TData extends Record<string, unknown> ? TData[keyof TData] : TData : {
70
+ data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
71
+ request: Request;
72
+ response: Response;
73
+ }> : Promise<TResponseStyle extends 'data' ? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined : ({
74
+ data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
75
+ error: undefined;
76
+ } | {
77
+ data: undefined;
78
+ error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
79
+ }) & {
80
+ /** request may be undefined, because error may be from building the request object itself */
81
+ request?: Request;
82
+ /** response may be undefined, because error may be from building the request object itself or from a network error */
83
+ response?: Response;
84
+ }>;
85
+ export interface ClientOptions {
86
+ baseUrl?: string;
87
+ responseStyle?: ResponseStyle;
88
+ throwOnError?: boolean;
89
+ }
90
+ type MethodFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
91
+ type SseFn = <TData = unknown, _TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<never, TResponseStyle, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData>>;
92
+ type RequestFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> & Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
93
+ type BuildUrlFn = <TData extends {
94
+ body?: unknown;
95
+ path?: Record<string, unknown>;
96
+ query?: Record<string, unknown>;
97
+ url: string;
98
+ }>(options: TData & Options<TData>) => string;
99
+ export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
100
+ interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
101
+ };
102
+ /**
103
+ * The `createClientConfig()` function will be called on client initialization
104
+ * and the returned object will become the client's initial configuration.
105
+ *
106
+ * You may want to initialize your client this way instead of calling
107
+ * `setConfig()`. This is useful for example if you're using Next.js
108
+ * to ensure your client always has the correct values.
109
+ */
110
+ export type CreateClientConfig<T extends ClientOptions = ClientOptions> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
111
+ export interface TDataShape {
112
+ body?: unknown;
113
+ headers?: unknown;
114
+ path?: unknown;
115
+ query?: unknown;
116
+ url: string;
117
+ }
118
+ type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
119
+ export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown, TResponseStyle extends ResponseStyle = 'fields'> = OmitKeys<RequestOptions<TResponse, TResponseStyle, ThrowOnError>, 'body' | 'path' | 'query' | 'url'> & ([TData] extends [never] ? unknown : Omit<TData, 'url'>);
120
+ export {};
@@ -1,2 +1,12 @@
1
- import type { Client, Config } from './types.gen';
2
- export declare const createClient: (config?: Config) => Client;
1
+ import { type Client, type ClientOptions, type Config } from './client';
2
+ import type { ClientOptions as ClientOptions2 } from './types.gen';
3
+ /**
4
+ * The `createClientConfig()` function will be called on client initialization
5
+ * and the returned object will become the client's initial configuration.
6
+ *
7
+ * You may want to initialize your client this way instead of calling
8
+ * `setConfig()`. This is useful for example if you're using Next.js
9
+ * to ensure your client always has the correct values.
10
+ */
11
+ export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
12
+ export declare const client: Client;