silgi 0.0.14 → 0.1.2

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.
@@ -0,0 +1,871 @@
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 { Defu } from 'defu';
6
+ import { Router, H3Event } from 'h3';
7
+ import { TSConfig } from 'pkg-types';
8
+ import { z } from 'zod';
9
+ import { NitroApp } from 'nitropack/types';
10
+
11
+ interface SilgiEvent extends Record<string, unknown> {
12
+ }
13
+
14
+ interface SilgiURIs {
15
+ }
16
+ type URIsTypes<T extends Record<string, string>> = {
17
+ [K in keyof T]: string;
18
+ };
19
+ type ExtractPath<T extends string> = T extends `${infer Path}` ? Path extends `${infer Service}/${infer Entity}/${infer Method}/${infer Action}` ? {
20
+ service: Service;
21
+ entity: Entity;
22
+ method: Method;
23
+ action: Action;
24
+ } : never : never;
25
+ type GetInput<T extends {
26
+ service: string;
27
+ entity: string;
28
+ method: string;
29
+ action: string;
30
+ }> = T['service'] extends keyof SilgiServiceTypes ? T['entity'] extends keyof SilgiServiceTypes[T['service']] ? T['method'] extends keyof SilgiServiceTypes[T['service']][T['entity']] ? T['action'] extends keyof SilgiServiceTypes[T['service']][T['entity']][T['method']] ? SilgiServiceTypes[T['service']][T['entity']][T['method']][T['action']]['input'] : never : never : never : never;
31
+ type GetOutput<T extends {
32
+ service: string;
33
+ entity: string;
34
+ method: string;
35
+ action: string;
36
+ }> = T['service'] extends keyof SilgiServiceTypes ? T['entity'] extends keyof SilgiServiceTypes[T['service']] ? T['method'] extends keyof SilgiServiceTypes[T['service']][T['entity']] ? T['action'] extends keyof SilgiServiceTypes[T['service']][T['entity']][T['method']] ? SilgiServiceTypes[T['service']][T['entity']][T['method']][T['action']]['output'] : never : never : never : never;
37
+ type ExtractInputFromURI<TURI extends keyof SilgiURIs> = GetInput<ExtractPath<TURI>>;
38
+ type ExtractOutputFromURI<TURI extends keyof SilgiURIs> = GetOutput<ExtractPath<TURI>>;
39
+
40
+ interface SilgiHook {
41
+ }
42
+ interface SilgiServiceTypes {
43
+ }
44
+ interface MergeSilgiType {
45
+ }
46
+ interface DefaultHooks {
47
+ }
48
+ interface DefaultMethods {
49
+ get: string;
50
+ post: string;
51
+ put: string;
52
+ delete: string;
53
+ }
54
+ interface DefaultMethods {
55
+ get: string;
56
+ post: string;
57
+ put: string;
58
+ delete: string;
59
+ }
60
+ type DeepPartial<T> = T extends void ? T : T extends Record<string, any> ? {
61
+ [P in keyof T]?: DeepPartial<T[P]>;
62
+ } : T;
63
+ type Awaitable<T> = T | Promise<T>;
64
+ interface CreateScope {
65
+ execute: <TURI extends keyof SilgiURIs>(uriString: TURI, input: ExtractInputFromURI<TURI>) => Promise<MethodResponse<ExtractOutputFromURI<TURI>>>;
66
+ }
67
+
68
+ interface SilgiCompatibilityIssue {
69
+ name: string;
70
+ message: string;
71
+ }
72
+ interface SilgiCompatibilityIssues extends Array<SilgiCompatibilityIssue> {
73
+ /**
74
+ * Return formatted error message.
75
+ */
76
+ toString: () => string;
77
+ }
78
+
79
+ declare class SilgiHelper {
80
+ setEvent(key: string, value: any): void;
81
+ getEvent(key: string): any;
82
+ addH3App(router: Router): Promise<void>;
83
+ addNitroApp(nitro: NitroApp): Promise<void>;
84
+ /**
85
+ * [...router.ts] tum router tarayan ve ona gore isteklere yonlendiren alan.
86
+ */
87
+ handler(_request: Request | H3Event | Record<string, any>): Promise<void>;
88
+ }
89
+
90
+ interface SRNPartition {
91
+ }
92
+ interface SRNService {
93
+ }
94
+ interface SRNRegion {
95
+ }
96
+ interface SRNAccountId {
97
+ }
98
+ interface SRNResource {
99
+ }
100
+ interface SRN {
101
+ partition: string | undefined | SRNPartition;
102
+ service: string | undefined | SRNService;
103
+ region: string | undefined | SRNRegion;
104
+ accountId: string | undefined | SRNAccountId;
105
+ resource: string | undefined | SRNResource;
106
+ }
107
+
108
+ declare class SRNManager {
109
+ private readonly silgi;
110
+ constructor(silgi?: Silgi);
111
+ register(_srn: string): void;
112
+ handle(srn: string): SRN;
113
+ findService({ namespace, name }: {
114
+ namespace: string;
115
+ name: string;
116
+ }): any;
117
+ getAllServices(): any;
118
+ }
119
+
120
+ interface SilgiMethods {
121
+ }
122
+ interface SilgiNamespaces {
123
+ }
124
+ type BaseSilgiMethodType = 'post' | 'delete' | 'put' | 'get' | keyof SilgiMethods;
125
+ interface DefaultNamespaces extends SilgiNamespaces {
126
+ }
127
+
128
+ interface SilgiValidationSchema {
129
+ }
130
+ type ValidationLibrary = 'zod' | 'yup';
131
+ type SelectedValidationLibrary = SilgiValidationSchema extends {
132
+ validationLibrary: infer V;
133
+ } ? V extends ValidationLibrary ? V : 'zod' : 'zod';
134
+ /**
135
+ * A map of validation library names to their type definitions.
136
+ *
137
+ * @see {@link https://zod.dev/ | Zod}
138
+ * @see {@link https://github.com/jquense/yup | Yup}
139
+ */
140
+ interface SchemaTypes {
141
+ zod: z.ZodTypeAny;
142
+ yup: any;
143
+ }
144
+ type InferSchemaType<V extends SelectedValidationLibrary, T> = V extends 'zod' ? T extends z.ZodTypeAny ? z.infer<T> : never : V extends 'yup' ? any : never;
145
+ type BaseSchemaType<V extends SelectedValidationLibrary> = {
146
+ [Action in BaseSilgiMethodType]?: Record<string, {
147
+ input?: SchemaTypes[V];
148
+ output?: SchemaTypes[V];
149
+ }>;
150
+ };
151
+
152
+ /**
153
+ * @example
154
+ * namespace: 'coreApi'
155
+ * serviceName: 'basket'
156
+ * action: 'post'
157
+ * method: 'createBasket'
158
+ */
159
+ interface SilgiOperation {
160
+ /**
161
+ * 'coreApi'
162
+ * 'storageApi'
163
+ */
164
+ namespaceName: keyof DefaultNamespaces;
165
+ /**
166
+ * 'basket'
167
+ * 'user'
168
+ */
169
+ serviceName: string;
170
+ /**
171
+ * 'post'
172
+ * 'delete'
173
+ */
174
+ methodName: string;
175
+ /**
176
+ * 'createBasket'
177
+ * 'deleteUser'
178
+ */
179
+ actionName: string;
180
+ /**
181
+ * 'coreApi/basket/post/createBasket'
182
+ */
183
+ raw: keyof SilgiURIs;
184
+ parts: string[];
185
+ }
186
+
187
+ type CustomDriverName = string & {
188
+ _custom?: any;
189
+ };
190
+ interface StorageMounts {
191
+ [path: string]: {
192
+ driver: BuiltinDriverName | CustomDriverName;
193
+ [option: string]: any;
194
+ };
195
+ }
196
+ interface SilgiStorageBase {
197
+ }
198
+ type StorageKeyGenerator<TInput> = (input: TInput) => string | Promise<string>;
199
+ interface StorageConfig<TInput> {
200
+ options: TransactionOptions;
201
+ base: '/memory:cache' | keyof SilgiStorageBase;
202
+ key?: StorageKeyGenerator<TInput>;
203
+ scope?: 'request' | 'global';
204
+ }
205
+
206
+ interface SilgiEventContext {
207
+ _context: any;
208
+ silgi: Silgi;
209
+ namespace?: string;
210
+ serviceName?: string;
211
+ methodName?: string;
212
+ }
213
+ interface SilgiOptions {
214
+ /**
215
+ * @default 'nitrojs'
216
+ */
217
+ environment?: ('nitrojs' | 'h3' | 'undefined');
218
+ validationLibrary?: ValidationLibrary;
219
+ isPackage: boolean;
220
+ /**
221
+ *
222
+ * @private
223
+ */
224
+ _eventContext?: Map<string, SilgiEventContext>;
225
+ /**
226
+ *
227
+ * @private
228
+ */
229
+ _requiredModules: any;
230
+ srn: SRNManager;
231
+ consolaOptions?: Partial<ConsolaOptions>;
232
+ h3Router?: Router;
233
+ nitro?: NitroApp;
234
+ /**
235
+ * Define the root directory of your application.
236
+ *
237
+ * 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.
238
+ * It is normally not needed to configure this option.
239
+ *
240
+ * @default "/<rootDir>"
241
+ */
242
+ rootDir: string;
243
+ /**
244
+ *
245
+ * default "/<rootDir>/.silgi"
246
+ */
247
+ buildDir: string;
248
+ builder: 'nuxt' | 'nitrojs';
249
+ /**
250
+ * @default ['.js', '.mjs', '.ts']
251
+ */
252
+ extensions?: string[];
253
+ /**
254
+ *
255
+ * @private
256
+ */
257
+ _silgiConfigFile: any;
258
+ /**
259
+ *
260
+ * @private
261
+ */
262
+ _silgiConfigFiles: Array<any>;
263
+ /**
264
+ * Modules are Nuxt extensions which can extend its core functionality and add endless integrations.
265
+ *
266
+ * Each module is either a string (which can refer to a package, or be a path to a file), a tuple with the module as first string and the options as a second object, or an inline module function.
267
+ * 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.
268
+ *
269
+ *
270
+ * @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/`
271
+ * directory are executed, and they load in alphabetical order.
272
+ *
273
+ * @example
274
+ * ```js
275
+ * modules: [
276
+ * // Using package name
277
+ * '@nuxtjs/axios',
278
+ * // Relative to your project srcDir
279
+ * '~/modules/awesome.js',
280
+ * // Providing options
281
+ * ['@nuxtjs/google-analytics', { ua: 'X1234567' }],
282
+ * // Inline definition
283
+ * function () {}
284
+ * ]
285
+ * ```
286
+ */
287
+ modules: (SilgiModule<any> | string | [SilgiModule | string, Record<string, any>] | undefined | null | false)[];
288
+ modulesDir: Array<string>;
289
+ /**
290
+ *
291
+ * @private
292
+ */
293
+ _installedModules: Array<{
294
+ meta: ModuleMeta;
295
+ timings?: Record<string, number | undefined>;
296
+ entryPath?: string;
297
+ packageName: string;
298
+ active?: boolean;
299
+ }>;
300
+ silgiDir: string;
301
+ /**
302
+ *
303
+ * @private
304
+ */
305
+ _modules: Array<any>;
306
+ /**
307
+ * `future` is for early opting-in to new features that will become default in a future (possibly major) version of the framework.
308
+ *
309
+ */
310
+ future: {
311
+ /**
312
+ * This enables 'Bundler' module resolution mode for TypeScript, which is the recommended setting for frameworks like Nuxt and Vite.
313
+ *
314
+ * It improves type support when using modern libraries with `exports`.
315
+ * You can set it to false to use the legacy 'Node' mode, which is the default for TypeScript.
316
+ *
317
+ * @default true
318
+ *
319
+ * @see [TypeScript PR implementing `bundler` module resolution](https://github.com/microsoft/TypeScript/pull/51669)
320
+ */
321
+ typescriptBundlerResolution: boolean;
322
+ };
323
+ /**
324
+ * Configuration for Nuxt's TypeScript integration.
325
+ *
326
+ */
327
+ typescript: {
328
+ /**
329
+ * 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)
330
+ *
331
+ * @default true
332
+ */
333
+ strict: boolean;
334
+ /**
335
+ * Modules to generate deep aliases for within `compilerOptions.paths`. This does not yet support subpaths. It may be necessary when using Nuxt within a pnpm monorepo with `shamefully-hoist=false`.
336
+ *
337
+ * @default ["nitro/types","nitro/runtime","defu","h3","consola","ofetch","@unhead/vue","@nuxt/devtools","vue","@vue/runtime-core","@vue/compiler-sfc","vue-router","vue-router/auto-routes","unplugin-vue-router/client","@nuxt/schema","nuxt"]
338
+ */
339
+ hoist: Array<string>;
340
+ /**
341
+ * Include parent workspace in the Nuxt project. Mostly useful for themes and module authors.
342
+ *
343
+ * @default false
344
+ */
345
+ includeWorkspace: boolean;
346
+ /**
347
+ * Enable build-time type checking.
348
+ *
349
+ * If set to true, this will type check in development. You can restrict this to build-time type checking by setting it to `build`. Requires to install `typescript` and `vue-tsc` as dev dependencies.
350
+ *
351
+ * @default false
352
+ *
353
+ * @see [Nuxt TypeScript docs](https://nuxt.com/docs/guide/concepts/typescript)
354
+ */
355
+ typeCheck: boolean | 'build';
356
+ /**
357
+ * You can extend generated `.nuxt/tsconfig.json` using this option.
358
+ *
359
+ */
360
+ tsConfig: TSConfig;
361
+ /**
362
+ * Generate a `*.vue` shim.
363
+ *
364
+ * We recommend instead letting the [official Vue extension](https://marketplace.visualstudio.com/items?itemName=Vue.volar) generate accurate types for your components.
365
+ * Note that you may wish to set this to `true` if you are using other libraries, such as ESLint, that are unable to understand the type of `.vue` files.
366
+ *
367
+ * @default false
368
+ */
369
+ shim: boolean;
370
+ };
371
+ /**
372
+ * Whether Nuxt is running in development mode.
373
+ *
374
+ * Normally, you should not need to set this.
375
+ *
376
+ * @default false
377
+ */
378
+ dev: boolean;
379
+ /**
380
+ * Whether your app is being unit tested.
381
+ *
382
+ * @default false
383
+ */
384
+ test: boolean;
385
+ /**
386
+ * Set to `true` to enable debug mode.
387
+ *
388
+ * At the moment, it prints out hook names and timings on the server, and logs hook arguments as well in the browser.
389
+ *
390
+ * @default false
391
+ */
392
+ debug: boolean;
393
+ namespaces: string[];
394
+ /**
395
+ * Define the server directory of your Nuxt application, where Nitro routes, middleware and plugins are kept.
396
+ *
397
+ * If a relative path is specified, it will be relative to your `rootDir`.
398
+ *
399
+ * @default "/<rootDir>/server"
400
+ */
401
+ serverDir: string;
402
+ /**
403
+ * Define the server directory of your Nuxt application, where Nitro routes, middleware and plugins are kept.
404
+ *
405
+ * If a relative path is specified, it will be relative to your `rootDir`.
406
+ *
407
+ * @default "/<rootDir>/app"
408
+ */
409
+ clientDir: string;
410
+ /**
411
+ * Customize default directory structure used by Nuxt.
412
+ *
413
+ * It is better to stick with defaults unless needed.
414
+ *
415
+ */
416
+ dir: {
417
+ /** @default "/<srcDir>" */
418
+ client: string;
419
+ /**
420
+ * The modules directory, each file in which will be auto-registered as a Nuxt module.
421
+ *
422
+ * @default "/<serverDir>/silgi/modules"
423
+ */
424
+ modules: string;
425
+ /**
426
+ * The shared directory. This directory is shared between the app and the server.
427
+ *
428
+ * @default "/<rootDir>/shared"
429
+ */
430
+ shared: string;
431
+ /**
432
+ * The directory containing your static files, which will be directly accessible via the Nuxt server and copied across into your `dist` folder when your app is generated.
433
+ *
434
+ * @default "/<rootDir>/public"
435
+ */
436
+ public: string;
437
+ };
438
+ /**
439
+ * More customizable than `ignorePrefix`: all files matching glob patterns specified inside the `ignore` array will be ignored in building.
440
+ *
441
+ * @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","**\/-*.*"]
442
+ */
443
+ ignore: Array<string>;
444
+ helper: SilgiHelper;
445
+ storage: StorageMounts;
446
+ [key: string]: any;
447
+ }
448
+
449
+ type HookResult = Promise<void> | void;
450
+ type TSReference = {
451
+ types: string;
452
+ } | {
453
+ path: string;
454
+ };
455
+ /**
456
+ * The listeners to Silgi
457
+ */
458
+ interface SilgiHooks {
459
+ /**
460
+ * Called after Silgi initialization, when the Silgi instance is ready to work.
461
+ * @param silgi The configured Silgi object
462
+ * @returns Promise
463
+ */
464
+ 'ready': (silgi: Silgi) => HookResult;
465
+ /**
466
+ * Called when silgi instance is gracefully closing.
467
+ * @param silgi The configured silgi object
468
+ * @returns Promise
469
+ */
470
+ 'close': (silgi: Silgi) => HookResult;
471
+ 'app:setup:start': (silgi: Silgi) => HookResult;
472
+ 'method:before': (context: ModuleHookContext) => HookResult;
473
+ 'method:after': (context: ModuleHookContext) => HookResult;
474
+ 'method:error': (context: ModuleHookContext) => HookResult;
475
+ 'method:finally': (context: ModuleHookContext) => HookResult;
476
+ 'module:register:before': (module: SilgiModule) => HookResult;
477
+ 'module:register:after': (module: SilgiOptions['_installedModules'][number]) => HookResult;
478
+ 'module:setup:finish': (module: SilgiModule) => HookResult;
479
+ 'module:before:excute': (context: ModuleHookContext) => HookResult;
480
+ 'module:after:excute': (context: ModuleHookContext) => HookResult;
481
+ 'module:error': (context: ModuleHookContext) => HookResult;
482
+ 'event:before': (event: SilgiEvent) => HookResult;
483
+ 'h3:app:setup': (router: Router) => HookResult;
484
+ /**
485
+ * Allows extending compatibility checks.
486
+ * @param compatibility Compatibility object
487
+ * @param issues Issues to be mapped
488
+ * @returns Promise
489
+ */
490
+ 'kit:compatibility': (compatibility: SilgiCompatibility, issues: SilgiCompatibilityIssues) => HookResult;
491
+ /**
492
+ * 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`
493
+ * @param options Objects containing `references`, `declarations`, `tsConfig`
494
+ * @returns Promise
495
+ */
496
+ 'prepare:types': (options: {
497
+ references: TSReference[];
498
+ declarations: string[];
499
+ tsConfig: TSConfig;
500
+ }) => HookResult;
501
+ /**
502
+ * 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`
503
+ * @param options Objects containing `references`, `declarations`, `tsConfig`
504
+ * @returns Promise
505
+ */
506
+ 'prepare:core.ts': (options: {
507
+ importedItems: {
508
+ [key: string]: {
509
+ import: {
510
+ type?: boolean;
511
+ name: string;
512
+ }[];
513
+ from: string;
514
+ };
515
+ };
516
+ imports: string[];
517
+ uris: string[];
518
+ services: string[];
519
+ shareds: string[];
520
+ types: string[];
521
+ modules: string[];
522
+ }) => HookResult;
523
+ 'prepare:schema.ts': (options: {
524
+ importedItems: {
525
+ [key: string]: {
526
+ import: {
527
+ type?: boolean;
528
+ name: string;
529
+ }[];
530
+ from: string;
531
+ };
532
+ };
533
+ imports: string[];
534
+ configs: {
535
+ key: string;
536
+ value: string;
537
+ }[];
538
+ contexts: {
539
+ key: string;
540
+ value: string;
541
+ }[];
542
+ methods: {
543
+ key: string;
544
+ value: string;
545
+ }[];
546
+ shareds: {
547
+ key: string;
548
+ value: string;
549
+ }[];
550
+ events: {
551
+ key: string;
552
+ value: string;
553
+ extends?: boolean;
554
+ isSilgiContext?: boolean;
555
+ }[];
556
+ storeBase: string[];
557
+ }) => HookResult;
558
+ 'prepare:h3.d.ts': (options: {
559
+ importedItems: {
560
+ [key: string]: {
561
+ import: {
562
+ type?: boolean;
563
+ name: string;
564
+ }[];
565
+ from: string;
566
+ };
567
+ };
568
+ imports: string[];
569
+ }) => HookResult;
570
+ 'read:core.ts': (data: () => Awaitable<{
571
+ context: string;
572
+ object: {
573
+ uris?: string[];
574
+ services?: string[];
575
+ shareds?: string[];
576
+ };
577
+ path: string;
578
+ }>) => HookResult;
579
+ }
580
+
581
+ interface SilgiModules {
582
+ }
583
+ interface SilgiModuleMethods {
584
+ }
585
+ interface SilgiModuleOptions {
586
+ }
587
+ interface SilgiCompatibility {
588
+ /**
589
+ * Required silgi version in semver format.
590
+ * @example `^3.2.0` or `>=3.13.0`.
591
+ */
592
+ silgi?: string;
593
+ }
594
+ interface ModuleMeta {
595
+ /** Module name. */
596
+ name?: string;
597
+ /** Module description. */
598
+ description?: string;
599
+ /** Module author. */
600
+ author?: string;
601
+ /** Module license. */
602
+ license?: string;
603
+ /** exports */
604
+ exports?: {
605
+ interface?: {
606
+ config?: true;
607
+ shared?: true;
608
+ context?: true;
609
+ method?: true;
610
+ event?: true;
611
+ };
612
+ variable?: {
613
+ shared?: true;
614
+ };
615
+ };
616
+ /** Module version. */
617
+ version?: string;
618
+ /**
619
+ * The configuration key used within `silgi.config` for this module's options.
620
+ * For example, `@silgijs/axios` uses `axios`.
621
+ */
622
+ configKey?: string;
623
+ /**
624
+ * Constraints for the versions of silgi or features this module requires.
625
+ */
626
+ compatibility?: SilgiCompatibility;
627
+ readonly dependencies?: ReadonlyArray<string>;
628
+ [key: string]: unknown;
629
+ }
630
+ type ModuleHookContext = Readonly<{
631
+ event?: SilgiEvent;
632
+ operation?: SilgiOperation;
633
+ input?: unknown;
634
+ result?: unknown;
635
+ modules?: ModuleConfigurations;
636
+ config?: unknown;
637
+ timestamp?: number;
638
+ meta?: Record<string, unknown>;
639
+ error?: Error;
640
+ hookName?: string;
641
+ success?: boolean;
642
+ }>;
643
+ /** The options received. */
644
+ type ModuleOptions = Record<string, any>;
645
+ type Prettify<T> = {
646
+ [K in keyof T]: T[K];
647
+ } & {};
648
+ type ResolvedModuleOptions<TOptions extends ModuleOptions, TOptionsDefaults extends Partial<TOptions>> = Prettify<Defu<Partial<TOptions>, [
649
+ Partial<TOptions>,
650
+ TOptionsDefaults
651
+ ]>>;
652
+ interface ModuleDefinition<TOptions extends ModuleOptions, TOptionsDefaults extends Partial<TOptions>, TWith extends boolean> {
653
+ meta?: ModuleMeta;
654
+ defaults?: TOptionsDefaults | ((silgi: Silgi) => Awaitable<TOptionsDefaults>);
655
+ hooks?: Partial<SilgiHooks>;
656
+ cli?: (this: void, resolvedOptions: TWith extends true ? ResolvedModuleOptions<TOptions, TOptionsDefaults> : TOptions, silgi: Silgi) => ModuleSetupReturn;
657
+ setup?: (this: void, resolvedOptions: TWith extends true ? ResolvedModuleOptions<TOptions, TOptionsDefaults> : TOptions, silgi: Silgi) => ModuleSetupReturn;
658
+ }
659
+ interface ModuleSetupInstallResult {
660
+ /**
661
+ * Timing information for the initial setup
662
+ */
663
+ timings?: {
664
+ /** Total time took for module setup in ms */
665
+ setup?: number;
666
+ [key: string]: number | undefined;
667
+ };
668
+ }
669
+ type ModuleSetupReturn = Awaitable<false | void | ModuleSetupInstallResult>;
670
+ interface SilgiModule<TOptions extends ModuleOptions = ModuleOptions, TOptionsDefaults extends Partial<TOptions> = Partial<TOptions>, TWith extends boolean = false> {
671
+ (this: void, resolvedOptions: TWith extends true ? ResolvedModuleOptions<TOptions, TOptionsDefaults> : TOptions, silgi: Silgi, cli?: boolean): ModuleSetupReturn;
672
+ getOptions?: (inlineOptions?: Partial<TOptions>, silgi?: Silgi) => Promise<TWith extends true ? ResolvedModuleOptions<TOptions, TOptionsDefaults> : TOptions>;
673
+ getMeta?: () => Promise<ModuleMeta>;
674
+ cli?: (silgi: Silgi) => ModuleSetupReturn;
675
+ }
676
+ type ModuleConfiguration<K extends keyof SilgiModuleMethods = keyof SilgiModuleMethods> = SilgiModuleMethods[K];
677
+ type ModuleConfigurations = {
678
+ [K in keyof SilgiModuleMethods]?: ModuleConfiguration;
679
+ };
680
+
681
+ declare function useStorage<T extends StorageValue = StorageValue>(base?: StorageConfig<T>['base']): Storage<T>;
682
+
683
+ interface SilgiDefaultShared extends SilgiModuleShared {
684
+ storage: (...data: Parameters<typeof useStorage>) => ReturnType<typeof useStorage>;
685
+ silgi: SilgiFunction;
686
+ }
687
+ interface SilgiModuleShared {
688
+ }
689
+ interface ExtendShared {
690
+ }
691
+
692
+ type EventHandlerResponse<T = undefined> = T extends undefined ? void : void | T | Promise<T>;
693
+ type MethodHandlerType<T> = {
694
+ [Action in keyof T]: T[Action] extends Record<string, any> ? {
695
+ [Method in keyof T[Action]]: {
696
+ default?: {
697
+ input?: T[Action][Method]['input'] extends infer U ? U : never;
698
+ output?: T[Action][Method]['output'] extends infer U ? U : never;
699
+ };
700
+ handler: (input: T[Action][Method]['input'], shared: SilgiDefaultShared, event: SilgiEvent) => EventHandlerResponse<T[Action][Method]['output'] extends infer U ? U : undefined>;
701
+ modules?: ModuleConfigurations;
702
+ storage?: StorageConfig<T[Action][Method]['input']>;
703
+ };
704
+ } : never;
705
+ };
706
+ interface ResolvedMethodHandlerType {
707
+ input?: Partial<InferSchemaType<SelectedValidationLibrary, any>>;
708
+ output: Partial<InferSchemaType<SelectedValidationLibrary, any>>;
709
+ handler: (input: InferSchemaType<SelectedValidationLibrary, any>, shared: SilgiDefaultShared, event: SilgiEvent) => Promise<InferSchemaType<SelectedValidationLibrary, any>>;
710
+ modules?: ModuleConfigurations;
711
+ storage?: StorageConfig<InferSchemaType<SelectedValidationLibrary, any>>;
712
+ execute: (input: InferSchemaType<SelectedValidationLibrary, any>, shared: SilgiDefaultShared, event: SilgiEvent) => Promise<InferSchemaType<SelectedValidationLibrary, any>>;
713
+ }
714
+ type MethodResponse<T> = {
715
+ success: true;
716
+ data: T;
717
+ cached?: boolean;
718
+ } | {
719
+ success: false;
720
+ error: {
721
+ code: string;
722
+ message: string;
723
+ details?: Record<string, unknown>;
724
+ };
725
+ };
726
+
727
+ declare function silgi(event?: SilgiEvent | Record<string, any>): {
728
+ execute: <TURI extends keyof SilgiURIs>(uriString: TURI, input: ExtractInputFromURI<TURI>) => Promise<MethodResponse<(TURI extends `${infer Path}` ? Path extends `${infer Service}/${infer Entity}/${infer Method}/${infer Action}` ? {
729
+ service: Service;
730
+ entity: Entity;
731
+ method: Method;
732
+ action: Action;
733
+ } : never : never)["service"] extends never ? (TURI extends `${infer Path}` ? Path extends `${infer Service}/${infer Entity}/${infer Method}/${infer Action}` ? {
734
+ service: Service;
735
+ entity: Entity;
736
+ method: Method;
737
+ action: Action;
738
+ } : never : never)["entity"] extends keyof SilgiServiceTypes[(TURI extends `${infer Path}` ? Path extends `${infer Service}/${infer Entity}/${infer Method}/${infer Action}` ? {
739
+ service: Service;
740
+ entity: Entity;
741
+ method: Method;
742
+ action: Action;
743
+ } : never : never)["service"]] ? (TURI extends `${infer Path}` ? Path extends `${infer Service}/${infer Entity}/${infer Method}/${infer Action}` ? {
744
+ service: Service;
745
+ entity: Entity;
746
+ method: Method;
747
+ action: Action;
748
+ } : never : never)["method"] extends keyof SilgiServiceTypes[(TURI extends `${infer Path}` ? Path extends `${infer Service}/${infer Entity}/${infer Method}/${infer Action}` ? {
749
+ service: Service;
750
+ entity: Entity;
751
+ method: Method;
752
+ action: Action;
753
+ } : never : never)["service"]][(TURI extends `${infer Path}` ? Path extends `${infer Service}/${infer Entity}/${infer Method}/${infer Action}` ? {
754
+ service: Service;
755
+ entity: Entity;
756
+ method: Method;
757
+ action: Action;
758
+ } : never : never)["entity"]] ? (TURI extends `${infer Path}` ? Path extends `${infer Service}/${infer Entity}/${infer Method}/${infer Action}` ? {
759
+ service: Service;
760
+ entity: Entity;
761
+ method: Method;
762
+ action: Action;
763
+ } : never : never)["action"] extends keyof SilgiServiceTypes[(TURI extends `${infer Path}` ? Path extends `${infer Service}/${infer Entity}/${infer Method}/${infer Action}` ? {
764
+ service: Service;
765
+ entity: Entity;
766
+ method: Method;
767
+ action: Action;
768
+ } : never : never)["service"]][(TURI extends `${infer Path}` ? Path extends `${infer Service}/${infer Entity}/${infer Method}/${infer Action}` ? {
769
+ service: Service;
770
+ entity: Entity;
771
+ method: Method;
772
+ action: Action;
773
+ } : never : never)["entity"]][(TURI extends `${infer Path}` ? Path extends `${infer Service}/${infer Entity}/${infer Method}/${infer Action}` ? {
774
+ service: Service;
775
+ entity: Entity;
776
+ method: Method;
777
+ action: Action;
778
+ } : never : never)["method"]] ? SilgiServiceTypes[(TURI extends `${infer Path}` ? Path extends `${infer Service}/${infer Entity}/${infer Method}/${infer Action}` ? {
779
+ service: Service;
780
+ entity: Entity;
781
+ method: Method;
782
+ action: Action;
783
+ } : never : never)["service"]][(TURI extends `${infer Path}` ? Path extends `${infer Service}/${infer Entity}/${infer Method}/${infer Action}` ? {
784
+ service: Service;
785
+ entity: Entity;
786
+ method: Method;
787
+ action: Action;
788
+ } : never : never)["entity"]][(TURI extends `${infer Path}` ? Path extends `${infer Service}/${infer Entity}/${infer Method}/${infer Action}` ? {
789
+ service: Service;
790
+ entity: Entity;
791
+ method: Method;
792
+ action: Action;
793
+ } : never : never)["method"]][(TURI extends `${infer Path}` ? Path extends `${infer Service}/${infer Entity}/${infer Method}/${infer Action}` ? {
794
+ service: Service;
795
+ entity: Entity;
796
+ method: Method;
797
+ action: Action;
798
+ } : never : never)["action"]]["output"] : never : never : never : never>>;
799
+ };
800
+
801
+ type SilgiServiceInterface<T extends BaseSchemaType<SelectedValidationLibrary>> = {
802
+ [Action in keyof T]: T[Action] extends Record<string, any> ? {
803
+ [Method in keyof T[Action]]: {
804
+ input: InferSchemaType<SelectedValidationLibrary, T[Action][Method]['input']>;
805
+ output?: InferSchemaType<SelectedValidationLibrary, T[Action][Method]['output']>;
806
+ };
807
+ } : never;
808
+ };
809
+ type ServiceType<T> = Partial<{
810
+ [Namespace in keyof T]: T[Namespace] extends Record<string, any> ? {
811
+ [Service in keyof T[Namespace]]?: MethodHandlerType<T[Namespace][Service]>;
812
+ } : never;
813
+ }>;
814
+ type RequiredServiceType<T> = {
815
+ [K in keyof T]-?: T[K] extends Record<string, any> ? {
816
+ [P in keyof T[K]]-?: MethodHandlerType<T[K][P]>;
817
+ } : never;
818
+ };
819
+ /**
820
+ * const test: ResolvedServiceType = {
821
+ aaa: {
822
+ bbb: {
823
+ delete: {
824
+ storage: {
825
+ handler: () => {}
826
+ },
827
+ },
828
+ },
829
+ },
830
+ }
831
+ */
832
+ type ResolvedServiceType = {
833
+ [K in string]: {
834
+ [P in string]: {
835
+ [Q in BaseSilgiMethodType]?: {
836
+ [M in string]: ResolvedMethodHandlerType;
837
+ };
838
+ };
839
+ };
840
+ };
841
+
842
+ interface Silgi {
843
+ types: any;
844
+ services: ResolvedServiceType;
845
+ shared: SilgiDefaultShared;
846
+ uris: Record<string, any>;
847
+ scannedHandlers: Map<string, ResolvedMethodHandlerType>;
848
+ /**
849
+ *
850
+ * @private
851
+ */
852
+ _initializedModules: Record<string, SilgiModule>;
853
+ _ignore?: Ignore;
854
+ _version: string;
855
+ hooks: Hookable<SilgiHooks & DefaultHooks>;
856
+ hooksNames: string[];
857
+ hook: Silgi['hooks']['hook'];
858
+ callHook: Silgi['hooks']['callHook'];
859
+ addHooks: Silgi['hooks']['addHooks'];
860
+ ready: () => Promise<void>;
861
+ close: () => Promise<void>;
862
+ logger: ConsolaInstance;
863
+ storage: Storage;
864
+ options: SilgiOptions;
865
+ }
866
+ interface SilgiConfig extends Pick<Silgi, 'services' | 'shared' | 'uris' | 'types' | '_initializedModules'> {
867
+ options: DeepPartial<SilgiOptions>;
868
+ }
869
+ type SilgiFunction = typeof silgi;
870
+
871
+ export { type Awaitable as A, type BaseSchemaType as B, type CreateScope as C, type DeepPartial as D, type ExtendShared as E, type ModuleOptions as M, type RequiredServiceType as R, type SilgiOptions as S, type URIsTypes as U, type ValidationLibrary as V, type SilgiModuleOptions as a, type SilgiConfig as b, SilgiHelper as c, type ModuleDefinition as d, type SilgiModule as e, type SelectedValidationLibrary as f, type SilgiServiceInterface as g, type DefaultNamespaces as h, type Silgi as i, type SilgiOperation as j, type MergeSilgiType as k, type ServiceType as l, type SilgiServiceTypes as m, type SilgiModuleShared as n, type SilgiEvent as o, type SilgiModuleMethods as p, type SilgiModules as q, type SilgiNamespaces as r, type SilgiValidationSchema as s, type SilgiDefaultShared as t, type SilgiURIs as u, type SilgiStorageBase as v, silgi as w, type SilgiHook as x, type DefaultMethods as y, type DefaultHooks as z };