silgi 0.41.18 → 0.41.20
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 +17 -22
- package/dist/core/index.mjs +64 -51
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +2 -1
- package/dist/types/index.d.mts +29 -24
- package/package.json +2 -1
package/dist/cli/index.mjs
CHANGED
package/dist/core/index.d.mts
CHANGED
|
@@ -158,29 +158,24 @@ declare function deepMergeObjects<T extends readonly Record<string, any>[]>(sche
|
|
|
158
158
|
* ServiceSetup tipinden oluşan bir yardımcı fonksiyon.
|
|
159
159
|
* Tip güvenliğini artırmak için ServiceSetup objesini doğrudan döndürür.
|
|
160
160
|
*/
|
|
161
|
+
declare function defineServiceSetup<Parent extends StandardSchemaV1, Input extends StandardSchemaV1 = StandardSchemaV1, Output extends StandardSchemaV1 = StandardSchemaV1, PathParams extends StandardSchemaV1 | undefined | never = undefined, QueryParams extends StandardSchemaV1 | undefined | never = undefined, Resolved extends boolean = false, HiddenParameters extends boolean = false>(setup: ServiceSetup<Parent, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>): ServiceSetup<Parent, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
|
|
161
162
|
type SlashCount<S extends string, Count extends any[] = []> = S extends `${infer _Prefix}/${infer Rest}` ? SlashCount<Rest, [any, ...Count]> : Count['length'];
|
|
162
|
-
type Max4Slashes<S extends keyof Routers> = SlashCount<S> extends 0 | 1 | 2 | 3
|
|
163
|
-
|
|
163
|
+
type Max4Slashes<S extends keyof Routers> = SlashCount<S> extends 0 | 1 | 2 | 3 ? S : never;
|
|
164
|
+
type ServiceSetupsForMethods<Parent extends StandardSchemaV1, Input extends StandardSchemaV1 = StandardSchemaV1, Output extends StandardSchemaV1 = StandardSchemaV1, PathParams extends StandardSchemaV1 | undefined | never = undefined, QueryParams extends StandardSchemaV1 | undefined | never = undefined, Resolved extends boolean = false, HiddenParameters extends boolean = false> = {
|
|
165
|
+
GET?: ServiceSetup<Parent, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
|
|
166
|
+
POST?: ServiceSetup<Parent, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
|
|
167
|
+
PUT?: ServiceSetup<Parent, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
|
|
168
|
+
PATCH?: ServiceSetup<Parent, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
|
|
169
|
+
DELETE?: ServiceSetup<Parent, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
|
|
170
|
+
OPTIONS?: ServiceSetup<Parent, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
|
|
171
|
+
HEAD?: ServiceSetup<Parent, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
|
|
172
|
+
CONNECT?: ServiceSetup<Parent, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
|
|
173
|
+
TRACE?: ServiceSetup<Parent, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
|
|
174
|
+
};
|
|
175
|
+
declare function createService<Parent extends StandardSchemaV1, Path extends keyof Routers = keyof Routers, Input extends StandardSchemaV1 = StandardSchemaV1, Output extends StandardSchemaV1 = StandardSchemaV1, PathParams extends StandardSchemaV1 | undefined | never = undefined, QueryParams extends StandardSchemaV1 | undefined | never = undefined, Resolved extends boolean = false, HiddenParameters extends boolean = false>(params: {
|
|
164
176
|
path: Max4Slashes<Path>;
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
output?: Output;
|
|
168
|
-
queryParams?: {
|
|
169
|
-
path?: PathParams;
|
|
170
|
-
query?: QueryParams;
|
|
171
|
-
};
|
|
172
|
-
setup: ServiceSetup<Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
|
|
173
|
-
}): {
|
|
174
|
-
[K in Path]: {
|
|
175
|
-
setup: ServiceSetup<Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
|
|
176
|
-
methods?: HTTPMethod[];
|
|
177
|
-
input?: Input;
|
|
178
|
-
output?: Output;
|
|
179
|
-
queryParams?: {
|
|
180
|
-
path?: PathParams;
|
|
181
|
-
query?: QueryParams;
|
|
182
|
-
};
|
|
183
|
-
};
|
|
177
|
+
} & ServiceSetupsForMethods<Parent, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>): {
|
|
178
|
+
[K in Path]: ServiceSetupsForMethods<Parent, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
|
|
184
179
|
};
|
|
185
180
|
|
|
186
181
|
type WildcardVariants<Path extends string, Acc extends string = ''> = Path extends `${infer Head}/${infer Tail}` ? Tail extends '' ? `${Acc}${Head}` : `${Acc}${Head}/${Tail}` | `${Acc}${Head}/*` | `${Acc}${Head}/**` | WildcardVariants<Tail, `${Acc}${Head}/`> : `${Acc}${Path}`;
|
|
@@ -252,4 +247,4 @@ declare function useRuntime(): SilgiRuntimeConfig;
|
|
|
252
247
|
|
|
253
248
|
declare const autoImportTypes: string[];
|
|
254
249
|
|
|
255
|
-
export { SilgiError, autoImportTypes, createError, createMiddleware, createResolver, createSchema, createService, createShared, createSilgi, createStorage, deepMergeObjects, getEvent, getEventContext, getUrlPrefix, handleResponse, handler, isError, middleware, replaceRuntimeValues, silgiCLICtx, silgiCtx, silgiFetch, storageMount, tryUseSilgi, tryUseSilgiCLI, updateRuntimeStorage, useRuntime, useSilgi, useSilgiCLI, useSilgiStorage };
|
|
250
|
+
export { SilgiError, autoImportTypes, createError, createMiddleware, createResolver, createSchema, createService, createShared, createSilgi, createStorage, deepMergeObjects, defineServiceSetup, getEvent, getEventContext, getUrlPrefix, handleResponse, handler, isError, middleware, replaceRuntimeValues, silgiCLICtx, silgiCtx, silgiFetch, storageMount, tryUseSilgi, tryUseSilgiCLI, updateRuntimeStorage, useRuntime, useSilgi, useSilgiCLI, useSilgiStorage };
|
package/dist/core/index.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import { Buffer } from 'node:buffer';
|
|
|
8
8
|
import { klona } from 'klona';
|
|
9
9
|
import { createStorage as createStorage$1, builtinDrivers, prefixStorage } from 'unstorage';
|
|
10
10
|
import { isDevelopment } from 'std-env';
|
|
11
|
+
import { toJsonSchema } from '@standard-community/standard-json';
|
|
11
12
|
import { FastURL, FastResponse } from 'srvx';
|
|
12
13
|
export { s as silgiCLICtx, t as tryUseSilgiCLI, u as useSilgiCLI } from '../_chunks/silgiApp.mjs';
|
|
13
14
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
@@ -298,29 +299,36 @@ async function createSilgi(config) {
|
|
|
298
299
|
silgi.router = createRouter();
|
|
299
300
|
}
|
|
300
301
|
for (const [route, object] of Object.entries(silgi.services)) {
|
|
301
|
-
const
|
|
302
|
-
if (
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
service: object
|
|
307
|
-
});
|
|
308
|
-
continue;
|
|
309
|
-
} else {
|
|
310
|
-
const routeParts = route.split("/").filter(Boolean);
|
|
311
|
-
if (routeParts.length > 0) {
|
|
312
|
-
const prefix = `/${routeParts[0]}`;
|
|
313
|
-
if (!silgi.routerPrefixs.includes(prefix)) {
|
|
314
|
-
silgi.routerPrefixs.push(prefix);
|
|
315
|
-
}
|
|
302
|
+
const routeParts = route.split("/").filter(Boolean);
|
|
303
|
+
if (routeParts.length > 0) {
|
|
304
|
+
const prefix = `/${routeParts[0]}`;
|
|
305
|
+
if (!silgi.routerPrefixs.includes(prefix)) {
|
|
306
|
+
silgi.routerPrefixs.push(prefix);
|
|
316
307
|
}
|
|
317
308
|
}
|
|
318
|
-
for (const method of
|
|
319
|
-
|
|
320
|
-
|
|
309
|
+
for (const [method, routeObject] of Object.entries(object)) {
|
|
310
|
+
let routeWithParams = route;
|
|
311
|
+
if (routeObject.pathParams) {
|
|
312
|
+
const jsonSchema = await toJsonSchema(routeObject.pathParams);
|
|
313
|
+
if (jsonSchema && jsonSchema.properties) {
|
|
314
|
+
const paramNames = Object.keys(jsonSchema.properties);
|
|
315
|
+
if (paramNames.length > 0) {
|
|
316
|
+
const routeParts2 = routeWithParams.split("/");
|
|
317
|
+
const lastParts = routeParts2.slice(-paramNames.length);
|
|
318
|
+
const alreadyHasParams = paramNames.every((name, idx) => lastParts[idx] === `:${name}`);
|
|
319
|
+
if (!alreadyHasParams) {
|
|
320
|
+
routeWithParams = routeWithParams.replace(/\/+$/, "");
|
|
321
|
+
for (const param of paramNames) {
|
|
322
|
+
routeWithParams += `/:${param}`;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
addRoute(silgi.router, method, routeWithParams, {
|
|
321
329
|
method,
|
|
322
|
-
route,
|
|
323
|
-
service:
|
|
330
|
+
route: routeWithParams,
|
|
331
|
+
service: routeObject
|
|
324
332
|
});
|
|
325
333
|
}
|
|
326
334
|
}
|
|
@@ -391,12 +399,16 @@ class _SilgiEvent {
|
|
|
391
399
|
req;
|
|
392
400
|
url;
|
|
393
401
|
context;
|
|
402
|
+
protocol;
|
|
403
|
+
// Added property
|
|
394
404
|
_res;
|
|
395
405
|
constructor(req, context) {
|
|
396
406
|
this.context = context || new EmptyObject();
|
|
397
407
|
this.req = req;
|
|
398
408
|
const _url = req._url;
|
|
399
409
|
this.url = _url && _url instanceof URL ? _url : new FastURL(req.url);
|
|
410
|
+
let proto = this.url.protocol.replace(":", "");
|
|
411
|
+
this.protocol = proto === "https" ? "http" : proto;
|
|
400
412
|
}
|
|
401
413
|
get res() {
|
|
402
414
|
if (!this._res) {
|
|
@@ -607,7 +619,7 @@ async function orchestrate(route, event, _input) {
|
|
|
607
619
|
pathParams: {},
|
|
608
620
|
queryParams: {}
|
|
609
621
|
};
|
|
610
|
-
const input = _input || (route.service?.
|
|
622
|
+
const input = _input || (route.service?.rules?.readBeforeBody === false || isGraphQL ? {} : await parseRequestInput(event.req));
|
|
611
623
|
const hookContext = { earlyReturnValue: false };
|
|
612
624
|
const routerParams = _input ? input.path : getRouterParams(event);
|
|
613
625
|
const queryParams = _input ? input.query : getQuery(event);
|
|
@@ -619,10 +631,8 @@ async function orchestrate(route, event, _input) {
|
|
|
619
631
|
}
|
|
620
632
|
const inputData = {
|
|
621
633
|
args: input,
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
path: routerParams
|
|
625
|
-
}
|
|
634
|
+
query: queryParams,
|
|
635
|
+
path: routerParams
|
|
626
636
|
};
|
|
627
637
|
try {
|
|
628
638
|
if (!route.service && route.method !== "GRAPHQL") {
|
|
@@ -660,10 +670,17 @@ async function orchestrate(route, event, _input) {
|
|
|
660
670
|
}
|
|
661
671
|
silgiCtx.shared.$fetch = silgiFetch;
|
|
662
672
|
silgiCtx.shared.silgi = silgiCtx;
|
|
663
|
-
const result = await route.service?.
|
|
673
|
+
const result = await route.service?.handler?.(
|
|
674
|
+
// input
|
|
664
675
|
inputData,
|
|
676
|
+
// shared
|
|
665
677
|
silgiCtx.shared,
|
|
666
|
-
event
|
|
678
|
+
// event
|
|
679
|
+
event,
|
|
680
|
+
// parent - graphql
|
|
681
|
+
{},
|
|
682
|
+
// info - graphql
|
|
683
|
+
{}
|
|
667
684
|
);
|
|
668
685
|
await silgiCtx.callHook("fetch:after", {
|
|
669
686
|
event,
|
|
@@ -674,12 +691,12 @@ async function orchestrate(route, event, _input) {
|
|
|
674
691
|
route,
|
|
675
692
|
hookContext
|
|
676
693
|
});
|
|
677
|
-
if (route.service?.
|
|
678
|
-
await useSilgiStorage(route.service.
|
|
694
|
+
if (route.service?.storage && cacheData?.cachedKey) {
|
|
695
|
+
await useSilgiStorage(route.service.storage.base).setItem(
|
|
679
696
|
cacheData.cachedKey,
|
|
680
697
|
result,
|
|
681
698
|
// Cast to StorageValue if needed
|
|
682
|
-
route.service.
|
|
699
|
+
route.service.storage.options
|
|
683
700
|
);
|
|
684
701
|
}
|
|
685
702
|
return result;
|
|
@@ -709,17 +726,17 @@ async function orchestrate(route, event, _input) {
|
|
|
709
726
|
}
|
|
710
727
|
}
|
|
711
728
|
async function cacheExecute(input, route, silgiURL, event) {
|
|
712
|
-
if (!route.service || !route.service.
|
|
729
|
+
if (!route.service || !route.service.storage)
|
|
713
730
|
return;
|
|
714
|
-
const cacheKey = route.service.
|
|
731
|
+
const cacheKey = route.service.storage ? await generateStorageKey({
|
|
715
732
|
url: silgiURL,
|
|
716
733
|
input,
|
|
717
|
-
keyGenerator: route.service.
|
|
718
|
-
storageOptions: route.service.
|
|
734
|
+
keyGenerator: route.service.storage.key,
|
|
735
|
+
storageOptions: route.service.storage,
|
|
719
736
|
requestId: event?.requestId
|
|
720
737
|
}) : null;
|
|
721
738
|
if (cacheKey) {
|
|
722
|
-
const cachedResult = await useSilgiStorage(route.service.
|
|
739
|
+
const cachedResult = await useSilgiStorage(route.service.storage.base).getItem(cacheKey);
|
|
723
740
|
if (cachedResult !== null) {
|
|
724
741
|
return {
|
|
725
742
|
success: true,
|
|
@@ -941,7 +958,7 @@ async function middleware(event, url) {
|
|
|
941
958
|
return _previous;
|
|
942
959
|
}
|
|
943
960
|
const allowedMethod = m.method ?? "";
|
|
944
|
-
const methodIsAllowed = allowedMethod ===
|
|
961
|
+
const methodIsAllowed = allowedMethod === event.req.method || event.protocol === "GRAPHQL";
|
|
945
962
|
if (!methodIsAllowed) {
|
|
946
963
|
return;
|
|
947
964
|
}
|
|
@@ -976,7 +993,7 @@ async function middleware(event, url) {
|
|
|
976
993
|
return _previous;
|
|
977
994
|
}
|
|
978
995
|
const allowedMethod = match.data.method ?? "";
|
|
979
|
-
const methodIsAllowed = allowedMethod ===
|
|
996
|
+
const methodIsAllowed = allowedMethod === event.req.method || event.protocol === "GRAPHQL";
|
|
980
997
|
if (!methodIsAllowed || !match.data.middleware) {
|
|
981
998
|
return;
|
|
982
999
|
}
|
|
@@ -1016,10 +1033,7 @@ async function handler(event, url, input) {
|
|
|
1016
1033
|
data: {
|
|
1017
1034
|
method: url?.method || event.req.method,
|
|
1018
1035
|
route: url?.path,
|
|
1019
|
-
service: {
|
|
1020
|
-
setup: {},
|
|
1021
|
-
methods: ["GRAPHQL"]
|
|
1022
|
-
}
|
|
1036
|
+
service: {}
|
|
1023
1037
|
},
|
|
1024
1038
|
params: {}
|
|
1025
1039
|
};
|
|
@@ -1090,6 +1104,9 @@ function deepMergeObjects(schemas) {
|
|
|
1090
1104
|
return merged;
|
|
1091
1105
|
}
|
|
1092
1106
|
|
|
1107
|
+
function defineServiceSetup(setup) {
|
|
1108
|
+
return setup;
|
|
1109
|
+
}
|
|
1093
1110
|
function createService(params) {
|
|
1094
1111
|
const slashCount = (String(params.path).match(/\//g) || []).length;
|
|
1095
1112
|
if (slashCount > 4) {
|
|
@@ -1097,16 +1114,12 @@ function createService(params) {
|
|
|
1097
1114
|
`Path '${params.path}' is invalid: maximum 4 '/' allowed (found ${slashCount})`
|
|
1098
1115
|
);
|
|
1099
1116
|
}
|
|
1100
|
-
const
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
input,
|
|
1106
|
-
output,
|
|
1107
|
-
queryParams
|
|
1117
|
+
const { path, ...objects } = params;
|
|
1118
|
+
return {
|
|
1119
|
+
[path]: {
|
|
1120
|
+
...objects
|
|
1121
|
+
}
|
|
1108
1122
|
};
|
|
1109
|
-
return result;
|
|
1110
1123
|
}
|
|
1111
1124
|
|
|
1112
1125
|
function createMiddleware(params) {
|
|
@@ -1163,4 +1176,4 @@ const autoImportTypes = [
|
|
|
1163
1176
|
"ExtractQueryParamsFromURI"
|
|
1164
1177
|
];
|
|
1165
1178
|
|
|
1166
|
-
export { SilgiError, autoImportTypes, createError, createMiddleware, createResolver, createSchema, createService, createShared, createSilgi, createStorage, deepMergeObjects, getEvent, getEventContext, getUrlPrefix, handleResponse, handler, isError, middleware, replaceRuntimeValues, silgiCtx, silgiFetch, storageMount, tryUseSilgi, updateRuntimeStorage, useRuntime, useSilgi, useSilgiStorage };
|
|
1179
|
+
export { SilgiError, autoImportTypes, createError, createMiddleware, createResolver, createSchema, createService, createShared, createSilgi, createStorage, deepMergeObjects, defineServiceSetup, getEvent, getEventContext, getUrlPrefix, handleResponse, handler, isError, middleware, replaceRuntimeValues, silgiCtx, silgiFetch, storageMount, tryUseSilgi, updateRuntimeStorage, useRuntime, useSilgi, useSilgiStorage };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { SilgiError, autoImportTypes, createError, createMiddleware, createResolver, createSchema, createService, createShared, createSilgi, createStorage, deepMergeObjects, getEvent, getEventContext, getUrlPrefix, handleResponse, handler, isError, middleware, replaceRuntimeValues, silgiCLICtx, silgiCtx, silgiFetch, storageMount, tryUseSilgi, tryUseSilgiCLI, updateRuntimeStorage, useRuntime, useSilgi, useSilgiCLI, useSilgiStorage } from './core/index.mjs';
|
|
1
|
+
export { SilgiError, autoImportTypes, createError, createMiddleware, createResolver, createSchema, createService, createShared, createSilgi, createStorage, deepMergeObjects, defineServiceSetup, getEvent, getEventContext, getUrlPrefix, handleResponse, handler, isError, middleware, replaceRuntimeValues, silgiCLICtx, silgiCtx, silgiFetch, storageMount, tryUseSilgi, tryUseSilgiCLI, updateRuntimeStorage, useRuntime, useSilgi, useSilgiCLI, useSilgiStorage } from './core/index.mjs';
|
|
2
2
|
import 'silgi/types';
|
|
3
3
|
import '@standard-schema/spec';
|
|
4
4
|
import 'unstorage';
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { SilgiError, autoImportTypes, createError, createMiddleware, createResolver, createSchema, createService, createShared, createSilgi, createStorage, deepMergeObjects, getEvent, getEventContext, getUrlPrefix, handleResponse, handler, isError, middleware, replaceRuntimeValues, silgiCtx, silgiFetch, storageMount, tryUseSilgi, updateRuntimeStorage, useRuntime, useSilgi, useSilgiStorage } from './core/index.mjs';
|
|
1
|
+
export { SilgiError, autoImportTypes, createError, createMiddleware, createResolver, createSchema, createService, createShared, createSilgi, createStorage, deepMergeObjects, defineServiceSetup, getEvent, getEventContext, getUrlPrefix, handleResponse, handler, isError, middleware, 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';
|
|
@@ -10,5 +10,6 @@ import 'node:buffer';
|
|
|
10
10
|
import 'klona';
|
|
11
11
|
import 'unstorage';
|
|
12
12
|
import 'std-env';
|
|
13
|
+
import '@standard-community/standard-json';
|
|
13
14
|
import 'srvx';
|
|
14
15
|
import 'node:async_hooks';
|
package/dist/types/index.d.mts
CHANGED
|
@@ -25,6 +25,7 @@ import { ServerRequest } from 'srvx';
|
|
|
25
25
|
import { Defu } from 'defu';
|
|
26
26
|
import { silgiFetch } from 'silgi';
|
|
27
27
|
import { useRuntimeConfig } from 'silgi/runtime';
|
|
28
|
+
import { GraphQLResolveInfo } from 'graphql';
|
|
28
29
|
import { Unimport } from 'unimport';
|
|
29
30
|
import { ProviderName } from 'std-env';
|
|
30
31
|
import { FetchOptions, FetchResponse } from 'ofetch';
|
|
@@ -99,10 +100,15 @@ interface SilgiRuntimeContext extends Record<string, any> {
|
|
|
99
100
|
runtimeConfig?: SilgiRuntimeConfig;
|
|
100
101
|
};
|
|
101
102
|
}
|
|
103
|
+
type EventProtocol = 'GRAPHQL' | 'HTTP' | 'WEBSOCKET';
|
|
102
104
|
/**
|
|
103
105
|
* Bu nitrojs, h3 event or request context.
|
|
104
106
|
*/
|
|
105
107
|
interface SilgiEvent extends Record<string, unknown> {
|
|
108
|
+
/**
|
|
109
|
+
* Protocol Type
|
|
110
|
+
*/
|
|
111
|
+
readonly protocol: EventProtocol;
|
|
106
112
|
/**
|
|
107
113
|
* Event context.
|
|
108
114
|
*/
|
|
@@ -243,20 +249,14 @@ type ServiceHandlerInput<Input extends StandardSchemaV1 = StandardSchemaV1, Path
|
|
|
243
249
|
args: InferInput<Input>;
|
|
244
250
|
} : HasPath<PathParams> extends true ? HasQuery<QueryParams> extends true ? {
|
|
245
251
|
args: InferInput<Input>;
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
query: Partial<InferInput<QueryParams>>;
|
|
249
|
-
};
|
|
252
|
+
path: InferInput<PathParams>;
|
|
253
|
+
query: Partial<InferInput<QueryParams>>;
|
|
250
254
|
} : {
|
|
251
255
|
args: InferInput<Input>;
|
|
252
|
-
|
|
253
|
-
path: InferInput<PathParams>;
|
|
254
|
-
};
|
|
256
|
+
path: InferInput<PathParams>;
|
|
255
257
|
} : HasQuery<QueryParams> extends true ? {
|
|
256
258
|
args: InferInput<Input>;
|
|
257
|
-
|
|
258
|
-
query: InferInput<QueryParams>;
|
|
259
|
-
};
|
|
259
|
+
query: InferInput<QueryParams>;
|
|
260
260
|
} : {
|
|
261
261
|
args: InferInput<Input>;
|
|
262
262
|
};
|
|
@@ -266,15 +266,19 @@ type ServiceHandlerInput<Input extends StandardSchemaV1 = StandardSchemaV1, Path
|
|
|
266
266
|
* Resolved = false -> handler(input, shared, event, source) // all required
|
|
267
267
|
* Resolved = true -> handler(input, shared?, event?, source?) // only input required
|
|
268
268
|
*/
|
|
269
|
-
type ServiceHandler<Input extends StandardSchemaV1, Output extends StandardSchemaV1, PathParams extends StandardSchemaV1 | never | undefined = never, QueryParams extends StandardSchemaV1 | never | undefined = never, Resolved extends boolean = false, HiddenParameters extends boolean = false> = Resolved extends true ? (input: ServiceHandlerInput<Input, PathParams, QueryParams, HiddenParameters>, shared?: SilgiRuntimeShareds, event?: SilgiEvent) => Promise<InferOutput<Output>> | InferOutput<Output> : (input: ServiceHandlerInput<Input, PathParams, QueryParams, HiddenParameters>, shared: SilgiRuntimeShareds, event: SilgiEvent) => Promise<InferOutput<Output>> | InferOutput<Output>;
|
|
269
|
+
type ServiceHandler<Parent extends StandardSchemaV1, Input extends StandardSchemaV1, Output extends StandardSchemaV1, PathParams extends StandardSchemaV1 | never | undefined = never, QueryParams extends StandardSchemaV1 | never | undefined = never, Resolved extends boolean = false, HiddenParameters extends boolean = false> = Resolved extends true ? (input: ServiceHandlerInput<Input, PathParams, QueryParams, HiddenParameters>, shared?: SilgiRuntimeShareds, event?: SilgiEvent, parent?: Parent, info?: GraphQLResolveInfo) => Promise<InferOutput<Output>> | InferOutput<Output> : (input: ServiceHandlerInput<Input, PathParams, QueryParams, HiddenParameters>, shared: SilgiRuntimeShareds, event: SilgiEvent, parent: Parent, info: GraphQLResolveInfo) => Promise<InferOutput<Output>> | InferOutput<Output>;
|
|
270
270
|
/**
|
|
271
271
|
* Servis setup tipi
|
|
272
272
|
*/
|
|
273
|
-
interface ServiceSetup<Input extends StandardSchemaV1 = StandardSchemaV1, Output extends StandardSchemaV1 = StandardSchemaV1, PathParams extends StandardSchemaV1 |
|
|
274
|
-
handler?: ServiceHandler<Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
|
|
273
|
+
interface ServiceSetup<Parent extends StandardSchemaV1, Input extends StandardSchemaV1 = StandardSchemaV1, Output extends StandardSchemaV1 = StandardSchemaV1, PathParams extends StandardSchemaV1 | undefined | never = undefined, QueryParams extends StandardSchemaV1 | undefined | never = undefined, Resolved extends boolean = false, HiddenParameters extends boolean = false> {
|
|
274
|
+
handler?: ServiceHandler<Parent, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
|
|
275
275
|
rules?: MergeRouteRules;
|
|
276
276
|
modules?: Partial<SetupModuleOption>;
|
|
277
277
|
storage?: StorageConfig<ServiceHandlerInput<Input, PathParams, QueryParams, HiddenParameters>>;
|
|
278
|
+
input?: Input;
|
|
279
|
+
output?: Output;
|
|
280
|
+
pathParams?: PathParams;
|
|
281
|
+
queryParams?: QueryParams;
|
|
278
282
|
}
|
|
279
283
|
/**
|
|
280
284
|
* Represents a fully resolved service definition that maps route paths
|
|
@@ -287,14 +291,15 @@ interface ServiceSetup<Input extends StandardSchemaV1 = StandardSchemaV1, Output
|
|
|
287
291
|
*/
|
|
288
292
|
interface ResolvedServiceDefinition {
|
|
289
293
|
[routePath: string]: {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
294
|
+
GET?: ServiceSetup<any, any, any, any, any, any>;
|
|
295
|
+
POST?: ServiceSetup<any, any, any, any, any, any>;
|
|
296
|
+
PUT?: ServiceSetup<any, any, any, any, any, any>;
|
|
297
|
+
PATCH?: ServiceSetup<any, any, any, any, any, any>;
|
|
298
|
+
DELETE?: ServiceSetup<any, any, any, any, any, any>;
|
|
299
|
+
OPTIONS?: ServiceSetup<any, any, any, any, any, any>;
|
|
300
|
+
HEAD?: ServiceSetup<any, any, any, any, any, any>;
|
|
301
|
+
CONNECT?: ServiceSetup<any, any, any, any, any, any>;
|
|
302
|
+
TRACE?: ServiceSetup<any, any, any, any, any, any>;
|
|
298
303
|
};
|
|
299
304
|
}
|
|
300
305
|
/**
|
|
@@ -693,14 +698,14 @@ interface ResolvedSchemaDefinition {
|
|
|
693
698
|
[methodAndRoutePath: string]: BaseMethodSchema;
|
|
694
699
|
}
|
|
695
700
|
|
|
696
|
-
type StandardHTTPMethod = 'GET' | 'HEAD' | 'PATCH' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE'
|
|
701
|
+
type StandardHTTPMethod = 'GET' | 'HEAD' | 'PATCH' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE';
|
|
697
702
|
type HTTPMethod = StandardHTTPMethod | (keyof SilgiRuntimeMethods extends string ? keyof SilgiRuntimeMethods : never);
|
|
698
703
|
interface MetaData extends Record<string, unknown> {
|
|
699
704
|
}
|
|
700
705
|
interface SilgiRoute {
|
|
701
706
|
route?: string;
|
|
702
707
|
method?: HTTPMethod;
|
|
703
|
-
service?: ResolvedServiceDefinition[string];
|
|
708
|
+
service?: ResolvedServiceDefinition[string][keyof ResolvedServiceDefinition[string]];
|
|
704
709
|
middleware?: MiddlewareSetup;
|
|
705
710
|
}
|
|
706
711
|
interface Silgi {
|
|
@@ -1224,4 +1229,4 @@ interface LoadConfigOptions {
|
|
|
1224
1229
|
consola?: ConsolaInstance;
|
|
1225
1230
|
}
|
|
1226
1231
|
|
|
1227
|
-
export type { AllPaths, AllPrefixes, AppConfig, Awaitable, BaseMethodSchema, BuildSilgi, CaptureError, CapturedErrorContext, CommandType, Commands, CustomRequestInit, DeepPartial, DeepRequired, DefaultHooks, DefineFrameworkOptions, DotenvOptions, EnvOptions, EventHandlerResponse, ExtendContext, ExtendShared, ExtractNamespace, ExtractPathParamKeys, ExtractPathParams, ExtractPrefix, ExtractRoute, GenImport, GenerateAppOptions, HTTPMethod, HasPathParams, HookResult, LoadConfigOptions, MergeAll, MergeRouteRules, MergedSilgiSchema, MetaData, MethodSchemas, MiddlewareHandler, MiddlewareSetup, ModuleDefinition, ModuleHookContext, ModuleMeta, ModuleOptionsCustom, ModuleSetupInstallResult, ModuleSetupReturn, NamespacesForPrefix, NitroBuildInfo, RequiredServiceType, ResolvedMiddlewareDefinition, ResolvedModuleMeta, ResolvedModuleOptions, ResolvedSchema, ResolvedSchemaDefinition, ResolvedServiceDefinition, ResolvedSilgiTemplate, Resolvers, RouteEntry, RouteRules, RouterParams, Routers, RoutesForPrefixAndNamespace, ScanFile, Schema, ServiceHandler, ServiceHandlerInput, ServiceSetup, ServicesObject, SetupModuleOption, Silgi, SilgiAppPlugin, SilgiCLI, SilgiCLIConfig, SilgiCLIHooks, SilgiCLIOptions, SilgiCommands, SilgiCompatibility, SilgiCompatibilityIssue, SilgiCompatibilityIssues, SilgiConfig, SilgiEvent, SilgiFetchClient, SilgiFetchOptions, SilgiFrameworkInfo, SilgiHooks, SilgiModule, SilgiModuleInput, SilgiModuleOptions, SilgiOptions, SilgiPreset, SilgiPresetMeta, SilgiRoute, SilgiRouterTypes, SilgiRuntimeConfig, SilgiRuntimeContext, SilgiRuntimeDefaultConfig, SilgiRuntimeHooks, SilgiRuntimeMethods, SilgiRuntimeOptions, SilgiRuntimeShareds, SilgiRuntimeSharedsExtend, SilgiSchema, SilgiStorageBase, SilgiTemplate, SilgiURL, StandardHTTPMethod, StorageConfig, StorageKeyGenerator, StorageKeyParams, StorageMounts, TSReference, TrimAfterFourSlashes, WithPathParams };
|
|
1232
|
+
export type { AllPaths, AllPrefixes, AppConfig, Awaitable, BaseMethodSchema, BuildSilgi, CaptureError, CapturedErrorContext, CommandType, Commands, CustomRequestInit, DeepPartial, DeepRequired, DefaultHooks, DefineFrameworkOptions, DotenvOptions, EnvOptions, EventHandlerResponse, EventProtocol, ExtendContext, ExtendShared, ExtractNamespace, ExtractPathParamKeys, ExtractPathParams, ExtractPrefix, ExtractRoute, GenImport, GenerateAppOptions, HTTPMethod, HasPathParams, HookResult, LoadConfigOptions, MergeAll, MergeRouteRules, MergedSilgiSchema, MetaData, MethodSchemas, MiddlewareHandler, MiddlewareSetup, ModuleDefinition, ModuleHookContext, ModuleMeta, ModuleOptionsCustom, ModuleSetupInstallResult, ModuleSetupReturn, NamespacesForPrefix, NitroBuildInfo, RequiredServiceType, ResolvedMiddlewareDefinition, ResolvedModuleMeta, ResolvedModuleOptions, ResolvedSchema, ResolvedSchemaDefinition, ResolvedServiceDefinition, ResolvedSilgiTemplate, Resolvers, RouteEntry, RouteRules, RouterParams, Routers, RoutesForPrefixAndNamespace, ScanFile, Schema, ServiceHandler, ServiceHandlerInput, ServiceSetup, ServicesObject, SetupModuleOption, Silgi, SilgiAppPlugin, SilgiCLI, SilgiCLIConfig, SilgiCLIHooks, SilgiCLIOptions, SilgiCommands, SilgiCompatibility, SilgiCompatibilityIssue, SilgiCompatibilityIssues, SilgiConfig, SilgiEvent, SilgiFetchClient, SilgiFetchOptions, SilgiFrameworkInfo, SilgiHooks, SilgiModule, SilgiModuleInput, SilgiModuleOptions, SilgiOptions, SilgiPreset, SilgiPresetMeta, SilgiRoute, SilgiRouterTypes, SilgiRuntimeConfig, SilgiRuntimeContext, SilgiRuntimeDefaultConfig, SilgiRuntimeHooks, SilgiRuntimeMethods, SilgiRuntimeOptions, SilgiRuntimeShareds, SilgiRuntimeSharedsExtend, SilgiSchema, SilgiStorageBase, SilgiTemplate, SilgiURL, StandardHTTPMethod, StorageConfig, StorageKeyGenerator, StorageKeyParams, StorageMounts, TSReference, TrimAfterFourSlashes, WithPathParams };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "silgi",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.41.
|
|
4
|
+
"version": "0.41.20",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"exports": {
|
|
@@ -114,6 +114,7 @@
|
|
|
114
114
|
"dotenv": "^16.5.0",
|
|
115
115
|
"escape-string-regexp": "^5.0.0",
|
|
116
116
|
"exsolve": "^1.0.5",
|
|
117
|
+
"graphql": "^16.11.0",
|
|
117
118
|
"hookable": "^5.5.3",
|
|
118
119
|
"ignore": "^7.0.4",
|
|
119
120
|
"klona": "^2.0.6",
|