silgi 0.41.61 → 0.42.0

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.
@@ -744,10 +744,29 @@ async function extractExportEntitiesFromFile(absoluteFilePath, functionExportNam
744
744
  if (Array.isArray(decls)) {
745
745
  for (const decl of decls) {
746
746
  if (decl.type === "VariableDeclarator" && decl.id.type === "Identifier" && decl.init && decl.init.type === "CallExpression" && decl.init.callee.type === "Identifier" && functionExportNames.includes(decl.init.callee.name)) {
747
+ let servicePath;
748
+ let serviceMethod;
749
+ if (decl.init.callee.name === "createService") {
750
+ const firstArg = decl.init.arguments?.[0];
751
+ if (firstArg && firstArg.type === "ObjectExpression" && Array.isArray(firstArg.properties)) {
752
+ for (const prop of firstArg.properties) {
753
+ if (prop.type === "Property" && prop.key.type === "Identifier") {
754
+ if (prop.key.name === "path" && prop.value.type === "Literal" && typeof prop.value.value === "string") {
755
+ servicePath = prop.value.value;
756
+ }
757
+ if (prop.key.name === "method" && prop.value.type === "Literal" && typeof prop.value.value === "string") {
758
+ serviceMethod = prop.value.value;
759
+ }
760
+ }
761
+ }
762
+ }
763
+ }
747
764
  exportEntities.push({
748
765
  name: decl.id.name,
749
766
  type: "function",
750
- funcName: decl.init.callee.name
767
+ funcName: decl.init.callee.name,
768
+ servicePath,
769
+ serviceMethod
751
770
  });
752
771
  }
753
772
  }
@@ -815,6 +834,21 @@ async function scanSilgiExports(path, packageName, silgiInstance = useSilgiCLI()
815
834
  functionExportNames,
816
835
  interfaceExtendsNames
817
836
  );
837
+ const seenServiceSignatures = /* @__PURE__ */ new Map();
838
+ for (const entity of exportEntities) {
839
+ if (entity.funcName === "createService" && entity.servicePath && entity.serviceMethod) {
840
+ const key = `${entity.serviceMethod}:${entity.servicePath}`;
841
+ if (seenServiceSignatures.has(key)) {
842
+ throw new Error(
843
+ `Duplicate createService detected for path "${entity.servicePath}" and method "${entity.serviceMethod}".
844
+ First found in: ${seenServiceSignatures.get(key)}
845
+ Duplicate in: ${absoluteFilePath}
846
+ Please ensure each service path/method combination is unique.`
847
+ );
848
+ }
849
+ seenServiceSignatures.set(key, absoluteFilePath);
850
+ }
851
+ }
818
852
  const allExportedEntities = exportEntities;
819
853
  const { runtimeExports, typeExports } = categorizeExports(
820
854
  allExportedEntities,
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { defineCommand, runMain } from 'citty';
3
3
 
4
- const version = "0.41.61";
4
+ const version = "0.42.0";
5
5
  const packageJson = {
6
6
  version: version};
7
7
 
@@ -3,6 +3,7 @@ import { ServerRequest, ServerRuntimeContext } from 'srvx';
3
3
  import { UseContext } from 'unctx';
4
4
  import { Storage, StorageValue } from 'unstorage';
5
5
  export { c as createMiddleware } from '../shared/silgi.DTwQEdSr.mjs';
6
+ import { Hooks } from 'crossws';
6
7
 
7
8
  declare function updateRuntimeStorage(runtime: any): void;
8
9
  /**
@@ -93,12 +94,12 @@ declare class SilgiHttpEvent implements SilgiEvent {
93
94
  context: SilgiRuntimeContext;
94
95
  _res?: SilgiEventResponse;
95
96
  constructor(req: ServerRequest, context?: SilgiRuntimeContext);
96
- get _chain(): Promise<unknown> | undefined;
97
+ _chain: Promise<unknown> | undefined;
98
+ [x: string]: unknown;
97
99
  get res(): SilgiEventResponse;
98
100
  get runtime(): ServerRuntimeContext | undefined;
99
101
  toString(): string;
100
102
  toJSON(): string;
101
- [x: string]: unknown;
102
103
  }
103
104
  declare class SilgiEventResponse {
104
105
  status?: number;
@@ -304,8 +305,8 @@ declare function createSchema<Key extends string, Schema extends BaseMethodSchem
304
305
  * ServiceSetup tipinden oluşan bir yardımcı fonksiyon.
305
306
  * Tip güvenliğini artırmak için ServiceSetup objesini doğrudan döndürür.
306
307
  */
307
- declare function defineServiceSetup<Method extends HTTPMethod, Path extends 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>(setup: Omit<ServiceSetup<Method, Path, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>, 'method' | 'path'>): Omit<ServiceSetup<Method, Path, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>, 'method' | 'path'>;
308
- declare function createService<Path extends string, Method extends HTTPMethod, 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: ServiceSetupsForMethods<Method, Path, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>): ServiceDefinitionByMethodAndPath<Path, Method, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
308
+ declare function defineServiceSetup<Method extends HTTPMethod, Path extends 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, Websocket extends Partial<Hooks> | undefined = undefined>(setup: Omit<ServiceSetup<Method, Path, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters, Websocket>, 'method' | 'path'>): Omit<ServiceSetup<Method, Path, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters, Websocket>, 'method' | 'path'>;
309
+ declare function createService<Path extends string, Method extends HTTPMethod, 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, Websocket extends Partial<Hooks> | undefined = undefined>(params: ServiceSetupsForMethods<Method, Path, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters, Websocket>): ServiceDefinitionByMethodAndPath<Path, Method, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters, Websocket>;
309
310
 
310
311
  declare function createShared(shared: Partial<SilgiRuntimeShareds>): SilgiRuntimeShareds;
311
312
 
@@ -450,9 +450,7 @@ class SilgiHttpEvent {
450
450
  const _url = req._url;
451
451
  this.url = _url && _url instanceof URL ? _url : new FastURL(req.url);
452
452
  }
453
- get _chain() {
454
- return this._chain;
455
- }
453
+ _chain;
456
454
  get res() {
457
455
  if (!this._res) {
458
456
  this._res = new SilgiEventResponse();
package/dist/index.d.mts CHANGED
@@ -4,3 +4,4 @@ import 'silgi/types';
4
4
  import 'srvx';
5
5
  import 'unctx';
6
6
  import 'unstorage';
7
+ import 'crossws';
@@ -23,7 +23,7 @@ import { TransactionOptions, BuiltinDriverName, StorageValue, Storage } from 'un
23
23
  import { ServerRequest } from 'srvx';
24
24
  import { C as CreateMiddlewareResult } from '../shared/silgi.DTwQEdSr.mjs';
25
25
  import { Defu } from 'defu';
26
- import * as crossws from 'crossws';
26
+ import { Hooks, ResolveHooks } from 'crossws';
27
27
  import { silgiFetch } from 'silgi';
28
28
  import { useRuntimeConfig } from 'silgi/runtime';
29
29
  import { Unimport } from 'unimport';
@@ -292,9 +292,9 @@ declare namespace StandardSchemaV1 {
292
292
  interface ServicesObject {
293
293
  }
294
294
  interface WebSocketOptions {
295
- resolve?: crossws.ResolveHooks;
296
- hooks?: Partial<crossws.Hooks>;
297
- adapterHooks?: Partial<crossws.Hooks>;
295
+ resolve?: ResolveHooks;
296
+ hooks?: Partial<Hooks>;
297
+ adapterHooks?: Partial<Hooks>;
298
298
  }
299
299
  type SlashCount<S extends string, Count extends any[] = []> = S extends `${infer _Prefix}/${infer Rest}` ? SlashCount<Rest, [any, ...Count]> : Count['length'];
300
300
  type Max4Slashes<S extends keyof Routers> = SlashCount<S> extends 0 | 1 | 2 | 3 ? S : never;
@@ -332,11 +332,11 @@ type ServiceHandler<Input extends StandardSchemaV1, Output extends StandardSchem
332
332
  /**
333
333
  * Servis setup tipi
334
334
  */
335
- interface ServiceSetup<Method extends HTTPMethod = HTTPMethod, Path extends string = string, 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> {
335
+ interface ServiceSetup<Method extends HTTPMethod = HTTPMethod, Path extends string = string, 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, Websocket extends Partial<Hooks> | undefined = undefined> {
336
336
  path: Path;
337
337
  method?: Method;
338
338
  handler?: ServiceHandler<Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
339
- websocket?: Partial<crossws.Hooks>;
339
+ websocket?: Websocket;
340
340
  rules?: MergeRouteRules;
341
341
  modules?: Partial<SetupModuleOption>;
342
342
  storage?: StorageConfig<ServiceHandlerInput<Input, PathParams, QueryParams, HiddenParameters>>;
@@ -369,7 +369,8 @@ interface SilgiURL {
369
369
  pathParams?: Record<string, string | undefined>;
370
370
  queryParams?: Record<string, string>;
371
371
  }
372
- type ServiceSetupsForMethods<Method extends HTTPMethod = HTTPMethod, Path extends string = string, 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> = ServiceSetup<Method, Path, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
372
+ type IsWebsocketEnabled<T> = [T] extends [undefined] | [never] ? false : true;
373
+ type ServiceSetupsForMethods<Method extends HTTPMethod = HTTPMethod, Path extends string = string, 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, Websocket extends Partial<Hooks> | undefined = undefined> = ServiceSetup<Method, Path, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters, Websocket>;
373
374
  /**
374
375
  * Sadece belirtilen HTTP methodları için anahtar üretir.
375
376
  * Varsayılan olarak tüm methodlar çıkar.
@@ -378,8 +379,8 @@ type ServiceSetupsForMethods<Method extends HTTPMethod = HTTPMethod, Path extend
378
379
  * ServiceDefinitionByMethodAndPath<'/foo', ..., 'GET' | 'POST'>
379
380
  * // Sadece "GET:/foo" ve "POST:/foo" anahtarları olur.
380
381
  */
381
- type ServiceDefinitionByMethodAndPath<Path extends string, Method extends HTTPMethod = HTTPMethod, 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> = {
382
- [M in Method as `${M}:${Path}`]: ServiceSetup<M, Path, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
382
+ type ServiceDefinitionByMethodAndPath<Path extends string, Method extends HTTPMethod = HTTPMethod, 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, Websocket extends Partial<Hooks> | undefined = undefined> = {
383
+ [M in Method as IsWebsocketEnabled<Websocket> extends true ? `websocket:${M}:${Path}` : `http:${M}:${Path}`]: ServiceSetup<M, Path, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters, Websocket>;
383
384
  };
384
385
 
385
386
  interface SilgiCLI {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.41.61",
4
+ "version": "0.42.0",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {
@@ -95,13 +95,13 @@
95
95
  }
96
96
  },
97
97
  "dependencies": {
98
- "@antfu/ni": "^24.3.0",
99
- "@clack/prompts": "^0.10.1",
98
+ "@antfu/ni": "^24.4.0",
99
+ "@clack/prompts": "^0.11.0",
100
100
  "@fastify/deepmerge": "^3.1.0",
101
101
  "@graphql-tools/utils": "^10.8.6",
102
102
  "@standard-community/standard-json": "^0.2.0",
103
103
  "apiful": "^2.2.0",
104
- "c12": "^3.0.3",
104
+ "c12": "^3.0.4",
105
105
  "chokidar": "^4.0.3",
106
106
  "citty": "^0.1.6",
107
107
  "compatx": "^0.2.0",
@@ -124,7 +124,7 @@
124
124
  "mlly": "^1.7.4",
125
125
  "ofetch": "^1.4.1",
126
126
  "ohash": "^2.0.11",
127
- "oxc-parser": "^0.68.1",
127
+ "oxc-parser": "^0.72.0",
128
128
  "pathe": "^2.0.3",
129
129
  "perfect-debounce": "^1.0.0",
130
130
  "picocolors": "^1.1.1",
@@ -132,8 +132,8 @@
132
132
  "rfc6902": "^5.1.2",
133
133
  "rou3": "^0.6.1",
134
134
  "scule": "^1.3.0",
135
- "semver": "^7.7.1",
136
- "srvx": "^0.6.0",
135
+ "semver": "^7.7.2",
136
+ "srvx": "^0.7.1",
137
137
  "std-env": "^3.9.0",
138
138
  "tinyexec": "^1.0.1",
139
139
  "tinyglobby": "^0.2.13",
@@ -145,24 +145,24 @@
145
145
  "untyped": "^2.0.0"
146
146
  },
147
147
  "devDependencies": {
148
- "@antfu/eslint-config": "^4.13.0",
149
- "@nuxt/kit": "^3.17.2",
150
- "@nuxt/schema": "^3.17.2",
151
- "@silgi/ecosystem": "^0.6.8",
148
+ "@antfu/eslint-config": "^4.13.2",
149
+ "@nuxt/kit": "^3.17.4",
150
+ "@nuxt/schema": "^3.17.4",
151
+ "@silgi/ecosystem": "^0.7.0",
152
152
  "@types/micromatch": "^4.0.9",
153
- "@types/node": "^22.15.16",
153
+ "@types/node": "^22.15.21",
154
154
  "@types/semver": "^7.7.0",
155
155
  "@vitest/coverage-v8": "3.0.5",
156
- "eslint": "^9.26.0",
156
+ "eslint": "^9.27.0",
157
157
  "h3": "^1.15.3",
158
158
  "next": "^15.3.2",
159
- "nitropack": "^2.11.11",
160
- "nuxt": "^3.17.2",
159
+ "nitropack": "^2.11.12",
160
+ "nuxt": "^3.17.4",
161
161
  "typescript": "^5.8.3",
162
162
  "unbuild": "^3.5.0",
163
- "vitest": "^3.1.3",
164
- "vue": "^3.5.13",
165
- "zod": "^3.24.4"
163
+ "vitest": "^3.1.4",
164
+ "vue": "^3.5.14",
165
+ "zod": "^3.25.28"
166
166
  },
167
167
  "resolutions": {
168
168
  "silgi": "link:."