@dcc-bs/communication.bs.js 0.1.0 → 0.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/communication.bs.d.ts +46 -7
- package/dist/communication.bs.js +4467 -3841
- package/dist/communication.bs.umd.cjs +18 -10
- package/package.json +4 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { default as default_2 } from 'zod';
|
|
2
|
+
import { Ref } from 'vue';
|
|
2
3
|
import { z } from 'zod';
|
|
3
4
|
import { ZodType } from 'zod';
|
|
4
5
|
|
|
@@ -21,12 +22,19 @@ import { ZodType } from 'zod';
|
|
|
21
22
|
*/
|
|
22
23
|
export declare type AfterResponseHook = (response: Response) => Promise<Response> | Response;
|
|
23
24
|
|
|
25
|
+
export declare interface ApiClient {
|
|
26
|
+
apiFetch: ApiFetchFunction;
|
|
27
|
+
apiStreamFetch: (url: string, options?: ApiFetchOptions) => Promise<ApiResponse<ReadableStream<Uint8Array>>>;
|
|
28
|
+
apiFetchTextMany: (url: string, options?: ApiFetchOptions) => AsyncGenerator<string, void, void>;
|
|
29
|
+
apiFetchMany: <T extends ZodType>(url: string, options: ApiFetchOptionsWithSchema<T>) => AsyncGenerator<z.infer<T>, void, void>;
|
|
30
|
+
}
|
|
31
|
+
|
|
24
32
|
export declare class ApiError extends Error {
|
|
25
33
|
$type: "ApiError";
|
|
26
|
-
errorId:
|
|
34
|
+
errorId: ErrorId_2;
|
|
27
35
|
debugMessage?: string;
|
|
28
36
|
status: number;
|
|
29
|
-
constructor(errorId:
|
|
37
|
+
constructor(errorId: ErrorId_2, status: number, debugMessage?: string);
|
|
30
38
|
}
|
|
31
39
|
|
|
32
40
|
export declare const ApiErrorResponse: default_2.ZodObject<{
|
|
@@ -36,9 +44,14 @@ export declare const ApiErrorResponse: default_2.ZodObject<{
|
|
|
36
44
|
|
|
37
45
|
export declare type ApiErrorResponse = default_2.infer<typeof ApiErrorResponse>;
|
|
38
46
|
|
|
39
|
-
export declare function apiFetch<T extends ZodType>(url: string, options: ApiFetchOptionsWithSchema<T>): Promise<
|
|
47
|
+
export declare function apiFetch<T extends ZodType>(url: string, options: ApiFetchOptionsWithSchema<T>): Promise<ApiResponse_2<z.infer<T>>>;
|
|
48
|
+
|
|
49
|
+
export declare function apiFetch<T extends object>(url: string, options?: ApiFetchOptions): Promise<ApiResponse_2<T>>;
|
|
40
50
|
|
|
41
|
-
|
|
51
|
+
declare interface ApiFetchFunction {
|
|
52
|
+
<T extends ZodType>(url: string, options: ApiFetchOptionsWithSchema<T>): Promise<ApiResponse<z.infer<T>>>;
|
|
53
|
+
<T extends object>(url: string, options?: ApiFetchOptions): Promise<ApiResponse<T>>;
|
|
54
|
+
}
|
|
42
55
|
|
|
43
56
|
export declare function apiFetchMany<T extends ZodType>(url: string, options: ApiFetchOptionsWithSchema<T>): AsyncGenerator<z.infer<T>, void, void>;
|
|
44
57
|
|
|
@@ -52,9 +65,11 @@ export declare type ApiFetchOptionsWithSchema<T extends ZodType> = ApiFetchOptio
|
|
|
52
65
|
|
|
53
66
|
export declare function apiFetchTextMany(url: string, options?: ApiFetchOptions): AsyncGenerator<string, void, void>;
|
|
54
67
|
|
|
55
|
-
declare type ApiResponse<T> = T | ApiError;
|
|
68
|
+
export declare type ApiResponse<T> = T | ApiError;
|
|
69
|
+
|
|
70
|
+
declare type ApiResponse_2<T> = T | ApiError;
|
|
56
71
|
|
|
57
|
-
export declare function apiStreamFetch(url: string, options?: ApiFetchOptions): Promise<
|
|
72
|
+
export declare function apiStreamFetch(url: string, options?: ApiFetchOptions): Promise<ApiResponse_2<ReadableStream<Uint8Array>>>;
|
|
58
73
|
|
|
59
74
|
/**
|
|
60
75
|
* Authentication configuration for the fetcher.
|
|
@@ -102,6 +117,8 @@ declare type BearerAuthConfig = {
|
|
|
102
117
|
*/
|
|
103
118
|
export declare type BeforeRequestHook = (url: string, options: RequestInit) => Promise<void> | void;
|
|
104
119
|
|
|
120
|
+
export declare function createApiClient(fetcher?: Fetcher): ApiClient;
|
|
121
|
+
|
|
105
122
|
/**
|
|
106
123
|
* Creates a builder for configuring and creating a customized fetcher.
|
|
107
124
|
* The builder allows you to chain configuration methods and then build a fetcher
|
|
@@ -395,7 +412,9 @@ export declare function createFetcherBuilder(options?: FetcherBuilderOptions): {
|
|
|
395
412
|
build: () => Fetcher;
|
|
396
413
|
};
|
|
397
414
|
|
|
398
|
-
declare type ErrorId = "unexpected_error" | "fetch_failed" | string;
|
|
415
|
+
export declare type ErrorId = "unexpected_error" | "fetch_failed" | string;
|
|
416
|
+
|
|
417
|
+
declare type ErrorId_2 = "unexpected_error" | "fetch_failed" | string;
|
|
399
418
|
|
|
400
419
|
export declare type Fetcher = (url: string, options: ApiFetchOptions) => Promise<Response>;
|
|
401
420
|
|
|
@@ -568,4 +587,24 @@ export declare function isApiError(response: unknown): response is ApiError;
|
|
|
568
587
|
*/
|
|
569
588
|
export declare type OnErrorHook = (error: Error) => void;
|
|
570
589
|
|
|
590
|
+
export declare function useApiFetch<T extends object>(url: string, options?: ApiFetchOptions, fetcher?: Fetcher): {
|
|
591
|
+
data: Ref<T | undefined, T | undefined>;
|
|
592
|
+
error: Ref<{
|
|
593
|
+
errorId: string;
|
|
594
|
+
debugMessage?: string | undefined;
|
|
595
|
+
} | undefined, {
|
|
596
|
+
errorId: string;
|
|
597
|
+
debugMessage?: string | undefined;
|
|
598
|
+
} | undefined>;
|
|
599
|
+
pending: Ref<boolean, boolean>;
|
|
600
|
+
};
|
|
601
|
+
|
|
602
|
+
export declare type UseApiFetchOutput<T> = {
|
|
603
|
+
data: Ref<T | undefined>;
|
|
604
|
+
error: Ref<ApiErrorResponse | undefined>;
|
|
605
|
+
pending: Ref<boolean>;
|
|
606
|
+
};
|
|
607
|
+
|
|
608
|
+
export declare function useApiFetchWithSchema<T extends ZodType>(url: string, options: ApiFetchOptionsWithSchema<T>, fetcher?: Fetcher): UseApiFetchOutput<z.infer<T>>;
|
|
609
|
+
|
|
571
610
|
export { }
|