silgi 0.3.8 → 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
|
@@ -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.
|
|
6
|
+
const version = "0.3.10";
|
|
7
7
|
const packageManager = "pnpm@9.15.1";
|
|
8
8
|
const sideEffects = false;
|
|
9
9
|
const exports = {
|
|
@@ -83,7 +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"
|
|
86
|
+
zod: "^3.24.1",
|
|
87
|
+
vue: "^3.5.13"
|
|
87
88
|
};
|
|
88
89
|
const peerDependenciesMeta = {
|
|
89
90
|
"@nuxt/kit": {
|
|
@@ -100,6 +101,9 @@ const peerDependenciesMeta = {
|
|
|
100
101
|
},
|
|
101
102
|
zod: {
|
|
102
103
|
optional: true
|
|
104
|
+
},
|
|
105
|
+
vue: {
|
|
106
|
+
optional: true
|
|
103
107
|
}
|
|
104
108
|
};
|
|
105
109
|
const dependencies = {
|
|
@@ -142,6 +146,7 @@ const devDependencies = {
|
|
|
142
146
|
nuxt: "^3.15.3",
|
|
143
147
|
unbuild: "^3.3.1",
|
|
144
148
|
vitest: "^3.0.3",
|
|
149
|
+
vue: "^3.5.13",
|
|
145
150
|
zod: "^3.24.1"
|
|
146
151
|
};
|
|
147
152
|
const resolutions = {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import type { AvailableRouterMethod, NitroFetchRequest } from 'nitropack';
|
|
2
|
-
import type { UseFetchOptions } from 'nuxt/app';
|
|
3
|
-
import type { FetchError } from 'ofetch';
|
|
4
1
|
import type { SilgiRouterTypes } from 'silgi';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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 {
|
|
11
12
|
input: any;
|
|
12
|
-
} ? SilgiRouterTypes[
|
|
13
|
-
}): import("nuxt/app").AsyncData<import("nuxt/dist/app/composables/asyncData").PickFrom<
|
|
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
1
|
import { useFetch } from "nuxt/app";
|
|
2
|
-
export function useSilgiFetch(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// key,
|
|
7
|
-
body,
|
|
8
|
-
method: method ?? "get"
|
|
2
|
+
export function useSilgiFetch(url, options) {
|
|
3
|
+
return useFetch(url, {
|
|
4
|
+
...options,
|
|
5
|
+
method: options?.method?.toUpperCase() ?? "GET"
|
|
9
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 { FetchOptions } from 'ofetch';
|
|
3
|
+
import { FetchError, 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';
|
|
@@ -56,6 +56,19 @@ declare class SilgiError extends Error {
|
|
|
56
56
|
static isSilgiError(error: unknown): error is SilgiError;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
type FetchResponseData<Route extends keyof SilgiRouterTypes, Method extends keyof SilgiRouterTypes[Route]> = SilgiRouterTypes[Route][Method] extends {
|
|
60
|
+
output: any;
|
|
61
|
+
} ? SilgiRouterTypes[Route][Method]['output'] : never;
|
|
62
|
+
type FetchResponseError<T extends Record<string | number, any>> = FetchError;
|
|
63
|
+
type MethodOption<M, P> = 'get' extends keyof P ? {
|
|
64
|
+
method?: M;
|
|
65
|
+
} : {
|
|
66
|
+
method: M;
|
|
67
|
+
};
|
|
68
|
+
type ParamsOption<T> = T extends {
|
|
69
|
+
parameters?: any;
|
|
70
|
+
query?: any;
|
|
71
|
+
} ? T['parameters'] : Record<string, never>;
|
|
59
72
|
type RequestBodyOption<Route extends keyof SilgiRouterTypes, Method extends keyof SilgiRouterTypes[Route]> = SilgiRouterTypes[Route][Method] extends {
|
|
60
73
|
input: any;
|
|
61
74
|
} ? {
|
|
@@ -70,13 +83,13 @@ type RouterParams<Route extends keyof SilgiRouterTypes, Method extends keyof Sil
|
|
|
70
83
|
} : {
|
|
71
84
|
params?: never;
|
|
72
85
|
};
|
|
86
|
+
type FilterMethods<T extends keyof SilgiRouterTypes> = keyof SilgiRouterTypes[T];
|
|
73
87
|
type DefaultMethod<Route extends keyof SilgiRouterTypes> = keyof SilgiRouterTypes[Route];
|
|
74
|
-
type SilgiFetchOptions<Route extends keyof SilgiRouterTypes, Method extends keyof SilgiRouterTypes[Route] =
|
|
88
|
+
type SilgiFetchOptions<Route extends keyof SilgiRouterTypes, Method extends keyof SilgiRouterTypes[Route] = DefaultMethod<Route>> = {
|
|
75
89
|
method?: Method;
|
|
76
90
|
} & RequestBodyOption<Route, Method> & RouterParams<Route, Method> & Omit<FetchOptions, 'query' | 'body' | 'method'>;
|
|
77
|
-
type SilgiFetchClient = <Route extends keyof SilgiRouterTypes, Method extends keyof SilgiRouterTypes[Route] = DefaultMethod<Route>>(url: Route, options?: SilgiFetchOptions<Route, Method>) => Promise<
|
|
78
|
-
|
|
79
|
-
} ? SilgiRouterTypes[Route][Method]['output'] : any>;
|
|
91
|
+
type SilgiFetchClient = <Route extends keyof SilgiRouterTypes, Method extends keyof SilgiRouterTypes[Route] = DefaultMethod<Route>, ResT = FetchResponseData<Route, Method>>(url: Route, options?: SilgiFetchOptions<Route, Method>) => Promise<ResT>;
|
|
92
|
+
declare function silgiFetchRequestInterceptor(ctx: FetchContext): void;
|
|
80
93
|
declare function createSilgiFetch(options: FetchOptions | ((options: FetchOptions) => FetchOptions), localFetch?: typeof globalThis.$fetch): SilgiFetchClient;
|
|
81
94
|
|
|
82
95
|
interface LoadSilgiConfigOptions extends Omit<LoadConfigOptions<SilgiOptions>, 'overrides'> {
|
|
@@ -181,4 +194,4 @@ declare function createSchema<T extends Partial<Record<keyof DefaultNamespaces,
|
|
|
181
194
|
};
|
|
182
195
|
};
|
|
183
196
|
|
|
184
|
-
export { DefaultNamespaces, type ExtendContext, MergedSilgiSchema, type Namespaces, ServiceType, Silgi, SilgiError, SilgiHelper, type SilgiModuleContext, SilgiModuleShared, SilgiOptions, SilgiRouterTypes, SilgiSchema, createResolver, createSchema, createService, createShared, createSilgi, createSilgiFetch, defineSilgiModule, loadSilgiConfig, mergeSchemas, mergeServices, mergeShared, normalizeResult, parseURI, relativeWithDot, silgiCtx, tryUseSilgi, useHook, useShared, useSilgi };
|
|
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 };
|
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 { FetchOptions } from 'ofetch';
|
|
3
|
+
import { FetchError, 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';
|
|
@@ -56,6 +56,19 @@ declare class SilgiError extends Error {
|
|
|
56
56
|
static isSilgiError(error: unknown): error is SilgiError;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
type FetchResponseData<Route extends keyof SilgiRouterTypes, Method extends keyof SilgiRouterTypes[Route]> = SilgiRouterTypes[Route][Method] extends {
|
|
60
|
+
output: any;
|
|
61
|
+
} ? SilgiRouterTypes[Route][Method]['output'] : never;
|
|
62
|
+
type FetchResponseError<T extends Record<string | number, any>> = FetchError;
|
|
63
|
+
type MethodOption<M, P> = 'get' extends keyof P ? {
|
|
64
|
+
method?: M;
|
|
65
|
+
} : {
|
|
66
|
+
method: M;
|
|
67
|
+
};
|
|
68
|
+
type ParamsOption<T> = T extends {
|
|
69
|
+
parameters?: any;
|
|
70
|
+
query?: any;
|
|
71
|
+
} ? T['parameters'] : Record<string, never>;
|
|
59
72
|
type RequestBodyOption<Route extends keyof SilgiRouterTypes, Method extends keyof SilgiRouterTypes[Route]> = SilgiRouterTypes[Route][Method] extends {
|
|
60
73
|
input: any;
|
|
61
74
|
} ? {
|
|
@@ -70,13 +83,13 @@ type RouterParams<Route extends keyof SilgiRouterTypes, Method extends keyof Sil
|
|
|
70
83
|
} : {
|
|
71
84
|
params?: never;
|
|
72
85
|
};
|
|
86
|
+
type FilterMethods<T extends keyof SilgiRouterTypes> = keyof SilgiRouterTypes[T];
|
|
73
87
|
type DefaultMethod<Route extends keyof SilgiRouterTypes> = keyof SilgiRouterTypes[Route];
|
|
74
|
-
type SilgiFetchOptions<Route extends keyof SilgiRouterTypes, Method extends keyof SilgiRouterTypes[Route] =
|
|
88
|
+
type SilgiFetchOptions<Route extends keyof SilgiRouterTypes, Method extends keyof SilgiRouterTypes[Route] = DefaultMethod<Route>> = {
|
|
75
89
|
method?: Method;
|
|
76
90
|
} & RequestBodyOption<Route, Method> & RouterParams<Route, Method> & Omit<FetchOptions, 'query' | 'body' | 'method'>;
|
|
77
|
-
type SilgiFetchClient = <Route extends keyof SilgiRouterTypes, Method extends keyof SilgiRouterTypes[Route] = DefaultMethod<Route>>(url: Route, options?: SilgiFetchOptions<Route, Method>) => Promise<
|
|
78
|
-
|
|
79
|
-
} ? SilgiRouterTypes[Route][Method]['output'] : any>;
|
|
91
|
+
type SilgiFetchClient = <Route extends keyof SilgiRouterTypes, Method extends keyof SilgiRouterTypes[Route] = DefaultMethod<Route>, ResT = FetchResponseData<Route, Method>>(url: Route, options?: SilgiFetchOptions<Route, Method>) => Promise<ResT>;
|
|
92
|
+
declare function silgiFetchRequestInterceptor(ctx: FetchContext): void;
|
|
80
93
|
declare function createSilgiFetch(options: FetchOptions | ((options: FetchOptions) => FetchOptions), localFetch?: typeof globalThis.$fetch): SilgiFetchClient;
|
|
81
94
|
|
|
82
95
|
interface LoadSilgiConfigOptions extends Omit<LoadConfigOptions<SilgiOptions>, 'overrides'> {
|
|
@@ -181,4 +194,4 @@ declare function createSchema<T extends Partial<Record<keyof DefaultNamespaces,
|
|
|
181
194
|
};
|
|
182
195
|
};
|
|
183
196
|
|
|
184
|
-
export { DefaultNamespaces, type ExtendContext, MergedSilgiSchema, type Namespaces, ServiceType, Silgi, SilgiError, SilgiHelper, type SilgiModuleContext, SilgiModuleShared, SilgiOptions, SilgiRouterTypes, SilgiSchema, createResolver, createSchema, createService, createShared, createSilgi, createSilgiFetch, defineSilgiModule, loadSilgiConfig, mergeSchemas, mergeServices, mergeShared, normalizeResult, parseURI, relativeWithDot, silgiCtx, tryUseSilgi, useHook, useShared, useSilgi };
|
|
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 };
|
package/dist/index.mjs
CHANGED
|
@@ -376,6 +376,9 @@ async function createSilgi(config) {
|
|
|
376
376
|
return silgi.options.helper;
|
|
377
377
|
}
|
|
378
378
|
|
|
379
|
+
function silgiFetchRequestInterceptor(ctx) {
|
|
380
|
+
ctx.request = fillPath(ctx.request, ctx.options.path);
|
|
381
|
+
}
|
|
379
382
|
function createSilgiFetch(options, localFetch) {
|
|
380
383
|
return (url, opts = {}) => {
|
|
381
384
|
opts = typeof options === "function" ? options(opts) : { ...options, ...opts };
|
|
@@ -493,4 +496,4 @@ function createSchema(silgiType) {
|
|
|
493
496
|
return silgiType;
|
|
494
497
|
}
|
|
495
498
|
|
|
496
|
-
export { SilgiError, SilgiHelper, createSchema, createService, createShared, createSilgi, createSilgiFetch, defineSilgiModule, mergeSchemas, mergeServices, mergeShared, normalizeResult, parseURI, silgi, silgiCtx, tryUseSilgi, useSilgi };
|
|
499
|
+
export { SilgiError, SilgiHelper, createSchema, createService, createShared, createSilgi, createSilgiFetch, defineSilgiModule, mergeSchemas, mergeServices, mergeShared, normalizeResult, parseURI, silgi, silgiCtx, silgiFetchRequestInterceptor, tryUseSilgi, useSilgi };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "silgi",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.10",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -66,7 +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"
|
|
69
|
+
"zod": "^3.24.1",
|
|
70
|
+
"vue": "^3.5.13"
|
|
70
71
|
},
|
|
71
72
|
"peerDependenciesMeta": {
|
|
72
73
|
"@nuxt/kit": {
|
|
@@ -83,6 +84,9 @@
|
|
|
83
84
|
},
|
|
84
85
|
"zod": {
|
|
85
86
|
"optional": true
|
|
87
|
+
},
|
|
88
|
+
"vue": {
|
|
89
|
+
"optional": true
|
|
86
90
|
}
|
|
87
91
|
},
|
|
88
92
|
"dependencies": {
|
|
@@ -125,6 +129,7 @@
|
|
|
125
129
|
"nuxt": "^3.15.3",
|
|
126
130
|
"unbuild": "^3.3.1",
|
|
127
131
|
"vitest": "^3.0.3",
|
|
132
|
+
"vue": "^3.5.13",
|
|
128
133
|
"zod": "^3.24.1"
|
|
129
134
|
},
|
|
130
135
|
"resolutions": {
|