silgi 0.3.9 → 0.3.10
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,19 +1,14 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
}>;
|
|
16
|
-
type UseOpenFetchOptions<ReqT extends keyof SilgiRouterTypes, Method extends keyof SilgiRouterTypes[ReqT], LowercasedMethod, Params, ResT, DataT = ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null, Operation = 'get' extends LowercasedMethod ? ('get' extends keyof Params ? Params['get'] : never) : LowercasedMethod extends keyof Params ? Params[LowercasedMethod] : never> = ComputedMethodOption<Method, Params> & ComputedOptions<ParamsOption<Operation>> & ComputedOptions<RequestBodyOption<ReqT, Method>> & Omit<UseFetchOptions<ResT, DataT, PickKeys, DefaultT>, 'query' | 'body' | 'method'>;
|
|
17
|
-
export type UseOpenFetchClient<Paths extends keyof SilgiRouterTypes, Lazy extends boolean> = <Methods extends FilterMethods<Paths>, Method extends Extract<keyof Methods, string> | Uppercase<Extract<keyof Methods, string>>, LowercasedMethod extends Lowercase<Method> extends keyof Methods ? Lowercase<Method> : never, DefaultMethod extends 'get' extends LowercasedMethod ? 'get' : LowercasedMethod, ResT = Methods[DefaultMethod] extends Record<string | number, any> ? FetchResponseData<Paths, Method> : never, ErrorT = Methods[DefaultMethod] extends Record<string | number, any> ? FetchResponseError<Methods[DefaultMethod]> : never, DataT = ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = null>(url: Paths | (() => Paths), options?: Lazy extends true ? Omit<UseOpenFetchOptions<Paths, Method, LowercasedMethod, Methods, ResT, DataT, PickKeys, DefaultT>, 'lazy'> : UseOpenFetchOptions<Paths, Method, LowercasedMethod, Methods, ResT, DataT, PickKeys, DefaultT>, autoKey?: string) => AsyncData<PickFrom<DataT, PickKeys> | DefaultT, ErrorT | null>;
|
|
18
|
-
export declare function createUseOpenFetch<Paths extends keyof SilgiRouterTypes, Lazy extends boolean = false>(client: $Fetch | OpenFetchClientName, lazy?: Lazy): UseOpenFetchClient<Paths, Lazy>;
|
|
19
|
-
export {};
|
|
1
|
+
import type { SilgiRouterTypes } from 'silgi';
|
|
2
|
+
import { type FetchResult, type UseFetchOptions } from 'nuxt/app';
|
|
3
|
+
import type { FetchError } from 'ofetch';
|
|
4
|
+
import type { AvailableRouterMethod } from 'nitropack';
|
|
5
|
+
import type { KeysOf } from 'nuxt/dist/app/composables/asyncData';
|
|
6
|
+
import type { DefaultAsyncDataValue } from 'nuxt/app/defaults';
|
|
7
|
+
export declare function useSilgiFetch<ResT = void, ErrorT = FetchError, ReqT extends keyof SilgiRouterTypes = keyof SilgiRouterTypes, Method extends AvailableRouterMethod<ReqT> = ResT extends void ? 'get' extends AvailableRouterMethod<ReqT> ? 'get' : AvailableRouterMethod<ReqT> : AvailableRouterMethod<ReqT>, _ResT = ResT extends void ? FetchResult<ReqT, Method> : ResT, DataT = _ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = DefaultAsyncDataValue>(url: ReqT | (() => ReqT), options?: Omit<UseFetchOptions<any, any, any, any, ReqT>, 'method' | 'body'> & {
|
|
8
|
+
method?: SilgiRouterTypes[ReqT][Method] extends {
|
|
9
|
+
output: any;
|
|
10
|
+
} ? SilgiRouterTypes[ReqT][Method]['output'] : any;
|
|
11
|
+
body?: SilgiRouterTypes[ReqT][Method] extends {
|
|
12
|
+
input: any;
|
|
13
|
+
} ? SilgiRouterTypes[ReqT][Method]['input'] : never;
|
|
14
|
+
}): import("nuxt/app").AsyncData<DefaultT | import("nuxt/dist/app/composables/asyncData").PickFrom<DataT, PickKeys>, ErrorT | null>;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { useFetch
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const opts = { $fetch, key: autoKey, ...options };
|
|
8
|
-
return useFetch(() => toValue(url), lazy ? { ...opts, lazy } : opts);
|
|
9
|
-
};
|
|
1
|
+
import { useFetch } from "nuxt/app";
|
|
2
|
+
export function useSilgiFetch(url, options) {
|
|
3
|
+
return useFetch(url, {
|
|
4
|
+
...options,
|
|
5
|
+
method: options?.method?.toUpperCase() ?? "GET"
|
|
6
|
+
});
|
|
10
7
|
}
|