@civitai/client 0.1.1-beta.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 (48) hide show
  1. package/README.md +0 -0
  2. package/dist/client/CivitaiClient.d.ts +17 -0
  3. package/dist/client/CivitaiClient.js +24 -0
  4. package/dist/client/RequestsClient.d.ts +0 -0
  5. package/dist/client/RequestsClient.js +58 -0
  6. package/dist/generated/GeneratedClient.d.ts +20 -0
  7. package/dist/generated/GeneratedClient.js +38 -0
  8. package/dist/generated/core/ApiError.d.ts +10 -0
  9. package/dist/generated/core/ApiError.js +15 -0
  10. package/dist/generated/core/ApiRequestOptions.d.ts +13 -0
  11. package/dist/generated/core/ApiRequestOptions.js +2 -0
  12. package/dist/generated/core/ApiResult.d.ts +7 -0
  13. package/dist/generated/core/ApiResult.js +2 -0
  14. package/dist/generated/core/AxiosHttpRequest.d.ts +14 -0
  15. package/dist/generated/core/AxiosHttpRequest.js +20 -0
  16. package/dist/generated/core/BaseHttpRequest.d.ts +8 -0
  17. package/dist/generated/core/BaseHttpRequest.js +9 -0
  18. package/dist/generated/core/CancelablePromise.d.ts +37 -0
  19. package/dist/generated/core/CancelablePromise.js +93 -0
  20. package/dist/generated/core/FetchHttpRequest.d.ts +14 -0
  21. package/dist/generated/core/FetchHttpRequest.js +20 -0
  22. package/dist/generated/core/OpenAPI.d.ts +27 -0
  23. package/dist/generated/core/OpenAPI.js +33 -0
  24. package/dist/generated/core/request.d.ts +49 -0
  25. package/dist/generated/core/request.js +277 -0
  26. package/dist/generated/enums.gen.d.ts +93 -0
  27. package/dist/generated/enums.gen.js +97 -0
  28. package/dist/generated/index.d.ts +9 -0
  29. package/dist/generated/index.js +20 -0
  30. package/dist/generated/schemas.gen.d.ts +2243 -0
  31. package/dist/generated/schemas.gen.js +2244 -0
  32. package/dist/generated/services.gen.d.ts +242 -0
  33. package/dist/generated/services.gen.js +469 -0
  34. package/dist/generated/types.gen.d.ts +1931 -0
  35. package/dist/generated/types.gen.js +3 -0
  36. package/dist/index.d.ts +3 -0
  37. package/dist/index.js +6 -0
  38. package/dist/utils/Air.d.ts +19 -0
  39. package/dist/utils/Air.js +18 -0
  40. package/dist/utils/CivitaiClientError.d.ts +0 -0
  41. package/dist/utils/CivitaiClientError.js +4 -0
  42. package/dist/utils/TimeSpan.d.ts +45 -0
  43. package/dist/utils/TimeSpan.js +101 -0
  44. package/dist/utils/createClient.d.ts +1 -0
  45. package/dist/utils/createClient.js +119 -0
  46. package/dist/utils/index.d.ts +2 -0
  47. package/dist/utils/index.js +5 -0
  48. package/package.json +48 -0
package/README.md ADDED
Binary file
@@ -0,0 +1,17 @@
1
+ import { BaseHttpRequest } from '../generated/core/BaseHttpRequest';
2
+ import { Interceptors, OpenAPIConfig } from '../generated/core/OpenAPI';
3
+ import { GeneratedClient } from '../generated/GeneratedClient';
4
+ type ClientConfig = {
5
+ env?: 'dev' | 'prod';
6
+ base?: string;
7
+ auth: string;
8
+ interceptors?: {
9
+ request?: Interceptors<RequestInit>;
10
+ response?: Interceptors<Response>;
11
+ };
12
+ };
13
+ type HttpRequestConstructor = new (config: OpenAPIConfig) => BaseHttpRequest;
14
+ export declare class CivitaiClient extends GeneratedClient {
15
+ constructor(config: ClientConfig, HttpRequest?: HttpRequestConstructor);
16
+ }
17
+ export {};
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CivitaiClient = void 0;
4
+ const OpenAPI_1 = require("../generated/core/OpenAPI");
5
+ const GeneratedClient_1 = require("../generated/GeneratedClient");
6
+ class CivitaiClient extends GeneratedClient_1.GeneratedClient {
7
+ constructor(config, HttpRequest) {
8
+ var _a, _b, _c, _d;
9
+ super({
10
+ BASE: config.env === 'dev'
11
+ ? 'https://orchestration-dev.civitai.com'
12
+ : 'https://orchestration-stage.civitai.com', // TODO: Switch to orchestration.civitai.com once prod is back up and running
13
+ HEADERS: { Authorization: `Bearer ${config.auth}` },
14
+ interceptors: {
15
+ request: (_b = (_a = config === null || config === void 0 ? void 0 : config.interceptors) === null || _a === void 0 ? void 0 : _a.request) !== null && _b !== void 0 ? _b : new OpenAPI_1.Interceptors(),
16
+ response: (_d = (_c = config === null || config === void 0 ? void 0 : config.interceptors) === null || _c === void 0 ? void 0 : _c.response) !== null && _d !== void 0 ? _d : new OpenAPI_1.Interceptors(),
17
+ },
18
+ }, HttpRequest);
19
+ }
20
+ }
21
+ exports.CivitaiClient = CivitaiClient;
22
+ // const test = new CivitaiClient({ auth: '' });
23
+ // test.requests.submitRequest([{ $type: 'textToImage' }]);
24
+ // test.workflows.submitRequest({requestBody: {} as TextToImageStep})
File without changes
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ // import {
3
+ // BaseHttpRequest,
4
+ // CancelError,
5
+ // CancelablePromise,
6
+ // JobTemplateReference,
7
+ // RequestInfo,
8
+ // RequestsService,
9
+ // ResultInclusion,
10
+ // } from '../generated';
11
+ // export class RequestsClient extends RequestsService {
12
+ // constructor(public readonly httpRequest: BaseHttpRequest) {
13
+ // super(httpRequest);
14
+ // }
15
+ // public override submitRequest(
16
+ // props?: {
17
+ // include?: ResultInclusion | undefined;
18
+ // requestBody?: JobTemplateReference | JobTemplateReference[] | undefined;
19
+ // wait?: boolean | undefined;
20
+ // whatif?: boolean | undefined;
21
+ // },
22
+ // options?: { cleanupOnCancellation?: boolean }
23
+ // ): CancelablePromise<RequestInfo> {
24
+ // return new CancelablePromise<RequestInfo>(async (resolve, reject, oncancel) => {
25
+ // try {
26
+ // const { wait, include } = props ?? {};
27
+ // const { cleanupOnCancellation = true } = options ?? {};
28
+ // let result = await withCancellation(super.submitRequest({ ...props, wait: false }));
29
+ // if (!result) throw new Error('no result');
30
+ // try {
31
+ // while (wait && (result.status === 'Initialized' || result.status === 'Processing')) {
32
+ // result = await withCancellation(
33
+ // this.getRequest({ requestId: result.id, include, wait })
34
+ // );
35
+ // }
36
+ // resolve(result);
37
+ // } catch (error) {
38
+ // if (error instanceof CancelError && wait && cleanupOnCancellation) {
39
+ // console.log('cancelling request');
40
+ // await this.updateRequest({
41
+ // requestId: result.id,
42
+ // requestBody: {
43
+ // status: 'Canceled',
44
+ // },
45
+ // });
46
+ // }
47
+ // throw error;
48
+ // }
49
+ // } catch (error) {
50
+ // reject(error);
51
+ // }
52
+ // function withCancellation<T>(promise: CancelablePromise<T>) {
53
+ // oncancel(promise.cancel);
54
+ // return promise;
55
+ // }
56
+ // });
57
+ // }
58
+ // }
@@ -0,0 +1,20 @@
1
+ import type { BaseHttpRequest } from './core/BaseHttpRequest';
2
+ import type { OpenAPIConfig } from './core/OpenAPI';
3
+ import { BlobsService } from './services.gen';
4
+ import { ConfigurationsService } from './services.gen';
5
+ import { ModelsService } from './services.gen';
6
+ import { WorkerJobsService } from './services.gen';
7
+ import { WorkersService } from './services.gen';
8
+ import { WorkflowsService } from './services.gen';
9
+ type HttpRequestConstructor = new (config: OpenAPIConfig) => BaseHttpRequest;
10
+ export declare class GeneratedClient {
11
+ readonly blobs: BlobsService;
12
+ readonly configurations: ConfigurationsService;
13
+ readonly models: ModelsService;
14
+ readonly workerJobs: WorkerJobsService;
15
+ readonly workers: WorkersService;
16
+ readonly workflows: WorkflowsService;
17
+ readonly request: BaseHttpRequest;
18
+ constructor(config?: Partial<OpenAPIConfig>, HttpRequest?: HttpRequestConstructor);
19
+ }
20
+ export {};
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GeneratedClient = void 0;
4
+ const OpenAPI_1 = require("./core/OpenAPI");
5
+ const FetchHttpRequest_1 = require("./core/FetchHttpRequest");
6
+ const services_gen_1 = require("./services.gen");
7
+ const services_gen_2 = require("./services.gen");
8
+ const services_gen_3 = require("./services.gen");
9
+ const services_gen_4 = require("./services.gen");
10
+ const services_gen_5 = require("./services.gen");
11
+ const services_gen_6 = require("./services.gen");
12
+ class GeneratedClient {
13
+ constructor(config, HttpRequest = FetchHttpRequest_1.FetchHttpRequest) {
14
+ var _a, _b, _c, _d, _e, _f, _g, _h;
15
+ this.request = new HttpRequest({
16
+ BASE: (_a = config === null || config === void 0 ? void 0 : config.BASE) !== null && _a !== void 0 ? _a : '',
17
+ VERSION: (_b = config === null || config === void 0 ? void 0 : config.VERSION) !== null && _b !== void 0 ? _b : '2',
18
+ WITH_CREDENTIALS: (_c = config === null || config === void 0 ? void 0 : config.WITH_CREDENTIALS) !== null && _c !== void 0 ? _c : false,
19
+ CREDENTIALS: (_d = config === null || config === void 0 ? void 0 : config.CREDENTIALS) !== null && _d !== void 0 ? _d : 'include',
20
+ TOKEN: config === null || config === void 0 ? void 0 : config.TOKEN,
21
+ USERNAME: config === null || config === void 0 ? void 0 : config.USERNAME,
22
+ PASSWORD: config === null || config === void 0 ? void 0 : config.PASSWORD,
23
+ HEADERS: config === null || config === void 0 ? void 0 : config.HEADERS,
24
+ ENCODE_PATH: config === null || config === void 0 ? void 0 : config.ENCODE_PATH,
25
+ interceptors: {
26
+ request: (_f = (_e = config === null || config === void 0 ? void 0 : config.interceptors) === null || _e === void 0 ? void 0 : _e.request) !== null && _f !== void 0 ? _f : new OpenAPI_1.Interceptors(),
27
+ response: (_h = (_g = config === null || config === void 0 ? void 0 : config.interceptors) === null || _g === void 0 ? void 0 : _g.response) !== null && _h !== void 0 ? _h : new OpenAPI_1.Interceptors(),
28
+ },
29
+ });
30
+ this.blobs = new services_gen_1.BlobsService(this.request);
31
+ this.configurations = new services_gen_2.ConfigurationsService(this.request);
32
+ this.models = new services_gen_3.ModelsService(this.request);
33
+ this.workerJobs = new services_gen_4.WorkerJobsService(this.request);
34
+ this.workers = new services_gen_5.WorkersService(this.request);
35
+ this.workflows = new services_gen_6.WorkflowsService(this.request);
36
+ }
37
+ }
38
+ exports.GeneratedClient = GeneratedClient;
@@ -0,0 +1,10 @@
1
+ import type { ApiRequestOptions } from './ApiRequestOptions';
2
+ import type { ApiResult } from './ApiResult';
3
+ export declare class ApiError extends Error {
4
+ readonly url: string;
5
+ readonly status: number;
6
+ readonly statusText: string;
7
+ readonly body: unknown;
8
+ readonly request: ApiRequestOptions;
9
+ constructor(request: ApiRequestOptions, response: ApiResult, message: string);
10
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApiError = void 0;
4
+ class ApiError extends Error {
5
+ constructor(request, response, message) {
6
+ super(message);
7
+ this.name = 'ApiError';
8
+ this.url = response.url;
9
+ this.status = response.status;
10
+ this.statusText = response.statusText;
11
+ this.body = response.body;
12
+ this.request = request;
13
+ }
14
+ }
15
+ exports.ApiError = ApiError;
@@ -0,0 +1,13 @@
1
+ export type ApiRequestOptions = {
2
+ readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH';
3
+ readonly url: string;
4
+ readonly path?: Record<string, unknown>;
5
+ readonly cookies?: Record<string, unknown>;
6
+ readonly headers?: Record<string, unknown>;
7
+ readonly query?: Record<string, unknown>;
8
+ readonly formData?: Record<string, unknown>;
9
+ readonly body?: any;
10
+ readonly mediaType?: string;
11
+ readonly responseHeader?: string;
12
+ readonly errors?: Record<number, string>;
13
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ export type ApiResult<TData = any> = {
2
+ readonly body: TData;
3
+ readonly ok: boolean;
4
+ readonly status: number;
5
+ readonly statusText: string;
6
+ readonly url: string;
7
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,14 @@
1
+ import type { ApiRequestOptions } from './ApiRequestOptions';
2
+ import { BaseHttpRequest } from './BaseHttpRequest';
3
+ import type { CancelablePromise } from './CancelablePromise';
4
+ import type { OpenAPIConfig } from './OpenAPI';
5
+ export declare class AxiosHttpRequest extends BaseHttpRequest {
6
+ constructor(config: OpenAPIConfig);
7
+ /**
8
+ * Request method
9
+ * @param options The request options from the service
10
+ * @returns CancelablePromise<T>
11
+ * @throws ApiError
12
+ */
13
+ request<T>(options: ApiRequestOptions): CancelablePromise<T>;
14
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AxiosHttpRequest = void 0;
4
+ const BaseHttpRequest_1 = require("./BaseHttpRequest");
5
+ const request_1 = require("./request");
6
+ class AxiosHttpRequest extends BaseHttpRequest_1.BaseHttpRequest {
7
+ constructor(config) {
8
+ super(config);
9
+ }
10
+ /**
11
+ * Request method
12
+ * @param options The request options from the service
13
+ * @returns CancelablePromise<T>
14
+ * @throws ApiError
15
+ */
16
+ request(options) {
17
+ return (0, request_1.request)(this.config, options);
18
+ }
19
+ }
20
+ exports.AxiosHttpRequest = AxiosHttpRequest;
@@ -0,0 +1,8 @@
1
+ import type { ApiRequestOptions } from './ApiRequestOptions';
2
+ import type { CancelablePromise } from './CancelablePromise';
3
+ import type { OpenAPIConfig } from './OpenAPI';
4
+ export declare abstract class BaseHttpRequest {
5
+ readonly config: OpenAPIConfig;
6
+ constructor(config: OpenAPIConfig);
7
+ abstract request<T>(options: ApiRequestOptions): CancelablePromise<T>;
8
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseHttpRequest = void 0;
4
+ class BaseHttpRequest {
5
+ constructor(config) {
6
+ this.config = config;
7
+ }
8
+ }
9
+ exports.BaseHttpRequest = BaseHttpRequest;
@@ -0,0 +1,37 @@
1
+ export declare class CancelError extends Error {
2
+ constructor(message: string);
3
+ get isCancelled(): boolean;
4
+ }
5
+ export interface OnCancel {
6
+ readonly isResolved: boolean;
7
+ readonly isRejected: boolean;
8
+ readonly isCancelled: boolean;
9
+ (cancelHandler: () => void): void;
10
+ }
11
+ export declare class CancelablePromise<T> implements Promise<T> {
12
+ private _isResolved;
13
+ private _isRejected;
14
+ private _isCancelled;
15
+ readonly cancelHandlers: (() => void)[];
16
+ readonly promise: Promise<T>;
17
+ private _resolve?;
18
+ private _reject?;
19
+ constructor(
20
+ executor: (
21
+ resolve: (value: T | PromiseLike<T>) => void,
22
+ reject: (reason?: unknown) => void,
23
+ onCancel: OnCancel
24
+ ) => void
25
+ );
26
+ get [Symbol.toStringTag](): string;
27
+ then<TResult1 = T, TResult2 = never>(
28
+ onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null,
29
+ onRejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null
30
+ ): Promise<TResult1 | TResult2>;
31
+ catch<TResult = never>(
32
+ onRejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null
33
+ ): Promise<T | TResult>;
34
+ finally(onFinally?: (() => void) | null): Promise<T>;
35
+ cancel(): void;
36
+ get isCancelled(): boolean;
37
+ }
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CancelablePromise = exports.CancelError = void 0;
4
+ class CancelError extends Error {
5
+ constructor(message) {
6
+ super(message);
7
+ this.name = 'CancelError';
8
+ }
9
+ get isCancelled() {
10
+ return true;
11
+ }
12
+ }
13
+ exports.CancelError = CancelError;
14
+ class CancelablePromise {
15
+ constructor(executor) {
16
+ this._isResolved = false;
17
+ this._isRejected = false;
18
+ this._isCancelled = false;
19
+ this.cancelHandlers = [];
20
+ this.promise = new Promise((resolve, reject) => {
21
+ this._resolve = resolve;
22
+ this._reject = reject;
23
+ const onResolve = (value) => {
24
+ if (this._isResolved || this._isRejected || this._isCancelled) {
25
+ return;
26
+ }
27
+ this._isResolved = true;
28
+ if (this._resolve)
29
+ this._resolve(value);
30
+ };
31
+ const onReject = (reason) => {
32
+ if (this._isResolved || this._isRejected || this._isCancelled) {
33
+ return;
34
+ }
35
+ this._isRejected = true;
36
+ if (this._reject)
37
+ this._reject(reason);
38
+ };
39
+ const onCancel = (cancelHandler) => {
40
+ if (this._isResolved || this._isRejected || this._isCancelled) {
41
+ return;
42
+ }
43
+ this.cancelHandlers.push(cancelHandler);
44
+ };
45
+ Object.defineProperty(onCancel, 'isResolved', {
46
+ get: () => this._isResolved,
47
+ });
48
+ Object.defineProperty(onCancel, 'isRejected', {
49
+ get: () => this._isRejected,
50
+ });
51
+ Object.defineProperty(onCancel, 'isCancelled', {
52
+ get: () => this._isCancelled,
53
+ });
54
+ return executor(onResolve, onReject, onCancel);
55
+ });
56
+ }
57
+ get [Symbol.toStringTag]() {
58
+ return 'Cancellable Promise';
59
+ }
60
+ then(onFulfilled, onRejected) {
61
+ return this.promise.then(onFulfilled, onRejected);
62
+ }
63
+ catch(onRejected) {
64
+ return this.promise.catch(onRejected);
65
+ }
66
+ finally(onFinally) {
67
+ return this.promise.finally(onFinally);
68
+ }
69
+ cancel() {
70
+ if (this._isResolved || this._isRejected || this._isCancelled) {
71
+ return;
72
+ }
73
+ this._isCancelled = true;
74
+ if (this.cancelHandlers.length) {
75
+ try {
76
+ for (const cancelHandler of this.cancelHandlers) {
77
+ cancelHandler();
78
+ }
79
+ }
80
+ catch (error) {
81
+ console.warn('Cancellation threw an error', error);
82
+ return;
83
+ }
84
+ }
85
+ this.cancelHandlers.length = 0;
86
+ if (this._reject)
87
+ this._reject(new CancelError('Request aborted'));
88
+ }
89
+ get isCancelled() {
90
+ return this._isCancelled;
91
+ }
92
+ }
93
+ exports.CancelablePromise = CancelablePromise;
@@ -0,0 +1,14 @@
1
+ import type { ApiRequestOptions } from './ApiRequestOptions';
2
+ import { BaseHttpRequest } from './BaseHttpRequest';
3
+ import type { CancelablePromise } from './CancelablePromise';
4
+ import type { OpenAPIConfig } from './OpenAPI';
5
+ export declare class FetchHttpRequest extends BaseHttpRequest {
6
+ constructor(config: OpenAPIConfig);
7
+ /**
8
+ * Request method
9
+ * @param options The request options from the service
10
+ * @returns CancelablePromise<T>
11
+ * @throws ApiError
12
+ */
13
+ request<T>(options: ApiRequestOptions): CancelablePromise<T>;
14
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FetchHttpRequest = void 0;
4
+ const BaseHttpRequest_1 = require("./BaseHttpRequest");
5
+ const request_1 = require("./request");
6
+ class FetchHttpRequest extends BaseHttpRequest_1.BaseHttpRequest {
7
+ constructor(config) {
8
+ super(config);
9
+ }
10
+ /**
11
+ * Request method
12
+ * @param options The request options from the service
13
+ * @returns CancelablePromise<T>
14
+ * @throws ApiError
15
+ */
16
+ request(options) {
17
+ return (0, request_1.request)(this.config, options);
18
+ }
19
+ }
20
+ exports.FetchHttpRequest = FetchHttpRequest;
@@ -0,0 +1,27 @@
1
+ import type { ApiRequestOptions } from './ApiRequestOptions';
2
+ type Headers = Record<string, string>;
3
+ type Middleware<T> = (value: T) => T | Promise<T>;
4
+ type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
5
+ export declare class Interceptors<T> {
6
+ _fns: Middleware<T>[];
7
+ constructor();
8
+ eject(fn: Middleware<T>): void;
9
+ use(fn: Middleware<T>): void;
10
+ }
11
+ export type OpenAPIConfig = {
12
+ BASE: string;
13
+ CREDENTIALS: 'include' | 'omit' | 'same-origin';
14
+ ENCODE_PATH?: ((path: string) => string) | undefined;
15
+ HEADERS?: Headers | Resolver<Headers> | undefined;
16
+ PASSWORD?: string | Resolver<string> | undefined;
17
+ TOKEN?: string | Resolver<string> | undefined;
18
+ USERNAME?: string | Resolver<string> | undefined;
19
+ VERSION: string;
20
+ WITH_CREDENTIALS: boolean;
21
+ interceptors: {
22
+ request: Interceptors<RequestInit>;
23
+ response: Interceptors<Response>;
24
+ };
25
+ };
26
+ export declare const OpenAPI: OpenAPIConfig;
27
+ export {};
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OpenAPI = exports.Interceptors = void 0;
4
+ class Interceptors {
5
+ constructor() {
6
+ this._fns = [];
7
+ }
8
+ eject(fn) {
9
+ const index = this._fns.indexOf(fn);
10
+ if (index !== -1) {
11
+ this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)];
12
+ }
13
+ }
14
+ use(fn) {
15
+ this._fns = [...this._fns, fn];
16
+ }
17
+ }
18
+ exports.Interceptors = Interceptors;
19
+ exports.OpenAPI = {
20
+ BASE: '',
21
+ CREDENTIALS: 'include',
22
+ ENCODE_PATH: undefined,
23
+ HEADERS: undefined,
24
+ PASSWORD: undefined,
25
+ TOKEN: undefined,
26
+ USERNAME: undefined,
27
+ VERSION: '2',
28
+ WITH_CREDENTIALS: false,
29
+ interceptors: {
30
+ request: new Interceptors(),
31
+ response: new Interceptors(),
32
+ },
33
+ };
@@ -0,0 +1,49 @@
1
+ import type { ApiRequestOptions } from './ApiRequestOptions';
2
+ import type { ApiResult } from './ApiResult';
3
+ import { CancelablePromise } from './CancelablePromise';
4
+ import type { OnCancel } from './CancelablePromise';
5
+ import type { OpenAPIConfig } from './OpenAPI';
6
+ export declare const isString: (value: unknown) => value is string;
7
+ export declare const isStringWithValue: (value: unknown) => value is string;
8
+ export declare const isBlob: (value: any) => value is Blob;
9
+ export declare const isFormData: (value: unknown) => value is FormData;
10
+ export declare const base64: (str: string) => string;
11
+ export declare const getQueryString: (params: Record<string, unknown>) => string;
12
+ export declare const getFormData: (options: ApiRequestOptions) => FormData | undefined;
13
+ type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
14
+ export declare const resolve: <T>(
15
+ options: ApiRequestOptions,
16
+ resolver?: T | Resolver<T>
17
+ ) => Promise<T | undefined>;
18
+ export declare const getHeaders: (
19
+ config: OpenAPIConfig,
20
+ options: ApiRequestOptions
21
+ ) => Promise<Headers>;
22
+ export declare const getRequestBody: (options: ApiRequestOptions) => unknown;
23
+ export declare const sendRequest: (
24
+ config: OpenAPIConfig,
25
+ options: ApiRequestOptions,
26
+ url: string,
27
+ body: any,
28
+ formData: FormData | undefined,
29
+ headers: Headers,
30
+ onCancel: OnCancel
31
+ ) => Promise<Response>;
32
+ export declare const getResponseHeader: (
33
+ response: Response,
34
+ responseHeader?: string
35
+ ) => string | undefined;
36
+ export declare const getResponseBody: (response: Response) => Promise<unknown>;
37
+ export declare const catchErrorCodes: (options: ApiRequestOptions, result: ApiResult) => void;
38
+ /**
39
+ * Request method
40
+ * @param config The OpenAPI configuration object
41
+ * @param options The request options from the service
42
+ * @returns CancelablePromise<T>
43
+ * @throws ApiError
44
+ */
45
+ export declare const request: <T>(
46
+ config: OpenAPIConfig,
47
+ options: ApiRequestOptions
48
+ ) => CancelablePromise<T>;
49
+ export {};