@guren/server 2.14.0 → 2.16.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-CzrwKeDp.js → Hash-D2DFd8xX.js} +12 -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-nNcbCIQX.js} +11 -20
- package/dist/{Random-DbIJ22KQ.js → Random-S0OvCuR8.js} +9 -106
- package/dist/agent/AgentApprovalRequested.d.ts +31 -0
- package/dist/agent/approval.d.ts +184 -0
- package/dist/agent/audit-emitter.d.ts +36 -0
- package/dist/agent/audit.d.ts +67 -0
- package/dist/agent/derive.d.ts +32 -66
- package/dist/agent/dispatch.d.ts +53 -63
- package/dist/agent/events.d.ts +11 -19
- package/dist/agent/meta-tools.d.ts +34 -0
- package/dist/agent/public.d.ts +14 -0
- package/dist/agent/public.js +2 -0
- package/dist/agent/redact.d.ts +16 -38
- package/dist/agent/scopes.d.ts +23 -69
- package/dist/auth/AuthManager.d.ts +19 -40
- 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 +9 -5
- package/dist/auth/password/PasswordHasher.d.ts +7 -0
- package/dist/auth/password/hash-format.d.ts +11 -0
- 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-BSUc14CD.js → auth-CbdPH4Cd.js} +252 -496
- 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-BxU-LIfF.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 +10 -12
- 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-BAwzftws.js +238 -0
- 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-DJtkkhiw.js → encryption-uwP3Di4D.js} +13 -79
- 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 +62 -208
- package/dist/http/FormRequest.d.ts +4 -55
- package/dist/http/dev-assets.d.ts +16 -18
- 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 +20 -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/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 +14 -0
- package/dist/http/request.d.ts +49 -48
- 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 +21 -0
- 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 +13 -4
- package/dist/index.js +1036 -3080
- package/dist/internal/agent-preflight.d.ts +9 -21
- package/dist/internal/request.d.ts +10 -17
- package/dist/internal/request.js +2 -2
- 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 -5
- package/dist/logging/channels/FileChannel.d.ts +1 -3
- package/dist/logging/daily-file-path.d.ts +15 -0
- package/dist/logging/index.d.ts +1 -0
- package/dist/logging/index.js +2 -2
- package/dist/logging/types.d.ts +13 -45
- package/dist/{logging-CPaRMuPP.js → logging-zOY1XCtq.js} +83 -129
- 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 +25 -57
- package/dist/mcp/endpoint.d.ts +12 -36
- package/dist/mcp/index.js +1 -1
- package/dist/mvc/Controller.d.ts +46 -253
- 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 +108 -74
- 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-BGfWbPYp.js → vite-manifest-CTQp-SOo.js} +34 -58
- package/package.json +6 -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-CRVuIiQr.js +0 -78
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
import { n as isHotReloadRuntime, t as claimHotDisposable } from "./hot-disposables-
|
|
1
|
+
import { n as isHotReloadRuntime, t as claimHotDisposable } from "./hot-disposables-B5BXqaIH.js";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
import { mkdir, readFile, readdir, rm, unlink, writeFile } from "node:fs/promises";
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
6
6
|
//#region src/cache/stores/MemoryStore.ts
|
|
7
|
-
/**
|
|
8
|
-
* In-memory cache store.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* const store = new MemoryStore()
|
|
13
|
-
*
|
|
14
|
-
* await store.set('user:1', { name: 'John' }, 3600)
|
|
15
|
-
* const user = await store.get<User>('user:1')
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
7
|
+
/** In-memory cache store. */
|
|
18
8
|
var MemoryStore = class {
|
|
19
9
|
cache = /* @__PURE__ */ new Map();
|
|
20
10
|
maxSize;
|
|
@@ -31,22 +21,13 @@ var MemoryStore = class {
|
|
|
31
21
|
if (this.checkInterval.unref) this.checkInterval.unref();
|
|
32
22
|
}
|
|
33
23
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Remove expired items from the cache.
|
|
36
|
-
*/
|
|
37
24
|
removeExpired() {
|
|
38
25
|
const now = this.now();
|
|
39
26
|
for (const [key, item] of this.cache) if (item.expiresAt !== null && item.expiresAt <= now) this.cache.delete(key);
|
|
40
27
|
}
|
|
41
|
-
/**
|
|
42
|
-
* Check if an item is expired.
|
|
43
|
-
*/
|
|
44
28
|
isExpired(item) {
|
|
45
29
|
return item.expiresAt !== null && item.expiresAt <= this.now();
|
|
46
30
|
}
|
|
47
|
-
/**
|
|
48
|
-
* Evict items if cache is full.
|
|
49
|
-
*/
|
|
50
31
|
evictIfNeeded() {
|
|
51
32
|
if (this.cache.size >= this.maxSize) {
|
|
52
33
|
const firstKey = this.cache.keys().next().value;
|
|
@@ -132,15 +113,10 @@ var MemoryStore = class {
|
|
|
132
113
|
if (item.expiresAt === null) return -1;
|
|
133
114
|
return Math.max(0, Math.ceil((item.expiresAt - this.now()) / 1e3));
|
|
134
115
|
}
|
|
135
|
-
/**
|
|
136
|
-
* Get the number of items in the cache.
|
|
137
|
-
*/
|
|
138
116
|
size() {
|
|
139
117
|
return this.cache.size;
|
|
140
118
|
}
|
|
141
|
-
/**
|
|
142
|
-
* Stop the expiration check interval.
|
|
143
|
-
*/
|
|
119
|
+
/** Stop the expiration check interval. */
|
|
144
120
|
destroy() {
|
|
145
121
|
if (this.checkInterval) {
|
|
146
122
|
clearInterval(this.checkInterval);
|
|
@@ -150,20 +126,7 @@ var MemoryStore = class {
|
|
|
150
126
|
};
|
|
151
127
|
//#endregion
|
|
152
128
|
//#region src/cache/stores/RedisStore.ts
|
|
153
|
-
/**
|
|
154
|
-
* Redis-backed cache store.
|
|
155
|
-
*
|
|
156
|
-
* @example
|
|
157
|
-
* ```ts
|
|
158
|
-
* import Redis from 'ioredis'
|
|
159
|
-
*
|
|
160
|
-
* const redis = new Redis(process.env.REDIS_URL)
|
|
161
|
-
* const store = new RedisStore({ client: redis })
|
|
162
|
-
*
|
|
163
|
-
* await store.set('user:1', { name: 'John' }, 3600)
|
|
164
|
-
* const user = await store.get<User>('user:1')
|
|
165
|
-
* ```
|
|
166
|
-
*/
|
|
129
|
+
/** Redis-backed cache store. */
|
|
167
130
|
var RedisStore = class {
|
|
168
131
|
client;
|
|
169
132
|
prefix;
|
|
@@ -171,21 +134,12 @@ var RedisStore = class {
|
|
|
171
134
|
this.client = options.client;
|
|
172
135
|
this.prefix = options.prefix ?? "cache:";
|
|
173
136
|
}
|
|
174
|
-
/**
|
|
175
|
-
* Get the prefixed key.
|
|
176
|
-
*/
|
|
177
137
|
prefixKey(key) {
|
|
178
138
|
return `${this.prefix}${key}`;
|
|
179
139
|
}
|
|
180
|
-
/**
|
|
181
|
-
* Serialize a value for storage.
|
|
182
|
-
*/
|
|
183
140
|
serialize(value) {
|
|
184
141
|
return JSON.stringify(value);
|
|
185
142
|
}
|
|
186
|
-
/**
|
|
187
|
-
* Deserialize a stored value.
|
|
188
|
-
*/
|
|
189
143
|
deserialize(value) {
|
|
190
144
|
if (value === null) return null;
|
|
191
145
|
try {
|
|
@@ -215,14 +169,10 @@ var RedisStore = class {
|
|
|
215
169
|
if (keys.length > 0) await this.client.del(...keys);
|
|
216
170
|
}
|
|
217
171
|
async increment(key, value = 1) {
|
|
218
|
-
|
|
219
|
-
if (!await this.client.exists(prefixedKey)) await this.client.set(prefixedKey, "0");
|
|
220
|
-
return this.client.incrby(prefixedKey, value);
|
|
172
|
+
return this.client.incrby(this.prefixKey(key), value);
|
|
221
173
|
}
|
|
222
174
|
async decrement(key, value = 1) {
|
|
223
|
-
|
|
224
|
-
if (!await this.client.exists(prefixedKey)) await this.client.set(prefixedKey, "0");
|
|
225
|
-
return this.client.decrby(prefixedKey, value);
|
|
175
|
+
return this.client.decrby(this.prefixKey(key), value);
|
|
226
176
|
}
|
|
227
177
|
async remember(key, ttl, callback) {
|
|
228
178
|
const cached = await this.get(key);
|
|
@@ -263,32 +213,16 @@ var RedisStore = class {
|
|
|
263
213
|
async ttl(key) {
|
|
264
214
|
return this.client.ttl(this.prefixKey(key));
|
|
265
215
|
}
|
|
266
|
-
/**
|
|
267
|
-
* Get the Redis client instance.
|
|
268
|
-
*/
|
|
269
216
|
getClient() {
|
|
270
217
|
return this.client;
|
|
271
218
|
}
|
|
272
|
-
/**
|
|
273
|
-
* Get the key prefix.
|
|
274
|
-
*/
|
|
275
219
|
getPrefix() {
|
|
276
220
|
return this.prefix;
|
|
277
221
|
}
|
|
278
222
|
};
|
|
279
223
|
//#endregion
|
|
280
224
|
//#region src/cache/stores/FileStore.ts
|
|
281
|
-
/**
|
|
282
|
-
* File-based cache store.
|
|
283
|
-
*
|
|
284
|
-
* @example
|
|
285
|
-
* ```ts
|
|
286
|
-
* const store = new FileStore({ path: './storage/cache' })
|
|
287
|
-
*
|
|
288
|
-
* await store.set('user:1', { name: 'John' }, 3600)
|
|
289
|
-
* const user = await store.get<User>('user:1')
|
|
290
|
-
* ```
|
|
291
|
-
*/
|
|
225
|
+
/** File-based cache store. */
|
|
292
226
|
var FileStore = class {
|
|
293
227
|
basePath;
|
|
294
228
|
extension;
|
|
@@ -298,24 +232,15 @@ var FileStore = class {
|
|
|
298
232
|
this.extension = options.extension ?? ".cache";
|
|
299
233
|
this.now = options.now ?? Date.now;
|
|
300
234
|
}
|
|
301
|
-
/**
|
|
302
|
-
* Generate a hashed filename for a cache key.
|
|
303
|
-
*/
|
|
304
235
|
getFilePath(key) {
|
|
305
236
|
const hash = createHash("sha256").update(key).digest("hex");
|
|
306
237
|
const dir = hash.slice(0, 2);
|
|
307
238
|
return join(this.basePath, dir, `${hash}${this.extension}`);
|
|
308
239
|
}
|
|
309
|
-
/**
|
|
310
|
-
* Ensure the cache directory exists.
|
|
311
|
-
*/
|
|
312
240
|
async ensureDirectory(filePath) {
|
|
313
241
|
const dir = dirname(filePath);
|
|
314
242
|
if (!existsSync(dir)) await mkdir(dir, { recursive: true });
|
|
315
243
|
}
|
|
316
|
-
/**
|
|
317
|
-
* Read a cache file.
|
|
318
|
-
*/
|
|
319
244
|
async readCacheFile(filePath) {
|
|
320
245
|
try {
|
|
321
246
|
const content = await readFile(filePath, "utf-8");
|
|
@@ -324,16 +249,10 @@ var FileStore = class {
|
|
|
324
249
|
return null;
|
|
325
250
|
}
|
|
326
251
|
}
|
|
327
|
-
/**
|
|
328
|
-
* Write a cache file.
|
|
329
|
-
*/
|
|
330
252
|
async writeCacheFile(filePath, item) {
|
|
331
253
|
await this.ensureDirectory(filePath);
|
|
332
254
|
await writeFile(filePath, JSON.stringify(item), "utf-8");
|
|
333
255
|
}
|
|
334
|
-
/**
|
|
335
|
-
* Delete a cache file.
|
|
336
|
-
*/
|
|
337
256
|
async deleteCacheFile(filePath) {
|
|
338
257
|
try {
|
|
339
258
|
await unlink(filePath);
|
|
@@ -342,9 +261,6 @@ var FileStore = class {
|
|
|
342
261
|
return false;
|
|
343
262
|
}
|
|
344
263
|
}
|
|
345
|
-
/**
|
|
346
|
-
* Check if a cached item is expired.
|
|
347
|
-
*/
|
|
348
264
|
isExpired(item) {
|
|
349
265
|
return item.expiresAt !== null && item.expiresAt <= this.now();
|
|
350
266
|
}
|
|
@@ -432,10 +348,7 @@ var FileStore = class {
|
|
|
432
348
|
if (item.expiresAt === null) return -1;
|
|
433
349
|
return Math.max(0, Math.ceil((item.expiresAt - this.now()) / 1e3));
|
|
434
350
|
}
|
|
435
|
-
/**
|
|
436
|
-
* Clean up expired cache files.
|
|
437
|
-
* This can be called periodically to free disk space.
|
|
438
|
-
*/
|
|
351
|
+
/** Delete expired cache files; call periodically to free disk space. */
|
|
439
352
|
async cleanup() {
|
|
440
353
|
let cleaned = 0;
|
|
441
354
|
if (!existsSync(this.basePath)) return cleaned;
|
|
@@ -460,27 +373,13 @@ var FileStore = class {
|
|
|
460
373
|
}
|
|
461
374
|
return cleaned;
|
|
462
375
|
}
|
|
463
|
-
/**
|
|
464
|
-
* Get the base path.
|
|
465
|
-
*/
|
|
466
376
|
getBasePath() {
|
|
467
377
|
return this.basePath;
|
|
468
378
|
}
|
|
469
379
|
};
|
|
470
380
|
//#endregion
|
|
471
381
|
//#region src/cache/TaggedCache.ts
|
|
472
|
-
/**
|
|
473
|
-
* Tagged cache implementation.
|
|
474
|
-
* Allows grouping cache items by tags for bulk invalidation.
|
|
475
|
-
*
|
|
476
|
-
* @example
|
|
477
|
-
* ```ts
|
|
478
|
-
* const tagged = new TaggedCache(store, ['posts', 'user:1'])
|
|
479
|
-
*
|
|
480
|
-
* await tagged.set('user:1:posts', posts, 3600)
|
|
481
|
-
* await tagged.flush() // Removes all items with these tags
|
|
482
|
-
* ```
|
|
483
|
-
*/
|
|
382
|
+
/** Groups cache items by tags for bulk invalidation. */
|
|
484
383
|
var TaggedCache = class {
|
|
485
384
|
store;
|
|
486
385
|
tags;
|
|
@@ -490,9 +389,6 @@ var TaggedCache = class {
|
|
|
490
389
|
this.tags = tags;
|
|
491
390
|
this.tagSetPrefix = tagSetPrefix;
|
|
492
391
|
}
|
|
493
|
-
/**
|
|
494
|
-
* Get a unique namespace for the current tags.
|
|
495
|
-
*/
|
|
496
392
|
async getTagNamespace() {
|
|
497
393
|
const namespaces = [];
|
|
498
394
|
for (const tag of this.tags) {
|
|
@@ -506,21 +402,12 @@ var TaggedCache = class {
|
|
|
506
402
|
}
|
|
507
403
|
return namespaces.join(":");
|
|
508
404
|
}
|
|
509
|
-
/**
|
|
510
|
-
* Generate a unique namespace identifier.
|
|
511
|
-
*/
|
|
512
405
|
generateNamespace() {
|
|
513
406
|
return `${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;
|
|
514
407
|
}
|
|
515
|
-
/**
|
|
516
|
-
* Get the tagged key.
|
|
517
|
-
*/
|
|
518
408
|
async taggedKey(key) {
|
|
519
409
|
return `tagged:${await this.getTagNamespace()}:${key}`;
|
|
520
410
|
}
|
|
521
|
-
/**
|
|
522
|
-
* Track a key in the tag sets.
|
|
523
|
-
*/
|
|
524
411
|
async trackKey(key) {
|
|
525
412
|
const taggedKey = await this.taggedKey(key);
|
|
526
413
|
for (const tag of this.tags) {
|
|
@@ -593,11 +480,7 @@ var TaggedCache = class {
|
|
|
593
480
|
const taggedKey = await this.taggedKey(key);
|
|
594
481
|
return this.store.ttl(taggedKey);
|
|
595
482
|
}
|
|
596
|
-
/**
|
|
597
|
-
* Flush all items with the current tags.
|
|
598
|
-
* This works by resetting the tag namespaces, effectively
|
|
599
|
-
* making all previously tagged items inaccessible.
|
|
600
|
-
*/
|
|
483
|
+
/** Flush every item carrying the current tags, and the tag namespaces themselves. */
|
|
601
484
|
async flush() {
|
|
602
485
|
for (const tag of this.tags) {
|
|
603
486
|
const tagKey = `${this.tagSetPrefix}${tag}`;
|
|
@@ -608,24 +491,16 @@ var TaggedCache = class {
|
|
|
608
491
|
await this.store.delete(setKey);
|
|
609
492
|
}
|
|
610
493
|
}
|
|
611
|
-
/**
|
|
612
|
-
* Get the current tags.
|
|
613
|
-
*/
|
|
614
494
|
getTags() {
|
|
615
495
|
return [...this.tags];
|
|
616
496
|
}
|
|
617
|
-
/**
|
|
618
|
-
* Get the underlying store.
|
|
619
|
-
*/
|
|
620
497
|
getStore() {
|
|
621
498
|
return this.store;
|
|
622
499
|
}
|
|
623
500
|
};
|
|
624
501
|
//#endregion
|
|
625
502
|
//#region src/cache/CacheManager.ts
|
|
626
|
-
/**
|
|
627
|
-
* Taggable wrapper that adds tag support to any cache store.
|
|
628
|
-
*/
|
|
503
|
+
/** Adds tag support to any cache store. */
|
|
629
504
|
var TaggableCacheStoreWrapper = class {
|
|
630
505
|
store;
|
|
631
506
|
constructor(store) {
|
|
@@ -674,42 +549,16 @@ var TaggableCacheStoreWrapper = class {
|
|
|
674
549
|
return new TaggedCache(this.store, tags);
|
|
675
550
|
}
|
|
676
551
|
};
|
|
677
|
-
/**
|
|
678
|
-
* Cache manager for handling multiple cache stores.
|
|
679
|
-
*
|
|
680
|
-
* @example
|
|
681
|
-
* ```ts
|
|
682
|
-
* const cache = new CacheManager({
|
|
683
|
-
* default: 'redis',
|
|
684
|
-
* stores: {
|
|
685
|
-
* memory: { driver: 'memory' },
|
|
686
|
-
* redis: { driver: 'redis', client: redisClient },
|
|
687
|
-
* file: { driver: 'file', path: './storage/cache' },
|
|
688
|
-
* }
|
|
689
|
-
* })
|
|
690
|
-
*
|
|
691
|
-
* // Use the default store
|
|
692
|
-
* await cache.store().set('key', 'value', 3600)
|
|
693
|
-
*
|
|
694
|
-
* // Use a specific store
|
|
695
|
-
* await cache.store('memory').set('key', 'value')
|
|
696
|
-
*
|
|
697
|
-
* // Use tagged cache
|
|
698
|
-
* await cache.store().tags(['posts', 'user:1']).set('user:1:posts', posts)
|
|
699
|
-
* await cache.store().tags(['user:1']).flush()
|
|
700
|
-
* ```
|
|
701
|
-
*/
|
|
552
|
+
/** Cache manager for handling multiple cache stores. */
|
|
702
553
|
var CacheManager = class {
|
|
703
554
|
defaultStoreName;
|
|
704
555
|
storeFactories = /* @__PURE__ */ new Map();
|
|
705
556
|
resolvedStores = /* @__PURE__ */ new Map();
|
|
706
557
|
/**
|
|
707
558
|
* Where this manager was built, for identifying its stores across hot reloads.
|
|
708
|
-
*
|
|
709
559
|
* Captured here rather than in `store()` because stores resolve lazily, from
|
|
710
|
-
* whichever request first asks for one
|
|
711
|
-
*
|
|
712
|
-
* formatted stack string held for the manager's lifetime and never read.
|
|
560
|
+
* whichever request first asks for one. Skipped outside `--hot`, where the
|
|
561
|
+
* stack string would be held for the manager's lifetime and never read.
|
|
713
562
|
*/
|
|
714
563
|
builtAt;
|
|
715
564
|
constructor(config = {}) {
|
|
@@ -720,9 +569,6 @@ var CacheManager = class {
|
|
|
720
569
|
if (!this.storeFactories.has(this.defaultStoreName) && this.defaultStoreName === "memory") this.storeFactories.set("memory", () => new MemoryStore());
|
|
721
570
|
}
|
|
722
571
|
driverFactories = /* @__PURE__ */ new Map();
|
|
723
|
-
/**
|
|
724
|
-
* Register built-in store drivers.
|
|
725
|
-
*/
|
|
726
572
|
registerBuiltinDrivers() {
|
|
727
573
|
this.driverFactories.set("memory", (options) => {
|
|
728
574
|
return new MemoryStore(options);
|
|
@@ -734,19 +580,13 @@ var CacheManager = class {
|
|
|
734
580
|
return new FileStore(options);
|
|
735
581
|
});
|
|
736
582
|
}
|
|
737
|
-
/**
|
|
738
|
-
* Register a store from configuration.
|
|
739
|
-
*/
|
|
740
583
|
registerStoreFromConfig(name, config) {
|
|
741
584
|
const { driver, ...options } = config;
|
|
742
585
|
const factory = this.driverFactories.get(driver);
|
|
743
586
|
if (!factory) throw new Error(`Unknown cache driver: ${driver}`);
|
|
744
587
|
this.storeFactories.set(name, () => factory(options));
|
|
745
588
|
}
|
|
746
|
-
/**
|
|
747
|
-
* Get a cache store by name.
|
|
748
|
-
* Returns the default store if no name is specified.
|
|
749
|
-
*/
|
|
589
|
+
/** Returns the default store if no name is given. */
|
|
750
590
|
store(name) {
|
|
751
591
|
const storeName = name ?? this.defaultStoreName;
|
|
752
592
|
const cached = this.resolvedStores.get(storeName);
|
|
@@ -760,51 +600,32 @@ var CacheManager = class {
|
|
|
760
600
|
return store;
|
|
761
601
|
}
|
|
762
602
|
/**
|
|
763
|
-
* Under `bun --hot`, stops the sweep timer held by the store this one
|
|
764
|
-
*
|
|
765
|
-
*
|
|
766
|
-
*
|
|
767
|
-
* stores in one config from sharing a slot and cancelling each other's sweep.
|
|
603
|
+
* Under `bun --hot`, stops the sweep timer held by the store this one
|
|
604
|
+
* replaces. Registered from here because the store's name is known here, and
|
|
605
|
+
* that name keeps two memory stores in one config from cancelling each
|
|
606
|
+
* other's sweep.
|
|
768
607
|
*/
|
|
769
608
|
stopPreviousStore(storeName, store) {
|
|
770
609
|
const disposable = store;
|
|
771
610
|
if (typeof disposable.destroy === "function") claimHotDisposable("cache-store", this.builtAt, storeName, () => disposable.destroy?.());
|
|
772
611
|
}
|
|
773
|
-
/**
|
|
774
|
-
* Register a custom store factory.
|
|
775
|
-
*/
|
|
776
612
|
registerStore(name, factory) {
|
|
777
613
|
this.storeFactories.set(name, factory);
|
|
778
614
|
this.resolvedStores.delete(name);
|
|
779
615
|
}
|
|
780
|
-
/**
|
|
781
|
-
* Register a custom driver.
|
|
782
|
-
*/
|
|
783
616
|
registerDriver(name, factory) {
|
|
784
617
|
this.driverFactories.set(name, factory);
|
|
785
618
|
}
|
|
786
|
-
/**
|
|
787
|
-
* Check if a store is registered.
|
|
788
|
-
*/
|
|
789
619
|
hasStore(name) {
|
|
790
620
|
return this.storeFactories.has(name);
|
|
791
621
|
}
|
|
792
|
-
/**
|
|
793
|
-
* Get the default store name.
|
|
794
|
-
*/
|
|
795
622
|
getDefaultStoreName() {
|
|
796
623
|
return this.defaultStoreName;
|
|
797
624
|
}
|
|
798
|
-
/**
|
|
799
|
-
* Get all registered store names.
|
|
800
|
-
*/
|
|
801
625
|
getStoreNames() {
|
|
802
626
|
return Array.from(this.storeFactories.keys());
|
|
803
627
|
}
|
|
804
628
|
};
|
|
805
|
-
/**
|
|
806
|
-
* Create a cache manager with configuration.
|
|
807
|
-
*/
|
|
808
629
|
function createCacheManager(config) {
|
|
809
630
|
return new CacheManager(config);
|
|
810
631
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Redis from "ioredis";
|
|
2
|
+
//#region src/redis/client.ts
|
|
3
|
+
function createRedisClient(options = {}) {
|
|
4
|
+
const { url, ...redisOptions } = options;
|
|
5
|
+
if (url) return new Redis(url, redisOptions);
|
|
6
|
+
return new Redis(redisOptions);
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { createRedisClient as n, Redis as t };
|
|
@@ -2,178 +2,69 @@ import type { Container } from '../container/index.js';
|
|
|
2
2
|
import type { OutputInterface, CommandInstance } from './types.js';
|
|
3
3
|
import { Input } from './Input.js';
|
|
4
4
|
import * as readline from 'readline';
|
|
5
|
-
/**
|
|
6
|
-
* Base command class for console commands.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* export class CreateUserCommand extends Command {
|
|
11
|
-
* static signature = 'users:create {email} {--admin} {--role=user}'
|
|
12
|
-
* static description = 'Create a new user'
|
|
13
|
-
*
|
|
14
|
-
* async handle(): Promise<void> {
|
|
15
|
-
* const email = this.argument('email')
|
|
16
|
-
* const isAdmin = this.hasOption('admin')
|
|
17
|
-
* const role = this.option('role', 'user')
|
|
18
|
-
*
|
|
19
|
-
* const password = await this.secret('Enter password:')
|
|
20
|
-
* const confirm = await this.confirm(`Create user ${email}?`)
|
|
21
|
-
*
|
|
22
|
-
* if (!confirm) {
|
|
23
|
-
* this.warn('Cancelled')
|
|
24
|
-
* return
|
|
25
|
-
* }
|
|
26
|
-
*
|
|
27
|
-
* this.info(`Creating user: ${email}`)
|
|
28
|
-
* this.success('User created!')
|
|
29
|
-
* }
|
|
30
|
-
* }
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
5
|
+
/** Base class for console commands. */
|
|
33
6
|
export declare abstract class Command implements CommandInstance {
|
|
34
7
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* Tokens may carry a description: 'command:name {arg : What it is}'
|
|
38
|
-
* See `parseSignature` for the full grammar.
|
|
8
|
+
* Format: `command:name {arg} {--option}`, tokens optionally carrying a
|
|
9
|
+
* description (`{arg : What it is}`). See `parseSignature` for the grammar.
|
|
39
10
|
*/
|
|
40
11
|
static signature: string;
|
|
41
|
-
/**
|
|
42
|
-
* The command description.
|
|
43
|
-
*/
|
|
44
12
|
static description: string;
|
|
45
|
-
/**
|
|
46
|
-
* The command input.
|
|
47
|
-
*/
|
|
48
13
|
protected input: Input;
|
|
49
|
-
/**
|
|
50
|
-
* The command output.
|
|
51
|
-
*/
|
|
52
14
|
protected output: OutputInterface;
|
|
53
|
-
/**
|
|
54
|
-
* The service container.
|
|
55
|
-
*/
|
|
56
15
|
protected container?: Container;
|
|
57
16
|
constructor(container?: Container);
|
|
58
|
-
/**
|
|
59
|
-
* Set the input for this command.
|
|
60
|
-
*/
|
|
61
17
|
setInput(argv: string[]): void;
|
|
62
|
-
/**
|
|
63
|
-
* Set the output for this command.
|
|
64
|
-
*/
|
|
65
18
|
setOutput(output: OutputInterface): void;
|
|
66
|
-
/**
|
|
67
|
-
* Execute the command.
|
|
68
|
-
*/
|
|
69
19
|
run(): Promise<number>;
|
|
70
|
-
/**
|
|
71
|
-
* Handle the command.
|
|
72
|
-
* Must be implemented by subclasses.
|
|
73
|
-
*/
|
|
74
20
|
abstract handle(): Promise<number | void>;
|
|
75
|
-
/**
|
|
76
|
-
* Get an argument value.
|
|
77
|
-
*/
|
|
78
21
|
argument<T = string>(name: string): T;
|
|
79
|
-
/**
|
|
80
|
-
* Get all arguments.
|
|
81
|
-
*/
|
|
82
22
|
arguments(): Record<string, string | string[]>;
|
|
83
|
-
/**
|
|
84
|
-
* Get an option value with optional default.
|
|
85
|
-
*/
|
|
86
23
|
option<T = string>(name: string, defaultValue?: T): T;
|
|
87
|
-
/**
|
|
88
|
-
* Get all options.
|
|
89
|
-
*/
|
|
90
24
|
options(): Record<string, string | boolean | string[]>;
|
|
91
|
-
/**
|
|
92
|
-
* Check if an option was provided.
|
|
93
|
-
*/
|
|
94
25
|
hasOption(name: string): boolean;
|
|
95
|
-
/**
|
|
96
|
-
* Output an info message.
|
|
97
|
-
*/
|
|
98
26
|
info(message: string): void;
|
|
99
|
-
/**
|
|
100
|
-
* Output an error message.
|
|
101
|
-
*/
|
|
102
27
|
error(message: string): void;
|
|
103
|
-
/**
|
|
104
|
-
* Output a warning message.
|
|
105
|
-
*/
|
|
106
28
|
warn(message: string): void;
|
|
107
|
-
/**
|
|
108
|
-
* Output a success message.
|
|
109
|
-
*/
|
|
110
29
|
success(message: string): void;
|
|
111
|
-
/**
|
|
112
|
-
* Output a plain line.
|
|
113
|
-
*/
|
|
114
30
|
line(message: string): void;
|
|
115
|
-
/**
|
|
116
|
-
* Output new lines.
|
|
117
|
-
*/
|
|
118
31
|
newLine(count?: number): void;
|
|
119
|
-
/**
|
|
120
|
-
* Output a table.
|
|
121
|
-
*/
|
|
122
32
|
table(headers: string[], rows: string[][]): void;
|
|
123
|
-
/**
|
|
124
|
-
* Ask a question and get user input.
|
|
125
|
-
*/
|
|
126
33
|
ask(question: string, defaultValue?: string): Promise<string>;
|
|
127
|
-
/**
|
|
128
|
-
* Ask for confirmation.
|
|
129
|
-
*/
|
|
130
34
|
confirm(question: string, defaultValue?: boolean): Promise<boolean>;
|
|
131
|
-
/**
|
|
132
|
-
* Present choices to the user.
|
|
133
|
-
*/
|
|
134
35
|
choice<T extends string>(question: string, choices: T[], defaultValue?: T): Promise<T>;
|
|
135
36
|
/**
|
|
136
37
|
* Ask for secret input (password).
|
|
38
|
+
*
|
|
39
|
+
* Rejects when input ends with nothing typed: unlike the other prompts there
|
|
40
|
+
* is no safe default for a password.
|
|
137
41
|
*/
|
|
138
42
|
secret(question: string): Promise<string>;
|
|
139
43
|
/**
|
|
140
|
-
*
|
|
44
|
+
* Run one readline prompt to completion. Settles exactly once, and tears the
|
|
45
|
+
* interface, the mask listener and raw mode down on every exit path, so a
|
|
46
|
+
* later prompt starts clean. Returns null when input ended with nothing
|
|
47
|
+
* typed; callers decide what that means, as leaving it unanswered would hang.
|
|
141
48
|
*/
|
|
142
|
-
|
|
49
|
+
private prompt;
|
|
50
|
+
/** The stream prompts read from. Overridable so a test can hand the command a fake terminal. */
|
|
51
|
+
protected inputStream(): NodeJS.ReadStream;
|
|
143
52
|
/**
|
|
144
|
-
*
|
|
53
|
+
* The stream prompts are echoed to. Derived from the output `setOutput()`
|
|
54
|
+
* installed, so redirecting a command's output redirects its prompts too.
|
|
145
55
|
*/
|
|
56
|
+
protected outputStream(): NodeJS.WriteStream;
|
|
57
|
+
protected createReadline(): readline.Interface;
|
|
146
58
|
withProgress<T>(items: T[], callback: (item: T, index: number) => Promise<void>): Promise<void>;
|
|
147
|
-
/**
|
|
148
|
-
* Kernel reference for calling other commands.
|
|
149
|
-
*/
|
|
150
59
|
protected kernel?: {
|
|
151
60
|
handle(argv: string[]): Promise<number>;
|
|
152
61
|
};
|
|
153
|
-
/**
|
|
154
|
-
* Set the kernel reference.
|
|
155
|
-
*/
|
|
156
62
|
setKernel(kernel: {
|
|
157
63
|
handle(argv: string[]): Promise<number>;
|
|
158
64
|
}): void;
|
|
159
|
-
/**
|
|
160
|
-
* Call another command.
|
|
161
|
-
*/
|
|
162
65
|
call(command: string, args?: string[]): Promise<number>;
|
|
163
|
-
/**
|
|
164
|
-
* Resolve a service from the container.
|
|
165
|
-
*/
|
|
166
66
|
protected resolve<T>(key: string): T;
|
|
167
|
-
/**
|
|
168
|
-
* Get the command signature.
|
|
169
|
-
*/
|
|
170
67
|
getSignature(): string;
|
|
171
|
-
/**
|
|
172
|
-
* Get the command description.
|
|
173
|
-
*/
|
|
174
68
|
getDescription(): string;
|
|
175
|
-
/**
|
|
176
|
-
* Get the command name.
|
|
177
|
-
*/
|
|
178
69
|
getName(): string;
|
|
179
70
|
}
|