silgi 0.3.9 → 0.3.12

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.
@@ -3,7 +3,7 @@ import consola from 'consola';
3
3
 
4
4
  const name = "silgi";
5
5
  const type = "module";
6
- const version = "0.3.9";
6
+ const version = "0.3.12";
7
7
  const packageManager = "pnpm@9.15.1";
8
8
  const sideEffects = false;
9
9
  const exports = {
@@ -83,8 +83,8 @@ const peerDependencies = {
83
83
  nitropack: "^2.10.4",
84
84
  nuxt: "^3.15.3",
85
85
  typescript: "^5.7.3",
86
- zod: "^3.24.1",
87
- vue: "^3.5.13"
86
+ vue: "^3.5.13",
87
+ zod: "^3.24.1"
88
88
  };
89
89
  const peerDependenciesMeta = {
90
90
  "@nuxt/kit": {
@@ -99,10 +99,10 @@ const peerDependenciesMeta = {
99
99
  nuxt: {
100
100
  optional: true
101
101
  },
102
- zod: {
102
+ vue: {
103
103
  optional: true
104
104
  },
105
- vue: {
105
+ zod: {
106
106
  optional: true
107
107
  }
108
108
  };
@@ -1,19 +1,16 @@
1
- import type { AsyncData, UseFetchOptions } from 'nuxt/app';
2
- import type { $Fetch } from 'ofetch';
3
- import type { Ref } from 'vue';
4
- import type { FetchResponseData, FetchResponseError, FilterMethods, ParamsOption, RequestBodyOption, SilgiRouterTypes } from 'silgi';
5
- export type OpenFetchClientName = 'ofetch';
6
- type PickFrom<T, K extends Array<string>> = T extends Array<any> ? T : T extends Record<string, any> ? keyof T extends K[number] ? T : K[number] extends never ? T : Pick<T, K[number]> : T;
7
- type KeysOf<T> = Array<T extends T ? keyof T extends string ? keyof T : never : never>;
8
- type ComputedOptions<T> = {
9
- [K in keyof T]: T[K] extends Function ? T[K] : ComputedOptions<T[K]> | Ref<T[K]> | T[K];
10
- };
11
- type ComputedMethodOption<M, P> = 'get' extends keyof P ? ComputedOptions<{
12
- method?: M;
13
- }> : ComputedOptions<{
14
- method: M;
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 { AvailableRouterMethod } from 'nitropack';
2
+ import type { FetchError } from 'ofetch';
3
+ import type { SilgiRouterTypes } from 'silgi';
4
+ import { type AsyncData, type FetchResult, type UseFetchOptions } from 'nuxt/app';
5
+ export type KeysOf<T> = Array<T extends T ? keyof T extends string ? keyof T : never : never>;
6
+ export type PickFrom<T, K extends Array<string>> = T extends Array<any> ? T : T extends Record<string, any> ? keyof T extends K[number] ? T : K[number] extends never ? T : Pick<T, K[number]> : T;
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 = SilgiRouterTypes[ReqT][Method] extends {
8
+ output: any;
9
+ } ? SilgiRouterTypes[ReqT][Method]['output'] : any, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = SilgiRouterTypes[ReqT][Method] extends {
10
+ output: infer T;
11
+ } ? T : never>(url: ReqT | (() => ReqT), options?: Omit<UseFetchOptions<any, any, any, any, ReqT>, 'method' | 'body'> & {
12
+ method?: keyof SilgiRouterTypes[ReqT];
13
+ body?: SilgiRouterTypes[ReqT][Method] extends {
14
+ input: any;
15
+ } ? SilgiRouterTypes[ReqT][Method]['input'] : never;
16
+ }): AsyncData<DefaultT | PickFrom<DataT, PickKeys>, ErrorT | null>;
@@ -1,10 +1,7 @@
1
- import { useFetch, useNuxtApp } from "nuxt/app";
2
- import { toValue } from "vue";
3
- export function createUseOpenFetch(client, lazy = false) {
4
- return (url, options = {}, autoKey) => {
5
- const nuxtApp = useNuxtApp();
6
- const $fetch = typeof client === "string" ? nuxtApp[`$${client}`] : client;
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
  }
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { b as SilgiConfig, c as SilgiHelper, d as SilgiRouterTypes, S as SilgiOptions, M as ModuleOptions, e as ModuleDefinition, f as SilgiModule, B as BaseSchemaType, g as SilgiServiceInterface, h as DefaultNamespaces, i as Silgi, j as SilgiOperation, k as MergedSilgiSchema, l as ServiceType, m as SilgiSchema, R as RequiredServiceType, n as SilgiModuleShared } from './shared/silgi.ClpvycKI.mjs';
2
2
  export { F as Awaitable, G as CreateScope, D as DeepPartial, C as DefaultHooks, A as DefaultMethods, E as ExtendShared, u as ExtractInputFromURI, v as ExtractOutputFromURI, w as ExtractRouterParamsFromURI, s as SilgiDefaultShared, o as SilgiEvent, z as SilgiHook, p as SilgiModuleMethods, a as SilgiModuleOptions, q as SilgiModules, r as SilgiNamespaces, x as SilgiStorageBase, t as SilgiURIs, U as URIsTypes, y as silgi } from './shared/silgi.ClpvycKI.mjs';
3
- import { FetchError, FetchContext, FetchOptions } from 'ofetch';
3
+ import { FetchContext, FetchOptions } from 'ofetch';
4
4
  import { LoadConfigOptions } from 'c12';
5
5
  import { StandardSchemaV1 } from '@standard-schema/spec';
6
6
  import * as unctx_index from 'unctx/index';
@@ -59,7 +59,6 @@ declare class SilgiError extends Error {
59
59
  type FetchResponseData<Route extends keyof SilgiRouterTypes, Method extends keyof SilgiRouterTypes[Route]> = SilgiRouterTypes[Route][Method] extends {
60
60
  output: any;
61
61
  } ? SilgiRouterTypes[Route][Method]['output'] : never;
62
- type FetchResponseError<T extends Record<string | number, any>> = FetchError;
63
62
  type MethodOption<M, P> = 'get' extends keyof P ? {
64
63
  method?: M;
65
64
  } : {
@@ -194,4 +193,4 @@ declare function createSchema<T extends Partial<Record<keyof DefaultNamespaces,
194
193
  };
195
194
  };
196
195
 
197
- export { DefaultNamespaces, type ExtendContext, type FetchResponseData, type FetchResponseError, type FilterMethods, MergedSilgiSchema, type MethodOption, type Namespaces, type ParamsOption, type RequestBodyOption, type RouterParams, ServiceType, Silgi, SilgiError, type SilgiFetchClient, SilgiHelper, type SilgiModuleContext, SilgiModuleShared, SilgiOptions, SilgiRouterTypes, SilgiSchema, createResolver, createSchema, createService, createShared, createSilgi, createSilgiFetch, defineSilgiModule, loadSilgiConfig, mergeSchemas, mergeServices, mergeShared, normalizeResult, parseURI, relativeWithDot, silgiCtx, silgiFetchRequestInterceptor, tryUseSilgi, useHook, useShared, useSilgi };
196
+ export { DefaultNamespaces, type ExtendContext, type FetchResponseData, type FilterMethods, MergedSilgiSchema, type MethodOption, type Namespaces, type ParamsOption, type RequestBodyOption, type RouterParams, ServiceType, Silgi, SilgiError, type SilgiFetchClient, SilgiHelper, type SilgiModuleContext, SilgiModuleShared, SilgiOptions, SilgiRouterTypes, SilgiSchema, createResolver, createSchema, createService, createShared, createSilgi, createSilgiFetch, defineSilgiModule, loadSilgiConfig, mergeSchemas, mergeServices, mergeShared, normalizeResult, parseURI, relativeWithDot, silgiCtx, silgiFetchRequestInterceptor, tryUseSilgi, useHook, useShared, useSilgi };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { b as SilgiConfig, c as SilgiHelper, d as SilgiRouterTypes, S as SilgiOptions, M as ModuleOptions, e as ModuleDefinition, f as SilgiModule, B as BaseSchemaType, g as SilgiServiceInterface, h as DefaultNamespaces, i as Silgi, j as SilgiOperation, k as MergedSilgiSchema, l as ServiceType, m as SilgiSchema, R as RequiredServiceType, n as SilgiModuleShared } from './shared/silgi.ClpvycKI.js';
2
2
  export { F as Awaitable, G as CreateScope, D as DeepPartial, C as DefaultHooks, A as DefaultMethods, E as ExtendShared, u as ExtractInputFromURI, v as ExtractOutputFromURI, w as ExtractRouterParamsFromURI, s as SilgiDefaultShared, o as SilgiEvent, z as SilgiHook, p as SilgiModuleMethods, a as SilgiModuleOptions, q as SilgiModules, r as SilgiNamespaces, x as SilgiStorageBase, t as SilgiURIs, U as URIsTypes, y as silgi } from './shared/silgi.ClpvycKI.js';
3
- import { FetchError, FetchContext, FetchOptions } from 'ofetch';
3
+ import { FetchContext, FetchOptions } from 'ofetch';
4
4
  import { LoadConfigOptions } from 'c12';
5
5
  import { StandardSchemaV1 } from '@standard-schema/spec';
6
6
  import * as unctx_index from 'unctx/index';
@@ -59,7 +59,6 @@ declare class SilgiError extends Error {
59
59
  type FetchResponseData<Route extends keyof SilgiRouterTypes, Method extends keyof SilgiRouterTypes[Route]> = SilgiRouterTypes[Route][Method] extends {
60
60
  output: any;
61
61
  } ? SilgiRouterTypes[Route][Method]['output'] : never;
62
- type FetchResponseError<T extends Record<string | number, any>> = FetchError;
63
62
  type MethodOption<M, P> = 'get' extends keyof P ? {
64
63
  method?: M;
65
64
  } : {
@@ -194,4 +193,4 @@ declare function createSchema<T extends Partial<Record<keyof DefaultNamespaces,
194
193
  };
195
194
  };
196
195
 
197
- export { DefaultNamespaces, type ExtendContext, type FetchResponseData, type FetchResponseError, type FilterMethods, MergedSilgiSchema, type MethodOption, type Namespaces, type ParamsOption, type RequestBodyOption, type RouterParams, ServiceType, Silgi, SilgiError, type SilgiFetchClient, SilgiHelper, type SilgiModuleContext, SilgiModuleShared, SilgiOptions, SilgiRouterTypes, SilgiSchema, createResolver, createSchema, createService, createShared, createSilgi, createSilgiFetch, defineSilgiModule, loadSilgiConfig, mergeSchemas, mergeServices, mergeShared, normalizeResult, parseURI, relativeWithDot, silgiCtx, silgiFetchRequestInterceptor, tryUseSilgi, useHook, useShared, useSilgi };
196
+ export { DefaultNamespaces, type ExtendContext, type FetchResponseData, type FilterMethods, MergedSilgiSchema, type MethodOption, type Namespaces, type ParamsOption, type RequestBodyOption, type RouterParams, ServiceType, Silgi, SilgiError, type SilgiFetchClient, SilgiHelper, type SilgiModuleContext, SilgiModuleShared, SilgiOptions, SilgiRouterTypes, SilgiSchema, createResolver, createSchema, createService, createShared, createSilgi, createSilgiFetch, defineSilgiModule, loadSilgiConfig, mergeSchemas, mergeServices, mergeShared, normalizeResult, parseURI, relativeWithDot, silgiCtx, silgiFetchRequestInterceptor, tryUseSilgi, useHook, useShared, useSilgi };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.3.9",
4
+ "version": "0.3.12",
5
5
  "sideEffects": false,
6
6
  "exports": {
7
7
  ".": {
@@ -66,8 +66,8 @@
66
66
  "nitropack": "^2.10.4",
67
67
  "nuxt": "^3.15.3",
68
68
  "typescript": "^5.7.3",
69
- "zod": "^3.24.1",
70
- "vue": "^3.5.13"
69
+ "vue": "^3.5.13",
70
+ "zod": "^3.24.1"
71
71
  },
72
72
  "peerDependenciesMeta": {
73
73
  "@nuxt/kit": {
@@ -82,10 +82,10 @@
82
82
  "nuxt": {
83
83
  "optional": true
84
84
  },
85
- "zod": {
85
+ "vue": {
86
86
  "optional": true
87
87
  },
88
- "vue": {
88
+ "zod": {
89
89
  "optional": true
90
90
  }
91
91
  },