silgi 0.3.13 → 0.4.1
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/README.md +1 -31
- package/cli.d.ts +1 -0
- package/config.d.ts +1 -0
- package/core.d.ts +1 -0
- package/dist/_chunks/index.mjs +233 -0
- package/dist/cli/compatibility.mjs +42 -0
- package/dist/cli/index.mjs +3 -184
- package/dist/cli/prepare.mjs +1350 -0
- package/dist/config/index.d.mts +5 -0
- package/dist/config/index.d.ts +5 -0
- package/dist/core/index.d.mts +136 -0
- package/dist/core/index.d.ts +136 -0
- package/dist/core/index.mjs +1444 -0
- package/dist/ecosystem/nitro/index.mjs +21 -29
- package/dist/ecosystem/nuxt/module.mjs +4 -25
- package/dist/kit/index.d.mts +90 -0
- package/dist/kit/index.d.ts +90 -0
- package/dist/kit/index.mjs +316 -0
- package/dist/meta/index.d.mts +3 -0
- package/dist/meta/index.d.ts +3 -0
- package/dist/meta/index.mjs +1 -0
- package/dist/presets/_all.gen.d.ts +2 -0
- package/dist/presets/_all.gen.mjs +10 -0
- package/dist/presets/_resolve.d.ts +8 -0
- package/dist/presets/_resolve.mjs +58 -0
- package/dist/presets/_types.gen.d.ts +5 -0
- package/dist/presets/_types.gen.mjs +1 -0
- package/dist/presets/h3/preset.d.ts +2 -0
- package/dist/presets/h3/preset.mjs +22 -0
- package/dist/presets/index.d.mts +1 -0
- package/dist/presets/index.d.ts +2 -0
- package/dist/presets/index.mjs +1 -0
- package/dist/presets/nitro/preset.d.ts +2 -0
- package/dist/presets/nitro/preset.mjs +26 -0
- package/dist/presets/npmpackage/preset.d.ts +2 -0
- package/dist/presets/npmpackage/preset.mjs +23 -0
- package/dist/presets/nuxt/preset.d.ts +2 -0
- package/dist/presets/nuxt/preset.mjs +26 -0
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.mjs +1 -0
- package/dist/runtime/internal/debug.d.ts +2 -0
- package/dist/runtime/internal/debug.mjs +5 -0
- package/dist/runtime/internal/nitro.d.ts +2 -0
- package/dist/runtime/internal/nitro.mjs +45 -0
- package/dist/runtime/internal/plugin.d.ts +3 -0
- package/dist/runtime/internal/plugin.mjs +4 -0
- package/dist/shared/silgi.40ZJYm8F.d.mts +11 -0
- package/dist/shared/silgi.40ZJYm8F.d.ts +11 -0
- package/dist/shared/{silgi.ClpvycKI.d.ts → silgi.CzUPBllI.d.mts} +452 -438
- package/dist/shared/{silgi.ClpvycKI.d.mts → silgi.D_LzzCtJ.d.ts} +452 -438
- package/dist/types/index.d.mts +42 -0
- package/dist/types/index.d.ts +42 -0
- package/dist/types/index.mjs +1 -0
- package/kit.d.ts +1 -0
- package/meta.d.ts +1 -0
- package/package.json +89 -39
- package/presets.d.ts +1 -0
- package/runtime-meta.d.ts +4 -0
- package/runtime-meta.mjs +32 -0
- package/runtime.d.ts +1 -0
- package/types.d.ts +1 -0
- package/bin/silgi.mjs +0 -3
- package/dist/chunks/generate.mjs +0 -1257
- package/dist/cli/config.d.mts +0 -1633
- package/dist/cli/config.d.ts +0 -1633
- package/dist/index.d.mts +0 -198
- package/dist/index.d.ts +0 -198
- package/dist/index.mjs +0 -503
- package/dist/shared/silgi.D2yb1XAa.mjs +0 -842
- /package/dist/{chunks → cli}/init.mjs +0 -0
- /package/dist/{cli/config.mjs → config/index.mjs} +0 -0
|
@@ -1,22 +1,38 @@
|
|
|
1
|
-
import { ConsolaOptions, ConsolaInstance } from 'consola';
|
|
2
|
-
import { Hookable } from 'hookable';
|
|
3
|
-
import { Ignore } from 'ignore';
|
|
4
|
-
import { BuiltinDriverName, TransactionOptions, StorageValue, Storage } from 'unstorage';
|
|
5
|
-
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
6
1
|
import { Defu } from 'defu';
|
|
7
|
-
import {
|
|
2
|
+
import { TypeSource, IResolvers } from '@graphql-tools/utils';
|
|
8
3
|
import { TSConfig } from 'pkg-types';
|
|
9
|
-
import {
|
|
4
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
5
|
+
import { ConsolaOptions, ConsolaInstance, LogLevel } from 'consola';
|
|
6
|
+
import { Hookable } from 'hookable';
|
|
7
|
+
import { PresetOptions, PresetName, PresetNameInput } from 'silgi/presets';
|
|
8
|
+
import { StorageMounts as StorageMounts$1, SilgiFrameworkInfo as SilgiFrameworkInfo$1, ResolvedServiceType as ResolvedServiceType$1, SilgiDefaultShared as SilgiDefaultShared$1, SilgiModules as SilgiModules$1, ModuleMeta as ModuleMeta$1 } from 'silgi/types';
|
|
9
|
+
import { Unimport } from 'unimport';
|
|
10
|
+
import { BuiltinDriverName, TransactionOptions, Storage } from 'unstorage';
|
|
11
|
+
import { ResolvedConfig, ConfigWatcher, C12InputConfig, WatchConfigOptions } from 'c12';
|
|
12
|
+
import { ChokidarOptions } from 'chokidar';
|
|
13
|
+
import { DateString, CompatibilityDates, CompatibilityDateSpec } from 'compatx';
|
|
14
|
+
import { UnimportPluginOptions } from 'unimport/unplugin';
|
|
15
|
+
import { ProviderName } from 'std-env';
|
|
16
|
+
import { s as silgi, u as useStorage } from './silgi.40ZJYm8F.mjs';
|
|
17
|
+
import { Ignore } from 'ignore';
|
|
10
18
|
|
|
11
|
-
|
|
12
|
-
}
|
|
19
|
+
type HookResult = Promise<void> | void;
|
|
13
20
|
|
|
14
|
-
interface
|
|
21
|
+
interface SilgiCompatibilityIssue {
|
|
22
|
+
name: string;
|
|
23
|
+
message: string;
|
|
15
24
|
}
|
|
16
|
-
interface
|
|
25
|
+
interface SilgiCompatibilityIssues extends Array<SilgiCompatibilityIssue> {
|
|
26
|
+
/**
|
|
27
|
+
* Return formatted error message.
|
|
28
|
+
*/
|
|
29
|
+
toString: () => string;
|
|
17
30
|
}
|
|
18
|
-
|
|
19
|
-
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Bu nitrojs, h3 event or request context.
|
|
34
|
+
*/
|
|
35
|
+
interface SilgiEvent extends Record<string, unknown> {
|
|
20
36
|
}
|
|
21
37
|
|
|
22
38
|
interface SilgiSchema {
|
|
@@ -27,7 +43,7 @@ type BaseSchemaType<T extends StandardSchemaV1> = {
|
|
|
27
43
|
[Action in BaseSilgiMethodType]?: Record<string, {
|
|
28
44
|
input?: T;
|
|
29
45
|
output?: T;
|
|
30
|
-
|
|
46
|
+
router?: T;
|
|
31
47
|
}>;
|
|
32
48
|
};
|
|
33
49
|
|
|
@@ -70,85 +86,6 @@ type ExtractInputFromURI<TURI extends keyof SilgiURIs> = GetInput<ExtractPath<TU
|
|
|
70
86
|
type ExtractOutputFromURI<TURI extends keyof SilgiURIs> = GetOutput<ExtractPath<TURI>>;
|
|
71
87
|
type ExtractRouterParamsFromURI<TURI extends keyof SilgiURIs> = GetRouterParams<ExtractPath<TURI>>;
|
|
72
88
|
|
|
73
|
-
interface SilgiRouterTypes {
|
|
74
|
-
}
|
|
75
|
-
interface SilgiHook {
|
|
76
|
-
}
|
|
77
|
-
interface DefaultHooks {
|
|
78
|
-
}
|
|
79
|
-
interface DefaultMethods {
|
|
80
|
-
get: string;
|
|
81
|
-
post: string;
|
|
82
|
-
put: string;
|
|
83
|
-
delete: string;
|
|
84
|
-
[key: string]: string;
|
|
85
|
-
}
|
|
86
|
-
interface DefaultMethods {
|
|
87
|
-
get: string;
|
|
88
|
-
post: string;
|
|
89
|
-
put: string;
|
|
90
|
-
delete: string;
|
|
91
|
-
}
|
|
92
|
-
type DeepPartial<T> = T extends void ? T : T extends Record<string, any> ? {
|
|
93
|
-
[P in keyof T]?: DeepPartial<T[P]>;
|
|
94
|
-
} : T;
|
|
95
|
-
type Awaitable<T> = T | Promise<T>;
|
|
96
|
-
interface CreateScope {
|
|
97
|
-
execute: <TURI extends keyof SilgiURIs>(uriString: TURI, input: ExtractInputFromURI<TURI>) => Promise<MethodResponse<ExtractOutputFromURI<TURI>>>;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
interface SilgiCompatibilityIssue {
|
|
101
|
-
name: string;
|
|
102
|
-
message: string;
|
|
103
|
-
}
|
|
104
|
-
interface SilgiCompatibilityIssues extends Array<SilgiCompatibilityIssue> {
|
|
105
|
-
/**
|
|
106
|
-
* Return formatted error message.
|
|
107
|
-
*/
|
|
108
|
-
toString: () => string;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
declare class SilgiHelper {
|
|
112
|
-
setEvent(key: string, value: any): void;
|
|
113
|
-
getEvent(key: string): any;
|
|
114
|
-
addH3App(router: Router): Promise<void>;
|
|
115
|
-
addNitroApp(nitro: NitroApp): Promise<void>;
|
|
116
|
-
/**
|
|
117
|
-
* [...router.ts] tum router tarayan ve ona gore isteklere yonlendiren alan.
|
|
118
|
-
*/
|
|
119
|
-
handler(_request: Request | H3Event | Record<string, any>): Promise<void>;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
interface SRNPartition {
|
|
123
|
-
}
|
|
124
|
-
interface SRNService {
|
|
125
|
-
}
|
|
126
|
-
interface SRNRegion {
|
|
127
|
-
}
|
|
128
|
-
interface SRNAccountId {
|
|
129
|
-
}
|
|
130
|
-
interface SRNResource {
|
|
131
|
-
}
|
|
132
|
-
interface SRN {
|
|
133
|
-
partition: string | undefined | SRNPartition;
|
|
134
|
-
service: string | undefined | SRNService;
|
|
135
|
-
region: string | undefined | SRNRegion;
|
|
136
|
-
accountId: string | undefined | SRNAccountId;
|
|
137
|
-
resource: string | undefined | SRNResource;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
declare class SRNManager {
|
|
141
|
-
private readonly silgi;
|
|
142
|
-
constructor(silgi?: Silgi);
|
|
143
|
-
register(_srn: string): void;
|
|
144
|
-
handle(srn: string): SRN;
|
|
145
|
-
findService({ namespace, name }: {
|
|
146
|
-
namespace: string;
|
|
147
|
-
name: string;
|
|
148
|
-
}): any;
|
|
149
|
-
getAllServices(): any;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
89
|
/**
|
|
153
90
|
* @example
|
|
154
91
|
* namespace: 'coreApi'
|
|
@@ -180,13 +117,23 @@ interface SilgiOperation {
|
|
|
180
117
|
/**
|
|
181
118
|
* 'coreApi/basket/post/createBasket'
|
|
182
119
|
*/
|
|
183
|
-
raw:
|
|
120
|
+
raw: string;
|
|
184
121
|
/**
|
|
185
122
|
* '/book/basket/getAllBaskets'
|
|
186
123
|
*/
|
|
187
|
-
uri:
|
|
124
|
+
uri: keyof SilgiURIs;
|
|
125
|
+
/**
|
|
126
|
+
* ['coreApi', 'book', 'basket', 'getAllBaskets']
|
|
127
|
+
*/
|
|
188
128
|
parts: string[];
|
|
189
|
-
|
|
129
|
+
/**
|
|
130
|
+
* {id: '123', name: 'John', bookId: '456', authorId: '789'}
|
|
131
|
+
*/
|
|
132
|
+
routerParams?: Record<string, string | undefined>;
|
|
133
|
+
/**
|
|
134
|
+
* url ?limit=10&page=1
|
|
135
|
+
* {limit: '10', page: '1'}
|
|
136
|
+
*/
|
|
190
137
|
query?: Record<string, string>;
|
|
191
138
|
}
|
|
192
139
|
|
|
@@ -208,110 +155,300 @@ interface StorageConfig<TInput> {
|
|
|
208
155
|
key?: StorageKeyGenerator<TInput>;
|
|
209
156
|
scope?: 'request' | 'global';
|
|
210
157
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
methodName?: string;
|
|
158
|
+
interface StorageKeyParams<TInput = unknown> {
|
|
159
|
+
operation: SilgiOperation;
|
|
160
|
+
input: TInput;
|
|
161
|
+
requestId?: string;
|
|
162
|
+
keyGenerator?: StorageKeyGenerator<TInput>;
|
|
163
|
+
storageOptions?: Pick<StorageConfig<TInput>, 'base' | 'options' | 'scope'>;
|
|
218
164
|
}
|
|
165
|
+
|
|
219
166
|
interface SilgiOptions {
|
|
220
|
-
/**
|
|
221
|
-
* @default 'nitrojs'
|
|
222
|
-
*/
|
|
223
|
-
environment?: ('nitrojs' | 'h3' | 'undefined');
|
|
224
|
-
isPackage: boolean;
|
|
225
|
-
/**
|
|
226
|
-
*
|
|
227
|
-
* @private
|
|
228
|
-
*/
|
|
229
|
-
_eventContext?: Map<string, SilgiEventContext>;
|
|
230
|
-
/**
|
|
231
|
-
*
|
|
232
|
-
* @private
|
|
233
|
-
*/
|
|
234
|
-
_requiredModules: any;
|
|
235
|
-
srn: SRNManager;
|
|
236
167
|
consolaOptions?: Partial<ConsolaOptions>;
|
|
237
|
-
h3Router?: Router;
|
|
238
|
-
nitro?: NitroApp;
|
|
239
|
-
/**
|
|
240
|
-
* Define the root directory of your application.
|
|
241
|
-
*
|
|
242
|
-
* This property can be overwritten (for example, running `nuxt ./my-app/` will set the `rootDir` to the absolute path of `./my-app/` from the current/working directory.
|
|
243
|
-
* It is normally not needed to configure this option.
|
|
244
|
-
*
|
|
245
|
-
* @default "/<rootDir>"
|
|
246
|
-
*/
|
|
247
|
-
rootDir: string;
|
|
248
|
-
/**
|
|
249
|
-
*
|
|
250
|
-
* default "/<rootDir>/.silgi"
|
|
251
|
-
*/
|
|
252
|
-
buildDir: string;
|
|
253
168
|
builder: 'nuxt' | 'nitrojs';
|
|
254
169
|
/**
|
|
255
|
-
*
|
|
256
|
-
*/
|
|
257
|
-
extensions?: string[];
|
|
258
|
-
/**
|
|
170
|
+
* Set to `true` to enable debug mode.
|
|
259
171
|
*
|
|
260
|
-
*
|
|
172
|
+
* At the moment, it prints out hook names and timings on the server, and logs hook arguments as well in the browser.
|
|
173
|
+
*
|
|
174
|
+
* @default false
|
|
261
175
|
*/
|
|
262
|
-
|
|
176
|
+
debug: boolean;
|
|
177
|
+
storage: StorageMounts;
|
|
178
|
+
[key: string]: any;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
interface SilgiAppPlugin {
|
|
182
|
+
(silgi: Silgi): Promise<void> | void;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
interface CapturedErrorContext {
|
|
186
|
+
event?: SilgiEvent;
|
|
187
|
+
[key: string]: unknown;
|
|
188
|
+
}
|
|
189
|
+
type CaptureError = (error: Error, context: CapturedErrorContext) => void;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* The listeners to Silgi
|
|
193
|
+
*/
|
|
194
|
+
interface SilgiHooks {
|
|
263
195
|
/**
|
|
264
|
-
*
|
|
265
|
-
* @
|
|
196
|
+
* Called after Silgi initialization, when the Silgi instance is ready to work.
|
|
197
|
+
* @param silgi The configured Silgi object
|
|
198
|
+
* @returns Promise
|
|
266
199
|
*/
|
|
267
|
-
|
|
200
|
+
'ready': (silgi: Silgi) => HookResult;
|
|
268
201
|
/**
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
* Nuxt tries to resolve each item in the modules array using node require path (in `node_modules`) and then will be resolved from project `srcDir` if `~` alias is used.
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
* @note Modules are executed sequentially so the order is important. First, the modules defined in `nuxt.config.ts` are loaded. Then, modules found in the `modules/`
|
|
276
|
-
* directory are executed, and they load in alphabetical order.
|
|
277
|
-
*
|
|
278
|
-
* @example
|
|
279
|
-
* ```js
|
|
280
|
-
* modules: [
|
|
281
|
-
* // Using package name
|
|
282
|
-
* '@nuxtjs/axios',
|
|
283
|
-
* // Relative to your project srcDir
|
|
284
|
-
* '~/modules/awesome.js',
|
|
285
|
-
* // Providing options
|
|
286
|
-
* ['@nuxtjs/google-analytics', { ua: 'X1234567' }],
|
|
287
|
-
* // Inline definition
|
|
288
|
-
* function () {}
|
|
289
|
-
* ]
|
|
290
|
-
* ```
|
|
202
|
+
* Called when silgi instance is gracefully closing.
|
|
203
|
+
* @param silgi The configured silgi object
|
|
204
|
+
* @returns Promise
|
|
291
205
|
*/
|
|
206
|
+
'close': (silgi: Silgi) => HookResult;
|
|
207
|
+
'app:setup:start': (silgi: Silgi) => HookResult;
|
|
208
|
+
'method:before': (context: ModuleHookContext) => HookResult;
|
|
209
|
+
'method:after': (context: ModuleHookContext) => HookResult;
|
|
210
|
+
'method:error': (context: ModuleHookContext) => HookResult;
|
|
211
|
+
'method:finally': (context: ModuleHookContext) => HookResult;
|
|
212
|
+
'event:before': (event: SilgiEvent) => HookResult;
|
|
213
|
+
'error': CaptureError;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
type SilgiServiceInterface<T extends BaseSchemaType<StandardSchemaV1>> = {
|
|
217
|
+
[Action in keyof T]: T[Action] extends Record<string, any> ? {
|
|
218
|
+
[Method in keyof T[Action]]: {
|
|
219
|
+
input: T[Action][Method]['input'];
|
|
220
|
+
output: T[Action][Method]['output'];
|
|
221
|
+
router: T[Action][Method]['router'];
|
|
222
|
+
};
|
|
223
|
+
} : never;
|
|
224
|
+
};
|
|
225
|
+
type ServiceType<T> = Partial<{
|
|
226
|
+
[Namespace in keyof T]: T[Namespace] extends Record<string, any> ? {
|
|
227
|
+
[Service in keyof T[Namespace]]?: MethodHandlerType<T[Namespace][Service]>;
|
|
228
|
+
} : never;
|
|
229
|
+
}>;
|
|
230
|
+
type RequiredServiceType<T> = {
|
|
231
|
+
[K in keyof T]-?: T[K] extends Record<string, any> ? {
|
|
232
|
+
[P in keyof T[K]]-?: MethodHandlerType<T[K][P]>;
|
|
233
|
+
} : never;
|
|
234
|
+
};
|
|
235
|
+
/**
|
|
236
|
+
* const test: ResolvedServiceType = {
|
|
237
|
+
aaa: {
|
|
238
|
+
bbb: {
|
|
239
|
+
delete: {
|
|
240
|
+
storage: {
|
|
241
|
+
handler: () => {}
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
}
|
|
247
|
+
*/
|
|
248
|
+
type ResolvedServiceType = {
|
|
249
|
+
[K in string]: {
|
|
250
|
+
[P in string]: {
|
|
251
|
+
[Q in BaseSilgiMethodType]?: {
|
|
252
|
+
[M in string]: ResolvedMethodHandlerType;
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
interface FrameworkContext {
|
|
259
|
+
}
|
|
260
|
+
interface Silgi {
|
|
261
|
+
schemas: any;
|
|
262
|
+
services: ResolvedServiceType;
|
|
263
|
+
shared: SilgiDefaultShared;
|
|
264
|
+
uris: Record<string, any>;
|
|
265
|
+
modulesURIs: Partial<Record<keyof SilgiModules, any>>;
|
|
266
|
+
scannedHandlers: Map<string, ResolvedMethodHandlerType>;
|
|
267
|
+
plugins: SilgiAppPlugin[];
|
|
268
|
+
framework: FrameworkContext;
|
|
269
|
+
_ignore?: Ignore;
|
|
270
|
+
hooks: Hookable<SilgiHooks & DefaultHooks>;
|
|
271
|
+
hook: Silgi['hooks']['hook'];
|
|
272
|
+
callHook: Silgi['hooks']['callHook'];
|
|
273
|
+
addHooks: Silgi['hooks']['addHooks'];
|
|
274
|
+
ready: () => Promise<void>;
|
|
275
|
+
close: () => Promise<void>;
|
|
276
|
+
logger: ConsolaInstance;
|
|
277
|
+
storage: Storage;
|
|
278
|
+
options: SilgiOptions & SilgiModuleOptions;
|
|
279
|
+
captureError: CaptureError;
|
|
280
|
+
}
|
|
281
|
+
interface SilgiConfig extends Pick<Silgi, 'services' | 'shared' | 'uris' | 'schemas' | 'modulesURIs' | 'plugins' | 'framework'>, Partial<SilgiModuleOptions> {
|
|
282
|
+
options: DeepPartial<SilgiOptions>;
|
|
283
|
+
}
|
|
284
|
+
type SilgiFunction = typeof silgi;
|
|
285
|
+
|
|
286
|
+
interface SilgiDefaultShared extends SilgiModuleShared {
|
|
287
|
+
storage: (...data: Parameters<typeof useStorage>) => ReturnType<typeof useStorage>;
|
|
288
|
+
silgi: SilgiFunction;
|
|
289
|
+
}
|
|
290
|
+
interface SilgiModuleShared {
|
|
291
|
+
}
|
|
292
|
+
interface ExtendShared {
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
interface MethodSchemaType<Input, Output> {
|
|
296
|
+
default: {
|
|
297
|
+
input?: Input;
|
|
298
|
+
output: Output;
|
|
299
|
+
};
|
|
300
|
+
handler: (input: Input, shared: SilgiDefaultShared, event: SilgiEvent) => Promise<Output>;
|
|
301
|
+
modules?: Partial<ModuleConfigurations>;
|
|
302
|
+
storage?: StorageConfig<Input>;
|
|
303
|
+
}
|
|
304
|
+
type EventHandlerResponse<T = undefined> = T extends undefined ? void : void | T | Promise<T>;
|
|
305
|
+
type MethodHandlerType<T> = {
|
|
306
|
+
[Action in keyof T]: T[Action] extends Record<string, any> ? {
|
|
307
|
+
[Method in keyof T[Action]]: {
|
|
308
|
+
default?: {
|
|
309
|
+
input?: StandardSchemaV1.InferInput<T[Action][Method]['input']>;
|
|
310
|
+
output?: StandardSchemaV1.InferInput<T[Action][Method]['output']>;
|
|
311
|
+
};
|
|
312
|
+
handler: (router: StandardSchemaV1.InferInput<T[Action][Method]['router']>, input: StandardSchemaV1.InferInput<T[Action][Method]['input']>, shared: SilgiDefaultShared, event: SilgiEvent) => EventHandlerResponse<StandardSchemaV1.InferOutput<T[Action][Method]['output']>>;
|
|
313
|
+
modules?: Partial<ModuleConfigurations>;
|
|
314
|
+
storage?: StorageConfig<T[Action][Method]['input']>;
|
|
315
|
+
};
|
|
316
|
+
} : never;
|
|
317
|
+
};
|
|
318
|
+
interface ResolvedMethodHandlerType {
|
|
319
|
+
input?: Partial<BaseSchemaType<any>>;
|
|
320
|
+
output: Partial<BaseSchemaType<any>>;
|
|
321
|
+
handler: (router: StandardSchemaV1.InferInput<any>, input: StandardSchemaV1.InferInput<any>, shared: SilgiDefaultShared, event: SilgiEvent) => Promise<StandardSchemaV1.InferInput<any>>;
|
|
322
|
+
modules?: Partial<ModuleConfigurations>;
|
|
323
|
+
storage?: StorageConfig<StandardSchemaV1.InferInput<any>>;
|
|
324
|
+
execute: (input: StandardSchemaV1.InferInput<any>, shared: SilgiDefaultShared, event: SilgiEvent) => Promise<StandardSchemaV1.InferInput<any>>;
|
|
325
|
+
}
|
|
326
|
+
type MethodResponse<T> = {
|
|
327
|
+
success: true;
|
|
328
|
+
data: T;
|
|
329
|
+
cached?: boolean;
|
|
330
|
+
} | {
|
|
331
|
+
success: false;
|
|
332
|
+
error: {
|
|
333
|
+
code: string;
|
|
334
|
+
message: string;
|
|
335
|
+
details?: Record<string, unknown>;
|
|
336
|
+
};
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
interface SilgiMethods {
|
|
340
|
+
}
|
|
341
|
+
interface SilgiNamespaces {
|
|
342
|
+
}
|
|
343
|
+
interface DefaultNamespaces extends SilgiNamespaces {
|
|
344
|
+
}
|
|
345
|
+
interface SilgiRouterTypes {
|
|
346
|
+
}
|
|
347
|
+
interface SilgiHook {
|
|
348
|
+
}
|
|
349
|
+
type BaseSilgiMethodType = 'post' | 'delete' | 'put' | 'get' | keyof SilgiMethods;
|
|
350
|
+
interface DefaultHooks {
|
|
351
|
+
}
|
|
352
|
+
type DeepPartial<T> = T extends void ? T : T extends Record<string, any> ? {
|
|
353
|
+
[P in keyof T]?: DeepPartial<T[P]>;
|
|
354
|
+
} : T;
|
|
355
|
+
type Awaitable<T> = T | Promise<T>;
|
|
356
|
+
interface CreateScope {
|
|
357
|
+
execute: <TURI extends keyof SilgiURIs>(uriString: TURI, input: ExtractInputFromURI<TURI>) => Promise<MethodResponse<ExtractOutputFromURI<TURI>>>;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
type SilgiPreset = SilgiCLIConfig | (() => SilgiCLIConfig);
|
|
361
|
+
interface SilgiPresetMeta {
|
|
362
|
+
url: string;
|
|
363
|
+
name: string;
|
|
364
|
+
stdName?: ProviderName;
|
|
365
|
+
aliases?: string[];
|
|
366
|
+
static?: boolean;
|
|
367
|
+
compatibilityDate?: DateString;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* SilgiCLI normalized options (silgi.options)
|
|
372
|
+
*/
|
|
373
|
+
interface SilgiCLIOptions extends PresetOptions {
|
|
374
|
+
_config: SilgiCLIConfig;
|
|
375
|
+
_c12: ResolvedConfig<SilgiCLIConfig> | ConfigWatcher<SilgiCLIConfig>;
|
|
376
|
+
_cli?: {
|
|
377
|
+
command?: string;
|
|
378
|
+
};
|
|
379
|
+
namespaces: string[];
|
|
380
|
+
plugins: {
|
|
381
|
+
path: string;
|
|
382
|
+
packageImport: string;
|
|
383
|
+
}[];
|
|
384
|
+
routeRules: Record<string, string>;
|
|
385
|
+
compatibilityDate: CompatibilityDates;
|
|
292
386
|
modules: (SilgiModule<any> | string | [SilgiModule | string, Record<string, any>] | undefined | null | false)[];
|
|
293
|
-
|
|
387
|
+
_modules: (SilgiModule<any> | string | [SilgiModule | string, Record<string, any>] | undefined | null | false)[];
|
|
388
|
+
debug: boolean;
|
|
389
|
+
preset: PresetName;
|
|
390
|
+
static: boolean;
|
|
391
|
+
logLevel: LogLevel;
|
|
392
|
+
appConfig: AppConfig;
|
|
393
|
+
appConfigFiles: string[];
|
|
394
|
+
storage: StorageMounts$1;
|
|
395
|
+
devStorage: StorageMounts$1;
|
|
396
|
+
workspaceDir: string;
|
|
397
|
+
rootDir: string;
|
|
398
|
+
srcDir: string;
|
|
399
|
+
scanDirs: string[];
|
|
400
|
+
apiDir: string;
|
|
401
|
+
routesDir: string;
|
|
402
|
+
build: {
|
|
403
|
+
dir: string;
|
|
404
|
+
typesDir: string;
|
|
405
|
+
};
|
|
406
|
+
modulesDir: string[];
|
|
407
|
+
output: {
|
|
408
|
+
dir: string;
|
|
409
|
+
serverDir: string;
|
|
410
|
+
publicDir: string;
|
|
411
|
+
};
|
|
412
|
+
serverDir: string;
|
|
413
|
+
clientDir: string;
|
|
414
|
+
silgi: {
|
|
415
|
+
serverDir: string;
|
|
416
|
+
clientDir: string;
|
|
417
|
+
publicDir: string;
|
|
418
|
+
utilsDir: string;
|
|
419
|
+
composablesDir: string;
|
|
420
|
+
typesDir: string;
|
|
421
|
+
servicesDir: string;
|
|
422
|
+
};
|
|
423
|
+
imports: UnimportPluginOptions | false;
|
|
424
|
+
watchOptions: ChokidarOptions;
|
|
425
|
+
nodeModulesDirs: string[];
|
|
426
|
+
commands: {
|
|
427
|
+
preview: string;
|
|
428
|
+
deploy: string;
|
|
429
|
+
};
|
|
430
|
+
framework: SilgiFrameworkInfo$1;
|
|
294
431
|
/**
|
|
432
|
+
* More customizable than `ignorePrefix`: all files matching glob patterns specified inside the `ignore` array will be ignored in building.
|
|
295
433
|
*
|
|
296
|
-
* @
|
|
434
|
+
* @default ["**\/*.stories.{js,cts,mts,ts,jsx,tsx}","**\/*.{spec,test}.{js,cts,mts,ts,jsx,tsx}","**\/*.d.{cts,mts,ts}","**\/.{pnpm-store,vercel,netlify,output,git,cache,data}",".nuxt/analyze",".nuxt","**\/-*.*"]
|
|
297
435
|
*/
|
|
298
|
-
|
|
299
|
-
meta: ModuleMeta;
|
|
300
|
-
timings?: Record<string, number | undefined>;
|
|
301
|
-
entryPath?: string;
|
|
302
|
-
packageName: string;
|
|
303
|
-
active?: boolean;
|
|
304
|
-
}>;
|
|
305
|
-
silgiDir: string;
|
|
436
|
+
ignore: Array<string>;
|
|
306
437
|
/**
|
|
438
|
+
* Whether Nuxt is running in development mode.
|
|
307
439
|
*
|
|
308
|
-
*
|
|
440
|
+
* Normally, you should not need to set this.
|
|
441
|
+
*
|
|
442
|
+
* @default false
|
|
309
443
|
*/
|
|
310
|
-
|
|
444
|
+
dev: boolean;
|
|
311
445
|
/**
|
|
312
|
-
*
|
|
446
|
+
* Whether your app is being unit tested.
|
|
313
447
|
*
|
|
448
|
+
* @default false
|
|
314
449
|
*/
|
|
450
|
+
test: boolean;
|
|
451
|
+
extensions: string[];
|
|
315
452
|
future: {
|
|
316
453
|
/**
|
|
317
454
|
* This enables 'Bundler' module resolution mode for TypeScript, which is the recommended setting for frameworks like Nuxt and Vite.
|
|
@@ -325,10 +462,6 @@ interface SilgiOptions {
|
|
|
325
462
|
*/
|
|
326
463
|
typescriptBundlerResolution: boolean;
|
|
327
464
|
};
|
|
328
|
-
/**
|
|
329
|
-
* Configuration for Nuxt's TypeScript integration.
|
|
330
|
-
*
|
|
331
|
-
*/
|
|
332
465
|
typescript: {
|
|
333
466
|
/**
|
|
334
467
|
* TypeScript comes with certain checks to give you more safety and analysis of your program. Once you’ve converted your codebase to TypeScript, you can start enabling these checks for greater safety. [Read More](https://www.typescriptlang.org/docs/handbook/migrating-from-javascript.html#getting-stricter-checks)
|
|
@@ -372,120 +505,140 @@ interface SilgiOptions {
|
|
|
372
505
|
* @default false
|
|
373
506
|
*/
|
|
374
507
|
shim: boolean;
|
|
375
|
-
};
|
|
376
|
-
/**
|
|
377
|
-
* Whether Nuxt is running in development mode.
|
|
378
|
-
*
|
|
379
|
-
* Normally, you should not need to set this.
|
|
380
|
-
*
|
|
381
|
-
* @default false
|
|
382
|
-
*/
|
|
383
|
-
dev: boolean;
|
|
384
|
-
/**
|
|
385
|
-
* Whether your app is being unit tested.
|
|
386
|
-
*
|
|
387
|
-
* @default false
|
|
388
|
-
*/
|
|
389
|
-
test: boolean;
|
|
390
|
-
/**
|
|
391
|
-
* Set to `true` to enable debug mode.
|
|
392
|
-
*
|
|
393
|
-
* At the moment, it prints out hook names and timings on the server, and logs hook arguments as well in the browser.
|
|
394
|
-
*
|
|
395
|
-
* @default false
|
|
396
|
-
*/
|
|
397
|
-
debug: boolean;
|
|
398
|
-
namespaces: string[];
|
|
399
|
-
/**
|
|
400
|
-
* Define the server directory of your Nuxt application, where Nitro routes, middleware and plugins are kept.
|
|
401
|
-
*
|
|
402
|
-
* If a relative path is specified, it will be relative to your `rootDir`.
|
|
403
|
-
*
|
|
404
|
-
* @default "/<rootDir>/server"
|
|
405
|
-
*/
|
|
406
|
-
serverDir: string;
|
|
407
|
-
/**
|
|
408
|
-
* Define the server directory of your Nuxt application, where Nitro routes, middleware and plugins are kept.
|
|
409
|
-
*
|
|
410
|
-
* If a relative path is specified, it will be relative to your `rootDir`.
|
|
411
|
-
*
|
|
412
|
-
* @default "/<rootDir>/app"
|
|
413
|
-
*/
|
|
414
|
-
clientDir: string;
|
|
415
|
-
/**
|
|
416
|
-
* Customize default directory structure used by Nuxt.
|
|
417
|
-
*
|
|
418
|
-
* It is better to stick with defaults unless needed.
|
|
419
|
-
*
|
|
420
|
-
*/
|
|
421
|
-
dir: {
|
|
422
|
-
/** @default "/<srcDir>" */
|
|
423
|
-
client: string;
|
|
424
508
|
/**
|
|
425
|
-
*
|
|
426
|
-
*
|
|
427
|
-
* @default "/<serverDir>/silgi/modules"
|
|
509
|
+
* @default "types/silgi.tsconfig.json"
|
|
428
510
|
*/
|
|
429
|
-
|
|
511
|
+
tsconfigPath: string;
|
|
430
512
|
/**
|
|
431
|
-
*
|
|
432
|
-
*
|
|
433
|
-
* @default "/<rootDir>/shared"
|
|
513
|
+
* @default true
|
|
434
514
|
*/
|
|
435
|
-
|
|
515
|
+
generateTsConfig: boolean;
|
|
436
516
|
/**
|
|
437
|
-
*
|
|
438
|
-
|
|
439
|
-
|
|
517
|
+
* @default false
|
|
518
|
+
*/
|
|
519
|
+
internalPaths?: boolean;
|
|
520
|
+
/**
|
|
521
|
+
* @default ['silgiTypes']
|
|
440
522
|
*/
|
|
441
|
-
|
|
523
|
+
customConditions: string[];
|
|
442
524
|
};
|
|
525
|
+
alias: Record<string, string>;
|
|
443
526
|
/**
|
|
444
|
-
*
|
|
445
|
-
*
|
|
446
|
-
* @default ["**\/*.stories.{js,cts,mts,ts,jsx,tsx}","**\/*.{spec,test}.{js,cts,mts,ts,jsx,tsx}","**\/*.d.{cts,mts,ts}","**\/.{pnpm-store,vercel,netlify,output,git,cache,data}",".nuxt/analyze",".nuxt","**\/-*.*"]
|
|
527
|
+
* @default ['silgi']
|
|
447
528
|
*/
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
529
|
+
conditions: string[];
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Silgi input config (silgi.config)
|
|
533
|
+
*/
|
|
534
|
+
interface SilgiCLIConfig extends DeepPartial<Omit<SilgiCLIOptions, 'preset' | 'compatibilityDate'>>, C12InputConfig<SilgiCLIConfig>, DeepPartial<SilgiModuleOptions> {
|
|
535
|
+
preset?: PresetNameInput;
|
|
536
|
+
extends?: string | string[] | SilgiPreset;
|
|
537
|
+
compatibilityDate?: CompatibilityDateSpec;
|
|
538
|
+
}
|
|
539
|
+
interface AppConfig {
|
|
451
540
|
[key: string]: any;
|
|
452
541
|
}
|
|
542
|
+
interface LoadConfigOptions {
|
|
543
|
+
watch?: boolean;
|
|
544
|
+
c12?: WatchConfigOptions;
|
|
545
|
+
compatibilityDate?: CompatibilityDateSpec;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
interface ImportItem {
|
|
549
|
+
importItems: {
|
|
550
|
+
[key: string]: {
|
|
551
|
+
import: {
|
|
552
|
+
type?: boolean;
|
|
553
|
+
name: string;
|
|
554
|
+
}[];
|
|
555
|
+
from: string;
|
|
556
|
+
};
|
|
557
|
+
};
|
|
558
|
+
customImports: string[];
|
|
559
|
+
customContent?: string[];
|
|
560
|
+
functions?: string[];
|
|
561
|
+
}
|
|
562
|
+
interface SilgiCLI {
|
|
563
|
+
services: ResolvedServiceType$1;
|
|
564
|
+
shareds: SilgiDefaultShared$1;
|
|
565
|
+
uris: Record<string, any>;
|
|
566
|
+
schemas: Record<string, any>;
|
|
567
|
+
modulesURIs: Partial<Record<keyof SilgiModules$1, any>>;
|
|
568
|
+
scannedURIs: Map<string, string>;
|
|
569
|
+
hooks: Hookable<SilgiCLIHooks>;
|
|
570
|
+
hook: SilgiCLI['hooks']['hook'];
|
|
571
|
+
callHook: SilgiCLI['hooks']['callHook'];
|
|
572
|
+
addHooks: SilgiCLI['hooks']['addHooks'];
|
|
573
|
+
storage: Storage;
|
|
574
|
+
unimport?: Unimport;
|
|
575
|
+
logger: ConsolaInstance;
|
|
576
|
+
close: () => Promise<void>;
|
|
577
|
+
updateConfig: (config: SilgiCLIDynamicConfig) => void | Promise<void>;
|
|
578
|
+
scanModules: Array<{
|
|
579
|
+
meta: ModuleMeta$1;
|
|
580
|
+
timings?: Record<string, number | undefined>;
|
|
581
|
+
entryPath: string;
|
|
582
|
+
installed?: boolean;
|
|
583
|
+
}>;
|
|
584
|
+
options: SilgiCLIOptions;
|
|
585
|
+
_requiredModules: Record<string, boolean>;
|
|
586
|
+
}
|
|
587
|
+
type SilgiCLIDynamicConfig = Pick<SilgiCLIConfig, 'routeRules'>;
|
|
588
|
+
interface SilgiFrameworkInfo {
|
|
589
|
+
name?: 'silgi' | (string & {});
|
|
590
|
+
version?: string;
|
|
591
|
+
}
|
|
592
|
+
/** Build info written to `.output/silgi.json` or `.silgi/dev/silgi.json` */
|
|
593
|
+
interface NitroBuildInfo {
|
|
594
|
+
date: string;
|
|
595
|
+
preset: PresetName;
|
|
596
|
+
framework: SilgiFrameworkInfo;
|
|
597
|
+
versions: {
|
|
598
|
+
silgi: string;
|
|
599
|
+
[key: string]: string;
|
|
600
|
+
};
|
|
601
|
+
commands?: {
|
|
602
|
+
preview?: string;
|
|
603
|
+
deploy?: string;
|
|
604
|
+
};
|
|
605
|
+
dev?: {
|
|
606
|
+
pid: number;
|
|
607
|
+
workerAddress: {
|
|
608
|
+
host: string;
|
|
609
|
+
port: number;
|
|
610
|
+
socketPath?: string;
|
|
611
|
+
};
|
|
612
|
+
};
|
|
613
|
+
config?: Partial<PresetOptions>;
|
|
614
|
+
}
|
|
453
615
|
|
|
454
|
-
type HookResult = Promise<void> | void;
|
|
455
616
|
type TSReference = {
|
|
456
617
|
types: string;
|
|
457
618
|
} | {
|
|
458
619
|
path: string;
|
|
459
620
|
};
|
|
460
|
-
|
|
461
|
-
* The listeners to Silgi
|
|
462
|
-
*/
|
|
463
|
-
interface SilgiHooks {
|
|
621
|
+
interface SilgiCLIHooks {
|
|
464
622
|
/**
|
|
465
623
|
* Called after Silgi initialization, when the Silgi instance is ready to work.
|
|
466
624
|
* @param silgi The configured Silgi object
|
|
467
625
|
* @returns Promise
|
|
468
626
|
*/
|
|
469
|
-
'ready': (silgi:
|
|
627
|
+
'ready': (silgi: SilgiCLI) => HookResult;
|
|
470
628
|
/**
|
|
471
629
|
* Called when silgi instance is gracefully closing.
|
|
472
630
|
* @param silgi The configured silgi object
|
|
473
631
|
* @returns Promise
|
|
474
632
|
*/
|
|
475
|
-
'close': (silgi:
|
|
476
|
-
'app:setup:start': (silgi: Silgi) => HookResult;
|
|
477
|
-
'method:before': (context: ModuleHookContext) => HookResult;
|
|
478
|
-
'method:after': (context: ModuleHookContext) => HookResult;
|
|
479
|
-
'method:error': (context: ModuleHookContext) => HookResult;
|
|
480
|
-
'method:finally': (context: ModuleHookContext) => HookResult;
|
|
633
|
+
'close': (silgi: SilgiCLI) => HookResult;
|
|
481
634
|
'module:register:before': (module: SilgiModule) => HookResult;
|
|
482
|
-
'module:register:after': (module:
|
|
635
|
+
'module:register:after': (module: SilgiCLI['scanModules'][number]) => HookResult;
|
|
483
636
|
'module:setup:finish': (module: SilgiModule) => HookResult;
|
|
484
637
|
'module:before:excute': (context: ModuleHookContext) => HookResult;
|
|
485
638
|
'module:after:excute': (context: ModuleHookContext) => HookResult;
|
|
486
639
|
'module:error': (context: ModuleHookContext) => HookResult;
|
|
487
|
-
'
|
|
488
|
-
'
|
|
640
|
+
'prepare:createCoreFramework': (options: ImportItem) => HookResult;
|
|
641
|
+
'prepare:createDTSFramework': (options: ImportItem) => HookResult;
|
|
489
642
|
/**
|
|
490
643
|
* Allows extending compatibility checks.
|
|
491
644
|
* @param compatibility Compatibility object
|
|
@@ -503,39 +656,15 @@ interface SilgiHooks {
|
|
|
503
656
|
declarations: string[];
|
|
504
657
|
tsConfig: TSConfig;
|
|
505
658
|
}) => HookResult;
|
|
506
|
-
/**
|
|
507
|
-
* 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`
|
|
508
|
-
* @param options Objects containing `references`, `declarations`, `tsConfig`
|
|
509
|
-
* @returns Promise
|
|
510
|
-
*/
|
|
511
659
|
'prepare:core.ts': (options: {
|
|
512
|
-
importedItems: {
|
|
513
|
-
[key: string]: {
|
|
514
|
-
import: {
|
|
515
|
-
type?: boolean;
|
|
516
|
-
name: string;
|
|
517
|
-
}[];
|
|
518
|
-
from: string;
|
|
519
|
-
};
|
|
520
|
-
};
|
|
521
|
-
imports: string[];
|
|
522
660
|
uris: string[];
|
|
523
661
|
services: string[];
|
|
524
662
|
shareds: string[];
|
|
525
663
|
schemas: string[];
|
|
526
|
-
|
|
527
|
-
}) => HookResult;
|
|
664
|
+
buildSilgiExtraContent: string[];
|
|
665
|
+
} & ImportItem) => HookResult;
|
|
666
|
+
'after:prepare:core.ts': (content: string[]) => HookResult;
|
|
528
667
|
'prepare:schema.ts': (options: {
|
|
529
|
-
importedItems: {
|
|
530
|
-
[key: string]: {
|
|
531
|
-
import: {
|
|
532
|
-
type?: boolean;
|
|
533
|
-
name: string;
|
|
534
|
-
}[];
|
|
535
|
-
from: string;
|
|
536
|
-
};
|
|
537
|
-
};
|
|
538
|
-
imports: string[];
|
|
539
668
|
configs: {
|
|
540
669
|
key: string;
|
|
541
670
|
value: string;
|
|
@@ -559,19 +688,9 @@ interface SilgiHooks {
|
|
|
559
688
|
isSilgiContext?: boolean;
|
|
560
689
|
}[];
|
|
561
690
|
storeBase: string[];
|
|
562
|
-
}) => HookResult;
|
|
563
|
-
'prepare:
|
|
564
|
-
|
|
565
|
-
[key: string]: {
|
|
566
|
-
import: {
|
|
567
|
-
type?: boolean;
|
|
568
|
-
name: string;
|
|
569
|
-
}[];
|
|
570
|
-
from: string;
|
|
571
|
-
};
|
|
572
|
-
};
|
|
573
|
-
imports: string[];
|
|
574
|
-
}) => HookResult;
|
|
691
|
+
} & ImportItem) => HookResult;
|
|
692
|
+
'after:prepare:schema.ts': (content: string[]) => HookResult;
|
|
693
|
+
'prepare:framework.d.ts': (options: {} & ImportItem) => HookResult;
|
|
575
694
|
'read:core.ts': (data: () => Awaitable<{
|
|
576
695
|
context: string;
|
|
577
696
|
object: {
|
|
@@ -579,9 +698,14 @@ interface SilgiHooks {
|
|
|
579
698
|
services?: string[];
|
|
580
699
|
shareds?: string[];
|
|
581
700
|
schemas?: string[];
|
|
701
|
+
modulesURIs?: string[];
|
|
582
702
|
};
|
|
583
703
|
path: string;
|
|
584
704
|
}>) => HookResult;
|
|
705
|
+
'before:graphql:schema': (data: {
|
|
706
|
+
typeDefs: TypeSource[];
|
|
707
|
+
resolvers: Array<IResolvers<any, any>>;
|
|
708
|
+
}) => HookResult;
|
|
585
709
|
}
|
|
586
710
|
|
|
587
711
|
interface SilgiModules {
|
|
@@ -590,6 +714,7 @@ interface SilgiModuleMethods {
|
|
|
590
714
|
}
|
|
591
715
|
interface SilgiModuleOptions {
|
|
592
716
|
}
|
|
717
|
+
type SilgiModuleInput = (SilgiModule<any> | string | [SilgiModule | string, Record<string, any>] | undefined | null | false);
|
|
593
718
|
interface SilgiCompatibility {
|
|
594
719
|
/**
|
|
595
720
|
* Required silgi version in semver format.
|
|
@@ -615,6 +740,7 @@ interface ModuleMeta {
|
|
|
615
740
|
method?: true;
|
|
616
741
|
schema?: true;
|
|
617
742
|
event?: true;
|
|
743
|
+
options?: true;
|
|
618
744
|
};
|
|
619
745
|
variable?: {
|
|
620
746
|
shared?: true;
|
|
@@ -631,9 +757,23 @@ interface ModuleMeta {
|
|
|
631
757
|
* Constraints for the versions of silgi or features this module requires.
|
|
632
758
|
*/
|
|
633
759
|
compatibility?: SilgiCompatibility;
|
|
760
|
+
/**
|
|
761
|
+
* @private
|
|
762
|
+
*/
|
|
763
|
+
_modules?: {
|
|
764
|
+
[key: string]: string;
|
|
765
|
+
};
|
|
766
|
+
/**
|
|
767
|
+
* @private
|
|
768
|
+
*/
|
|
769
|
+
_packageName?: string;
|
|
634
770
|
readonly dependencies?: ReadonlyArray<string>;
|
|
635
771
|
[key: string]: unknown;
|
|
636
772
|
}
|
|
773
|
+
interface ResolvedModuleMeta extends ModuleMeta {
|
|
774
|
+
configKey: string;
|
|
775
|
+
name: string;
|
|
776
|
+
}
|
|
637
777
|
type ModuleHookContext = Readonly<{
|
|
638
778
|
event?: SilgiEvent;
|
|
639
779
|
operation?: SilgiOperation;
|
|
@@ -658,10 +798,9 @@ type ResolvedModuleOptions<TOptions extends ModuleOptions, TOptionsDefaults exte
|
|
|
658
798
|
]>>;
|
|
659
799
|
interface ModuleDefinition<TOptions extends ModuleOptions, TOptionsDefaults extends Partial<TOptions>, TWith extends boolean> {
|
|
660
800
|
meta?: ModuleMeta;
|
|
661
|
-
defaults?: TOptionsDefaults | ((silgi:
|
|
662
|
-
hooks?: Partial<
|
|
663
|
-
|
|
664
|
-
setup?: (this: void, resolvedOptions: TWith extends true ? ResolvedModuleOptions<TOptions, TOptionsDefaults> : TOptions, silgi: Silgi) => ModuleSetupReturn;
|
|
801
|
+
defaults?: TOptionsDefaults | ((silgi: SilgiCLI) => Awaitable<TOptionsDefaults>);
|
|
802
|
+
hooks?: Partial<SilgiCLIHooks>;
|
|
803
|
+
setup?: (this: void, resolvedOptions: TWith extends true ? ResolvedModuleOptions<TOptions, TOptionsDefaults> : TOptions, silgi: SilgiCLI) => ModuleSetupReturn;
|
|
665
804
|
}
|
|
666
805
|
interface ModuleSetupInstallResult {
|
|
667
806
|
/**
|
|
@@ -675,135 +814,10 @@ interface ModuleSetupInstallResult {
|
|
|
675
814
|
}
|
|
676
815
|
type ModuleSetupReturn = Awaitable<false | void | ModuleSetupInstallResult>;
|
|
677
816
|
interface SilgiModule<TOptions extends ModuleOptions = ModuleOptions, TOptionsDefaults extends Partial<TOptions> = Partial<TOptions>, TWith extends boolean = false> {
|
|
678
|
-
(this: void, resolvedOptions: TWith extends true ? ResolvedModuleOptions<TOptions, TOptionsDefaults> : TOptions, silgi:
|
|
679
|
-
getOptions?: (inlineOptions?: Partial<TOptions>, silgi?:
|
|
817
|
+
(this: void, resolvedOptions: TWith extends true ? ResolvedModuleOptions<TOptions, TOptionsDefaults> : TOptions, silgi: SilgiCLI): ModuleSetupReturn;
|
|
818
|
+
getOptions?: (inlineOptions?: Partial<TOptions>, silgi?: SilgiCLI) => Promise<TWith extends true ? ResolvedModuleOptions<TOptions, TOptionsDefaults> : TOptions>;
|
|
680
819
|
getMeta?: () => Promise<ModuleMeta>;
|
|
681
|
-
cli?: (silgi: Silgi) => ModuleSetupReturn;
|
|
682
|
-
}
|
|
683
|
-
type ModuleConfiguration<K extends keyof SilgiModuleMethods = keyof SilgiModuleMethods> = SilgiModuleMethods[K];
|
|
684
|
-
type ModuleConfigurations = {
|
|
685
|
-
[K in keyof SilgiModuleMethods]?: ModuleConfiguration;
|
|
686
|
-
};
|
|
687
|
-
|
|
688
|
-
declare function useStorage<T extends StorageValue = StorageValue>(base?: StorageConfig<T>['base']): Storage<T>;
|
|
689
|
-
|
|
690
|
-
interface SilgiDefaultShared extends SilgiModuleShared {
|
|
691
|
-
storage: (...data: Parameters<typeof useStorage>) => ReturnType<typeof useStorage>;
|
|
692
|
-
silgi: SilgiFunction;
|
|
693
|
-
}
|
|
694
|
-
interface SilgiModuleShared {
|
|
695
|
-
}
|
|
696
|
-
interface ExtendShared {
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
type EventHandlerResponse<T = undefined> = T extends undefined ? void : void | T | Promise<T>;
|
|
700
|
-
type MethodHandlerType<T> = {
|
|
701
|
-
[Action in keyof T]: T[Action] extends Record<string, any> ? {
|
|
702
|
-
[Method in keyof T[Action]]: {
|
|
703
|
-
default?: {
|
|
704
|
-
input?: StandardSchemaV1.InferInput<T[Action][Method]['input']>;
|
|
705
|
-
output?: StandardSchemaV1.InferInput<T[Action][Method]['output']>;
|
|
706
|
-
};
|
|
707
|
-
handler: (router: StandardSchemaV1.InferInput<T[Action][Method]['router']>, input: StandardSchemaV1.InferInput<T[Action][Method]['input']>, shared: SilgiDefaultShared, event: SilgiEvent) => EventHandlerResponse<StandardSchemaV1.InferOutput<T[Action][Method]['output']>>;
|
|
708
|
-
modules?: ModuleConfigurations;
|
|
709
|
-
storage?: StorageConfig<T[Action][Method]['input']>;
|
|
710
|
-
};
|
|
711
|
-
} : never;
|
|
712
|
-
};
|
|
713
|
-
interface ResolvedMethodHandlerType {
|
|
714
|
-
input?: Partial<BaseSchemaType<any>>;
|
|
715
|
-
output: Partial<BaseSchemaType<any>>;
|
|
716
|
-
handler: (router: StandardSchemaV1.InferInput<any>, input: StandardSchemaV1.InferInput<any>, shared: SilgiDefaultShared, event: SilgiEvent) => Promise<StandardSchemaV1.InferInput<any>>;
|
|
717
|
-
modules?: ModuleConfigurations;
|
|
718
|
-
storage?: StorageConfig<StandardSchemaV1.InferInput<any>>;
|
|
719
|
-
execute: (input: StandardSchemaV1.InferInput<any>, shared: SilgiDefaultShared, event: SilgiEvent) => Promise<StandardSchemaV1.InferInput<any>>;
|
|
720
|
-
}
|
|
721
|
-
type MethodResponse<T> = {
|
|
722
|
-
success: true;
|
|
723
|
-
data: T;
|
|
724
|
-
cached?: boolean;
|
|
725
|
-
} | {
|
|
726
|
-
success: false;
|
|
727
|
-
error: {
|
|
728
|
-
code: string;
|
|
729
|
-
message: string;
|
|
730
|
-
details?: Record<string, unknown>;
|
|
731
|
-
};
|
|
732
|
-
};
|
|
733
|
-
|
|
734
|
-
declare function silgi(event?: SilgiEvent | Record<string, any>): {
|
|
735
|
-
execute: <TURI extends keyof SilgiURIs>(uriString: TURI, input: ExtractInputFromURI<TURI>) => Promise<MethodResponse<ExtractOutputFromURI<TURI>>>;
|
|
736
|
-
};
|
|
737
|
-
|
|
738
|
-
type SilgiServiceInterface<T extends BaseSchemaType<StandardSchemaV1>> = {
|
|
739
|
-
[Action in keyof T]: T[Action] extends Record<string, any> ? {
|
|
740
|
-
[Method in keyof T[Action]]: {
|
|
741
|
-
input: T[Action][Method]['input'];
|
|
742
|
-
output: T[Action][Method]['output'];
|
|
743
|
-
router: T[Action][Method]['router'];
|
|
744
|
-
};
|
|
745
|
-
} : never;
|
|
746
|
-
};
|
|
747
|
-
type ServiceType<T> = Partial<{
|
|
748
|
-
[Namespace in keyof T]: T[Namespace] extends Record<string, any> ? {
|
|
749
|
-
[Service in keyof T[Namespace]]?: MethodHandlerType<T[Namespace][Service]>;
|
|
750
|
-
} : never;
|
|
751
|
-
}>;
|
|
752
|
-
type RequiredServiceType<T> = {
|
|
753
|
-
[K in keyof T]-?: T[K] extends Record<string, any> ? {
|
|
754
|
-
[P in keyof T[K]]-?: MethodHandlerType<T[K][P]>;
|
|
755
|
-
} : never;
|
|
756
|
-
};
|
|
757
|
-
/**
|
|
758
|
-
* const test: ResolvedServiceType = {
|
|
759
|
-
aaa: {
|
|
760
|
-
bbb: {
|
|
761
|
-
delete: {
|
|
762
|
-
storage: {
|
|
763
|
-
handler: () => {}
|
|
764
|
-
},
|
|
765
|
-
},
|
|
766
|
-
},
|
|
767
|
-
},
|
|
768
|
-
}
|
|
769
|
-
*/
|
|
770
|
-
type ResolvedServiceType = {
|
|
771
|
-
[K in string]: {
|
|
772
|
-
[P in string]: {
|
|
773
|
-
[Q in BaseSilgiMethodType]?: {
|
|
774
|
-
[M in string]: ResolvedMethodHandlerType;
|
|
775
|
-
};
|
|
776
|
-
};
|
|
777
|
-
};
|
|
778
|
-
};
|
|
779
|
-
|
|
780
|
-
interface Silgi {
|
|
781
|
-
schemas: any;
|
|
782
|
-
services: ResolvedServiceType;
|
|
783
|
-
shared: SilgiDefaultShared;
|
|
784
|
-
uris: Record<string, any>;
|
|
785
|
-
scannedHandlers: Map<string, ResolvedMethodHandlerType>;
|
|
786
|
-
/**
|
|
787
|
-
*
|
|
788
|
-
* @private
|
|
789
|
-
*/
|
|
790
|
-
_initializedModules: Record<string, SilgiModule>;
|
|
791
|
-
_ignore?: Ignore;
|
|
792
|
-
_version: string;
|
|
793
|
-
hooks: Hookable<SilgiHooks & DefaultHooks>;
|
|
794
|
-
hooksNames: string[];
|
|
795
|
-
hook: Silgi['hooks']['hook'];
|
|
796
|
-
callHook: Silgi['hooks']['callHook'];
|
|
797
|
-
addHooks: Silgi['hooks']['addHooks'];
|
|
798
|
-
ready: () => Promise<void>;
|
|
799
|
-
close: () => Promise<void>;
|
|
800
|
-
logger: ConsolaInstance;
|
|
801
|
-
storage: Storage;
|
|
802
|
-
options: SilgiOptions;
|
|
803
|
-
}
|
|
804
|
-
interface SilgiConfig extends Pick<Silgi, 'services' | 'shared' | 'uris' | 'schemas' | '_initializedModules'> {
|
|
805
|
-
options: DeepPartial<SilgiOptions>;
|
|
806
820
|
}
|
|
807
|
-
type
|
|
821
|
+
type ModuleConfigurations = SilgiModuleMethods;
|
|
808
822
|
|
|
809
|
-
export {
|
|
823
|
+
export type { ResolvedServiceType as $, AppConfig as A, BaseSchemaType as B, CreateScope as C, DefaultNamespaces as D, ModuleSetupReturn as E, SilgiModule as F, ModuleConfigurations as G, SilgiOperation as H, SilgiPreset as I, SilgiPresetMeta as J, MethodSchemaType as K, LoadConfigOptions as L, ModuleMeta as M, EventHandlerResponse as N, MethodHandlerType as O, ResolvedMethodHandlerType as P, MethodResponse as Q, ResolvedModuleMeta as R, SilgiServiceInterface as S, TSReference as T, SilgiAppPlugin as U, CapturedErrorContext as V, CaptureError as W, SilgiSchema as X, MergedSilgiSchema as Y, ServiceType as Z, RequiredServiceType as _, SilgiCLIOptions as a, SilgiDefaultShared as a0, SilgiModuleShared as a1, ExtendShared as a2, FrameworkContext as a3, Silgi as a4, SilgiConfig as a5, SilgiFunction as a6, ImportItem as a7, SilgiCLI as a8, SilgiCLIDynamicConfig as a9, SilgiFrameworkInfo as aa, NitroBuildInfo as ab, SilgiURIs as ac, URIsTypes as ad, ExtractInputFromURI as ae, ExtractOutputFromURI as af, ExtractRouterParamsFromURI as ag, StorageMounts as ah, SilgiStorageBase as ai, StorageKeyGenerator as aj, StorageConfig as ak, StorageKeyParams as al, SilgiCLIConfig as b, SilgiCLIHooks as c, SilgiCompatibilityIssue as d, SilgiCompatibilityIssues as e, SilgiOptions as f, SilgiEvent as g, SilgiMethods as h, SilgiNamespaces as i, SilgiRouterTypes as j, SilgiHook as k, BaseSilgiMethodType as l, DefaultHooks as m, DeepPartial as n, Awaitable as o, SilgiHooks as p, SilgiModules as q, SilgiModuleMethods as r, SilgiModuleOptions as s, SilgiModuleInput as t, SilgiCompatibility as u, ModuleHookContext as v, ModuleOptions as w, ResolvedModuleOptions as x, ModuleDefinition as y, ModuleSetupInstallResult as z };
|