silgi 0.34.10 → 0.34.11
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/build.mjs +13 -40
- package/dist/cli/index.mjs +1 -1
- package/dist/cli/init.mjs +0 -2
- package/dist/core/index.d.mts +1 -60
- package/dist/types/index.d.mts +141 -110
- package/package.json +1 -1
package/dist/cli/build.mjs
CHANGED
|
@@ -1059,33 +1059,21 @@ async function prepareScanFile(silgi) {
|
|
|
1059
1059
|
}),
|
|
1060
1060
|
""
|
|
1061
1061
|
];
|
|
1062
|
+
const generateExport = (name, items, defaultEmpty = "{}") => {
|
|
1063
|
+
const hasItems = items.length > 0;
|
|
1064
|
+
return [
|
|
1065
|
+
`export const ${name} = ${hasItems ? "deepMergeObjects([" : defaultEmpty}`,
|
|
1066
|
+
...items.map((item) => ` ${item},`),
|
|
1067
|
+
hasItems ? "])" : defaultEmpty === "{}" ? "}" : "",
|
|
1068
|
+
""
|
|
1069
|
+
];
|
|
1070
|
+
};
|
|
1062
1071
|
const importData = [
|
|
1063
1072
|
"",
|
|
1064
|
-
|
|
1065
|
-
...scanned.
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
scanned.schemas.length > 0 ? "])" : "}",
|
|
1069
|
-
"",
|
|
1070
|
-
scanned.services.length > 0 ? "export const services = deepMergeObjects([" : "export const services = {",
|
|
1071
|
-
...scanned.services.map((name) => {
|
|
1072
|
-
return ` ${name},`;
|
|
1073
|
-
}),
|
|
1074
|
-
scanned.services.length > 0 ? "])" : "}",
|
|
1075
|
-
"",
|
|
1076
|
-
scanned.shareds.length > 0 ? "export const shareds = deepMergeObjects([" : "export const shareds = {",
|
|
1077
|
-
...scanned.shareds.map((name) => {
|
|
1078
|
-
return ` ${name},`;
|
|
1079
|
-
}),
|
|
1080
|
-
"",
|
|
1081
|
-
scanned.shareds.length > 0 ? "])" : "}",
|
|
1082
|
-
"",
|
|
1083
|
-
scanned.routers.length > 0 ? "export const routers = deepMergeObjects([" : "export const routers = {",
|
|
1084
|
-
...scanned.routers.map((name) => {
|
|
1085
|
-
return ` ${name},`;
|
|
1086
|
-
}),
|
|
1087
|
-
scanned.routers.length > 0 ? "])" : "}",
|
|
1088
|
-
""
|
|
1073
|
+
...generateExport("schemas", scanned.schemas),
|
|
1074
|
+
...generateExport("services", scanned.services),
|
|
1075
|
+
...generateExport("shareds", scanned.shareds, "undefined"),
|
|
1076
|
+
...generateExport("routers", scanned.routers)
|
|
1089
1077
|
];
|
|
1090
1078
|
await silgi.callHook("after:scan.ts", importData);
|
|
1091
1079
|
importData.unshift(...importsContent);
|
|
@@ -1791,20 +1779,6 @@ async function prepareSchema(silgi) {
|
|
|
1791
1779
|
""
|
|
1792
1780
|
];
|
|
1793
1781
|
const importData = [
|
|
1794
|
-
generateTypes(
|
|
1795
|
-
await resolveSchema(
|
|
1796
|
-
{
|
|
1797
|
-
...silgi.options.namespaces?.reduce((acc, key) => ({ ...acc, [key]: "" }), {}) || {}
|
|
1798
|
-
}
|
|
1799
|
-
),
|
|
1800
|
-
{
|
|
1801
|
-
interfaceName: "InferredNamespaces",
|
|
1802
|
-
addExport: false,
|
|
1803
|
-
addDefaults: false,
|
|
1804
|
-
allowExtraKeys: false,
|
|
1805
|
-
indentation: 0
|
|
1806
|
-
}
|
|
1807
|
-
),
|
|
1808
1782
|
"",
|
|
1809
1783
|
`type SchemaExtends = typeof import('${silgiScanTS}')['schemas']`,
|
|
1810
1784
|
`type BaseServices = typeof import('${silgiScanTS}')['services']`,
|
|
@@ -1877,7 +1851,6 @@ async function prepareSchema(silgi) {
|
|
|
1877
1851
|
FrameworkContext: [{}, { extends: ["FrameworkContextExtends"] }],
|
|
1878
1852
|
SilgiSchema: [{}, { extends: ["SchemaExtends"] }],
|
|
1879
1853
|
ServicesObject: [{}, { extends: ["BaseServices"] }],
|
|
1880
|
-
SilgiNamespaces: [{}, { extends: ["InferredNamespaces"] }],
|
|
1881
1854
|
SilgiStorageBase: [{}, { extends: ["SilgiStorageBaseExtends"] }],
|
|
1882
1855
|
SilgiURIs: [{}, { extends: ["SilgiURIsMerge"] }],
|
|
1883
1856
|
SilgiRuntimeContext: [{}, { extends: ["SilgiModuleContextExtends"] }],
|
package/dist/cli/index.mjs
CHANGED
package/dist/cli/init.mjs
CHANGED
|
@@ -69,8 +69,6 @@ const command = defineCommand({
|
|
|
69
69
|
"export default defineSilgiConfig({",
|
|
70
70
|
` preset: '${framework}',`,
|
|
71
71
|
` compatibilityDate: '${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}',`,
|
|
72
|
-
" // Please create a namespace for your project",
|
|
73
|
-
" namespaces: [],",
|
|
74
72
|
"",
|
|
75
73
|
"})",
|
|
76
74
|
""
|
package/dist/core/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SilgiConfig, Silgi, SilgiEvent, SilgiSchema, ServiceSetup, CustomRequestInit, SilgiRuntimeContext, AllPrefixes, NamespacesForPrefix, RoutesForPrefixAndNamespace,
|
|
1
|
+
import { SilgiConfig, Silgi, SilgiEvent, SilgiSchema, ServiceSetup, CustomRequestInit, SilgiRuntimeContext, AllPrefixes, NamespacesForPrefix, RoutesForPrefixAndNamespace, MethodSchemas, MergeAll, ServiceMethods, SilgiRuntimeShareds, RouteConfig, SilgiURL, StorageConfig, SilgiCLI, SilgiStorageBase } from 'silgi/types';
|
|
2
2
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
3
|
import { Storage, StorageValue } from 'unstorage';
|
|
4
4
|
import { UseContext } from 'unctx';
|
|
@@ -106,62 +106,6 @@ declare function handleResponse(val: unknown, event: SilgiEvent, config: SilgiHa
|
|
|
106
106
|
declare function getEvent<T extends SilgiEvent>(event?: SilgiEvent): T;
|
|
107
107
|
declare function getEventContext<T extends SilgiRuntimeContext>(event?: SilgiEvent): T;
|
|
108
108
|
|
|
109
|
-
/**
|
|
110
|
-
* Creates an object type representing path parameters extracted from a URL pattern.
|
|
111
|
-
*
|
|
112
|
-
* @example
|
|
113
|
-
* PathParamsObject<'/users/:id/posts/:postId'> // { id: string | number, postId: string | number }
|
|
114
|
-
*/
|
|
115
|
-
type PathParamsObject<S extends string> = {
|
|
116
|
-
[K in ExtractPathParamKeys<S>]: string | number;
|
|
117
|
-
};
|
|
118
|
-
/**
|
|
119
|
-
* Determines if a URL pattern contains any path parameters.
|
|
120
|
-
*
|
|
121
|
-
* @example
|
|
122
|
-
* HasPathParams<'/users/:id'> // true
|
|
123
|
-
* HasPathParams<'/users'> // false
|
|
124
|
-
*/
|
|
125
|
-
type HasPathParams<S extends string> = ExtractPathParamKeys<S> extends never ? false : true;
|
|
126
|
-
/**
|
|
127
|
-
* Base schema definition for API method handlers.
|
|
128
|
-
* Defines the structure of input/output data.
|
|
129
|
-
*/
|
|
130
|
-
interface BaseMethodSchema {
|
|
131
|
-
/** Schema for request body */
|
|
132
|
-
input?: StandardSchemaV1;
|
|
133
|
-
/** Schema for response body */
|
|
134
|
-
output?: StandardSchemaV1;
|
|
135
|
-
/** Schema for URL query parameters */
|
|
136
|
-
queryParams?: StandardSchemaV1;
|
|
137
|
-
/** Schema for source data (contextual information) */
|
|
138
|
-
source?: StandardSchemaV1;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Interface for adding path parameters schema to method definitions.
|
|
142
|
-
*/
|
|
143
|
-
interface WithPathParams<PathParamsStr extends string> {
|
|
144
|
-
/** Schema for path parameters */
|
|
145
|
-
pathParams: StandardSchemaV1<PathParamsObject<PathParamsStr>>;
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Defines the schema structure for HTTP methods, conditionally including
|
|
149
|
-
* path parameters based on the URL pattern.
|
|
150
|
-
*
|
|
151
|
-
* @example
|
|
152
|
-
* // For a route with path parameters:
|
|
153
|
-
* type UserMethodSchema = MethodSchemas<'/:id'>
|
|
154
|
-
* // Result includes required pathParams for each method
|
|
155
|
-
*
|
|
156
|
-
* // For a route without path parameters:
|
|
157
|
-
* type ListMethodSchema = MethodSchemas<''>
|
|
158
|
-
* // Result doesn't allow pathParams property
|
|
159
|
-
*/
|
|
160
|
-
type MethodSchemas<PathParamsStr extends string = ''> = {
|
|
161
|
-
[K in HTTPMethod]?: HasPathParams<PathParamsStr> extends true ? BaseMethodSchema & WithPathParams<PathParamsStr> : BaseMethodSchema & {
|
|
162
|
-
pathParams?: never;
|
|
163
|
-
};
|
|
164
|
-
};
|
|
165
109
|
/**
|
|
166
110
|
* Creates a type-safe API route schema definition.
|
|
167
111
|
*
|
|
@@ -288,9 +232,6 @@ declare function createSchema<P extends AllPrefixes, N extends NamespacesForPref
|
|
|
288
232
|
*/
|
|
289
233
|
declare function deepMergeObjects<T extends readonly Record<string, any>[]>(schemas: [...T]): MergeAll<T>;
|
|
290
234
|
|
|
291
|
-
type ServiceMethods<Schema extends SilgiSchema, Path extends keyof Schema, Resolved extends boolean = false, HiddenParameters extends boolean = false> = {
|
|
292
|
-
[M in keyof Schema[Path]]?: ServiceSetup<Schema, Path, M, Resolved, HiddenParameters>;
|
|
293
|
-
};
|
|
294
235
|
declare function createService<Schema extends SilgiSchema, Path extends keyof Schema, Resolved extends boolean = false, Methods extends ServiceMethods<Schema, Path, Resolved> = ServiceMethods<Schema, Path, Resolved>>(params: {
|
|
295
236
|
path: Path;
|
|
296
237
|
methods: Methods;
|
package/dist/types/index.d.mts
CHANGED
|
@@ -316,6 +316,9 @@ interface GenerateAppOptions {
|
|
|
316
316
|
filter?: (template: ResolvedSilgiTemplate<any>) => boolean;
|
|
317
317
|
}
|
|
318
318
|
|
|
319
|
+
type ServiceMethods<Schema extends SilgiSchema$1, Path extends keyof Schema, Resolved extends boolean = false, HiddenParameters extends boolean = false> = {
|
|
320
|
+
[M in keyof Schema[Path]]?: ServiceSetup<Schema, Path, M, Resolved, HiddenParameters>;
|
|
321
|
+
};
|
|
319
322
|
/**
|
|
320
323
|
* Yardımcı tipler
|
|
321
324
|
*/
|
|
@@ -368,24 +371,20 @@ interface ServiceSetup<Schema extends SilgiSchema$1 = SilgiSchema$1, Route exten
|
|
|
368
371
|
storage?: StorageConfig$1<ServiceHandlerInput<Schema, Route, Method, HiddenParameters>>;
|
|
369
372
|
}
|
|
370
373
|
/**
|
|
371
|
-
*
|
|
374
|
+
* Represents a fully resolved service definition that maps route paths
|
|
375
|
+
* to their method handlers and configurations.
|
|
376
|
+
*
|
|
377
|
+
* This interface is designed to be compatible with the structure created
|
|
378
|
+
* by the createService function.
|
|
372
379
|
*/
|
|
373
|
-
|
|
374
|
-
[
|
|
375
|
-
[
|
|
380
|
+
interface ResolvedServiceDefinition$1 {
|
|
381
|
+
[routePath: string]: {
|
|
382
|
+
[method: string]: {
|
|
383
|
+
handler: (...args: any[]) => Promise<any>;
|
|
384
|
+
modules?: Partial<SilgiRuntimeActions$1>;
|
|
385
|
+
storage?: StorageConfig$1<any>;
|
|
386
|
+
};
|
|
376
387
|
};
|
|
377
|
-
};
|
|
378
|
-
/**
|
|
379
|
-
* Çoklu servisleri birleştirmek için yardımcı tip
|
|
380
|
-
*/
|
|
381
|
-
type MergeServiceDefinitions<T extends object[]> = T extends [infer F, ...infer R] ? F & MergeServiceDefinitions<R extends object[] ? R : []> : unknown;
|
|
382
|
-
/**
|
|
383
|
-
* Servis oluşturmak için parametreler
|
|
384
|
-
*/
|
|
385
|
-
interface CreateServiceParams<Schema extends SilgiSchema$1, Route extends keyof Schema, Method extends keyof Schema[Route], Resolved extends boolean = false> {
|
|
386
|
-
route: Route;
|
|
387
|
-
method: Method;
|
|
388
|
-
setup: ServiceSetup<Schema, Route, Method, Resolved>;
|
|
389
388
|
}
|
|
390
389
|
/**
|
|
391
390
|
* SilgiURL tipi
|
|
@@ -497,14 +496,9 @@ interface SilgiModule<TOptions extends ModuleOptionsCustom = ModuleOptionsCustom
|
|
|
497
496
|
|
|
498
497
|
interface SilgiRuntimeMethods {
|
|
499
498
|
}
|
|
500
|
-
interface SilgiNamespaces {
|
|
501
|
-
}
|
|
502
499
|
type CommandType = 'run' | 'prepare' | 'install' | 'dev' | 'init';
|
|
503
|
-
interface DefaultNamespaces extends SilgiNamespaces {
|
|
504
|
-
}
|
|
505
500
|
interface SilgiRouterTypes {
|
|
506
501
|
}
|
|
507
|
-
type BaseSilgiMethodType = 'post' | 'delete' | 'put' | 'get' | keyof SilgiRuntimeMethods | (string & {});
|
|
508
502
|
interface DefaultHooks {
|
|
509
503
|
}
|
|
510
504
|
type DeepPartial<T> = T extends (...args: any[]) => any ? T : T extends Record<string, any> ? {
|
|
@@ -563,7 +557,6 @@ interface SilgiCLIOptions extends PresetOptions {
|
|
|
563
557
|
[key: string]: any;
|
|
564
558
|
};
|
|
565
559
|
storages: string[];
|
|
566
|
-
namespaces: string[];
|
|
567
560
|
hooks: NestedHooks<SilgiCLIHooks$1>;
|
|
568
561
|
plugins: {
|
|
569
562
|
path: string;
|
|
@@ -828,43 +821,140 @@ interface CapturedErrorContext {
|
|
|
828
821
|
}
|
|
829
822
|
type CaptureError = (silgi: Silgi, error: Error, context: CapturedErrorContext) => void;
|
|
830
823
|
|
|
824
|
+
/**
|
|
825
|
+
* Main interface containing all route definitions.
|
|
826
|
+
* Example:
|
|
827
|
+
* {
|
|
828
|
+
* "/api/blueSpace/basket/getBook": { ... }
|
|
829
|
+
* }
|
|
830
|
+
*/
|
|
831
|
+
interface Routers {
|
|
832
|
+
}
|
|
833
|
+
/**
|
|
834
|
+
* Extracts the prefix (first segment) from a URL, including the leading slash.
|
|
835
|
+
* @example ExtractPrefix<'/api/blueSpace/basket'> // '/api'
|
|
836
|
+
*/
|
|
837
|
+
type ExtractPrefix<URL extends string> = URL extends `/${infer Prefix}/${string}` ? `/${Prefix}` : never;
|
|
838
|
+
/**
|
|
839
|
+
* Extracts the namespace (second segment) from a URL, including the leading slash.
|
|
840
|
+
* @example ExtractNamespace<'/api/blueSpace/basket'> // '/blueSpace'
|
|
841
|
+
*/
|
|
842
|
+
type ExtractNamespace<URL extends string> = URL extends `/${string}/${infer Namespace}/${string}` ? `/${Namespace}` : never;
|
|
843
|
+
/**
|
|
844
|
+
* Extracts the route (third and subsequent segments) from a URL, including the leading slash.
|
|
845
|
+
* @example ExtractRoute<'/api/blueSpace/basket/getBook'> // '/basket/getBook'
|
|
846
|
+
*/
|
|
847
|
+
type ExtractRoute<URL extends string> = URL extends `/${string}/${string}/${infer Route}` ? `/${Route}` : never;
|
|
848
|
+
/**
|
|
849
|
+
* Gets all route keys from Routers as strings.
|
|
850
|
+
* All keys should start with a leading slash.
|
|
851
|
+
*/
|
|
852
|
+
type RouterKeys = keyof Routers & string;
|
|
853
|
+
/**
|
|
854
|
+
* Extracts all prefixes (first segment) in the system, including the leading slash.
|
|
855
|
+
* @example AllPrefixes // '/api' | ...
|
|
856
|
+
*/
|
|
857
|
+
type AllPrefixes = RouterKeys extends infer K ? K extends string ? ExtractPrefix<K> : never : never;
|
|
858
|
+
/**
|
|
859
|
+
* Extracts all namespaces (second segment) for a given prefix, including the leading slash.
|
|
860
|
+
* @example NamespacesForPrefix<'/api'> // '/blueSpace' | ...
|
|
861
|
+
*/
|
|
862
|
+
type NamespacesForPrefix<P extends string> = RouterKeys extends infer K ? K extends string ? K extends `${P}/${infer N}/${string}` ? `/${N}` : never : never : never;
|
|
863
|
+
/**
|
|
864
|
+
* Extracts all routes (third and subsequent segments) for a given prefix and namespace, including the leading slash.
|
|
865
|
+
* @example RoutesForPrefixAndNamespace<'/api', '/blueSpace'> // '/basket/getBook' | ...
|
|
866
|
+
*/
|
|
867
|
+
type RoutesForPrefixAndNamespace<P extends string, N extends string> = RouterKeys extends infer K ? K extends string ? K extends `${P}${N}${infer R}` ? `${R}` : never : never : never;
|
|
868
|
+
/**
|
|
869
|
+
* Extracts path parameter keys from a URL pattern string.
|
|
870
|
+
*
|
|
871
|
+
* @example
|
|
872
|
+
* ExtractPathParamKeys<'/users/:id/posts/:postId'> // 'id' | 'postId'
|
|
873
|
+
* ExtractPathParamKeys<'/users/:id?'> // 'id'
|
|
874
|
+
*/
|
|
875
|
+
type ExtractPathParamKeys<S extends string> = S extends `${string}:${infer Param}/${infer Rest}` ? Param extends `${infer Key}?` ? Key | ExtractPathParamKeys<Rest> : Param | ExtractPathParamKeys<Rest> : S extends `${string}:${infer Param}` ? Param extends `${infer Key}?` ? Key : Param : never;
|
|
876
|
+
/**
|
|
877
|
+
* Route configuration interface.
|
|
878
|
+
*/
|
|
879
|
+
interface RouteConfig<T> {
|
|
880
|
+
route: T;
|
|
881
|
+
setup?: any;
|
|
882
|
+
}
|
|
883
|
+
|
|
831
884
|
interface SilgiSchema {
|
|
832
885
|
}
|
|
833
886
|
interface MergedSilgiSchema {
|
|
834
887
|
}
|
|
835
888
|
/**
|
|
836
|
-
*
|
|
889
|
+
* Creates an object type representing path parameters extracted from a URL pattern.
|
|
890
|
+
*
|
|
891
|
+
* @example
|
|
892
|
+
* PathParamsObject<'/users/:id/posts/:postId'> // { id: string | number, postId: string | number }
|
|
837
893
|
*/
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
894
|
+
type PathParamsObject<S extends string> = {
|
|
895
|
+
[K in ExtractPathParamKeys<S>]: string | number;
|
|
896
|
+
};
|
|
897
|
+
/**
|
|
898
|
+
* Determines if a URL pattern contains any path parameters.
|
|
899
|
+
*
|
|
900
|
+
* @example
|
|
901
|
+
* HasPathParams<'/users/:id'> // true
|
|
902
|
+
* HasPathParams<'/users'> // false
|
|
903
|
+
*/
|
|
904
|
+
type HasPathParams<S extends string> = ExtractPathParamKeys<S> extends never ? false : true;
|
|
905
|
+
/**
|
|
906
|
+
* Base schema definition for API method handlers.
|
|
907
|
+
* Defines the structure of input/output data.
|
|
908
|
+
*/
|
|
909
|
+
interface BaseMethodSchema {
|
|
910
|
+
/** Schema for request body */
|
|
911
|
+
input?: StandardSchemaV1;
|
|
912
|
+
/** Schema for response body */
|
|
913
|
+
output?: StandardSchemaV1;
|
|
914
|
+
/** Schema for URL query parameters */
|
|
915
|
+
queryParams?: StandardSchemaV1;
|
|
916
|
+
/** Schema for source data (contextual information) */
|
|
917
|
+
source?: StandardSchemaV1;
|
|
844
918
|
}
|
|
845
919
|
/**
|
|
846
|
-
*
|
|
847
|
-
* Allows specifying schemas for input, output, path parameters, query parameters, and source data.
|
|
848
|
-
* @template TInput - The schema type for the request body/input.
|
|
849
|
-
* @template TOutput - The schema type for the response body/output.
|
|
850
|
-
* @template TPathParams - The schema type for URL path parameters.
|
|
851
|
-
* @template TQueryParams - The schema type for URL query parameters.
|
|
852
|
-
* @template TSource - The schema type for the source data or context.
|
|
920
|
+
* Interface for adding path parameters schema to method definitions.
|
|
853
921
|
*/
|
|
854
|
-
|
|
922
|
+
interface WithPathParams<PathParamsStr extends string> {
|
|
923
|
+
/** Schema for path parameters */
|
|
924
|
+
pathParams: StandardSchemaV1<PathParamsObject<PathParamsStr>>;
|
|
925
|
+
}
|
|
855
926
|
/**
|
|
856
|
-
*
|
|
857
|
-
*
|
|
927
|
+
* Defines the schema structure for HTTP methods, conditionally including
|
|
928
|
+
* path parameters based on the URL pattern.
|
|
929
|
+
*
|
|
930
|
+
* @example
|
|
931
|
+
* // For a route with path parameters:
|
|
932
|
+
* type UserMethodSchema = MethodSchemas<'/:id'>
|
|
933
|
+
* // Result includes required pathParams for each method
|
|
934
|
+
*
|
|
935
|
+
* // For a route without path parameters:
|
|
936
|
+
* type ListMethodSchema = MethodSchemas<''>
|
|
937
|
+
* // Result doesn't allow pathParams property
|
|
938
|
+
*/
|
|
939
|
+
type MethodSchemas<PathParamsStr extends string = ''> = {
|
|
940
|
+
[K in HTTPMethod$1]?: HasPathParams<PathParamsStr> extends true ? BaseMethodSchema & WithPathParams<PathParamsStr> : BaseMethodSchema & {
|
|
941
|
+
pathParams?: never;
|
|
942
|
+
};
|
|
943
|
+
};
|
|
944
|
+
/**
|
|
945
|
+
* Represents a fully resolved schema definition that maps API route paths
|
|
946
|
+
* to their method schemas.
|
|
947
|
+
*/
|
|
948
|
+
interface ResolvedSchema {
|
|
949
|
+
[routePath: string]: MethodSchemas<string>;
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* Represents a schema definition that has been fully resolved,
|
|
953
|
+
* typically after processing and validating all schema components.
|
|
858
954
|
*/
|
|
859
955
|
interface ResolvedSchemaDefinition {
|
|
860
|
-
[
|
|
861
|
-
[method
|
|
862
|
-
input?: StandardSchemaV1;
|
|
863
|
-
output?: StandardSchemaV1;
|
|
864
|
-
pathParams?: StandardSchemaV1;
|
|
865
|
-
queryParams?: StandardSchemaV1;
|
|
866
|
-
source?: StandardSchemaV1;
|
|
867
|
-
};
|
|
956
|
+
[key: string]: {
|
|
957
|
+
[method: string]: BaseMethodSchema;
|
|
868
958
|
};
|
|
869
959
|
}
|
|
870
960
|
|
|
@@ -907,7 +997,8 @@ interface ExtendShared {
|
|
|
907
997
|
|
|
908
998
|
interface FrameworkContext {
|
|
909
999
|
}
|
|
910
|
-
type
|
|
1000
|
+
type StandardHTTPMethod = 'GET' | 'HEAD' | 'PATCH' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE';
|
|
1001
|
+
type HTTPMethod = SilgiRuntimeMethods extends Record<string, any> ? keyof SilgiRuntimeMethods | StandardHTTPMethod : StandardHTTPMethod;
|
|
911
1002
|
interface SilgiRoute {
|
|
912
1003
|
route: string;
|
|
913
1004
|
method?: HTTPMethod;
|
|
@@ -918,7 +1009,7 @@ interface Silgi {
|
|
|
918
1009
|
router: RouterContext<SilgiRoute>;
|
|
919
1010
|
routerPrefixs: string[];
|
|
920
1011
|
schemas: ResolvedSchemaDefinition;
|
|
921
|
-
services: ResolvedServiceDefinition;
|
|
1012
|
+
services: ResolvedServiceDefinition$1;
|
|
922
1013
|
shared: SilgiRuntimeShareds;
|
|
923
1014
|
plugins: SilgiAppPlugin[];
|
|
924
1015
|
framework: FrameworkContext;
|
|
@@ -1093,64 +1184,4 @@ interface GraphQLJSON {
|
|
|
1093
1184
|
references: any;
|
|
1094
1185
|
}
|
|
1095
1186
|
|
|
1096
|
-
|
|
1097
|
-
* Main interface containing all route definitions.
|
|
1098
|
-
* Example:
|
|
1099
|
-
* {
|
|
1100
|
-
* "/api/blueSpace/basket/getBook": { ... }
|
|
1101
|
-
* }
|
|
1102
|
-
*/
|
|
1103
|
-
interface Routers {
|
|
1104
|
-
}
|
|
1105
|
-
/**
|
|
1106
|
-
* Extracts the prefix (first segment) from a URL, including the leading slash.
|
|
1107
|
-
* @example ExtractPrefix<'/api/blueSpace/basket'> // '/api'
|
|
1108
|
-
*/
|
|
1109
|
-
type ExtractPrefix<URL extends string> = URL extends `/${infer Prefix}/${string}` ? `/${Prefix}` : never;
|
|
1110
|
-
/**
|
|
1111
|
-
* Extracts the namespace (second segment) from a URL, including the leading slash.
|
|
1112
|
-
* @example ExtractNamespace<'/api/blueSpace/basket'> // '/blueSpace'
|
|
1113
|
-
*/
|
|
1114
|
-
type ExtractNamespace<URL extends string> = URL extends `/${string}/${infer Namespace}/${string}` ? `/${Namespace}` : never;
|
|
1115
|
-
/**
|
|
1116
|
-
* Extracts the route (third and subsequent segments) from a URL, including the leading slash.
|
|
1117
|
-
* @example ExtractRoute<'/api/blueSpace/basket/getBook'> // '/basket/getBook'
|
|
1118
|
-
*/
|
|
1119
|
-
type ExtractRoute<URL extends string> = URL extends `/${string}/${string}/${infer Route}` ? `/${Route}` : never;
|
|
1120
|
-
/**
|
|
1121
|
-
* Gets all route keys from Routers as strings.
|
|
1122
|
-
* All keys should start with a leading slash.
|
|
1123
|
-
*/
|
|
1124
|
-
type RouterKeys = keyof Routers & string;
|
|
1125
|
-
/**
|
|
1126
|
-
* Extracts all prefixes (first segment) in the system, including the leading slash.
|
|
1127
|
-
* @example AllPrefixes // '/api' | ...
|
|
1128
|
-
*/
|
|
1129
|
-
type AllPrefixes = RouterKeys extends infer K ? K extends string ? ExtractPrefix<K> : never : never;
|
|
1130
|
-
/**
|
|
1131
|
-
* Extracts all namespaces (second segment) for a given prefix, including the leading slash.
|
|
1132
|
-
* @example NamespacesForPrefix<'/api'> // '/blueSpace' | ...
|
|
1133
|
-
*/
|
|
1134
|
-
type NamespacesForPrefix<P extends string> = RouterKeys extends infer K ? K extends string ? K extends `${P}/${infer N}/${string}` ? `/${N}` : never : never : never;
|
|
1135
|
-
/**
|
|
1136
|
-
* Extracts all routes (third and subsequent segments) for a given prefix and namespace, including the leading slash.
|
|
1137
|
-
* @example RoutesForPrefixAndNamespace<'/api', '/blueSpace'> // '/basket/getBook' | ...
|
|
1138
|
-
*/
|
|
1139
|
-
type RoutesForPrefixAndNamespace<P extends string, N extends string> = RouterKeys extends infer K ? K extends string ? K extends `${P}${N}${infer R}` ? `${R}` : never : never : never;
|
|
1140
|
-
/**
|
|
1141
|
-
* Extracts path parameter keys from a URL pattern string.
|
|
1142
|
-
*
|
|
1143
|
-
* @example
|
|
1144
|
-
* ExtractPathParamKeys<'/users/:id/posts/:postId'> // 'id' | 'postId'
|
|
1145
|
-
* ExtractPathParamKeys<'/users/:id?'> // 'id'
|
|
1146
|
-
*/
|
|
1147
|
-
type ExtractPathParamKeys<S extends string> = S extends `${string}:${infer Param}/${infer Rest}` ? Param extends `${infer Key}?` ? Key | ExtractPathParamKeys<Rest> : Param | ExtractPathParamKeys<Rest> : S extends `${string}:${infer Param}` ? Param extends `${infer Key}?` ? Key : Param : never;
|
|
1148
|
-
/**
|
|
1149
|
-
* Route configuration interface.
|
|
1150
|
-
*/
|
|
1151
|
-
interface RouteConfig<T> {
|
|
1152
|
-
route: T;
|
|
1153
|
-
setup?: any;
|
|
1154
|
-
}
|
|
1155
|
-
|
|
1156
|
-
export type { AllPaths, AllPrefixes, AppConfig, Awaitable, BaseSilgiMethodType, BuildSilgi, CaptureError, CapturedErrorContext, CommandType, Commands, CreateServiceParams, CustomRequestInit, DeepPartial, DeepRequired, DefaultHooks, DefaultNamespaces, DefineFrameworkOptions, DotenvOptions, EnvOptions, EventHandlerResponse, ExtendContext, ExtendShared, ExtractNamespace, ExtractPathParamKeys, ExtractPathParams, ExtractPrefix, ExtractRoute, FrameworkContext, GenImport, GenerateAppOptions, GraphQLJSON, HTTPMethod, HookResult, HttpMethod, LoadConfigOptions, MergeAll, MergeServiceDefinitions, MergedSilgiSchema, ModuleDefinition, ModuleHookContext, ModuleMeta, ModuleOptionsCustom, ModuleSetupInstallResult, ModuleSetupReturn, NamespacesForPrefix, NitroBuildInfo, RequiredServiceType, ResolvedModuleMeta, ResolvedModuleOptions, ResolvedSchemaDefinition, ResolvedSilgiTemplate, RouteConfig, RouterParams, Routers, RoutesForPrefixAndNamespace, ScanFile, Schema, SchemaDefinition, SchemaParams, ServiceDefinition, ServiceHandler, ServiceHandlerInput, ServiceHandlerOutput, ServiceHandlerSource, ServiceSetup, Silgi, SilgiAppPlugin, SilgiCLI, SilgiCLIConfig, SilgiCLIDynamicConfig, SilgiCLIHooks, SilgiCLIOptions, SilgiCommands, SilgiCompatibility, SilgiCompatibilityIssue, SilgiCompatibilityIssues, SilgiConfig, SilgiEvent, SilgiFetchClient, SilgiFetchOptions, SilgiFrameworkInfo, SilgiHooks, SilgiModule, SilgiModuleInput, SilgiModuleOptions, SilgiNamespaces, SilgiOptions, SilgiPreset, SilgiPresetMeta, SilgiRoute, SilgiRouterTypes, SilgiRuntimeActions, SilgiRuntimeConfig, SilgiRuntimeContext, SilgiRuntimeHooks, SilgiRuntimeMethods, SilgiRuntimeOptions, SilgiRuntimeShareds, SilgiRuntimeSharedsExtend, SilgiSchema, SilgiStorageBase, SilgiTemplate, SilgiURL, StorageConfig, StorageKeyGenerator, StorageKeyParams, StorageMounts, TSReference, TrimAfterFourSlashes };
|
|
1187
|
+
export type { AllPaths, AllPrefixes, AppConfig, Awaitable, BuildSilgi, CaptureError, CapturedErrorContext, CommandType, Commands, CustomRequestInit, DeepPartial, DeepRequired, DefaultHooks, DefineFrameworkOptions, DotenvOptions, EnvOptions, EventHandlerResponse, ExtendContext, ExtendShared, ExtractNamespace, ExtractPathParamKeys, ExtractPathParams, ExtractPrefix, ExtractRoute, FrameworkContext, GenImport, GenerateAppOptions, GraphQLJSON, HTTPMethod, HookResult, HttpMethod, LoadConfigOptions, MergeAll, MergedSilgiSchema, MethodSchemas, ModuleDefinition, ModuleHookContext, ModuleMeta, ModuleOptionsCustom, ModuleSetupInstallResult, ModuleSetupReturn, NamespacesForPrefix, NitroBuildInfo, RequiredServiceType, ResolvedModuleMeta, ResolvedModuleOptions, ResolvedSchema, ResolvedSchemaDefinition, ResolvedServiceDefinition$1 as ResolvedServiceDefinition, ResolvedSilgiTemplate, RouteConfig, RouterParams, Routers, RoutesForPrefixAndNamespace, ScanFile, Schema, ServiceHandler, ServiceHandlerInput, ServiceHandlerOutput, ServiceHandlerSource, ServiceMethods, ServiceSetup, Silgi, SilgiAppPlugin, SilgiCLI, SilgiCLIConfig, SilgiCLIDynamicConfig, SilgiCLIHooks, SilgiCLIOptions, SilgiCommands, SilgiCompatibility, SilgiCompatibilityIssue, SilgiCompatibilityIssues, SilgiConfig, SilgiEvent, SilgiFetchClient, SilgiFetchOptions, SilgiFrameworkInfo, SilgiHooks, SilgiModule, SilgiModuleInput, SilgiModuleOptions, SilgiOptions, SilgiPreset, SilgiPresetMeta, SilgiRoute, SilgiRouterTypes, SilgiRuntimeActions, SilgiRuntimeConfig, SilgiRuntimeContext, SilgiRuntimeHooks, SilgiRuntimeMethods, SilgiRuntimeOptions, SilgiRuntimeShareds, SilgiRuntimeSharedsExtend, SilgiSchema, SilgiStorageBase, SilgiTemplate, SilgiURL, StandardHTTPMethod, StorageConfig, StorageKeyGenerator, StorageKeyParams, StorageMounts, TSReference, TrimAfterFourSlashes, WithPathParams };
|