@guren/server 2.15.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-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-nNcbCIQX.js} +11 -20
- package/dist/{Random-DbIJ22KQ.js → Random-S0OvCuR8.js} +9 -106
- package/dist/agent/AgentApprovalRequested.d.ts +11 -39
- 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 +11 -19
- package/dist/agent/meta-tools.d.ts +18 -46
- 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 +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 +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-CbdPH4Cd.js} +169 -502
- 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 +62 -208
- 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 +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 +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 +2 -1
- package/dist/index.js +714 -3011
- package/dist/internal/agent-preflight.d.ts +9 -21
- 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 +25 -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-CTQp-SOo.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
package/dist/runtime/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as trimTrailingSlashes } from "../trim-slashes-
|
|
2
|
-
import { n as hash } from "../Hash-
|
|
3
|
-
import { _ as parseImportMap, a as getManifestCss, c as isViteProduction, d as startViteDevServer, f as GUREN_ASCII_ART, h as logDevServerBanner, i as clientManifestCandidates, l as loadViteManifest, o as getManifestFile, r as PUBLIC_ASSETS_URL_PREFIX, u as normalizeDevServerUrl } from "../vite-manifest-
|
|
1
|
+
import { n as trimTrailingSlashes } from "../trim-slashes-BLY9hKAa.js";
|
|
2
|
+
import { n as hash } from "../Hash-D2DFd8xX.js";
|
|
3
|
+
import { _ as parseImportMap, a as getManifestCss, c as isViteProduction, d as startViteDevServer, f as GUREN_ASCII_ART, h as logDevServerBanner, i as clientManifestCandidates, l as loadViteManifest, o as getManifestFile, r as PUBLIC_ASSETS_URL_PREFIX, u as normalizeDevServerUrl } from "../vite-manifest-CTQp-SOo.js";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { realpath } from "node:fs/promises";
|
|
6
6
|
import { dirname, extname, join, resolve, sep } from "node:path";
|
|
@@ -9,31 +9,21 @@ import { serveStatic } from "hono/bun";
|
|
|
9
9
|
import { getMimeType } from "hono/utils/mime";
|
|
10
10
|
//#region src/support/contained-path.ts
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* doubled slash in the request path left the relative part rooted.
|
|
18
|
-
*
|
|
19
|
-
* Cheap, but not sufficient on its own: `resolve()` collapses `..` without
|
|
20
|
-
* following symlinks. Use {@link isRealPathWithin} before reading the file.
|
|
12
|
+
* Lexical containment. The trailing separator keeps out a sibling whose name
|
|
13
|
+
* merely extends the root's (`…/inertia` vs `…/inertia-secrets`) and rejects an
|
|
14
|
+
* absolute `candidate`, which `resolve()` returns verbatim. Not sufficient
|
|
15
|
+
* alone: `resolve()` collapses `..` without following symlinks, so use
|
|
16
|
+
* {@link isRealPathWithin} before reading the file.
|
|
21
17
|
*/
|
|
22
18
|
function isPathWithin(root, candidate) {
|
|
23
19
|
return candidate.startsWith(root.endsWith(sep) ? root : root + sep);
|
|
24
20
|
}
|
|
25
21
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* *Both* sides are canonicalized: a root reached through a symlink itself is
|
|
32
|
-
* routine (workspace and pnpm layouts, macOS `/var` → `/private/var`), and
|
|
33
|
-
* canonicalizing only the candidate would 404 every asset such an app serves.
|
|
34
|
-
*
|
|
35
|
-
* Call this on a path already known to exist — a path that does not exist
|
|
36
|
-
* cannot be read, and `realpath` rejects it, so either way this fails closed.
|
|
22
|
+
* Containment once both sides are canonicalized. Every reader downstream
|
|
23
|
+
* (`Bun.file().text()`, `new Response(file)`) follows symlinks, so a lexical
|
|
24
|
+
* check alone accepts `<root>/link/secret`. *Both* sides, because a root
|
|
25
|
+
* reached through a symlink is routine (macOS `/var` → `/private/var`) and
|
|
26
|
+
* doing only the candidate would 404 every asset such an app serves.
|
|
37
27
|
*/
|
|
38
28
|
async function isRealPathWithin(root, candidate) {
|
|
39
29
|
if (!isPathWithin(root, candidate)) return false;
|
|
@@ -52,16 +42,10 @@ async function canonicalize(path) {
|
|
|
52
42
|
//#region src/http/static-documents.ts
|
|
53
43
|
/**
|
|
54
44
|
* The one rule for "a browser would render this as a document in the serving
|
|
55
|
-
* origin"
|
|
56
|
-
*
|
|
57
|
-
* the
|
|
58
|
-
*
|
|
59
|
-
* A denylist rather than the attachments engine's `INLINE_CONTENT_TYPES`
|
|
60
|
-
* allowlist, because these mounts also serve the app's own build output. An
|
|
61
|
-
* allowlist here would have to enumerate every asset type a project can ship,
|
|
62
|
-
* and would break a deployment the first time it shipped one that was missed.
|
|
63
|
-
* Everything absent from this set — scripts, stylesheets, fonts, images,
|
|
64
|
-
* media, PDFs — is inert when navigated to, and stays inline.
|
|
45
|
+
* origin" — otherwise an upload kept under `public/` becomes script running as
|
|
46
|
+
* the app: same cookies, same session, same CSRF token. A denylist rather than
|
|
47
|
+
* the attachments engine's `INLINE_CONTENT_TYPES` allowlist, because these mounts
|
|
48
|
+
* also serve the app's build output and an allowlist breaks the first deployment shipping a type it missed.
|
|
65
49
|
*/
|
|
66
50
|
const DOCUMENT_CONTENT_TYPES = /* @__PURE__ */ new Set([
|
|
67
51
|
"text/html",
|
|
@@ -70,11 +54,9 @@ const DOCUMENT_CONTENT_TYPES = /* @__PURE__ */ new Set([
|
|
|
70
54
|
"text/xsl"
|
|
71
55
|
]);
|
|
72
56
|
/**
|
|
73
|
-
* Judged on the media type alone
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* verbatim is precisely how the check stops matching while still looking
|
|
77
|
-
* present.
|
|
57
|
+
* Judged on the media type alone: both inputs are parameterised (`getMimeType`
|
|
58
|
+
* returns `text/html; charset=utf-8`, and so does a `contentTypeMap` entry), so
|
|
59
|
+
* comparing the header verbatim silently stops matching.
|
|
78
60
|
*/
|
|
79
61
|
function rendersAsDocument(contentType) {
|
|
80
62
|
if (!contentType) return false;
|
|
@@ -83,15 +65,10 @@ function rendersAsDocument(contentType) {
|
|
|
83
65
|
}
|
|
84
66
|
/**
|
|
85
67
|
* Neutralizes a served document by turning it into a download.
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* working unchanged, while `/logo.svg` opened directly is downloaded instead
|
|
91
|
-
* of rendered. An `<iframe>` or `<object>` *is* a navigation, so an SVG or
|
|
92
|
-
* HTML page embedded that way stops rendering — which is the same mechanism
|
|
93
|
-
* as the fix, not an exception to it. `nosniff` rides along for the types a
|
|
94
|
-
* browser would otherwise promote on its own.
|
|
68
|
+
* `Content-Disposition: attachment` is honoured for navigations and ignored for
|
|
69
|
+
* subresource loads, so `<img>`, `<link rel="icon">` and CSS `url()` keep
|
|
70
|
+
* working while a direct visit downloads. An `<iframe>`/`<object>` *is* a
|
|
71
|
+
* navigation, so embedding an SVG or HTML page that way stops rendering.
|
|
95
72
|
*/
|
|
96
73
|
function applyDocumentDisposition(headers, contentType) {
|
|
97
74
|
if (!rendersAsDocument(contentType)) return;
|
|
@@ -99,12 +76,9 @@ function applyDocumentDisposition(headers, contentType) {
|
|
|
99
76
|
headers.set("X-Content-Type-Options", "nosniff");
|
|
100
77
|
}
|
|
101
78
|
/**
|
|
102
|
-
* The {@link
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* Keyed on the same `getMimeType(path)` the middleware itself used a line
|
|
106
|
-
* earlier to set `Content-Type`, rather than on the extension: the two agree
|
|
107
|
-
* by construction only while they read the same function.
|
|
79
|
+
* The `serveStatic` `onFound` form of {@link applyDocumentDisposition}. Keyed on
|
|
80
|
+
* the same `getMimeType(path)` that middleware uses for `Content-Type`, not on
|
|
81
|
+
* the extension: the two agree only while they read the same function.
|
|
108
82
|
*/
|
|
109
83
|
function guardStaticDocument(path, ctx) {
|
|
110
84
|
if (!rendersAsDocument(getMimeType(path))) return;
|
|
@@ -114,7 +88,13 @@ function guardStaticDocument(path, ctx) {
|
|
|
114
88
|
//#endregion
|
|
115
89
|
//#region src/http/public-assets.ts
|
|
116
90
|
const DEFAULT_CACHE_CONTROL = "public, max-age=31536000, immutable";
|
|
117
|
-
|
|
91
|
+
/**
|
|
92
|
+
* The root-asset extensions served when `rootPublicAssets.extensions` is
|
|
93
|
+
* omitted. Exported because the option *replaces* this list rather than
|
|
94
|
+
* extending it — an app that wants one more extension spreads this rather
|
|
95
|
+
* than restating it, so additions here reach it.
|
|
96
|
+
*/
|
|
97
|
+
const DEFAULT_ROOT_PUBLIC_ASSET_EXTENSIONS = [
|
|
118
98
|
".svg",
|
|
119
99
|
".png",
|
|
120
100
|
".jpg",
|
|
@@ -175,13 +155,13 @@ function registerRootPublicAssets(app, publicDir, config) {
|
|
|
175
155
|
function normalizeConfig(config) {
|
|
176
156
|
if (config === false) return;
|
|
177
157
|
if (config === void 0 || config === true) return {
|
|
178
|
-
extensions: new Set(
|
|
158
|
+
extensions: new Set(DEFAULT_ROOT_PUBLIC_ASSET_EXTENSIONS),
|
|
179
159
|
cacheControlHeader: DEFAULT_CACHE_CONTROL,
|
|
180
160
|
inlineDocuments: false
|
|
181
161
|
};
|
|
182
162
|
if (!(config.enabled ?? true)) return;
|
|
183
163
|
return {
|
|
184
|
-
extensions: new Set((config.extensions && config.extensions.length > 0 ? config.extensions :
|
|
164
|
+
extensions: new Set((config.extensions && config.extensions.length > 0 ? config.extensions : DEFAULT_ROOT_PUBLIC_ASSET_EXTENSIONS).map((ext) => normalizeExtension(ext))),
|
|
185
165
|
cacheControlHeader: config.cacheControlHeader ?? DEFAULT_CACHE_CONTROL,
|
|
186
166
|
routePrefix: config.routePrefix,
|
|
187
167
|
contentTypeMap: config.contentTypeMap,
|
|
@@ -199,9 +179,8 @@ const DEFAULT_VENDOR_PATH = "/vendor/inertia-client.tsx";
|
|
|
199
179
|
const DEFAULT_JSX_RUNTIME = "https://esm.sh/react@19.0.0/jsx-dev-runtime?dev";
|
|
200
180
|
const REACT_IMPORT_PATTERN = /from\s+['"]react['"]/u;
|
|
201
181
|
/**
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
* pattern for it, and the file's path relative to that base.
|
|
182
|
+
* The vendored Inertia client's mount point: containing directory (always
|
|
183
|
+
* slash-terminated), Hono route pattern, and the file's path relative to it.
|
|
205
184
|
*/
|
|
206
185
|
function resolveInertiaClientRoute(inertiaClientPath) {
|
|
207
186
|
const base = inertiaClientPath.slice(0, inertiaClientPath.lastIndexOf("/") + 1) || "/";
|
|
@@ -216,23 +195,14 @@ function resolveGurenInertiaClient() {
|
|
|
216
195
|
return require.resolve("@guren/inertia-client/app");
|
|
217
196
|
}
|
|
218
197
|
/**
|
|
219
|
-
*
|
|
220
|
-
* production serves
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
* `paths` mapping to the package's TypeScript sources — production serves
|
|
224
|
-
* files, it cannot transpile them. So it anchors on `./package.json`, a
|
|
225
|
-
* subpath such a mapping misses (there is no `src/package.json`) and real
|
|
226
|
-
* package resolution answers with the package root.
|
|
198
|
+
* `@guren/inertia-client`'s build output. Anchored on `./package.json` rather
|
|
199
|
+
* than a code subpath, because production serves files and cannot transpile: a
|
|
200
|
+
* tsconfig `paths` mapping misses that subpath (there is no `src/package.json`)
|
|
201
|
+
* and real package resolution answers with the package root.
|
|
227
202
|
*/
|
|
228
203
|
function resolveInertiaClientDir() {
|
|
229
204
|
return join(dirname(require.resolve("@guren/inertia-client/package.json")), "dist");
|
|
230
205
|
}
|
|
231
|
-
/**
|
|
232
|
-
* Registers development asset serving middleware.
|
|
233
|
-
* @param app
|
|
234
|
-
* @param options
|
|
235
|
-
*/
|
|
236
206
|
function registerDevAssets(app, options) {
|
|
237
207
|
if (typeof Bun === "undefined") throw new Error("Bun runtime is required for dev asset serving.");
|
|
238
208
|
const moduleDir = options.importMeta ? dirname(fileURLToPath(options.importMeta.url)) : void 0;
|
|
@@ -309,14 +279,6 @@ function createStaticRewrite(route) {
|
|
|
309
279
|
return remainder.startsWith("/") ? remainder : `/${remainder}`;
|
|
310
280
|
};
|
|
311
281
|
}
|
|
312
|
-
/**
|
|
313
|
-
* Handles a request to transpile a JavaScript or TypeScript file.
|
|
314
|
-
* @param ctx The request context.
|
|
315
|
-
* @param resourcesJsDir The directory containing the resource files.
|
|
316
|
-
* @param prefix The URL prefix for the request.
|
|
317
|
-
* @param transpile The transpilers and JSX runtime to use.
|
|
318
|
-
* @returns A Promise that resolves to a Response object.
|
|
319
|
-
*/
|
|
320
282
|
async function handleTranspileRequest(ctx, resourcesJsDir, prefix, transpile) {
|
|
321
283
|
const relative = ctx.req.path.slice(prefix.length + 1);
|
|
322
284
|
const fsPath = resolve(resourcesJsDir, relative);
|
|
@@ -324,11 +286,10 @@ async function handleTranspileRequest(ctx, resourcesJsDir, prefix, transpile) {
|
|
|
324
286
|
return transpileFile(fsPath, transpile, resourcesJsDir);
|
|
325
287
|
}
|
|
326
288
|
/**
|
|
327
|
-
* Transpiles
|
|
328
|
-
*
|
|
329
|
-
* @param
|
|
330
|
-
*
|
|
331
|
-
* @returns A Promise that resolves to a Response object.
|
|
289
|
+
* Transpiles TS/TSX, otherwise serves the file as-is.
|
|
290
|
+
*
|
|
291
|
+
* @param containmentRoot Directory the resolved file must really live under.
|
|
292
|
+
* Omit for configured (non request-derived) paths.
|
|
332
293
|
*/
|
|
333
294
|
async function transpileFile(fsPath, transpile, containmentRoot) {
|
|
334
295
|
const candidates = buildCandidatePaths(fsPath);
|
|
@@ -448,12 +409,9 @@ function publicRouteBase(route) {
|
|
|
448
409
|
return trimTrailingSlashes(base);
|
|
449
410
|
}
|
|
450
411
|
/**
|
|
451
|
-
* Serves the built Inertia client and
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
* Split out of {@link configureInertiaAssets} so it can be pointed at a
|
|
455
|
-
* directory: the caller derives `inertiaClientDir` from `import.meta.resolve`,
|
|
456
|
-
* which no test can redirect at a fixture.
|
|
412
|
+
* Serves the built Inertia client and its chunks. Takes a directory rather than
|
|
413
|
+
* deriving one, because the caller's `import.meta.resolve` cannot be redirected
|
|
414
|
+
* at a fixture by a test.
|
|
457
415
|
*/
|
|
458
416
|
function registerBuiltInertiaClient(app, inertiaClientDir, inertiaClientPath) {
|
|
459
417
|
const { base: inertiaClientBase, pattern: inertiaClientPattern, requestPath: inertiaClientRequestPath } = resolveInertiaClientRoute(inertiaClientPath);
|
|
@@ -572,4 +530,4 @@ function resolveResourcesDir(options, moduleDir) {
|
|
|
572
530
|
return resolve(moduleDir, resourcesPath);
|
|
573
531
|
}
|
|
574
532
|
//#endregion
|
|
575
|
-
export { GUREN_ASCII_ART, autoConfigureInertiaAssets, configureInertiaAssets, logDevServerBanner, registerDevAssets, startViteDevServer };
|
|
533
|
+
export { DEFAULT_ROOT_PUBLIC_ASSET_EXTENSIONS, GUREN_ASCII_ART, autoConfigureInertiaAssets, configureInertiaAssets, logDevServerBanner, registerDevAssets, startViteDevServer };
|
|
@@ -1,37 +1,8 @@
|
|
|
1
1
|
import type { ParsedCron } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Parse a cron expression.
|
|
4
|
-
*
|
|
5
|
-
* Cron format: minute hour dayOfMonth month dayOfWeek
|
|
6
|
-
*
|
|
7
|
-
* Examples:
|
|
8
|
-
* - Every minute: "* * * * *"
|
|
9
|
-
* - Every 5 minutes: "*/5 * * * *" (step value)
|
|
10
|
-
* - At 3:00 AM daily: "0 3 * * *"
|
|
11
|
-
* - Every Monday at 9:00 AM: "0 9 * * 1"
|
|
12
|
-
*/
|
|
13
2
|
export declare function parseCron(expression: string): ParsedCron;
|
|
14
|
-
/**
|
|
15
|
-
* Check if a date matches a parsed cron expression.
|
|
16
|
-
*/
|
|
17
3
|
export declare function matchesCron(date: Date, cron: ParsedCron): boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Get the next occurrence of a cron expression.
|
|
20
|
-
*/
|
|
21
4
|
export declare function getNextOccurrence(expression: string, from?: Date): Date;
|
|
22
|
-
/**
|
|
23
|
-
* Check if a cron expression is due at the given date.
|
|
24
|
-
*/
|
|
25
5
|
export declare function isDue(expression: string, date?: Date): boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Get multiple next occurrences.
|
|
28
|
-
*/
|
|
29
6
|
export declare function getNextOccurrences(expression: string, count: number, from?: Date): Date[];
|
|
30
|
-
/**
|
|
31
|
-
* Convert a Date to a specific timezone.
|
|
32
|
-
*/
|
|
33
7
|
export declare function toTimezone(date: Date, timezone: string): Date;
|
|
34
|
-
/**
|
|
35
|
-
* Check if a cron expression is due in a specific timezone.
|
|
36
|
-
*/
|
|
37
8
|
export declare function isDueInTimezone(expression: string, timezone: string, date?: Date): boolean;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import type { TaskCallback, TaskDefinition, JobClass } from './types.js';
|
|
2
2
|
import { ScheduledTask } from './ScheduledTask.js';
|
|
3
|
-
/**
|
|
4
|
-
* Pending schedule builder for fluent API.
|
|
5
|
-
*/
|
|
6
3
|
export declare class PendingSchedule {
|
|
7
4
|
private readonly callback;
|
|
8
5
|
private expression;
|
|
@@ -18,88 +15,26 @@ export declare class PendingSchedule {
|
|
|
18
15
|
private successCallback?;
|
|
19
16
|
private failureCallback?;
|
|
20
17
|
constructor(callback: TaskCallback);
|
|
21
|
-
/**
|
|
22
|
-
* Run every minute.
|
|
23
|
-
*/
|
|
24
18
|
everyMinute(): this;
|
|
25
|
-
/**
|
|
26
|
-
* Run every two minutes.
|
|
27
|
-
*/
|
|
28
19
|
everyTwoMinutes(): this;
|
|
29
|
-
/**
|
|
30
|
-
* Run every three minutes.
|
|
31
|
-
*/
|
|
32
20
|
everyThreeMinutes(): this;
|
|
33
|
-
/**
|
|
34
|
-
* Run every four minutes.
|
|
35
|
-
*/
|
|
36
21
|
everyFourMinutes(): this;
|
|
37
|
-
/**
|
|
38
|
-
* Run every five minutes.
|
|
39
|
-
*/
|
|
40
22
|
everyFiveMinutes(): this;
|
|
41
|
-
/**
|
|
42
|
-
* Run every ten minutes.
|
|
43
|
-
*/
|
|
44
23
|
everyTenMinutes(): this;
|
|
45
|
-
/**
|
|
46
|
-
* Run every fifteen minutes.
|
|
47
|
-
*/
|
|
48
24
|
everyFifteenMinutes(): this;
|
|
49
|
-
/**
|
|
50
|
-
* Run every thirty minutes.
|
|
51
|
-
*/
|
|
52
25
|
everyThirtyMinutes(): this;
|
|
53
|
-
/**
|
|
54
|
-
* Run hourly.
|
|
55
|
-
*/
|
|
56
26
|
hourly(): this;
|
|
57
|
-
/**
|
|
58
|
-
* Run hourly at a specific minute.
|
|
59
|
-
*/
|
|
60
27
|
hourlyAt(minute: number): this;
|
|
61
|
-
/**
|
|
62
|
-
* Run every two hours.
|
|
63
|
-
*/
|
|
64
28
|
everyTwoHours(): this;
|
|
65
|
-
/**
|
|
66
|
-
* Run every three hours.
|
|
67
|
-
*/
|
|
68
29
|
everyThreeHours(): this;
|
|
69
|
-
/**
|
|
70
|
-
* Run every four hours.
|
|
71
|
-
*/
|
|
72
30
|
everyFourHours(): this;
|
|
73
|
-
/**
|
|
74
|
-
* Run every six hours.
|
|
75
|
-
*/
|
|
76
31
|
everySixHours(): this;
|
|
77
|
-
/**
|
|
78
|
-
* Run daily at midnight.
|
|
79
|
-
*/
|
|
80
32
|
daily(): this;
|
|
81
|
-
/**
|
|
82
|
-
* Run daily at a specific time.
|
|
83
|
-
* @param time Time in HH:MM format
|
|
84
|
-
*/
|
|
85
33
|
dailyAt(time: string): this;
|
|
86
|
-
/**
|
|
87
|
-
* Alias for dailyAt.
|
|
88
|
-
*/
|
|
89
34
|
at(time: string): this;
|
|
90
|
-
/**
|
|
91
|
-
* Run twice daily.
|
|
92
|
-
*/
|
|
93
35
|
twiceDaily(firstHour?: number, secondHour?: number): this;
|
|
94
|
-
/**
|
|
95
|
-
* Run weekly on Sunday at midnight.
|
|
96
|
-
*/
|
|
97
36
|
weekly(): this;
|
|
98
|
-
/**
|
|
99
|
-
* Run weekly on a specific day at a specific time.
|
|
100
|
-
* @param day Day of week (0 = Sunday, 6 = Saturday)
|
|
101
|
-
* @param time Time in HH:MM format
|
|
102
|
-
*/
|
|
37
|
+
/** `day`: cron day-of-week, 0 = Sunday. */
|
|
103
38
|
weeklyOn(day: number, time?: string): this;
|
|
104
39
|
sundays(): this;
|
|
105
40
|
mondays(): this;
|
|
@@ -108,122 +43,35 @@ export declare class PendingSchedule {
|
|
|
108
43
|
thursdays(): this;
|
|
109
44
|
fridays(): this;
|
|
110
45
|
saturdays(): this;
|
|
111
|
-
/**
|
|
112
|
-
* Run on weekdays (Monday-Friday).
|
|
113
|
-
*/
|
|
114
46
|
weekdays(): this;
|
|
115
|
-
/**
|
|
116
|
-
* Run on weekends (Saturday-Sunday).
|
|
117
|
-
*/
|
|
118
47
|
weekends(): this;
|
|
119
|
-
/**
|
|
120
|
-
* Run monthly on the first day at midnight.
|
|
121
|
-
*/
|
|
122
48
|
monthly(): this;
|
|
123
|
-
/**
|
|
124
|
-
* Run monthly on a specific day at a specific time.
|
|
125
|
-
*/
|
|
126
49
|
monthlyOn(day: number, time?: string): this;
|
|
127
|
-
/**
|
|
128
|
-
* Run on the last day of the month.
|
|
129
|
-
*/
|
|
130
50
|
lastDayOfMonth(time?: string): this;
|
|
131
|
-
/**
|
|
132
|
-
* Run quarterly.
|
|
133
|
-
*/
|
|
134
51
|
quarterly(): this;
|
|
135
|
-
/**
|
|
136
|
-
* Run yearly on January 1st at midnight.
|
|
137
|
-
*/
|
|
138
52
|
yearly(): this;
|
|
139
|
-
/**
|
|
140
|
-
* Run yearly on a specific date.
|
|
141
|
-
*/
|
|
142
53
|
yearlyOn(month: number, day: number, time?: string): this;
|
|
143
|
-
/**
|
|
144
|
-
* Set a custom cron expression.
|
|
145
|
-
*/
|
|
146
54
|
cron(expression: string): this;
|
|
147
|
-
/**
|
|
148
|
-
* Set the task name.
|
|
149
|
-
*/
|
|
150
55
|
name(name: string): this;
|
|
151
|
-
/**
|
|
152
|
-
* Set the timezone.
|
|
153
|
-
*/
|
|
154
56
|
tz(timezone: string): this;
|
|
155
|
-
/**
|
|
156
|
-
* Alias for tz().
|
|
157
|
-
*/
|
|
158
57
|
setTimezone(timezone: string): this;
|
|
159
|
-
/**
|
|
160
|
-
* Prevent overlapping executions.
|
|
161
|
-
*/
|
|
162
58
|
preventOverlapping(expiresAt?: number): this;
|
|
163
|
-
/**
|
|
164
|
-
* Alias for preventOverlapping().
|
|
165
|
-
*/
|
|
166
59
|
withoutOverlaps(expiresAt?: number): this;
|
|
167
|
-
/**
|
|
168
|
-
* Only run on one server.
|
|
169
|
-
*/
|
|
170
60
|
runOnOneServer(): this;
|
|
171
|
-
/**
|
|
172
|
-
* Set a condition for running.
|
|
173
|
-
*/
|
|
174
61
|
when(callback: () => boolean | Promise<boolean>): this;
|
|
175
|
-
/**
|
|
176
|
-
* Set a condition to skip execution.
|
|
177
|
-
*/
|
|
178
62
|
skip(callback: () => boolean | Promise<boolean>): this;
|
|
179
|
-
/**
|
|
180
|
-
* Set a before callback.
|
|
181
|
-
*/
|
|
182
63
|
before(callback: () => void | Promise<void>): this;
|
|
183
|
-
/**
|
|
184
|
-
* Set an after callback.
|
|
185
|
-
*/
|
|
186
64
|
after(callback: () => void | Promise<void>): this;
|
|
187
|
-
/**
|
|
188
|
-
* Set a success callback.
|
|
189
|
-
*/
|
|
190
65
|
onSuccess(callback: () => void | Promise<void>): this;
|
|
191
|
-
/**
|
|
192
|
-
* Set a failure callback.
|
|
193
|
-
*/
|
|
194
66
|
onFailure(callback: (error: Error) => void | Promise<void>): this;
|
|
195
|
-
/**
|
|
196
|
-
* Build the task definition.
|
|
197
|
-
*/
|
|
198
67
|
build(): TaskDefinition;
|
|
199
|
-
/**
|
|
200
|
-
* Build as a ScheduledTask.
|
|
201
|
-
*/
|
|
202
68
|
toTask(): ScheduledTask;
|
|
203
69
|
}
|
|
204
|
-
/**
|
|
205
|
-
* Schedule builder for defining multiple tasks.
|
|
206
|
-
*/
|
|
207
70
|
export declare class Schedule {
|
|
208
71
|
private readonly tasks;
|
|
209
|
-
/**
|
|
210
|
-
* Schedule a callback.
|
|
211
|
-
*/
|
|
212
72
|
call(callback: TaskCallback): PendingSchedule;
|
|
213
|
-
/**
|
|
214
|
-
* Schedule a job.
|
|
215
|
-
*/
|
|
216
73
|
job<T>(jobClass: JobClass<T>, payload: T): PendingSchedule;
|
|
217
|
-
/**
|
|
218
|
-
* Schedule a shell command.
|
|
219
|
-
*/
|
|
220
74
|
command(cmd: string): PendingSchedule;
|
|
221
|
-
/**
|
|
222
|
-
* Get all pending schedules.
|
|
223
|
-
*/
|
|
224
75
|
getPendingSchedules(): PendingSchedule[];
|
|
225
|
-
/**
|
|
226
|
-
* Build all tasks.
|
|
227
|
-
*/
|
|
228
76
|
buildTasks(): ScheduledTask[];
|
|
229
77
|
}
|
|
@@ -1,47 +1,16 @@
|
|
|
1
1
|
import type { TaskDefinition } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Represents a scheduled task.
|
|
4
|
-
*/
|
|
5
2
|
export declare class ScheduledTask {
|
|
6
3
|
private readonly definition;
|
|
7
4
|
private lastRun;
|
|
8
5
|
private isRunning;
|
|
9
6
|
constructor(definition: TaskDefinition);
|
|
10
|
-
/**
|
|
11
|
-
* Get the task name.
|
|
12
|
-
*/
|
|
13
7
|
getName(): string;
|
|
14
|
-
/**
|
|
15
|
-
* Get the cron expression.
|
|
16
|
-
*/
|
|
17
8
|
getExpression(): string;
|
|
18
|
-
/**
|
|
19
|
-
* Get the timezone.
|
|
20
|
-
*/
|
|
21
9
|
getTimezone(): string | undefined;
|
|
22
|
-
/**
|
|
23
|
-
* Check if the task is due.
|
|
24
|
-
*/
|
|
25
10
|
isDue(date?: Date): boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Check if the task should run based on conditions.
|
|
28
|
-
* Note: Overlap checking is handled separately in run() to prevent race conditions.
|
|
29
|
-
*/
|
|
30
11
|
shouldRun(): Promise<boolean>;
|
|
31
|
-
/**
|
|
32
|
-
* Run the task.
|
|
33
|
-
*/
|
|
34
12
|
run(): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* Get the last run time.
|
|
37
|
-
*/
|
|
38
13
|
getLastRun(): Date | null;
|
|
39
|
-
/**
|
|
40
|
-
* Check if the task is currently running.
|
|
41
|
-
*/
|
|
42
14
|
isCurrentlyRunning(): boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Get the task definition.
|
|
45
|
-
*/
|
|
46
15
|
getDefinition(): TaskDefinition;
|
|
47
16
|
}
|
|
@@ -1,28 +1,6 @@
|
|
|
1
1
|
import type { SchedulerOptions } from './types.js';
|
|
2
2
|
import { Schedule } from './Schedule.js';
|
|
3
3
|
import { ScheduledTask } from './ScheduledTask.js';
|
|
4
|
-
/**
|
|
5
|
-
* Task scheduler for running periodic tasks.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* const scheduler = new Scheduler()
|
|
10
|
-
*
|
|
11
|
-
* scheduler.schedule((schedule) => {
|
|
12
|
-
* schedule.call(async () => {
|
|
13
|
-
* await cleanupOldSessions()
|
|
14
|
-
* }).daily().at('03:00').name('cleanup-sessions')
|
|
15
|
-
*
|
|
16
|
-
* schedule.job(SendWeeklyDigestJob, {})
|
|
17
|
-
* .weekly()
|
|
18
|
-
* .sundays()
|
|
19
|
-
* .at('09:00')
|
|
20
|
-
* .tz('Asia/Tokyo')
|
|
21
|
-
* })
|
|
22
|
-
*
|
|
23
|
-
* scheduler.start()
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
4
|
export declare class Scheduler {
|
|
27
5
|
private tasks;
|
|
28
6
|
private readonly options;
|
|
@@ -32,68 +10,20 @@ export declare class Scheduler {
|
|
|
32
10
|
/** This scheduler's claim on its hot-reload slot while it is running. */
|
|
33
11
|
private hotReloadClaim;
|
|
34
12
|
constructor(options?: SchedulerOptions);
|
|
35
|
-
/**
|
|
36
|
-
* Define schedules using a callback.
|
|
37
|
-
*/
|
|
38
13
|
schedule(definer: (schedule: Schedule) => void): void;
|
|
39
|
-
/**
|
|
40
|
-
* Add a pre-built task.
|
|
41
|
-
*/
|
|
42
14
|
addTask(task: ScheduledTask): void;
|
|
43
|
-
/**
|
|
44
|
-
* Get all scheduled tasks.
|
|
45
|
-
*/
|
|
46
15
|
getTasks(): ScheduledTask[];
|
|
47
|
-
/**
|
|
48
|
-
* Get tasks that are due now.
|
|
49
|
-
*/
|
|
50
16
|
getDueTasks(date?: Date): ScheduledTask[];
|
|
51
|
-
/**
|
|
52
|
-
* Run all due tasks.
|
|
53
|
-
*/
|
|
54
17
|
runDueTasks(date?: Date): Promise<void>;
|
|
55
|
-
/**
|
|
56
|
-
* Start the scheduler.
|
|
57
|
-
*/
|
|
58
18
|
start(): void;
|
|
59
|
-
/**
|
|
60
|
-
* Stop the scheduler.
|
|
61
|
-
*/
|
|
62
19
|
stop(): void;
|
|
63
|
-
/**
|
|
64
|
-
* Check and run due tasks.
|
|
65
|
-
*/
|
|
66
20
|
private tick;
|
|
67
|
-
/**
|
|
68
|
-
* Check if the scheduler is running.
|
|
69
|
-
*/
|
|
70
21
|
getIsRunning(): boolean;
|
|
71
|
-
/**
|
|
72
|
-
* Get the check interval.
|
|
73
|
-
*/
|
|
74
22
|
getCheckInterval(): number;
|
|
75
|
-
/**
|
|
76
|
-
* Get the default timezone.
|
|
77
|
-
*/
|
|
78
23
|
getTimezone(): string;
|
|
79
|
-
/**
|
|
80
|
-
* Clear all tasks.
|
|
81
|
-
*/
|
|
82
24
|
clear(): void;
|
|
83
|
-
/**
|
|
84
|
-
* Get the number of tasks.
|
|
85
|
-
*/
|
|
86
25
|
count(): number;
|
|
87
|
-
/**
|
|
88
|
-
* Get task by name.
|
|
89
|
-
*/
|
|
90
26
|
getTask(name: string): ScheduledTask | undefined;
|
|
91
|
-
/**
|
|
92
|
-
* Remove a task by name.
|
|
93
|
-
*/
|
|
94
27
|
removeTask(name: string): boolean;
|
|
95
28
|
}
|
|
96
|
-
/**
|
|
97
|
-
* Create a scheduler instance.
|
|
98
|
-
*/
|
|
99
29
|
export declare function createScheduler(options?: SchedulerOptions): Scheduler;
|
package/dist/scheduling/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as ScheduledTask, c as isDue, d as parseCron, f as toTimezone, i as Schedule, l as isDueInTimezone, n as createScheduler, o as getNextOccurrence, r as PendingSchedule, s as getNextOccurrences, t as Scheduler, u as matchesCron } from "../scheduling-
|
|
1
|
+
import { a as ScheduledTask, c as isDue, d as parseCron, f as toTimezone, i as Schedule, l as isDueInTimezone, n as createScheduler, o as getNextOccurrence, r as PendingSchedule, s as getNextOccurrences, t as Scheduler, u as matchesCron } from "../scheduling-C6tcOtUl.js";
|
|
2
2
|
export { PendingSchedule, Schedule, ScheduledTask, Scheduler, createScheduler, getNextOccurrence, getNextOccurrences, isDue, isDueInTimezone, matchesCron, parseCron, toTimezone };
|