@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
|
@@ -5,56 +5,22 @@ import type { Provider } from './types.js';
|
|
|
5
5
|
*/
|
|
6
6
|
export type ServiceProviderConstructor = new (container: Container) => ServiceProvider;
|
|
7
7
|
/**
|
|
8
|
-
* Base service provider
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* Your own application, as well as all core services, are bootstrapped via providers.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* export class AppServiceProvider extends ServiceProvider {
|
|
16
|
-
* register(): void {
|
|
17
|
-
* // Register bindings
|
|
18
|
-
* this.container.singleton('db', (c) => new Database(c.make('config')))
|
|
19
|
-
* }
|
|
20
|
-
*
|
|
21
|
-
* boot(): void {
|
|
22
|
-
* // Bootstrap after all providers registered
|
|
23
|
-
* const db = this.container.make<Database>('db')
|
|
24
|
-
* db.connect()
|
|
25
|
-
* }
|
|
26
|
-
* }
|
|
27
|
-
* ```
|
|
8
|
+
* Base service provider: all application and core bootstrapping runs through
|
|
9
|
+
* providers. `register()` binds services before any provider boots; `boot()` runs
|
|
10
|
+
* after every provider has registered.
|
|
28
11
|
*/
|
|
29
12
|
export declare abstract class ServiceProvider implements Provider {
|
|
30
13
|
protected container: Container;
|
|
31
|
-
/**
|
|
32
|
-
* Whether this provider should be deferred.
|
|
33
|
-
* Deferred providers are only loaded when one of their provided services is requested.
|
|
34
|
-
*/
|
|
14
|
+
/** Load only when one of `provides` is requested. */
|
|
35
15
|
static deferred: boolean;
|
|
36
|
-
/**
|
|
37
|
-
* The services provided by this provider (for deferred loading).
|
|
38
|
-
*/
|
|
16
|
+
/** Services this provider supplies, for deferred loading. */
|
|
39
17
|
static provides: string[];
|
|
40
18
|
constructor(container: Container);
|
|
41
|
-
/**
|
|
42
|
-
* Register any application services.
|
|
43
|
-
* This is called before any other providers have booted.
|
|
44
|
-
*/
|
|
19
|
+
/** Runs before any provider has booted. */
|
|
45
20
|
abstract register(): void | Promise<void>;
|
|
46
|
-
/**
|
|
47
|
-
* Bootstrap any application services.
|
|
48
|
-
* This is called after all providers have registered.
|
|
49
|
-
*/
|
|
21
|
+
/** Runs after all providers have registered. */
|
|
50
22
|
boot?(): void | Promise<void>;
|
|
51
|
-
/**
|
|
52
|
-
* Get the services provided by the provider.
|
|
53
|
-
*/
|
|
54
23
|
provides(): string[];
|
|
55
|
-
/**
|
|
56
|
-
* Check if this provider is deferred.
|
|
57
|
-
*/
|
|
58
24
|
isDeferred(): boolean;
|
|
59
25
|
}
|
|
60
26
|
/**
|
|
@@ -66,38 +32,28 @@ export declare class ProviderManager {
|
|
|
66
32
|
protected registered: Set<ServiceProvider>;
|
|
67
33
|
protected booted: Set<ServiceProvider>;
|
|
68
34
|
protected deferredProviders: Map<string, ServiceProvider>;
|
|
35
|
+
/** Per service, the boot of an already-activated deferred provider, so a later loadDeferredProvider() awaits that boot */
|
|
36
|
+
private deferredActivations;
|
|
69
37
|
private allBooted;
|
|
70
38
|
constructor(container: Container);
|
|
71
|
-
/**
|
|
72
|
-
* Register a provider.
|
|
73
|
-
*/
|
|
74
39
|
register(providerOrClass: ServiceProvider | ServiceProviderConstructor): this;
|
|
75
|
-
/**
|
|
76
|
-
* Register multiple providers.
|
|
77
|
-
*/
|
|
78
40
|
registerMany(providers: Array<ServiceProvider | ServiceProviderConstructor>): this;
|
|
79
|
-
/**
|
|
80
|
-
* Register all non-deferred providers.
|
|
81
|
-
*/
|
|
82
41
|
registerAll(): Promise<void>;
|
|
83
|
-
/**
|
|
84
|
-
* Boot all registered providers.
|
|
85
|
-
*/
|
|
86
42
|
bootAll(): Promise<void>;
|
|
87
43
|
/**
|
|
88
|
-
*
|
|
44
|
+
* Register, boot, and unclaim a deferred provider's services. Resolves once
|
|
45
|
+
* boot() has finished, also when Container.make() already activated it.
|
|
89
46
|
*/
|
|
90
47
|
loadDeferredProvider(service: string): Promise<void>;
|
|
91
48
|
/**
|
|
92
|
-
*
|
|
49
|
+
* Synchronous half of deferred loading, so a synchronous Container.make() can
|
|
50
|
+
* resolve the service: register() runs before this returns; boot() follows on the
|
|
51
|
+
* returned promise, which make() does not await (a boot failure is an unhandled
|
|
52
|
+
* rejection). Services are unclaimed up front so a re-entrant make() for a sibling
|
|
53
|
+
* service cannot register the provider twice.
|
|
93
54
|
*/
|
|
55
|
+
private activateDeferredProvider;
|
|
94
56
|
isDeferredService(service: string): boolean;
|
|
95
|
-
/**
|
|
96
|
-
* Get all registered providers.
|
|
97
|
-
*/
|
|
98
57
|
getProviders(): ServiceProvider[];
|
|
99
|
-
/**
|
|
100
|
-
* Get all deferred services.
|
|
101
|
-
*/
|
|
102
58
|
getDeferredServices(): string[];
|
|
103
59
|
}
|
|
@@ -19,18 +19,7 @@ import type { Gate } from '../authorization/Gate.js';
|
|
|
19
19
|
import type { ExceptionHandler } from '../errors/index.js';
|
|
20
20
|
import type { SharedInertiaPropsRegistry } from '../mvc/inertia/shared.js';
|
|
21
21
|
import type { AgentAuditEmitter } from '../agent/audit-emitter.js';
|
|
22
|
-
/**
|
|
23
|
-
* Type-safe service binding map.
|
|
24
|
-
*
|
|
25
|
-
* Maps service keys to their concrete types for type-safe resolution
|
|
26
|
-
* via `container.make('key')`.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```typescript
|
|
30
|
-
* const events = container.make('events') // EventManager
|
|
31
|
-
* const cache = container.make('cache') // CacheManager
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
22
|
+
/** Maps service keys to their concrete types, for `container.make('key')`. */
|
|
34
23
|
export interface ServiceBindings {
|
|
35
24
|
app: Application;
|
|
36
25
|
hono: Hono;
|
|
@@ -54,20 +43,10 @@ export interface ServiceBindings {
|
|
|
54
43
|
'inertia.sharedProps': SharedInertiaPropsRegistry;
|
|
55
44
|
/**
|
|
56
45
|
* How an agent surface records what it did (RFC 0016 §5.2). Bound by
|
|
57
|
-
* `@guren/plugin-mcp` at boot,
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* The binding is the *emitter*, not the sink: a second caller that resolved
|
|
62
|
-
* a sink would have to build its own emitter around it, and the two would
|
|
63
|
-
* then differ on the questions the emitter answers — whether a sink failure
|
|
64
|
-
* warns, whether the events are emitted beside it. One emitter per
|
|
65
|
-
* application means every surface's records reach the same place the same
|
|
66
|
-
* way.
|
|
67
|
-
*
|
|
68
|
-
* An interface key cannot be a constant, so the *runtime* spelling of this
|
|
69
|
-
* name lives once in `AGENT_AUDIT_BINDING`, which both the writing and the
|
|
70
|
-
* reading package import. Rename here and there together.
|
|
46
|
+
* `@guren/plugin-mcp` at boot, absent when no MCP plugin is registered. The
|
|
47
|
+
* binding is the *emitter*, not the sink, so every surface's records reach
|
|
48
|
+
* the same place the same way. The runtime spelling of this name lives in
|
|
49
|
+
* `AGENT_AUDIT_BINDING` — rename here and there together.
|
|
71
50
|
*/
|
|
72
51
|
'agent.audit': AgentAuditEmitter;
|
|
73
52
|
'exception.handler': ExceptionHandler;
|
|
@@ -2,11 +2,9 @@ import type { CommandClass } from '../console/types.js';
|
|
|
2
2
|
import type { Router } from '../mvc/Router.js';
|
|
3
3
|
import type { ServiceProviderConstructor } from './ServiceProvider.js';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* `
|
|
7
|
-
*
|
|
8
|
-
* register/boot lifecycle of its own: it's a plain descriptor bundling
|
|
9
|
-
* providers and a route registrar that `Application` folds into its own
|
|
5
|
+
* A self-contained `modules/<name>/` directory registering routes and
|
|
6
|
+
* providers (RFC 0002). Unlike `definePlugin()` it has no config stage and no
|
|
7
|
+
* register/boot lifecycle: `Application` folds the descriptor into its own
|
|
10
8
|
* provider list and route mounting.
|
|
11
9
|
*/
|
|
12
10
|
export interface ModuleDefinition {
|
|
@@ -14,8 +12,7 @@ export interface ModuleDefinition {
|
|
|
14
12
|
name: string;
|
|
15
13
|
/**
|
|
16
14
|
* URL prefix applied to all module routes via `router.group(prefix, ...)`.
|
|
17
|
-
* Declarative
|
|
18
|
-
* statically without executing the registrar.
|
|
15
|
+
* Declarative so tooling can read the URL surface without running the registrar.
|
|
19
16
|
*/
|
|
20
17
|
prefix?: string;
|
|
21
18
|
/** Route registrar, invoked after `options.routes` during boot. */
|
|
@@ -23,21 +20,16 @@ export interface ModuleDefinition {
|
|
|
23
20
|
/** Providers appended to the application's provider list. */
|
|
24
21
|
providers?: ServiceProviderConstructor[];
|
|
25
22
|
/**
|
|
26
|
-
* Console commands the module owns,
|
|
27
|
-
*
|
|
28
|
-
* `
|
|
29
|
-
*
|
|
30
|
-
* command registration stays explicit so a bundled deployment resolves
|
|
31
|
-
* the same commands as a local checkout.
|
|
23
|
+
* Console commands the module owns, for the project's console entrypoint to
|
|
24
|
+
* register (`kernel.registerMany(billingModule.commands)`). Nothing registers
|
|
25
|
+
* them automatically: `Application` never builds a `ConsoleKernel`, and
|
|
26
|
+
* explicit registration keeps a bundled deployment resolving the same set.
|
|
32
27
|
*/
|
|
33
28
|
commands?: CommandClass[];
|
|
34
29
|
}
|
|
35
30
|
/**
|
|
36
|
-
* A module as `Application` consumes it
|
|
37
|
-
*
|
|
38
|
-
* fallback. `commands` in particular is read by hand-written console
|
|
39
|
-
* entrypoints (`kernel.registerMany(billingModule.commands)`), where an
|
|
40
|
-
* `undefined` would be a runtime error rather than a no-op.
|
|
31
|
+
* A module as `Application` consumes it: `providers` and `commands` normalized
|
|
32
|
+
* to arrays, so a console entrypoint reading `commands` cannot hit `undefined`.
|
|
41
33
|
*/
|
|
42
34
|
export interface GurenModule {
|
|
43
35
|
name: string;
|
|
@@ -46,43 +38,13 @@ export interface GurenModule {
|
|
|
46
38
|
providers: ServiceProviderConstructor[];
|
|
47
39
|
commands: CommandClass[];
|
|
48
40
|
}
|
|
49
|
-
/**
|
|
50
|
-
* Define a Guren application module without boilerplate.
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```typescript
|
|
54
|
-
* // modules/billing/index.ts
|
|
55
|
-
* export const billingModule = defineModule({
|
|
56
|
-
* name: 'billing',
|
|
57
|
-
* prefix: '/billing',
|
|
58
|
-
* routes: registerBillingRoutes,
|
|
59
|
-
* providers: [BillingServiceProvider],
|
|
60
|
-
* commands: [InvoiceCommand],
|
|
61
|
-
* })
|
|
62
|
-
*
|
|
63
|
-
* // src/app.ts
|
|
64
|
-
* createApp({ routes, providers, modules: [billingModule] })
|
|
65
|
-
*
|
|
66
|
-
* // src/console.ts
|
|
67
|
-
* kernel.registerMany(billingModule.commands)
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
41
|
+
/** Define a Guren application module without boilerplate. */
|
|
70
42
|
export declare function defineModule(definition: ModuleDefinition): GurenModule;
|
|
71
43
|
/**
|
|
72
|
-
* Runs a module's route registrar
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* `router.group(prefix, callback)`'s callback is synchronous — it pushes
|
|
79
|
-
* the prefix, invokes the callback, then pops it, with no support for
|
|
80
|
-
* awaiting inside. Capturing the registrar's return value and awaiting it
|
|
81
|
-
* after `group()` returns preserves prefixing for the common case (a
|
|
82
|
-
* synchronous registrar, or an async one that calls `router.get`/`post`/
|
|
83
|
-
* etc. before its first `await`); route calls after an `await` inside an
|
|
84
|
-
* async, prefixed module registrar would run with the prefix already
|
|
85
|
-
* popped. Registrars with no prefix don't go through group() and have no
|
|
86
|
-
* such limitation.
|
|
44
|
+
* Runs a module's route registrar, applying its `prefix` via `router.group()`.
|
|
45
|
+
* Shared by `Application.mountRoutes()` and the CLI's route loader, so both see
|
|
46
|
+
* the same route set. `router.group()`'s callback is synchronous (prefix
|
|
47
|
+
* pushed, callback run, prefix popped), so route calls made after an `await`
|
|
48
|
+
* inside an async prefixed registrar run with the prefix already popped.
|
|
87
49
|
*/
|
|
88
50
|
export declare function mountModuleRoutes(router: Router, gurenModule: GurenModule): Promise<void>;
|
|
@@ -1,62 +1,29 @@
|
|
|
1
1
|
import type { Container } from './Container.js';
|
|
2
2
|
import { type ServiceProviderConstructor } from './ServiceProvider.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* `register` and `boot` mirror the ServiceProvider hooks and receive the
|
|
7
|
-
* container plus the configuration captured by the plugin factory.
|
|
4
|
+
* A plugin's lifecycle hooks, mirroring the ServiceProvider ones and receiving
|
|
5
|
+
* the configuration captured by the plugin factory.
|
|
8
6
|
*/
|
|
9
7
|
export interface PluginDefinition<TConfig = void> {
|
|
10
|
-
/**
|
|
11
|
-
* Diagnostic name for the plugin (e.g. 'analytics').
|
|
12
|
-
* Used to derive the generated provider class name.
|
|
13
|
-
*/
|
|
8
|
+
/** Diagnostic name, also used for the generated provider class name. */
|
|
14
9
|
name: string;
|
|
15
|
-
/**
|
|
16
|
-
* Register services into the container.
|
|
17
|
-
* Called before any provider has booted.
|
|
18
|
-
*/
|
|
10
|
+
/** Called before any provider has booted. */
|
|
19
11
|
register(container: Container, config: TConfig): void | Promise<void>;
|
|
20
|
-
/**
|
|
21
|
-
* Bootstrap after all providers have registered.
|
|
22
|
-
*/
|
|
12
|
+
/** Called after all providers have registered. */
|
|
23
13
|
boot?(container: Container, config: TConfig): void | Promise<void>;
|
|
24
|
-
/**
|
|
25
|
-
* Defer instantiation until one of the `provides` services is resolved.
|
|
26
|
-
* Maps to `ServiceProvider.deferred`.
|
|
27
|
-
*/
|
|
14
|
+
/** Defer instantiation until one of `provides` is resolved. */
|
|
28
15
|
deferred?: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Services bound by this plugin (required when `deferred` is true).
|
|
31
|
-
* Maps to `ServiceProvider.provides`.
|
|
32
|
-
*/
|
|
16
|
+
/** Services bound by this plugin; required when `deferred` is true. */
|
|
33
17
|
provides?: string[];
|
|
34
18
|
}
|
|
35
19
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
20
|
+
* Each call produces an independent ServiceProvider subclass with the given
|
|
21
|
+
* configuration captured in a closure.
|
|
38
22
|
*/
|
|
39
23
|
export type PluginFactory<TConfig = void> = (config: TConfig) => ServiceProviderConstructor;
|
|
40
24
|
/**
|
|
41
|
-
* Define a configurable Guren plugin without ServiceProvider boilerplate.
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* returns a fresh provider class, so the same plugin can be registered twice
|
|
45
|
-
* with different configurations.
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* ```typescript
|
|
49
|
-
* export const analyticsPlugin = definePlugin<AnalyticsConfig>({
|
|
50
|
-
* name: 'analytics',
|
|
51
|
-
* register(container, config) {
|
|
52
|
-
* container.singleton('analytics', () => new AnalyticsClient(config))
|
|
53
|
-
* },
|
|
54
|
-
* })
|
|
55
|
-
*
|
|
56
|
-
* // In the application:
|
|
57
|
-
* createApp({
|
|
58
|
-
* providers: [analyticsPlugin({ apiKey: process.env.ANALYTICS_API_KEY! })],
|
|
59
|
-
* })
|
|
60
|
-
* ```
|
|
25
|
+
* Define a configurable Guren plugin without ServiceProvider boilerplate. Each
|
|
26
|
+
* factory call returns a fresh provider class, so the same plugin can be
|
|
27
|
+
* registered twice with different configurations.
|
|
61
28
|
*/
|
|
62
29
|
export declare function definePlugin<TConfig = void>(definition: PluginDefinition<TConfig>): PluginFactory<TConfig>;
|
|
@@ -1,71 +1,39 @@
|
|
|
1
1
|
import type { Container } from './Container.js';
|
|
2
2
|
/**
|
|
3
3
|
* Structural type for DI containers, avoiding a hard dependency on Container
|
|
4
|
-
* where only resolution is needed
|
|
4
|
+
* where only resolution is needed.
|
|
5
5
|
*/
|
|
6
6
|
export interface ContainerLike {
|
|
7
7
|
make(key: string): unknown;
|
|
8
8
|
has?(key: string): boolean;
|
|
9
9
|
}
|
|
10
|
-
/**
|
|
11
|
-
* Service factory function.
|
|
12
|
-
*/
|
|
13
10
|
export type ServiceFactory<T> = (container: Container) => T;
|
|
14
|
-
/**
|
|
15
|
-
* Service class constructor.
|
|
16
|
-
*/
|
|
17
11
|
export type ServiceClass<T> = new (...args: unknown[]) => T;
|
|
18
|
-
/**
|
|
19
|
-
* Service binding configuration.
|
|
20
|
-
*/
|
|
21
12
|
export interface ServiceBinding {
|
|
22
13
|
factory: ServiceFactory<unknown>;
|
|
23
14
|
singleton: boolean;
|
|
24
15
|
instance?: unknown;
|
|
25
16
|
}
|
|
26
|
-
/**
|
|
27
|
-
* Contextual binding builder interface.
|
|
28
|
-
*/
|
|
29
17
|
export interface ContextualBindingBuilder {
|
|
30
18
|
needs(abstract: string): ContextualNeedsBuilder;
|
|
31
19
|
}
|
|
32
|
-
/**
|
|
33
|
-
* Contextual needs builder interface.
|
|
34
|
-
*/
|
|
35
20
|
export interface ContextualNeedsBuilder {
|
|
36
21
|
give<T>(factory: ServiceFactory<T> | T): void;
|
|
37
22
|
}
|
|
38
|
-
/**
|
|
39
|
-
* Contextual binding configuration.
|
|
40
|
-
*/
|
|
41
23
|
export interface ContextualBinding {
|
|
42
24
|
concrete: string;
|
|
43
25
|
needs: string;
|
|
44
26
|
factory: ServiceFactory<unknown>;
|
|
45
27
|
}
|
|
46
|
-
/**
|
|
47
|
-
* Service provider options.
|
|
48
|
-
*/
|
|
49
28
|
export interface ServiceProviderOptions {
|
|
50
|
-
/**
|
|
51
|
-
* Whether this provider should be deferred.
|
|
52
|
-
*/
|
|
53
29
|
deferred?: boolean;
|
|
54
|
-
/**
|
|
55
|
-
* Services this provider provides (for deferred loading).
|
|
56
|
-
*/
|
|
30
|
+
/** Services this provider provides, for deferred loading. */
|
|
57
31
|
provides?: string[];
|
|
58
32
|
}
|
|
59
|
-
/**
|
|
60
|
-
* Provider interface for container-based service providers.
|
|
61
|
-
*/
|
|
62
33
|
export interface Provider {
|
|
63
34
|
register?(context: unknown): void | Promise<void>;
|
|
64
35
|
boot?(context: unknown): void | Promise<void>;
|
|
65
36
|
}
|
|
66
|
-
/**
|
|
67
|
-
* Service provider class type.
|
|
68
|
-
*/
|
|
69
37
|
export interface ServiceProviderClass {
|
|
70
38
|
new (container: Container): Provider;
|
|
71
39
|
deferred?: boolean;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/auth/context.ts
|
|
2
|
+
/**
|
|
3
|
+
* Context key the framework auth context is stored under.
|
|
4
|
+
*
|
|
5
|
+
* Lives here rather than in `http/middleware/auth` so that `auth/` modules can
|
|
6
|
+
* import it without reaching back into the middleware layer. The middleware
|
|
7
|
+
* re-exports it, and it stays a public root export.
|
|
8
|
+
*/
|
|
9
|
+
const AUTH_CONTEXT_KEY = "guren:auth";
|
|
10
|
+
/**
|
|
11
|
+
* Read the framework auth context off a request context. `ctx.get` returns
|
|
12
|
+
* arbitrary values for unknown keys, so the cast is a claim, not a check. A
|
|
13
|
+
* caller whose behavior turns on a real auth context probes the member it is
|
|
14
|
+
* about to call, as `Gate.resolveUser` does before its legacy `ctx.get('user')`
|
|
15
|
+
* fallback; probing here would reject contexts `requireAuthenticated` can use.
|
|
16
|
+
*/
|
|
17
|
+
function getAuthContext(ctx) {
|
|
18
|
+
return ctx.get(AUTH_CONTEXT_KEY);
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { getAuthContext as n, AUTH_CONTEXT_KEY as t };
|
|
@@ -1,82 +1,29 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* State definition for factories.
|
|
3
|
-
*/
|
|
4
1
|
type StateDefinition<T> = Partial<T> | ((attributes: Partial<T>) => Partial<T>);
|
|
5
|
-
/**
|
|
6
|
-
* Abstract base class for model factories.
|
|
7
|
-
*/
|
|
8
2
|
export declare abstract class BaseFactory<T> {
|
|
9
3
|
private _sequence;
|
|
10
4
|
private _states;
|
|
11
5
|
private _activeStates;
|
|
12
6
|
private _afterCreatingCallbacks;
|
|
13
7
|
private _afterMakingCallbacks;
|
|
14
|
-
/**
|
|
15
|
-
* Get the current sequence number.
|
|
16
|
-
*/
|
|
17
8
|
protected get sequence(): number;
|
|
18
|
-
/**
|
|
19
|
-
* Define the default attributes for the model.
|
|
20
|
-
*/
|
|
9
|
+
/** The model's default attributes. */
|
|
21
10
|
abstract definition(): Partial<T>;
|
|
22
|
-
/**
|
|
23
|
-
* Create a model instance (to be overridden for persistence).
|
|
24
|
-
*/
|
|
11
|
+
/** Override to persist. */
|
|
25
12
|
protected persist(attributes: Partial<T>): Promise<T>;
|
|
26
|
-
/**
|
|
27
|
-
* Define a state.
|
|
28
|
-
*/
|
|
29
13
|
state(name: string, state: StateDefinition<T>): this;
|
|
30
|
-
/**
|
|
31
|
-
* Apply a state to the factory.
|
|
32
|
-
*/
|
|
33
14
|
withState(name: string): this;
|
|
34
|
-
/**
|
|
35
|
-
* Apply multiple states.
|
|
36
|
-
*/
|
|
37
15
|
withStates(...names: string[]): this;
|
|
38
|
-
/**
|
|
39
|
-
* Register a callback to run after creating.
|
|
40
|
-
*/
|
|
41
16
|
afterCreating(callback: (model: T) => void | Promise<void>): this;
|
|
42
|
-
/**
|
|
43
|
-
* Register a callback to run after making.
|
|
44
|
-
*/
|
|
45
17
|
afterMaking(callback: (model: T) => void | Promise<void>): this;
|
|
46
|
-
/**
|
|
47
|
-
* Make a model instance without persisting.
|
|
48
|
-
*/
|
|
18
|
+
/** Build without persisting. */
|
|
49
19
|
make(overrides?: Partial<T>): T;
|
|
50
|
-
/**
|
|
51
|
-
* Make multiple model instances without persisting.
|
|
52
|
-
*/
|
|
53
20
|
makeMany(count: number, overrides?: Partial<T>): T[];
|
|
54
|
-
/**
|
|
55
|
-
* Create and persist a model instance.
|
|
56
|
-
*/
|
|
57
21
|
create(overrides?: Partial<T>): Promise<T>;
|
|
58
|
-
/**
|
|
59
|
-
* Create and persist multiple model instances.
|
|
60
|
-
*/
|
|
61
22
|
createMany(count: number, overrides?: Partial<T>): Promise<T[]>;
|
|
62
|
-
/**
|
|
63
|
-
* Reset the sequence counter.
|
|
64
|
-
*/
|
|
65
23
|
resetSequence(): this;
|
|
66
|
-
/**
|
|
67
|
-
* Clear active states.
|
|
68
|
-
*/
|
|
69
24
|
clearStates(): this;
|
|
70
|
-
/**
|
|
71
|
-
* Create a new factory instance with fresh state.
|
|
72
|
-
*/
|
|
25
|
+
/** A new factory instance with fresh state. */
|
|
73
26
|
fresh(): this;
|
|
74
27
|
}
|
|
75
|
-
/**
|
|
76
|
-
* Alias for BaseFactory.
|
|
77
|
-
*/
|
|
78
28
|
export { BaseFactory as Factory };
|
|
79
|
-
/**
|
|
80
|
-
* Helper to create a simple factory with a definition function.
|
|
81
|
-
*/
|
|
82
29
|
export declare function defineFactory<T>(definition: (sequence: number) => Partial<T>, persist?: (attributes: Partial<T>) => Promise<T>): BaseFactory<T>;
|
|
@@ -1,72 +1,34 @@
|
|
|
1
1
|
import type { SeederClass } from './types.js';
|
|
2
2
|
/**
|
|
3
|
-
* Reset called seeders tracking (for testing).
|
|
4
|
-
*
|
|
5
3
|
* @deprecated Bookkeeping for {@link BaseSeeder}'s `callOnce`. Write seeders
|
|
6
4
|
* with `defineSeeder` from `@guren/core` instead, which needs no such
|
|
7
5
|
* tracking. Deprecated in 2.9.0, removed in 3.0.0.
|
|
8
6
|
*/
|
|
9
7
|
export declare function resetCalledSeeders(): void;
|
|
10
8
|
/**
|
|
11
|
-
* Abstract base class for database seeders.
|
|
12
|
-
*
|
|
13
9
|
* @deprecated Write seeders with `defineSeeder` from `@guren/core` instead.
|
|
14
10
|
* Deprecated in 2.9.0, removed in 3.0.0.
|
|
15
11
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* declared to take no parameters, so it hides the one argument a seeder
|
|
21
|
-
* needs.
|
|
22
|
-
*
|
|
23
|
-
* A subclass cannot simply correct that: declaring `run(ctx: SeederContext)`
|
|
24
|
-
* fails to compile against the base (`TS2416: Target signature provides too
|
|
25
|
-
* few arguments. Expected 1 or more, but got 0`). Widening it to an optional
|
|
26
|
-
* `run(ctx?: SeederContext)` does compile, but then the subclass has to handle
|
|
27
|
-
* a missing context — and that case is real, because
|
|
28
|
-
* {@link BaseSeeder.call}, {@link BaseSeeder.callOnce},
|
|
29
|
-
* {@link BaseSeeder.callMany} and {@link BaseSeeder.callParallel} construct
|
|
30
|
-
* child seeders and invoke `run()` with no arguments at all. A parent that
|
|
31
|
-
* received a context cannot pass it down.
|
|
32
|
-
*
|
|
33
|
-
* The orchestration these classes were written for, `SeederRunner`, is
|
|
34
|
-
* reached by no Guren command.
|
|
12
|
+
* The signature is the problem: `run()` takes no parameters, so it hides the
|
|
13
|
+
* `{ db }` context `runSeeders()` passes, and a subclass cannot widen it
|
|
14
|
+
* (TS2416). The orchestration these classes were written for, `SeederRunner`,
|
|
15
|
+
* is reached by no Guren command.
|
|
35
16
|
*/
|
|
36
17
|
export declare abstract class BaseSeeder {
|
|
37
18
|
constructor();
|
|
38
19
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* Declared without parameters, which is what makes this class the wrong
|
|
42
|
-
* base: `runSeeders()` calls it with a `{ db }` context that this signature
|
|
43
|
-
* cannot name.
|
|
20
|
+
* Declared without parameters: `runSeeders()` calls it with a `{ db }`
|
|
21
|
+
* context this signature cannot name.
|
|
44
22
|
*/
|
|
45
23
|
abstract run(): Promise<void>;
|
|
46
|
-
/**
|
|
47
|
-
* Call another seeder.
|
|
48
|
-
*
|
|
49
|
-
* No context is forwarded: the child's `run()` is invoked with no
|
|
50
|
-
* arguments, whatever the caller itself received.
|
|
51
|
-
*/
|
|
24
|
+
/** No context is forwarded: the child's `run()` gets no arguments. */
|
|
52
25
|
protected call(SeederClass: SeederClass): Promise<void>;
|
|
53
|
-
/**
|
|
54
|
-
* Call another seeder only once.
|
|
55
|
-
* Useful for avoiding duplicate data when seeders have dependencies.
|
|
56
|
-
*/
|
|
26
|
+
/** Skips the seeder if it already ran in this process. */
|
|
57
27
|
protected callOnce(SeederClass: SeederClass): Promise<void>;
|
|
58
|
-
/**
|
|
59
|
-
* Call multiple seeders in sequence.
|
|
60
|
-
*/
|
|
61
28
|
protected callMany(seeders: SeederClass[]): Promise<void>;
|
|
62
|
-
/**
|
|
63
|
-
* Call multiple seeders in parallel.
|
|
64
|
-
*/
|
|
65
29
|
protected callParallel(seeders: SeederClass[]): Promise<void>;
|
|
66
30
|
}
|
|
67
31
|
/**
|
|
68
|
-
* Alias for BaseSeeder.
|
|
69
|
-
*
|
|
70
32
|
* @deprecated Write seeders with `defineSeeder` from `@guren/core` instead.
|
|
71
33
|
* Deprecated in 2.9.0, removed in 3.0.0. See {@link BaseSeeder}.
|
|
72
34
|
*/
|
|
@@ -1,56 +1,26 @@
|
|
|
1
1
|
import type { SeederClass, SeederRunnerOptions } from './types.js';
|
|
2
2
|
/**
|
|
3
|
-
* Seeder runner for executing database seeders.
|
|
4
|
-
*
|
|
5
3
|
* @deprecated No Guren command reaches this runner. Write seeders with
|
|
6
4
|
* `defineSeeder` from `@guren/core` and run them with `db:seed`. Deprecated
|
|
7
5
|
* in 2.9.0, removed in 3.0.0.
|
|
8
6
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* runner orchestrates differently: it runs a single seeder per call, taken
|
|
12
|
-
* from a class passed in, a name registered with {@link SeederRunner.register},
|
|
13
|
-
* or a name resolved to `<seedersPath>/<Name>.ts` and defaulting to
|
|
14
|
-
* `DatabaseSeeder`; it constructs it with `new` and invokes `.run()` with no
|
|
15
|
-
* context. Nothing in the framework calls any of it. See {@link BaseSeeder}
|
|
16
|
-
* for what the no-context `run()` costs a seeder written against it.
|
|
7
|
+
* It runs a single seeder per call and invokes `.run()` with no context,
|
|
8
|
+
* unlike `runSeeders()`, which hands every seeder a `{ db }` context.
|
|
17
9
|
*/
|
|
18
10
|
export declare class SeederRunner {
|
|
19
11
|
private options;
|
|
20
12
|
private seeders;
|
|
21
13
|
constructor(options?: SeederRunnerOptions);
|
|
22
|
-
/**
|
|
23
|
-
* Register a seeder class.
|
|
24
|
-
*/
|
|
25
14
|
register(name: string, seeder: SeederClass): this;
|
|
26
|
-
/**
|
|
27
|
-
* Register multiple seeder classes.
|
|
28
|
-
*/
|
|
29
15
|
registerMany(seeders: Record<string, SeederClass>): this;
|
|
30
|
-
/**
|
|
31
|
-
* Run a specific seeder by name or class.
|
|
32
|
-
*/
|
|
33
16
|
run(seeder?: string | SeederClass): Promise<void>;
|
|
34
|
-
/**
|
|
35
|
-
* Run multiple seeders in sequence.
|
|
36
|
-
*/
|
|
37
17
|
runMany(seeders: Array<string | SeederClass>): Promise<void>;
|
|
38
|
-
/**
|
|
39
|
-
* Resolve a seeder by name.
|
|
40
|
-
*/
|
|
41
18
|
private resolveSeeder;
|
|
42
|
-
/**
|
|
43
|
-
* Get available seeders from the seeders directory.
|
|
44
|
-
*/
|
|
19
|
+
/** The seeder names found in the seeders directory. */
|
|
45
20
|
getAvailableSeeders(): Promise<string[]>;
|
|
46
|
-
/**
|
|
47
|
-
* Log a message if not silent.
|
|
48
|
-
*/
|
|
49
21
|
private log;
|
|
50
22
|
}
|
|
51
23
|
/**
|
|
52
|
-
* Create a seeder runner.
|
|
53
|
-
*
|
|
54
24
|
* @deprecated No Guren command reaches this runner. Write seeders with
|
|
55
25
|
* `defineSeeder` from `@guren/core` instead. Deprecated in 2.9.0, removed in
|
|
56
26
|
* 3.0.0. See {@link SeederRunner}.
|