silgi 0.4.12 → 0.5.0
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/_chunks/index.mjs +1 -1
- package/dist/cli/prepare.mjs +5 -0
- package/dist/core/index.d.mts +183 -36
- package/dist/core/index.d.ts +183 -36
- package/dist/core/index.mjs +308 -107
- package/dist/kit/index.d.mts +6 -3
- package/dist/kit/index.d.ts +6 -3
- package/dist/kit/index.mjs +24 -1
- package/dist/meta/index.d.mts +1 -1
- package/dist/meta/index.d.ts +1 -1
- package/dist/presets/_types.gen.d.ts +1 -1
- package/dist/runtime/internal/nitro.mjs +46 -35
- package/dist/shared/{silgi.yr8vHHvd.d.ts → silgi.CN_giHTc.d.mts} +67 -267
- package/dist/shared/{silgi.DQSwjP5u.d.mts → silgi.CN_giHTc.d.ts} +67 -267
- package/dist/shared/{silgi.40ZJYm8F.d.mts → silgi.DGmIWx95.d.mts} +2 -2
- package/dist/shared/{silgi.40ZJYm8F.d.ts → silgi.DGmIWx95.d.ts} +2 -2
- package/dist/types/index.d.mts +196 -9
- package/dist/types/index.d.ts +196 -9
- package/package.json +1 -1
|
@@ -2,19 +2,18 @@ import { Defu } from 'defu';
|
|
|
2
2
|
import { TypeSource, IResolvers } from '@graphql-tools/utils';
|
|
3
3
|
import { TSConfig } from 'pkg-types';
|
|
4
4
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
5
|
-
import {
|
|
5
|
+
import { LogLevel, ConsolaInstance } from 'consola';
|
|
6
6
|
import { Hookable } from 'hookable';
|
|
7
|
-
import {
|
|
7
|
+
import { Options, Ignore } from 'ignore';
|
|
8
8
|
import { PresetOptions, PresetName, PresetNameInput } from 'silgi/presets';
|
|
9
|
-
import { StorageMounts
|
|
9
|
+
import { StorageMounts, SilgiFrameworkInfo as SilgiFrameworkInfo$1, ResolvedServiceType, SilgiDefaultShared, SilgiModules as SilgiModules$1, ModuleMeta as ModuleMeta$1 } from 'silgi/types';
|
|
10
10
|
import { Unimport } from 'unimport';
|
|
11
|
-
import {
|
|
11
|
+
import { Storage } from 'unstorage';
|
|
12
12
|
import { ResolvedConfig, ConfigWatcher, C12InputConfig, WatchConfigOptions } from 'c12';
|
|
13
13
|
import { ChokidarOptions } from 'chokidar';
|
|
14
14
|
import { DateString, CompatibilityDates, CompatibilityDateSpec } from 'compatx';
|
|
15
15
|
import { UnimportPluginOptions } from 'unimport/unplugin';
|
|
16
16
|
import { ProviderName } from 'std-env';
|
|
17
|
-
import { s as silgi, u as useStorage } from './silgi.40ZJYm8F.mjs';
|
|
18
17
|
|
|
19
18
|
type HookResult = Promise<void> | void;
|
|
20
19
|
|
|
@@ -29,12 +28,6 @@ interface SilgiCompatibilityIssues extends Array<SilgiCompatibilityIssue> {
|
|
|
29
28
|
toString: () => string;
|
|
30
29
|
}
|
|
31
30
|
|
|
32
|
-
/**
|
|
33
|
-
* Bu nitrojs, h3 event or request context.
|
|
34
|
-
*/
|
|
35
|
-
interface SilgiEvent extends Record<string, unknown> {
|
|
36
|
-
}
|
|
37
|
-
|
|
38
31
|
interface SilgiSchema {
|
|
39
32
|
}
|
|
40
33
|
interface MergedSilgiSchema {
|
|
@@ -86,256 +79,6 @@ type ExtractInputFromURI<TURI extends keyof SilgiURIs> = GetInput<ExtractPath<TU
|
|
|
86
79
|
type ExtractOutputFromURI<TURI extends keyof SilgiURIs> = GetOutput<ExtractPath<TURI>>;
|
|
87
80
|
type ExtractRouterParamsFromURI<TURI extends keyof SilgiURIs> = GetRouterParams<ExtractPath<TURI>>;
|
|
88
81
|
|
|
89
|
-
/**
|
|
90
|
-
* @example
|
|
91
|
-
* namespace: 'coreApi'
|
|
92
|
-
* serviceName: 'basket'
|
|
93
|
-
* method: 'post'
|
|
94
|
-
* action: 'createBasket'
|
|
95
|
-
*/
|
|
96
|
-
interface SilgiOperation {
|
|
97
|
-
/**
|
|
98
|
-
* 'coreApi'
|
|
99
|
-
* 'storageApi'
|
|
100
|
-
*/
|
|
101
|
-
namespaceName: keyof DefaultNamespaces;
|
|
102
|
-
/**
|
|
103
|
-
* 'basket'
|
|
104
|
-
* 'user'
|
|
105
|
-
*/
|
|
106
|
-
serviceName: string;
|
|
107
|
-
/**
|
|
108
|
-
* 'post'
|
|
109
|
-
* 'delete'
|
|
110
|
-
*/
|
|
111
|
-
methodName: string;
|
|
112
|
-
/**
|
|
113
|
-
* 'createBasket'
|
|
114
|
-
* 'deleteUser'
|
|
115
|
-
*/
|
|
116
|
-
actionName: string;
|
|
117
|
-
/**
|
|
118
|
-
* 'coreApi/basket/post/createBasket'
|
|
119
|
-
*/
|
|
120
|
-
raw: string;
|
|
121
|
-
/**
|
|
122
|
-
* '/book/basket/getAllBaskets'
|
|
123
|
-
*/
|
|
124
|
-
uri: keyof SilgiURIs;
|
|
125
|
-
/**
|
|
126
|
-
* ['coreApi', 'book', 'basket', 'getAllBaskets']
|
|
127
|
-
*/
|
|
128
|
-
parts: string[];
|
|
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
|
-
*/
|
|
137
|
-
query?: Record<string, string>;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
type CustomDriverName = string & {
|
|
141
|
-
_custom?: any;
|
|
142
|
-
};
|
|
143
|
-
interface StorageMounts {
|
|
144
|
-
[path: string]: {
|
|
145
|
-
driver: BuiltinDriverName | CustomDriverName;
|
|
146
|
-
[option: string]: any;
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
interface SilgiStorageBase {
|
|
150
|
-
}
|
|
151
|
-
type StorageKeyGenerator<TInput> = (input: TInput) => string | Promise<string>;
|
|
152
|
-
interface StorageConfig<TInput> {
|
|
153
|
-
options: TransactionOptions;
|
|
154
|
-
base: '/memory:cache' | keyof SilgiStorageBase;
|
|
155
|
-
key?: StorageKeyGenerator<TInput>;
|
|
156
|
-
scope?: 'request' | 'global';
|
|
157
|
-
}
|
|
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'>;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
interface SilgiOptions {
|
|
167
|
-
consolaOptions?: Partial<ConsolaOptions>;
|
|
168
|
-
builder: 'nuxt' | 'nitrojs';
|
|
169
|
-
/**
|
|
170
|
-
* Set to `true` to enable debug mode.
|
|
171
|
-
*
|
|
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
|
|
175
|
-
*/
|
|
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 {
|
|
195
|
-
/**
|
|
196
|
-
* Called after Silgi initialization, when the Silgi instance is ready to work.
|
|
197
|
-
* @param silgi The configured Silgi object
|
|
198
|
-
* @returns Promise
|
|
199
|
-
*/
|
|
200
|
-
'ready': (silgi: Silgi) => HookResult;
|
|
201
|
-
/**
|
|
202
|
-
* Called when silgi instance is gracefully closing.
|
|
203
|
-
* @param silgi The configured silgi object
|
|
204
|
-
* @returns Promise
|
|
205
|
-
*/
|
|
206
|
-
'close': (silgi: Silgi) => HookResult;
|
|
207
|
-
'app:setup:start': (silgi: Silgi) => HookResult;
|
|
208
|
-
'action:before': (context: ModuleHookContext) => HookResult;
|
|
209
|
-
'action:after': (context: ModuleHookContext) => HookResult;
|
|
210
|
-
'action:error': (context: ModuleHookContext) => HookResult;
|
|
211
|
-
'action: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
82
|
interface SilgiMethods {
|
|
340
83
|
}
|
|
341
84
|
interface SilgiNamespaces {
|
|
@@ -354,7 +97,7 @@ type DeepPartial<T> = T extends void ? T : T extends Record<string, any> ? {
|
|
|
354
97
|
} : T;
|
|
355
98
|
type Awaitable<T> = T | Promise<T>;
|
|
356
99
|
interface CreateScope {
|
|
357
|
-
execute: <TURI extends keyof SilgiURIs>(uriString: TURI, input: ExtractInputFromURI<TURI>) => Promise<
|
|
100
|
+
execute: <TURI extends keyof SilgiURIs>(uriString: TURI, input: ExtractInputFromURI<TURI>) => Promise<ExtractOutputFromURI<TURI>>;
|
|
358
101
|
}
|
|
359
102
|
|
|
360
103
|
type SilgiPreset = SilgiCLIConfig | (() => SilgiCLIConfig);
|
|
@@ -391,8 +134,8 @@ interface SilgiCLIOptions extends PresetOptions {
|
|
|
391
134
|
logLevel: LogLevel;
|
|
392
135
|
appConfig: AppConfig;
|
|
393
136
|
appConfigFiles: string[];
|
|
394
|
-
storage: StorageMounts
|
|
395
|
-
devStorage: StorageMounts
|
|
137
|
+
storage: StorageMounts;
|
|
138
|
+
devStorage: StorageMounts;
|
|
396
139
|
workspaceDir: string;
|
|
397
140
|
rootDir: string;
|
|
398
141
|
srcDir: string;
|
|
@@ -574,8 +317,8 @@ interface ImportItem {
|
|
|
574
317
|
}
|
|
575
318
|
interface SilgiCLI {
|
|
576
319
|
_ignore?: Ignore;
|
|
577
|
-
services: ResolvedServiceType
|
|
578
|
-
shareds: SilgiDefaultShared
|
|
320
|
+
services: ResolvedServiceType;
|
|
321
|
+
shareds: SilgiDefaultShared;
|
|
579
322
|
uris: Record<string, any>;
|
|
580
323
|
schemas: Record<string, any>;
|
|
581
324
|
modulesURIs: Partial<Record<keyof SilgiModules$1, any>>;
|
|
@@ -721,6 +464,63 @@ interface SilgiCLIHooks {
|
|
|
721
464
|
}) => HookResult;
|
|
722
465
|
}
|
|
723
466
|
|
|
467
|
+
/**
|
|
468
|
+
* Bu nitrojs, h3 event or request context.
|
|
469
|
+
*/
|
|
470
|
+
interface SilgiEvent extends Record<string, unknown> {
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* @example
|
|
475
|
+
* namespace: 'coreApi'
|
|
476
|
+
* serviceName: 'basket'
|
|
477
|
+
* method: 'post'
|
|
478
|
+
* action: 'createBasket'
|
|
479
|
+
*/
|
|
480
|
+
interface SilgiOperation {
|
|
481
|
+
/**
|
|
482
|
+
* 'coreApi'
|
|
483
|
+
* 'storageApi'
|
|
484
|
+
*/
|
|
485
|
+
namespaceName: keyof DefaultNamespaces;
|
|
486
|
+
/**
|
|
487
|
+
* 'basket'
|
|
488
|
+
* 'user'
|
|
489
|
+
*/
|
|
490
|
+
serviceName: string;
|
|
491
|
+
/**
|
|
492
|
+
* 'post'
|
|
493
|
+
* 'delete'
|
|
494
|
+
*/
|
|
495
|
+
methodName: string;
|
|
496
|
+
/**
|
|
497
|
+
* 'createBasket'
|
|
498
|
+
* 'deleteUser'
|
|
499
|
+
*/
|
|
500
|
+
actionName: string;
|
|
501
|
+
/**
|
|
502
|
+
* 'coreApi/basket/post/createBasket'
|
|
503
|
+
*/
|
|
504
|
+
raw: string;
|
|
505
|
+
/**
|
|
506
|
+
* '/book/basket/getAllBaskets'
|
|
507
|
+
*/
|
|
508
|
+
uri: keyof SilgiURIs;
|
|
509
|
+
/**
|
|
510
|
+
* ['coreApi', 'book', 'basket', 'getAllBaskets']
|
|
511
|
+
*/
|
|
512
|
+
parts: string[];
|
|
513
|
+
/**
|
|
514
|
+
* {id: '123', name: 'John', bookId: '456', authorId: '789'}
|
|
515
|
+
*/
|
|
516
|
+
routerParams?: Record<string, string | undefined>;
|
|
517
|
+
/**
|
|
518
|
+
* url ?limit=10&page=1
|
|
519
|
+
* {limit: '10', page: '1'}
|
|
520
|
+
*/
|
|
521
|
+
query?: Record<string, string>;
|
|
522
|
+
}
|
|
523
|
+
|
|
724
524
|
interface SilgiModules {
|
|
725
525
|
}
|
|
726
526
|
interface SilgiModuleMethods {
|
|
@@ -831,4 +631,4 @@ interface SilgiModule<TOptions extends ModuleOptions = ModuleOptions, TOptionsDe
|
|
|
831
631
|
}
|
|
832
632
|
type ModuleConfigurations = SilgiModuleMethods;
|
|
833
633
|
|
|
834
|
-
export type {
|
|
634
|
+
export type { AppConfig as A, BaseSchemaType as B, CreateScope as C, DefaultHooks as D, ModuleSetupReturn as E, SilgiPreset as F, SilgiPresetMeta as G, HookResult as H, SilgiSchema as I, MergedSilgiSchema as J, ImportItem as K, LoadConfigOptions as L, ModuleOptions as M, SilgiCLI as N, SilgiCLIDynamicConfig as O, SilgiFrameworkInfo as P, NitroBuildInfo as Q, ResolvedModuleMeta as R, SilgiModule as S, TSReference as T, SilgiURIs as U, URIsTypes as V, ExtractInputFromURI as W, ExtractOutputFromURI as X, ExtractRouterParamsFromURI as Y, ModuleDefinition as a, SilgiOperation as b, SilgiEvent as c, ModuleConfigurations as d, BaseSilgiMethodType as e, SilgiModules as f, SilgiModuleOptions as g, DeepPartial as h, ModuleHookContext as i, DefaultNamespaces as j, SilgiCLIOptions as k, SilgiCLIConfig as l, SilgiCLIHooks as m, SilgiCompatibilityIssue as n, SilgiCompatibilityIssues as o, SilgiMethods as p, SilgiNamespaces as q, SilgiRouterTypes as r, SilgiHook as s, Awaitable as t, SilgiModuleMethods as u, SilgiModuleInput as v, SilgiCompatibility as w, ModuleMeta as x, ResolvedModuleOptions as y, ModuleSetupInstallResult as z };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { SilgiEvent, SilgiURIs, ExtractInputFromURI,
|
|
1
|
+
import { SilgiEvent, SilgiURIs, ExtractInputFromURI, ExtractOutputFromURI, Silgi, StorageConfig } from 'silgi/types';
|
|
2
2
|
import { Storage, StorageValue } from 'unstorage';
|
|
3
3
|
|
|
4
4
|
declare function silgi(event?: SilgiEvent | Record<string, any>): {
|
|
5
|
-
execute: <TURI extends keyof SilgiURIs>(uriString: TURI, input: ExtractInputFromURI<TURI>) => Promise<
|
|
5
|
+
execute: <TURI extends keyof SilgiURIs>(uriString: TURI, input: ExtractInputFromURI<TURI>) => Promise<ExtractOutputFromURI<TURI>>;
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
declare function createStorage(silgi: Silgi): Promise<Storage<StorageValue>>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { SilgiEvent, SilgiURIs, ExtractInputFromURI,
|
|
1
|
+
import { SilgiEvent, SilgiURIs, ExtractInputFromURI, ExtractOutputFromURI, Silgi, StorageConfig } from 'silgi/types';
|
|
2
2
|
import { Storage, StorageValue } from 'unstorage';
|
|
3
3
|
|
|
4
4
|
declare function silgi(event?: SilgiEvent | Record<string, any>): {
|
|
5
|
-
execute: <TURI extends keyof SilgiURIs>(uriString: TURI, input: ExtractInputFromURI<TURI>) => Promise<
|
|
5
|
+
execute: <TURI extends keyof SilgiURIs>(uriString: TURI, input: ExtractInputFromURI<TURI>) => Promise<ExtractOutputFromURI<TURI>>;
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
declare function createStorage(silgi: Silgi): Promise<Storage<StorageValue>>;
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,22 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as AppConfig,
|
|
1
|
+
import { b as SilgiOperation, c as SilgiEvent, d as ModuleConfigurations, B as BaseSchemaType, e as BaseSilgiMethodType, f as SilgiModules, D as DefaultHooks, g as SilgiModuleOptions, h as DeepPartial, H as HookResult, i as ModuleHookContext, j as DefaultNamespaces } from '../shared/silgi.CN_giHTc.mjs';
|
|
2
|
+
export { A as AppConfig, t as Awaitable, C as CreateScope, W as ExtractInputFromURI, X as ExtractOutputFromURI, Y as ExtractRouterParamsFromURI, K as ImportItem, L as LoadConfigOptions, J as MergedSilgiSchema, a as ModuleDefinition, x as ModuleMeta, M as ModuleOptions, z as ModuleSetupInstallResult, E as ModuleSetupReturn, Q as NitroBuildInfo, R as ResolvedModuleMeta, y as ResolvedModuleOptions, N as SilgiCLI, l as SilgiCLIConfig, O as SilgiCLIDynamicConfig, m as SilgiCLIHooks, k as SilgiCLIOptions, w as SilgiCompatibility, n as SilgiCompatibilityIssue, o as SilgiCompatibilityIssues, P as SilgiFrameworkInfo, s as SilgiHook, p as SilgiMethods, S as SilgiModule, v as SilgiModuleInput, u as SilgiModuleMethods, q as SilgiNamespaces, F as SilgiPreset, G as SilgiPresetMeta, r as SilgiRouterTypes, I as SilgiSchema, U as SilgiURIs, T as TSReference, V as URIsTypes } from '../shared/silgi.CN_giHTc.mjs';
|
|
3
|
+
import { ConsolaOptions, ConsolaInstance } from 'consola';
|
|
4
|
+
import { PresetNameInput } from 'silgi/presets';
|
|
5
|
+
import { BuiltinDriverName, TransactionOptions, Storage } from 'unstorage';
|
|
6
|
+
import { Hookable } from 'hookable';
|
|
7
|
+
import { Ignore } from 'ignore';
|
|
8
|
+
import { u as useStorage, s as silgi } from '../shared/silgi.DGmIWx95.mjs';
|
|
3
9
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
4
10
|
import 'defu';
|
|
5
11
|
import '@graphql-tools/utils';
|
|
6
12
|
import 'pkg-types';
|
|
7
|
-
import 'consola';
|
|
8
|
-
import 'hookable';
|
|
9
|
-
import 'ignore';
|
|
10
|
-
import 'silgi/presets';
|
|
11
13
|
import 'silgi/types';
|
|
12
14
|
import 'unimport';
|
|
13
|
-
import 'unstorage';
|
|
14
15
|
import 'c12';
|
|
15
16
|
import 'chokidar';
|
|
16
17
|
import 'compatx';
|
|
17
18
|
import 'unimport/unplugin';
|
|
18
19
|
import 'std-env';
|
|
19
|
-
|
|
20
|
+
|
|
21
|
+
type CustomDriverName = string & {
|
|
22
|
+
_custom?: any;
|
|
23
|
+
};
|
|
24
|
+
interface StorageMounts {
|
|
25
|
+
[path: string]: {
|
|
26
|
+
driver: BuiltinDriverName | CustomDriverName;
|
|
27
|
+
[option: string]: any;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
interface SilgiStorageBase {
|
|
31
|
+
}
|
|
32
|
+
type StorageKeyGenerator<TInput> = (input: TInput) => string | Promise<string>;
|
|
33
|
+
interface StorageConfig<TInput> {
|
|
34
|
+
options: TransactionOptions;
|
|
35
|
+
base: '/memory:cache' | keyof SilgiStorageBase;
|
|
36
|
+
key?: StorageKeyGenerator<TInput>;
|
|
37
|
+
scope?: 'request' | 'global';
|
|
38
|
+
}
|
|
39
|
+
interface StorageKeyParams<TInput = unknown> {
|
|
40
|
+
operation: SilgiOperation;
|
|
41
|
+
input: TInput;
|
|
42
|
+
requestId?: string;
|
|
43
|
+
keyGenerator?: StorageKeyGenerator<TInput>;
|
|
44
|
+
storageOptions?: Pick<StorageConfig<TInput>, 'base' | 'options' | 'scope'>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface SilgiOptions {
|
|
48
|
+
consolaOptions?: Partial<ConsolaOptions>;
|
|
49
|
+
present: PresetNameInput;
|
|
50
|
+
/**
|
|
51
|
+
* Set to `true` to enable debug mode.
|
|
52
|
+
*
|
|
53
|
+
* At the moment, it prints out hook names and timings on the server, and logs hook arguments as well in the browser.
|
|
54
|
+
*
|
|
55
|
+
* @default false
|
|
56
|
+
*/
|
|
57
|
+
debug: boolean;
|
|
58
|
+
storage: StorageMounts;
|
|
59
|
+
[key: string]: any;
|
|
60
|
+
}
|
|
20
61
|
|
|
21
62
|
interface SilgiModuleContext extends Record<string, any> {
|
|
22
63
|
}
|
|
@@ -31,6 +72,152 @@ interface GraphQLJSON {
|
|
|
31
72
|
references: any;
|
|
32
73
|
}
|
|
33
74
|
|
|
75
|
+
interface SilgiDefaultShared extends SilgiModuleShared {
|
|
76
|
+
storage: (...data: Parameters<typeof useStorage>) => ReturnType<typeof useStorage>;
|
|
77
|
+
silgi: SilgiFunction;
|
|
78
|
+
}
|
|
79
|
+
interface SilgiModuleShared {
|
|
80
|
+
}
|
|
81
|
+
interface ExtendShared {
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface MethodSchemaType<Input, Output> {
|
|
85
|
+
default: {
|
|
86
|
+
input?: Input;
|
|
87
|
+
output: Output;
|
|
88
|
+
};
|
|
89
|
+
handler: (input: Input, shared: SilgiDefaultShared, event: SilgiEvent) => Promise<Output>;
|
|
90
|
+
modules?: Partial<ModuleConfigurations>;
|
|
91
|
+
storage?: StorageConfig<Input>;
|
|
92
|
+
}
|
|
93
|
+
type EventHandlerResponse<T = undefined> = T extends undefined ? void : void | T | Promise<T>;
|
|
94
|
+
type MethodHandlerType<T> = {
|
|
95
|
+
[Action in keyof T]: T[Action] extends Record<string, any> ? {
|
|
96
|
+
[Method in keyof T[Action]]: {
|
|
97
|
+
default?: {
|
|
98
|
+
input?: StandardSchemaV1.InferInput<T[Action][Method]['input']>;
|
|
99
|
+
output?: StandardSchemaV1.InferInput<T[Action][Method]['output']>;
|
|
100
|
+
};
|
|
101
|
+
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']>>;
|
|
102
|
+
modules?: Partial<ModuleConfigurations>;
|
|
103
|
+
storage?: StorageConfig<T[Action][Method]['input']>;
|
|
104
|
+
};
|
|
105
|
+
} : never;
|
|
106
|
+
};
|
|
107
|
+
interface ResolvedMethodHandlerType {
|
|
108
|
+
input?: Partial<BaseSchemaType<any>>;
|
|
109
|
+
output: Partial<BaseSchemaType<any>>;
|
|
110
|
+
handler: (router: StandardSchemaV1.InferInput<any>, input: StandardSchemaV1.InferInput<any>, shared: SilgiDefaultShared, event: SilgiEvent) => Promise<StandardSchemaV1.InferInput<any>>;
|
|
111
|
+
modules?: Partial<ModuleConfigurations>;
|
|
112
|
+
storage?: StorageConfig<StandardSchemaV1.InferInput<any>>;
|
|
113
|
+
execute: (input: StandardSchemaV1.InferInput<any>, shared: SilgiDefaultShared, event: SilgiEvent) => Promise<StandardSchemaV1.InferInput<any>>;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
type SilgiServiceInterface<T extends BaseSchemaType<StandardSchemaV1>> = {
|
|
117
|
+
[Action in keyof T]: T[Action] extends Record<string, any> ? {
|
|
118
|
+
[Method in keyof T[Action]]: {
|
|
119
|
+
input: T[Action][Method]['input'];
|
|
120
|
+
output: T[Action][Method]['output'];
|
|
121
|
+
router: T[Action][Method]['router'];
|
|
122
|
+
};
|
|
123
|
+
} : never;
|
|
124
|
+
};
|
|
125
|
+
type ServiceType<T> = Partial<{
|
|
126
|
+
[Namespace in keyof T]: T[Namespace] extends Record<string, any> ? {
|
|
127
|
+
[Service in keyof T[Namespace]]?: MethodHandlerType<T[Namespace][Service]>;
|
|
128
|
+
} : never;
|
|
129
|
+
}>;
|
|
130
|
+
type RequiredServiceType<T> = {
|
|
131
|
+
[K in keyof T]-?: T[K] extends Record<string, any> ? {
|
|
132
|
+
[P in keyof T[K]]-?: MethodHandlerType<T[K][P]>;
|
|
133
|
+
} : never;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* const test: ResolvedServiceType = {
|
|
137
|
+
aaa: {
|
|
138
|
+
bbb: {
|
|
139
|
+
delete: {
|
|
140
|
+
storage: {
|
|
141
|
+
handler: () => {}
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
}
|
|
147
|
+
*/
|
|
148
|
+
type ResolvedServiceType = {
|
|
149
|
+
[K in string]: {
|
|
150
|
+
[P in string]: {
|
|
151
|
+
[Q in BaseSilgiMethodType]?: {
|
|
152
|
+
[M in string]: ResolvedMethodHandlerType;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
interface FrameworkContext {
|
|
159
|
+
}
|
|
160
|
+
interface Silgi {
|
|
161
|
+
schemas: any;
|
|
162
|
+
services: ResolvedServiceType;
|
|
163
|
+
shared: SilgiDefaultShared;
|
|
164
|
+
uris: Record<string, any>;
|
|
165
|
+
modulesURIs: Partial<Record<keyof SilgiModules, any>>;
|
|
166
|
+
scannedHandlers: Map<string, ResolvedMethodHandlerType>;
|
|
167
|
+
plugins: SilgiAppPlugin[];
|
|
168
|
+
framework: FrameworkContext;
|
|
169
|
+
_ignore?: Ignore;
|
|
170
|
+
hooks: Hookable<SilgiHooks & DefaultHooks>;
|
|
171
|
+
hook: Silgi['hooks']['hook'];
|
|
172
|
+
callHook: Silgi['hooks']['callHook'];
|
|
173
|
+
addHooks: Silgi['hooks']['addHooks'];
|
|
174
|
+
ready: () => Promise<void>;
|
|
175
|
+
close: () => Promise<void>;
|
|
176
|
+
logger: ConsolaInstance;
|
|
177
|
+
storage: Storage;
|
|
178
|
+
options: SilgiOptions & SilgiModuleOptions;
|
|
179
|
+
captureError: CaptureError;
|
|
180
|
+
}
|
|
181
|
+
interface SilgiConfig extends Pick<Silgi, 'services' | 'shared' | 'uris' | 'schemas' | 'modulesURIs' | 'plugins' | 'framework'>, Partial<SilgiModuleOptions> {
|
|
182
|
+
options: DeepPartial<SilgiOptions>;
|
|
183
|
+
}
|
|
184
|
+
type SilgiFunction = typeof silgi;
|
|
185
|
+
|
|
186
|
+
interface SilgiAppPlugin {
|
|
187
|
+
(silgi: Silgi): Promise<void> | void;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
interface CapturedErrorContext {
|
|
191
|
+
event?: SilgiEvent;
|
|
192
|
+
[key: string]: unknown;
|
|
193
|
+
}
|
|
194
|
+
type CaptureError = (error: Error, context: CapturedErrorContext) => void;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* The listeners to Silgi
|
|
198
|
+
*/
|
|
199
|
+
interface SilgiHooks {
|
|
200
|
+
/**
|
|
201
|
+
* Called after Silgi initialization, when the Silgi instance is ready to work.
|
|
202
|
+
* @param silgi The configured Silgi object
|
|
203
|
+
* @returns Promise
|
|
204
|
+
*/
|
|
205
|
+
'ready': (silgi: Silgi) => HookResult;
|
|
206
|
+
/**
|
|
207
|
+
* Called when silgi instance is gracefully closing.
|
|
208
|
+
* @param silgi The configured silgi object
|
|
209
|
+
* @returns Promise
|
|
210
|
+
*/
|
|
211
|
+
'close': (silgi: Silgi) => HookResult;
|
|
212
|
+
'app:setup:start': (silgi: Silgi) => HookResult;
|
|
213
|
+
'action:before': (context: ModuleHookContext) => HookResult;
|
|
214
|
+
'action:after': (context: ModuleHookContext) => HookResult;
|
|
215
|
+
'action:error': (context: ModuleHookContext) => HookResult;
|
|
216
|
+
'action:finally': (context: ModuleHookContext) => HookResult;
|
|
217
|
+
'event:before': (event: SilgiEvent) => HookResult;
|
|
218
|
+
'error': CaptureError;
|
|
219
|
+
}
|
|
220
|
+
|
|
34
221
|
interface BaseNamespaceType extends Record<keyof DefaultNamespaces, Record<string, BaseSchemaType<StandardSchemaV1>>> {
|
|
35
222
|
}
|
|
36
223
|
type Namespaces<T extends BaseNamespaceType> = {
|
|
@@ -41,4 +228,4 @@ type Namespaces<T extends BaseNamespaceType> = {
|
|
|
41
228
|
|
|
42
229
|
declare const autoImportTypes: string[];
|
|
43
230
|
|
|
44
|
-
export { type BaseNamespaceType, BaseSchemaType, DefaultNamespaces, type ExtendContext, type GraphQLJSON, type Namespaces, type SilgiModuleContext, SilgiServiceInterface, autoImportTypes };
|
|
231
|
+
export { type BaseNamespaceType, BaseSchemaType, BaseSilgiMethodType, type CaptureError, type CapturedErrorContext, DeepPartial, DefaultHooks, DefaultNamespaces, type EventHandlerResponse, type ExtendContext, type ExtendShared, type FrameworkContext, type GraphQLJSON, type MethodHandlerType, type MethodSchemaType, ModuleConfigurations, ModuleHookContext, type Namespaces, type RequiredServiceType, type ResolvedMethodHandlerType, type ResolvedServiceType, type ServiceType, type Silgi, type SilgiAppPlugin, type SilgiConfig, type SilgiDefaultShared, SilgiEvent, type SilgiFunction, type SilgiHooks, type SilgiModuleContext, SilgiModuleOptions, type SilgiModuleShared, SilgiModules, SilgiOperation, type SilgiOptions, type SilgiServiceInterface, type SilgiStorageBase, type StorageConfig, type StorageKeyGenerator, type StorageKeyParams, type StorageMounts, autoImportTypes };
|