silgi 0.38.14 → 0.38.16

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.
@@ -468,6 +468,19 @@ async function registerModuleExportScan(silgi) {
468
468
  });
469
469
  options.routeRules.push({ key: configKey, value: importName });
470
470
  }
471
+ if (hasTypeExport("MetaData")) {
472
+ const importName = hash(`${configKey}MetaData`);
473
+ options.addImportItemType({
474
+ imports: [
475
+ {
476
+ as: importName,
477
+ name: "MetaData"
478
+ }
479
+ ],
480
+ specifier
481
+ });
482
+ options.metaDatas.push({ key: configKey, value: importName });
483
+ }
471
484
  }
472
485
  });
473
486
  }
@@ -1869,7 +1882,8 @@ async function prepareSchema(silgi) {
1869
1882
  runtimeHooks: [],
1870
1883
  runtimeOptions: [],
1871
1884
  methods: [],
1872
- routeRules: []
1885
+ routeRules: [],
1886
+ metaDatas: []
1873
1887
  };
1874
1888
  await silgi.callHook("before:schema.ts", data);
1875
1889
  const silgiScanTS = relativeWithDot(silgi.options.build.typesDir, `${silgi.options.silgi.serverDir}/scan`);
@@ -1911,6 +1925,9 @@ async function prepareSchema(silgi) {
1911
1925
  `type SilgiRuntimeOptionExtends = ${data.runtimeOptions?.length ? data.runtimeOptions.map(({ value }) => `${value}`).join(" & ") : "{}"}`,
1912
1926
  "",
1913
1927
  `type RouteRulesExtend = ${data.routeRules?.length ? data.routeRules.map(({ value }) => `${value}`).join(" & ") : "{}"}`,
1928
+ "",
1929
+ `type MetaDataExtend = ${data.metaDatas?.length ? data.metaDatas.map(({ value }) => `${value}`).join(" & ") : "{}"}`,
1930
+ "",
1914
1931
  silgi.options.typescript.generateRuntimeConfigTypes ? generateTypes(
1915
1932
  await resolveSchema(
1916
1933
  {
@@ -1969,7 +1986,8 @@ async function prepareSchema(silgi) {
1969
1986
  SilgiRuntimeMethods: [{}, { extends: ["RuntimeMethodExtends"] }],
1970
1987
  Routers: [{}, { extends: ["RoutersExtend"] }],
1971
1988
  SilgiModuleOptions: [{}, { extends: ["SilgiModuleOptionExtend"] }],
1972
- RouteRules: [{}, { extends: ["RouteRulesExtend"] }]
1989
+ RouteRules: [{}, { extends: ["RouteRulesExtend"] }],
1990
+ MetaData: [{}, { extends: ["MetaDataExtend"] }]
1973
1991
  }).replace(/,\s*/g, "\n"),
1974
1992
  "",
1975
1993
  "export {}"
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { defineCommand, runMain } from 'citty';
3
3
 
4
- const version = "0.38.14";
4
+ const version = "0.38.16";
5
5
  const packageJson = {
6
6
  version: version};
7
7
 
@@ -245,16 +245,17 @@ declare function createService<Schema extends SilgiSchema, Path extends keyof Sc
245
245
  };
246
246
  };
247
247
  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}`;
248
- type MiddlewareParams<Schema extends SilgiSchema, Path extends keyof Schema & string, S extends string = WildcardVariants<Path>, Service extends MiddlewareDefinition = MiddlewareDefinition, Method extends string = HttpMethod, UsedMethod extends readonly Method[] = readonly never[]> = ({
249
- path: S;
250
- method: UsedMethod;
248
+ type MiddlewareParams<Schema extends SilgiSchema, Path extends keyof Schema & string, S extends string = WildcardVariants<Path>, Service extends MiddlewareDefinition = MiddlewareDefinition, Method extends string = HttpMethod, UsedMethod extends readonly Method[] = readonly never[], Global extends boolean = false> = Global extends true ? {
249
+ global: Global;
250
+ key: string;
251
251
  setup: Service;
252
- }) | ({
253
- global: true;
254
- key: S;
255
252
  method?: UsedMethod;
253
+ } : {
254
+ global?: Global;
255
+ path: S;
256
+ method: UsedMethod;
256
257
  setup: Service;
257
- });
258
+ };
258
259
  type MiddlewareReturn<S extends string, Service extends MiddlewareDefinition, UsedMethod extends readonly string[]> = {
259
260
  [K in S]: {
260
261
  method: boolean;
@@ -264,7 +265,7 @@ type MiddlewareReturn<S extends string, Service extends MiddlewareDefinition, Us
264
265
  };
265
266
  };
266
267
  };
267
- declare function createMiddleware<Schema extends SilgiSchema, Path extends keyof Schema & string, S extends string = WildcardVariants<Path>, Service extends MiddlewareDefinition = MiddlewareDefinition, Method extends string = HttpMethod, UsedMethod extends readonly Method[] = readonly never[]>(params: MiddlewareParams<Schema, Path, S, Service, Method, UsedMethod>): MiddlewareReturn<S, Service, UsedMethod>;
268
+ declare function createMiddleware<Schema extends SilgiSchema, Path extends keyof Schema & string, S extends string = WildcardVariants<Path>, Service extends MiddlewareDefinition = MiddlewareDefinition, Method extends string = HttpMethod, UsedMethod extends readonly Method[] = readonly never[], Global extends boolean = false>(params: MiddlewareParams<Schema, Path, S, Service, Method, UsedMethod, Global>): MiddlewareReturn<S, Service, UsedMethod>;
268
269
 
269
270
  declare function createShared(shared: Partial<SilgiRuntimeShareds>): SilgiRuntimeShareds;
270
271
 
@@ -1075,7 +1075,8 @@ function createMiddleware(params) {
1075
1075
  [params.key]: {
1076
1076
  method: false,
1077
1077
  global: params.global,
1078
- methods: {}
1078
+ methods: {},
1079
+ setup: params.setup
1079
1080
  }
1080
1081
  };
1081
1082
  }
@@ -448,7 +448,7 @@ interface SilgiCLI {
448
448
  options: SilgiCLIOptions;
449
449
  _requiredModules: Record<string, boolean>;
450
450
  adapters: Record<string, Adapter<Record<string, any>, TablesSchema, InferModelTypes<TablesSchema>>>;
451
- meta: SilgiMeta;
451
+ meta: MetaData;
452
452
  }
453
453
  interface SilgiFrameworkInfo {
454
454
  name?: 'silgi' | (string & {});
@@ -694,13 +694,13 @@ interface SilgiOptions {
694
694
  };
695
695
  captureError: CaptureError;
696
696
  adapters: Record<string, Adapter<Record<string, any>, TablesSchema, InferModelTypes<TablesSchema>>>;
697
- meta: SilgiMeta;
697
+ meta: MetaData;
698
698
  [key: string]: any;
699
699
  }
700
700
 
701
701
  type StandardHTTPMethod = 'GET' | 'HEAD' | 'PATCH' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE';
702
702
  type HTTPMethod = SilgiRuntimeMethods extends Record<string, any> ? keyof SilgiRuntimeMethods | StandardHTTPMethod : StandardHTTPMethod;
703
- interface SilgiMeta extends Record<string, unknown> {
703
+ interface MetaData extends Record<string, unknown> {
704
704
  }
705
705
  interface SilgiRoute {
706
706
  route: string;
@@ -884,6 +884,10 @@ interface SilgiCLIHooks extends SilgiHooks {
884
884
  key: string;
885
885
  value: string;
886
886
  }[];
887
+ metaDatas: {
888
+ key: string;
889
+ value: string;
890
+ }[];
887
891
  events: {
888
892
  key: string;
889
893
  value: string;
@@ -1222,4 +1226,4 @@ interface LoadConfigOptions {
1222
1226
  consola?: ConsolaInstance;
1223
1227
  }
1224
1228
 
1225
- 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, GenImport, GenerateAppOptions, HTTPMethod, HookResult, HttpMethod, LoadConfigOptions, MergeAll, MergedSilgiSchema, MethodSchemas, MiddlewareDefinition, MiddlewareHandler, MiddlewareRoute, MiddlewareSetup, ModuleDefinition, ModuleHookContext, ModuleMeta, ModuleOptionsCustom, ModuleSetupInstallResult, ModuleSetupReturn, NamespacesForPrefix, NitroBuildInfo, RequiredServiceType, ResolvedMiddlewareDefinition, ResolvedModuleMeta, ResolvedModuleOptions, ResolvedSchema, ResolvedSchemaDefinition, ResolvedServiceDefinition, ResolvedSilgiTemplate, RouteConfig, RouteConfigService, RouteRules, RouterParams, Routers, RoutesForPrefixAndNamespace, ScanFile, Schema, ServiceHandler, ServiceHandlerInput, ServiceHandlerOutput, ServiceHandlerSource, ServiceMethods, ServiceSetup, SetupModuleOption, Silgi, SilgiAppPlugin, SilgiCLI, SilgiCLIConfig, SilgiCLIHooks, SilgiCLIOptions, SilgiCommands, SilgiCompatibility, SilgiCompatibilityIssue, SilgiCompatibilityIssues, SilgiConfig, SilgiEvent, SilgiFetchClient, SilgiFetchOptions, SilgiFrameworkInfo, SilgiHooks, SilgiMeta, 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 };
1229
+ 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, GenImport, GenerateAppOptions, HTTPMethod, HookResult, HttpMethod, LoadConfigOptions, MergeAll, MergedSilgiSchema, MetaData, MethodSchemas, MiddlewareDefinition, MiddlewareHandler, MiddlewareRoute, MiddlewareSetup, ModuleDefinition, ModuleHookContext, ModuleMeta, ModuleOptionsCustom, ModuleSetupInstallResult, ModuleSetupReturn, NamespacesForPrefix, NitroBuildInfo, RequiredServiceType, ResolvedMiddlewareDefinition, ResolvedModuleMeta, ResolvedModuleOptions, ResolvedSchema, ResolvedSchemaDefinition, ResolvedServiceDefinition, ResolvedSilgiTemplate, RouteConfig, RouteConfigService, RouteRules, RouterParams, Routers, RoutesForPrefixAndNamespace, ScanFile, Schema, ServiceHandler, ServiceHandlerInput, ServiceHandlerOutput, ServiceHandlerSource, ServiceMethods, ServiceSetup, 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 };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.38.14",
4
+ "version": "0.38.16",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {