silgi 0.7.8 → 0.7.9
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/cli/prepare.mjs +21 -1
- package/dist/cli/types.mjs +1 -1
- package/dist/core/index.d.mts +2 -33
- package/dist/core/index.d.ts +2 -33
- package/dist/core/index.mjs +3 -50
- package/dist/meta/index.d.mts +1 -1
- package/dist/meta/index.d.ts +1 -1
- package/dist/types/index.d.mts +59 -58
- package/dist/types/index.d.ts +59 -58
- package/package.json +13 -38
- package/dist/ecosystem/nitro/index.d.mts +0 -9
- package/dist/ecosystem/nitro/index.d.ts +0 -9
- package/dist/ecosystem/nitro/index.mjs +0 -62
- package/dist/ecosystem/nitro/runtime/plugin.d.ts +0 -3
- package/dist/ecosystem/nitro/runtime/plugin.mjs +0 -2
- package/dist/ecosystem/nuxt/module.d.mts +0 -7
- package/dist/ecosystem/nuxt/module.d.ts +0 -7
- package/dist/ecosystem/nuxt/module.mjs +0 -37
- package/dist/ecosystem/nuxt/runtime/composables/useFetch.d.ts +0 -1
- package/dist/ecosystem/nuxt/runtime/composables/useFetch.mjs +0 -1
package/dist/_chunks/index.mjs
CHANGED
package/dist/cli/prepare.mjs
CHANGED
|
@@ -76,6 +76,25 @@ async function h3Framework(silgi, skip = false) {
|
|
|
76
76
|
""
|
|
77
77
|
);
|
|
78
78
|
});
|
|
79
|
+
silgi.hook("prepare:core.ts", (data) => {
|
|
80
|
+
data._silgiConfigs.push(`captureError: (error, context = {}) => {
|
|
81
|
+
const promise = silgi.hooks
|
|
82
|
+
.callHookParallel('error', error, context)
|
|
83
|
+
.catch((error_) => {
|
|
84
|
+
console.error('Error while capturing another error', error_)
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
if (context.event && isEvent(context.event)) {
|
|
88
|
+
const errors = context.event.context.nitro?.errors
|
|
89
|
+
if (errors) {
|
|
90
|
+
errors.push({ error, context })
|
|
91
|
+
}
|
|
92
|
+
if (context.event.waitUntil) {
|
|
93
|
+
context.event.waitUntil(promise)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}`);
|
|
97
|
+
});
|
|
79
98
|
}
|
|
80
99
|
|
|
81
100
|
async function nitroFramework(silgi, skip = false) {
|
|
@@ -215,6 +234,7 @@ async function readCoreFile(silgi) {
|
|
|
215
234
|
debug: silgi.options.debug,
|
|
216
235
|
alias: silgi.options.alias
|
|
217
236
|
});
|
|
237
|
+
console.log("injectedResult", silgi.options.conditions);
|
|
218
238
|
const coreFile = await jiti.evalModule(
|
|
219
239
|
injectedResult.code,
|
|
220
240
|
{
|
|
@@ -652,7 +672,7 @@ async function silgiCoreFile(data, frameworkContext, silgi) {
|
|
|
652
672
|
" uris,",
|
|
653
673
|
" modulesURIs,",
|
|
654
674
|
` plugins: [${plugins.join(", ")}],`,
|
|
655
|
-
_silgiConfigs.length > 0 ? ` ${_silgiConfigs.map((config) => Object.entries(config).map(([key, value]) => `${key}: ${value}`)).join(",\n ")},` : "",
|
|
675
|
+
_silgiConfigs.length > 0 ? ` ${_silgiConfigs.map((config) => typeof config === "string" ? config : typeof config === "object" ? Object.entries(config).map(([key, value]) => `${key}: ${value}`).join(",\n ") : "").join(",\n ")},` : "",
|
|
656
676
|
" ...buildOptions,",
|
|
657
677
|
" options: {",
|
|
658
678
|
` present: '${silgi.options.preset}',`,
|
package/dist/cli/types.mjs
CHANGED
|
@@ -433,7 +433,7 @@ async function resolvePathOptions(options) {
|
|
|
433
433
|
}
|
|
434
434
|
}
|
|
435
435
|
const modulesRuntimePaths = {};
|
|
436
|
-
if (options.
|
|
436
|
+
if (options.preset === "npm-package") {
|
|
437
437
|
for (let i of options.modules) {
|
|
438
438
|
if (typeof i === "string") {
|
|
439
439
|
i = resolveAlias(i, options.alias);
|
package/dist/core/index.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { SilgiConfig, Silgi,
|
|
2
|
-
import { FetchOptions } from 'ofetch';
|
|
1
|
+
import { SilgiConfig, Silgi, SilgiOperation, MergedSilgiSchema, ServiceType, SilgiSchema, RequiredServiceType, ModuleRuntimeShared, SilgiEvents, DefaultNamespaces, BaseSchemaType, SilgiCLI } from 'silgi/types';
|
|
3
2
|
export { c as createStorage, s as silgi, u as useSilgiStorage } from '../shared/silgi.BuspmWeq.mjs';
|
|
4
3
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
5
4
|
import * as unctx from 'unctx';
|
|
@@ -7,36 +6,6 @@ import 'unstorage';
|
|
|
7
6
|
|
|
8
7
|
declare function createSilgi(config: SilgiConfig): Promise<Silgi>;
|
|
9
8
|
|
|
10
|
-
type TrimAfterFourSlashes<T extends string> = T extends `/${infer S1}/${infer S2}/${infer S3}/${infer S4}/${infer _}` ? `/${S1}/${S2}/${S3}/${S4}` : T;
|
|
11
|
-
type AllPaths = SilgiRouterTypes extends {
|
|
12
|
-
keys: infer U;
|
|
13
|
-
} ? keyof U extends never ? string : keyof U : string;
|
|
14
|
-
type ExtractPathParams<T extends string> = T extends `${infer _Start}:${infer Param}/${infer Rest}` ? {
|
|
15
|
-
[K in Param]: string;
|
|
16
|
-
} & ExtractPathParams<Rest> : T extends `${infer _Start}:${infer Param}` ? {
|
|
17
|
-
[K in Param]: string;
|
|
18
|
-
} : object;
|
|
19
|
-
type ValidRoute = AllPaths | (string & {});
|
|
20
|
-
type Method<R extends ValidRoute> = TrimAfterFourSlashes<R> extends keyof SilgiRouterTypes ? keyof SilgiRouterTypes[TrimAfterFourSlashes<R>] : never;
|
|
21
|
-
type FetchResponseData<R extends ValidRoute, M extends Method<R>> = TrimAfterFourSlashes<R> extends keyof SilgiRouterTypes ? SilgiRouterTypes[TrimAfterFourSlashes<R>][M]['output'] : never;
|
|
22
|
-
type RequestBodyOption<R extends ValidRoute, M extends Method<R>> = TrimAfterFourSlashes<R> extends keyof SilgiRouterTypes ? SilgiRouterTypes[TrimAfterFourSlashes<R>][M] extends {
|
|
23
|
-
input: infer I;
|
|
24
|
-
} ? {
|
|
25
|
-
body: I;
|
|
26
|
-
} : {
|
|
27
|
-
body?: never;
|
|
28
|
-
} : never;
|
|
29
|
-
type RouterParams<R extends ValidRoute> = ExtractPathParams<R>;
|
|
30
|
-
type SilgiFetchOptions<R extends ValidRoute, M extends Method<R>> = {
|
|
31
|
-
method: M;
|
|
32
|
-
} & RequestBodyOption<R, M> & (RouterParams<R> extends object ? {
|
|
33
|
-
params?: RouterParams<R>;
|
|
34
|
-
} : {
|
|
35
|
-
params?: never;
|
|
36
|
-
}) & Omit<FetchOptions, 'query' | 'body' | 'method'>;
|
|
37
|
-
type SilgiFetchClient = <R extends ValidRoute, M extends Method<R> = 'get' extends Method<R> ? 'get' : Method<R>>(url: R, options: SilgiFetchOptions<R, M>) => Promise<FetchResponseData<R, M>>;
|
|
38
|
-
declare function createSilgiFetch(options: FetchOptions | ((options: FetchOptions) => FetchOptions), localFetch?: typeof globalThis.$fetch): SilgiFetchClient;
|
|
39
|
-
|
|
40
9
|
interface RouteTemplateValidator {
|
|
41
10
|
(value: string): boolean;
|
|
42
11
|
}
|
|
@@ -284,4 +253,4 @@ declare function useSilgiCLI(): SilgiCLI;
|
|
|
284
253
|
*/
|
|
285
254
|
declare function tryUseSilgiCLI(): SilgiCLI | null;
|
|
286
255
|
|
|
287
|
-
export { type BaseError, ErrorCategory, ErrorFactory, type ErrorMetadata, ErrorSeverity, HttpStatus, SilgiError, createSchema, createService, createShared, createSilgi,
|
|
256
|
+
export { type BaseError, ErrorCategory, ErrorFactory, type ErrorMetadata, ErrorSeverity, HttpStatus, SilgiError, createSchema, createService, createShared, createSilgi, getEvent, isBaseError, mergeSchemas, mergeServices, mergeShared, parseURI, silgiCLICtx, silgiCtx, tryUseSilgi, tryUseSilgiCLI, useSilgi, useSilgiCLI };
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { SilgiConfig, Silgi,
|
|
2
|
-
import { FetchOptions } from 'ofetch';
|
|
1
|
+
import { SilgiConfig, Silgi, SilgiOperation, MergedSilgiSchema, ServiceType, SilgiSchema, RequiredServiceType, ModuleRuntimeShared, SilgiEvents, DefaultNamespaces, BaseSchemaType, SilgiCLI } from 'silgi/types';
|
|
3
2
|
export { c as createStorage, s as silgi, u as useSilgiStorage } from '../shared/silgi.BuspmWeq.js';
|
|
4
3
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
5
4
|
import * as unctx from 'unctx';
|
|
@@ -7,36 +6,6 @@ import 'unstorage';
|
|
|
7
6
|
|
|
8
7
|
declare function createSilgi(config: SilgiConfig): Promise<Silgi>;
|
|
9
8
|
|
|
10
|
-
type TrimAfterFourSlashes<T extends string> = T extends `/${infer S1}/${infer S2}/${infer S3}/${infer S4}/${infer _}` ? `/${S1}/${S2}/${S3}/${S4}` : T;
|
|
11
|
-
type AllPaths = SilgiRouterTypes extends {
|
|
12
|
-
keys: infer U;
|
|
13
|
-
} ? keyof U extends never ? string : keyof U : string;
|
|
14
|
-
type ExtractPathParams<T extends string> = T extends `${infer _Start}:${infer Param}/${infer Rest}` ? {
|
|
15
|
-
[K in Param]: string;
|
|
16
|
-
} & ExtractPathParams<Rest> : T extends `${infer _Start}:${infer Param}` ? {
|
|
17
|
-
[K in Param]: string;
|
|
18
|
-
} : object;
|
|
19
|
-
type ValidRoute = AllPaths | (string & {});
|
|
20
|
-
type Method<R extends ValidRoute> = TrimAfterFourSlashes<R> extends keyof SilgiRouterTypes ? keyof SilgiRouterTypes[TrimAfterFourSlashes<R>] : never;
|
|
21
|
-
type FetchResponseData<R extends ValidRoute, M extends Method<R>> = TrimAfterFourSlashes<R> extends keyof SilgiRouterTypes ? SilgiRouterTypes[TrimAfterFourSlashes<R>][M]['output'] : never;
|
|
22
|
-
type RequestBodyOption<R extends ValidRoute, M extends Method<R>> = TrimAfterFourSlashes<R> extends keyof SilgiRouterTypes ? SilgiRouterTypes[TrimAfterFourSlashes<R>][M] extends {
|
|
23
|
-
input: infer I;
|
|
24
|
-
} ? {
|
|
25
|
-
body: I;
|
|
26
|
-
} : {
|
|
27
|
-
body?: never;
|
|
28
|
-
} : never;
|
|
29
|
-
type RouterParams<R extends ValidRoute> = ExtractPathParams<R>;
|
|
30
|
-
type SilgiFetchOptions<R extends ValidRoute, M extends Method<R>> = {
|
|
31
|
-
method: M;
|
|
32
|
-
} & RequestBodyOption<R, M> & (RouterParams<R> extends object ? {
|
|
33
|
-
params?: RouterParams<R>;
|
|
34
|
-
} : {
|
|
35
|
-
params?: never;
|
|
36
|
-
}) & Omit<FetchOptions, 'query' | 'body' | 'method'>;
|
|
37
|
-
type SilgiFetchClient = <R extends ValidRoute, M extends Method<R> = 'get' extends Method<R> ? 'get' : Method<R>>(url: R, options: SilgiFetchOptions<R, M>) => Promise<FetchResponseData<R, M>>;
|
|
38
|
-
declare function createSilgiFetch(options: FetchOptions | ((options: FetchOptions) => FetchOptions), localFetch?: typeof globalThis.$fetch): SilgiFetchClient;
|
|
39
|
-
|
|
40
9
|
interface RouteTemplateValidator {
|
|
41
10
|
(value: string): boolean;
|
|
42
11
|
}
|
|
@@ -284,4 +253,4 @@ declare function useSilgiCLI(): SilgiCLI;
|
|
|
284
253
|
*/
|
|
285
254
|
declare function tryUseSilgiCLI(): SilgiCLI | null;
|
|
286
255
|
|
|
287
|
-
export { type BaseError, ErrorCategory, ErrorFactory, type ErrorMetadata, ErrorSeverity, HttpStatus, SilgiError, createSchema, createService, createShared, createSilgi,
|
|
256
|
+
export { type BaseError, ErrorCategory, ErrorFactory, type ErrorMetadata, ErrorSeverity, HttpStatus, SilgiError, createSchema, createService, createShared, createSilgi, getEvent, isBaseError, mergeSchemas, mergeServices, mergeShared, parseURI, silgiCLICtx, silgiCtx, tryUseSilgi, tryUseSilgiCLI, useSilgi, useSilgiCLI };
|
package/dist/core/index.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createConsola } from 'consola';
|
|
2
2
|
import defu from 'defu';
|
|
3
|
-
import { isEvent } from 'h3';
|
|
4
3
|
import { createHooks } from 'hookable';
|
|
5
4
|
import { defineUntypedSchema, applyDefaults } from 'untyped';
|
|
6
5
|
import { isDebug, isTest, isDevelopment } from 'std-env';
|
|
@@ -574,20 +573,8 @@ async function createSilgi(config) {
|
|
|
574
573
|
logger: createConsola(defu(config.options.consolaOptions, {
|
|
575
574
|
tag: "silgi"
|
|
576
575
|
})).withTag("silgi"),
|
|
577
|
-
captureError:
|
|
578
|
-
|
|
579
|
-
console.error("Error while capturing another error", error_);
|
|
580
|
-
});
|
|
581
|
-
if (context.event && isEvent(context.event)) {
|
|
582
|
-
const errors = context.event.context.nitro?.errors;
|
|
583
|
-
if (errors) {
|
|
584
|
-
errors.push({ error, context });
|
|
585
|
-
}
|
|
586
|
-
if (context.event.waitUntil) {
|
|
587
|
-
context.event.waitUntil(promise);
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
}
|
|
576
|
+
captureError: config.captureError ?? (() => {
|
|
577
|
+
})
|
|
591
578
|
};
|
|
592
579
|
await runSilgiPlugins(silgi);
|
|
593
580
|
await scanAction(silgi);
|
|
@@ -612,40 +599,6 @@ async function createSilgi(config) {
|
|
|
612
599
|
return silgi;
|
|
613
600
|
}
|
|
614
601
|
|
|
615
|
-
function createSilgiFetch(options, localFetch) {
|
|
616
|
-
return (url, opts) => {
|
|
617
|
-
const finalOpts = {
|
|
618
|
-
...typeof options === "function" ? options(opts) : options,
|
|
619
|
-
...opts,
|
|
620
|
-
method: opts.method || "get"
|
|
621
|
-
};
|
|
622
|
-
const $fetch = getFetch(url, finalOpts, localFetch);
|
|
623
|
-
return $fetch(fillPath(url, opts.params), finalOpts);
|
|
624
|
-
};
|
|
625
|
-
}
|
|
626
|
-
function getFetch(url, opts, localFetch) {
|
|
627
|
-
if (import.meta.server && localFetch) {
|
|
628
|
-
const isLocalFetch = url[0] === "/" && (!opts.baseURL || opts.baseURL[0] === "/");
|
|
629
|
-
if (isLocalFetch)
|
|
630
|
-
return localFetch;
|
|
631
|
-
}
|
|
632
|
-
return globalThis.$fetch;
|
|
633
|
-
}
|
|
634
|
-
function fillPath(path, params) {
|
|
635
|
-
if (!params) {
|
|
636
|
-
if (path.includes(":"))
|
|
637
|
-
throw new Error("Parametreler dogru kullanmal\u0131s\u0131n\u0131z");
|
|
638
|
-
return path;
|
|
639
|
-
}
|
|
640
|
-
if (!path.includes(":"))
|
|
641
|
-
throw new Error("Path parametler : ile belirtilmelidir");
|
|
642
|
-
let result = path;
|
|
643
|
-
for (const [key, value] of Object.entries(params)) {
|
|
644
|
-
result = result.replace(`:${key}`, value);
|
|
645
|
-
}
|
|
646
|
-
return result;
|
|
647
|
-
}
|
|
648
|
-
|
|
649
602
|
function silgi(event) {
|
|
650
603
|
return {
|
|
651
604
|
execute: (uriString, input) => {
|
|
@@ -806,4 +759,4 @@ function tryUseSilgiCLI() {
|
|
|
806
759
|
return silgiCLICtx.tryUse();
|
|
807
760
|
}
|
|
808
761
|
|
|
809
|
-
export { ErrorCategory, ErrorFactory, ErrorSeverity, HttpStatus, SilgiError, createSchema, createService, createShared, createSilgi,
|
|
762
|
+
export { ErrorCategory, ErrorFactory, ErrorSeverity, HttpStatus, SilgiError, createSchema, createService, createShared, createSilgi, createStorage, getEvent, isBaseError, mergeSchemas, mergeServices, mergeShared, parseURI, silgi, silgiCLICtx, silgiCtx, tryUseSilgi, tryUseSilgiCLI, useSilgi, useSilgiCLI, useSilgiStorage };
|
package/dist/meta/index.d.mts
CHANGED
package/dist/meta/index.d.ts
CHANGED
package/dist/types/index.d.mts
CHANGED
|
@@ -725,6 +725,40 @@ interface LoadConfigOptions {
|
|
|
725
725
|
compatibilityDate?: CompatibilityDateSpec;
|
|
726
726
|
}
|
|
727
727
|
|
|
728
|
+
/**
|
|
729
|
+
* The listeners to Silgi
|
|
730
|
+
*/
|
|
731
|
+
interface SilgiRuntimeHooks {
|
|
732
|
+
/**
|
|
733
|
+
* Called after Silgi initialization, when the Silgi instance is ready to work.
|
|
734
|
+
* @param silgi The configured Silgi object
|
|
735
|
+
* @returns Promise
|
|
736
|
+
*/
|
|
737
|
+
'ready': (silgi: Silgi) => HookResult;
|
|
738
|
+
/**
|
|
739
|
+
* Called when silgi instance is gracefully closing.
|
|
740
|
+
* @param silgi The configured silgi object
|
|
741
|
+
* @returns Promise
|
|
742
|
+
*/
|
|
743
|
+
'close': (silgi: Silgi) => HookResult;
|
|
744
|
+
'app:setup:start': (silgi: Silgi) => HookResult;
|
|
745
|
+
'action:before': (context: ModuleHookContext) => HookResult;
|
|
746
|
+
'action:after': (context: ModuleHookContext) => HookResult;
|
|
747
|
+
'action:error': (context: ModuleHookContext) => HookResult;
|
|
748
|
+
'action:finally': (context: ModuleHookContext) => HookResult;
|
|
749
|
+
'event:before': (event: SilgiEvents) => HookResult;
|
|
750
|
+
'error': CaptureError;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
interface SilgiShareds extends ModuleRuntimeShared {
|
|
754
|
+
storage: (...data: Parameters<typeof useSilgiStorage>) => ReturnType<typeof useSilgiStorage>;
|
|
755
|
+
silgi: SilgiFunction;
|
|
756
|
+
}
|
|
757
|
+
interface ModuleRuntimeShared {
|
|
758
|
+
}
|
|
759
|
+
interface ExtendShared {
|
|
760
|
+
}
|
|
761
|
+
|
|
728
762
|
type CustomDriverName = string & {
|
|
729
763
|
_custom?: any;
|
|
730
764
|
};
|
|
@@ -751,43 +785,6 @@ interface StorageKeyParams<TInput = unknown> {
|
|
|
751
785
|
storageOptions?: Pick<StorageConfig<TInput>, 'base' | 'options' | 'scope'>;
|
|
752
786
|
}
|
|
753
787
|
|
|
754
|
-
interface SilgiOptions {
|
|
755
|
-
consolaOptions?: Partial<ConsolaOptions>;
|
|
756
|
-
present: PresetNameInput;
|
|
757
|
-
/**
|
|
758
|
-
* Set to `true` to enable debug mode.
|
|
759
|
-
*
|
|
760
|
-
* At the moment, it prints out hook names and timings on the server, and logs hook arguments as well in the browser.
|
|
761
|
-
*
|
|
762
|
-
* @default false
|
|
763
|
-
*/
|
|
764
|
-
debug: boolean;
|
|
765
|
-
storage: StorageMounts;
|
|
766
|
-
[key: string]: any;
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
interface SilgiRuntimeContext extends Record<string, any> {
|
|
770
|
-
}
|
|
771
|
-
interface ExtendContext {
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
interface GraphQLJSON {
|
|
775
|
-
queries: any;
|
|
776
|
-
mutations: any;
|
|
777
|
-
types: any;
|
|
778
|
-
inputs: any;
|
|
779
|
-
references: any;
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
interface SilgiShareds extends ModuleRuntimeShared {
|
|
783
|
-
storage: (...data: Parameters<typeof useSilgiStorage>) => ReturnType<typeof useSilgiStorage>;
|
|
784
|
-
silgi: SilgiFunction;
|
|
785
|
-
}
|
|
786
|
-
interface ModuleRuntimeShared {
|
|
787
|
-
}
|
|
788
|
-
interface ExtendShared {
|
|
789
|
-
}
|
|
790
|
-
|
|
791
788
|
interface MethodSchemaType<Input, Output> {
|
|
792
789
|
default: {
|
|
793
790
|
input?: Input;
|
|
@@ -902,29 +899,33 @@ interface CapturedErrorContext {
|
|
|
902
899
|
}
|
|
903
900
|
type CaptureError = (error: Error, context: CapturedErrorContext) => void;
|
|
904
901
|
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
interface SilgiRuntimeHooks {
|
|
909
|
-
/**
|
|
910
|
-
* Called after Silgi initialization, when the Silgi instance is ready to work.
|
|
911
|
-
* @param silgi The configured Silgi object
|
|
912
|
-
* @returns Promise
|
|
913
|
-
*/
|
|
914
|
-
'ready': (silgi: Silgi) => HookResult;
|
|
902
|
+
interface SilgiOptions {
|
|
903
|
+
consolaOptions?: Partial<ConsolaOptions>;
|
|
904
|
+
present: PresetNameInput;
|
|
915
905
|
/**
|
|
916
|
-
*
|
|
917
|
-
*
|
|
918
|
-
*
|
|
906
|
+
* Set to `true` to enable debug mode.
|
|
907
|
+
*
|
|
908
|
+
* At the moment, it prints out hook names and timings on the server, and logs hook arguments as well in the browser.
|
|
909
|
+
*
|
|
910
|
+
* @default false
|
|
919
911
|
*/
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
912
|
+
debug: boolean;
|
|
913
|
+
storage: StorageMounts;
|
|
914
|
+
captureError: CaptureError;
|
|
915
|
+
[key: string]: any;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
interface SilgiRuntimeContext extends Record<string, any> {
|
|
919
|
+
}
|
|
920
|
+
interface ExtendContext {
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
interface GraphQLJSON {
|
|
924
|
+
queries: any;
|
|
925
|
+
mutations: any;
|
|
926
|
+
types: any;
|
|
927
|
+
inputs: any;
|
|
928
|
+
references: any;
|
|
928
929
|
}
|
|
929
930
|
|
|
930
931
|
interface BaseNamespaceType extends Record<keyof DefaultNamespaces, Record<string, BaseSchemaType<StandardSchemaV1>>> {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -725,6 +725,40 @@ interface LoadConfigOptions {
|
|
|
725
725
|
compatibilityDate?: CompatibilityDateSpec;
|
|
726
726
|
}
|
|
727
727
|
|
|
728
|
+
/**
|
|
729
|
+
* The listeners to Silgi
|
|
730
|
+
*/
|
|
731
|
+
interface SilgiRuntimeHooks {
|
|
732
|
+
/**
|
|
733
|
+
* Called after Silgi initialization, when the Silgi instance is ready to work.
|
|
734
|
+
* @param silgi The configured Silgi object
|
|
735
|
+
* @returns Promise
|
|
736
|
+
*/
|
|
737
|
+
'ready': (silgi: Silgi) => HookResult;
|
|
738
|
+
/**
|
|
739
|
+
* Called when silgi instance is gracefully closing.
|
|
740
|
+
* @param silgi The configured silgi object
|
|
741
|
+
* @returns Promise
|
|
742
|
+
*/
|
|
743
|
+
'close': (silgi: Silgi) => HookResult;
|
|
744
|
+
'app:setup:start': (silgi: Silgi) => HookResult;
|
|
745
|
+
'action:before': (context: ModuleHookContext) => HookResult;
|
|
746
|
+
'action:after': (context: ModuleHookContext) => HookResult;
|
|
747
|
+
'action:error': (context: ModuleHookContext) => HookResult;
|
|
748
|
+
'action:finally': (context: ModuleHookContext) => HookResult;
|
|
749
|
+
'event:before': (event: SilgiEvents) => HookResult;
|
|
750
|
+
'error': CaptureError;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
interface SilgiShareds extends ModuleRuntimeShared {
|
|
754
|
+
storage: (...data: Parameters<typeof useSilgiStorage>) => ReturnType<typeof useSilgiStorage>;
|
|
755
|
+
silgi: SilgiFunction;
|
|
756
|
+
}
|
|
757
|
+
interface ModuleRuntimeShared {
|
|
758
|
+
}
|
|
759
|
+
interface ExtendShared {
|
|
760
|
+
}
|
|
761
|
+
|
|
728
762
|
type CustomDriverName = string & {
|
|
729
763
|
_custom?: any;
|
|
730
764
|
};
|
|
@@ -751,43 +785,6 @@ interface StorageKeyParams<TInput = unknown> {
|
|
|
751
785
|
storageOptions?: Pick<StorageConfig<TInput>, 'base' | 'options' | 'scope'>;
|
|
752
786
|
}
|
|
753
787
|
|
|
754
|
-
interface SilgiOptions {
|
|
755
|
-
consolaOptions?: Partial<ConsolaOptions>;
|
|
756
|
-
present: PresetNameInput;
|
|
757
|
-
/**
|
|
758
|
-
* Set to `true` to enable debug mode.
|
|
759
|
-
*
|
|
760
|
-
* At the moment, it prints out hook names and timings on the server, and logs hook arguments as well in the browser.
|
|
761
|
-
*
|
|
762
|
-
* @default false
|
|
763
|
-
*/
|
|
764
|
-
debug: boolean;
|
|
765
|
-
storage: StorageMounts;
|
|
766
|
-
[key: string]: any;
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
interface SilgiRuntimeContext extends Record<string, any> {
|
|
770
|
-
}
|
|
771
|
-
interface ExtendContext {
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
interface GraphQLJSON {
|
|
775
|
-
queries: any;
|
|
776
|
-
mutations: any;
|
|
777
|
-
types: any;
|
|
778
|
-
inputs: any;
|
|
779
|
-
references: any;
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
interface SilgiShareds extends ModuleRuntimeShared {
|
|
783
|
-
storage: (...data: Parameters<typeof useSilgiStorage>) => ReturnType<typeof useSilgiStorage>;
|
|
784
|
-
silgi: SilgiFunction;
|
|
785
|
-
}
|
|
786
|
-
interface ModuleRuntimeShared {
|
|
787
|
-
}
|
|
788
|
-
interface ExtendShared {
|
|
789
|
-
}
|
|
790
|
-
|
|
791
788
|
interface MethodSchemaType<Input, Output> {
|
|
792
789
|
default: {
|
|
793
790
|
input?: Input;
|
|
@@ -902,29 +899,33 @@ interface CapturedErrorContext {
|
|
|
902
899
|
}
|
|
903
900
|
type CaptureError = (error: Error, context: CapturedErrorContext) => void;
|
|
904
901
|
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
interface SilgiRuntimeHooks {
|
|
909
|
-
/**
|
|
910
|
-
* Called after Silgi initialization, when the Silgi instance is ready to work.
|
|
911
|
-
* @param silgi The configured Silgi object
|
|
912
|
-
* @returns Promise
|
|
913
|
-
*/
|
|
914
|
-
'ready': (silgi: Silgi) => HookResult;
|
|
902
|
+
interface SilgiOptions {
|
|
903
|
+
consolaOptions?: Partial<ConsolaOptions>;
|
|
904
|
+
present: PresetNameInput;
|
|
915
905
|
/**
|
|
916
|
-
*
|
|
917
|
-
*
|
|
918
|
-
*
|
|
906
|
+
* Set to `true` to enable debug mode.
|
|
907
|
+
*
|
|
908
|
+
* At the moment, it prints out hook names and timings on the server, and logs hook arguments as well in the browser.
|
|
909
|
+
*
|
|
910
|
+
* @default false
|
|
919
911
|
*/
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
912
|
+
debug: boolean;
|
|
913
|
+
storage: StorageMounts;
|
|
914
|
+
captureError: CaptureError;
|
|
915
|
+
[key: string]: any;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
interface SilgiRuntimeContext extends Record<string, any> {
|
|
919
|
+
}
|
|
920
|
+
interface ExtendContext {
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
interface GraphQLJSON {
|
|
924
|
+
queries: any;
|
|
925
|
+
mutations: any;
|
|
926
|
+
types: any;
|
|
927
|
+
inputs: any;
|
|
928
|
+
references: any;
|
|
928
929
|
}
|
|
929
930
|
|
|
930
931
|
interface BaseNamespaceType extends Record<keyof DefaultNamespaces, Record<string, BaseSchemaType<StandardSchemaV1>>> {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "silgi",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.9",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"exports": {
|
|
@@ -21,24 +21,6 @@
|
|
|
21
21
|
"types": "./dist/core/index.d.ts",
|
|
22
22
|
"import": "./dist/core/index.mjs"
|
|
23
23
|
},
|
|
24
|
-
"./ecosystem/nitro": {
|
|
25
|
-
"types": "./dist/ecosystem/nitro/index.d.ts",
|
|
26
|
-
"import": "./dist/ecosystem/nitro/index.mjs"
|
|
27
|
-
},
|
|
28
|
-
"./ecosystem/nitro/runtime/*": {
|
|
29
|
-
"types": "./dist/ecosystem/nitro/runtime/*.d.ts",
|
|
30
|
-
"import": "./dist/ecosystem/nitro/runtime/*.mjs"
|
|
31
|
-
},
|
|
32
|
-
"./ecosystem/nuxt/runtime/*": {
|
|
33
|
-
"silgi": "./dist/ecosystem/nuxt/runtime/**/*.ts",
|
|
34
|
-
"silgiTypes": "./dist/ecosystem/nuxt/runtime/**/*.ts",
|
|
35
|
-
"types": "./dist/ecosystem/nuxt/runtime/*.d.ts",
|
|
36
|
-
"import": "./dist/ecosystem/nuxt/runtime/*.mjs"
|
|
37
|
-
},
|
|
38
|
-
"./nuxt": {
|
|
39
|
-
"types": "./dist/ecosystem/nuxt/module.d.ts",
|
|
40
|
-
"import": "./dist/ecosystem/nuxt/module.mjs"
|
|
41
|
-
},
|
|
42
24
|
"./meta": {
|
|
43
25
|
"types": "./dist/meta/index.d.ts",
|
|
44
26
|
"import": "./dist/meta/index.mjs"
|
|
@@ -76,8 +58,6 @@
|
|
|
76
58
|
"import": "./dist/runtime/*.mjs"
|
|
77
59
|
},
|
|
78
60
|
"./dist/runtime/*": {
|
|
79
|
-
"silgi": "./dist/runtime/*.ts",
|
|
80
|
-
"silgiTypes": "./dist/runtime/*.ts",
|
|
81
61
|
"types": "./dist/runtime/*.d.ts",
|
|
82
62
|
"import": "./dist/runtime/*.mjs"
|
|
83
63
|
},
|
|
@@ -97,6 +77,7 @@
|
|
|
97
77
|
],
|
|
98
78
|
"peerDependencies": {
|
|
99
79
|
"@nuxt/kit": "^3.15.3",
|
|
80
|
+
"@nuxt/schema": "^3.15.4",
|
|
100
81
|
"h3": "^1.14.0",
|
|
101
82
|
"nitropack": "^2.10.4",
|
|
102
83
|
"nuxt": "^3.15.3",
|
|
@@ -108,6 +89,9 @@
|
|
|
108
89
|
"@nuxt/kit": {
|
|
109
90
|
"optional": true
|
|
110
91
|
},
|
|
92
|
+
"@nuxt/schema": {
|
|
93
|
+
"optional": true
|
|
94
|
+
},
|
|
111
95
|
"h3": {
|
|
112
96
|
"optional": true
|
|
113
97
|
},
|
|
@@ -125,8 +109,6 @@
|
|
|
125
109
|
}
|
|
126
110
|
},
|
|
127
111
|
"dependencies": {
|
|
128
|
-
"@antfu/eslint-config": "^4.2.0",
|
|
129
|
-
"@nuxt/schema": "^3.15.4",
|
|
130
112
|
"@oxc-parser/wasm": "^0.49.0",
|
|
131
113
|
"@standard-schema/spec": "^1.0.0",
|
|
132
114
|
"c12": "^2.0.1",
|
|
@@ -138,8 +120,6 @@
|
|
|
138
120
|
"dev-jiti": "^2.4.2",
|
|
139
121
|
"dot-prop": "^9.0.0",
|
|
140
122
|
"escape-string-regexp": "^5.0.0",
|
|
141
|
-
"eslint": "^9.20.0",
|
|
142
|
-
"esno": "^4.8.0",
|
|
143
123
|
"globby": "^14.1.0",
|
|
144
124
|
"hookable": "^5.5.3",
|
|
145
125
|
"ignore": "^7.0.3",
|
|
@@ -153,8 +133,6 @@
|
|
|
153
133
|
"scule": "^1.3.0",
|
|
154
134
|
"semver": "^7.7.1",
|
|
155
135
|
"std-env": "^3.8.0",
|
|
156
|
-
"tsconfck": "^3.1.5",
|
|
157
|
-
"typescript": "^5.7.3",
|
|
158
136
|
"ufo": "^1.5.4",
|
|
159
137
|
"unctx": "^2.4.1",
|
|
160
138
|
"unimport": "^4.1.1",
|
|
@@ -162,23 +140,23 @@
|
|
|
162
140
|
"untyped": "^1.5.2"
|
|
163
141
|
},
|
|
164
142
|
"devDependencies": {
|
|
143
|
+
"@antfu/eslint-config": "^4.2.0",
|
|
165
144
|
"@nuxt/kit": "^3.15.4",
|
|
145
|
+
"@nuxt/schema": "^3.15.4",
|
|
166
146
|
"@types/node": "^22.13.1",
|
|
167
147
|
"@types/semver": "^7.5.8",
|
|
168
148
|
"@vitest/coverage-v8": "3.0.5",
|
|
149
|
+
"eslint": "^9.20.0",
|
|
169
150
|
"h3": "^1.15.0",
|
|
170
151
|
"nitropack": "^2.10.4",
|
|
171
152
|
"nuxt": "^3.15.4",
|
|
153
|
+
"typescript": "^5.7.3",
|
|
172
154
|
"unbuild": "^3.3.1",
|
|
173
155
|
"vitest": "^3.0.5",
|
|
174
156
|
"vue": "^3.5.13",
|
|
175
157
|
"zod": "^3.24.1"
|
|
176
158
|
},
|
|
177
159
|
"resolutions": {
|
|
178
|
-
"@silgi/openapi": "workspace:^",
|
|
179
|
-
"@silgi/permission": "workspace:^",
|
|
180
|
-
"@silgi/scalar": "workspace:^",
|
|
181
|
-
"@silgi/yoga": "workspace:^",
|
|
182
160
|
"silgi": "link:."
|
|
183
161
|
},
|
|
184
162
|
"publishConfig": {
|
|
@@ -186,12 +164,9 @@
|
|
|
186
164
|
},
|
|
187
165
|
"scripts": {
|
|
188
166
|
"build:package": "unbuild",
|
|
189
|
-
"build": "pnpm gen-presets && pnpm
|
|
190
|
-
"build:
|
|
191
|
-
"
|
|
192
|
-
"build:builder": "pnpm --filter './module-builder' build",
|
|
193
|
-
"build:prepare": "pnpm build:stub && pnpm --filter './module-builder' build:stub --stub && pnpm prepare:modules",
|
|
194
|
-
"build:stub": "pnpm gen-presets && unbuild --stub && pnpm --filter './module-builder' build:stub && pnpm --filter './modules/*' build:stub",
|
|
167
|
+
"build": "pnpm gen-presets && pnpm install && pnpm build:package",
|
|
168
|
+
"build:prepare": "pnpm build:stub",
|
|
169
|
+
"build:stub": "pnpm gen-presets && unbuild --stub",
|
|
195
170
|
"dev:k6": "k6 run ./__tests__/k6.js",
|
|
196
171
|
"test": "vitest",
|
|
197
172
|
"test:coverage": "vitest run --coverage.enabled true",
|
|
@@ -199,7 +174,7 @@
|
|
|
199
174
|
"lint:fix": "eslint . --fix",
|
|
200
175
|
"silgi": "tsx cli/index.ts",
|
|
201
176
|
"pb": "pnpm unbuild && pnpm publish --no-git-checks --access public",
|
|
202
|
-
"generate": "pnpm --filter './
|
|
177
|
+
"generate": "pnpm --filter './examples/**' silgi:prepare",
|
|
203
178
|
"gen-presets": "pnpm jiti scripts/gen-presets.ts",
|
|
204
179
|
"all:delete": "find . -type d \\( -name \"node_modules\" -o -name \"dist\" \\) -prune -exec rm -rf {} +"
|
|
205
180
|
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { execSync } from 'node:child_process';
|
|
2
|
-
import { fileURLToPath } from 'node:url';
|
|
3
|
-
import { resolve, dirname, join } from 'pathe';
|
|
4
|
-
import { loadOptions } from 'silgi/cli/config';
|
|
5
|
-
import { relativeWithDot } from 'silgi/kit';
|
|
6
|
-
import { autoImportTypes } from 'silgi/types';
|
|
7
|
-
|
|
8
|
-
const module = {
|
|
9
|
-
name: "silgi",
|
|
10
|
-
setup: async (nitro) => {
|
|
11
|
-
const silgiConfig = await loadOptions({});
|
|
12
|
-
nitro.options.plugins = nitro.options.plugins || [];
|
|
13
|
-
nitro.options.plugins.push(
|
|
14
|
-
fileURLToPath(new URL("runtime/plugin", import.meta.url))
|
|
15
|
-
);
|
|
16
|
-
const tsConfigPath = resolve(
|
|
17
|
-
nitro.options.buildDir,
|
|
18
|
-
nitro.options.typescript.tsconfigPath
|
|
19
|
-
);
|
|
20
|
-
const tsconfigDir = dirname(tsConfigPath);
|
|
21
|
-
nitro.options.typescript.strict = true;
|
|
22
|
-
nitro.options.typescript.tsConfig ??= {};
|
|
23
|
-
nitro.options.typescript.tsConfig.extends = "./silgi.tsconfig.json";
|
|
24
|
-
nitro.options.typescript.tsConfig.include ??= [];
|
|
25
|
-
nitro.options.typescript.tsConfig.exclude ??= [];
|
|
26
|
-
if (silgiConfig.typescript.internalPaths || silgiConfig.stub) {
|
|
27
|
-
nitro.options.alias ||= {};
|
|
28
|
-
nitro.options.alias = {
|
|
29
|
-
...nitro.options.alias,
|
|
30
|
-
...silgiConfig.alias
|
|
31
|
-
// 'silgi/runtime': fileURLToPath(`${new URL(pkgDir, import.meta.url)}dist/runtime/`),
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
nitro.options.typescript.tsConfig.include.push(join(relativeWithDot(tsconfigDir, silgiConfig.build.dir), "**/*"));
|
|
35
|
-
nitro.options.typescript.tsConfig.compilerOptions ??= {};
|
|
36
|
-
nitro.options.typescript.tsConfig.compilerOptions.paths ??= {};
|
|
37
|
-
nitro.hooks.hook("types:extend", async () => {
|
|
38
|
-
const isStub = silgiConfig.stub ? "pnpm silgi prepare --stub" : "pnpm silgi prepare";
|
|
39
|
-
execSync(isStub, { stdio: "inherit", cwd: nitro.options.rootDir, env: process.env });
|
|
40
|
-
});
|
|
41
|
-
nitro.options.exportConditions ??= [];
|
|
42
|
-
nitro.options.exportConditions.push(...silgiConfig.conditions);
|
|
43
|
-
if (nitro.options.imports) {
|
|
44
|
-
nitro.options.imports.dirs ??= [];
|
|
45
|
-
nitro.options.imports.dirs.push(
|
|
46
|
-
join(silgiConfig.silgi.serverDir, "**/*")
|
|
47
|
-
);
|
|
48
|
-
nitro.options.imports.presets ??= [];
|
|
49
|
-
nitro.options.imports.presets.push({
|
|
50
|
-
from: "silgi",
|
|
51
|
-
imports: ["silgi"]
|
|
52
|
-
});
|
|
53
|
-
nitro.options.imports.presets.push({
|
|
54
|
-
from: "silgi/types",
|
|
55
|
-
imports: autoImportTypes.map((type) => type),
|
|
56
|
-
type: true
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export { module as default };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { defineNuxtModule, addImports } from '@nuxt/kit';
|
|
2
|
-
import { resolvePath } from 'mlly';
|
|
3
|
-
import { join } from 'pathe';
|
|
4
|
-
import { loadOptions } from 'silgi/cli/config';
|
|
5
|
-
import { relativeWithDot } from 'silgi/kit';
|
|
6
|
-
import { autoImportTypes } from 'silgi/types';
|
|
7
|
-
|
|
8
|
-
const module = defineNuxtModule({
|
|
9
|
-
meta: {
|
|
10
|
-
name: "silgi",
|
|
11
|
-
configKey: "silgi",
|
|
12
|
-
compatibility: {
|
|
13
|
-
nuxt: ">=3.14"
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
defaults: {},
|
|
17
|
-
async setup(options, nuxt) {
|
|
18
|
-
const silgi = await loadOptions({});
|
|
19
|
-
nuxt.options.build.transpile.push("silgi");
|
|
20
|
-
nuxt.options.nitro.modules ||= [];
|
|
21
|
-
nuxt.options.nitro.modules.push(await resolvePath("silgi/ecosystem/nitro"));
|
|
22
|
-
nuxt.hook("prepare:types", ({ references }) => {
|
|
23
|
-
references.push({ path: relativeWithDot(nuxt.options.buildDir, join(silgi.build.typesDir, "silgi.d.ts")) });
|
|
24
|
-
});
|
|
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
|
-
});
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
export { module as default };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|