@guren/server 2.15.0 → 2.17.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/{DocsViewerServiceProvider-qFCaeiUv.js → DocsViewerServiceProvider-D2cuVgtN.js} +7 -12
- package/dist/{Hash-C8aejmi8.js → Hash-D2DFd8xX.js} +7 -57
- package/dist/{HttpException-BkS3euNG.js → HttpException-BlQ2yEmT.js} +2 -79
- package/dist/{Job-BVT813DO.js → Job-DxQK8h3P.js} +24 -179
- package/dist/{McpServiceProvider-BawsYjgN.js → McpServiceProvider-Zihx3Bjq.js} +35 -20
- package/dist/{Random-DbIJ22KQ.js → Random-S0OvCuR8.js} +9 -106
- package/dist/agent/AgentApprovalRequested.d.ts +11 -39
- package/dist/agent/approval-status.d.ts +56 -0
- package/dist/agent/approval.d.ts +76 -187
- package/dist/agent/audit-emitter.d.ts +16 -44
- package/dist/agent/audit.d.ts +20 -56
- package/dist/agent/derive.d.ts +32 -66
- package/dist/agent/dispatch.d.ts +38 -90
- package/dist/agent/events.d.ts +17 -23
- package/dist/agent/gate.d.ts +118 -0
- package/dist/agent/meta-tools.d.ts +18 -46
- package/dist/agent/pipeline.d.ts +234 -0
- package/dist/agent/public.d.ts +6 -25
- package/dist/agent/public.js +1 -1
- package/dist/agent/redact.d.ts +16 -38
- package/dist/agent/scopes.d.ts +55 -69
- package/dist/auth/AgentPrincipalGuard.d.ts +49 -0
- package/dist/auth/AuthManager.d.ts +22 -43
- package/dist/auth/AuthenticatableModel.d.ts +2 -2
- package/dist/auth/SessionGuard.d.ts +0 -1
- package/dist/auth/TokenGuard.d.ts +6 -26
- package/dist/auth/api-token.d.ts +16 -148
- package/dist/auth/context.d.ts +5 -10
- package/dist/auth/email-verification.d.ts +29 -127
- package/dist/auth/index.js +1 -1
- package/dist/auth/oauth/index.d.ts +35 -57
- package/dist/auth/password/DefaultHasher.d.ts +5 -14
- package/dist/auth/password/PasswordHasher.d.ts +5 -13
- package/dist/auth/password/hash-format.d.ts +5 -13
- package/dist/auth/password-reset.d.ts +16 -42
- package/dist/auth/providers/ModelUserProvider.d.ts +3 -4
- package/dist/auth/providers/UserProvider.d.ts +4 -4
- package/dist/auth/signed-token.d.ts +18 -0
- package/dist/auth/types.d.ts +9 -32
- package/dist/auth/utils.d.ts +6 -27
- package/dist/{auth-DkYoAPVn.js → auth-Gg54ppQi.js} +279 -519
- package/dist/authorization/Gate.d.ts +9 -145
- package/dist/authorization/Policy.d.ts +6 -53
- package/dist/authorization/index.js +1 -1
- package/dist/authorization/middleware.d.ts +16 -62
- package/dist/authorization/types.d.ts +8 -64
- package/dist/{authorization-CdfbCj8J.js → authorization-CdEWZZw3.js} +44 -309
- package/dist/broadcasting/BroadcastManager.d.ts +29 -149
- package/dist/broadcasting/channels/Channel.d.ts +1 -19
- package/dist/broadcasting/channels/PresenceChannel.d.ts +1 -55
- package/dist/broadcasting/channels/PrivateChannel.d.ts +1 -23
- package/dist/broadcasting/drivers/MemoryDriver.d.ts +18 -70
- package/dist/broadcasting/drivers/RedisDriver.d.ts +3 -80
- package/dist/broadcasting/drivers/index.d.ts +1 -1
- package/dist/broadcasting/index.d.ts +1 -1
- package/dist/broadcasting/index.js +1 -1
- package/dist/broadcasting/types.d.ts +7 -88
- package/dist/{broadcasting-BwodCA4q.js → broadcasting-B5RzB0A2.js} +87 -414
- package/dist/cache/CacheManager.d.ts +8 -62
- package/dist/cache/TaggedCache.d.ts +2 -35
- package/dist/cache/index.js +1 -1
- package/dist/cache/stores/FileStore.d.ts +2 -36
- package/dist/cache/stores/MemoryStore.d.ts +2 -26
- package/dist/cache/stores/RedisStore.d.ts +1 -29
- package/dist/cache/types.d.ts +21 -128
- package/dist/{cache-BYnZf2FR.js → cache-BOOIr324.js} +19 -198
- package/dist/client-C4TEr_Dd.js +9 -0
- package/dist/console/Command.d.ts +17 -126
- package/dist/console/ConsoleKernel.d.ts +2 -74
- package/dist/console/Input.d.ts +5 -113
- package/dist/console/Output.d.ts +3 -99
- package/dist/console/types.d.ts +3 -33
- package/dist/container/Container.d.ts +12 -103
- package/dist/container/ServiceProvider.d.ts +17 -61
- package/dist/container/bindings.d.ts +5 -26
- package/dist/container/defineModule.d.ts +16 -54
- package/dist/container/definePlugin.d.ts +12 -45
- package/dist/container/types.d.ts +2 -34
- package/dist/context-CXk_umpT.js +21 -0
- package/dist/database/Factory.d.ts +4 -57
- package/dist/database/Seeder.d.ts +8 -46
- package/dist/database/SeederRunner.d.ts +3 -33
- package/dist/database/types.d.ts +3 -24
- package/dist/discovery/AutoDiscovery.d.ts +10 -82
- package/dist/{dispatch-erOS9epZ.js → dispatch-BAwzftws.js} +32 -79
- package/dist/docs-viewer/DocsViewerServiceProvider.d.ts +2 -5
- package/dist/docs-viewer/endpoint.d.ts +5 -11
- package/dist/encryption/Encrypter.d.ts +5 -71
- package/dist/encryption/Hash.d.ts +7 -57
- package/dist/encryption/Random.d.ts +6 -99
- package/dist/encryption/index.js +3 -3
- package/dist/encryption/types.d.ts +10 -72
- package/dist/{encryption-D99Vmls3.js → encryption-uwP3Di4D.js} +9 -78
- package/dist/{endpoint-D6GIqOpe.js → endpoint-BXipU2Jj.js} +6 -12
- package/dist/endpoint-Dsw3Acvq.js +26 -0
- package/dist/errors/ExceptionHandler.d.ts +3 -90
- package/dist/errors/HttpException.d.ts +2 -79
- package/dist/errors/debug-page.d.ts +3 -17
- package/dist/errors/error-page.d.ts +1 -0
- package/dist/errors/exceptions/AuthenticationException.d.ts +2 -24
- package/dist/errors/exceptions/AuthorizationException.d.ts +1 -24
- package/dist/errors/exceptions/MethodNotAllowedException.d.ts +1 -23
- package/dist/errors/exceptions/NotFoundHttpException.d.ts +1 -27
- package/dist/errors/exceptions/ValidationException.d.ts +2 -43
- package/dist/errors/types.d.ts +1 -25
- package/dist/{errors-BgeOl_DC.js → errors-JpkcCjjn.js} +3 -41
- package/dist/events/Event.d.ts +1 -28
- package/dist/events/EventManager.d.ts +5 -107
- package/dist/events/Listener.d.ts +7 -55
- package/dist/events/builtin.d.ts +0 -24
- package/dist/events/index.js +1 -1
- package/dist/events/types.d.ts +4 -22
- package/dist/{events-aIH_bWRx.js → events-DOmAHDeP.js} +11 -191
- package/dist/facades/index.d.ts +2 -14
- package/dist/health/HealthCheck.d.ts +0 -24
- package/dist/health/HealthManager.d.ts +0 -36
- package/dist/health/checks/CacheCheck.d.ts +2 -17
- package/dist/health/checks/CustomCheck.d.ts +0 -9
- package/dist/health/checks/DatabaseCheck.d.ts +2 -17
- package/dist/health/checks/MemoryCheck.d.ts +3 -12
- package/dist/health/checks/RedisCheck.d.ts +1 -13
- package/dist/health/checks/StorageCheck.d.ts +2 -17
- package/dist/health/index.js +1 -1
- package/dist/health/types.d.ts +4 -24
- package/dist/{health-VWdWXRwh.js → health-DQSvUplL.js} +1 -76
- package/dist/hot-disposables-B5BXqaIH.js +167 -0
- package/dist/hot-reload/hot-disposables.d.ts +22 -74
- package/dist/hot-reload/testing.d.ts +4 -9
- package/dist/http/Application.d.ts +77 -205
- package/dist/http/FormRequest.d.ts +4 -55
- package/dist/http/dev-assets.d.ts +13 -31
- package/dist/http/dev-banner.d.ts +2 -5
- package/dist/http/inertia-assets.d.ts +3 -6
- package/dist/http/middleware/capabilities.d.ts +27 -50
- package/dist/http/middleware/cors.d.ts +4 -29
- package/dist/http/middleware/csp.d.ts +2 -25
- package/dist/http/middleware/csrf.d.ts +28 -95
- package/dist/http/middleware/detect-locale.d.ts +7 -27
- package/dist/http/middleware/force-https.d.ts +6 -24
- package/dist/http/middleware/host-authorization.d.ts +2 -12
- package/dist/http/middleware/index.d.ts +1 -1
- package/dist/http/middleware/loopback-guard.d.ts +15 -33
- package/dist/http/middleware/rate-limit.d.ts +29 -126
- package/dist/http/middleware/redirect-safety.d.ts +2 -20
- package/dist/http/middleware/request-id.d.ts +1 -14
- package/dist/http/middleware/request-logging.d.ts +2 -13
- package/dist/http/middleware/response-headers.d.ts +5 -13
- package/dist/http/middleware/security-headers.d.ts +2 -16
- package/dist/http/middleware/session.d.ts +15 -34
- package/dist/http/middleware/validation-errors-cookie.d.ts +7 -18
- package/dist/http/middleware/validation.d.ts +8 -63
- package/dist/http/public-assets.d.ts +11 -7
- package/dist/http/request.d.ts +32 -118
- package/dist/http/resources/CursorPaginator.d.ts +5 -64
- package/dist/http/resources/Paginator.d.ts +7 -84
- package/dist/http/resources/Resource.d.ts +9 -65
- package/dist/http/resources/ResourceCollection.d.ts +5 -39
- package/dist/http/resources/types.d.ts +10 -30
- package/dist/http/static-documents.d.ts +10 -20
- package/dist/http/validation/Validator.d.ts +25 -85
- package/dist/http/validation/rules.d.ts +48 -147
- package/dist/http/validation/types.d.ts +16 -61
- package/dist/http/vite-assets.d.ts +5 -28
- package/dist/http/vite-dev-server.d.ts +6 -9
- package/dist/http/vite-manifest.d.ts +19 -33
- package/dist/i18n/I18nManager.d.ts +12 -78
- package/dist/i18n/Translator.d.ts +3 -54
- package/dist/i18n/index.js +1 -1
- package/dist/i18n/loaders/JsonLoader.d.ts +4 -31
- package/dist/i18n/loaders/MemoryLoader.d.ts +1 -21
- package/dist/i18n/pluralization.d.ts +4 -13
- package/dist/i18n/types.d.ts +17 -69
- package/dist/{i18n-mcWi7LCd.js → i18n-Cg1aajRP.js} +31 -225
- package/dist/index.d.ts +11 -4
- package/dist/index.js +1186 -3040
- package/dist/internal/agent-preflight.d.ts +9 -21
- package/dist/internal/agent-principal.d.ts +32 -0
- package/dist/internal/request.d.ts +6 -19
- package/dist/internal/request.js +1 -1
- package/dist/internal/route-path.d.ts +9 -21
- package/dist/internal/route-path.js +9 -21
- package/dist/internal/zod-compat.d.ts +55 -122
- package/dist/internal/zod-compat.js +39 -70
- package/dist/internal/zod-json-schema.d.ts +18 -54
- package/dist/internal/zod-json-schema.js +46 -123
- package/dist/jsx-runtime.d.ts +3 -8
- package/dist/lambda/index.d.ts +17 -79
- package/dist/lambda/index.js +11 -59
- package/dist/logging/LogManager.d.ts +1 -51
- package/dist/logging/Logger.d.ts +8 -47
- package/dist/logging/channels/ConsoleChannel.d.ts +1 -3
- package/dist/logging/channels/DailyFileChannel.d.ts +1 -3
- package/dist/logging/channels/FileChannel.d.ts +1 -3
- package/dist/logging/daily-file-path.d.ts +7 -16
- package/dist/logging/index.js +1 -1
- package/dist/logging/types.d.ts +13 -45
- package/dist/{logging-B-kngi3q.js → logging-zOY1XCtq.js} +52 -141
- package/dist/{loopback-guard-D0Kc7-xc.js → loopback-guard-DT9gHF0F.js} +41 -92
- package/dist/mail/Mail.d.ts +10 -106
- package/dist/mail/MailManager.d.ts +2 -60
- package/dist/mail/index.js +1 -1
- package/dist/mail/transports/LogTransport.d.ts +1 -4
- package/dist/mail/transports/MemoryTransport.d.ts +1 -63
- package/dist/mail/transports/ResendTransport.d.ts +1 -23
- package/dist/mail/transports/SmtpTransport.d.ts +1 -31
- package/dist/mail/types.d.ts +28 -150
- package/dist/{mail-DfEfSQEr.js → mail-76DWy9lj.js} +31 -289
- package/dist/mcp/McpServiceProvider.d.ts +4 -10
- package/dist/mcp/create-mcp-server.d.ts +42 -57
- package/dist/mcp/endpoint.d.ts +12 -36
- package/dist/mcp/index.js +1 -1
- package/dist/mvc/Controller.d.ts +46 -227
- package/dist/mvc/Router.d.ts +50 -129
- package/dist/mvc/inertia/InertiaEngine.d.ts +18 -48
- package/dist/mvc/inertia/shared.d.ts +6 -19
- package/dist/mvc/mount-route.d.ts +2 -6
- package/dist/mvc/view.d.ts +1 -2
- package/dist/notifications/Notification.d.ts +8 -75
- package/dist/notifications/NotificationManager.d.ts +15 -88
- package/dist/notifications/channels/DatabaseChannel.d.ts +1 -41
- package/dist/notifications/channels/MailChannel.d.ts +2 -31
- package/dist/notifications/channels/MemoryChannel.d.ts +2 -62
- package/dist/notifications/channels/SlackChannel.d.ts +3 -48
- package/dist/notifications/index.js +1 -1
- package/dist/notifications/notifiable-type.d.ts +3 -6
- package/dist/notifications/registry.d.ts +8 -27
- package/dist/notifications/types.d.ts +16 -53
- package/dist/{notifications-BGqmUNZ8.js → notifications-okWFs9ly.js} +37 -335
- package/dist/providers/AuthServiceProvider.d.ts +1 -3
- package/dist/providers/AuthorizationServiceProvider.d.ts +2 -3
- package/dist/providers/BroadcastServiceProvider.d.ts +1 -3
- package/dist/providers/CacheServiceProvider.d.ts +1 -3
- package/dist/providers/EncryptionServiceProvider.d.ts +1 -3
- package/dist/providers/ErrorServiceProvider.d.ts +1 -4
- package/dist/providers/EventServiceProvider.d.ts +1 -3
- package/dist/providers/HealthServiceProvider.d.ts +1 -3
- package/dist/providers/I18nServiceProvider.d.ts +6 -10
- package/dist/providers/InertiaServiceProvider.d.ts +1 -4
- package/dist/providers/LogServiceProvider.d.ts +1 -3
- package/dist/providers/MailServiceProvider.d.ts +1 -3
- package/dist/providers/NotificationServiceProvider.d.ts +1 -3
- package/dist/providers/OAuthServiceProvider.d.ts +1 -3
- package/dist/providers/QueueServiceProvider.d.ts +1 -3
- package/dist/providers/SchedulingServiceProvider.d.ts +1 -3
- package/dist/providers/StorageServiceProvider.d.ts +1 -3
- package/dist/queue/FailedJobReporter.d.ts +1 -24
- package/dist/queue/Job.d.ts +12 -99
- package/dist/queue/QueueManager.d.ts +6 -57
- package/dist/queue/Worker.d.ts +4 -65
- package/dist/queue/drivers/MemoryDriver.d.ts +3 -44
- package/dist/queue/drivers/RedisDriver.d.ts +7 -65
- package/dist/queue/drivers/SqsDriver.d.ts +6 -57
- package/dist/queue/drivers/SyncDriver.d.ts +10 -13
- package/dist/queue/index.js +2 -2
- package/dist/queue/types.d.ts +10 -92
- package/dist/{queue-CXrRK85G.js → queue-CcXCjuJI.js} +32 -260
- package/dist/redis/RedisApiTokenStore.d.ts +4 -56
- package/dist/redis/RedisEmailVerificationStore.d.ts +4 -37
- package/dist/redis/RedisOAuthStateStore.d.ts +2 -10
- package/dist/redis/RedisPasswordResetStore.d.ts +4 -37
- package/dist/redis/RedisRateLimitStore.d.ts +16 -49
- package/dist/redis/RedisSessionStore.d.ts +3 -44
- package/dist/redis/client.d.ts +2 -32
- package/dist/redis/index.js +47 -232
- package/dist/redis/redis-values.d.ts +6 -12
- package/dist/redis/scan-keys.d.ts +1 -4
- package/dist/request-CLOYytGP.js +68 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.js +50 -92
- package/dist/scheduling/CronParser.d.ts +0 -29
- package/dist/scheduling/Schedule.d.ts +1 -153
- package/dist/scheduling/ScheduledTask.d.ts +0 -31
- package/dist/scheduling/Scheduler.d.ts +0 -70
- package/dist/scheduling/index.js +1 -1
- package/dist/scheduling/types.d.ts +4 -65
- package/dist/{scheduling-CPiEdtQd.js → scheduling-C6tcOtUl.js} +2 -287
- package/dist/storage/StorageManager.d.ts +0 -48
- package/dist/storage/drivers/LocalDriver.d.ts +1 -25
- package/dist/storage/drivers/MemoryDriver.d.ts +5 -35
- package/dist/storage/drivers/S3Driver.d.ts +6 -36
- package/dist/storage/drivers/s3-acl.d.ts +5 -10
- package/dist/storage/index.js +1 -1
- package/dist/storage/types.d.ts +27 -265
- package/dist/{storage-TLD9t0Q2.js → storage-BB59f07j.js} +17 -157
- package/dist/support/contained-path.d.ts +10 -20
- package/dist/support/error-polyfill.d.ts +4 -6
- package/dist/support/expiry.d.ts +17 -33
- package/dist/support/expiry.js +17 -33
- package/dist/support/import-map.d.ts +3 -7
- package/dist/support/inertia-defaults.d.ts +5 -10
- package/dist/support/redirect-target.d.ts +4 -6
- package/dist/support/stack-frames.d.ts +11 -50
- package/dist/support/trim-slashes.d.ts +4 -7
- package/dist/support/warn-once.d.ts +2 -6
- package/dist/{trim-slashes-ZJ_VsY5s.js → trim-slashes-BLY9hKAa.js} +4 -7
- package/dist/{vite-manifest-w_RSOvQW.js → vite-manifest-B_Iy5183.js} +34 -58
- package/package.json +2 -2
- package/dist/client-Dd7vLcqp.js +0 -27
- package/dist/context-DoD0c7J_.js +0 -26
- package/dist/endpoint-D-20PiHY.js +0 -46
- package/dist/hot-disposables-WsTX2ySN.js +0 -281
- package/dist/request-CVQwpu2J.js +0 -129
|
@@ -1,99 +1,27 @@
|
|
|
1
1
|
import type { Container } from '../container/index.js';
|
|
2
2
|
import type { CommandClass, ConsoleKernelOptions, OutputInterface } from './types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Console kernel for managing and executing commands.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```typescript
|
|
8
|
-
* const kernel = new ConsoleKernel()
|
|
9
|
-
*
|
|
10
|
-
* kernel.register(CreateUserCommand)
|
|
11
|
-
* kernel.register(SendNotificationsCommand)
|
|
12
|
-
*
|
|
13
|
-
* // Execute command
|
|
14
|
-
* const exitCode = await kernel.handle(['users:create', 'john@example.com', '--admin'])
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
3
|
+
/** Console kernel for managing and executing commands. */
|
|
17
4
|
export declare class ConsoleKernel {
|
|
18
|
-
/**
|
|
19
|
-
* Registered commands.
|
|
20
|
-
*/
|
|
21
5
|
protected commands: Map<string, CommandClass>;
|
|
22
|
-
/**
|
|
23
|
-
* Service container.
|
|
24
|
-
*/
|
|
25
6
|
protected container?: Container;
|
|
26
|
-
/**
|
|
27
|
-
* Output instance.
|
|
28
|
-
*/
|
|
29
7
|
protected output: OutputInterface;
|
|
30
8
|
constructor(options?: ConsoleKernelOptions);
|
|
31
|
-
/**
|
|
32
|
-
* Register a command.
|
|
33
|
-
*/
|
|
34
9
|
register(command: CommandClass): this;
|
|
35
|
-
/**
|
|
36
|
-
* Register multiple commands.
|
|
37
|
-
*/
|
|
38
10
|
registerMany(commands: CommandClass[]): this;
|
|
39
|
-
/**
|
|
40
|
-
* Get all registered commands.
|
|
41
|
-
*/
|
|
42
11
|
getCommands(): Map<string, CommandClass>;
|
|
43
|
-
/**
|
|
44
|
-
* Get a command by name.
|
|
45
|
-
*/
|
|
46
12
|
getCommand(name: string): CommandClass | undefined;
|
|
47
|
-
/**
|
|
48
|
-
* Check if a command is registered.
|
|
49
|
-
*/
|
|
50
13
|
hasCommand(name: string): boolean;
|
|
51
|
-
/**
|
|
52
|
-
* Set the output instance.
|
|
53
|
-
*/
|
|
54
14
|
setOutput(output: OutputInterface): this;
|
|
55
|
-
/**
|
|
56
|
-
* Get the output instance.
|
|
57
|
-
*/
|
|
58
15
|
getOutput(): OutputInterface;
|
|
59
|
-
/**
|
|
60
|
-
* Handle command execution.
|
|
61
|
-
*/
|
|
62
16
|
handle(argv?: string[]): Promise<number>;
|
|
63
|
-
/**
|
|
64
|
-
* Run a command.
|
|
65
|
-
*/
|
|
66
17
|
protected runCommand(CommandClass: CommandClass, args: string[]): Promise<number>;
|
|
67
|
-
/**
|
|
68
|
-
* Show help.
|
|
69
|
-
*/
|
|
70
18
|
protected showHelp(): void;
|
|
71
|
-
/**
|
|
72
|
-
* Show help for a specific command.
|
|
73
|
-
*/
|
|
74
19
|
protected showCommandHelp(commandName: string): void;
|
|
75
|
-
/**
|
|
76
|
-
* List all commands.
|
|
77
|
-
*/
|
|
78
20
|
protected listCommands(): void;
|
|
79
|
-
/**
|
|
80
|
-
* Group commands by namespace.
|
|
81
|
-
*/
|
|
82
21
|
protected groupCommands(): Map<string, Map<string, CommandClass>>;
|
|
83
|
-
/**
|
|
84
|
-
* Suggest similar commands.
|
|
85
|
-
*/
|
|
86
22
|
protected suggestCommands(input: string): void;
|
|
87
|
-
/**
|
|
88
|
-
* Calculate string similarity (simple Dice coefficient).
|
|
89
|
-
*/
|
|
23
|
+
/** Dice coefficient over bigrams. */
|
|
90
24
|
protected similarity(a: string, b: string): number;
|
|
91
|
-
/**
|
|
92
|
-
* Call a command programmatically.
|
|
93
|
-
*/
|
|
94
25
|
call(commandName: string, args?: string[], silent?: boolean): Promise<number>;
|
|
95
26
|
}
|
|
96
|
-
/**
|
|
97
|
-
* Create a console kernel.
|
|
98
|
-
*/
|
|
99
27
|
export declare function createConsoleKernel(options?: ConsoleKernelOptions): ConsoleKernel;
|
package/dist/console/Input.d.ts
CHANGED
|
@@ -1,140 +1,32 @@
|
|
|
1
1
|
import type { ParsedSignature, ArgumentDefinition, OptionDefinition, InputInterface } from './types.js';
|
|
2
2
|
/**
|
|
3
|
-
* Parse a command signature
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* - `{argument?}` - Optional argument
|
|
9
|
-
* - `{argument=default}` - Argument with default
|
|
10
|
-
* - `{argument*}` - Array argument (must be last)
|
|
11
|
-
* - `{--option}` - Boolean option (flag)
|
|
12
|
-
* - `{--option=}` - Option that requires a value
|
|
13
|
-
* - `{--option=default}` - Option with default value
|
|
14
|
-
* - `{-o|--option}` - Option with shortcut
|
|
15
|
-
* - `{--option=*}` - Array option
|
|
16
|
-
* - `{argument : Description}` - Argument with a description
|
|
17
|
-
* - `{--option= : Description}` - Option with a description
|
|
18
|
-
*
|
|
19
|
-
* A description is separated from the token by a colon with whitespace on at
|
|
20
|
-
* least one side, so it may contain spaces and colons freely. Requiring that
|
|
21
|
-
* whitespace keeps colons inside default values (`{--url=https://example.com}`)
|
|
22
|
-
* out of descriptions.
|
|
23
|
-
*
|
|
24
|
-
* A colon with no whitespace at all (`{argument:Description}`) is accepted for
|
|
25
|
-
* a single-word description, but only on a token carrying no other marker:
|
|
26
|
-
* `{argument?}`, `{argument*}` and `{--option=default}` must use the spaced
|
|
27
|
-
* form, since their markers are stripped before that fallback runs.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* ```typescript
|
|
31
|
-
* parseSignature('users:create {name} {--admin} {--role=user}')
|
|
32
|
-
* // => {
|
|
33
|
-
* // name: 'users:create',
|
|
34
|
-
* // arguments: [{ name: 'name', required: true, array: false }],
|
|
35
|
-
* // options: [
|
|
36
|
-
* // { name: 'admin', requiresValue: false },
|
|
37
|
-
* // { name: 'role', requiresValue: true, defaultValue: 'user' }
|
|
38
|
-
* // ]
|
|
39
|
-
* // }
|
|
40
|
-
*
|
|
41
|
-
* parseSignature('users:create {name : The full name} {--admin : Grant admin rights}')
|
|
42
|
-
* // => arguments[0].description === 'The full name'
|
|
43
|
-
* // options[0].description === 'Grant admin rights'
|
|
44
|
-
* ```
|
|
3
|
+
* Parse a command signature: `command:name`, then `{arg}` `{arg?}` `{arg=default}`
|
|
4
|
+
* `{arg*}` (array, must be last) and `{--opt}` `{--opt=}` `{--opt=default}`
|
|
5
|
+
* `{--opt=*}` `{-o|--opt}`, each optionally followed by ` : Description`. The
|
|
6
|
+
* separator needs whitespace on at least one side (keeps colons in defaults out
|
|
7
|
+
* of descriptions); unspaced `{arg:Description}` only on a token with no other marker.
|
|
45
8
|
*/
|
|
46
9
|
export declare function parseSignature(signature: string): ParsedSignature;
|
|
47
|
-
/**
|
|
48
|
-
* The label an argument is displayed with in help output.
|
|
49
|
-
*/
|
|
50
10
|
export declare function argumentLabel(arg: ArgumentDefinition): string;
|
|
51
|
-
/**
|
|
52
|
-
* The label an option is displayed with in help output, carrying whether it
|
|
53
|
-
* takes a value and whether it may be repeated.
|
|
54
|
-
*/
|
|
55
11
|
export declare function optionLabel(opt: OptionDefinition): string;
|
|
56
|
-
/**
|
|
57
|
-
* Build a usage line from a parsed signature.
|
|
58
|
-
*/
|
|
59
12
|
export declare function formatUsage(parsed: ParsedSignature): string;
|
|
60
|
-
/**
|
|
61
|
-
* Console input handler.
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```typescript
|
|
65
|
-
* const input = new Input('users:create {name} {--admin}', ['John', '--admin'])
|
|
66
|
-
* input.argument('name') // => 'John'
|
|
67
|
-
* input.option('admin') // => true
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
13
|
export declare class Input implements InputInterface {
|
|
71
|
-
/**
|
|
72
|
-
* Parsed signature.
|
|
73
|
-
*/
|
|
74
14
|
protected parsed: ParsedSignature;
|
|
75
|
-
/**
|
|
76
|
-
* Parsed argument values.
|
|
77
|
-
*/
|
|
78
15
|
protected argumentValues: Record<string, string | string[]>;
|
|
79
|
-
/**
|
|
80
|
-
* Parsed option values.
|
|
81
|
-
*/
|
|
82
16
|
protected optionValues: Record<string, string | boolean | string[]>;
|
|
83
17
|
constructor(signature: string, argv?: string[]);
|
|
84
|
-
/**
|
|
85
|
-
* Parse command line arguments.
|
|
86
|
-
*/
|
|
87
18
|
protected parseArgv(argv: string[]): void;
|
|
88
|
-
/**
|
|
89
|
-
* Parse a long option.
|
|
90
|
-
*/
|
|
91
19
|
protected parseLongOption(option: string, argv: string[], index: number): void;
|
|
92
|
-
/**
|
|
93
|
-
* Parse a short option.
|
|
94
|
-
*/
|
|
95
20
|
protected parseShortOption(option: string, argv: string[], index: number): void;
|
|
96
|
-
/**
|
|
97
|
-
* Map positional arguments to definitions.
|
|
98
|
-
*/
|
|
99
21
|
protected mapArguments(args: string[]): void;
|
|
100
|
-
/**
|
|
101
|
-
* Find an option definition by name.
|
|
102
|
-
*/
|
|
103
22
|
protected findOption(name: string): OptionDefinition | undefined;
|
|
104
|
-
/**
|
|
105
|
-
* Find an option definition by shortcut.
|
|
106
|
-
*/
|
|
107
23
|
protected findOptionByShortcut(shortcut: string): OptionDefinition | undefined;
|
|
108
|
-
/**
|
|
109
|
-
* Check if an option requires a value.
|
|
110
|
-
*/
|
|
111
24
|
protected optionRequiresValue(name: string): boolean;
|
|
112
|
-
/**
|
|
113
|
-
* Get an argument value.
|
|
114
|
-
*/
|
|
115
25
|
argument<T = string>(name: string): T;
|
|
116
|
-
/**
|
|
117
|
-
* Get all argument values.
|
|
118
|
-
*/
|
|
119
26
|
arguments(): Record<string, string | string[]>;
|
|
120
|
-
/**
|
|
121
|
-
* Get an option value.
|
|
122
|
-
*/
|
|
123
27
|
option<T = string | boolean>(name: string): T | undefined;
|
|
124
|
-
/**
|
|
125
|
-
* Get all option values.
|
|
126
|
-
*/
|
|
127
28
|
options(): Record<string, string | boolean | string[]>;
|
|
128
|
-
/**
|
|
129
|
-
* Check if an option was provided.
|
|
130
|
-
*/
|
|
131
29
|
hasOption(name: string): boolean;
|
|
132
|
-
/**
|
|
133
|
-
* Get the parsed signature.
|
|
134
|
-
*/
|
|
135
30
|
getSignature(): ParsedSignature;
|
|
136
|
-
/**
|
|
137
|
-
* Get the command name.
|
|
138
|
-
*/
|
|
139
31
|
getCommandName(): string;
|
|
140
32
|
}
|
package/dist/console/Output.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import type { OutputInterface } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* ANSI color codes.
|
|
4
|
-
*/
|
|
5
2
|
declare const COLORS: {
|
|
6
3
|
readonly reset: '\u001B[0m';
|
|
7
4
|
readonly bold: '\u001B[1m';
|
|
@@ -22,140 +19,47 @@ declare const COLORS: {
|
|
|
22
19
|
readonly bgCyan: '\u001B[46m';
|
|
23
20
|
readonly bgWhite: '\u001B[47m';
|
|
24
21
|
};
|
|
25
|
-
/**
|
|
26
|
-
* Console output handler.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```typescript
|
|
30
|
-
* const output = new Output()
|
|
31
|
-
* output.info('Processing...')
|
|
32
|
-
* output.success('Done!')
|
|
33
|
-
* output.table(['Name', 'Age'], [['John', '30'], ['Jane', '25']])
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
22
|
export declare class Output implements OutputInterface {
|
|
37
|
-
/**
|
|
38
|
-
* Whether to use colors.
|
|
39
|
-
*/
|
|
40
23
|
protected useColors: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Output stream.
|
|
43
|
-
*/
|
|
44
24
|
protected stdout: NodeJS.WriteStream;
|
|
45
|
-
/**
|
|
46
|
-
* Error stream.
|
|
47
|
-
*/
|
|
48
25
|
protected stderr: NodeJS.WriteStream;
|
|
49
26
|
constructor(options?: {
|
|
50
27
|
colors?: boolean;
|
|
51
28
|
stdout?: NodeJS.WriteStream;
|
|
52
29
|
stderr?: NodeJS.WriteStream;
|
|
53
30
|
});
|
|
54
|
-
|
|
55
|
-
* Apply color to text.
|
|
56
|
-
*/
|
|
31
|
+
stream(): NodeJS.WriteStream;
|
|
57
32
|
protected color(text: string, ...codes: string[]): string;
|
|
58
|
-
/**
|
|
59
|
-
* Output an info message.
|
|
60
|
-
*/
|
|
61
33
|
info(message: string): void;
|
|
62
|
-
/**
|
|
63
|
-
* Output an error message.
|
|
64
|
-
*/
|
|
65
34
|
error(message: string): void;
|
|
66
|
-
/**
|
|
67
|
-
* Output a warning message.
|
|
68
|
-
*/
|
|
69
35
|
warn(message: string): void;
|
|
70
|
-
/**
|
|
71
|
-
* Output a success message.
|
|
72
|
-
*/
|
|
73
36
|
success(message: string): void;
|
|
74
|
-
/**
|
|
75
|
-
* Output a plain line.
|
|
76
|
-
*/
|
|
77
37
|
line(message: string): void;
|
|
78
|
-
/**
|
|
79
|
-
* Output new lines.
|
|
80
|
-
*/
|
|
81
38
|
newLine(count?: number): void;
|
|
82
|
-
/**
|
|
83
|
-
* Output a table.
|
|
84
|
-
*/
|
|
85
39
|
table(headers: string[], rows: string[][]): void;
|
|
86
|
-
/**
|
|
87
|
-
* Write raw text without newline.
|
|
88
|
-
*/
|
|
40
|
+
/** Write raw text, without a newline. */
|
|
89
41
|
write(message: string): void;
|
|
90
|
-
/**
|
|
91
|
-
* Write a line to stdout.
|
|
92
|
-
*/
|
|
93
42
|
protected writeLine(message: string): void;
|
|
94
|
-
/**
|
|
95
|
-
* Write a line to stderr.
|
|
96
|
-
*/
|
|
97
43
|
protected writeErrorLine(message: string): void;
|
|
98
|
-
/**
|
|
99
|
-
* Output a comment.
|
|
100
|
-
*/
|
|
101
44
|
comment(message: string): void;
|
|
102
|
-
/**
|
|
103
|
-
* Output a question.
|
|
104
|
-
*/
|
|
105
45
|
question(message: string): void;
|
|
106
|
-
/**
|
|
107
|
-
* Output a bulleted list.
|
|
108
|
-
*/
|
|
109
46
|
listing(items: string[]): void;
|
|
110
|
-
/**
|
|
111
|
-
* Output text with specific color.
|
|
112
|
-
*/
|
|
113
47
|
colored(message: string, color: keyof typeof COLORS): void;
|
|
114
|
-
/**
|
|
115
|
-
* Create a progress bar string.
|
|
116
|
-
*/
|
|
117
48
|
progressBar(current: number, total: number, width?: number): string;
|
|
118
|
-
/**
|
|
119
|
-
* Clear the current line.
|
|
120
|
-
*/
|
|
121
49
|
clearLine(): void;
|
|
122
|
-
/**
|
|
123
|
-
* Check if colors are enabled.
|
|
124
|
-
*/
|
|
125
50
|
isColored(): boolean;
|
|
126
|
-
/**
|
|
127
|
-
* Enable or disable colors.
|
|
128
|
-
*/
|
|
129
51
|
setColors(enabled: boolean): void;
|
|
130
52
|
}
|
|
131
|
-
/**
|
|
132
|
-
* Output that collects messages instead of printing.
|
|
133
|
-
* Useful for testing.
|
|
134
|
-
*/
|
|
53
|
+
/** Collects messages instead of printing them, for testing. */
|
|
135
54
|
export declare class BufferedOutput extends Output {
|
|
136
|
-
/**
|
|
137
|
-
* Collected messages.
|
|
138
|
-
*/
|
|
139
55
|
protected buffer: string[];
|
|
140
56
|
constructor();
|
|
141
57
|
protected writeLine(message: string): void;
|
|
142
58
|
protected writeErrorLine(message: string): void;
|
|
143
59
|
write(message: string): void;
|
|
144
|
-
/**
|
|
145
|
-
* Get all output as array.
|
|
146
|
-
*/
|
|
147
60
|
getLines(): string[];
|
|
148
|
-
/**
|
|
149
|
-
* Get all output as string.
|
|
150
|
-
*/
|
|
151
61
|
getOutput(): string;
|
|
152
|
-
/**
|
|
153
|
-
* Clear the buffer.
|
|
154
|
-
*/
|
|
155
62
|
clear(): void;
|
|
156
|
-
/**
|
|
157
|
-
* Check if buffer contains a string.
|
|
158
|
-
*/
|
|
159
63
|
contains(text: string): boolean;
|
|
160
64
|
}
|
|
161
65
|
export {};
|
package/dist/console/types.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import type { Container } from '../container/index.js';
|
|
2
|
-
/**
|
|
3
|
-
* Parsed argument definition.
|
|
4
|
-
*/
|
|
5
2
|
export interface ArgumentDefinition {
|
|
6
3
|
name: string;
|
|
7
4
|
description?: string;
|
|
@@ -9,9 +6,6 @@ export interface ArgumentDefinition {
|
|
|
9
6
|
array: boolean;
|
|
10
7
|
defaultValue?: string;
|
|
11
8
|
}
|
|
12
|
-
/**
|
|
13
|
-
* Parsed option definition.
|
|
14
|
-
*/
|
|
15
9
|
export interface OptionDefinition {
|
|
16
10
|
name: string;
|
|
17
11
|
shortcut?: string;
|
|
@@ -20,25 +14,16 @@ export interface OptionDefinition {
|
|
|
20
14
|
defaultValue?: string | boolean;
|
|
21
15
|
array: boolean;
|
|
22
16
|
}
|
|
23
|
-
/**
|
|
24
|
-
* Parsed signature.
|
|
25
|
-
*/
|
|
26
17
|
export interface ParsedSignature {
|
|
27
18
|
name: string;
|
|
28
19
|
arguments: ArgumentDefinition[];
|
|
29
20
|
options: OptionDefinition[];
|
|
30
21
|
}
|
|
31
|
-
/**
|
|
32
|
-
* Command class type.
|
|
33
|
-
*/
|
|
34
22
|
export interface CommandClass {
|
|
35
23
|
signature: string;
|
|
36
24
|
description: string;
|
|
37
25
|
new (container?: Container): CommandInstance;
|
|
38
26
|
}
|
|
39
|
-
/**
|
|
40
|
-
* Command instance type.
|
|
41
|
-
*/
|
|
42
27
|
export interface CommandInstance {
|
|
43
28
|
setInput(argv: string[]): void;
|
|
44
29
|
setOutput(output: OutputInterface): void;
|
|
@@ -47,9 +32,6 @@ export interface CommandInstance {
|
|
|
47
32
|
}): void;
|
|
48
33
|
run(): Promise<number>;
|
|
49
34
|
}
|
|
50
|
-
/**
|
|
51
|
-
* Output interface.
|
|
52
|
-
*/
|
|
53
35
|
export interface OutputInterface {
|
|
54
36
|
info(message: string): void;
|
|
55
37
|
error(message: string): void;
|
|
@@ -59,10 +41,9 @@ export interface OutputInterface {
|
|
|
59
41
|
newLine(count?: number): void;
|
|
60
42
|
table(headers: string[], rows: string[][]): void;
|
|
61
43
|
write(message: string): void;
|
|
44
|
+
/** The raw stream behind this output, for callers that need one (readline). */
|
|
45
|
+
stream?(): NodeJS.WriteStream;
|
|
62
46
|
}
|
|
63
|
-
/**
|
|
64
|
-
* Input interface.
|
|
65
|
-
*/
|
|
66
47
|
export interface InputInterface {
|
|
67
48
|
argument<T = string>(name: string): T;
|
|
68
49
|
arguments(): Record<string, string | string[]>;
|
|
@@ -70,15 +51,10 @@ export interface InputInterface {
|
|
|
70
51
|
options(): Record<string, string | boolean | string[]>;
|
|
71
52
|
hasOption(name: string): boolean;
|
|
72
53
|
}
|
|
73
|
-
/**
|
|
74
|
-
* Console kernel options.
|
|
75
|
-
*/
|
|
76
54
|
export interface ConsoleKernelOptions {
|
|
77
55
|
container?: Container;
|
|
78
56
|
}
|
|
79
|
-
/**
|
|
80
|
-
* Schedule definition for a command.
|
|
81
|
-
*/
|
|
57
|
+
/** Schedule definition for a command. */
|
|
82
58
|
export interface ScheduledCommand {
|
|
83
59
|
command: string;
|
|
84
60
|
args?: string[];
|
|
@@ -86,18 +62,12 @@ export interface ScheduledCommand {
|
|
|
86
62
|
timezone?: string;
|
|
87
63
|
description?: string;
|
|
88
64
|
}
|
|
89
|
-
/**
|
|
90
|
-
* Interactive prompt types.
|
|
91
|
-
*/
|
|
92
65
|
export interface PromptInterface {
|
|
93
66
|
ask(question: string, defaultValue?: string): Promise<string>;
|
|
94
67
|
confirm(question: string, defaultValue?: boolean): Promise<boolean>;
|
|
95
68
|
choice<T extends string>(question: string, choices: T[], defaultValue?: T): Promise<T>;
|
|
96
69
|
secret(question: string): Promise<string>;
|
|
97
70
|
}
|
|
98
|
-
/**
|
|
99
|
-
* Progress bar interface.
|
|
100
|
-
*/
|
|
101
71
|
export interface ProgressInterface {
|
|
102
72
|
start(total: number): void;
|
|
103
73
|
advance(step?: number): void;
|
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
import type { ServiceFactory, ServiceBinding, ContextualBindingBuilder, ContextualBinding } from './types.js';
|
|
2
2
|
import type { ServiceBindings } from './bindings.js';
|
|
3
3
|
/**
|
|
4
|
-
* Dependency injection container
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```typescript
|
|
8
|
-
* const container = new Container()
|
|
9
|
-
*
|
|
10
|
-
* // Register services
|
|
11
|
-
* container.singleton('events', (c) => new EventManager())
|
|
12
|
-
* container.instance('config', loadConfig())
|
|
13
|
-
*
|
|
14
|
-
* // Type-safe resolution (known bindings)
|
|
15
|
-
* const events = container.make('events') // EventManager
|
|
16
|
-
*
|
|
17
|
-
* // Generic resolution (custom bindings)
|
|
18
|
-
* const db = container.make<Database>('db')
|
|
19
|
-
* ```
|
|
4
|
+
* Dependency injection container. Keys from `ServiceBindings` type `make()`
|
|
5
|
+
* automatically; other keys take an explicit type parameter (`make<T>(key)`).
|
|
20
6
|
*/
|
|
21
7
|
export declare class Container {
|
|
22
8
|
protected bindings: Map<string, ServiceBinding>;
|
|
@@ -26,122 +12,45 @@ export declare class Container {
|
|
|
26
12
|
protected resolvingStack: string[];
|
|
27
13
|
protected scopedInstances: Map<string, unknown>[];
|
|
28
14
|
protected fakes: Map<string, unknown>;
|
|
29
|
-
/** @internal Used by ProviderManager to resolve deferred providers on demand */
|
|
30
|
-
deferredProviderLoader: ((service: string) => Promise<void>) | null;
|
|
31
15
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
16
|
+
* @internal Installed by ProviderManager once every eager provider has booted.
|
|
17
|
+
* Called from make() for an unbound key; must run the deferred provider's
|
|
18
|
+
* register() synchronously before returning (boot() may settle on the returned
|
|
19
|
+
* promise). `undefined` means no deferred provider claims the service.
|
|
34
20
|
*/
|
|
21
|
+
deferredProviderLoader: ((service: string) => Promise<void> | undefined) | null;
|
|
22
|
+
/** Bind a factory; each resolution creates a new instance. */
|
|
35
23
|
bind<T>(key: string, factory: ServiceFactory<T>): this;
|
|
36
|
-
/**
|
|
37
|
-
* Bind a singleton service to the container.
|
|
38
|
-
* Only one instance is created and reused.
|
|
39
|
-
*/
|
|
24
|
+
/** Bind a factory whose single instance is reused. */
|
|
40
25
|
singleton<T>(key: string, factory: ServiceFactory<T>): this;
|
|
41
|
-
/**
|
|
42
|
-
* Bind an existing instance to the container.
|
|
43
|
-
*/
|
|
44
26
|
instance<T>(key: string, value: T): this;
|
|
45
|
-
/**
|
|
46
|
-
* Resolve a service from the container.
|
|
47
|
-
*
|
|
48
|
-
* Known service keys (from ServiceBindings) are automatically typed:
|
|
49
|
-
* ```typescript
|
|
50
|
-
* container.make('events') // EventManager
|
|
51
|
-
* container.make('cache') // CacheManager
|
|
52
|
-
* ```
|
|
53
|
-
*
|
|
54
|
-
* Custom keys require an explicit type parameter:
|
|
55
|
-
* ```typescript
|
|
56
|
-
* container.make<MyService>('myService')
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
27
|
make<K extends keyof ServiceBindings>(key: K): ServiceBindings[K];
|
|
60
28
|
make<T>(key: string): T;
|
|
61
|
-
/**
|
|
62
|
-
* Resolve a service with additional parameters.
|
|
63
|
-
*/
|
|
64
29
|
makeWith<T>(key: string, params: Record<string, unknown>): T;
|
|
65
|
-
/**
|
|
66
|
-
* Check if a service is bound in the container.
|
|
67
|
-
*/
|
|
68
30
|
has(key: string): boolean;
|
|
69
|
-
/**
|
|
70
|
-
* Create an alias for a service.
|
|
71
|
-
*/
|
|
72
31
|
alias(alias: string, key: string): this;
|
|
73
|
-
/**
|
|
74
|
-
* Tag multiple services with a tag name.
|
|
75
|
-
*/
|
|
76
32
|
tag(keys: string[], tagName: string): this;
|
|
77
|
-
/**
|
|
78
|
-
* Resolve all services with a given tag.
|
|
79
|
-
*/
|
|
80
33
|
tagged<T = unknown>(tagName: string): T[];
|
|
81
|
-
/**
|
|
82
|
-
* Define a contextual binding.
|
|
83
|
-
*/
|
|
84
34
|
when(concrete: string): ContextualBindingBuilder;
|
|
85
|
-
/**
|
|
86
|
-
* Run a callback within a scoped context.
|
|
87
|
-
* Services resolved within the scope are cached and released when the scope ends.
|
|
88
|
-
*/
|
|
35
|
+
/** Services resolved inside the callback are cached for the scope and released when it ends. */
|
|
89
36
|
scoped<T>(callback: () => T): T;
|
|
90
|
-
/**
|
|
91
|
-
* Run an async callback within a scoped context.
|
|
92
|
-
*/
|
|
93
37
|
scopedAsync<T>(callback: () => Promise<T>): Promise<T>;
|
|
94
38
|
/**
|
|
95
|
-
* Replace a
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
|
-
* ```typescript
|
|
100
|
-
* // Using 'using' declaration (auto-cleanup)
|
|
101
|
-
* using _ = container.fake('events', fakeEventManager)
|
|
102
|
-
*
|
|
103
|
-
* // Manual cleanup
|
|
104
|
-
* const restore = container.fake('mail', fakeMailManager)
|
|
105
|
-
* // ... run tests ...
|
|
106
|
-
* restore[Symbol.dispose]()
|
|
107
|
-
* ```
|
|
39
|
+
* Replace a binding with a fake for tests; the returned disposable restores the
|
|
40
|
+
* original (`using _ = container.fake(key, fake)`).
|
|
108
41
|
*/
|
|
109
42
|
fake<K extends keyof ServiceBindings>(key: K, instance: ServiceBindings[K]): Disposable;
|
|
110
43
|
fake(key: string, instance: unknown): Disposable;
|
|
111
|
-
/**
|
|
112
|
-
* Check if a service is currently faked.
|
|
113
|
-
*/
|
|
114
44
|
isFaked(key: string): boolean;
|
|
115
|
-
/**
|
|
116
|
-
* Remove all fakes.
|
|
117
|
-
*/
|
|
118
45
|
clearFakes(): void;
|
|
119
|
-
/**
|
|
120
|
-
* Flush all resolved singleton instances.
|
|
121
|
-
*/
|
|
122
46
|
flush(): void;
|
|
123
|
-
/**
|
|
124
|
-
* Remove a binding from the container.
|
|
125
|
-
*/
|
|
126
47
|
forget(key: string): this;
|
|
127
|
-
/**
|
|
128
|
-
* Get all bound service keys.
|
|
129
|
-
*/
|
|
130
48
|
getBindings(): string[];
|
|
131
|
-
/**
|
|
132
|
-
* Get all aliases.
|
|
133
|
-
*/
|
|
134
49
|
getAliases(): Record<string, string>;
|
|
135
|
-
/**
|
|
136
|
-
* Get all tags.
|
|
137
|
-
*/
|
|
138
50
|
getTags(): Record<string, string[]>;
|
|
139
51
|
protected resolveAlias(key: string): string;
|
|
140
52
|
protected findContextualBinding(needs: string): ServiceFactory<unknown> | null;
|
|
141
53
|
}
|
|
142
|
-
/**
|
|
143
|
-
* Create a new container instance.
|
|
144
|
-
*/
|
|
145
54
|
export declare function createContainer(): Container;
|
|
146
55
|
export declare function setContainer(container: Container): void;
|
|
147
56
|
export declare function getContainer(): Container;
|