silgi 0.37.38 → 0.37.39

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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { defineCommand, runMain } from 'citty';
3
3
 
4
- const version = "0.37.38";
4
+ const version = "0.37.39";
5
5
  const packageJson = {
6
6
  version: version};
7
7
 
@@ -1,5 +1,5 @@
1
1
  import { ApifulConfig } from 'apiful/config';
2
- import { C12InputConfig, ResolvedConfig, ConfigWatcher, WatchConfigOptions } from 'c12';
2
+ import { C12InputConfig, ResolvedConfig, ConfigWatcher, DotenvOptions as DotenvOptions$1, WatchConfigOptions } from 'c12';
3
3
  import { ChokidarOptions } from 'chokidar';
4
4
  import { DateString, CompatibilityDateSpec, CompatibilityDates } from 'compatx';
5
5
  import { ConsolaInstance, ConsolaOptions, LogLevel } from 'consola';
@@ -7,43 +7,27 @@ import { Hookable, NestedHooks } from 'hookable';
7
7
  import { Ignore, Options } from 'ignore';
8
8
  import { TSConfig } from 'pkg-types';
9
9
  import { PresetName, PresetOptions, PresetNameInput } from 'silgi/presets';
10
- import { ResolvedServiceDefinition as ResolvedServiceDefinition$1, SilgiRuntimeShareds as SilgiRuntimeShareds$1, ModuleMeta as ModuleMeta$1, SilgiModule as SilgiModule$1, BuildSilgi as BuildSilgi$1, SilgiSchema as SilgiSchema$1, SilgiEvent as SilgiEvent$1, RouteConfigService as RouteConfigService$1, SilgiRuntimeActions as SilgiRuntimeActions$1, StorageConfig as StorageConfig$1, Commands as Commands$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';
11
10
  import { Adapter, TablesSchema, InferModelTypes } from 'unadapter/types';
12
11
  import { UnimportPluginOptions } from 'unimport/unplugin';
13
- import { Defu } from 'defu';
14
12
  import * as next from 'next';
15
13
  import { NextConfig } from 'next';
16
14
  import { Stats } from 'node:fs';
17
15
  import * as h3 from 'h3';
18
- import { HTTPMethod as HTTPMethod$1, Session } from 'h3';
16
+ import { Session, HTTPMethod as HTTPMethod$1 } from 'h3';
19
17
  import * as nitropack_types from 'nitropack/types';
20
18
  import { ESMImport, ESMCodeGenOptions } from 'knitwork';
21
- import { useRuntimeConfig } from 'silgi/runtime';
22
- import { Unimport } from 'unimport';
23
- import { Storage, TransactionOptions, BuiltinDriverName, StorageValue } from 'unstorage';
24
- import { ServerRequest } from 'srvx';
25
19
  import { StandardSchemaV1 } from '@standard-schema/spec';
26
20
  import { NitroApp } from 'nitropack';
27
21
  import { RouterContext } from 'rou3';
22
+ import { TransactionOptions, BuiltinDriverName, StorageValue, Storage } from 'unstorage';
23
+ import { ServerRequest } from 'srvx';
24
+ import { Defu } from 'defu';
28
25
  import { silgiFetch } from 'silgi';
26
+ import { useRuntimeConfig } from 'silgi/runtime';
27
+ import { Unimport } from 'unimport';
29
28
  import { ProviderName } from 'std-env';
30
29
  import { FetchOptions, FetchResponse } from 'ofetch';
31
30
 
32
- interface SilgiRuntimeMethods {
33
- }
34
- type CommandType = 'run' | 'prepare' | 'install' | 'dev' | 'init';
35
- interface SilgiRouterTypes {
36
- }
37
- interface DefaultHooks {
38
- }
39
- type DeepPartial<T> = T extends (...args: any[]) => any ? T : T extends Record<string, any> ? {
40
- [P in keyof T]?: DeepPartial<T[P]>;
41
- } : T;
42
- type DeepRequired<T> = T extends (...args: any[]) => any ? T : T extends Record<string, any> ? {
43
- [P in keyof T]-?: DeepRequired<T[P]>;
44
- } : T;
45
- type Awaitable<T> = T | Promise<T>;
46
-
47
31
  interface SilgiCompatibilityIssue {
48
32
  name: string;
49
33
  message: string;
@@ -83,279 +67,68 @@ type DeepMerge<A, B> = {
83
67
  */
84
68
  type MergeAll<T extends readonly any[]> = T extends [infer First, ...infer Rest] ? Rest extends [] ? First : DeepMerge<First, MergeAll<Rest>> : object;
85
69
 
86
- interface SilgiCLI {
87
- _ignore?: Ignore;
88
- errors: {
89
- type: 'Parser';
90
- path?: string;
91
- }[];
92
- services: ResolvedServiceDefinition$1;
93
- shareds: SilgiRuntimeShareds$1;
94
- schemas: Record<string, any>;
95
- scannedURIs: Map<string, string>;
96
- templates: SilgiTemplate[];
97
- hooks: Hookable<SilgiCLIHooks>;
98
- hook: SilgiCLI['hooks']['hook'];
99
- callHook: SilgiCLI['hooks']['callHook'];
100
- addHooks: SilgiCLI['hooks']['addHooks'];
101
- storage: Storage;
102
- useLocalConfig: typeof useRuntimeConfig;
103
- unimport?: Unimport;
104
- logger: ConsolaInstance;
105
- close: () => Promise<void>;
106
- updateConfig: (config: SilgiCLIDynamicConfig) => void | Promise<void>;
107
- scanModules: Array<{
108
- meta: ModuleMeta$1;
109
- module: SilgiModule$1;
110
- timings?: Record<string, number | undefined>;
111
- entryPath?: string;
112
- installed?: boolean;
113
- options: Record<string, any>;
114
- }>;
115
- options: SilgiCLIOptions;
116
- _requiredModules: Record<string, boolean>;
117
- adapters: Record<string, Adapter<Record<string, any>, TablesSchema, InferModelTypes<TablesSchema>>>;
118
- }
119
- type SilgiCLIDynamicConfig = Pick<SilgiCLIConfig, 'routeRules'>;
120
- interface SilgiFrameworkInfo {
121
- name?: 'silgi' | (string & {});
122
- version?: string;
123
- }
124
- /** Build info written to `.output/silgi.json` or `.silgi/dev/silgi.json` */
125
- interface NitroBuildInfo {
126
- date: string;
127
- preset: PresetName;
128
- framework: SilgiFrameworkInfo;
129
- versions: {
130
- silgi: string;
131
- [key: string]: string;
132
- };
133
- commands?: {
134
- preview?: string;
135
- deploy?: string;
136
- };
137
- dev?: {
138
- pid: number;
139
- workerAddress: {
140
- host: string;
141
- port: number;
142
- socketPath?: string;
143
- };
144
- };
145
- config?: Partial<PresetOptions>;
146
- }
147
- interface ScanFile {
148
- context: string;
149
- object: {
150
- schemas: any;
151
- services: any;
152
- shareds: any;
153
- };
154
- path: string;
70
+ interface SilgiRuntimeMethods {
155
71
  }
156
- type TemplateDefaultOptions = Record<string, any>;
157
- interface SilgiTemplate<Options = TemplateDefaultOptions> {
158
- /** resolved output file path (generated) */
159
- dst?: string;
160
- /** The target filename once the template is copied into the Silgi buildDir */
161
- filename?: string;
162
- /** An options object that will be accessible within the template via `<% options %>` */
163
- options?: Options;
164
- /** The resolved path to the source file to be template */
165
- src?: string;
166
- /** Provided compile option instead of src */
167
- where?: 'server' | 'client' | '.silgi';
168
- getContents?: (data: {
169
- app: SilgiCLI;
170
- options: Options;
171
- }) => string | Promise<string>;
172
- /** Write to filesystem */
173
- write?: boolean;
174
- skipIfExists?: boolean;
72
+ type CommandType = 'run' | 'prepare' | 'install' | 'dev' | 'init';
73
+ interface SilgiRouterTypes {
175
74
  }
176
- interface ResolvedSilgiTemplate<Options = TemplateDefaultOptions> extends SilgiTemplate<Options> {
177
- filename: string;
178
- dst: string;
179
- modified?: boolean;
75
+ interface DefaultHooks {
180
76
  }
77
+ type DeepPartial<T> = T extends (...args: any[]) => any ? T : T extends Record<string, any> ? {
78
+ [P in keyof T]?: DeepPartial<T[P]>;
79
+ } : T;
80
+ type DeepRequired<T> = T extends (...args: any[]) => any ? T : T extends Record<string, any> ? {
81
+ [P in keyof T]-?: DeepRequired<T[P]>;
82
+ } : T;
83
+ type Awaitable<T> = T | Promise<T>;
181
84
 
182
- interface SilgiCommands {
183
- }
184
- interface Commands {
185
- name: string;
186
- description?: string;
187
- group: string;
188
- when?: boolean;
189
- type: 'function' | 'command';
190
- tags?: (keyof SilgiCommands)[] | (string | object)[];
191
- getContents: (data: {
192
- app: SilgiCLI;
193
- }) => string;
194
- order?: number;
195
- }
196
- interface GenImport {
197
- specifier: string;
198
- imports: ESMImport | ESMImport[];
199
- options?: ESMCodeGenOptions;
200
- }
201
- type Framework<T extends PresetName> = T extends 'nitro' ? nitropack_types.NitroApp : T extends 'nuxt' ? nitropack_types.NitroApp : T extends 'h3' ? h3.Router : T extends 'next' ? next.NextApiHandler : never;
202
- interface DefineFrameworkOptions<T extends PresetName> extends Omit<BuildSilgi$1, 'framework'> {
203
- framework: Framework<T>;
85
+ interface ExtendContext {
204
86
  }
205
-
206
- interface SilgiCLIHooks extends SilgiHooks {
207
- /**
208
- * Called after Silgi initialization, when the Silgi instance is ready to work.
209
- * @param silgi The configured Silgi object
210
- * @returns Promise
211
- */
212
- 'ready': (silgi: SilgiCLI) => HookResult;
87
+ interface SilgiRuntimeContext extends Record<string, any> {
88
+ params?: Record<string, string>;
213
89
  /**
214
- * Called when silgi instance is gracefully closing.
215
- * @param silgi The configured silgi object
216
- * @returns Promise
90
+ * Matched router Node
91
+ *
92
+ * @experimental The object structure may change in non-major version.
217
93
  */
218
- 'close': (silgi: SilgiCLI) => HookResult;
219
- 'reload:scan': (path: string, stats?: Stats) => HookResult;
94
+ matchedRoute?: SilgiRoute;
95
+ sessions?: Record<string, Session>;
96
+ clientAddress?: string;
97
+ source?: any;
98
+ silgi: {
99
+ runtimeConfig?: SilgiRuntimeConfig;
100
+ };
101
+ }
102
+ /**
103
+ * Bu nitrojs, h3 event or request context.
104
+ */
105
+ interface SilgiEvent extends Record<string, unknown> {
220
106
  /**
221
- * Allows extending compatibility checks.
222
- * @param compatibility Compatibility object
223
- * @param issues Issues to be mapped
224
- * @returns Promise
107
+ * Event context.
225
108
  */
226
- 'kit:compatibility': (compatibility: SilgiCompatibility, issues: SilgiCompatibilityIssues) => HookResult;
109
+ readonly context: SilgiRuntimeContext;
227
110
  /**
228
- * Called before Nuxi writes `.nuxt/tsconfig.json` and `.nuxt/nuxt.d.ts`, allowing addition of custom references and declarations in `nuxt.d.ts`, or directly modifying the options in `tsconfig.json`
229
- * @param options Objects containing `references`, `declarations`, `tsConfig`
230
- * @returns Promise
111
+ * Incoming HTTP request info.
112
+ *
113
+ * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Request)
231
114
  */
232
- 'prepare:types': (options: {
233
- references: TSReference[];
234
- declarations: string[];
235
- tsConfig: TSConfig;
236
- }) => HookResult;
237
- 'before:core.ts': (data: {
238
- silgiConfigs: Record<string, any>[];
239
- addImportItem: (data: GenImport | GenImport[]) => void;
240
- addImportItemType: (data: GenImport | GenImport[]) => void;
241
- addBuildFunction: (data: {
242
- name: string;
243
- params?: string[];
244
- custom?: string;
245
- where: 'before' | 'after';
246
- }[] | {
247
- name: string;
248
- params?: string[];
249
- custom?: string;
250
- where: 'before' | 'after';
251
- }) => void;
252
- }) => HookResult;
253
- 'after:core.ts': (content: string[]) => HookResult;
254
- 'before:scan.ts': (data: {
255
- services: string[];
256
- shareds: string[];
257
- routers: string[];
258
- schemas: string[];
259
- addImportItem: (data: GenImport | GenImport[]) => void;
260
- addImportItemType: (data: GenImport | GenImport[]) => void;
261
- }) => HookResult;
262
- 'after:scan.ts': (content: string[]) => HookResult;
263
- 'before:schema.ts': (options: {
264
- addImportItem: (data: GenImport | GenImport[]) => void;
265
- addImportItemType: (data: GenImport | GenImport[]) => void;
266
- options: {
267
- key: string;
268
- value: string;
269
- }[];
270
- runtimeOptions: {
271
- key: string;
272
- value: string;
273
- }[];
274
- methods: {
275
- key: string;
276
- value: string;
277
- }[];
278
- contexts: {
279
- key: string;
280
- value: string;
281
- }[];
282
- actions: {
283
- key: string;
284
- value: string;
285
- }[];
286
- shareds: {
287
- key: string;
288
- value: string;
289
- }[];
290
- events: {
291
- key: string;
292
- value: string;
293
- /**
294
- * If extends is true, it won't be added to the key value interface.
295
- * interface SilgiModuleEventsExtends extends SilgiEvent {}
296
- */
297
- extends?: boolean;
298
- isSilgiContext?: boolean;
299
- }[];
300
- hooks: {
301
- key: string;
302
- value: string;
303
- }[];
304
- runtimeHooks: {
305
- key: string;
306
- value: string;
307
- }[];
308
- }) => HookResult;
309
- 'after:schema.ts': (content: string[]) => HookResult;
310
- 'prepare:configs.ts': (cliOptions: Record<string, any>) => HookResult;
115
+ readonly req: ServerRequest;
311
116
  /**
312
- * Called during `SilgiCLI` generation, to allow customizing, modifying or adding new files to the build directory (either virtually or to written to `.nuxt`).
313
- * @param app The configured `SilgiCLI` object
314
- * @returns Promise
117
+ * Access to the parsed request URL.
118
+ *
119
+ * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/URL)
315
120
  */
316
- 'app:templates': (app: SilgiCLI) => HookResult;
121
+ readonly url: URL;
317
122
  /**
318
- * Called after templates are compiled into the [virtual file system](https://nuxt.com/docs/guide/directory-structure/nuxt#virtual-file-system) (vfs).
319
- * @param app The configured `SilgiCLI` object
320
- * @returns Promise
123
+ * Prepared HTTP response.
321
124
  */
322
- 'app:templatesGenerated': (app: SilgiCLI, templates: ResolvedSilgiTemplate[], options?: GenerateAppOptions) => HookResult;
323
- 'scanFiles:done': (app: SilgiCLI) => HookResult;
324
- 'prepare:commands': (commands: Commands[]) => HookResult;
325
- 'nextjs:prepare': (data: {
326
- config: NextConfig;
327
- }) => HookResult;
328
- }
329
- type TSReference = {
330
- types: string;
331
- } | {
332
- path: string;
333
- };
334
- interface SilgiHooks {
335
- }
336
- interface GenerateAppOptions {
337
- filter?: (template: ResolvedSilgiTemplate<any>) => boolean;
125
+ readonly res: {
126
+ status?: number;
127
+ statusText?: string;
128
+ readonly headers: Headers;
129
+ };
338
130
  }
339
131
 
340
- type TrimAfterFourSlashes<T extends string> = T extends `/${infer S1}/${infer S2}/${infer S3}/${infer S4}/${infer _}` ? `/${S1}/${S2}/${S3}/${S4}` : T;
341
- type AllPaths = SilgiRouterTypes extends {
342
- keys: infer U;
343
- } ? keyof U extends never ? string : keyof U : string;
344
- type ExtractPathParams<T extends string> = T extends `${infer _Start}:${infer Param}/${infer Rest}` ? {
345
- [K in Param]: string;
346
- } & ExtractPathParams<Rest> : T extends `${infer _Start}:${infer Param}` ? {
347
- [K in Param]: string;
348
- } : unknown;
349
-
350
- type HttpMethod = 'get' | 'GET' | 'HEAD' | 'PATCH' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'head' | 'patch' | 'post' | 'put' | 'delete' | 'connect' | 'options' | 'trace';
351
- type RouterParams<R extends AllPaths | (string & {})> = ExtractPathParams<R>;
352
- type SilgiFetchOptions<P extends AllPaths | (string & {}), BasePath extends keyof SilgiRouterTypes = TrimAfterFourSlashes<P> extends keyof SilgiRouterTypes ? TrimAfterFourSlashes<P> : never, M extends keyof SilgiRouterTypes[BasePath] = keyof SilgiRouterTypes[BasePath]> = {
353
- method?: M;
354
- params?: ExtractPathParams<P>;
355
- body?: SilgiRouterTypes[BasePath][M]['input'];
356
- } & Omit<FetchOptions, 'method' | 'body' | 'params'>;
357
- type SilgiFetchClient = <P extends AllPaths | (string & {}), BasePath extends keyof SilgiRouterTypes = TrimAfterFourSlashes<P> extends keyof SilgiRouterTypes ? TrimAfterFourSlashes<P> : never, M extends keyof SilgiRouterTypes[BasePath] = keyof SilgiRouterTypes[BasePath]>(url: BasePath, options?: SilgiFetchOptions<P, BasePath, M>) => Promise<FetchResponse<SilgiRouterTypes[BasePath][M]['output']>>;
358
-
359
132
  /**
360
133
  * Main interface containing all route definitions.
361
134
  * Example:
@@ -495,7 +268,44 @@ interface ResolvedSchemaDefinition {
495
268
  };
496
269
  }
497
270
 
498
- type ServiceMethods<Schema extends SilgiSchema$1, Path extends keyof Schema, Resolved extends boolean = false, HiddenParameters extends boolean = false> = {
271
+ type CustomDriverName = string & {
272
+ _custom?: any;
273
+ };
274
+ interface StorageMounts {
275
+ [path: string]: {
276
+ driver: BuiltinDriverName | CustomDriverName;
277
+ [option: string]: any;
278
+ };
279
+ }
280
+ interface SilgiStorageBase {
281
+ }
282
+ type StorageKeyGenerator<TInput> = (input: TInput) => string | Promise<string>;
283
+ interface StorageConfig<TInput> {
284
+ options: TransactionOptions;
285
+ base: 'memory' | keyof SilgiStorageBase;
286
+ key?: StorageKeyGenerator<TInput>;
287
+ scope?: 'request' | 'global';
288
+ }
289
+ interface StorageKeyParams<TInput = unknown> {
290
+ url: SilgiURL;
291
+ input: TInput;
292
+ requestId?: string;
293
+ keyGenerator?: StorageKeyGenerator<TInput>;
294
+ storageOptions?: Pick<StorageConfig<TInput>, 'base' | 'options' | 'scope'>;
295
+ }
296
+
297
+ interface SilgiRuntimeShareds extends SilgiRuntimeSharedsExtend {
298
+ storage: <T extends StorageValue = StorageValue>(base: StorageConfig<T>['base']) => Storage<T>;
299
+ useRuntimeConfig: typeof useRuntimeConfig;
300
+ $fetch: typeof silgiFetch;
301
+ silgi: Silgi;
302
+ }
303
+ interface SilgiRuntimeSharedsExtend {
304
+ }
305
+ interface ExtendShared {
306
+ }
307
+
308
+ type ServiceMethods<Schema extends SilgiSchema, Path extends keyof Schema, Resolved extends boolean = false, HiddenParameters extends boolean = false> = {
499
309
  [M in keyof Schema[Path]]?: ServiceSetup<Schema, Path, M, Resolved, HiddenParameters>;
500
310
  };
501
311
  /**
@@ -521,17 +331,17 @@ type ServiceHandlerParameters<S, R extends keyof S, M extends keyof S[R]> = S[R]
521
331
  /**
522
332
  * Route ve method'a göre input, output, params çıkarımı
523
333
  */
524
- type ServiceHandlerInput<Schema extends SilgiSchema$1, Route extends keyof Schema, Method extends keyof Schema[Route], HiddenParameters extends boolean = false> = (Schema[Route][Method] extends {
334
+ type ServiceHandlerInput<Schema extends SilgiSchema, Route extends keyof Schema, Method extends keyof Schema[Route], HiddenParameters extends boolean = false> = (Schema[Route][Method] extends {
525
335
  input?: infer I;
526
336
  } ? {
527
337
  args: InferInput<I>;
528
338
  } : unknown) & (HiddenParameters extends false ? (keyof ServiceHandlerParameters<Schema, Route, Method> extends never ? unknown : {
529
339
  parameters: ServiceHandlerParameters<Schema, Route, Method>;
530
340
  }) : unknown);
531
- type ServiceHandlerOutput<Schema extends SilgiSchema$1, Route extends keyof Schema, Method extends keyof Schema[Route]> = Schema[Route][Method] extends {
341
+ type ServiceHandlerOutput<Schema extends SilgiSchema, Route extends keyof Schema, Method extends keyof Schema[Route]> = Schema[Route][Method] extends {
532
342
  output?: infer O;
533
343
  } ? InferOutput<O> : unknown;
534
- type ServiceHandlerSource<Schema extends SilgiSchema$1, Route extends keyof Schema, Method extends keyof Schema[Route]> = Schema[Route][Method] extends {
344
+ type ServiceHandlerSource<Schema extends SilgiSchema, Route extends keyof Schema, Method extends keyof Schema[Route]> = Schema[Route][Method] extends {
535
345
  source?: infer S;
536
346
  } ? InferInput<S> : unknown;
537
347
  /**
@@ -540,15 +350,15 @@ type ServiceHandlerSource<Schema extends SilgiSchema$1, Route extends keyof Sche
540
350
  * Resolved = false -> handler(input, shared, event, source) // all required
541
351
  * Resolved = true -> handler(input, shared?, event?, source?) // only input required
542
352
  */
543
- type ServiceHandler<Schema extends SilgiSchema$1, Route extends keyof Schema, Method extends keyof Schema[Route], Resolved extends boolean = false, HiddenParameters extends boolean = false> = Resolved extends true ? (input: ServiceHandlerInput<Schema, Route, Method, HiddenParameters>, shared?: SilgiRuntimeShareds$1, event?: SilgiEvent$1, source?: ServiceHandlerSource<Schema, Route, Method>) => Promise<ServiceHandlerOutput<Schema, Route, Method>> : (input: ServiceHandlerInput<Schema, Route, Method, HiddenParameters>, shared: SilgiRuntimeShareds$1, event: SilgiEvent$1, source: ServiceHandlerSource<Schema, Route, Method>) => Promise<ServiceHandlerOutput<Schema, Route, Method>>;
353
+ type ServiceHandler<Schema extends SilgiSchema, Route extends keyof Schema, Method extends keyof Schema[Route], Resolved extends boolean = false, HiddenParameters extends boolean = false> = Resolved extends true ? (input: ServiceHandlerInput<Schema, Route, Method, HiddenParameters>, shared?: SilgiRuntimeShareds, event?: SilgiEvent, source?: ServiceHandlerSource<Schema, Route, Method>) => Promise<ServiceHandlerOutput<Schema, Route, Method>> : (input: ServiceHandlerInput<Schema, Route, Method, HiddenParameters>, shared: SilgiRuntimeShareds, event: SilgiEvent, source: ServiceHandlerSource<Schema, Route, Method>) => Promise<ServiceHandlerOutput<Schema, Route, Method>>;
544
354
  /**
545
355
  * Servis setup tipi
546
356
  */
547
- interface ServiceSetup<Schema extends SilgiSchema$1 = SilgiSchema$1, Route extends keyof Schema = keyof Schema, Method extends keyof Schema[Route] = keyof Schema[Route], Resolved extends boolean = false, HiddenParameters extends boolean = false> {
357
+ interface ServiceSetup<Schema extends SilgiSchema = SilgiSchema, Route extends keyof Schema = keyof Schema, Method extends keyof Schema[Route] = keyof Schema[Route], Resolved extends boolean = false, HiddenParameters extends boolean = false> {
548
358
  handler: ServiceHandler<Schema, Route, Method, Resolved, HiddenParameters>;
549
- routerRule?: RouteConfigService$1;
550
- modules?: Partial<SilgiRuntimeActions$1>;
551
- storage?: StorageConfig$1<ServiceHandlerInput<Schema, Route, Method, HiddenParameters>>;
359
+ routerRule?: RouteConfigService;
360
+ modules?: Partial<SilgiRuntimeActions>;
361
+ storage?: StorageConfig<ServiceHandlerInput<Schema, Route, Method, HiddenParameters>>;
552
362
  }
553
363
  /**
554
364
  * Represents a fully resolved service definition that maps route paths
@@ -561,8 +371,8 @@ interface ResolvedServiceDefinition {
561
371
  [routePath: string]: {
562
372
  [method: string]: {
563
373
  handler: (...args: any[]) => Promise<any>;
564
- modules?: Partial<SilgiRuntimeActions$1>;
565
- storage?: StorageConfig$1<any>;
374
+ modules?: Partial<SilgiRuntimeActions>;
375
+ storage?: StorageConfig<any>;
566
376
  };
567
377
  };
568
378
  }
@@ -579,105 +389,220 @@ interface SilgiURL {
579
389
  queryParams?: Record<string, string>;
580
390
  }
581
391
 
582
- type CustomDriverName = string & {
583
- _custom?: any;
584
- };
585
- interface StorageMounts {
586
- [path: string]: {
587
- driver: BuiltinDriverName | CustomDriverName;
588
- [option: string]: any;
392
+ interface SilgiCLI {
393
+ _ignore?: Ignore;
394
+ errors: {
395
+ type: 'Parser';
396
+ path?: string;
397
+ }[];
398
+ services: ResolvedServiceDefinition;
399
+ shareds: SilgiRuntimeShareds;
400
+ schemas: Record<string, any>;
401
+ scannedURIs: Map<string, string>;
402
+ templates: SilgiTemplate[];
403
+ hooks: Hookable<SilgiCLIHooks>;
404
+ hook: SilgiCLI['hooks']['hook'];
405
+ callHook: SilgiCLI['hooks']['callHook'];
406
+ addHooks: SilgiCLI['hooks']['addHooks'];
407
+ storage: Storage;
408
+ useLocalConfig: typeof useRuntimeConfig;
409
+ unimport?: Unimport;
410
+ logger: ConsolaInstance;
411
+ close: () => Promise<void>;
412
+ updateConfig: (config: SilgiCLIDynamicConfig) => void | Promise<void>;
413
+ scanModules: Array<{
414
+ meta: ModuleMeta;
415
+ module: SilgiModule;
416
+ timings?: Record<string, number | undefined>;
417
+ entryPath?: string;
418
+ installed?: boolean;
419
+ options: Record<string, any>;
420
+ }>;
421
+ options: SilgiCLIOptions;
422
+ _requiredModules: Record<string, boolean>;
423
+ adapters: Record<string, Adapter<Record<string, any>, TablesSchema, InferModelTypes<TablesSchema>>>;
424
+ }
425
+ type SilgiCLIDynamicConfig = Pick<SilgiCLIConfig, 'routeRules'>;
426
+ interface SilgiFrameworkInfo {
427
+ name?: 'silgi' | (string & {});
428
+ version?: string;
429
+ }
430
+ /** Build info written to `.output/silgi.json` or `.silgi/dev/silgi.json` */
431
+ interface NitroBuildInfo {
432
+ date: string;
433
+ preset: PresetName;
434
+ framework: SilgiFrameworkInfo;
435
+ versions: {
436
+ silgi: string;
437
+ [key: string]: string;
589
438
  };
439
+ commands?: {
440
+ preview?: string;
441
+ deploy?: string;
442
+ };
443
+ dev?: {
444
+ pid: number;
445
+ workerAddress: {
446
+ host: string;
447
+ port: number;
448
+ socketPath?: string;
449
+ };
450
+ };
451
+ config?: Partial<PresetOptions>;
590
452
  }
591
- interface SilgiStorageBase {
453
+ interface ScanFile {
454
+ context: string;
455
+ object: {
456
+ schemas: any;
457
+ services: any;
458
+ shareds: any;
459
+ };
460
+ path: string;
592
461
  }
593
- type StorageKeyGenerator<TInput> = (input: TInput) => string | Promise<string>;
594
- interface StorageConfig<TInput> {
595
- options: TransactionOptions;
596
- base: 'memory' | keyof SilgiStorageBase;
597
- key?: StorageKeyGenerator<TInput>;
598
- scope?: 'request' | 'global';
462
+ type TemplateDefaultOptions = Record<string, any>;
463
+ interface SilgiTemplate<Options = TemplateDefaultOptions> {
464
+ /** resolved output file path (generated) */
465
+ dst?: string;
466
+ /** The target filename once the template is copied into the Silgi buildDir */
467
+ filename?: string;
468
+ /** An options object that will be accessible within the template via `<% options %>` */
469
+ options?: Options;
470
+ /** The resolved path to the source file to be template */
471
+ src?: string;
472
+ /** Provided compile option instead of src */
473
+ where?: 'server' | 'client' | '.silgi';
474
+ getContents?: (data: {
475
+ app: SilgiCLI;
476
+ options: Options;
477
+ }) => string | Promise<string>;
478
+ /** Write to filesystem */
479
+ write?: boolean;
480
+ skipIfExists?: boolean;
599
481
  }
600
- interface StorageKeyParams<TInput = unknown> {
601
- url: SilgiURL;
602
- input: TInput;
603
- requestId?: string;
604
- keyGenerator?: StorageKeyGenerator<TInput>;
605
- storageOptions?: Pick<StorageConfig<TInput>, 'base' | 'options' | 'scope'>;
482
+ interface ResolvedSilgiTemplate<Options = TemplateDefaultOptions> extends SilgiTemplate<Options> {
483
+ filename: string;
484
+ dst: string;
485
+ modified?: boolean;
606
486
  }
607
487
 
608
- interface SilgiRuntimeShareds extends SilgiRuntimeSharedsExtend {
609
- storage: <T extends StorageValue = StorageValue>(base: StorageConfig<T>['base']) => Storage<T>;
610
- useRuntimeConfig: typeof useRuntimeConfig;
611
- $fetch: typeof silgiFetch;
612
- silgi: Silgi;
488
+ interface SilgiRuntimeActions {
613
489
  }
614
- interface SilgiRuntimeSharedsExtend {
490
+ interface SilgiModuleOptions {
615
491
  }
616
- interface ExtendShared {
492
+ interface SilgiRuntimeOptions {
617
493
  }
618
-
619
- type StandardHTTPMethod = 'GET' | 'HEAD' | 'PATCH' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE';
620
- type HTTPMethod = SilgiRuntimeMethods extends Record<string, any> ? keyof SilgiRuntimeMethods | StandardHTTPMethod : StandardHTTPMethod;
621
- interface SilgiRoute {
622
- route: string;
623
- method?: HTTPMethod;
624
- service: ServiceSetup;
625
- schema: ResolvedSchemaDefinition;
494
+ type SilgiModuleInput = (SilgiModule<any> | string | [SilgiModule | string, Record<string, any>] | undefined | null | false);
495
+ interface SilgiCompatibility {
496
+ /**
497
+ * Required silgi version in semver format.
498
+ * @example `^3.2.0` or `>=3.13.0`.
499
+ */
500
+ silgi?: string;
626
501
  }
627
- interface Silgi {
628
- router: RouterContext<SilgiRoute>;
629
- routerPrefixs: string[];
630
- schemas: ResolvedSchemaDefinition;
631
- services: ResolvedServiceDefinition;
632
- shared: SilgiRuntimeShareds;
633
- plugins: SilgiAppPlugin[];
634
- framework?: {
635
- nitro?: NitroApp;
502
+ interface ModuleMeta {
503
+ /** Module name. */
504
+ name?: string;
505
+ /** Module description. */
506
+ description?: string;
507
+ /** Module author. */
508
+ author?: string;
509
+ /** Module license. */
510
+ license?: string;
511
+ /** Module version. */
512
+ version?: string;
513
+ /**
514
+ * The configuration key used within `silgi.config` for this module's options.
515
+ * For example, `@silgijs/axios` uses `axios`.
516
+ */
517
+ configKey?: string;
518
+ /**
519
+ * Constraints for the versions of silgi or features this module requires.
520
+ */
521
+ compatibility?: SilgiCompatibility;
522
+ /**
523
+ * @private
524
+ */
525
+ _modules?: {
526
+ [key: string]: string;
636
527
  };
637
- _ignore?: Ignore;
638
- hooks: Hookable<SilgiRuntimeHooks & DefaultHooks>;
639
- hook: Silgi['hooks']['hook'];
640
- callHook: Silgi['hooks']['callHook'];
641
- addHooks: Silgi['hooks']['addHooks'];
642
- ready: () => Promise<void>;
643
- close: () => Promise<void>;
644
- logger: ConsolaInstance;
645
- storage: Storage;
646
- envOptions: EnvOptions;
647
- options: SilgiOptions & SilgiRuntimeOptions;
648
- captureError: CaptureError;
528
+ /**
529
+ * @private
530
+ */
531
+ _packageName?: string;
532
+ cliToRuntimeOptionsKeys?: string[];
533
+ readonly afterDependencies?: ReadonlyArray<string>;
534
+ readonly beforeDependencies?: ReadonlyArray<string>;
535
+ readonly requiredDependencies?: ReadonlyArray<string>;
536
+ [key: string]: unknown;
649
537
  }
650
- interface SilgiConfig extends Partial<Omit<Silgi, 'options'>>, Partial<SilgiRuntimeOptions> {
651
- options: DeepPartial<SilgiOptions>;
538
+ interface ResolvedModuleMeta extends ModuleMeta {
539
+ configKey: string;
540
+ name: string;
652
541
  }
653
- interface BuildSilgi {
654
- framework?: {
655
- nitro?: NitroApp;
542
+ type ModuleHookContext = Readonly<{
543
+ event?: SilgiEvent;
544
+ url: SilgiURL;
545
+ input?: unknown;
546
+ result?: unknown;
547
+ route?: SilgiRoute;
548
+ error?: Error;
549
+ success?: boolean;
550
+ cached?: boolean;
551
+ }> & {
552
+ hookContext?: {
553
+ earlyReturnValue: any | false;
656
554
  };
657
- modules?: Partial<SilgiRuntimeOptions>;
658
- options?: Partial<SilgiOptions>;
555
+ };
556
+ /** The options received. */
557
+ type ModuleOptionsCustom = Record<string, any>;
558
+ type Prettify<T> = {
559
+ [K in keyof T]: T[K];
560
+ } & {};
561
+ type ResolvedModuleOptions<TOptions extends ModuleOptionsCustom, TOptionsDefaults extends Partial<TOptions>> = Prettify<Defu<Partial<TOptions>, [
562
+ Partial<TOptions>,
563
+ TOptionsDefaults
564
+ ]>>;
565
+ interface ModuleDefinition<TOptions extends ModuleOptionsCustom, TOptionsDefaults extends Partial<TOptions>, TWith extends boolean> {
566
+ meta?: ModuleMeta;
567
+ defaults?: TOptionsDefaults | ((silgi: SilgiCLI) => Awaitable<TOptionsDefaults>);
568
+ hooks?: Partial<SilgiCLIHooks>;
569
+ setup?: (this: void, resolvedOptions: TWith extends true ? ResolvedModuleOptions<TOptions, TOptionsDefaults> : TOptions, silgi: SilgiCLI & SilgiModuleOptions) => ModuleSetupReturn;
659
570
  }
660
- type CustomRequestInit<Schema extends SilgiSchema = SilgiSchema, Route extends keyof Schema = keyof Schema, Method extends keyof Schema[Route] = keyof Schema[Route], _Resolved extends boolean = true, _HiddenParameters extends boolean = true> = Omit<RequestInit, 'body' | 'headers' | 'method'> & {
661
- method: Method;
662
- body?: Route extends keyof Schema ? Method extends keyof Schema[Route] ? Schema[Route][Method] extends {
663
- input?: infer I;
664
- } ? I extends StandardSchemaV1 ? StandardSchemaV1.InferInput<I> : unknown : unknown : unknown : unknown;
665
- headers?: Route extends keyof Schema ? Method extends keyof Schema[Route] ? Schema[Route][Method] extends {
666
- headers?: infer H;
667
- } ? H extends StandardSchemaV1 ? StandardSchemaV1.InferInput<H> : unknown : unknown : unknown : unknown;
668
- } & (Route extends keyof Schema ? Method extends keyof Schema[Route] ? Schema[Route][Method] extends {
669
- pathParams?: infer P;
670
- } ? P extends StandardSchemaV1 ? {
671
- pathParams: StandardSchemaV1.InferInput<P>;
672
- } : {
673
- pathParams?: unknown;
674
- } : {
675
- pathParams?: unknown;
676
- } : {
677
- pathParams?: unknown;
678
- } : {
679
- pathParams?: unknown;
680
- });
571
+ interface ModuleSetupInstallResult {
572
+ /**
573
+ * Timing information for the initial setup
574
+ */
575
+ timings?: {
576
+ /** Total time took for module setup in ms */
577
+ setup?: number;
578
+ [key: string]: number | undefined;
579
+ };
580
+ }
581
+ type ModuleSetupReturn = Awaitable<false | void | ModuleSetupInstallResult>;
582
+ interface SilgiModule<TOptions extends ModuleOptionsCustom = ModuleOptionsCustom, TOptionsDefaults extends Partial<TOptions> = Partial<TOptions>, TWith extends boolean = false> {
583
+ (this: void, resolvedOptions: TWith extends true ? ResolvedModuleOptions<TOptions, TOptionsDefaults> : TOptions, silgi: SilgiCLI): ModuleSetupReturn;
584
+ getOptions?: (inlineOptions?: Partial<TOptions>, silgi?: SilgiCLI) => Promise<TWith extends true ? ResolvedModuleOptions<TOptions, TOptionsDefaults> : TOptions>;
585
+ getMeta?: () => Promise<ModuleMeta>;
586
+ }
587
+
588
+ type TrimAfterFourSlashes<T extends string> = T extends `/${infer S1}/${infer S2}/${infer S3}/${infer S4}/${infer _}` ? `/${S1}/${S2}/${S3}/${S4}` : T;
589
+ type AllPaths = SilgiRouterTypes extends {
590
+ keys: infer U;
591
+ } ? keyof U extends never ? string : keyof U : string;
592
+ type ExtractPathParams<T extends string> = T extends `${infer _Start}:${infer Param}/${infer Rest}` ? {
593
+ [K in Param]: string;
594
+ } & ExtractPathParams<Rest> : T extends `${infer _Start}:${infer Param}` ? {
595
+ [K in Param]: string;
596
+ } : unknown;
597
+
598
+ type HttpMethod = 'get' | 'GET' | 'HEAD' | 'PATCH' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'head' | 'patch' | 'post' | 'put' | 'delete' | 'connect' | 'options' | 'trace';
599
+ type RouterParams<R extends AllPaths | (string & {})> = ExtractPathParams<R>;
600
+ type SilgiFetchOptions<P extends AllPaths | (string & {}), BasePath extends keyof SilgiRouterTypes = TrimAfterFourSlashes<P> extends keyof SilgiRouterTypes ? TrimAfterFourSlashes<P> : never, M extends keyof SilgiRouterTypes[BasePath] = keyof SilgiRouterTypes[BasePath]> = {
601
+ method?: M;
602
+ params?: ExtractPathParams<P>;
603
+ body?: SilgiRouterTypes[BasePath][M]['input'];
604
+ } & Omit<FetchOptions, 'method' | 'body' | 'params'>;
605
+ type SilgiFetchClient = <P extends AllPaths | (string & {}), BasePath extends keyof SilgiRouterTypes = TrimAfterFourSlashes<P> extends keyof SilgiRouterTypes ? TrimAfterFourSlashes<P> : never, M extends keyof SilgiRouterTypes[BasePath] = keyof SilgiRouterTypes[BasePath]>(url: BasePath, options?: SilgiFetchOptions<P, BasePath, M>) => Promise<FetchResponse<SilgiRouterTypes[BasePath][M]['output']>>;
681
606
 
682
607
  interface SilgiAppPlugin {
683
608
  (silgi: Silgi): Promise<void> | void;
@@ -743,151 +668,225 @@ interface SilgiOptions {
743
668
  [key: string]: any;
744
669
  }
745
670
 
746
- interface ExtendContext {
671
+ type StandardHTTPMethod = 'GET' | 'HEAD' | 'PATCH' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE';
672
+ type HTTPMethod = SilgiRuntimeMethods extends Record<string, any> ? keyof SilgiRuntimeMethods | StandardHTTPMethod : StandardHTTPMethod;
673
+ interface SilgiRoute {
674
+ route: string;
675
+ method?: HTTPMethod;
676
+ service: ServiceSetup;
677
+ schema: ResolvedSchemaDefinition;
747
678
  }
748
- interface SilgiRuntimeContext extends Record<string, any> {
749
- params?: Record<string, string>;
750
- /**
751
- * Matched router Node
752
- *
753
- * @experimental The object structure may change in non-major version.
754
- */
755
- matchedRoute?: SilgiRoute;
756
- sessions?: Record<string, Session>;
757
- clientAddress?: string;
758
- source?: any;
759
- silgi: {
760
- runtimeConfig?: SilgiRuntimeConfig;
679
+ interface Silgi {
680
+ router: RouterContext<SilgiRoute>;
681
+ routerPrefixs: string[];
682
+ schemas: ResolvedSchemaDefinition;
683
+ services: ResolvedServiceDefinition;
684
+ shared: SilgiRuntimeShareds;
685
+ plugins: SilgiAppPlugin[];
686
+ framework?: {
687
+ nitro?: NitroApp;
761
688
  };
762
- }
763
- /**
764
- * Bu nitrojs, h3 event or request context.
765
- */
766
- interface SilgiEvent extends Record<string, unknown> {
767
- /**
768
- * Event context.
769
- */
770
- readonly context: SilgiRuntimeContext;
771
- /**
772
- * Incoming HTTP request info.
773
- *
774
- * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Request)
775
- */
776
- readonly req: ServerRequest;
777
- /**
778
- * Access to the parsed request URL.
779
- *
780
- * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/URL)
781
- */
782
- readonly url: URL;
783
- /**
784
- * Prepared HTTP response.
785
- */
786
- readonly res: {
787
- status?: number;
788
- statusText?: string;
789
- readonly headers: Headers;
689
+ _ignore?: Ignore;
690
+ hooks: Hookable<SilgiRuntimeHooks & DefaultHooks>;
691
+ hook: Silgi['hooks']['hook'];
692
+ callHook: Silgi['hooks']['callHook'];
693
+ addHooks: Silgi['hooks']['addHooks'];
694
+ ready: () => Promise<void>;
695
+ close: () => Promise<void>;
696
+ logger: ConsolaInstance;
697
+ storage: Storage;
698
+ envOptions: EnvOptions;
699
+ options: SilgiOptions & SilgiRuntimeOptions;
700
+ captureError: CaptureError;
701
+ }
702
+ interface SilgiConfig extends Partial<Omit<Silgi, 'options'>>, Partial<SilgiRuntimeOptions> {
703
+ options: DeepPartial<SilgiOptions>;
704
+ }
705
+ interface BuildSilgi {
706
+ framework?: {
707
+ nitro?: NitroApp;
790
708
  };
709
+ modules?: Partial<SilgiRuntimeOptions>;
710
+ options?: Partial<SilgiOptions>;
791
711
  }
712
+ type CustomRequestInit<Schema extends SilgiSchema = SilgiSchema, Route extends keyof Schema = keyof Schema, Method extends keyof Schema[Route] = keyof Schema[Route], _Resolved extends boolean = true, _HiddenParameters extends boolean = true> = Omit<RequestInit, 'body' | 'headers' | 'method'> & {
713
+ method: Method;
714
+ body?: Route extends keyof Schema ? Method extends keyof Schema[Route] ? Schema[Route][Method] extends {
715
+ input?: infer I;
716
+ } ? I extends StandardSchemaV1 ? StandardSchemaV1.InferInput<I> : unknown : unknown : unknown : unknown;
717
+ headers?: Route extends keyof Schema ? Method extends keyof Schema[Route] ? Schema[Route][Method] extends {
718
+ headers?: infer H;
719
+ } ? H extends StandardSchemaV1 ? StandardSchemaV1.InferInput<H> : unknown : unknown : unknown : unknown;
720
+ } & (Route extends keyof Schema ? Method extends keyof Schema[Route] ? Schema[Route][Method] extends {
721
+ pathParams?: infer P;
722
+ } ? P extends StandardSchemaV1 ? {
723
+ pathParams: StandardSchemaV1.InferInput<P>;
724
+ } : {
725
+ pathParams?: unknown;
726
+ } : {
727
+ pathParams?: unknown;
728
+ } : {
729
+ pathParams?: unknown;
730
+ } : {
731
+ pathParams?: unknown;
732
+ });
792
733
 
793
- interface SilgiRuntimeActions {
734
+ interface SilgiCommands {
794
735
  }
795
- interface SilgiModuleOptions {
736
+ interface Commands {
737
+ name: string;
738
+ description?: string;
739
+ group: string;
740
+ when?: boolean;
741
+ type: 'function' | 'command';
742
+ tags?: (keyof SilgiCommands)[] | (string | object)[];
743
+ getContents: (data: {
744
+ app: SilgiCLI;
745
+ }) => string;
746
+ order?: number;
796
747
  }
797
- interface SilgiRuntimeOptions {
748
+ interface GenImport {
749
+ specifier: string;
750
+ imports: ESMImport | ESMImport[];
751
+ options?: ESMCodeGenOptions;
798
752
  }
799
- type SilgiModuleInput = (SilgiModule<any> | string | [SilgiModule | string, Record<string, any>] | undefined | null | false);
800
- interface SilgiCompatibility {
753
+ type Framework<T extends PresetName> = T extends 'nitro' ? nitropack_types.NitroApp : T extends 'nuxt' ? nitropack_types.NitroApp : T extends 'h3' ? h3.Router : T extends 'next' ? next.NextApiHandler : never;
754
+ interface DefineFrameworkOptions<T extends PresetName> extends Omit<BuildSilgi, 'framework'> {
755
+ framework: Framework<T>;
756
+ }
757
+
758
+ interface SilgiCLIHooks extends SilgiHooks {
801
759
  /**
802
- * Required silgi version in semver format.
803
- * @example `^3.2.0` or `>=3.13.0`.
760
+ * Called after Silgi initialization, when the Silgi instance is ready to work.
761
+ * @param silgi The configured Silgi object
762
+ * @returns Promise
804
763
  */
805
- silgi?: string;
806
- }
807
- interface ModuleMeta {
808
- /** Module name. */
809
- name?: string;
810
- /** Module description. */
811
- description?: string;
812
- /** Module author. */
813
- author?: string;
814
- /** Module license. */
815
- license?: string;
816
- /** Module version. */
817
- version?: string;
764
+ 'ready': (silgi: SilgiCLI) => HookResult;
818
765
  /**
819
- * The configuration key used within `silgi.config` for this module's options.
820
- * For example, `@silgijs/axios` uses `axios`.
766
+ * Called when silgi instance is gracefully closing.
767
+ * @param silgi The configured silgi object
768
+ * @returns Promise
821
769
  */
822
- configKey?: string;
770
+ 'close': (silgi: SilgiCLI) => HookResult;
771
+ 'reload:scan': (path: string, stats?: Stats) => HookResult;
823
772
  /**
824
- * Constraints for the versions of silgi or features this module requires.
773
+ * Allows extending compatibility checks.
774
+ * @param compatibility Compatibility object
775
+ * @param issues Issues to be mapped
776
+ * @returns Promise
825
777
  */
826
- compatibility?: SilgiCompatibility;
778
+ 'kit:compatibility': (compatibility: SilgiCompatibility, issues: SilgiCompatibilityIssues) => HookResult;
827
779
  /**
828
- * @private
780
+ * Called before Nuxi writes `.nuxt/tsconfig.json` and `.nuxt/nuxt.d.ts`, allowing addition of custom references and declarations in `nuxt.d.ts`, or directly modifying the options in `tsconfig.json`
781
+ * @param options Objects containing `references`, `declarations`, `tsConfig`
782
+ * @returns Promise
829
783
  */
830
- _modules?: {
831
- [key: string]: string;
832
- };
784
+ 'prepare:types': (options: {
785
+ references: TSReference[];
786
+ declarations: string[];
787
+ tsConfig: TSConfig;
788
+ }) => HookResult;
789
+ 'before:core.ts': (data: {
790
+ silgiConfigs: Record<string, any>[];
791
+ addImportItem: (data: GenImport | GenImport[]) => void;
792
+ addImportItemType: (data: GenImport | GenImport[]) => void;
793
+ addBuildFunction: (data: {
794
+ name: string;
795
+ params?: string[];
796
+ custom?: string;
797
+ where: 'before' | 'after';
798
+ }[] | {
799
+ name: string;
800
+ params?: string[];
801
+ custom?: string;
802
+ where: 'before' | 'after';
803
+ }) => void;
804
+ }) => HookResult;
805
+ 'after:core.ts': (content: string[]) => HookResult;
806
+ 'before:scan.ts': (data: {
807
+ services: string[];
808
+ shareds: string[];
809
+ routers: string[];
810
+ schemas: string[];
811
+ addImportItem: (data: GenImport | GenImport[]) => void;
812
+ addImportItemType: (data: GenImport | GenImport[]) => void;
813
+ }) => HookResult;
814
+ 'after:scan.ts': (content: string[]) => HookResult;
815
+ 'before:schema.ts': (options: {
816
+ addImportItem: (data: GenImport | GenImport[]) => void;
817
+ addImportItemType: (data: GenImport | GenImport[]) => void;
818
+ options: {
819
+ key: string;
820
+ value: string;
821
+ }[];
822
+ runtimeOptions: {
823
+ key: string;
824
+ value: string;
825
+ }[];
826
+ methods: {
827
+ key: string;
828
+ value: string;
829
+ }[];
830
+ contexts: {
831
+ key: string;
832
+ value: string;
833
+ }[];
834
+ actions: {
835
+ key: string;
836
+ value: string;
837
+ }[];
838
+ shareds: {
839
+ key: string;
840
+ value: string;
841
+ }[];
842
+ events: {
843
+ key: string;
844
+ value: string;
845
+ /**
846
+ * If extends is true, it won't be added to the key value interface.
847
+ * interface SilgiModuleEventsExtends extends SilgiEvent {}
848
+ */
849
+ extends?: boolean;
850
+ isSilgiContext?: boolean;
851
+ }[];
852
+ hooks: {
853
+ key: string;
854
+ value: string;
855
+ }[];
856
+ runtimeHooks: {
857
+ key: string;
858
+ value: string;
859
+ }[];
860
+ }) => HookResult;
861
+ 'after:schema.ts': (content: string[]) => HookResult;
862
+ 'prepare:configs.ts': (cliOptions: Record<string, any>) => HookResult;
833
863
  /**
834
- * @private
864
+ * Called during `SilgiCLI` generation, to allow customizing, modifying or adding new files to the build directory (either virtually or to written to `.nuxt`).
865
+ * @param app The configured `SilgiCLI` object
866
+ * @returns Promise
835
867
  */
836
- _packageName?: string;
837
- cliToRuntimeOptionsKeys?: string[];
838
- readonly afterDependencies?: ReadonlyArray<string>;
839
- readonly beforeDependencies?: ReadonlyArray<string>;
840
- readonly requiredDependencies?: ReadonlyArray<string>;
841
- [key: string]: unknown;
842
- }
843
- interface ResolvedModuleMeta extends ModuleMeta {
844
- configKey: string;
845
- name: string;
846
- }
847
- type ModuleHookContext = Readonly<{
848
- event?: SilgiEvent;
849
- url: SilgiURL;
850
- input?: unknown;
851
- result?: unknown;
852
- route?: SilgiRoute;
853
- error?: Error;
854
- success?: boolean;
855
- cached?: boolean;
856
- }> & {
857
- hookContext?: {
858
- earlyReturnValue: any | false;
859
- };
860
- };
861
- /** The options received. */
862
- type ModuleOptionsCustom = Record<string, any>;
863
- type Prettify<T> = {
864
- [K in keyof T]: T[K];
865
- } & {};
866
- type ResolvedModuleOptions<TOptions extends ModuleOptionsCustom, TOptionsDefaults extends Partial<TOptions>> = Prettify<Defu<Partial<TOptions>, [
867
- Partial<TOptions>,
868
- TOptionsDefaults
869
- ]>>;
870
- interface ModuleDefinition<TOptions extends ModuleOptionsCustom, TOptionsDefaults extends Partial<TOptions>, TWith extends boolean> {
871
- meta?: ModuleMeta;
872
- defaults?: TOptionsDefaults | ((silgi: SilgiCLI) => Awaitable<TOptionsDefaults>);
873
- hooks?: Partial<SilgiCLIHooks>;
874
- setup?: (this: void, resolvedOptions: TWith extends true ? ResolvedModuleOptions<TOptions, TOptionsDefaults> : TOptions, silgi: SilgiCLI & SilgiModuleOptions) => ModuleSetupReturn;
875
- }
876
- interface ModuleSetupInstallResult {
868
+ 'app:templates': (app: SilgiCLI) => HookResult;
877
869
  /**
878
- * Timing information for the initial setup
870
+ * Called after templates are compiled into the [virtual file system](https://nuxt.com/docs/guide/directory-structure/nuxt#virtual-file-system) (vfs).
871
+ * @param app The configured `SilgiCLI` object
872
+ * @returns Promise
879
873
  */
880
- timings?: {
881
- /** Total time took for module setup in ms */
882
- setup?: number;
883
- [key: string]: number | undefined;
884
- };
874
+ 'app:templatesGenerated': (app: SilgiCLI, templates: ResolvedSilgiTemplate[], options?: GenerateAppOptions) => HookResult;
875
+ 'scanFiles:done': (app: SilgiCLI) => HookResult;
876
+ 'prepare:commands': (commands: Commands[]) => HookResult;
877
+ 'nextjs:prepare': (data: {
878
+ config: NextConfig;
879
+ }) => HookResult;
885
880
  }
886
- type ModuleSetupReturn = Awaitable<false | void | ModuleSetupInstallResult>;
887
- interface SilgiModule<TOptions extends ModuleOptionsCustom = ModuleOptionsCustom, TOptionsDefaults extends Partial<TOptions> = Partial<TOptions>, TWith extends boolean = false> {
888
- (this: void, resolvedOptions: TWith extends true ? ResolvedModuleOptions<TOptions, TOptionsDefaults> : TOptions, silgi: SilgiCLI): ModuleSetupReturn;
889
- getOptions?: (inlineOptions?: Partial<TOptions>, silgi?: SilgiCLI) => Promise<TWith extends true ? ResolvedModuleOptions<TOptions, TOptionsDefaults> : TOptions>;
890
- getMeta?: () => Promise<ModuleMeta>;
881
+ type TSReference = {
882
+ types: string;
883
+ } | {
884
+ path: string;
885
+ };
886
+ interface SilgiHooks {
887
+ }
888
+ interface GenerateAppOptions {
889
+ filter?: (template: ResolvedSilgiTemplate<any>) => boolean;
891
890
  }
892
891
 
893
892
  type SilgiPreset = (SilgiCLIConfig & {
@@ -915,14 +914,14 @@ interface SilgiCLIOptions extends PresetOptions {
915
914
  command?: string;
916
915
  };
917
916
  commandType: CommandType;
918
- commands: Commands$1[];
917
+ commands: Commands[];
919
918
  schemaVendor: Schema | Schema[];
920
919
  environments: DotenvOptions$1[];
921
920
  activeEnvironment: 'prod' | 'docker' | 'staging' | 'testing' | '.env' | (string & {});
922
- envOptions: EnvOptions$1;
923
- runtimeConfig: SilgiRuntimeConfig$1;
921
+ envOptions: EnvOptions;
922
+ runtimeConfig: SilgiRuntimeConfig;
924
923
  storages: string[];
925
- hooks: NestedHooks<SilgiCLIHooks$1>;
924
+ hooks: NestedHooks<SilgiCLIHooks>;
926
925
  plugins: {
927
926
  path: string;
928
927
  packageImport: string;
@@ -946,8 +945,8 @@ interface SilgiCLIOptions extends PresetOptions {
946
945
  safeList: string[][];
947
946
  };
948
947
  };
949
- storage: StorageMounts$1;
950
- devStorage: StorageMounts$1;
948
+ storage: StorageMounts;
949
+ devStorage: StorageMounts;
951
950
  workspaceDir: string;
952
951
  rootDir: string;
953
952
  srcDir: string;
@@ -970,7 +969,7 @@ interface SilgiCLIOptions extends PresetOptions {
970
969
  * ]
971
970
  * ```
972
971
  */
973
- templates: SilgiTemplate$1<any>[];
972
+ templates: SilgiTemplate<any>[];
974
973
  };
975
974
  modulesDir: string[];
976
975
  output: {
@@ -1009,7 +1008,7 @@ interface SilgiCLIOptions extends PresetOptions {
1009
1008
  devServer: {
1010
1009
  watch: string[];
1011
1010
  };
1012
- framework: SilgiFrameworkInfo$1;
1011
+ framework: SilgiFrameworkInfo;
1013
1012
  /**
1014
1013
  * More customizable than `ignorePrefix`: all files matching glob patterns specified inside the `ignore` array will be ignored in building.
1015
1014
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.37.38",
4
+ "version": "0.37.39",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {