silgi 0.41.17 → 0.41.18
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 +23 -8
- package/dist/cli/index.mjs +1 -1
- package/dist/core/index.d.mts +6 -6
- package/dist/core/index.mjs +1 -1
- package/dist/types/index.d.mts +4 -2
- package/package.json +1 -1
package/dist/cli/build.mjs
CHANGED
|
@@ -1953,15 +1953,30 @@ async function prepareSchema(silgi) {
|
|
|
1953
1953
|
generateTypes(
|
|
1954
1954
|
await resolveSchema(
|
|
1955
1955
|
{
|
|
1956
|
-
...
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
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: "
|
|
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 {}"
|
package/dist/cli/index.mjs
CHANGED
package/dist/core/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SilgiConfig, Silgi, SilgiEvent, HTTPMethod, SilgiSchema, RouteEntry, CustomRequestInit, SilgiRuntimeContext, BaseMethodSchema, MergeAll,
|
|
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,8 +159,8 @@ 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
|
|
163
|
-
declare function createService<Path extends
|
|
162
|
+
type Max4Slashes<S extends keyof Routers> = SlashCount<S> extends 0 | 1 | 2 | 3 | 4 ? S : never;
|
|
163
|
+
declare function createService<Path extends keyof Routers = keyof Routers, 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: {
|
|
164
164
|
path: Max4Slashes<Path>;
|
|
165
165
|
methods: HTTPMethod[];
|
|
166
166
|
input?: Input;
|
|
@@ -184,8 +184,8 @@ declare function createService<Path extends string = string, Input extends Stand
|
|
|
184
184
|
};
|
|
185
185
|
|
|
186
186
|
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
|
|
188
|
-
interface CreateMiddlewareParams<S extends WildcardVariants<keyof
|
|
187
|
+
type MiddlewarePath<S extends WildcardVariants<keyof Routers>> = S | 'global';
|
|
188
|
+
interface CreateMiddlewareParams<S extends WildcardVariants<keyof Routers>, UsedMethod extends readonly HTTPMethod[] = readonly HTTPMethod[], Key extends string = string> {
|
|
189
189
|
path: MiddlewarePath<S>;
|
|
190
190
|
methods?: UsedMethod;
|
|
191
191
|
setup: MiddlewareSetup;
|
|
@@ -199,7 +199,7 @@ type CreateMiddlewareResult<Path extends string, UsedMethod extends readonly HTT
|
|
|
199
199
|
path: Path;
|
|
200
200
|
};
|
|
201
201
|
};
|
|
202
|
-
declare function createMiddleware<S extends WildcardVariants<keyof
|
|
202
|
+
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
203
|
path: Path;
|
|
204
204
|
}): CreateMiddlewareResult<Path, UsedMethod, Key>;
|
|
205
205
|
|
package/dist/core/index.mjs
CHANGED
|
@@ -1091,7 +1091,7 @@ function deepMergeObjects(schemas) {
|
|
|
1091
1091
|
}
|
|
1092
1092
|
|
|
1093
1093
|
function createService(params) {
|
|
1094
|
-
const slashCount = (params.path.match(/\//g) || []).length;
|
|
1094
|
+
const slashCount = (String(params.path).match(/\//g) || []).length;
|
|
1095
1095
|
if (slashCount > 4) {
|
|
1096
1096
|
throw new Error(
|
|
1097
1097
|
`Path '${params.path}' is invalid: maximum 4 '/' allowed (found ${slashCount})`
|
package/dist/types/index.d.mts
CHANGED
|
@@ -134,6 +134,8 @@ interface SilgiEvent extends Record<string, unknown> {
|
|
|
134
134
|
*/
|
|
135
135
|
interface Resolvers {
|
|
136
136
|
}
|
|
137
|
+
interface Routers {
|
|
138
|
+
}
|
|
137
139
|
interface RouteRules extends Record<string, unknown> {
|
|
138
140
|
}
|
|
139
141
|
type MergeRouteRules = Partial<RouteRules> & {
|
|
@@ -158,7 +160,7 @@ type ExtractRoute<URL extends string> = URL extends `/${string}/${string}/${infe
|
|
|
158
160
|
* Gets all route keys from Routers as strings.
|
|
159
161
|
* All keys should start with a leading slash.
|
|
160
162
|
*/
|
|
161
|
-
type RouterKeys = keyof ServicesObject & string;
|
|
163
|
+
type RouterKeys = (keyof ServicesObject extends string ? keyof ServicesObject : never) & (keyof Routers extends string ? keyof Routers : never);
|
|
162
164
|
/**
|
|
163
165
|
* Extracts all prefixes (first segment) in the system, including the leading slash.
|
|
164
166
|
* @example AllPrefixes // '/api' | ...
|
|
@@ -1222,4 +1224,4 @@ interface LoadConfigOptions {
|
|
|
1222
1224
|
consola?: ConsolaInstance;
|
|
1223
1225
|
}
|
|
1224
1226
|
|
|
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 };
|
|
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 };
|