silgi 0.37.38 → 0.37.40
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/build.mjs +1 -1
- package/dist/cli/build.mjs +4 -4
- package/dist/cli/index.mjs +1 -1
- package/dist/cli/init.mjs +1 -1
- package/dist/cli/install.mjs +1 -1
- package/dist/cli/types.mjs +8 -1
- package/dist/cli/watch.mjs +1 -1
- package/dist/types/index.d.mts +505 -506
- package/package.json +2 -2
package/dist/build.mjs
CHANGED
package/dist/cli/build.mjs
CHANGED
|
@@ -18,8 +18,8 @@ import { defu } from 'defu';
|
|
|
18
18
|
import { resolveModuleURL } from 'exsolve';
|
|
19
19
|
import { withTrailingSlash, isRelative } from 'ufo';
|
|
20
20
|
import { readdir, readFile } from 'node:fs/promises';
|
|
21
|
-
import { globby } from 'globby';
|
|
22
21
|
import { parseAsync } from 'oxc-parser';
|
|
22
|
+
import { glob } from 'tinyglobby';
|
|
23
23
|
import ignore from 'ignore';
|
|
24
24
|
import { klona } from 'klona';
|
|
25
25
|
import { createStorage, builtinDrivers } from 'unstorage';
|
|
@@ -330,7 +330,7 @@ async function registerModuleExportScan(silgi) {
|
|
|
330
330
|
if (!module.entryPath) {
|
|
331
331
|
continue;
|
|
332
332
|
}
|
|
333
|
-
const moduleTypes = await promises.readFile(module.entryPath.replace(/\.mjs$/, "
|
|
333
|
+
const moduleTypes = await promises.readFile(module.entryPath.replace(/\.mjs$/, "moduleTypes.d.mts"), "utf8").catch(() => "");
|
|
334
334
|
const normalisedModuleTypes = moduleTypes.replace(/export\s*\{.*?\}/gs, (match) => match.replace(/\b(type|interface)\b/g, ""));
|
|
335
335
|
for (const e of findTypeExports(normalisedModuleTypes)) {
|
|
336
336
|
moduleReExports.push(e);
|
|
@@ -753,7 +753,7 @@ async function scanSilgiExports(path, packageName, silgiInstance = useSilgiCLI()
|
|
|
753
753
|
return;
|
|
754
754
|
}
|
|
755
755
|
try {
|
|
756
|
-
const matchedFiles = await
|
|
756
|
+
const matchedFiles = await glob(serverDirectory, {
|
|
757
757
|
cwd: silgiInstance.options.rootDir,
|
|
758
758
|
ignore: silgiInstance.options.ignore
|
|
759
759
|
});
|
|
@@ -1397,7 +1397,7 @@ async function scanFiles(silgi, name) {
|
|
|
1397
1397
|
return files;
|
|
1398
1398
|
}
|
|
1399
1399
|
async function scanDir(silgi, dir, name) {
|
|
1400
|
-
const fileNames = await
|
|
1400
|
+
const fileNames = await glob(join(name, GLOB_SCAN_PATTERN), {
|
|
1401
1401
|
cwd: dir,
|
|
1402
1402
|
dot: true,
|
|
1403
1403
|
ignore: silgi.options.ignore,
|
package/dist/cli/index.mjs
CHANGED
package/dist/cli/init.mjs
CHANGED
package/dist/cli/install.mjs
CHANGED
package/dist/cli/types.mjs
CHANGED
|
@@ -76,7 +76,14 @@ const SilgiCLIDefaults = {
|
|
|
76
76
|
presets: [],
|
|
77
77
|
virtualImports: ["#silgiImports"]
|
|
78
78
|
},
|
|
79
|
-
ignore: [
|
|
79
|
+
ignore: [
|
|
80
|
+
"**/*.stories.{js,cts,mts,ts,jsx,tsx}",
|
|
81
|
+
"**/*.{spec,test}.{js,cts,mts,ts,jsx,tsx}",
|
|
82
|
+
"**/*.d.{cts,mts,ts}",
|
|
83
|
+
"**/.{pnpm-store,vercel,netlify,output,git,cache,data}",
|
|
84
|
+
".silgi",
|
|
85
|
+
"**/-*.*"
|
|
86
|
+
],
|
|
80
87
|
// Dev
|
|
81
88
|
dev: false,
|
|
82
89
|
// devServer: { watch: [] },
|
package/dist/cli/watch.mjs
CHANGED
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,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
|
|
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
|
|
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
|
|
157
|
-
interface
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
*
|
|
215
|
-
*
|
|
216
|
-
* @
|
|
90
|
+
* Matched router Node
|
|
91
|
+
*
|
|
92
|
+
* @experimental The object structure may change in non-major version.
|
|
217
93
|
*/
|
|
218
|
-
|
|
219
|
-
|
|
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
|
-
*
|
|
222
|
-
* @param compatibility Compatibility object
|
|
223
|
-
* @param issues Issues to be mapped
|
|
224
|
-
* @returns Promise
|
|
107
|
+
* Event context.
|
|
225
108
|
*/
|
|
226
|
-
|
|
109
|
+
readonly context: SilgiRuntimeContext;
|
|
227
110
|
/**
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
111
|
+
* Incoming HTTP request info.
|
|
112
|
+
*
|
|
113
|
+
* [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
231
114
|
*/
|
|
232
|
-
|
|
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
|
-
*
|
|
313
|
-
*
|
|
314
|
-
*
|
|
117
|
+
* Access to the parsed request URL.
|
|
118
|
+
*
|
|
119
|
+
* [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/URL)
|
|
315
120
|
*/
|
|
316
|
-
|
|
121
|
+
readonly url: URL;
|
|
317
122
|
/**
|
|
318
|
-
*
|
|
319
|
-
* @param app The configured `SilgiCLI` object
|
|
320
|
-
* @returns Promise
|
|
123
|
+
* Prepared HTTP response.
|
|
321
124
|
*/
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
550
|
-
modules?: Partial<SilgiRuntimeActions
|
|
551
|
-
storage?: StorageConfig
|
|
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
|
|
565
|
-
storage?: StorageConfig
|
|
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
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
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
|
|
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
|
|
594
|
-
interface
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
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
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
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
|
|
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
|
|
490
|
+
interface SilgiModuleOptions {
|
|
615
491
|
}
|
|
616
|
-
interface
|
|
492
|
+
interface SilgiRuntimeOptions {
|
|
617
493
|
}
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
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
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
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
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
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
|
|
651
|
-
|
|
538
|
+
interface ResolvedModuleMeta extends ModuleMeta {
|
|
539
|
+
configKey: string;
|
|
540
|
+
name: string;
|
|
652
541
|
}
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
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
|
-
|
|
658
|
-
|
|
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
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
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
|
-
|
|
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
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
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
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
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
|
|
734
|
+
interface SilgiCommands {
|
|
794
735
|
}
|
|
795
|
-
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;
|
|
796
747
|
}
|
|
797
|
-
interface
|
|
748
|
+
interface GenImport {
|
|
749
|
+
specifier: string;
|
|
750
|
+
imports: ESMImport | ESMImport[];
|
|
751
|
+
options?: ESMCodeGenOptions;
|
|
798
752
|
}
|
|
799
|
-
type
|
|
800
|
-
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 {
|
|
801
759
|
/**
|
|
802
|
-
*
|
|
803
|
-
* @
|
|
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
|
|
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
|
-
*
|
|
820
|
-
*
|
|
766
|
+
* Called when silgi instance is gracefully closing.
|
|
767
|
+
* @param silgi The configured silgi object
|
|
768
|
+
* @returns Promise
|
|
821
769
|
*/
|
|
822
|
-
|
|
770
|
+
'close': (silgi: SilgiCLI) => HookResult;
|
|
771
|
+
'reload:scan': (path: string, stats?: Stats) => HookResult;
|
|
823
772
|
/**
|
|
824
|
-
*
|
|
773
|
+
* Allows extending compatibility checks.
|
|
774
|
+
* @param compatibility Compatibility object
|
|
775
|
+
* @param issues Issues to be mapped
|
|
776
|
+
* @returns Promise
|
|
825
777
|
*/
|
|
826
|
-
compatibility
|
|
778
|
+
'kit:compatibility': (compatibility: SilgiCompatibility, issues: SilgiCompatibilityIssues) => HookResult;
|
|
827
779
|
/**
|
|
828
|
-
*
|
|
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
|
-
|
|
831
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
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
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
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
|
|
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
|
|
923
|
-
runtimeConfig: SilgiRuntimeConfig
|
|
921
|
+
envOptions: EnvOptions;
|
|
922
|
+
runtimeConfig: SilgiRuntimeConfig;
|
|
924
923
|
storages: string[];
|
|
925
|
-
hooks: NestedHooks<SilgiCLIHooks
|
|
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
|
|
950
|
-
devStorage: StorageMounts
|
|
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
|
|
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
|
|
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.
|
|
4
|
+
"version": "0.37.40",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"exports": {
|
|
@@ -108,7 +108,6 @@
|
|
|
108
108
|
"dotenv": "^16.5.0",
|
|
109
109
|
"escape-string-regexp": "^5.0.0",
|
|
110
110
|
"exsolve": "^1.0.5",
|
|
111
|
-
"globby": "^14.1.0",
|
|
112
111
|
"hookable": "^5.5.3",
|
|
113
112
|
"ignore": "^7.0.4",
|
|
114
113
|
"klona": "^2.0.6",
|
|
@@ -128,6 +127,7 @@
|
|
|
128
127
|
"semver": "^7.7.1",
|
|
129
128
|
"srvx": "^0.6.0",
|
|
130
129
|
"std-env": "^3.9.0",
|
|
130
|
+
"tinyglobby": "^0.2.13",
|
|
131
131
|
"ufo": "^1.6.1",
|
|
132
132
|
"unadapter": "^0.1.2",
|
|
133
133
|
"unctx": "^2.4.1",
|