silgi 0.14.4 → 0.16.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.
- package/dist/_chunks/index.mjs +1 -1
- package/dist/_chunks/routeRules.mjs +274 -0
- package/dist/cli/dev.mjs +1 -0
- package/dist/cli/loader.mjs +2 -1
- package/dist/cli/prepare.mjs +46 -2
- package/dist/cli/writeTypesAndFiles.mjs +175 -174
- package/dist/core/index.mjs +6 -1
- package/dist/kit/index.d.mts +28 -2
- package/dist/kit/index.d.ts +28 -2
- package/dist/kit/index.mjs +64 -2
- package/dist/meta/index.d.mts +1 -1
- package/dist/meta/index.d.ts +1 -1
- package/dist/types/index.d.mts +72 -5
- package/dist/types/index.d.ts +72 -5
- package/package.json +9 -9
package/dist/types/index.d.mts
CHANGED
|
@@ -6,7 +6,7 @@ import { Hookable, NestedHooks } from 'hookable';
|
|
|
6
6
|
import { Ignore, Options } from 'ignore';
|
|
7
7
|
import { TSConfig } from 'pkg-types';
|
|
8
8
|
import { PresetName, PresetOptions, PresetNameInput } from 'silgi/presets';
|
|
9
|
-
import { ResolvedServiceType as ResolvedServiceType$1, SilgiRuntimeShareds as SilgiRuntimeShareds$1, SilgiRuntimeOptions as SilgiRuntimeOptions$1, ModuleMeta as ModuleMeta$1, DotenvOptions as DotenvOptions$1, EnvOptions as EnvOptions$1, SilgiRuntimeConfig as SilgiRuntimeConfig$1, SilgiCLIHooks as SilgiCLIHooks$1, StorageMounts as StorageMounts$1, SilgiTemplate as SilgiTemplate$1, SilgiFrameworkInfo as SilgiFrameworkInfo$1 } from 'silgi/types';
|
|
9
|
+
import { ResolvedServiceType as ResolvedServiceType$1, SilgiRuntimeShareds as SilgiRuntimeShareds$1, SilgiRuntimeOptions as SilgiRuntimeOptions$1, RouteRules as RouteRules$1, ModuleMeta as ModuleMeta$1, SilgiRouteRules as SilgiRouteRules$1, DotenvOptions as DotenvOptions$1, EnvOptions as EnvOptions$1, SilgiRuntimeConfig as SilgiRuntimeConfig$1, ServiceParseModule as ServiceParseModule$1, SilgiCLIHooks as SilgiCLIHooks$1, StorageMounts as StorageMounts$1, SilgiTemplate as SilgiTemplate$1, SilgiFrameworkInfo as SilgiFrameworkInfo$1 } from 'silgi/types';
|
|
10
10
|
import { UnimportPluginOptions } from 'unimport/unplugin';
|
|
11
11
|
import { Defu } from 'defu';
|
|
12
12
|
import { Unimport } from 'unimport';
|
|
@@ -55,6 +55,7 @@ interface SilgiCLI {
|
|
|
55
55
|
modulesURIs: Partial<Record<keyof SilgiRuntimeOptions$1 | (string & {}), any>>;
|
|
56
56
|
scannedURIs: Map<string, string>;
|
|
57
57
|
templates: SilgiTemplate[];
|
|
58
|
+
routeRules: RouteRules$1;
|
|
58
59
|
hooks: Hookable<SilgiCLIHooks>;
|
|
59
60
|
hook: SilgiCLI['hooks']['hook'];
|
|
60
61
|
callHook: SilgiCLI['hooks']['callHook'];
|
|
@@ -170,6 +171,14 @@ interface SchemaPreparationOptions extends ImportItem {
|
|
|
170
171
|
key: string;
|
|
171
172
|
value: string;
|
|
172
173
|
}[];
|
|
174
|
+
routeRules: {
|
|
175
|
+
key: string;
|
|
176
|
+
value: string;
|
|
177
|
+
}[];
|
|
178
|
+
routeRulesConfig: {
|
|
179
|
+
key: string;
|
|
180
|
+
value: string;
|
|
181
|
+
}[];
|
|
173
182
|
contexts: {
|
|
174
183
|
key: string;
|
|
175
184
|
value: string;
|
|
@@ -242,11 +251,11 @@ interface SilgiCLIHooks extends SilgiHooks {
|
|
|
242
251
|
'prepare:core.ts': (data: PrepareCore) => HookResult;
|
|
243
252
|
'after:prepare:core.ts': (content: string[]) => HookResult;
|
|
244
253
|
'prepare:scan.ts': (data: Pick<ImportItem, 'customImports' | 'importItems'> & {
|
|
245
|
-
uris: string
|
|
254
|
+
uris: Record<string, string>;
|
|
246
255
|
services: string[];
|
|
247
256
|
shareds: string[];
|
|
248
257
|
schemas: string[];
|
|
249
|
-
modulesURIs: string
|
|
258
|
+
modulesURIs: Record<string, string>;
|
|
250
259
|
}) => HookResult;
|
|
251
260
|
'after:prepare:scan.ts': (content: string[]) => HookResult;
|
|
252
261
|
'prepare:schema.ts': (options: SchemaPreparationOptions) => HookResult;
|
|
@@ -563,12 +572,14 @@ interface SilgiCLIOptions extends PresetOptions {
|
|
|
563
572
|
command?: string;
|
|
564
573
|
};
|
|
565
574
|
commandType: CommandType;
|
|
575
|
+
routeRules: SilgiRouteRules$1;
|
|
566
576
|
environments: DotenvOptions$1[];
|
|
567
577
|
activeEnvironment: string;
|
|
568
578
|
envOptions: EnvOptions$1;
|
|
569
579
|
runtimeConfig: SilgiRuntimeConfig$1 & {
|
|
570
580
|
[key: string]: any;
|
|
571
581
|
};
|
|
582
|
+
serviceParseModules: ServiceParseModule$1[];
|
|
572
583
|
storages: string[];
|
|
573
584
|
namespaces: string[];
|
|
574
585
|
hooks: NestedHooks<SilgiCLIHooks$1>;
|
|
@@ -576,7 +587,6 @@ interface SilgiCLIOptions extends PresetOptions {
|
|
|
576
587
|
path: string;
|
|
577
588
|
packageImport: string;
|
|
578
589
|
}[];
|
|
579
|
-
routeRules: Record<string, string>;
|
|
580
590
|
compatibilityDate: CompatibilityDates;
|
|
581
591
|
modules: (SilgiModule<any> | string | [SilgiModule | string, Record<string, any>] | undefined | null | false)[];
|
|
582
592
|
_modules: (SilgiModule<any> | string | [SilgiModule | string, Record<string, any>] | undefined | null | false)[];
|
|
@@ -800,6 +810,49 @@ interface EnvOptions {
|
|
|
800
810
|
envExpansion?: boolean;
|
|
801
811
|
}
|
|
802
812
|
|
|
813
|
+
interface DefaultRouteConfig extends SilgiRuntimeRouteRulesConfig {
|
|
814
|
+
[key: string]: any;
|
|
815
|
+
}
|
|
816
|
+
interface DefaultRouteRules extends SilgiRuntimeRouteRules {
|
|
817
|
+
[key: string]: any;
|
|
818
|
+
}
|
|
819
|
+
type SilgiRouteRules = Record<DefaultRouteRules extends string ? DefaultRouteRules : string, DefaultRouteConfig>;
|
|
820
|
+
type RouteConfig<T extends Record<string, any> = DefaultRouteConfig> = T;
|
|
821
|
+
type RouteRulesConfig<T extends Record<string, any> = DefaultRouteConfig> = Record<string, T>;
|
|
822
|
+
type MergedRulesCache<T extends Record<string, any> = DefaultRouteConfig> = Record<string, T>;
|
|
823
|
+
interface SilgiRuntimeRouteRules {
|
|
824
|
+
}
|
|
825
|
+
interface SilgiRuntimeRouteRulesConfig {
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* Interface for the object returned by createRouteRules
|
|
829
|
+
*/
|
|
830
|
+
interface RouteRules<T extends Record<string, any> = DefaultRouteRules> {
|
|
831
|
+
readonly rules: RouteRulesConfig<T>;
|
|
832
|
+
readonly mergedRules: MergedRulesCache<T>;
|
|
833
|
+
importRules: (config: RouteRulesConfig<T>) => void;
|
|
834
|
+
exportRules: () => RouteRulesConfig<T>;
|
|
835
|
+
addRule: (pattern: string, config: RouteConfig<T>) => void;
|
|
836
|
+
updateRule: (pattern: string, config: Partial<RouteConfig<T>>) => void;
|
|
837
|
+
removeRule: (pattern: string) => void;
|
|
838
|
+
matchesRule: (url: string, pattern: string) => boolean;
|
|
839
|
+
getMatchingPatterns: (url: string) => string[];
|
|
840
|
+
getConfig: (url: string) => RouteConfig<T> | null;
|
|
841
|
+
getParams: (url: string, pattern: string) => Record<string, string> | null;
|
|
842
|
+
match: (url: string) => {
|
|
843
|
+
pattern: string;
|
|
844
|
+
config: RouteConfig<T>;
|
|
845
|
+
params: Record<string, string> | null;
|
|
846
|
+
} | null;
|
|
847
|
+
clear: () => void;
|
|
848
|
+
clearMergedRules: () => void;
|
|
849
|
+
precomputeMergedRules: (urls: string[]) => void;
|
|
850
|
+
setMergedRule: (url: string, config: RouteConfig<T>) => void;
|
|
851
|
+
getMergedRules: () => MergedRulesCache<T>;
|
|
852
|
+
configure: (config: RouteRulesConfig<T>) => void;
|
|
853
|
+
updateMergeRules: () => MergedRulesCache<T>;
|
|
854
|
+
}
|
|
855
|
+
|
|
803
856
|
type CustomDriverName = string & {
|
|
804
857
|
_custom?: any;
|
|
805
858
|
};
|
|
@@ -851,6 +904,7 @@ type MethodHandlerType<T> = {
|
|
|
851
904
|
parameters: StandardSchemaV1.InferInput<T[Action][Method]['pathParams']> & StandardSchemaV1.InferInput<T[Action][Method]['queryParams']>;
|
|
852
905
|
}, shared: SilgiRuntimeShareds, event: SilgiEvents, source: StandardSchemaV1.InferInput<T[Action][Method]['source']>) => EventHandlerResponse<StandardSchemaV1.InferOutput<T[Action][Method]['output']>>;
|
|
853
906
|
modules?: Partial<SilgiRuntimeActions>;
|
|
907
|
+
routeRules?: SilgiRouteRules;
|
|
854
908
|
storage?: StorageConfig<T[Action][Method]['input']>;
|
|
855
909
|
};
|
|
856
910
|
} : never;
|
|
@@ -863,6 +917,7 @@ interface ResolvedMethodHandlerType {
|
|
|
863
917
|
}, shared: SilgiRuntimeShareds, event: SilgiEvents, source: StandardSchemaV1.InferInput<any>) => Promise<StandardSchemaV1.InferInput<any>>;
|
|
864
918
|
modules?: Partial<SilgiRuntimeActions>;
|
|
865
919
|
storage?: StorageConfig<StandardSchemaV1.InferInput<any>>;
|
|
920
|
+
routeRules?: SilgiRouteRules;
|
|
866
921
|
execute: (input: StandardSchemaV1.InferInput<any>, shared: SilgiRuntimeShareds, event: SilgiEvents, source: StandardSchemaV1.InferInput<any>) => Promise<StandardSchemaV1.InferInput<any>>;
|
|
867
922
|
}
|
|
868
923
|
|
|
@@ -927,6 +982,7 @@ interface Silgi {
|
|
|
927
982
|
scannedHandlers: Map<string, ResolvedMethodHandlerType>;
|
|
928
983
|
plugins: SilgiAppPlugin[];
|
|
929
984
|
framework: FrameworkContext;
|
|
985
|
+
routeRules: RouteRules;
|
|
930
986
|
_ignore?: Ignore;
|
|
931
987
|
hooks: Hookable<SilgiRuntimeHooks & DefaultHooks>;
|
|
932
988
|
hook: Silgi['hooks']['hook'];
|
|
@@ -987,6 +1043,7 @@ interface SilgiRuntimeConfig {
|
|
|
987
1043
|
}
|
|
988
1044
|
interface SilgiOptions {
|
|
989
1045
|
consolaOptions?: Partial<ConsolaOptions>;
|
|
1046
|
+
routeRules: SilgiRouteRules;
|
|
990
1047
|
present: PresetNameInput;
|
|
991
1048
|
hooks: Partial<SilgiRuntimeHooks & DefaultHooks>;
|
|
992
1049
|
/**
|
|
@@ -1054,6 +1111,16 @@ type Namespaces<T extends BaseNamespaceType> = {
|
|
|
1054
1111
|
};
|
|
1055
1112
|
};
|
|
1056
1113
|
|
|
1114
|
+
interface ServiceParse {
|
|
1115
|
+
node: ResolvedMethodHandlerType;
|
|
1116
|
+
basePath: string;
|
|
1117
|
+
silgi: SilgiCLI;
|
|
1118
|
+
modulesURIs: Record<string, Record<string, any>>;
|
|
1119
|
+
}
|
|
1120
|
+
interface ServiceParseModule {
|
|
1121
|
+
(params: ServiceParse): Awaited<void> | void;
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1057
1124
|
declare const autoImportTypes: string[];
|
|
1058
1125
|
|
|
1059
|
-
export { type AppConfig, type Awaitable, type BaseNamespaceType, type BaseSchemaType, type BaseSilgiMethodType, type CaptureError, type CapturedErrorContext, type CommandType, type CreateScope, type DeepPartial, type DefaultHooks, type DefaultNamespaces, type DotenvOptions, type EnvOptions, type EventHandlerResponse, type ExtendContext, type ExtendShared, type ExtractInputFromURI, type ExtractOutputFromURI, type ExtractPathParamsFromURI, type ExtractQueryParamsFromURI, type ExtractSourceFromURI, type FrameworkContext, type GenerateAppOptions, type GraphQLJSON, type HookResult, type ImportItem, type LoadConfigOptions, type MergedSilgiSchema, type MethodHandlerType, type ModuleDefinition, type ModuleHookContext, type ModuleMeta, type ModuleOptionsCustom, type ModuleSetupInstallResult, type ModuleSetupReturn, type Namespaces, type NitroBuildInfo, type PrepareCore, type RequiredServiceType, type ResolvedMethodHandlerType, type ResolvedModuleMeta, type ResolvedModuleOptions, type ResolvedServiceType, type ResolvedSilgiTemplate, type ScanFile, type SchemaPreparationOptions, type ServiceType, type Silgi, type SilgiAppPlugin, type SilgiCLI, type SilgiCLIConfig, type SilgiCLIDynamicConfig, type SilgiCLIHooks, type SilgiCLIOptions, type SilgiCompatibility, type SilgiCompatibilityIssue, type SilgiCompatibilityIssues, type SilgiConfig, type SilgiEvents, type SilgiFrameworkInfo, type SilgiFunction, type SilgiHooks, type SilgiModule, type SilgiModuleInput, type SilgiModuleOptions, type SilgiNamespaces, type SilgiOperation, type SilgiOptions, type SilgiPreset, type SilgiPresetMeta, type SilgiRouterTypes, type SilgiRuntimeActions, type SilgiRuntimeConfig, type SilgiRuntimeContext, type SilgiRuntimeHooks, type SilgiRuntimeMethods, type SilgiRuntimeOptions, type SilgiRuntimeSharedExtends, type SilgiRuntimeShareds, type SilgiSchema, type SilgiServiceInterface, type SilgiStorageBase, type SilgiTemplate, type SilgiURIs, type StorageConfig, type StorageKeyGenerator, type StorageKeyParams, type StorageMounts, type TSReference, type URIsTypes, autoImportTypes };
|
|
1126
|
+
export { type AppConfig, type Awaitable, type BaseNamespaceType, type BaseSchemaType, type BaseSilgiMethodType, type CaptureError, type CapturedErrorContext, type CommandType, type CreateScope, type DeepPartial, type DefaultHooks, type DefaultNamespaces, type DotenvOptions, type EnvOptions, type EventHandlerResponse, type ExtendContext, type ExtendShared, type ExtractInputFromURI, type ExtractOutputFromURI, type ExtractPathParamsFromURI, type ExtractQueryParamsFromURI, type ExtractSourceFromURI, type FrameworkContext, type GenerateAppOptions, type GraphQLJSON, type HookResult, type ImportItem, type LoadConfigOptions, type MergedRulesCache, type MergedSilgiSchema, type MethodHandlerType, type ModuleDefinition, type ModuleHookContext, type ModuleMeta, type ModuleOptionsCustom, type ModuleSetupInstallResult, type ModuleSetupReturn, type Namespaces, type NitroBuildInfo, type PrepareCore, type RequiredServiceType, type ResolvedMethodHandlerType, type ResolvedModuleMeta, type ResolvedModuleOptions, type ResolvedServiceType, type ResolvedSilgiTemplate, type RouteConfig, type RouteRules, type RouteRulesConfig, type ScanFile, type SchemaPreparationOptions, type ServiceParse, type ServiceParseModule, type ServiceType, type Silgi, type SilgiAppPlugin, type SilgiCLI, type SilgiCLIConfig, type SilgiCLIDynamicConfig, type SilgiCLIHooks, type SilgiCLIOptions, type SilgiCompatibility, type SilgiCompatibilityIssue, type SilgiCompatibilityIssues, type SilgiConfig, type SilgiEvents, type SilgiFrameworkInfo, type SilgiFunction, type SilgiHooks, type SilgiModule, type SilgiModuleInput, type SilgiModuleOptions, type SilgiNamespaces, type SilgiOperation, type SilgiOptions, type SilgiPreset, type SilgiPresetMeta, type SilgiRouteRules, type SilgiRouterTypes, type SilgiRuntimeActions, type SilgiRuntimeConfig, type SilgiRuntimeContext, type SilgiRuntimeHooks, type SilgiRuntimeMethods, type SilgiRuntimeOptions, type SilgiRuntimeRouteRules, type SilgiRuntimeRouteRulesConfig, type SilgiRuntimeSharedExtends, type SilgiRuntimeShareds, type SilgiSchema, type SilgiServiceInterface, type SilgiStorageBase, type SilgiTemplate, type SilgiURIs, type StorageConfig, type StorageKeyGenerator, type StorageKeyParams, type StorageMounts, type TSReference, type URIsTypes, autoImportTypes };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { Hookable, NestedHooks } from 'hookable';
|
|
|
6
6
|
import { Ignore, Options } from 'ignore';
|
|
7
7
|
import { TSConfig } from 'pkg-types';
|
|
8
8
|
import { PresetName, PresetOptions, PresetNameInput } from 'silgi/presets';
|
|
9
|
-
import { ResolvedServiceType as ResolvedServiceType$1, SilgiRuntimeShareds as SilgiRuntimeShareds$1, SilgiRuntimeOptions as SilgiRuntimeOptions$1, ModuleMeta as ModuleMeta$1, DotenvOptions as DotenvOptions$1, EnvOptions as EnvOptions$1, SilgiRuntimeConfig as SilgiRuntimeConfig$1, SilgiCLIHooks as SilgiCLIHooks$1, StorageMounts as StorageMounts$1, SilgiTemplate as SilgiTemplate$1, SilgiFrameworkInfo as SilgiFrameworkInfo$1 } from 'silgi/types';
|
|
9
|
+
import { ResolvedServiceType as ResolvedServiceType$1, SilgiRuntimeShareds as SilgiRuntimeShareds$1, SilgiRuntimeOptions as SilgiRuntimeOptions$1, RouteRules as RouteRules$1, ModuleMeta as ModuleMeta$1, SilgiRouteRules as SilgiRouteRules$1, DotenvOptions as DotenvOptions$1, EnvOptions as EnvOptions$1, SilgiRuntimeConfig as SilgiRuntimeConfig$1, ServiceParseModule as ServiceParseModule$1, SilgiCLIHooks as SilgiCLIHooks$1, StorageMounts as StorageMounts$1, SilgiTemplate as SilgiTemplate$1, SilgiFrameworkInfo as SilgiFrameworkInfo$1 } from 'silgi/types';
|
|
10
10
|
import { UnimportPluginOptions } from 'unimport/unplugin';
|
|
11
11
|
import { Defu } from 'defu';
|
|
12
12
|
import { Unimport } from 'unimport';
|
|
@@ -55,6 +55,7 @@ interface SilgiCLI {
|
|
|
55
55
|
modulesURIs: Partial<Record<keyof SilgiRuntimeOptions$1 | (string & {}), any>>;
|
|
56
56
|
scannedURIs: Map<string, string>;
|
|
57
57
|
templates: SilgiTemplate[];
|
|
58
|
+
routeRules: RouteRules$1;
|
|
58
59
|
hooks: Hookable<SilgiCLIHooks>;
|
|
59
60
|
hook: SilgiCLI['hooks']['hook'];
|
|
60
61
|
callHook: SilgiCLI['hooks']['callHook'];
|
|
@@ -170,6 +171,14 @@ interface SchemaPreparationOptions extends ImportItem {
|
|
|
170
171
|
key: string;
|
|
171
172
|
value: string;
|
|
172
173
|
}[];
|
|
174
|
+
routeRules: {
|
|
175
|
+
key: string;
|
|
176
|
+
value: string;
|
|
177
|
+
}[];
|
|
178
|
+
routeRulesConfig: {
|
|
179
|
+
key: string;
|
|
180
|
+
value: string;
|
|
181
|
+
}[];
|
|
173
182
|
contexts: {
|
|
174
183
|
key: string;
|
|
175
184
|
value: string;
|
|
@@ -242,11 +251,11 @@ interface SilgiCLIHooks extends SilgiHooks {
|
|
|
242
251
|
'prepare:core.ts': (data: PrepareCore) => HookResult;
|
|
243
252
|
'after:prepare:core.ts': (content: string[]) => HookResult;
|
|
244
253
|
'prepare:scan.ts': (data: Pick<ImportItem, 'customImports' | 'importItems'> & {
|
|
245
|
-
uris: string
|
|
254
|
+
uris: Record<string, string>;
|
|
246
255
|
services: string[];
|
|
247
256
|
shareds: string[];
|
|
248
257
|
schemas: string[];
|
|
249
|
-
modulesURIs: string
|
|
258
|
+
modulesURIs: Record<string, string>;
|
|
250
259
|
}) => HookResult;
|
|
251
260
|
'after:prepare:scan.ts': (content: string[]) => HookResult;
|
|
252
261
|
'prepare:schema.ts': (options: SchemaPreparationOptions) => HookResult;
|
|
@@ -563,12 +572,14 @@ interface SilgiCLIOptions extends PresetOptions {
|
|
|
563
572
|
command?: string;
|
|
564
573
|
};
|
|
565
574
|
commandType: CommandType;
|
|
575
|
+
routeRules: SilgiRouteRules$1;
|
|
566
576
|
environments: DotenvOptions$1[];
|
|
567
577
|
activeEnvironment: string;
|
|
568
578
|
envOptions: EnvOptions$1;
|
|
569
579
|
runtimeConfig: SilgiRuntimeConfig$1 & {
|
|
570
580
|
[key: string]: any;
|
|
571
581
|
};
|
|
582
|
+
serviceParseModules: ServiceParseModule$1[];
|
|
572
583
|
storages: string[];
|
|
573
584
|
namespaces: string[];
|
|
574
585
|
hooks: NestedHooks<SilgiCLIHooks$1>;
|
|
@@ -576,7 +587,6 @@ interface SilgiCLIOptions extends PresetOptions {
|
|
|
576
587
|
path: string;
|
|
577
588
|
packageImport: string;
|
|
578
589
|
}[];
|
|
579
|
-
routeRules: Record<string, string>;
|
|
580
590
|
compatibilityDate: CompatibilityDates;
|
|
581
591
|
modules: (SilgiModule<any> | string | [SilgiModule | string, Record<string, any>] | undefined | null | false)[];
|
|
582
592
|
_modules: (SilgiModule<any> | string | [SilgiModule | string, Record<string, any>] | undefined | null | false)[];
|
|
@@ -800,6 +810,49 @@ interface EnvOptions {
|
|
|
800
810
|
envExpansion?: boolean;
|
|
801
811
|
}
|
|
802
812
|
|
|
813
|
+
interface DefaultRouteConfig extends SilgiRuntimeRouteRulesConfig {
|
|
814
|
+
[key: string]: any;
|
|
815
|
+
}
|
|
816
|
+
interface DefaultRouteRules extends SilgiRuntimeRouteRules {
|
|
817
|
+
[key: string]: any;
|
|
818
|
+
}
|
|
819
|
+
type SilgiRouteRules = Record<DefaultRouteRules extends string ? DefaultRouteRules : string, DefaultRouteConfig>;
|
|
820
|
+
type RouteConfig<T extends Record<string, any> = DefaultRouteConfig> = T;
|
|
821
|
+
type RouteRulesConfig<T extends Record<string, any> = DefaultRouteConfig> = Record<string, T>;
|
|
822
|
+
type MergedRulesCache<T extends Record<string, any> = DefaultRouteConfig> = Record<string, T>;
|
|
823
|
+
interface SilgiRuntimeRouteRules {
|
|
824
|
+
}
|
|
825
|
+
interface SilgiRuntimeRouteRulesConfig {
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* Interface for the object returned by createRouteRules
|
|
829
|
+
*/
|
|
830
|
+
interface RouteRules<T extends Record<string, any> = DefaultRouteRules> {
|
|
831
|
+
readonly rules: RouteRulesConfig<T>;
|
|
832
|
+
readonly mergedRules: MergedRulesCache<T>;
|
|
833
|
+
importRules: (config: RouteRulesConfig<T>) => void;
|
|
834
|
+
exportRules: () => RouteRulesConfig<T>;
|
|
835
|
+
addRule: (pattern: string, config: RouteConfig<T>) => void;
|
|
836
|
+
updateRule: (pattern: string, config: Partial<RouteConfig<T>>) => void;
|
|
837
|
+
removeRule: (pattern: string) => void;
|
|
838
|
+
matchesRule: (url: string, pattern: string) => boolean;
|
|
839
|
+
getMatchingPatterns: (url: string) => string[];
|
|
840
|
+
getConfig: (url: string) => RouteConfig<T> | null;
|
|
841
|
+
getParams: (url: string, pattern: string) => Record<string, string> | null;
|
|
842
|
+
match: (url: string) => {
|
|
843
|
+
pattern: string;
|
|
844
|
+
config: RouteConfig<T>;
|
|
845
|
+
params: Record<string, string> | null;
|
|
846
|
+
} | null;
|
|
847
|
+
clear: () => void;
|
|
848
|
+
clearMergedRules: () => void;
|
|
849
|
+
precomputeMergedRules: (urls: string[]) => void;
|
|
850
|
+
setMergedRule: (url: string, config: RouteConfig<T>) => void;
|
|
851
|
+
getMergedRules: () => MergedRulesCache<T>;
|
|
852
|
+
configure: (config: RouteRulesConfig<T>) => void;
|
|
853
|
+
updateMergeRules: () => MergedRulesCache<T>;
|
|
854
|
+
}
|
|
855
|
+
|
|
803
856
|
type CustomDriverName = string & {
|
|
804
857
|
_custom?: any;
|
|
805
858
|
};
|
|
@@ -851,6 +904,7 @@ type MethodHandlerType<T> = {
|
|
|
851
904
|
parameters: StandardSchemaV1.InferInput<T[Action][Method]['pathParams']> & StandardSchemaV1.InferInput<T[Action][Method]['queryParams']>;
|
|
852
905
|
}, shared: SilgiRuntimeShareds, event: SilgiEvents, source: StandardSchemaV1.InferInput<T[Action][Method]['source']>) => EventHandlerResponse<StandardSchemaV1.InferOutput<T[Action][Method]['output']>>;
|
|
853
906
|
modules?: Partial<SilgiRuntimeActions>;
|
|
907
|
+
routeRules?: SilgiRouteRules;
|
|
854
908
|
storage?: StorageConfig<T[Action][Method]['input']>;
|
|
855
909
|
};
|
|
856
910
|
} : never;
|
|
@@ -863,6 +917,7 @@ interface ResolvedMethodHandlerType {
|
|
|
863
917
|
}, shared: SilgiRuntimeShareds, event: SilgiEvents, source: StandardSchemaV1.InferInput<any>) => Promise<StandardSchemaV1.InferInput<any>>;
|
|
864
918
|
modules?: Partial<SilgiRuntimeActions>;
|
|
865
919
|
storage?: StorageConfig<StandardSchemaV1.InferInput<any>>;
|
|
920
|
+
routeRules?: SilgiRouteRules;
|
|
866
921
|
execute: (input: StandardSchemaV1.InferInput<any>, shared: SilgiRuntimeShareds, event: SilgiEvents, source: StandardSchemaV1.InferInput<any>) => Promise<StandardSchemaV1.InferInput<any>>;
|
|
867
922
|
}
|
|
868
923
|
|
|
@@ -927,6 +982,7 @@ interface Silgi {
|
|
|
927
982
|
scannedHandlers: Map<string, ResolvedMethodHandlerType>;
|
|
928
983
|
plugins: SilgiAppPlugin[];
|
|
929
984
|
framework: FrameworkContext;
|
|
985
|
+
routeRules: RouteRules;
|
|
930
986
|
_ignore?: Ignore;
|
|
931
987
|
hooks: Hookable<SilgiRuntimeHooks & DefaultHooks>;
|
|
932
988
|
hook: Silgi['hooks']['hook'];
|
|
@@ -987,6 +1043,7 @@ interface SilgiRuntimeConfig {
|
|
|
987
1043
|
}
|
|
988
1044
|
interface SilgiOptions {
|
|
989
1045
|
consolaOptions?: Partial<ConsolaOptions>;
|
|
1046
|
+
routeRules: SilgiRouteRules;
|
|
990
1047
|
present: PresetNameInput;
|
|
991
1048
|
hooks: Partial<SilgiRuntimeHooks & DefaultHooks>;
|
|
992
1049
|
/**
|
|
@@ -1054,6 +1111,16 @@ type Namespaces<T extends BaseNamespaceType> = {
|
|
|
1054
1111
|
};
|
|
1055
1112
|
};
|
|
1056
1113
|
|
|
1114
|
+
interface ServiceParse {
|
|
1115
|
+
node: ResolvedMethodHandlerType;
|
|
1116
|
+
basePath: string;
|
|
1117
|
+
silgi: SilgiCLI;
|
|
1118
|
+
modulesURIs: Record<string, Record<string, any>>;
|
|
1119
|
+
}
|
|
1120
|
+
interface ServiceParseModule {
|
|
1121
|
+
(params: ServiceParse): Awaited<void> | void;
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1057
1124
|
declare const autoImportTypes: string[];
|
|
1058
1125
|
|
|
1059
|
-
export { type AppConfig, type Awaitable, type BaseNamespaceType, type BaseSchemaType, type BaseSilgiMethodType, type CaptureError, type CapturedErrorContext, type CommandType, type CreateScope, type DeepPartial, type DefaultHooks, type DefaultNamespaces, type DotenvOptions, type EnvOptions, type EventHandlerResponse, type ExtendContext, type ExtendShared, type ExtractInputFromURI, type ExtractOutputFromURI, type ExtractPathParamsFromURI, type ExtractQueryParamsFromURI, type ExtractSourceFromURI, type FrameworkContext, type GenerateAppOptions, type GraphQLJSON, type HookResult, type ImportItem, type LoadConfigOptions, type MergedSilgiSchema, type MethodHandlerType, type ModuleDefinition, type ModuleHookContext, type ModuleMeta, type ModuleOptionsCustom, type ModuleSetupInstallResult, type ModuleSetupReturn, type Namespaces, type NitroBuildInfo, type PrepareCore, type RequiredServiceType, type ResolvedMethodHandlerType, type ResolvedModuleMeta, type ResolvedModuleOptions, type ResolvedServiceType, type ResolvedSilgiTemplate, type ScanFile, type SchemaPreparationOptions, type ServiceType, type Silgi, type SilgiAppPlugin, type SilgiCLI, type SilgiCLIConfig, type SilgiCLIDynamicConfig, type SilgiCLIHooks, type SilgiCLIOptions, type SilgiCompatibility, type SilgiCompatibilityIssue, type SilgiCompatibilityIssues, type SilgiConfig, type SilgiEvents, type SilgiFrameworkInfo, type SilgiFunction, type SilgiHooks, type SilgiModule, type SilgiModuleInput, type SilgiModuleOptions, type SilgiNamespaces, type SilgiOperation, type SilgiOptions, type SilgiPreset, type SilgiPresetMeta, type SilgiRouterTypes, type SilgiRuntimeActions, type SilgiRuntimeConfig, type SilgiRuntimeContext, type SilgiRuntimeHooks, type SilgiRuntimeMethods, type SilgiRuntimeOptions, type SilgiRuntimeSharedExtends, type SilgiRuntimeShareds, type SilgiSchema, type SilgiServiceInterface, type SilgiStorageBase, type SilgiTemplate, type SilgiURIs, type StorageConfig, type StorageKeyGenerator, type StorageKeyParams, type StorageMounts, type TSReference, type URIsTypes, autoImportTypes };
|
|
1126
|
+
export { type AppConfig, type Awaitable, type BaseNamespaceType, type BaseSchemaType, type BaseSilgiMethodType, type CaptureError, type CapturedErrorContext, type CommandType, type CreateScope, type DeepPartial, type DefaultHooks, type DefaultNamespaces, type DotenvOptions, type EnvOptions, type EventHandlerResponse, type ExtendContext, type ExtendShared, type ExtractInputFromURI, type ExtractOutputFromURI, type ExtractPathParamsFromURI, type ExtractQueryParamsFromURI, type ExtractSourceFromURI, type FrameworkContext, type GenerateAppOptions, type GraphQLJSON, type HookResult, type ImportItem, type LoadConfigOptions, type MergedRulesCache, type MergedSilgiSchema, type MethodHandlerType, type ModuleDefinition, type ModuleHookContext, type ModuleMeta, type ModuleOptionsCustom, type ModuleSetupInstallResult, type ModuleSetupReturn, type Namespaces, type NitroBuildInfo, type PrepareCore, type RequiredServiceType, type ResolvedMethodHandlerType, type ResolvedModuleMeta, type ResolvedModuleOptions, type ResolvedServiceType, type ResolvedSilgiTemplate, type RouteConfig, type RouteRules, type RouteRulesConfig, type ScanFile, type SchemaPreparationOptions, type ServiceParse, type ServiceParseModule, type ServiceType, type Silgi, type SilgiAppPlugin, type SilgiCLI, type SilgiCLIConfig, type SilgiCLIDynamicConfig, type SilgiCLIHooks, type SilgiCLIOptions, type SilgiCompatibility, type SilgiCompatibilityIssue, type SilgiCompatibilityIssues, type SilgiConfig, type SilgiEvents, type SilgiFrameworkInfo, type SilgiFunction, type SilgiHooks, type SilgiModule, type SilgiModuleInput, type SilgiModuleOptions, type SilgiNamespaces, type SilgiOperation, type SilgiOptions, type SilgiPreset, type SilgiPresetMeta, type SilgiRouteRules, type SilgiRouterTypes, type SilgiRuntimeActions, type SilgiRuntimeConfig, type SilgiRuntimeContext, type SilgiRuntimeHooks, type SilgiRuntimeMethods, type SilgiRuntimeOptions, type SilgiRuntimeRouteRules, type SilgiRuntimeRouteRulesConfig, type SilgiRuntimeSharedExtends, type SilgiRuntimeShareds, type SilgiSchema, type SilgiServiceInterface, type SilgiStorageBase, type SilgiTemplate, type SilgiURIs, type StorageConfig, type StorageKeyGenerator, type StorageKeyParams, type StorageMounts, type TSReference, type URIsTypes, autoImportTypes };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "silgi",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.16.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"exports": {
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"dependencies": {
|
|
114
114
|
"@clack/prompts": "^0.10.0",
|
|
115
115
|
"@fastify/deepmerge": "^2.0.2",
|
|
116
|
-
"@oxc-parser/wasm": "^0.
|
|
116
|
+
"@oxc-parser/wasm": "^0.56.0",
|
|
117
117
|
"@standard-schema/spec": "^1.0.0",
|
|
118
118
|
"c12": "^3.0.2",
|
|
119
119
|
"chokidar": "^4.0.3",
|
|
@@ -133,13 +133,13 @@
|
|
|
133
133
|
"knitwork": "^1.2.0",
|
|
134
134
|
"mlly": "^1.7.4",
|
|
135
135
|
"ofetch": "^1.4.1",
|
|
136
|
-
"ohash": "^2.0.
|
|
136
|
+
"ohash": "^2.0.11",
|
|
137
137
|
"pathe": "^2.0.3",
|
|
138
138
|
"picocolors": "^1.1.1",
|
|
139
|
-
"pkg-types": "^2.0
|
|
139
|
+
"pkg-types": "^2.1.0",
|
|
140
140
|
"scule": "^1.3.0",
|
|
141
141
|
"semver": "^7.7.1",
|
|
142
|
-
"std-env": "^3.8.
|
|
142
|
+
"std-env": "^3.8.1",
|
|
143
143
|
"ufo": "^1.5.4",
|
|
144
144
|
"unctx": "^2.4.1",
|
|
145
145
|
"unimport": "^4.1.2",
|
|
@@ -147,19 +147,19 @@
|
|
|
147
147
|
"untyped": "^2.0.0"
|
|
148
148
|
},
|
|
149
149
|
"devDependencies": {
|
|
150
|
-
"@antfu/eslint-config": "^4.
|
|
150
|
+
"@antfu/eslint-config": "^4.6.0",
|
|
151
151
|
"@nuxt/kit": "^3.15.4",
|
|
152
152
|
"@nuxt/schema": "^3.15.4",
|
|
153
|
-
"@types/node": "^22.13.
|
|
153
|
+
"@types/node": "^22.13.9",
|
|
154
154
|
"@types/semver": "^7.5.8",
|
|
155
155
|
"@vitest/coverage-v8": "3.0.5",
|
|
156
156
|
"eslint": "^9.21.0",
|
|
157
157
|
"h3": "^1.15.1",
|
|
158
|
-
"nitropack": "^2.
|
|
158
|
+
"nitropack": "^2.11.4",
|
|
159
159
|
"nuxt": "^3.15.4",
|
|
160
160
|
"typescript": "^5.8.2",
|
|
161
161
|
"unbuild": "^3.5.0",
|
|
162
|
-
"vitest": "^3.0.
|
|
162
|
+
"vitest": "^3.0.8",
|
|
163
163
|
"vue": "^3.5.13",
|
|
164
164
|
"zod": "^3.24.2"
|
|
165
165
|
},
|