silgi 0.41.17 → 0.41.19

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.
@@ -1953,15 +1953,30 @@ async function prepareSchema(silgi) {
1953
1953
  generateTypes(
1954
1954
  await resolveSchema(
1955
1955
  {
1956
- ...silgi.options.storages?.reduce((acc, key) => ({ ...acc, [key]: "" }), {}) || {},
1957
- // 'redis': {} -> 'redis': string
1958
- ...Object.entries(silgi.options.storage).map(([key]) => ({
1959
- [key]: ""
1960
- })).reduce((acc, obj) => ({ ...acc, ...obj }), {})
1956
+ ...Object.fromEntries(
1957
+ Object.entries(silgi.options.runtimeConfig).filter(
1958
+ ([key]) => !["app", "nitro", "nuxt"].includes(key)
1959
+ )
1960
+ )
1961
+ }
1962
+ ),
1963
+ {
1964
+ interfaceName: "SilgiRuntimeConfigExtends",
1965
+ addExport: false,
1966
+ addDefaults: false,
1967
+ allowExtraKeys: false,
1968
+ indentation: 0
1969
+ }
1970
+ ),
1971
+ "",
1972
+ generateTypes(
1973
+ await resolveSchema(
1974
+ {
1975
+ ...silgi.services ? Object.keys(silgi.services).reduce((acc, key) => ({ ...acc, [key]: "" }), {}) : {}
1961
1976
  }
1962
1977
  ),
1963
1978
  {
1964
- interfaceName: "SilgiStorageBaseExtends",
1979
+ interfaceName: "RoutersExtend",
1965
1980
  addExport: false,
1966
1981
  addDefaults: false,
1967
1982
  allowExtraKeys: false,
@@ -1977,7 +1992,6 @@ async function prepareSchema(silgi) {
1977
1992
  SilgiSchema: [{}, { extends: ["SchemaExtends"] }],
1978
1993
  ServicesObject: [{}, { extends: ["BaseServices"] }],
1979
1994
  SilgiStorageBase: [{}, { extends: ["SilgiStorageBaseExtends"] }],
1980
- SilgiURIs: [{}, { extends: ["SilgiURIsMerge"] }],
1981
1995
  SilgiRuntimeContext: [{}, { extends: ["SilgiModuleContextExtends"] }],
1982
1996
  SilgiEvent: [{}, { extends: ["SilgiModuleEventsExtends"] }],
1983
1997
  SilgiRuntimeSharedsExtend: [{}, { extends: ["SilgiModuleSharedExtends"] }],
@@ -1991,7 +2005,8 @@ async function prepareSchema(silgi) {
1991
2005
  SilgiModuleOptions: [{}, { extends: ["SilgiModuleOptionExtend"] }],
1992
2006
  // TODO: bunu kontrol et.
1993
2007
  RouteRules: [{}, { extends: ["RouteRulesExtend"] }],
1994
- MetaData: [{}, { extends: ["MetaDataExtend"] }]
2008
+ MetaData: [{}, { extends: ["MetaDataExtend"] }],
2009
+ Routers: [{}, { extends: ["RoutersExtend"] }]
1995
2010
  }).replace(/,\s*/g, "\n"),
1996
2011
  "",
1997
2012
  "export {}"
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { defineCommand, runMain } from 'citty';
3
3
 
4
- const version = "0.41.17";
4
+ const version = "0.41.19";
5
5
  const packageJson = {
6
6
  version: version};
7
7
 
@@ -1,4 +1,4 @@
1
- import { SilgiConfig, Silgi, SilgiEvent, HTTPMethod, SilgiSchema, RouteEntry, CustomRequestInit, SilgiRuntimeContext, BaseMethodSchema, MergeAll, ServiceSetup, ServicesObject, MiddlewareSetup, SilgiRuntimeShareds, Resolvers, SilgiURL, StorageConfig, SilgiCLI, SilgiStorageBase, SilgiRuntimeConfig } from 'silgi/types';
1
+ import { SilgiConfig, Silgi, SilgiEvent, HTTPMethod, SilgiSchema, RouteEntry, CustomRequestInit, SilgiRuntimeContext, BaseMethodSchema, MergeAll, Routers, ServiceSetup, MiddlewareSetup, SilgiRuntimeShareds, Resolvers, SilgiURL, StorageConfig, SilgiCLI, SilgiStorageBase, SilgiRuntimeConfig } from 'silgi/types';
2
2
  import { StandardSchemaV1 } from '@standard-schema/spec';
3
3
  import { Storage, StorageValue } from 'unstorage';
4
4
  import { UseContext } from 'unctx';
@@ -159,33 +159,27 @@ declare function deepMergeObjects<T extends readonly Record<string, any>[]>(sche
159
159
  * Tip güvenliğini artırmak için ServiceSetup objesini doğrudan döndürür.
160
160
  */
161
161
  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 string> = SlashCount<S> extends 0 | 1 | 2 | 3 | 4 ? S : never;
163
- declare function createService<Path extends string = string, Input extends StandardSchemaV1 = StandardSchemaV1, Output extends StandardSchemaV1 = StandardSchemaV1, PathParams extends StandardSchemaV1 | never | undefined = never, QueryParams extends StandardSchemaV1 | never | undefined = never, Resolved extends boolean = false, HiddenParameters extends boolean = false>(params: {
162
+ type Max4Slashes<S extends keyof Routers> = SlashCount<S> extends 0 | 1 | 2 | 3 ? S : never;
163
+ 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> = {
164
+ GET?: ServiceSetup<Parent, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
165
+ POST?: ServiceSetup<Parent, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
166
+ PUT?: ServiceSetup<Parent, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
167
+ PATCH?: ServiceSetup<Parent, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
168
+ DELETE?: ServiceSetup<Parent, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
169
+ OPTIONS?: ServiceSetup<Parent, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
170
+ HEAD?: ServiceSetup<Parent, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
171
+ CONNECT?: ServiceSetup<Parent, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
172
+ TRACE?: ServiceSetup<Parent, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
173
+ };
174
+ 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
175
  path: Max4Slashes<Path>;
165
- methods: HTTPMethod[];
166
- input?: Input;
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
- };
176
+ } & ServiceSetupsForMethods<Parent, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>): {
177
+ [K in Path]: ServiceSetupsForMethods<Parent, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
184
178
  };
185
179
 
186
180
  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}`;
187
- type MiddlewarePath<S extends WildcardVariants<keyof ServicesObject>> = S | 'global';
188
- interface CreateMiddlewareParams<S extends WildcardVariants<keyof ServicesObject>, UsedMethod extends readonly HTTPMethod[] = readonly HTTPMethod[], Key extends string = string> {
181
+ type MiddlewarePath<S extends WildcardVariants<keyof Routers>> = S | 'global';
182
+ interface CreateMiddlewareParams<S extends WildcardVariants<keyof Routers>, UsedMethod extends readonly HTTPMethod[] = readonly HTTPMethod[], Key extends string = string> {
189
183
  path: MiddlewarePath<S>;
190
184
  methods?: UsedMethod;
191
185
  setup: MiddlewareSetup;
@@ -199,7 +193,7 @@ type CreateMiddlewareResult<Path extends string, UsedMethod extends readonly HTT
199
193
  path: Path;
200
194
  };
201
195
  };
202
- declare function createMiddleware<S extends WildcardVariants<keyof ServicesObject>, UsedMethod extends readonly HTTPMethod[] = readonly HTTPMethod[], Path extends MiddlewarePath<S> = MiddlewarePath<S>, Key extends string = string>(params: CreateMiddlewareParams<S, UsedMethod, Key> & {
196
+ declare function createMiddleware<S extends WildcardVariants<keyof Routers>, UsedMethod extends readonly HTTPMethod[] = readonly HTTPMethod[], Path extends MiddlewarePath<S> = MiddlewarePath<S>, Key extends string = string>(params: CreateMiddlewareParams<S, UsedMethod, Key> & {
203
197
  path: Path;
204
198
  }): CreateMiddlewareResult<Path, UsedMethod, Key>;
205
199
 
@@ -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,37 @@ async function createSilgi(config) {
298
299
  silgi.router = createRouter();
299
300
  }
300
301
  for (const [route, object] of Object.entries(silgi.services)) {
301
- const methods = object.methods?.length ? object.methods : ["ALL"];
302
- if (methods.includes("GRAPHQL")) {
303
- addRoute(silgi.router, "GRAPHQL", route, {
304
- method: "GRAPHQL",
305
- route,
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 methods) {
319
- const globalMethod = method === "ALL" ? "" : method.toUpperCase();
320
- addRoute(silgi.router, globalMethod, route, {
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
+ console.log("Route:", routeWithParams, method);
329
+ addRoute(silgi.router, method, routeWithParams, {
321
330
  method,
322
- route,
323
- service: object
331
+ route: routeWithParams,
332
+ service: routeObject
324
333
  });
325
334
  }
326
335
  }
@@ -391,12 +400,16 @@ class _SilgiEvent {
391
400
  req;
392
401
  url;
393
402
  context;
403
+ protocol;
404
+ // Added property
394
405
  _res;
395
406
  constructor(req, context) {
396
407
  this.context = context || new EmptyObject();
397
408
  this.req = req;
398
409
  const _url = req._url;
399
410
  this.url = _url && _url instanceof URL ? _url : new FastURL(req.url);
411
+ let proto = this.url.protocol.replace(":", "");
412
+ this.protocol = proto === "https" ? "http" : proto;
400
413
  }
401
414
  get res() {
402
415
  if (!this._res) {
@@ -607,7 +620,7 @@ async function orchestrate(route, event, _input) {
607
620
  pathParams: {},
608
621
  queryParams: {}
609
622
  };
610
- const input = _input || (route.service?.setup.rules?.readBeforeBody === false || isGraphQL ? {} : await parseRequestInput(event.req));
623
+ const input = _input || (route.service?.rules?.readBeforeBody === false || isGraphQL ? {} : await parseRequestInput(event.req));
611
624
  const hookContext = { earlyReturnValue: false };
612
625
  const routerParams = _input ? input.path : getRouterParams(event);
613
626
  const queryParams = _input ? input.query : getQuery(event);
@@ -619,10 +632,8 @@ async function orchestrate(route, event, _input) {
619
632
  }
620
633
  const inputData = {
621
634
  args: input,
622
- parameters: {
623
- query: queryParams,
624
- path: routerParams
625
- }
635
+ query: queryParams,
636
+ path: routerParams
626
637
  };
627
638
  try {
628
639
  if (!route.service && route.method !== "GRAPHQL") {
@@ -660,10 +671,17 @@ async function orchestrate(route, event, _input) {
660
671
  }
661
672
  silgiCtx.shared.$fetch = silgiFetch;
662
673
  silgiCtx.shared.silgi = silgiCtx;
663
- const result = await route.service?.setup.handler?.(
674
+ const result = await route.service?.handler?.(
675
+ // input
664
676
  inputData,
677
+ // shared
665
678
  silgiCtx.shared,
666
- event
679
+ // event
680
+ event,
681
+ // parent - graphql
682
+ {},
683
+ // info - graphql
684
+ {}
667
685
  );
668
686
  await silgiCtx.callHook("fetch:after", {
669
687
  event,
@@ -674,12 +692,12 @@ async function orchestrate(route, event, _input) {
674
692
  route,
675
693
  hookContext
676
694
  });
677
- if (route.service?.setup.storage && cacheData?.cachedKey) {
678
- await useSilgiStorage(route.service.setup.storage.base).setItem(
695
+ if (route.service?.storage && cacheData?.cachedKey) {
696
+ await useSilgiStorage(route.service.storage.base).setItem(
679
697
  cacheData.cachedKey,
680
698
  result,
681
699
  // Cast to StorageValue if needed
682
- route.service.setup.storage.options
700
+ route.service.storage.options
683
701
  );
684
702
  }
685
703
  return result;
@@ -709,17 +727,17 @@ async function orchestrate(route, event, _input) {
709
727
  }
710
728
  }
711
729
  async function cacheExecute(input, route, silgiURL, event) {
712
- if (!route.service || !route.service.setup?.storage)
730
+ if (!route.service || !route.service.storage)
713
731
  return;
714
- const cacheKey = route.service.setup.storage ? await generateStorageKey({
732
+ const cacheKey = route.service.storage ? await generateStorageKey({
715
733
  url: silgiURL,
716
734
  input,
717
- keyGenerator: route.service.setup.storage.key,
718
- storageOptions: route.service.setup.storage,
735
+ keyGenerator: route.service.storage.key,
736
+ storageOptions: route.service.storage,
719
737
  requestId: event?.requestId
720
738
  }) : null;
721
739
  if (cacheKey) {
722
- const cachedResult = await useSilgiStorage(route.service.setup.storage.base).getItem(cacheKey);
740
+ const cachedResult = await useSilgiStorage(route.service.storage.base).getItem(cacheKey);
723
741
  if (cachedResult !== null) {
724
742
  return {
725
743
  success: true,
@@ -941,7 +959,7 @@ async function middleware(event, url) {
941
959
  return _previous;
942
960
  }
943
961
  const allowedMethod = m.method ?? "";
944
- const methodIsAllowed = allowedMethod === "ALL" || allowedMethod === event.req.method || allowedMethod === "GRAPHQL";
962
+ const methodIsAllowed = allowedMethod === event.req.method || event.protocol === "GRAPHQL";
945
963
  if (!methodIsAllowed) {
946
964
  return;
947
965
  }
@@ -976,7 +994,7 @@ async function middleware(event, url) {
976
994
  return _previous;
977
995
  }
978
996
  const allowedMethod = match.data.method ?? "";
979
- const methodIsAllowed = allowedMethod === "ALL" || allowedMethod === event.req.method || allowedMethod === "GRAPHQL";
997
+ const methodIsAllowed = allowedMethod === event.req.method || event.protocol === "GRAPHQL";
980
998
  if (!methodIsAllowed || !match.data.middleware) {
981
999
  return;
982
1000
  }
@@ -1016,10 +1034,7 @@ async function handler(event, url, input) {
1016
1034
  data: {
1017
1035
  method: url?.method || event.req.method,
1018
1036
  route: url?.path,
1019
- service: {
1020
- setup: {},
1021
- methods: ["GRAPHQL"]
1022
- }
1037
+ service: {}
1023
1038
  },
1024
1039
  params: {}
1025
1040
  };
@@ -1091,22 +1106,18 @@ function deepMergeObjects(schemas) {
1091
1106
  }
1092
1107
 
1093
1108
  function createService(params) {
1094
- const slashCount = (params.path.match(/\//g) || []).length;
1109
+ const slashCount = (String(params.path).match(/\//g) || []).length;
1095
1110
  if (slashCount > 4) {
1096
1111
  throw new Error(
1097
1112
  `Path '${params.path}' is invalid: maximum 4 '/' allowed (found ${slashCount})`
1098
1113
  );
1099
1114
  }
1100
- const result = {};
1101
- const { path, setup, methods, input, output, queryParams } = params;
1102
- result[path] = {
1103
- setup,
1104
- methods,
1105
- input,
1106
- output,
1107
- queryParams
1115
+ const { path, ...objects } = params;
1116
+ return {
1117
+ [path]: {
1118
+ ...objects
1119
+ }
1108
1120
  };
1109
- return result;
1110
1121
  }
1111
1122
 
1112
1123
  function createMiddleware(params) {
package/dist/index.mjs CHANGED
@@ -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';
@@ -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
  */
@@ -134,6 +140,8 @@ interface SilgiEvent extends Record<string, unknown> {
134
140
  */
135
141
  interface Resolvers {
136
142
  }
143
+ interface Routers {
144
+ }
137
145
  interface RouteRules extends Record<string, unknown> {
138
146
  }
139
147
  type MergeRouteRules = Partial<RouteRules> & {
@@ -158,7 +166,7 @@ type ExtractRoute<URL extends string> = URL extends `/${string}/${string}/${infe
158
166
  * Gets all route keys from Routers as strings.
159
167
  * All keys should start with a leading slash.
160
168
  */
161
- type RouterKeys = keyof ServicesObject & string;
169
+ type RouterKeys = (keyof ServicesObject extends string ? keyof ServicesObject : never) & (keyof Routers extends string ? keyof Routers : never);
162
170
  /**
163
171
  * Extracts all prefixes (first segment) in the system, including the leading slash.
164
172
  * @example AllPrefixes // '/api' | ...
@@ -241,20 +249,14 @@ type ServiceHandlerInput<Input extends StandardSchemaV1 = StandardSchemaV1, Path
241
249
  args: InferInput<Input>;
242
250
  } : HasPath<PathParams> extends true ? HasQuery<QueryParams> extends true ? {
243
251
  args: InferInput<Input>;
244
- parameters: {
245
- path: InferInput<PathParams>;
246
- query: Partial<InferInput<QueryParams>>;
247
- };
252
+ path: InferInput<PathParams>;
253
+ query: Partial<InferInput<QueryParams>>;
248
254
  } : {
249
255
  args: InferInput<Input>;
250
- parameters: {
251
- path: InferInput<PathParams>;
252
- };
256
+ path: InferInput<PathParams>;
253
257
  } : HasQuery<QueryParams> extends true ? {
254
258
  args: InferInput<Input>;
255
- parameters: {
256
- query: InferInput<QueryParams>;
257
- };
259
+ query: InferInput<QueryParams>;
258
260
  } : {
259
261
  args: InferInput<Input>;
260
262
  };
@@ -264,15 +266,19 @@ type ServiceHandlerInput<Input extends StandardSchemaV1 = StandardSchemaV1, Path
264
266
  * Resolved = false -> handler(input, shared, event, source) // all required
265
267
  * Resolved = true -> handler(input, shared?, event?, source?) // only input required
266
268
  */
267
- 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>;
268
270
  /**
269
271
  * Servis setup tipi
270
272
  */
271
- interface ServiceSetup<Input extends StandardSchemaV1 = StandardSchemaV1, Output extends StandardSchemaV1 = StandardSchemaV1, PathParams extends StandardSchemaV1 | never | undefined = never, QueryParams extends StandardSchemaV1 | never | undefined = never, Resolved extends boolean = false, HiddenParameters extends boolean = false> {
272
- 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>;
273
275
  rules?: MergeRouteRules;
274
276
  modules?: Partial<SetupModuleOption>;
275
277
  storage?: StorageConfig<ServiceHandlerInput<Input, PathParams, QueryParams, HiddenParameters>>;
278
+ input?: Input;
279
+ output?: Output;
280
+ pathParams?: PathParams;
281
+ queryParams?: QueryParams;
276
282
  }
277
283
  /**
278
284
  * Represents a fully resolved service definition that maps route paths
@@ -285,14 +291,15 @@ interface ServiceSetup<Input extends StandardSchemaV1 = StandardSchemaV1, Output
285
291
  */
286
292
  interface ResolvedServiceDefinition {
287
293
  [routePath: string]: {
288
- setup: ServiceSetup<any, any, any, any, any, any>;
289
- methods: HTTPMethod[];
290
- input?: StandardSchemaV1;
291
- output?: StandardSchemaV1;
292
- queryParams?: {
293
- path?: StandardSchemaV1;
294
- query?: StandardSchemaV1;
295
- };
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>;
296
303
  };
297
304
  }
298
305
  /**
@@ -691,14 +698,14 @@ interface ResolvedSchemaDefinition {
691
698
  [methodAndRoutePath: string]: BaseMethodSchema;
692
699
  }
693
700
 
694
- type StandardHTTPMethod = 'GET' | 'HEAD' | 'PATCH' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'ALL' | 'GRAPHQL';
701
+ type StandardHTTPMethod = 'GET' | 'HEAD' | 'PATCH' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE';
695
702
  type HTTPMethod = StandardHTTPMethod | (keyof SilgiRuntimeMethods extends string ? keyof SilgiRuntimeMethods : never);
696
703
  interface MetaData extends Record<string, unknown> {
697
704
  }
698
705
  interface SilgiRoute {
699
706
  route?: string;
700
707
  method?: HTTPMethod;
701
- service?: ResolvedServiceDefinition[string];
708
+ service?: ResolvedServiceDefinition[string][keyof ResolvedServiceDefinition[string]];
702
709
  middleware?: MiddlewareSetup;
703
710
  }
704
711
  interface Silgi {
@@ -1222,4 +1229,4 @@ interface LoadConfigOptions {
1222
1229
  consola?: ConsolaInstance;
1223
1230
  }
1224
1231
 
1225
- 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, 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.17",
4
+ "version": "0.41.19",
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",