silgi 0.41.57 → 0.41.58
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 +12 -32
- package/dist/core/index.mjs +7 -4
- package/dist/index.d.mts +2 -1
- package/dist/shared/silgi.DTwQEdSr.d.mts +16 -0
- package/dist/types/index.d.mts +15 -10
- package/package.json +2 -1
package/dist/cli/index.mjs
CHANGED
package/dist/core/index.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { SilgiRuntimeConfig, SilgiConfig, Silgi, SilgiEvent, SilgiRuntimeContext, SilgiSchema, RouteEntry, CustomRequestInit,
|
|
2
|
-
import { ServerRequest } from 'srvx';
|
|
1
|
+
import { SilgiRuntimeConfig, SilgiConfig, Silgi, SilgiEvent, SilgiRuntimeContext, WebSocketOptions, SilgiSchema, RouteEntry, CustomRequestInit, SilgiCLI, SilgiStorageBase, MergeAll, Resolvers, SilgiURL, BaseMethodSchema, HTTPMethod, ServiceSetupsForMethods, ServiceDefinitionByMethodAndPath, Routers, ServiceSetup, SilgiRuntimeShareds, StorageConfig } from 'silgi/types';
|
|
2
|
+
import { ServerRequest, ServerRuntimeContext } from 'srvx';
|
|
3
3
|
import { UseContext } from 'unctx';
|
|
4
4
|
import { Storage, StorageValue } from 'unstorage';
|
|
5
|
+
export { c as createMiddleware } from '../shared/silgi.DTwQEdSr.mjs';
|
|
5
6
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
6
7
|
|
|
7
8
|
declare function updateRuntimeStorage(runtime: any): void;
|
|
@@ -93,11 +94,12 @@ declare class SilgiHttpEvent implements SilgiEvent {
|
|
|
93
94
|
context: SilgiRuntimeContext;
|
|
94
95
|
_res?: SilgiEventResponse;
|
|
95
96
|
constructor(req: ServerRequest, context?: SilgiRuntimeContext);
|
|
96
|
-
_chain: Promise<unknown> | undefined;
|
|
97
|
-
[x: string]: unknown;
|
|
97
|
+
get _chain(): Promise<unknown> | undefined;
|
|
98
98
|
get res(): SilgiEventResponse;
|
|
99
|
+
get runtime(): ServerRuntimeContext | undefined;
|
|
99
100
|
toString(): string;
|
|
100
101
|
toJSON(): string;
|
|
102
|
+
[x: string]: unknown;
|
|
101
103
|
}
|
|
102
104
|
declare class SilgiEventResponse {
|
|
103
105
|
status?: number;
|
|
@@ -259,26 +261,6 @@ declare function getEventContext<T extends SilgiRuntimeContext>(event?: SilgiEve
|
|
|
259
261
|
*/
|
|
260
262
|
declare function deepMergeObjects<T extends readonly Record<string, any>[]>(schemas: [...T]): MergeAll<T>;
|
|
261
263
|
|
|
262
|
-
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}`;
|
|
263
|
-
type MiddlewarePath<S extends WildcardVariants<keyof Routers>> = S | 'global';
|
|
264
|
-
interface CreateMiddlewareParams<S extends WildcardVariants<keyof Routers>, UsedMethod extends readonly HTTPMethod[] = readonly HTTPMethod[], Key extends string = string> {
|
|
265
|
-
path: MiddlewarePath<S>;
|
|
266
|
-
methods?: UsedMethod;
|
|
267
|
-
setup: MiddlewareSetup;
|
|
268
|
-
key: Key;
|
|
269
|
-
}
|
|
270
|
-
type CreateMiddlewareResult<Path extends string, UsedMethod extends readonly HTTPMethod[] = readonly HTTPMethod[], Key extends string = string> = {
|
|
271
|
-
[K in `${Key}:${Path}`]: {
|
|
272
|
-
setup: MiddlewareSetup;
|
|
273
|
-
methods?: UsedMethod;
|
|
274
|
-
key: Key;
|
|
275
|
-
path: Path;
|
|
276
|
-
};
|
|
277
|
-
};
|
|
278
|
-
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> & {
|
|
279
|
-
path: Path;
|
|
280
|
-
}): CreateMiddlewareResult<Path, UsedMethod, Key>;
|
|
281
|
-
|
|
282
264
|
declare function createResolver(resolver: Resolvers): Resolvers;
|
|
283
265
|
declare function getUrlPrefix(path: string, method?: string): SilgiURL;
|
|
284
266
|
|
|
@@ -293,20 +275,18 @@ declare function replaceRuntimeValues(obj: any, runtime: any): any;
|
|
|
293
275
|
* This utility function helps you define API schemas with proper typing for
|
|
294
276
|
* input, output, path parameters, and query parameters.
|
|
295
277
|
*
|
|
296
|
-
* @template
|
|
297
|
-
* @template
|
|
278
|
+
* @template Key - API key
|
|
279
|
+
* @template Schema - Schema definition type
|
|
298
280
|
*
|
|
299
281
|
* @param params - Schema configuration parameters
|
|
300
|
-
* @param params.
|
|
301
|
-
* @param params.method - HTTP method(s) as an array (optional)
|
|
282
|
+
* @param params.key - Unique key for the schema
|
|
302
283
|
* @param params.setup - Schema definition for the specified methods
|
|
303
284
|
* @returns Route schema object with complete type information
|
|
304
285
|
*
|
|
305
286
|
* @example
|
|
306
|
-
* // Define a user API schema
|
|
287
|
+
* // Define a user API schema
|
|
307
288
|
* const userSchema = createSchema({
|
|
308
|
-
*
|
|
309
|
-
* method: ['GET', 'POST'],
|
|
289
|
+
* key: '/api/v1/users',
|
|
310
290
|
* setup: {
|
|
311
291
|
* output: z.object({
|
|
312
292
|
* users: z.array(z.object({ id: z.string(), name: z.string() }))
|
|
@@ -335,4 +315,4 @@ declare function useSilgiStorage<T extends StorageValue = StorageValue>(base?: S
|
|
|
335
315
|
|
|
336
316
|
declare const autoImportTypes: string[];
|
|
337
317
|
|
|
338
|
-
export { SilgiError, SilgiHttpEvent, autoImportTypes, createError, createEventStream,
|
|
318
|
+
export { SilgiError, SilgiHttpEvent, autoImportTypes, createError, createEventStream, createResolver, createSchema, createService, createShared, createSilgi, createStorage, deepMergeObjects, defineServiceSetup, getEvent, getEventContext, getUrlPrefix, getWebsocket, handleResponse, handler, isError, kHandled, kNotFound, middleware, replaceRuntimeValues, silgiCLICtx, silgiCtx, silgiFetch, storageMount, tryUseSilgi, tryUseSilgiCLI, updateRuntimeStorage, useRuntime, useSilgi, useSilgiCLI, useSilgiStorage };
|
package/dist/core/index.mjs
CHANGED
|
@@ -450,13 +450,18 @@ class SilgiHttpEvent {
|
|
|
450
450
|
const _url = req._url;
|
|
451
451
|
this.url = _url && _url instanceof URL ? _url : new FastURL(req.url);
|
|
452
452
|
}
|
|
453
|
-
_chain
|
|
453
|
+
get _chain() {
|
|
454
|
+
return this._chain;
|
|
455
|
+
}
|
|
454
456
|
get res() {
|
|
455
457
|
if (!this._res) {
|
|
456
458
|
this._res = new SilgiEventResponse();
|
|
457
459
|
}
|
|
458
460
|
return this._res;
|
|
459
461
|
}
|
|
462
|
+
get runtime() {
|
|
463
|
+
return this.req.runtime;
|
|
464
|
+
}
|
|
460
465
|
toString() {
|
|
461
466
|
return `[${this.req.method}] ${this.req.url}`;
|
|
462
467
|
}
|
|
@@ -1070,13 +1075,11 @@ function getWebsocket(silgi = useSilgi()) {
|
|
|
1070
1075
|
return {
|
|
1071
1076
|
...silgi.options.websocket,
|
|
1072
1077
|
resolve: async (request) => {
|
|
1073
|
-
console.log("WebSocket resolve");
|
|
1074
|
-
getPathname(request.url || "/");
|
|
1075
1078
|
request.method || "GET";
|
|
1076
1079
|
const event = new SilgiHttpEvent(request, {});
|
|
1077
1080
|
const silgiContext = useSilgi();
|
|
1078
1081
|
const handler2 = silgiContext.router && findRoute(silgiContext.router, event.req.method, event.url.pathname);
|
|
1079
|
-
return handler2?.data.service?.websocket
|
|
1082
|
+
return handler2?.data.service?.websocket || {};
|
|
1080
1083
|
}
|
|
1081
1084
|
};
|
|
1082
1085
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { SilgiError, SilgiHttpEvent, autoImportTypes, createError, createEventStream,
|
|
1
|
+
export { SilgiError, SilgiHttpEvent, autoImportTypes, createError, createEventStream, createResolver, createSchema, createService, createShared, createSilgi, createStorage, deepMergeObjects, defineServiceSetup, getEvent, getEventContext, getUrlPrefix, getWebsocket, handleResponse, handler, isError, kHandled, kNotFound, middleware, replaceRuntimeValues, silgiCLICtx, silgiCtx, silgiFetch, storageMount, tryUseSilgi, tryUseSilgiCLI, updateRuntimeStorage, useRuntime, useSilgi, useSilgiCLI, useSilgiStorage } from './core/index.mjs';
|
|
2
|
+
export { c as createMiddleware } from './shared/silgi.DTwQEdSr.mjs';
|
|
2
3
|
import 'silgi/types';
|
|
3
4
|
import 'srvx';
|
|
4
5
|
import 'unctx';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { WildcardVariants, Routers, HTTPMethod, MiddlewarePath, CreateMiddlewareParams, MiddlewareSetup } from 'silgi/types';
|
|
2
|
+
|
|
3
|
+
type CreateMiddlewareResult<Path extends string, UsedMethod extends readonly HTTPMethod[] = readonly HTTPMethod[], Key extends string = string> = {
|
|
4
|
+
[K in `${Key}:${Path}`]: {
|
|
5
|
+
setup: MiddlewareSetup;
|
|
6
|
+
methods?: UsedMethod;
|
|
7
|
+
key: Key;
|
|
8
|
+
path: Path;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
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> & {
|
|
12
|
+
path: Path;
|
|
13
|
+
}): CreateMiddlewareResult<Path, UsedMethod, Key>;
|
|
14
|
+
|
|
15
|
+
export { createMiddleware as c };
|
|
16
|
+
export type { CreateMiddlewareResult as C };
|
package/dist/types/index.d.mts
CHANGED
|
@@ -22,6 +22,7 @@ import { NitroApp } from 'nitropack';
|
|
|
22
22
|
import { RouterContext } from 'rou3';
|
|
23
23
|
import { TransactionOptions, BuiltinDriverName, StorageValue, Storage } from 'unstorage';
|
|
24
24
|
import { ServerRequest } from 'srvx';
|
|
25
|
+
import { C as CreateMiddlewareResult } from '../shared/silgi.DTwQEdSr.mjs';
|
|
25
26
|
import { Defu } from 'defu';
|
|
26
27
|
import * as crossws from 'crossws';
|
|
27
28
|
import { silgiFetch } from 'silgi';
|
|
@@ -29,6 +30,7 @@ import { useRuntimeConfig } from 'silgi/runtime';
|
|
|
29
30
|
import { Unimport } from 'unimport';
|
|
30
31
|
import { ProviderName } from 'std-env';
|
|
31
32
|
import { FetchOptions, FetchResponse } from 'ofetch';
|
|
33
|
+
import 'silgi/types';
|
|
32
34
|
|
|
33
35
|
interface SilgiCompatibilityIssue {
|
|
34
36
|
name: string;
|
|
@@ -121,7 +123,7 @@ interface SilgiEvent extends Record<string, unknown> {
|
|
|
121
123
|
* Access to runtime specific additional context.
|
|
122
124
|
*
|
|
123
125
|
*/
|
|
124
|
-
runtime: ServerRequest[
|
|
126
|
+
runtime: ServerRequest['runtime'];
|
|
125
127
|
/**
|
|
126
128
|
* Access to the parsed request URL.
|
|
127
129
|
*
|
|
@@ -297,7 +299,7 @@ interface ServiceSetup<Method extends HTTPMethod = HTTPMethod, Path extends stri
|
|
|
297
299
|
* Format: "routePath" => setup + methods + input + output + queryParams
|
|
298
300
|
*/
|
|
299
301
|
interface ResolvedServiceDefinition {
|
|
300
|
-
[key: string]: ServiceSetup
|
|
302
|
+
[key: string]: ServiceSetup<any, any, any, any, any, any, any, any>;
|
|
301
303
|
}
|
|
302
304
|
/**
|
|
303
305
|
* SilgiURL tipi
|
|
@@ -321,7 +323,7 @@ type ServiceSetupsForMethods<Method extends HTTPMethod = HTTPMethod, Path extend
|
|
|
321
323
|
* // Sadece "GET:/foo" ve "POST:/foo" anahtarları olur.
|
|
322
324
|
*/
|
|
323
325
|
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> = {
|
|
324
|
-
[M in Method as `${M}:${Path}`]
|
|
326
|
+
[M in Method as `${M}:${Path}`]: ServiceSetup<M, Path, Input, Output, PathParams, QueryParams, Resolved, HiddenParameters>;
|
|
325
327
|
};
|
|
326
328
|
|
|
327
329
|
interface SilgiCLI {
|
|
@@ -521,6 +523,14 @@ interface SilgiModule<TOptions extends ModuleOptionsCustom = ModuleOptionsCustom
|
|
|
521
523
|
getMeta?: () => Promise<ModuleMeta>;
|
|
522
524
|
}
|
|
523
525
|
|
|
526
|
+
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}`;
|
|
527
|
+
type MiddlewarePath<S extends WildcardVariants<keyof Routers>> = S | 'global';
|
|
528
|
+
interface CreateMiddlewareParams<S extends WildcardVariants<keyof Routers>, UsedMethod extends readonly HTTPMethod[] = readonly HTTPMethod[], Key extends string = string> {
|
|
529
|
+
path: MiddlewarePath<S>;
|
|
530
|
+
methods?: UsedMethod;
|
|
531
|
+
setup: MiddlewareSetup;
|
|
532
|
+
key: Key;
|
|
533
|
+
}
|
|
524
534
|
type MiddlewareHandler<Response extends EventHandlerResponse = EventHandlerResponse> = (event: SilgiEvent, silgi: Silgi) => Response;
|
|
525
535
|
/**
|
|
526
536
|
* Middleware Setup tipi
|
|
@@ -531,12 +541,7 @@ interface MiddlewareSetup {
|
|
|
531
541
|
modules?: Partial<SetupModuleOption>;
|
|
532
542
|
storage?: StorageConfig;
|
|
533
543
|
}
|
|
534
|
-
|
|
535
|
-
[methodAndPath: string]: {
|
|
536
|
-
setup: MiddlewareSetup;
|
|
537
|
-
methods?: HTTPMethod[];
|
|
538
|
-
};
|
|
539
|
-
}
|
|
544
|
+
type ResolvedMiddlewareDefinition = CreateMiddlewareResult<string, readonly HTTPMethod[], string>;
|
|
540
545
|
|
|
541
546
|
type TrimAfterFourSlashes<T extends string> = T extends `/${infer S1}/${infer S2}/${infer S3}/${infer S4}/${infer _}` ? `/${S1}/${S2}/${S3}/${S4}` : T;
|
|
542
547
|
type AllPaths = SilgiRouterTypes extends {
|
|
@@ -1242,4 +1247,4 @@ interface LoadConfigOptions {
|
|
|
1242
1247
|
consola?: ConsolaInstance;
|
|
1243
1248
|
}
|
|
1244
1249
|
|
|
1245
|
-
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, Max4Slashes, 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, ServiceDefinitionByMethodAndPath, ServiceHandler, ServiceHandlerInput, ServiceSetup, ServiceSetupsForMethods, 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, WebSocketOptions, WithPathParams };
|
|
1250
|
+
export type { AllPaths, AllPrefixes, AppConfig, Awaitable, BaseMethodSchema, BuildSilgi, CaptureError, CapturedErrorContext, CommandType, Commands, CreateMiddlewareParams, CustomRequestInit, DeepPartial, DeepRequired, DefaultHooks, DefineFrameworkOptions, DotenvOptions, EnvOptions, EventHandlerResponse, EventProtocol, ExtendContext, ExtendShared, ExtractNamespace, ExtractPathParamKeys, ExtractPathParams, ExtractPrefix, ExtractRoute, GenImport, GenerateAppOptions, HTTPMethod, HasPathParams, HookResult, LoadConfigOptions, Max4Slashes, MergeAll, MergeRouteRules, MergedSilgiSchema, MetaData, MethodSchemas, MiddlewareHandler, MiddlewarePath, 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, ServiceDefinitionByMethodAndPath, ServiceHandler, ServiceHandlerInput, ServiceSetup, ServiceSetupsForMethods, 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, WebSocketOptions, WildcardVariants, 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.58",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"exports": {
|
|
@@ -107,6 +107,7 @@
|
|
|
107
107
|
"citty": "^0.1.6",
|
|
108
108
|
"compatx": "^0.2.0",
|
|
109
109
|
"consola": "^3.4.2",
|
|
110
|
+
"crossws": "^0.4.1",
|
|
110
111
|
"defu": "^6.1.4",
|
|
111
112
|
"destr": "^2.0.5",
|
|
112
113
|
"dev-jiti": "^2.4.2",
|