silgi 0.3.7 → 0.3.8
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/cli/index.mjs
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import type { AvailableRouterMethod, NitroFetchRequest } from 'nitropack';
|
|
2
|
+
import type { UseFetchOptions } from 'nuxt/app';
|
|
3
|
+
import type { FetchError } from 'ofetch';
|
|
1
4
|
import type { SilgiRouterTypes } from 'silgi';
|
|
2
|
-
|
|
3
|
-
export declare function useSilgiFetch<Route extends keyof SilgiRouterTypes, Method extends Extract<keyof SilgiRouterTypes[Route], string
|
|
5
|
+
export type KeysOf<T> = Array<T extends T ? keyof T extends string ? keyof T : never : never>;
|
|
6
|
+
export declare function useSilgiFetch<Route extends keyof SilgiRouterTypes, Method extends Extract<keyof SilgiRouterTypes[Route], string>, ResT = SilgiRouterTypes[Route][Method] extends {
|
|
4
7
|
output: any;
|
|
5
|
-
} ? SilgiRouterTypes[Route][Method]['output'] :
|
|
8
|
+
} ? SilgiRouterTypes[Route][Method]['output'] : never, ErrorT = FetchError>(request: Route | (() => Route), opts?: Omit<UseFetchOptions<ResT extends void ? unknown : ResT, ResT extends void ? unknown : ResT, KeysOf<ResT extends void ? unknown : ResT>, ResT extends void ? unknown : ResT, NitroFetchRequest, ResT extends void ? 'get' : AvailableRouterMethod<NitroFetchRequest>>, 'method' | 'body' | 'default' | 'transform' | 'pick' | 'getCachedData'> & {
|
|
6
9
|
method?: Method;
|
|
7
10
|
body?: SilgiRouterTypes[Route][Method] extends {
|
|
8
11
|
input: any;
|
|
9
12
|
} ? SilgiRouterTypes[Route][Method]['input'] : never;
|
|
10
|
-
}): import("nuxt/app").AsyncData<import("nuxt/dist/app/composables/asyncData").PickFrom<
|
|
13
|
+
}): import("nuxt/app").AsyncData<import("nuxt/dist/app/composables/asyncData").PickFrom<(ResT extends void ? unknown : ResT) extends infer T ? T extends (ResT extends void ? unknown : ResT) ? T extends void ? unknown : T : never : never, import("nuxt/dist/app/composables/asyncData").KeysOf<(ResT extends void ? unknown : ResT) extends infer T_1 ? T_1 extends (ResT extends void ? unknown : ResT) ? T_1 extends void ? unknown : T_1 : never : never>> | null, ErrorT | null>;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { useFetch } from "nuxt/app";
|
|
2
|
-
export function useSilgiFetch(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
export function useSilgiFetch(request, opts = {}) {
|
|
3
|
+
const { method, body, ...rest } = opts;
|
|
4
|
+
return useFetch(request, {
|
|
5
|
+
...rest,
|
|
6
|
+
// key,
|
|
7
|
+
body,
|
|
8
|
+
method: method ?? "get"
|
|
6
9
|
});
|
|
7
10
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -59,14 +59,21 @@ declare class SilgiError extends Error {
|
|
|
59
59
|
type RequestBodyOption<Route extends keyof SilgiRouterTypes, Method extends keyof SilgiRouterTypes[Route]> = SilgiRouterTypes[Route][Method] extends {
|
|
60
60
|
input: any;
|
|
61
61
|
} ? {
|
|
62
|
-
body
|
|
62
|
+
body: SilgiRouterTypes[Route][Method]['input'];
|
|
63
63
|
} : {
|
|
64
64
|
body?: never;
|
|
65
65
|
};
|
|
66
|
+
type RouterParams<Route extends keyof SilgiRouterTypes, Method extends keyof SilgiRouterTypes[Route]> = SilgiRouterTypes[Route][Method] extends {
|
|
67
|
+
params: any;
|
|
68
|
+
} ? {
|
|
69
|
+
params?: SilgiRouterTypes[Route][Method]['params'];
|
|
70
|
+
} : {
|
|
71
|
+
params?: never;
|
|
72
|
+
};
|
|
66
73
|
type DefaultMethod<Route extends keyof SilgiRouterTypes> = keyof SilgiRouterTypes[Route];
|
|
67
74
|
type SilgiFetchOptions<Route extends keyof SilgiRouterTypes, Method extends keyof SilgiRouterTypes[Route] = keyof SilgiRouterTypes[Route]> = {
|
|
68
75
|
method?: Method;
|
|
69
|
-
} & RequestBodyOption<Route, Method> & Omit<FetchOptions, 'query' | 'body' | 'method'>;
|
|
76
|
+
} & RequestBodyOption<Route, Method> & RouterParams<Route, Method> & Omit<FetchOptions, 'query' | 'body' | 'method'>;
|
|
70
77
|
type SilgiFetchClient = <Route extends keyof SilgiRouterTypes, Method extends keyof SilgiRouterTypes[Route] = DefaultMethod<Route>>(url: Route, options?: SilgiFetchOptions<Route, Method>) => Promise<SilgiRouterTypes[Route][Method] extends {
|
|
71
78
|
output: any;
|
|
72
79
|
} ? SilgiRouterTypes[Route][Method]['output'] : any>;
|
package/dist/index.d.ts
CHANGED
|
@@ -59,14 +59,21 @@ declare class SilgiError extends Error {
|
|
|
59
59
|
type RequestBodyOption<Route extends keyof SilgiRouterTypes, Method extends keyof SilgiRouterTypes[Route]> = SilgiRouterTypes[Route][Method] extends {
|
|
60
60
|
input: any;
|
|
61
61
|
} ? {
|
|
62
|
-
body
|
|
62
|
+
body: SilgiRouterTypes[Route][Method]['input'];
|
|
63
63
|
} : {
|
|
64
64
|
body?: never;
|
|
65
65
|
};
|
|
66
|
+
type RouterParams<Route extends keyof SilgiRouterTypes, Method extends keyof SilgiRouterTypes[Route]> = SilgiRouterTypes[Route][Method] extends {
|
|
67
|
+
params: any;
|
|
68
|
+
} ? {
|
|
69
|
+
params?: SilgiRouterTypes[Route][Method]['params'];
|
|
70
|
+
} : {
|
|
71
|
+
params?: never;
|
|
72
|
+
};
|
|
66
73
|
type DefaultMethod<Route extends keyof SilgiRouterTypes> = keyof SilgiRouterTypes[Route];
|
|
67
74
|
type SilgiFetchOptions<Route extends keyof SilgiRouterTypes, Method extends keyof SilgiRouterTypes[Route] = keyof SilgiRouterTypes[Route]> = {
|
|
68
75
|
method?: Method;
|
|
69
|
-
} & RequestBodyOption<Route, Method> & Omit<FetchOptions, 'query' | 'body' | 'method'>;
|
|
76
|
+
} & RequestBodyOption<Route, Method> & RouterParams<Route, Method> & Omit<FetchOptions, 'query' | 'body' | 'method'>;
|
|
70
77
|
type SilgiFetchClient = <Route extends keyof SilgiRouterTypes, Method extends keyof SilgiRouterTypes[Route] = DefaultMethod<Route>>(url: Route, options?: SilgiFetchOptions<Route, Method>) => Promise<SilgiRouterTypes[Route][Method] extends {
|
|
71
78
|
output: any;
|
|
72
79
|
} ? SilgiRouterTypes[Route][Method]['output'] : any>;
|