silgi 0.37.42 → 0.37.44
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 +1 -1
- package/dist/core/index.d.mts +6 -10
- package/dist/core/index.mjs +5 -20
- package/dist/index.d.mts +1 -2
- package/dist/index.mjs +1 -1
- package/dist/types/index.d.mts +1 -1
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
package/dist/core/index.d.mts
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
import { SilgiConfig, Silgi, SilgiEvent, SilgiSchema,
|
|
2
|
-
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
1
|
+
import { SilgiConfig, Silgi, SilgiEvent, SilgiSchema, CustomRequestInit, SilgiRuntimeContext, AllPrefixes, NamespacesForPrefix, RoutesForPrefixAndNamespace, MethodSchemas, MergeAll, ServiceMethods, SilgiRuntimeShareds, RouteConfig, SilgiURL, StorageConfig, SilgiCLI, SilgiStorageBase, SilgiRuntimeConfig } from 'silgi/types';
|
|
3
2
|
import { Storage, StorageValue } from 'unstorage';
|
|
4
3
|
import { UseContext } from 'unctx';
|
|
5
4
|
|
|
6
5
|
declare function createSilgi(config: SilgiConfig): Promise<Silgi>;
|
|
7
6
|
|
|
8
|
-
declare function createSilgiCore(event: SilgiEvent): {
|
|
9
|
-
resolve: <Schema extends SilgiSchema = SilgiSchema, Route extends keyof Schema = keyof Schema, Method extends keyof Schema[Route] = keyof Schema[Route], Resolved extends boolean = true, HiddenParameters extends boolean = false>(path: Route, method: Method, context: {
|
|
10
|
-
pathParams?: Route extends keyof Schema ? Method extends keyof Schema[Route] ? Schema[Route][Method] extends {
|
|
11
|
-
pathParams?: infer P;
|
|
12
|
-
} ? P extends StandardSchemaV1 ? StandardSchemaV1.InferInput<P> : undefined : undefined : undefined : undefined;
|
|
13
|
-
}) => Promise<Route extends keyof Schema ? Method extends keyof Schema[Route] ? ServiceSetup<Schema, Route, Method, Resolved, HiddenParameters> : undefined : undefined>;
|
|
14
|
-
};
|
|
15
7
|
/**
|
|
16
8
|
* Fetch API for Silgi framework
|
|
17
9
|
*/
|
|
@@ -22,6 +14,10 @@ declare function silgiFetch<Schema extends SilgiSchema = SilgiSchema, Route exte
|
|
|
22
14
|
declare function silgiFetch(_request: Request | URL | string, options?: RequestInit & {
|
|
23
15
|
pathParams?: Record<string, any>;
|
|
24
16
|
}, context?: SilgiRuntimeContext): Promise<Response | Promise<Response>>;
|
|
17
|
+
declare function handler(event: SilgiEvent, url?: {
|
|
18
|
+
path: string;
|
|
19
|
+
method: string;
|
|
20
|
+
}): Promise<any>;
|
|
25
21
|
|
|
26
22
|
/**
|
|
27
23
|
* LICENSE: MIT
|
|
@@ -292,4 +288,4 @@ declare function useRuntime(): SilgiRuntimeConfig;
|
|
|
292
288
|
|
|
293
289
|
declare const autoImportTypes: string[];
|
|
294
290
|
|
|
295
|
-
export { SilgiError, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi,
|
|
291
|
+
export { SilgiError, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi, createStorage, deepMergeObjects, getEvent, getEventContext, getUrlPrefix, handleResponse, handler, isError, replaceRuntimeValues, silgiCLICtx, silgiCtx, silgiFetch, storageMount, tryUseSilgi, tryUseSilgiCLI, updateRuntimeStorage, useRuntime, useSilgi, useSilgiCLI, useSilgiStorage };
|
package/dist/core/index.mjs
CHANGED
|
@@ -281,8 +281,7 @@ async function createSilgi(config) {
|
|
|
281
281
|
tag: "silgi"
|
|
282
282
|
})).withTag("silgi"),
|
|
283
283
|
captureError: config.captureError ?? (() => {
|
|
284
|
-
})
|
|
285
|
-
meta: config.meta ?? {}
|
|
284
|
+
})
|
|
286
285
|
};
|
|
287
286
|
sharedRuntimeConfig(silgi.options.runtimeConfig);
|
|
288
287
|
if (!silgi.router) {
|
|
@@ -822,20 +821,6 @@ function withDuplexIfBody(options) {
|
|
|
822
821
|
}
|
|
823
822
|
return options;
|
|
824
823
|
}
|
|
825
|
-
function createSilgiCore(event) {
|
|
826
|
-
return {
|
|
827
|
-
resolve: async (path, method, context) => {
|
|
828
|
-
const silgiCtx = useSilgi();
|
|
829
|
-
if (!silgiCtx.router) {
|
|
830
|
-
return void 0;
|
|
831
|
-
}
|
|
832
|
-
const routeStr = substitutePathParams(String(path), context?.pathParams);
|
|
833
|
-
const methodStr = String(method);
|
|
834
|
-
const match = findRoute(silgiCtx.router, methodStr, routeStr);
|
|
835
|
-
return match?.data?.service;
|
|
836
|
-
}
|
|
837
|
-
};
|
|
838
|
-
}
|
|
839
824
|
async function silgiFetch(_request, options, context) {
|
|
840
825
|
const silgiCtx = useSilgi();
|
|
841
826
|
let request;
|
|
@@ -871,13 +856,13 @@ async function silgiFetch(_request, options, context) {
|
|
|
871
856
|
}
|
|
872
857
|
return handleResponse(handlerRes, silgiEvent, {});
|
|
873
858
|
}
|
|
874
|
-
async function handler(event) {
|
|
859
|
+
async function handler(event, url) {
|
|
875
860
|
const silgiCtx = useSilgi();
|
|
876
|
-
const pathname = event.url.pathname;
|
|
861
|
+
const pathname = url?.path || event.url.pathname;
|
|
877
862
|
let _chain = void 0;
|
|
878
863
|
_chain = Promise.resolve(await silgiCtx.callHook("request:on", event));
|
|
879
864
|
if (silgiCtx.router) {
|
|
880
|
-
const match = findRoute(silgiCtx.router, event.req.method, pathname);
|
|
865
|
+
const match = findRoute(silgiCtx.router, url?.method || event.req.method, pathname);
|
|
881
866
|
if (match) {
|
|
882
867
|
if (_chain) {
|
|
883
868
|
return _chain.then(async (_previous) => {
|
|
@@ -992,4 +977,4 @@ const autoImportTypes = [
|
|
|
992
977
|
"ExtractQueryParamsFromURI"
|
|
993
978
|
];
|
|
994
979
|
|
|
995
|
-
export { SilgiError, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi,
|
|
980
|
+
export { SilgiError, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi, createStorage, deepMergeObjects, getEvent, getEventContext, getUrlPrefix, handleResponse, handler, isError, replaceRuntimeValues, silgiCtx, silgiFetch, storageMount, tryUseSilgi, updateRuntimeStorage, useRuntime, useSilgi, useSilgiStorage };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export { SilgiError, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi,
|
|
1
|
+
export { SilgiError, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi, createStorage, deepMergeObjects, getEvent, getEventContext, getUrlPrefix, handleResponse, handler, isError, replaceRuntimeValues, silgiCLICtx, silgiCtx, silgiFetch, storageMount, tryUseSilgi, tryUseSilgiCLI, updateRuntimeStorage, useRuntime, useSilgi, useSilgiCLI, useSilgiStorage } from './core/index.mjs';
|
|
2
2
|
import 'silgi/types';
|
|
3
|
-
import '@standard-schema/spec';
|
|
4
3
|
import 'unstorage';
|
|
5
4
|
import 'unctx';
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { SilgiError, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi,
|
|
1
|
+
export { SilgiError, autoImportTypes, createError, createRoute, createSchema, createService, createShared, createSilgi, createStorage, deepMergeObjects, getEvent, getEventContext, getUrlPrefix, handleResponse, handler, isError, replaceRuntimeValues, silgiCtx, silgiFetch, storageMount, tryUseSilgi, updateRuntimeStorage, useRuntime, useSilgi, useSilgiStorage } from './core/index.mjs';
|
|
2
2
|
export { s as silgiCLICtx, t as tryUseSilgiCLI, u as useSilgiCLI } from './_chunks/silgiApp.mjs';
|
|
3
3
|
import 'consola';
|
|
4
4
|
import 'defu';
|
package/dist/types/index.d.mts
CHANGED
|
@@ -699,10 +699,10 @@ interface Silgi {
|
|
|
699
699
|
envOptions: EnvOptions;
|
|
700
700
|
options: SilgiOptions & SilgiRuntimeOptions;
|
|
701
701
|
captureError: CaptureError;
|
|
702
|
-
meta: SilgiMeta;
|
|
703
702
|
}
|
|
704
703
|
interface SilgiConfig extends Partial<Omit<Silgi, 'options'>>, Partial<SilgiRuntimeOptions> {
|
|
705
704
|
options: DeepPartial<SilgiOptions>;
|
|
705
|
+
meta: SilgiMeta;
|
|
706
706
|
}
|
|
707
707
|
interface BuildSilgi {
|
|
708
708
|
framework?: {
|