@deliverart/sdk-js-core 1.1.0 → 1.1.2
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/dist/index.cjs +15099 -0
- package/dist/index.d.cts +54 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.js +15092 -0
- package/package.json +1 -1
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { AxiosResponse, AxiosInstance } from 'axios';
|
|
2
|
+
import { ZodType, ZodTypeDef, ZodSchema, ZodIssue } from 'zod';
|
|
3
|
+
|
|
4
|
+
type ApiExtension = Record<string, unknown>;
|
|
5
|
+
interface ApiClientPlugin<T extends ApiExtension = Record<string, unknown>> {
|
|
6
|
+
setup: (client: ApiClient<Record<string, unknown>>) => T;
|
|
7
|
+
}
|
|
8
|
+
type ZodInput<T extends ZodType<any, any, any>> = T extends ZodType<any, any, infer I> ? I : never;
|
|
9
|
+
type ZodOutput<T extends ZodType<any, any, any>> = T extends ZodType<infer O, any, any> ? O : never;
|
|
10
|
+
|
|
11
|
+
declare abstract class AbstractApiRequest<TInputSchema extends ZodType<any, ZodTypeDef, any>, TOutputSchema extends ZodType<any, ZodTypeDef, any>, Query = unknown, Headers = unknown> {
|
|
12
|
+
readonly input: ZodInput<TInputSchema>;
|
|
13
|
+
readonly options?: {
|
|
14
|
+
query?: Query;
|
|
15
|
+
headers?: Headers;
|
|
16
|
+
} | undefined;
|
|
17
|
+
abstract readonly method: 'GET' | 'POST' | 'PATCH' | 'DELETE';
|
|
18
|
+
abstract readonly contentType: 'application/json' | 'multipart/form-data' | 'application/merge-patch+json';
|
|
19
|
+
abstract readonly accept: 'application/json';
|
|
20
|
+
abstract readonly inputSchema: TInputSchema;
|
|
21
|
+
abstract readonly outputSchema: TOutputSchema;
|
|
22
|
+
abstract readonly querySchema?: ZodSchema<Query>;
|
|
23
|
+
abstract readonly headersSchema?: ZodSchema<Headers>;
|
|
24
|
+
protected constructor(input: ZodInput<TInputSchema>, options?: {
|
|
25
|
+
query?: Query;
|
|
26
|
+
headers?: Headers;
|
|
27
|
+
} | undefined);
|
|
28
|
+
abstract getPath(): string;
|
|
29
|
+
validateInput(): ZodOutput<TInputSchema>;
|
|
30
|
+
validateQuery(): Query | undefined;
|
|
31
|
+
validateHeaders(): Headers | undefined;
|
|
32
|
+
validateOutput(data: unknown): ZodOutput<TOutputSchema>;
|
|
33
|
+
parseResponse(data: unknown, rawResponse?: AxiosResponse): ZodOutput<TOutputSchema>;
|
|
34
|
+
}
|
|
35
|
+
interface ApiClientBase {
|
|
36
|
+
http: AxiosInstance;
|
|
37
|
+
call<TInputSchema extends ZodType<any, ZodTypeDef, any>, TOutputSchema extends ZodType<any, ZodTypeDef, any>, Q = unknown, H = unknown>(request: AbstractApiRequest<TInputSchema, TOutputSchema, Q, H>): Promise<ZodOutput<TOutputSchema>>;
|
|
38
|
+
addPlugin: <T extends ApiExtension>(plugin: ApiClientPlugin<T>) => ApiClient<T>;
|
|
39
|
+
}
|
|
40
|
+
type ApiClient<Extensions extends ApiExtension = NonNullable<unknown>> = ApiClientBase & Extensions;
|
|
41
|
+
declare function createApiClient<Extensions extends ApiExtension = NonNullable<unknown>>(config: {
|
|
42
|
+
baseUrl: string;
|
|
43
|
+
}): ApiClient<Extensions>;
|
|
44
|
+
|
|
45
|
+
declare class InputValidationError extends Error {
|
|
46
|
+
readonly issues: ZodIssue[];
|
|
47
|
+
constructor(issues: ZodIssue[]);
|
|
48
|
+
}
|
|
49
|
+
declare class OutputValidationError extends Error {
|
|
50
|
+
readonly issues: ZodIssue[];
|
|
51
|
+
constructor(issues: ZodIssue[]);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { AbstractApiRequest, type ApiClient, type ApiClientPlugin, type ApiExtension, InputValidationError, OutputValidationError, type ZodInput, type ZodOutput, createApiClient };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { AxiosResponse, AxiosInstance } from 'axios';
|
|
2
|
+
import { ZodType, ZodTypeDef, ZodSchema, ZodIssue } from 'zod';
|
|
3
|
+
|
|
4
|
+
type ApiExtension = Record<string, unknown>;
|
|
5
|
+
interface ApiClientPlugin<T extends ApiExtension = Record<string, unknown>> {
|
|
6
|
+
setup: (client: ApiClient<Record<string, unknown>>) => T;
|
|
7
|
+
}
|
|
8
|
+
type ZodInput<T extends ZodType<any, any, any>> = T extends ZodType<any, any, infer I> ? I : never;
|
|
9
|
+
type ZodOutput<T extends ZodType<any, any, any>> = T extends ZodType<infer O, any, any> ? O : never;
|
|
10
|
+
|
|
11
|
+
declare abstract class AbstractApiRequest<TInputSchema extends ZodType<any, ZodTypeDef, any>, TOutputSchema extends ZodType<any, ZodTypeDef, any>, Query = unknown, Headers = unknown> {
|
|
12
|
+
readonly input: ZodInput<TInputSchema>;
|
|
13
|
+
readonly options?: {
|
|
14
|
+
query?: Query;
|
|
15
|
+
headers?: Headers;
|
|
16
|
+
} | undefined;
|
|
17
|
+
abstract readonly method: 'GET' | 'POST' | 'PATCH' | 'DELETE';
|
|
18
|
+
abstract readonly contentType: 'application/json' | 'multipart/form-data' | 'application/merge-patch+json';
|
|
19
|
+
abstract readonly accept: 'application/json';
|
|
20
|
+
abstract readonly inputSchema: TInputSchema;
|
|
21
|
+
abstract readonly outputSchema: TOutputSchema;
|
|
22
|
+
abstract readonly querySchema?: ZodSchema<Query>;
|
|
23
|
+
abstract readonly headersSchema?: ZodSchema<Headers>;
|
|
24
|
+
protected constructor(input: ZodInput<TInputSchema>, options?: {
|
|
25
|
+
query?: Query;
|
|
26
|
+
headers?: Headers;
|
|
27
|
+
} | undefined);
|
|
28
|
+
abstract getPath(): string;
|
|
29
|
+
validateInput(): ZodOutput<TInputSchema>;
|
|
30
|
+
validateQuery(): Query | undefined;
|
|
31
|
+
validateHeaders(): Headers | undefined;
|
|
32
|
+
validateOutput(data: unknown): ZodOutput<TOutputSchema>;
|
|
33
|
+
parseResponse(data: unknown, rawResponse?: AxiosResponse): ZodOutput<TOutputSchema>;
|
|
34
|
+
}
|
|
35
|
+
interface ApiClientBase {
|
|
36
|
+
http: AxiosInstance;
|
|
37
|
+
call<TInputSchema extends ZodType<any, ZodTypeDef, any>, TOutputSchema extends ZodType<any, ZodTypeDef, any>, Q = unknown, H = unknown>(request: AbstractApiRequest<TInputSchema, TOutputSchema, Q, H>): Promise<ZodOutput<TOutputSchema>>;
|
|
38
|
+
addPlugin: <T extends ApiExtension>(plugin: ApiClientPlugin<T>) => ApiClient<T>;
|
|
39
|
+
}
|
|
40
|
+
type ApiClient<Extensions extends ApiExtension = NonNullable<unknown>> = ApiClientBase & Extensions;
|
|
41
|
+
declare function createApiClient<Extensions extends ApiExtension = NonNullable<unknown>>(config: {
|
|
42
|
+
baseUrl: string;
|
|
43
|
+
}): ApiClient<Extensions>;
|
|
44
|
+
|
|
45
|
+
declare class InputValidationError extends Error {
|
|
46
|
+
readonly issues: ZodIssue[];
|
|
47
|
+
constructor(issues: ZodIssue[]);
|
|
48
|
+
}
|
|
49
|
+
declare class OutputValidationError extends Error {
|
|
50
|
+
readonly issues: ZodIssue[];
|
|
51
|
+
constructor(issues: ZodIssue[]);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { AbstractApiRequest, type ApiClient, type ApiClientPlugin, type ApiExtension, InputValidationError, OutputValidationError, type ZodInput, type ZodOutput, createApiClient };
|