silgi 0.37.43 → 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 +4 -18
- package/dist/index.d.mts +1 -2
- package/dist/index.mjs +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
|
@@ -821,20 +821,6 @@ function withDuplexIfBody(options) {
|
|
|
821
821
|
}
|
|
822
822
|
return options;
|
|
823
823
|
}
|
|
824
|
-
function createSilgiCore(event) {
|
|
825
|
-
return {
|
|
826
|
-
resolve: async (path, method, context) => {
|
|
827
|
-
const silgiCtx = useSilgi();
|
|
828
|
-
if (!silgiCtx.router) {
|
|
829
|
-
return void 0;
|
|
830
|
-
}
|
|
831
|
-
const routeStr = substitutePathParams(String(path), context?.pathParams);
|
|
832
|
-
const methodStr = String(method);
|
|
833
|
-
const match = findRoute(silgiCtx.router, methodStr, routeStr);
|
|
834
|
-
return match?.data?.service;
|
|
835
|
-
}
|
|
836
|
-
};
|
|
837
|
-
}
|
|
838
824
|
async function silgiFetch(_request, options, context) {
|
|
839
825
|
const silgiCtx = useSilgi();
|
|
840
826
|
let request;
|
|
@@ -870,13 +856,13 @@ async function silgiFetch(_request, options, context) {
|
|
|
870
856
|
}
|
|
871
857
|
return handleResponse(handlerRes, silgiEvent, {});
|
|
872
858
|
}
|
|
873
|
-
async function handler(event) {
|
|
859
|
+
async function handler(event, url) {
|
|
874
860
|
const silgiCtx = useSilgi();
|
|
875
|
-
const pathname = event.url.pathname;
|
|
861
|
+
const pathname = url?.path || event.url.pathname;
|
|
876
862
|
let _chain = void 0;
|
|
877
863
|
_chain = Promise.resolve(await silgiCtx.callHook("request:on", event));
|
|
878
864
|
if (silgiCtx.router) {
|
|
879
|
-
const match = findRoute(silgiCtx.router, event.req.method, pathname);
|
|
865
|
+
const match = findRoute(silgiCtx.router, url?.method || event.req.method, pathname);
|
|
880
866
|
if (match) {
|
|
881
867
|
if (_chain) {
|
|
882
868
|
return _chain.then(async (_previous) => {
|
|
@@ -991,4 +977,4 @@ const autoImportTypes = [
|
|
|
991
977
|
"ExtractQueryParamsFromURI"
|
|
992
978
|
];
|
|
993
979
|
|
|
994
|
-
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';
|