@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
package/dist/runtime/index.js
CHANGED
|
@@ -1,38 +1,29 @@
|
|
|
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";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
import { serveStatic } from "hono/bun";
|
|
9
|
+
import { getMimeType } from "hono/utils/mime";
|
|
9
10
|
//#region src/support/contained-path.ts
|
|
10
11
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* doubled slash in the request path left the relative part rooted.
|
|
17
|
-
*
|
|
18
|
-
* Cheap, but not sufficient on its own: `resolve()` collapses `..` without
|
|
19
|
-
* 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.
|
|
20
17
|
*/
|
|
21
18
|
function isPathWithin(root, candidate) {
|
|
22
19
|
return candidate.startsWith(root.endsWith(sep) ? root : root + sep);
|
|
23
20
|
}
|
|
24
21
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* *Both* sides are canonicalized: a root reached through a symlink itself is
|
|
31
|
-
* routine (workspace and pnpm layouts, macOS `/var` → `/private/var`), and
|
|
32
|
-
* canonicalizing only the candidate would 404 every asset such an app serves.
|
|
33
|
-
*
|
|
34
|
-
* Call this on a path already known to exist — a path that does not exist
|
|
35
|
-
* 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.
|
|
36
27
|
*/
|
|
37
28
|
async function isRealPathWithin(root, candidate) {
|
|
38
29
|
if (!isPathWithin(root, candidate)) return false;
|
|
@@ -48,9 +39,62 @@ async function canonicalize(path) {
|
|
|
48
39
|
}
|
|
49
40
|
}
|
|
50
41
|
//#endregion
|
|
42
|
+
//#region src/http/static-documents.ts
|
|
43
|
+
/**
|
|
44
|
+
* The one rule for "a browser would render this as a document in the serving
|
|
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.
|
|
49
|
+
*/
|
|
50
|
+
const DOCUMENT_CONTENT_TYPES = /* @__PURE__ */ new Set([
|
|
51
|
+
"text/html",
|
|
52
|
+
"text/xml",
|
|
53
|
+
"application/xml",
|
|
54
|
+
"text/xsl"
|
|
55
|
+
]);
|
|
56
|
+
/**
|
|
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.
|
|
60
|
+
*/
|
|
61
|
+
function rendersAsDocument(contentType) {
|
|
62
|
+
if (!contentType) return false;
|
|
63
|
+
const mediaType = contentType.split(";", 1)[0].trim().toLowerCase();
|
|
64
|
+
return DOCUMENT_CONTENT_TYPES.has(mediaType) || mediaType.endsWith("+xml");
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Neutralizes a served document by turning it into a download.
|
|
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.
|
|
72
|
+
*/
|
|
73
|
+
function applyDocumentDisposition(headers, contentType) {
|
|
74
|
+
if (!rendersAsDocument(contentType)) return;
|
|
75
|
+
headers.set("Content-Disposition", "attachment");
|
|
76
|
+
headers.set("X-Content-Type-Options", "nosniff");
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
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.
|
|
82
|
+
*/
|
|
83
|
+
function guardStaticDocument(path, ctx) {
|
|
84
|
+
if (!rendersAsDocument(getMimeType(path))) return;
|
|
85
|
+
ctx.header("Content-Disposition", "attachment");
|
|
86
|
+
ctx.header("X-Content-Type-Options", "nosniff");
|
|
87
|
+
}
|
|
88
|
+
//#endregion
|
|
51
89
|
//#region src/http/public-assets.ts
|
|
52
90
|
const DEFAULT_CACHE_CONTROL = "public, max-age=31536000, immutable";
|
|
53
|
-
|
|
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 = [
|
|
54
98
|
".svg",
|
|
55
99
|
".png",
|
|
56
100
|
".jpg",
|
|
@@ -84,7 +128,7 @@ function registerRootPublicAssets(app, publicDir, config) {
|
|
|
84
128
|
console.warn("Root public asset serving is only available when running on Bun; skipping registration.");
|
|
85
129
|
return;
|
|
86
130
|
}
|
|
87
|
-
const { extensions, cacheControlHeader, routePrefix, contentTypeMap } = normalized;
|
|
131
|
+
const { extensions, cacheControlHeader, routePrefix, contentTypeMap, inlineDocuments } = normalized;
|
|
88
132
|
const normalizedPrefix = routePrefix ? trimTrailingSlashes(routePrefix) || "/" : void 0;
|
|
89
133
|
app.hono.use(async (ctx, next) => {
|
|
90
134
|
const path = ctx.req.path;
|
|
@@ -99,25 +143,29 @@ function registerRootPublicAssets(app, publicDir, config) {
|
|
|
99
143
|
const file = Bun.file(candidatePath);
|
|
100
144
|
if (!await file.exists()) return next();
|
|
101
145
|
if (!await isRealPathWithin(publicDir, candidatePath)) return next();
|
|
146
|
+
const contentType = contentTypeMap?.[extension] ?? DEFAULT_CONTENT_TYPES[extension] ?? "application/octet-stream";
|
|
102
147
|
const headers = new Headers({
|
|
103
148
|
"Cache-Control": cacheControlHeader,
|
|
104
|
-
"Content-Type":
|
|
149
|
+
"Content-Type": contentType
|
|
105
150
|
});
|
|
151
|
+
if (!inlineDocuments) applyDocumentDisposition(headers, contentType);
|
|
106
152
|
return new Response(file, { headers });
|
|
107
153
|
});
|
|
108
154
|
}
|
|
109
155
|
function normalizeConfig(config) {
|
|
110
156
|
if (config === false) return;
|
|
111
157
|
if (config === void 0 || config === true) return {
|
|
112
|
-
extensions: new Set(
|
|
113
|
-
cacheControlHeader: DEFAULT_CACHE_CONTROL
|
|
158
|
+
extensions: new Set(DEFAULT_ROOT_PUBLIC_ASSET_EXTENSIONS),
|
|
159
|
+
cacheControlHeader: DEFAULT_CACHE_CONTROL,
|
|
160
|
+
inlineDocuments: false
|
|
114
161
|
};
|
|
115
162
|
if (!(config.enabled ?? true)) return;
|
|
116
163
|
return {
|
|
117
|
-
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))),
|
|
118
165
|
cacheControlHeader: config.cacheControlHeader ?? DEFAULT_CACHE_CONTROL,
|
|
119
166
|
routePrefix: config.routePrefix,
|
|
120
|
-
contentTypeMap: config.contentTypeMap
|
|
167
|
+
contentTypeMap: config.contentTypeMap,
|
|
168
|
+
inlineDocuments: config.inlineDocuments ?? false
|
|
121
169
|
};
|
|
122
170
|
}
|
|
123
171
|
function normalizeExtension(value) {
|
|
@@ -131,9 +179,8 @@ const DEFAULT_VENDOR_PATH = "/vendor/inertia-client.tsx";
|
|
|
131
179
|
const DEFAULT_JSX_RUNTIME = "https://esm.sh/react@19.0.0/jsx-dev-runtime?dev";
|
|
132
180
|
const REACT_IMPORT_PATTERN = /from\s+['"]react['"]/u;
|
|
133
181
|
/**
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
* 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.
|
|
137
184
|
*/
|
|
138
185
|
function resolveInertiaClientRoute(inertiaClientPath) {
|
|
139
186
|
const base = inertiaClientPath.slice(0, inertiaClientPath.lastIndexOf("/") + 1) || "/";
|
|
@@ -148,23 +195,14 @@ function resolveGurenInertiaClient() {
|
|
|
148
195
|
return require.resolve("@guren/inertia-client/app");
|
|
149
196
|
}
|
|
150
197
|
/**
|
|
151
|
-
*
|
|
152
|
-
* production serves
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
* `paths` mapping to the package's TypeScript sources — production serves
|
|
156
|
-
* files, it cannot transpile them. So it anchors on `./package.json`, a
|
|
157
|
-
* subpath such a mapping misses (there is no `src/package.json`) and real
|
|
158
|
-
* 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.
|
|
159
202
|
*/
|
|
160
203
|
function resolveInertiaClientDir() {
|
|
161
204
|
return join(dirname(require.resolve("@guren/inertia-client/package.json")), "dist");
|
|
162
205
|
}
|
|
163
|
-
/**
|
|
164
|
-
* Registers development asset serving middleware.
|
|
165
|
-
* @param app
|
|
166
|
-
* @param options
|
|
167
|
-
*/
|
|
168
206
|
function registerDevAssets(app, options) {
|
|
169
207
|
if (typeof Bun === "undefined") throw new Error("Bun runtime is required for dev asset serving.");
|
|
170
208
|
const moduleDir = options.importMeta ? dirname(fileURLToPath(options.importMeta.url)) : void 0;
|
|
@@ -200,7 +238,8 @@ function registerDevAssets(app, options) {
|
|
|
200
238
|
const cssRewrite = createStaticRewrite(cssRoute);
|
|
201
239
|
app.use(cssRoute, serveStatic({
|
|
202
240
|
root: cssDir,
|
|
203
|
-
rewriteRequestPath: cssRewrite
|
|
241
|
+
rewriteRequestPath: cssRewrite,
|
|
242
|
+
onFound: options.inlineDocuments ? void 0 : guardStaticDocument
|
|
204
243
|
}));
|
|
205
244
|
}
|
|
206
245
|
if (options.inertiaClient !== false) {
|
|
@@ -221,7 +260,8 @@ function registerDevAssets(app, options) {
|
|
|
221
260
|
const rewriteRequestPath = createStaticRewrite(publicRoute);
|
|
222
261
|
app.use(publicRoute, serveStatic({
|
|
223
262
|
root: publicDir,
|
|
224
|
-
rewriteRequestPath
|
|
263
|
+
rewriteRequestPath,
|
|
264
|
+
onFound: options.inlineDocuments ? void 0 : guardStaticDocument
|
|
225
265
|
}));
|
|
226
266
|
if (options.favicon !== false) app.hono.get("/favicon.ico", () => new Response(null, { status: 204 }));
|
|
227
267
|
registerRootPublicAssets(app, publicDir, options.rootPublicAssets);
|
|
@@ -239,14 +279,6 @@ function createStaticRewrite(route) {
|
|
|
239
279
|
return remainder.startsWith("/") ? remainder : `/${remainder}`;
|
|
240
280
|
};
|
|
241
281
|
}
|
|
242
|
-
/**
|
|
243
|
-
* Handles a request to transpile a JavaScript or TypeScript file.
|
|
244
|
-
* @param ctx The request context.
|
|
245
|
-
* @param resourcesJsDir The directory containing the resource files.
|
|
246
|
-
* @param prefix The URL prefix for the request.
|
|
247
|
-
* @param transpile The transpilers and JSX runtime to use.
|
|
248
|
-
* @returns A Promise that resolves to a Response object.
|
|
249
|
-
*/
|
|
250
282
|
async function handleTranspileRequest(ctx, resourcesJsDir, prefix, transpile) {
|
|
251
283
|
const relative = ctx.req.path.slice(prefix.length + 1);
|
|
252
284
|
const fsPath = resolve(resourcesJsDir, relative);
|
|
@@ -254,11 +286,10 @@ async function handleTranspileRequest(ctx, resourcesJsDir, prefix, transpile) {
|
|
|
254
286
|
return transpileFile(fsPath, transpile, resourcesJsDir);
|
|
255
287
|
}
|
|
256
288
|
/**
|
|
257
|
-
* Transpiles
|
|
258
|
-
*
|
|
259
|
-
* @param
|
|
260
|
-
*
|
|
261
|
-
* @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.
|
|
262
293
|
*/
|
|
263
294
|
async function transpileFile(fsPath, transpile, containmentRoot) {
|
|
264
295
|
const candidates = buildCandidatePaths(fsPath);
|
|
@@ -292,10 +323,13 @@ async function transpileFile(fsPath, transpile, containmentRoot) {
|
|
|
292
323
|
} });
|
|
293
324
|
}
|
|
294
325
|
const body = await file.arrayBuffer();
|
|
295
|
-
|
|
296
|
-
|
|
326
|
+
const contentType = file.type || "application/octet-stream";
|
|
327
|
+
const headers = new Headers({
|
|
328
|
+
"Content-Type": contentType,
|
|
297
329
|
"Cache-Control": isDev() ? "no-cache" : "public, max-age=31536000"
|
|
298
|
-
}
|
|
330
|
+
});
|
|
331
|
+
applyDocumentDisposition(headers, contentType);
|
|
332
|
+
return new Response(body, { headers });
|
|
299
333
|
}
|
|
300
334
|
function buildCandidatePaths(fsPath) {
|
|
301
335
|
if (extname(fsPath)) return [fsPath];
|
|
@@ -355,7 +389,8 @@ function configureInertiaAssets(app, options) {
|
|
|
355
389
|
app.use(publicRoute, serveStatic({
|
|
356
390
|
root: publicDir,
|
|
357
391
|
rewriteRequestPath,
|
|
358
|
-
onFound: (
|
|
392
|
+
onFound: (path, ctx) => {
|
|
393
|
+
if (!options.inlineDocuments) guardStaticDocument(path, ctx);
|
|
359
394
|
if (ctx.req.path.startsWith(hashedAssetsPrefix)) ctx.header("Cache-Control", "public, max-age=31536000, immutable");
|
|
360
395
|
}
|
|
361
396
|
}));
|
|
@@ -374,12 +409,9 @@ function publicRouteBase(route) {
|
|
|
374
409
|
return trimTrailingSlashes(base);
|
|
375
410
|
}
|
|
376
411
|
/**
|
|
377
|
-
* Serves the built Inertia client and
|
|
378
|
-
*
|
|
379
|
-
*
|
|
380
|
-
* Split out of {@link configureInertiaAssets} so it can be pointed at a
|
|
381
|
-
* directory: the caller derives `inertiaClientDir` from `import.meta.resolve`,
|
|
382
|
-
* 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.
|
|
383
415
|
*/
|
|
384
416
|
function registerBuiltInertiaClient(app, inertiaClientDir, inertiaClientPath) {
|
|
385
417
|
const { base: inertiaClientBase, pattern: inertiaClientPattern, requestPath: inertiaClientRequestPath } = resolveInertiaClientRoute(inertiaClientPath);
|
|
@@ -397,10 +429,12 @@ function registerBuiltInertiaClient(app, inertiaClientDir, inertiaClientPath) {
|
|
|
397
429
|
if (!await file.exists()) return ctx.notFound();
|
|
398
430
|
if (containmentRoot && !await isRealPathWithin(containmentRoot, targetPath)) return ctx.notFound();
|
|
399
431
|
const contentType = file.type || "application/javascript; charset=utf-8";
|
|
400
|
-
|
|
432
|
+
const headers = new Headers({
|
|
401
433
|
"Content-Type": contentType,
|
|
402
434
|
"Cache-Control": "public, max-age=31536000"
|
|
403
|
-
}
|
|
435
|
+
});
|
|
436
|
+
applyDocumentDisposition(headers, contentType);
|
|
437
|
+
return new Response(file, { headers });
|
|
404
438
|
});
|
|
405
439
|
}
|
|
406
440
|
function autoConfigureInertiaAssets(app, options) {
|
|
@@ -496,4 +530,4 @@ function resolveResourcesDir(options, moduleDir) {
|
|
|
496
530
|
return resolve(moduleDir, resourcesPath);
|
|
497
531
|
}
|
|
498
532
|
//#endregion
|
|
499
|
-
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
|
}
|