silgi 0.37.37 → 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.
- package/dist/cli/build.mjs +7 -6
- package/dist/cli/index.mjs +1 -1
- package/dist/core/index.d.mts +1 -16
- package/dist/core/index.mjs +4 -8
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/runtime/index.d.mts +1 -1
- package/dist/runtime/index.mjs +1 -1
- package/dist/runtime/internal/config.d.mts +1 -1
- package/dist/runtime/internal/config.mjs +1 -1
- package/dist/types/index.d.mts +505 -520
- package/package.json +1 -1
package/dist/types/index.d.mts
CHANGED
|
@@ -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,26 +7,24 @@ 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 * as h3 from 'h3';
|
|
14
|
-
import { HTTPMethod as HTTPMethod$1, Session, H3Event } from 'h3';
|
|
15
|
-
import * as nitropack_types from 'nitropack/types';
|
|
16
|
-
import { NitroRuntimeConfig } from 'nitropack/types';
|
|
17
|
-
import { Defu } from 'defu';
|
|
18
12
|
import * as next from 'next';
|
|
19
13
|
import { NextConfig } from 'next';
|
|
20
14
|
import { Stats } from 'node:fs';
|
|
15
|
+
import * as h3 from 'h3';
|
|
16
|
+
import { Session, HTTPMethod as HTTPMethod$1 } from 'h3';
|
|
17
|
+
import * as nitropack_types from 'nitropack/types';
|
|
21
18
|
import { ESMImport, ESMCodeGenOptions } from 'knitwork';
|
|
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';
|
|
29
|
-
import {
|
|
26
|
+
import { useRuntimeConfig } from 'silgi/runtime';
|
|
27
|
+
import { Unimport } from 'unimport';
|
|
30
28
|
import { ProviderName } from 'std-env';
|
|
31
29
|
import { FetchOptions, FetchResponse } from 'ofetch';
|
|
32
30
|
|
|
@@ -69,278 +67,68 @@ type DeepMerge<A, B> = {
|
|
|
69
67
|
*/
|
|
70
68
|
type MergeAll<T extends readonly any[]> = T extends [infer First, ...infer Rest] ? Rest extends [] ? First : DeepMerge<First, MergeAll<Rest>> : object;
|
|
71
69
|
|
|
72
|
-
interface
|
|
73
|
-
_ignore?: Ignore;
|
|
74
|
-
errors: {
|
|
75
|
-
type: 'Parser';
|
|
76
|
-
path?: string;
|
|
77
|
-
}[];
|
|
78
|
-
services: ResolvedServiceDefinition$1;
|
|
79
|
-
shareds: SilgiRuntimeShareds$1;
|
|
80
|
-
schemas: Record<string, any>;
|
|
81
|
-
scannedURIs: Map<string, string>;
|
|
82
|
-
templates: SilgiTemplate[];
|
|
83
|
-
hooks: Hookable<SilgiCLIHooks>;
|
|
84
|
-
hook: SilgiCLI['hooks']['hook'];
|
|
85
|
-
callHook: SilgiCLI['hooks']['callHook'];
|
|
86
|
-
addHooks: SilgiCLI['hooks']['addHooks'];
|
|
87
|
-
storage: Storage;
|
|
88
|
-
unimport?: Unimport;
|
|
89
|
-
logger: ConsolaInstance;
|
|
90
|
-
close: () => Promise<void>;
|
|
91
|
-
updateConfig: (config: SilgiCLIDynamicConfig) => void | Promise<void>;
|
|
92
|
-
scanModules: Array<{
|
|
93
|
-
meta: ModuleMeta$1;
|
|
94
|
-
module: SilgiModule$1;
|
|
95
|
-
timings?: Record<string, number | undefined>;
|
|
96
|
-
entryPath?: string;
|
|
97
|
-
installed?: boolean;
|
|
98
|
-
options: Record<string, any>;
|
|
99
|
-
}>;
|
|
100
|
-
options: SilgiCLIOptions;
|
|
101
|
-
_requiredModules: Record<string, boolean>;
|
|
102
|
-
adapters: Record<string, Adapter<Record<string, any>, TablesSchema, InferModelTypes<TablesSchema>>>;
|
|
103
|
-
}
|
|
104
|
-
type SilgiCLIDynamicConfig = Pick<SilgiCLIConfig, 'routeRules'>;
|
|
105
|
-
interface SilgiFrameworkInfo {
|
|
106
|
-
name?: 'silgi' | (string & {});
|
|
107
|
-
version?: string;
|
|
108
|
-
}
|
|
109
|
-
/** Build info written to `.output/silgi.json` or `.silgi/dev/silgi.json` */
|
|
110
|
-
interface NitroBuildInfo {
|
|
111
|
-
date: string;
|
|
112
|
-
preset: PresetName;
|
|
113
|
-
framework: SilgiFrameworkInfo;
|
|
114
|
-
versions: {
|
|
115
|
-
silgi: string;
|
|
116
|
-
[key: string]: string;
|
|
117
|
-
};
|
|
118
|
-
commands?: {
|
|
119
|
-
preview?: string;
|
|
120
|
-
deploy?: string;
|
|
121
|
-
};
|
|
122
|
-
dev?: {
|
|
123
|
-
pid: number;
|
|
124
|
-
workerAddress: {
|
|
125
|
-
host: string;
|
|
126
|
-
port: number;
|
|
127
|
-
socketPath?: string;
|
|
128
|
-
};
|
|
129
|
-
};
|
|
130
|
-
config?: Partial<PresetOptions>;
|
|
131
|
-
}
|
|
132
|
-
interface ScanFile {
|
|
133
|
-
context: string;
|
|
134
|
-
object: {
|
|
135
|
-
schemas: any;
|
|
136
|
-
services: any;
|
|
137
|
-
shareds: any;
|
|
138
|
-
};
|
|
139
|
-
path: string;
|
|
70
|
+
interface SilgiRuntimeMethods {
|
|
140
71
|
}
|
|
141
|
-
type
|
|
142
|
-
interface
|
|
143
|
-
/** resolved output file path (generated) */
|
|
144
|
-
dst?: string;
|
|
145
|
-
/** The target filename once the template is copied into the Silgi buildDir */
|
|
146
|
-
filename?: string;
|
|
147
|
-
/** An options object that will be accessible within the template via `<% options %>` */
|
|
148
|
-
options?: Options;
|
|
149
|
-
/** The resolved path to the source file to be template */
|
|
150
|
-
src?: string;
|
|
151
|
-
/** Provided compile option instead of src */
|
|
152
|
-
where?: 'server' | 'client' | '.silgi';
|
|
153
|
-
getContents?: (data: {
|
|
154
|
-
app: SilgiCLI;
|
|
155
|
-
options: Options;
|
|
156
|
-
}) => string | Promise<string>;
|
|
157
|
-
/** Write to filesystem */
|
|
158
|
-
write?: boolean;
|
|
159
|
-
skipIfExists?: boolean;
|
|
72
|
+
type CommandType = 'run' | 'prepare' | 'install' | 'dev' | 'init';
|
|
73
|
+
interface SilgiRouterTypes {
|
|
160
74
|
}
|
|
161
|
-
interface
|
|
162
|
-
filename: string;
|
|
163
|
-
dst: string;
|
|
164
|
-
modified?: boolean;
|
|
75
|
+
interface DefaultHooks {
|
|
165
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>;
|
|
166
84
|
|
|
167
|
-
interface
|
|
168
|
-
}
|
|
169
|
-
interface Commands {
|
|
170
|
-
name: string;
|
|
171
|
-
description?: string;
|
|
172
|
-
group: string;
|
|
173
|
-
when?: boolean;
|
|
174
|
-
type: 'function' | 'command';
|
|
175
|
-
tags?: (keyof SilgiCommands)[] | (string | object)[];
|
|
176
|
-
getContents: (data: {
|
|
177
|
-
app: SilgiCLI;
|
|
178
|
-
}) => string;
|
|
179
|
-
order?: number;
|
|
180
|
-
}
|
|
181
|
-
interface GenImport {
|
|
182
|
-
specifier: string;
|
|
183
|
-
imports: ESMImport | ESMImport[];
|
|
184
|
-
options?: ESMCodeGenOptions;
|
|
185
|
-
}
|
|
186
|
-
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;
|
|
187
|
-
interface DefineFrameworkOptions<T extends PresetName> extends Omit<BuildSilgi$1, 'framework'> {
|
|
188
|
-
framework: Framework<T>;
|
|
85
|
+
interface ExtendContext {
|
|
189
86
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Called after Silgi initialization, when the Silgi instance is ready to work.
|
|
194
|
-
* @param silgi The configured Silgi object
|
|
195
|
-
* @returns Promise
|
|
196
|
-
*/
|
|
197
|
-
'ready': (silgi: SilgiCLI) => HookResult;
|
|
87
|
+
interface SilgiRuntimeContext extends Record<string, any> {
|
|
88
|
+
params?: Record<string, string>;
|
|
198
89
|
/**
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
* @
|
|
90
|
+
* Matched router Node
|
|
91
|
+
*
|
|
92
|
+
* @experimental The object structure may change in non-major version.
|
|
202
93
|
*/
|
|
203
|
-
|
|
204
|
-
|
|
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> {
|
|
205
106
|
/**
|
|
206
|
-
*
|
|
207
|
-
* @param compatibility Compatibility object
|
|
208
|
-
* @param issues Issues to be mapped
|
|
209
|
-
* @returns Promise
|
|
107
|
+
* Event context.
|
|
210
108
|
*/
|
|
211
|
-
|
|
109
|
+
readonly context: SilgiRuntimeContext;
|
|
212
110
|
/**
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
111
|
+
* Incoming HTTP request info.
|
|
112
|
+
*
|
|
113
|
+
* [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
216
114
|
*/
|
|
217
|
-
|
|
218
|
-
references: TSReference[];
|
|
219
|
-
declarations: string[];
|
|
220
|
-
tsConfig: TSConfig;
|
|
221
|
-
}) => HookResult;
|
|
222
|
-
'before:core.ts': (data: {
|
|
223
|
-
silgiConfigs: Record<string, any>[];
|
|
224
|
-
addImportItem: (data: GenImport | GenImport[]) => void;
|
|
225
|
-
addImportItemType: (data: GenImport | GenImport[]) => void;
|
|
226
|
-
addBuildFunction: (data: {
|
|
227
|
-
name: string;
|
|
228
|
-
params?: string[];
|
|
229
|
-
custom?: string;
|
|
230
|
-
where: 'before' | 'after';
|
|
231
|
-
}[] | {
|
|
232
|
-
name: string;
|
|
233
|
-
params?: string[];
|
|
234
|
-
custom?: string;
|
|
235
|
-
where: 'before' | 'after';
|
|
236
|
-
}) => void;
|
|
237
|
-
}) => HookResult;
|
|
238
|
-
'after:core.ts': (content: string[]) => HookResult;
|
|
239
|
-
'before:scan.ts': (data: {
|
|
240
|
-
services: string[];
|
|
241
|
-
shareds: string[];
|
|
242
|
-
routers: string[];
|
|
243
|
-
schemas: string[];
|
|
244
|
-
addImportItem: (data: GenImport | GenImport[]) => void;
|
|
245
|
-
addImportItemType: (data: GenImport | GenImport[]) => void;
|
|
246
|
-
}) => HookResult;
|
|
247
|
-
'after:scan.ts': (content: string[]) => HookResult;
|
|
248
|
-
'before:schema.ts': (options: {
|
|
249
|
-
addImportItem: (data: GenImport | GenImport[]) => void;
|
|
250
|
-
addImportItemType: (data: GenImport | GenImport[]) => void;
|
|
251
|
-
options: {
|
|
252
|
-
key: string;
|
|
253
|
-
value: string;
|
|
254
|
-
}[];
|
|
255
|
-
runtimeOptions: {
|
|
256
|
-
key: string;
|
|
257
|
-
value: string;
|
|
258
|
-
}[];
|
|
259
|
-
methods: {
|
|
260
|
-
key: string;
|
|
261
|
-
value: string;
|
|
262
|
-
}[];
|
|
263
|
-
contexts: {
|
|
264
|
-
key: string;
|
|
265
|
-
value: string;
|
|
266
|
-
}[];
|
|
267
|
-
actions: {
|
|
268
|
-
key: string;
|
|
269
|
-
value: string;
|
|
270
|
-
}[];
|
|
271
|
-
shareds: {
|
|
272
|
-
key: string;
|
|
273
|
-
value: string;
|
|
274
|
-
}[];
|
|
275
|
-
events: {
|
|
276
|
-
key: string;
|
|
277
|
-
value: string;
|
|
278
|
-
/**
|
|
279
|
-
* If extends is true, it won't be added to the key value interface.
|
|
280
|
-
* interface SilgiModuleEventsExtends extends SilgiEvent {}
|
|
281
|
-
*/
|
|
282
|
-
extends?: boolean;
|
|
283
|
-
isSilgiContext?: boolean;
|
|
284
|
-
}[];
|
|
285
|
-
hooks: {
|
|
286
|
-
key: string;
|
|
287
|
-
value: string;
|
|
288
|
-
}[];
|
|
289
|
-
runtimeHooks: {
|
|
290
|
-
key: string;
|
|
291
|
-
value: string;
|
|
292
|
-
}[];
|
|
293
|
-
}) => HookResult;
|
|
294
|
-
'after:schema.ts': (content: string[]) => HookResult;
|
|
295
|
-
'prepare:configs.ts': (cliOptions: Record<string, any>) => HookResult;
|
|
115
|
+
readonly req: ServerRequest;
|
|
296
116
|
/**
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
117
|
+
* Access to the parsed request URL.
|
|
118
|
+
*
|
|
119
|
+
* [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/URL)
|
|
300
120
|
*/
|
|
301
|
-
|
|
121
|
+
readonly url: URL;
|
|
302
122
|
/**
|
|
303
|
-
*
|
|
304
|
-
* @param app The configured `SilgiCLI` object
|
|
305
|
-
* @returns Promise
|
|
123
|
+
* Prepared HTTP response.
|
|
306
124
|
*/
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}) => HookResult;
|
|
313
|
-
}
|
|
314
|
-
type TSReference = {
|
|
315
|
-
types: string;
|
|
316
|
-
} | {
|
|
317
|
-
path: string;
|
|
318
|
-
};
|
|
319
|
-
interface SilgiHooks {
|
|
320
|
-
}
|
|
321
|
-
interface GenerateAppOptions {
|
|
322
|
-
filter?: (template: ResolvedSilgiTemplate<any>) => boolean;
|
|
125
|
+
readonly res: {
|
|
126
|
+
status?: number;
|
|
127
|
+
statusText?: string;
|
|
128
|
+
readonly headers: Headers;
|
|
129
|
+
};
|
|
323
130
|
}
|
|
324
131
|
|
|
325
|
-
type TrimAfterFourSlashes<T extends string> = T extends `/${infer S1}/${infer S2}/${infer S3}/${infer S4}/${infer _}` ? `/${S1}/${S2}/${S3}/${S4}` : T;
|
|
326
|
-
type AllPaths = SilgiRouterTypes extends {
|
|
327
|
-
keys: infer U;
|
|
328
|
-
} ? keyof U extends never ? string : keyof U : string;
|
|
329
|
-
type ExtractPathParams<T extends string> = T extends `${infer _Start}:${infer Param}/${infer Rest}` ? {
|
|
330
|
-
[K in Param]: string;
|
|
331
|
-
} & ExtractPathParams<Rest> : T extends `${infer _Start}:${infer Param}` ? {
|
|
332
|
-
[K in Param]: string;
|
|
333
|
-
} : unknown;
|
|
334
|
-
|
|
335
|
-
type HttpMethod = 'get' | 'GET' | 'HEAD' | 'PATCH' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'head' | 'patch' | 'post' | 'put' | 'delete' | 'connect' | 'options' | 'trace';
|
|
336
|
-
type RouterParams<R extends AllPaths | (string & {})> = ExtractPathParams<R>;
|
|
337
|
-
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]> = {
|
|
338
|
-
method?: M;
|
|
339
|
-
params?: ExtractPathParams<P>;
|
|
340
|
-
body?: SilgiRouterTypes[BasePath][M]['input'];
|
|
341
|
-
} & Omit<FetchOptions, 'method' | 'body' | 'params'>;
|
|
342
|
-
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']>>;
|
|
343
|
-
|
|
344
132
|
/**
|
|
345
133
|
* Main interface containing all route definitions.
|
|
346
134
|
* Example:
|
|
@@ -480,7 +268,44 @@ interface ResolvedSchemaDefinition {
|
|
|
480
268
|
};
|
|
481
269
|
}
|
|
482
270
|
|
|
483
|
-
type
|
|
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> = {
|
|
484
309
|
[M in keyof Schema[Path]]?: ServiceSetup<Schema, Path, M, Resolved, HiddenParameters>;
|
|
485
310
|
};
|
|
486
311
|
/**
|
|
@@ -506,17 +331,17 @@ type ServiceHandlerParameters<S, R extends keyof S, M extends keyof S[R]> = S[R]
|
|
|
506
331
|
/**
|
|
507
332
|
* Route ve method'a göre input, output, params çıkarımı
|
|
508
333
|
*/
|
|
509
|
-
type ServiceHandlerInput<Schema extends SilgiSchema
|
|
334
|
+
type ServiceHandlerInput<Schema extends SilgiSchema, Route extends keyof Schema, Method extends keyof Schema[Route], HiddenParameters extends boolean = false> = (Schema[Route][Method] extends {
|
|
510
335
|
input?: infer I;
|
|
511
336
|
} ? {
|
|
512
337
|
args: InferInput<I>;
|
|
513
338
|
} : unknown) & (HiddenParameters extends false ? (keyof ServiceHandlerParameters<Schema, Route, Method> extends never ? unknown : {
|
|
514
339
|
parameters: ServiceHandlerParameters<Schema, Route, Method>;
|
|
515
340
|
}) : unknown);
|
|
516
|
-
type ServiceHandlerOutput<Schema extends SilgiSchema
|
|
341
|
+
type ServiceHandlerOutput<Schema extends SilgiSchema, Route extends keyof Schema, Method extends keyof Schema[Route]> = Schema[Route][Method] extends {
|
|
517
342
|
output?: infer O;
|
|
518
343
|
} ? InferOutput<O> : unknown;
|
|
519
|
-
type ServiceHandlerSource<Schema extends SilgiSchema
|
|
344
|
+
type ServiceHandlerSource<Schema extends SilgiSchema, Route extends keyof Schema, Method extends keyof Schema[Route]> = Schema[Route][Method] extends {
|
|
520
345
|
source?: infer S;
|
|
521
346
|
} ? InferInput<S> : unknown;
|
|
522
347
|
/**
|
|
@@ -525,15 +350,15 @@ type ServiceHandlerSource<Schema extends SilgiSchema$1, Route extends keyof Sche
|
|
|
525
350
|
* Resolved = false -> handler(input, shared, event, source) // all required
|
|
526
351
|
* Resolved = true -> handler(input, shared?, event?, source?) // only input required
|
|
527
352
|
*/
|
|
528
|
-
type ServiceHandler<Schema extends SilgiSchema
|
|
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>>;
|
|
529
354
|
/**
|
|
530
355
|
* Servis setup tipi
|
|
531
356
|
*/
|
|
532
|
-
interface ServiceSetup<Schema extends SilgiSchema
|
|
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> {
|
|
533
358
|
handler: ServiceHandler<Schema, Route, Method, Resolved, HiddenParameters>;
|
|
534
|
-
routerRule?: RouteConfigService
|
|
535
|
-
modules?: Partial<SilgiRuntimeActions
|
|
536
|
-
storage?: StorageConfig
|
|
359
|
+
routerRule?: RouteConfigService;
|
|
360
|
+
modules?: Partial<SilgiRuntimeActions>;
|
|
361
|
+
storage?: StorageConfig<ServiceHandlerInput<Schema, Route, Method, HiddenParameters>>;
|
|
537
362
|
}
|
|
538
363
|
/**
|
|
539
364
|
* Represents a fully resolved service definition that maps route paths
|
|
@@ -546,8 +371,8 @@ interface ResolvedServiceDefinition {
|
|
|
546
371
|
[routePath: string]: {
|
|
547
372
|
[method: string]: {
|
|
548
373
|
handler: (...args: any[]) => Promise<any>;
|
|
549
|
-
modules?: Partial<SilgiRuntimeActions
|
|
550
|
-
storage?: StorageConfig
|
|
374
|
+
modules?: Partial<SilgiRuntimeActions>;
|
|
375
|
+
storage?: StorageConfig<any>;
|
|
551
376
|
};
|
|
552
377
|
};
|
|
553
378
|
}
|
|
@@ -564,105 +389,220 @@ interface SilgiURL {
|
|
|
564
389
|
queryParams?: Record<string, string>;
|
|
565
390
|
}
|
|
566
391
|
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
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;
|
|
574
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>;
|
|
575
452
|
}
|
|
576
|
-
interface
|
|
453
|
+
interface ScanFile {
|
|
454
|
+
context: string;
|
|
455
|
+
object: {
|
|
456
|
+
schemas: any;
|
|
457
|
+
services: any;
|
|
458
|
+
shareds: any;
|
|
459
|
+
};
|
|
460
|
+
path: string;
|
|
577
461
|
}
|
|
578
|
-
type
|
|
579
|
-
interface
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
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;
|
|
584
481
|
}
|
|
585
|
-
interface
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
keyGenerator?: StorageKeyGenerator<TInput>;
|
|
590
|
-
storageOptions?: Pick<StorageConfig<TInput>, 'base' | 'options' | 'scope'>;
|
|
482
|
+
interface ResolvedSilgiTemplate<Options = TemplateDefaultOptions> extends SilgiTemplate<Options> {
|
|
483
|
+
filename: string;
|
|
484
|
+
dst: string;
|
|
485
|
+
modified?: boolean;
|
|
591
486
|
}
|
|
592
487
|
|
|
593
|
-
interface
|
|
594
|
-
storage: <T extends StorageValue = StorageValue>(base: StorageConfig<T>['base']) => Storage<T>;
|
|
595
|
-
useRuntimeConfig: typeof useSilgiRuntimeConfig;
|
|
596
|
-
$fetch: typeof silgiFetch;
|
|
597
|
-
silgi: Silgi;
|
|
488
|
+
interface SilgiRuntimeActions {
|
|
598
489
|
}
|
|
599
|
-
interface
|
|
490
|
+
interface SilgiModuleOptions {
|
|
600
491
|
}
|
|
601
|
-
interface
|
|
492
|
+
interface SilgiRuntimeOptions {
|
|
602
493
|
}
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
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;
|
|
611
501
|
}
|
|
612
|
-
interface
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
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;
|
|
621
527
|
};
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
envOptions: EnvOptions;
|
|
632
|
-
options: SilgiOptions & SilgiRuntimeOptions;
|
|
633
|
-
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;
|
|
634
537
|
}
|
|
635
|
-
interface
|
|
636
|
-
|
|
538
|
+
interface ResolvedModuleMeta extends ModuleMeta {
|
|
539
|
+
configKey: string;
|
|
540
|
+
name: string;
|
|
637
541
|
}
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
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;
|
|
641
554
|
};
|
|
642
|
-
|
|
643
|
-
|
|
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;
|
|
644
570
|
}
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
}
|
|
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']>>;
|
|
666
606
|
|
|
667
607
|
interface SilgiAppPlugin {
|
|
668
608
|
(silgi: Silgi): Promise<void> | void;
|
|
@@ -728,180 +668,225 @@ interface SilgiOptions {
|
|
|
728
668
|
[key: string]: any;
|
|
729
669
|
}
|
|
730
670
|
|
|
731
|
-
|
|
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;
|
|
732
678
|
}
|
|
733
|
-
interface
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
clientAddress?: string;
|
|
743
|
-
source?: any;
|
|
744
|
-
silgi: {
|
|
745
|
-
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;
|
|
746
688
|
};
|
|
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;
|
|
747
701
|
}
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
interface
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
*/
|
|
755
|
-
readonly context: SilgiRuntimeContext;
|
|
756
|
-
/**
|
|
757
|
-
* Incoming HTTP request info.
|
|
758
|
-
*
|
|
759
|
-
* [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
760
|
-
*/
|
|
761
|
-
readonly req: ServerRequest;
|
|
762
|
-
/**
|
|
763
|
-
* Access to the parsed request URL.
|
|
764
|
-
*
|
|
765
|
-
* [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/URL)
|
|
766
|
-
*/
|
|
767
|
-
readonly url: URL;
|
|
768
|
-
/**
|
|
769
|
-
* Prepared HTTP response.
|
|
770
|
-
*/
|
|
771
|
-
readonly res: {
|
|
772
|
-
status?: number;
|
|
773
|
-
statusText?: string;
|
|
774
|
-
readonly headers: Headers;
|
|
702
|
+
interface SilgiConfig extends Partial<Omit<Silgi, 'options'>>, Partial<SilgiRuntimeOptions> {
|
|
703
|
+
options: DeepPartial<SilgiOptions>;
|
|
704
|
+
}
|
|
705
|
+
interface BuildSilgi {
|
|
706
|
+
framework?: {
|
|
707
|
+
nitro?: NitroApp;
|
|
775
708
|
};
|
|
709
|
+
modules?: Partial<SilgiRuntimeOptions>;
|
|
710
|
+
options?: Partial<SilgiOptions>;
|
|
776
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
|
+
});
|
|
777
733
|
|
|
778
|
-
interface
|
|
734
|
+
interface SilgiCommands {
|
|
779
735
|
}
|
|
780
|
-
interface
|
|
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;
|
|
781
747
|
}
|
|
782
|
-
interface
|
|
748
|
+
interface GenImport {
|
|
749
|
+
specifier: string;
|
|
750
|
+
imports: ESMImport | ESMImport[];
|
|
751
|
+
options?: ESMCodeGenOptions;
|
|
783
752
|
}
|
|
784
|
-
type
|
|
785
|
-
interface
|
|
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 {
|
|
786
759
|
/**
|
|
787
|
-
*
|
|
788
|
-
* @
|
|
760
|
+
* Called after Silgi initialization, when the Silgi instance is ready to work.
|
|
761
|
+
* @param silgi The configured Silgi object
|
|
762
|
+
* @returns Promise
|
|
789
763
|
*/
|
|
790
|
-
silgi
|
|
791
|
-
}
|
|
792
|
-
interface ModuleMeta {
|
|
793
|
-
/** Module name. */
|
|
794
|
-
name?: string;
|
|
795
|
-
/** Module description. */
|
|
796
|
-
description?: string;
|
|
797
|
-
/** Module author. */
|
|
798
|
-
author?: string;
|
|
799
|
-
/** Module license. */
|
|
800
|
-
license?: string;
|
|
801
|
-
/** Module version. */
|
|
802
|
-
version?: string;
|
|
764
|
+
'ready': (silgi: SilgiCLI) => HookResult;
|
|
803
765
|
/**
|
|
804
|
-
*
|
|
805
|
-
*
|
|
766
|
+
* Called when silgi instance is gracefully closing.
|
|
767
|
+
* @param silgi The configured silgi object
|
|
768
|
+
* @returns Promise
|
|
806
769
|
*/
|
|
807
|
-
|
|
770
|
+
'close': (silgi: SilgiCLI) => HookResult;
|
|
771
|
+
'reload:scan': (path: string, stats?: Stats) => HookResult;
|
|
808
772
|
/**
|
|
809
|
-
*
|
|
773
|
+
* Allows extending compatibility checks.
|
|
774
|
+
* @param compatibility Compatibility object
|
|
775
|
+
* @param issues Issues to be mapped
|
|
776
|
+
* @returns Promise
|
|
810
777
|
*/
|
|
811
|
-
compatibility
|
|
778
|
+
'kit:compatibility': (compatibility: SilgiCompatibility, issues: SilgiCompatibilityIssues) => HookResult;
|
|
812
779
|
/**
|
|
813
|
-
*
|
|
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
|
|
814
783
|
*/
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
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;
|
|
818
863
|
/**
|
|
819
|
-
*
|
|
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
|
|
820
867
|
*/
|
|
821
|
-
|
|
822
|
-
cliToRuntimeOptionsKeys?: string[];
|
|
823
|
-
readonly afterDependencies?: ReadonlyArray<string>;
|
|
824
|
-
readonly beforeDependencies?: ReadonlyArray<string>;
|
|
825
|
-
readonly requiredDependencies?: ReadonlyArray<string>;
|
|
826
|
-
[key: string]: unknown;
|
|
827
|
-
}
|
|
828
|
-
interface ResolvedModuleMeta extends ModuleMeta {
|
|
829
|
-
configKey: string;
|
|
830
|
-
name: string;
|
|
831
|
-
}
|
|
832
|
-
type ModuleHookContext = Readonly<{
|
|
833
|
-
event?: SilgiEvent;
|
|
834
|
-
url: SilgiURL;
|
|
835
|
-
input?: unknown;
|
|
836
|
-
result?: unknown;
|
|
837
|
-
route?: SilgiRoute;
|
|
838
|
-
error?: Error;
|
|
839
|
-
success?: boolean;
|
|
840
|
-
cached?: boolean;
|
|
841
|
-
}> & {
|
|
842
|
-
hookContext?: {
|
|
843
|
-
earlyReturnValue: any | false;
|
|
844
|
-
};
|
|
845
|
-
};
|
|
846
|
-
/** The options received. */
|
|
847
|
-
type ModuleOptionsCustom = Record<string, any>;
|
|
848
|
-
type Prettify<T> = {
|
|
849
|
-
[K in keyof T]: T[K];
|
|
850
|
-
} & {};
|
|
851
|
-
type ResolvedModuleOptions<TOptions extends ModuleOptionsCustom, TOptionsDefaults extends Partial<TOptions>> = Prettify<Defu<Partial<TOptions>, [
|
|
852
|
-
Partial<TOptions>,
|
|
853
|
-
TOptionsDefaults
|
|
854
|
-
]>>;
|
|
855
|
-
interface ModuleDefinition<TOptions extends ModuleOptionsCustom, TOptionsDefaults extends Partial<TOptions>, TWith extends boolean> {
|
|
856
|
-
meta?: ModuleMeta;
|
|
857
|
-
defaults?: TOptionsDefaults | ((silgi: SilgiCLI) => Awaitable<TOptionsDefaults>);
|
|
858
|
-
hooks?: Partial<SilgiCLIHooks>;
|
|
859
|
-
setup?: (this: void, resolvedOptions: TWith extends true ? ResolvedModuleOptions<TOptions, TOptionsDefaults> : TOptions, silgi: SilgiCLI & SilgiModuleOptions) => ModuleSetupReturn;
|
|
860
|
-
}
|
|
861
|
-
interface ModuleSetupInstallResult {
|
|
868
|
+
'app:templates': (app: SilgiCLI) => HookResult;
|
|
862
869
|
/**
|
|
863
|
-
*
|
|
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
|
|
864
873
|
*/
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
}
|
|
871
|
-
type ModuleSetupReturn = Awaitable<false | void | ModuleSetupInstallResult>;
|
|
872
|
-
interface SilgiModule<TOptions extends ModuleOptionsCustom = ModuleOptionsCustom, TOptionsDefaults extends Partial<TOptions> = Partial<TOptions>, TWith extends boolean = false> {
|
|
873
|
-
(this: void, resolvedOptions: TWith extends true ? ResolvedModuleOptions<TOptions, TOptionsDefaults> : TOptions, silgi: SilgiCLI): ModuleSetupReturn;
|
|
874
|
-
getOptions?: (inlineOptions?: Partial<TOptions>, silgi?: SilgiCLI) => Promise<TWith extends true ? ResolvedModuleOptions<TOptions, TOptionsDefaults> : TOptions>;
|
|
875
|
-
getMeta?: () => Promise<ModuleMeta>;
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
interface SilgiRuntimeMethods {
|
|
879
|
-
}
|
|
880
|
-
type CommandType = 'run' | 'prepare' | 'install' | 'dev' | 'init';
|
|
881
|
-
interface SilgiRouterTypes {
|
|
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;
|
|
882
880
|
}
|
|
883
|
-
|
|
881
|
+
type TSReference = {
|
|
882
|
+
types: string;
|
|
883
|
+
} | {
|
|
884
|
+
path: string;
|
|
885
|
+
};
|
|
886
|
+
interface SilgiHooks {
|
|
884
887
|
}
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
} : T;
|
|
888
|
-
type DeepRequired<T> = T extends (...args: any[]) => any ? T : T extends Record<string, any> ? {
|
|
889
|
-
[P in keyof T]-?: DeepRequired<T[P]>;
|
|
890
|
-
} : T;
|
|
891
|
-
type Awaitable<T> = T | Promise<T>;
|
|
892
|
-
declare global {
|
|
893
|
-
var $silgiStatus: CommandType;
|
|
894
|
-
var _silgi_runtime: SilgiRuntimeOptions;
|
|
895
|
-
namespace NodeJS {
|
|
896
|
-
interface Global {
|
|
897
|
-
$silgiStatus: CommandType;
|
|
898
|
-
_silgi_runtime: SilgiRuntimeOptions;
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
var __silgi__: {
|
|
902
|
-
useRuntimeConfig?: <T extends NitroRuntimeConfig = NitroRuntimeConfig>(event?: H3Event) => T;
|
|
903
|
-
[key: string]: any;
|
|
904
|
-
};
|
|
888
|
+
interface GenerateAppOptions {
|
|
889
|
+
filter?: (template: ResolvedSilgiTemplate<any>) => boolean;
|
|
905
890
|
}
|
|
906
891
|
|
|
907
892
|
type SilgiPreset = (SilgiCLIConfig & {
|
|
@@ -929,14 +914,14 @@ interface SilgiCLIOptions extends PresetOptions {
|
|
|
929
914
|
command?: string;
|
|
930
915
|
};
|
|
931
916
|
commandType: CommandType;
|
|
932
|
-
commands: Commands
|
|
917
|
+
commands: Commands[];
|
|
933
918
|
schemaVendor: Schema | Schema[];
|
|
934
919
|
environments: DotenvOptions$1[];
|
|
935
920
|
activeEnvironment: 'prod' | 'docker' | 'staging' | 'testing' | '.env' | (string & {});
|
|
936
|
-
envOptions: EnvOptions
|
|
937
|
-
runtimeConfig: SilgiRuntimeConfig
|
|
921
|
+
envOptions: EnvOptions;
|
|
922
|
+
runtimeConfig: SilgiRuntimeConfig;
|
|
938
923
|
storages: string[];
|
|
939
|
-
hooks: NestedHooks<SilgiCLIHooks
|
|
924
|
+
hooks: NestedHooks<SilgiCLIHooks>;
|
|
940
925
|
plugins: {
|
|
941
926
|
path: string;
|
|
942
927
|
packageImport: string;
|
|
@@ -960,8 +945,8 @@ interface SilgiCLIOptions extends PresetOptions {
|
|
|
960
945
|
safeList: string[][];
|
|
961
946
|
};
|
|
962
947
|
};
|
|
963
|
-
storage: StorageMounts
|
|
964
|
-
devStorage: StorageMounts
|
|
948
|
+
storage: StorageMounts;
|
|
949
|
+
devStorage: StorageMounts;
|
|
965
950
|
workspaceDir: string;
|
|
966
951
|
rootDir: string;
|
|
967
952
|
srcDir: string;
|
|
@@ -984,7 +969,7 @@ interface SilgiCLIOptions extends PresetOptions {
|
|
|
984
969
|
* ]
|
|
985
970
|
* ```
|
|
986
971
|
*/
|
|
987
|
-
templates: SilgiTemplate
|
|
972
|
+
templates: SilgiTemplate<any>[];
|
|
988
973
|
};
|
|
989
974
|
modulesDir: string[];
|
|
990
975
|
output: {
|
|
@@ -1023,7 +1008,7 @@ interface SilgiCLIOptions extends PresetOptions {
|
|
|
1023
1008
|
devServer: {
|
|
1024
1009
|
watch: string[];
|
|
1025
1010
|
};
|
|
1026
|
-
framework: SilgiFrameworkInfo
|
|
1011
|
+
framework: SilgiFrameworkInfo;
|
|
1027
1012
|
/**
|
|
1028
1013
|
* More customizable than `ignorePrefix`: all files matching glob patterns specified inside the `ignore` array will be ignored in building.
|
|
1029
1014
|
*
|