silgi 0.4.7 → 0.4.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/_chunks/index.mjs +1 -1
- package/dist/ecosystem/nitro/index.mjs +6 -0
- package/dist/ecosystem/nuxt/module.mjs +11 -5
- package/dist/ecosystem/nuxt/runtime/composables/useFetch.d.ts +1 -16
- package/dist/ecosystem/nuxt/runtime/composables/useFetch.mjs +1 -7
- package/dist/meta/index.d.mts +1 -1
- package/dist/meta/index.d.ts +1 -1
- package/dist/runtime/internal/nuxt.d.ts +18 -0
- package/dist/runtime/internal/nuxt.mjs +8 -0
- package/dist/types/index.d.mts +3 -1
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.mjs +6 -0
- package/package.json +1 -1
package/dist/_chunks/index.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
3
3
|
import { resolve, dirname, join } from 'pathe';
|
|
4
4
|
import { loadOptions } from 'silgi/core';
|
|
5
5
|
import { relativeWithDot } from 'silgi/kit';
|
|
6
|
+
import { autoImportTypes } from 'silgi/types';
|
|
6
7
|
|
|
7
8
|
const module = {
|
|
8
9
|
name: "silgi",
|
|
@@ -46,6 +47,11 @@ const module = {
|
|
|
46
47
|
from: "silgi",
|
|
47
48
|
imports: ["silgi"]
|
|
48
49
|
});
|
|
50
|
+
nitro.options.imports.presets.push({
|
|
51
|
+
from: "silgi/type",
|
|
52
|
+
imports: autoImportTypes.map((type) => type),
|
|
53
|
+
type: true
|
|
54
|
+
});
|
|
49
55
|
}
|
|
50
56
|
}
|
|
51
57
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { defineNuxtModule,
|
|
1
|
+
import { defineNuxtModule, addImports } from '@nuxt/kit';
|
|
2
2
|
import { resolvePath } from 'mlly';
|
|
3
3
|
import { join } from 'pathe';
|
|
4
4
|
import { loadOptions } from 'silgi/core';
|
|
5
5
|
import { relativeWithDot } from 'silgi/kit';
|
|
6
|
+
import { autoImportTypes } from 'silgi/types';
|
|
6
7
|
|
|
7
8
|
const module = defineNuxtModule({
|
|
8
9
|
meta: {
|
|
@@ -14,9 +15,6 @@ const module = defineNuxtModule({
|
|
|
14
15
|
},
|
|
15
16
|
defaults: {},
|
|
16
17
|
async setup(options, nuxt) {
|
|
17
|
-
const { resolve } = createResolver(import.meta.url);
|
|
18
|
-
const runtimeDir = resolve("./runtime");
|
|
19
|
-
const composablesDir = resolve(join(runtimeDir, "./composables"));
|
|
20
18
|
const silgi = await loadOptions({});
|
|
21
19
|
nuxt.options.build.transpile.push("silgi");
|
|
22
20
|
nuxt.options.nitro.modules ||= [];
|
|
@@ -24,7 +22,15 @@ const module = defineNuxtModule({
|
|
|
24
22
|
nuxt.hook("prepare:types", ({ references }) => {
|
|
25
23
|
references.push({ path: relativeWithDot(nuxt.options.buildDir, join(silgi.build.dir, "silgi.d.ts")) });
|
|
26
24
|
});
|
|
27
|
-
|
|
25
|
+
nuxt.options.imports.presets.push({
|
|
26
|
+
from: "silgi/types",
|
|
27
|
+
imports: autoImportTypes.map((type) => type),
|
|
28
|
+
type: true
|
|
29
|
+
});
|
|
30
|
+
addImports({
|
|
31
|
+
name: "useSilgiFetch",
|
|
32
|
+
from: "silgi/runtime/internal/nuxt"
|
|
33
|
+
});
|
|
28
34
|
}
|
|
29
35
|
});
|
|
30
36
|
|
|
@@ -1,16 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { FetchError } from 'ofetch';
|
|
3
|
-
import type { SilgiRouterTypes } from 'silgi/types';
|
|
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
|
+
export {};
|
package/dist/meta/index.d.mts
CHANGED
package/dist/meta/index.d.ts
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AvailableRouterMethod } from 'nitropack';
|
|
2
|
+
import type { FetchError } from 'ofetch';
|
|
3
|
+
import type { SilgiRouterTypes } from 'silgi/types';
|
|
4
|
+
import { type AsyncData, type FetchResult, type UseFetchOptions } from 'nuxt/app';
|
|
5
|
+
type RouteString<T extends keyof SilgiRouterTypes> = T | (string & {});
|
|
6
|
+
export type KeysOf<T> = Array<T extends T ? keyof T extends string ? keyof T : never : never>;
|
|
7
|
+
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;
|
|
8
|
+
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 {
|
|
9
|
+
output: any;
|
|
10
|
+
} ? SilgiRouterTypes[ReqT][Method]['output'] : any, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = SilgiRouterTypes[ReqT][Method] extends {
|
|
11
|
+
output: infer T;
|
|
12
|
+
} ? T : never>(url: RouteString<ReqT> | (() => RouteString<ReqT>), options?: Omit<UseFetchOptions<any, any, any, any, ReqT>, 'method' | 'body'> & {
|
|
13
|
+
method?: keyof SilgiRouterTypes[ReqT];
|
|
14
|
+
body?: SilgiRouterTypes[ReqT][Method] extends {
|
|
15
|
+
input: any;
|
|
16
|
+
} ? SilgiRouterTypes[ReqT][Method]['input'] : never;
|
|
17
|
+
}): AsyncData<DefaultT | PickFrom<DataT, PickKeys>, ErrorT | null>;
|
|
18
|
+
export {};
|
package/dist/types/index.d.mts
CHANGED
|
@@ -39,4 +39,6 @@ type Namespaces<T extends BaseNamespaceType> = {
|
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
declare const autoImportTypes: string[];
|
|
43
|
+
|
|
44
|
+
export { type BaseNamespaceType, BaseSchemaType, DefaultNamespaces, type ExtendContext, type GraphQLJSON, type Namespaces, type SilgiModuleContext, SilgiServiceInterface, autoImportTypes };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -39,4 +39,6 @@ type Namespaces<T extends BaseNamespaceType> = {
|
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
declare const autoImportTypes: string[];
|
|
43
|
+
|
|
44
|
+
export { type BaseNamespaceType, BaseSchemaType, DefaultNamespaces, type ExtendContext, type GraphQLJSON, type Namespaces, type SilgiModuleContext, SilgiServiceInterface, autoImportTypes };
|
package/dist/types/index.mjs
CHANGED