@db3.ai/app 0.1.0-beta.1 → 0.1.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/README.md +75 -17
- package/agent-instructions.md +76 -0
- package/dist/ai/AIErrors.d.ts +7 -1
- package/dist/ai/AIErrors.js +8 -1
- package/dist/ai/AIFailover.d.ts +10 -0
- package/dist/ai/AIFailover.js +3 -2
- package/dist/ai/AIProviderAdmission.d.ts +101 -0
- package/dist/ai/AIProviderAdmission.js +336 -0
- package/dist/ai/AIRateLimiter.d.ts +11 -2
- package/dist/ai/AIRateLimiter.js +125 -10
- package/dist/ai/AIRequestTrackingError.d.ts +22 -0
- package/dist/ai/AIRequestTrackingError.js +33 -0
- package/dist/ai/Agent.d.ts +7 -7
- package/dist/ai/Agent.js +84 -56
- package/dist/ai/Ai.d.ts +11 -3
- package/dist/ai/Ai.js +94 -44
- package/dist/ai/OpenAIProviderError.js +1 -1
- package/dist/ai/ProviderSseObserver.d.ts +19 -0
- package/dist/ai/ProviderSseObserver.js +98 -0
- package/dist/ai/aiServiceTier.d.ts +5 -0
- package/dist/ai/aiServiceTier.js +14 -0
- package/dist/ai/chunkEmbeddingText.d.ts +14 -0
- package/dist/ai/chunkEmbeddingText.js +147 -0
- package/dist/ai/contracts/AI.d.ts +16 -0
- package/dist/ai/contracts/AIRequestErrorDiagnostics.d.ts +12 -0
- package/dist/ai/contracts/AIRequestErrorDiagnostics.js +1 -0
- package/dist/ai/contracts/AIServiceTier.d.ts +2 -0
- package/dist/ai/contracts/AIServiceTier.js +1 -0
- package/dist/ai/contracts/Agent.d.ts +3 -0
- package/dist/ai/contracts/EmbeddingTextChunk.d.ts +25 -0
- package/dist/ai/contracts/EmbeddingTextChunk.js +1 -0
- package/dist/ai/contracts/Pricing.d.ts +7 -1
- package/dist/ai/contracts/Providers.d.ts +2 -0
- package/dist/ai/contracts/index.d.ts +2 -0
- package/dist/ai/contracts/index.js +1 -0
- package/dist/ai/index.d.ts +8 -2
- package/dist/ai/index.js +5 -2
- package/dist/ai/{Models.d.ts → modelPricing.d.ts} +2 -2
- package/dist/ai/{Models.js → modelPricing.js} +38 -4
- package/dist/apps/AppInstallation.d.ts +21 -0
- package/dist/apps/AppInstallation.js +16 -0
- package/dist/apps/AppRouteError.d.ts +6 -0
- package/dist/apps/AppRouteError.js +10 -0
- package/dist/apps/AppService.d.ts +24 -0
- package/dist/apps/AppService.js +21 -0
- package/dist/apps/Apps.d.ts +59 -0
- package/dist/apps/Apps.js +566 -0
- package/dist/apps/appsPlugin.d.ts +3 -0
- package/dist/apps/appsPlugin.js +36 -0
- package/dist/apps/commands/disableApp.d.ts +2 -0
- package/dist/apps/commands/disableApp.js +5 -0
- package/dist/apps/commands/enableApp.d.ts +2 -0
- package/dist/apps/commands/enableApp.js +5 -0
- package/dist/apps/commands/index.d.ts +10 -0
- package/dist/apps/commands/index.js +27 -0
- package/dist/apps/commands/installApp.d.ts +2 -0
- package/dist/apps/commands/installApp.js +5 -0
- package/dist/apps/commands/listApps.d.ts +2 -0
- package/dist/apps/commands/listApps.js +5 -0
- package/dist/apps/commands/makeAppMigration.d.ts +2 -0
- package/dist/apps/commands/makeAppMigration.js +9 -0
- package/dist/apps/commands/rollbackApp.d.ts +2 -0
- package/dist/apps/commands/rollbackApp.js +5 -0
- package/dist/apps/commands/uninstallApp.d.ts +2 -0
- package/dist/apps/commands/uninstallApp.js +5 -0
- package/dist/apps/contracts/AppAction.d.ts +2 -0
- package/dist/apps/contracts/AppAction.js +1 -0
- package/dist/apps/contracts/AppDefinition.d.ts +45 -0
- package/dist/apps/contracts/AppDefinition.js +1 -0
- package/dist/apps/contracts/AppDescription.d.ts +32 -0
- package/dist/apps/contracts/AppDescription.js +1 -0
- package/dist/apps/contracts/AppManifest.d.ts +30 -0
- package/dist/apps/contracts/AppManifest.js +1 -0
- package/dist/apps/contracts/AppNavigation.d.ts +9 -0
- package/dist/apps/contracts/AppNavigation.js +1 -0
- package/dist/apps/contracts/AppNavigationBadge.d.ts +6 -0
- package/dist/apps/contracts/AppNavigationBadge.js +1 -0
- package/dist/apps/contracts/AppNavigationContext.d.ts +8 -0
- package/dist/apps/contracts/AppNavigationContext.js +1 -0
- package/dist/apps/contracts/AppNavigationResult.d.ts +12 -0
- package/dist/apps/contracts/AppNavigationResult.js +1 -0
- package/dist/apps/contracts/AppRoute.d.ts +19 -0
- package/dist/apps/contracts/AppRoute.js +1 -0
- package/dist/apps/contracts/DiscoveredApp.d.ts +10 -0
- package/dist/apps/contracts/DiscoveredApp.js +1 -0
- package/dist/apps/contracts/InstalledApps.d.ts +3 -0
- package/dist/apps/contracts/InstalledApps.js +1 -0
- package/dist/apps/contracts/index.d.ts +11 -0
- package/dist/apps/contracts/index.js +1 -0
- package/dist/apps/defineApp.d.ts +7 -0
- package/dist/apps/defineApp.js +8 -0
- package/dist/apps/discoverApps.d.ts +3 -0
- package/dist/apps/discoverApps.js +62 -0
- package/dist/apps/fastify.d.ts +1 -0
- package/dist/apps/fastify.js +1 -0
- package/dist/apps/index.d.ts +7 -0
- package/dist/apps/index.js +7 -0
- package/dist/apps/normalizeAppNavigation.d.ts +3 -0
- package/dist/apps/normalizeAppNavigation.js +30 -0
- package/dist/apps/registerAppRoutes.d.ts +6 -0
- package/dist/apps/registerAppRoutes.js +52 -0
- package/dist/apps/validateAppDefinitions.d.ts +3 -0
- package/dist/apps/validateAppDefinitions.js +65 -0
- package/dist/apps/vite.d.ts +1 -0
- package/dist/apps/vite.js +1 -0
- package/dist/apps/writeAppTypes.d.ts +2 -0
- package/dist/apps/writeAppTypes.js +13 -0
- package/dist/auth/Auth.d.ts +18 -0
- package/dist/auth/Auth.js +89 -13
- package/dist/auth/PasswordLoginAttempt.d.ts +50 -0
- package/dist/auth/PasswordLoginAttempt.js +60 -0
- package/dist/auth/PasswordSuspendedError.d.ts +10 -0
- package/dist/auth/PasswordSuspendedError.js +13 -0
- package/dist/auth/contracts/PasswordAuthProviderOptions.d.ts +26 -0
- package/dist/auth/contracts/PasswordAuthProviderOptions.js +1 -0
- package/dist/auth/contracts/PasswordSuspension.d.ts +7 -0
- package/dist/auth/contracts/PasswordSuspension.js +1 -0
- package/dist/auth/contracts/PasswordSuspensionOptions.d.ts +10 -0
- package/dist/auth/contracts/PasswordSuspensionOptions.js +1 -0
- package/dist/auth/contracts/index.d.ts +3 -0
- package/dist/auth/contracts/index.js +3 -0
- package/dist/auth/index.d.ts +2 -0
- package/dist/auth/index.js +2 -0
- package/dist/auth/providers/PasswordAuthProvider.d.ts +19 -23
- package/dist/auth/providers/PasswordAuthProvider.js +96 -8
- package/dist/auth/providers/resolveAuthProviders.js +1 -0
- package/dist/cli/Cli.d.ts +2 -0
- package/dist/cli/Cli.js +8 -0
- package/dist/cli/commands/repl.js +2 -1
- package/dist/cli/contracts/CliCommand.d.ts +2 -0
- package/dist/cli/contracts/CliCommandInfo.d.ts +12 -0
- package/dist/cli/contracts/CliCommandInfo.js +1 -0
- package/dist/cli/contracts/index.d.ts +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +1 -0
- package/dist/cli/listDb3Commands.d.ts +8 -0
- package/dist/cli/listDb3Commands.js +10 -0
- package/dist/cli/runDb3.d.ts +3 -6
- package/dist/cli/runDb3.js +5 -59
- package/dist/cli/withDb3Cli.d.ts +4 -0
- package/dist/cli/withDb3Cli.js +60 -0
- package/dist/db/ActiveQueryBuilder.d.ts +8 -0
- package/dist/db/ActiveQueryBuilder.js +11 -0
- package/dist/db/ActiveRecord.d.ts +6 -0
- package/dist/db/ActiveRecord.js +8 -0
- package/dist/db/connection.js +14 -2
- package/dist/db/fields/TimestampField.d.ts +1 -1
- package/dist/db/fields/TimestampField.js +7 -12
- package/dist/db/migrations/DatabaseMigrationManager.d.ts +3 -1
- package/dist/db/migrations/DatabaseMigrationManager.js +9 -3
- package/dist/db/migrations/contracts/DatabaseMigration.d.ts +7 -0
- package/dist/db/migrations/index.d.ts +1 -1
- package/dist/db/migrations/index.js +1 -1
- package/dist/db/migrations/{KnexMigrationRenderer.d.ts → renderKnexMigration.d.ts} +4 -3
- package/dist/db/migrations/{KnexMigrationRenderer.js → renderKnexMigration.js} +7 -6
- package/dist/flows/FlowCompiler.js +1 -1
- package/dist/flows/Flows.js +1 -1
- package/dist/flows/index.d.ts +1 -1
- package/dist/flows/index.js +1 -1
- package/dist/health/Health.d.ts +41 -0
- package/dist/health/Health.js +153 -0
- package/dist/health/contracts/Health.d.ts +36 -0
- package/dist/health/contracts/Health.js +1 -0
- package/dist/health/contracts/HealthHttp.d.ts +15 -0
- package/dist/health/contracts/HealthHttp.js +1 -0
- package/dist/health/contracts/index.d.ts +2 -0
- package/dist/health/contracts/index.js +1 -0
- package/dist/health/databaseHealthCheck.d.ts +15 -0
- package/dist/health/databaseHealthCheck.js +18 -0
- package/dist/health/fastify.d.ts +13 -0
- package/dist/health/fastify.js +44 -0
- package/dist/health/index.d.ts +3 -0
- package/dist/health/index.js +2 -0
- package/dist/in-app/InApp.d.ts +33 -0
- package/dist/in-app/InApp.js +191 -0
- package/dist/in-app/InAppError.d.ts +6 -0
- package/dist/in-app/InAppError.js +10 -0
- package/dist/in-app/InAppRecord.d.ts +36 -0
- package/dist/in-app/InAppRecord.js +24 -0
- package/dist/in-app/contracts/InAppInbox.d.ts +45 -0
- package/dist/in-app/contracts/InAppInbox.js +1 -0
- package/dist/in-app/contracts/InAppMessage.d.ts +22 -0
- package/dist/in-app/contracts/InAppMessage.js +1 -0
- package/dist/in-app/contracts/InAppScope.d.ts +17 -0
- package/dist/in-app/contracts/InAppScope.js +1 -0
- package/dist/in-app/contracts/index.d.ts +3 -0
- package/dist/in-app/contracts/index.js +3 -0
- package/dist/in-app/index.d.ts +4 -0
- package/dist/in-app/index.js +4 -0
- package/dist/in-app/validation.d.ts +21 -0
- package/dist/in-app/validation.js +50 -0
- package/dist/index.d.ts +2 -14
- package/dist/index.js +2 -5
- package/dist/logging/DevelopmentConsole.d.ts +42 -0
- package/dist/logging/DevelopmentConsole.js +162 -0
- package/dist/logging/Log.d.ts +3 -1
- package/dist/logging/Log.js +5 -2
- package/dist/logging/PrettyLogFormatter.d.ts +16 -0
- package/dist/logging/PrettyLogFormatter.js +151 -0
- package/dist/logging/acquireDevelopmentConsole.d.ts +6 -0
- package/dist/logging/acquireDevelopmentConsole.js +21 -0
- package/dist/logging/contracts/DevelopmentConsoleOptions.d.ts +16 -0
- package/dist/logging/contracts/DevelopmentConsoleOptions.js +1 -0
- package/dist/logging/contracts/EmailLogOptions.d.ts +8 -0
- package/dist/logging/contracts/EmailLogOptions.js +1 -0
- package/dist/logging/contracts/HttpExchangeMonitorOptions.d.ts +12 -0
- package/dist/logging/contracts/HttpExchangeMonitorOptions.js +1 -0
- package/dist/logging/contracts/LogTransportOptions.d.ts +19 -0
- package/dist/logging/contracts/LogTransportOptions.js +1 -0
- package/dist/logging/contracts/LoggingOptions.d.ts +12 -1
- package/dist/logging/contracts/index.d.ts +4 -0
- package/dist/logging/contracts/index.js +4 -0
- package/dist/logging/drivers/PinoLoggerDriver.d.ts +3 -1
- package/dist/logging/drivers/PinoLoggerDriver.js +75 -16
- package/dist/logging/formatLogEmail.d.ts +4 -0
- package/dist/logging/formatLogEmail.js +21 -0
- package/dist/logging/highlightQueueMessage.d.ts +11 -0
- package/dist/logging/highlightQueueMessage.js +36 -0
- package/dist/logging/httpBodyCapture.d.ts +24 -0
- package/dist/logging/httpBodyCapture.js +321 -0
- package/dist/logging/index.d.ts +2 -0
- package/dist/logging/index.js +2 -0
- package/dist/logging/redactLogEmail.d.ts +2 -0
- package/dist/logging/redactLogEmail.js +12 -0
- package/dist/logging/registerHttpExchangeMonitor.d.ts +10 -0
- package/dist/logging/registerHttpExchangeMonitor.js +43 -0
- package/dist/logging/transports/EmailLogTransport.d.ts +18 -0
- package/dist/logging/transports/EmailLogTransport.js +47 -0
- package/dist/mail/Mail.d.ts +2 -0
- package/dist/mail/Mail.js +3 -0
- package/dist/mail/MailDeliveryError.d.ts +9 -0
- package/dist/mail/MailDeliveryError.js +16 -0
- package/dist/mail/index.d.ts +1 -0
- package/dist/mail/index.js +1 -0
- package/dist/mail/transports/MailgunTransport.js +2 -0
- package/dist/mail/transports/ResendTransport.d.ts +3 -2
- package/dist/mail/transports/ResendTransport.js +22 -14
- package/dist/media/MediaManager.d.ts +4 -2
- package/dist/media/MediaManager.js +40 -8
- package/dist/network/BlockedUrlError.d.ts +16 -0
- package/dist/network/BlockedUrlError.js +19 -0
- package/dist/network/assertPublicUrl.d.ts +22 -0
- package/dist/network/assertPublicUrl.js +67 -0
- package/dist/network/contracts/GuardedFetch.d.ts +35 -0
- package/dist/network/contracts/GuardedFetch.js +1 -0
- package/dist/network/contracts/PublicUrlOptions.d.ts +17 -0
- package/dist/network/contracts/PublicUrlOptions.js +1 -0
- package/dist/network/contracts/index.d.ts +2 -0
- package/dist/network/contracts/index.js +2 -0
- package/dist/network/guardedFetch.d.ts +29 -0
- package/dist/network/guardedFetch.js +133 -0
- package/dist/network/index.d.ts +6 -0
- package/dist/network/index.js +6 -0
- package/dist/network/playwright/GuardedBrowserProxy.d.ts +32 -0
- package/dist/network/playwright/GuardedBrowserProxy.js +172 -0
- package/dist/network/playwright/contracts/GuardedBrowserContextOptions.d.ts +37 -0
- package/dist/network/playwright/contracts/GuardedBrowserContextOptions.js +1 -0
- package/dist/network/playwright/contracts/index.d.ts +1 -0
- package/dist/network/playwright/contracts/index.js +1 -0
- package/dist/network/playwright/index.d.ts +2 -0
- package/dist/network/playwright/index.js +2 -0
- package/dist/network/playwright/newGuardedBrowserContext.d.ts +21 -0
- package/dist/network/playwright/newGuardedBrowserContext.js +86 -0
- package/dist/network/privateNetworkAddresses.d.ts +44 -0
- package/dist/network/privateNetworkAddresses.js +157 -0
- package/dist/network/publicAddressLookup.d.ts +26 -0
- package/dist/network/publicAddressLookup.js +42 -0
- package/dist/notifications/Notifications.d.ts +27 -0
- package/dist/notifications/Notifications.js +99 -0
- package/dist/notifications/contracts/Notification.d.ts +56 -0
- package/dist/notifications/contracts/Notification.js +1 -0
- package/dist/notifications/contracts/NotificationDelivery.d.ts +11 -0
- package/dist/notifications/contracts/NotificationDelivery.js +1 -0
- package/dist/notifications/contracts/index.d.ts +2 -0
- package/dist/notifications/contracts/index.js +2 -0
- package/dist/notifications/index.d.ts +2 -0
- package/dist/notifications/index.js +2 -0
- package/dist/queue/JobRunAttempt.d.ts +16 -0
- package/dist/queue/JobRunAttempt.js +17 -0
- package/dist/queue/JobRunEvent.d.ts +15 -0
- package/dist/queue/JobRunEvent.js +16 -0
- package/dist/queue/JobRunStoppedError.d.ts +6 -0
- package/dist/queue/JobRunStoppedError.js +10 -0
- package/dist/queue/Queue.d.ts +19 -4
- package/dist/queue/Queue.js +122 -9
- package/dist/queue/QueueTerminalError.d.ts +9 -0
- package/dist/queue/QueueTerminalError.js +12 -0
- package/dist/queue/QueueWorker.d.ts +12 -5
- package/dist/queue/QueueWorker.js +94 -9
- package/dist/queue/QueueWorkerReporter.d.ts +17 -0
- package/dist/queue/QueueWorkerReporter.js +71 -0
- package/dist/queue/QueueableJob.d.ts +2 -2
- package/dist/queue/RunnableJob.d.ts +78 -0
- package/dist/queue/RunnableJob.js +284 -0
- package/dist/queue/console.d.ts +8 -0
- package/dist/queue/console.js +53 -19
- package/dist/queue/contracts/QueueDriver.d.ts +8 -0
- package/dist/queue/contracts/QueueJobRunner.d.ts +4 -0
- package/dist/queue/contracts/QueueJobRunner.js +1 -0
- package/dist/queue/contracts/QueuePayload.d.ts +1 -1
- package/dist/queue/contracts/QueueSelection.d.ts +11 -0
- package/dist/queue/contracts/QueueSelection.js +1 -0
- package/dist/queue/contracts/QueueService.d.ts +18 -4
- package/dist/queue/contracts/QueueWorkerLifecycle.d.ts +2 -2
- package/dist/queue/contracts/QueueWorkerSnapshot.d.ts +14 -0
- package/dist/queue/contracts/QueueWorkerSnapshot.js +1 -0
- package/dist/queue/contracts/QueueableJob.d.ts +7 -3
- package/dist/queue/contracts/QueueableJobContract.d.ts +12 -0
- package/dist/queue/contracts/QueueableJobContract.js +1 -0
- package/dist/queue/contracts/index.d.ts +4 -0
- package/dist/queue/contracts/index.js +2 -0
- package/dist/queue/drivers/DatabaseQueueDriver.d.ts +4 -0
- package/dist/queue/drivers/DatabaseQueueDriver.js +27 -3
- package/dist/queue/drivers/RedisQueueDriver.d.ts +7 -0
- package/dist/queue/drivers/RedisQueueDriver.js +37 -0
- package/dist/queue/index.d.ts +5 -0
- package/dist/queue/index.js +5 -0
- package/dist/queue/jobEnvelopeHasPrefix.d.ts +3 -0
- package/dist/queue/jobEnvelopeHasPrefix.js +4 -0
- package/dist/scheduler/ScheduledEvent.d.ts +8 -4
- package/dist/scheduler/ScheduledEvent.js +17 -3
- package/dist/scheduler/ScheduledJob.d.ts +1 -1
- package/dist/scheduler/Scheduler.d.ts +5 -0
- package/dist/scheduler/Scheduler.js +92 -28
- package/dist/scheduler/SchedulerCheckpointRecord.d.ts +16 -0
- package/dist/scheduler/SchedulerCheckpointRecord.js +53 -0
- package/dist/scheduler/SchedulerWorker.d.ts +3 -5
- package/dist/scheduler/SchedulerWorker.js +58 -14
- package/dist/scheduler/console.js +3 -1
- package/dist/scheduler/contracts/Schedule.d.ts +19 -0
- package/dist/scheduler/contracts/Schedule.js +1 -0
- package/dist/scheduler/contracts/Scheduler.d.ts +18 -6
- package/dist/scheduler/contracts/SchedulerCheckpoint.d.ts +23 -0
- package/dist/scheduler/contracts/SchedulerCheckpoint.js +1 -0
- package/dist/scheduler/contracts/SchedulerConsole.d.ts +5 -0
- package/dist/scheduler/contracts/SchedulerWorker.d.ts +6 -1
- package/dist/scheduler/contracts/index.d.ts +2 -0
- package/dist/scheduler/contracts/index.js +2 -0
- package/dist/scheduler/index.d.ts +1 -0
- package/dist/scheduler/index.js +1 -0
- package/dist/server/App.d.ts +36 -4
- package/dist/server/App.js +57 -7
- package/dist/server/contracts/HttpErrorHandlerOptions.d.ts +29 -0
- package/dist/server/contracts/HttpErrorHandlerOptions.js +1 -0
- package/dist/server/contracts/index.d.ts +1 -0
- package/dist/server/contracts/index.js +1 -0
- package/dist/server/index.d.ts +4 -0
- package/dist/server/index.js +4 -0
- package/dist/server/publicServerErrorMessage.d.ts +11 -0
- package/dist/server/publicServerErrorMessage.js +16 -0
- package/dist/server/registerBrowserJsonFormatting.d.ts +16 -0
- package/dist/server/registerBrowserJsonFormatting.js +100 -0
- package/dist/server/registerHttpErrorHandler.d.ts +20 -0
- package/dist/server/registerHttpErrorHandler.js +93 -0
- package/dist/ssr/vite/contracts/ViteSsrOptions.d.ts +2 -0
- package/dist/ssr/vite/fastifyViteSsr.js +4 -3
- package/dist/storage/drivers/FlystorageDisk.js +2 -2
- package/dist/storage/index.d.ts +2 -2
- package/dist/storage/index.js +2 -2
- package/dist/websocket/WebSocketChannels.d.ts +18 -0
- package/dist/websocket/WebSocketChannels.js +129 -0
- package/dist/websocket/WebSocketConnection.d.ts +25 -0
- package/dist/websocket/WebSocketConnection.js +244 -0
- package/dist/websocket/WebSockets.d.ts +41 -0
- package/dist/websocket/WebSockets.js +194 -0
- package/dist/websocket/client/WebSocketClient.d.ts +21 -0
- package/dist/websocket/client/WebSocketClient.js +230 -0
- package/dist/websocket/client/index.d.ts +3 -0
- package/dist/websocket/client/index.js +1 -0
- package/dist/websocket/contracts/WebSocketChannel.d.ts +20 -0
- package/dist/websocket/contracts/WebSocketChannel.js +1 -0
- package/dist/websocket/contracts/WebSocketClient.d.ts +45 -0
- package/dist/websocket/contracts/WebSocketClient.js +1 -0
- package/dist/websocket/contracts/WebSocketEndpoint.d.ts +43 -0
- package/dist/websocket/contracts/WebSocketEndpoint.js +1 -0
- package/dist/websocket/contracts/WebSocketOptions.d.ts +48 -0
- package/dist/websocket/contracts/WebSocketOptions.js +1 -0
- package/dist/websocket/contracts/WebSocketPresence.d.ts +6 -0
- package/dist/websocket/contracts/WebSocketPresence.js +1 -0
- package/dist/websocket/contracts/WebSocketServiceOptions.d.ts +12 -0
- package/dist/websocket/contracts/WebSocketServiceOptions.js +1 -0
- package/dist/websocket/contracts/index.d.ts +6 -0
- package/dist/websocket/contracts/index.js +1 -0
- package/dist/websocket/defineChannel.d.ts +8 -0
- package/dist/websocket/defineChannel.js +13 -0
- package/dist/websocket/defineWebSocket.d.ts +14 -0
- package/dist/websocket/defineWebSocket.js +4 -0
- package/dist/websocket/fastify.d.ts +11 -0
- package/dist/websocket/fastify.js +38 -0
- package/dist/websocket/index.d.ts +5 -0
- package/dist/websocket/index.js +4 -0
- package/package.json +108 -7
- package/src/ai/AIErrors.ts +10 -0
- package/src/ai/AIFailover.ts +3 -2
- package/src/ai/AIProviderAdmission.ts +329 -0
- package/src/ai/AIRateLimiter.ts +134 -10
- package/src/ai/AIRequestTrackingError.ts +37 -0
- package/src/ai/Agent.ts +85 -71
- package/src/ai/Ai.ts +104 -48
- package/src/ai/OpenAIProviderError.ts +1 -1
- package/src/ai/ProviderSseObserver.ts +89 -0
- package/src/ai/README.md +216 -11
- package/src/ai/aiServiceTier.ts +14 -0
- package/src/ai/chunkEmbeddingText.ts +137 -0
- package/src/ai/contracts/AI.ts +17 -0
- package/src/ai/contracts/AIRequestErrorDiagnostics.ts +12 -0
- package/src/ai/contracts/AIServiceTier.ts +2 -0
- package/src/ai/contracts/Agent.ts +3 -0
- package/src/ai/contracts/EmbeddingTextChunk.ts +26 -0
- package/src/ai/contracts/Pricing.ts +7 -1
- package/src/ai/contracts/Providers.ts +2 -0
- package/src/ai/contracts/index.ts +2 -0
- package/src/ai/examples/prepareDocumentEmbeddings.ts +20 -0
- package/src/ai/index.ts +9 -2
- package/src/ai/{Models.ts → modelPricing.ts} +37 -4
- package/src/apps/AppInstallation.ts +25 -0
- package/src/apps/AppRouteError.ts +8 -0
- package/src/apps/AppService.ts +30 -0
- package/src/apps/Apps.ts +508 -0
- package/src/apps/README.md +354 -0
- package/src/apps/appsPlugin.ts +34 -0
- package/src/apps/commands/disableApp.ts +6 -0
- package/src/apps/commands/enableApp.ts +6 -0
- package/src/apps/commands/index.ts +29 -0
- package/src/apps/commands/installApp.ts +6 -0
- package/src/apps/commands/listApps.ts +6 -0
- package/src/apps/commands/makeAppMigration.ts +9 -0
- package/src/apps/commands/rollbackApp.ts +6 -0
- package/src/apps/commands/uninstallApp.ts +6 -0
- package/src/apps/contracts/AppAction.ts +2 -0
- package/src/apps/contracts/AppDefinition.ts +49 -0
- package/src/apps/contracts/AppDescription.ts +27 -0
- package/src/apps/contracts/AppManifest.ts +32 -0
- package/src/apps/contracts/AppNavigation.ts +10 -0
- package/src/apps/contracts/AppNavigationBadge.ts +6 -0
- package/src/apps/contracts/AppNavigationContext.ts +6 -0
- package/src/apps/contracts/AppNavigationResult.ts +9 -0
- package/src/apps/contracts/AppRoute.ts +18 -0
- package/src/apps/contracts/DiscoveredApp.ts +11 -0
- package/src/apps/contracts/InstalledApps.ts +2 -0
- package/src/apps/contracts/index.ts +11 -0
- package/src/apps/defineApp.ts +10 -0
- package/src/apps/discoverApps.ts +56 -0
- package/src/apps/fastify.ts +1 -0
- package/src/apps/index.ts +7 -0
- package/src/apps/normalizeAppNavigation.ts +29 -0
- package/src/apps/registerAppRoutes.ts +48 -0
- package/src/apps/validateAppDefinitions.ts +52 -0
- package/src/apps/vite.ts +1 -0
- package/src/apps/writeAppTypes.ts +14 -0
- package/src/auth/Auth.ts +89 -23
- package/src/auth/PasswordLoginAttempt.ts +72 -0
- package/src/auth/PasswordSuspendedError.ts +13 -0
- package/src/auth/README.md +94 -4
- package/src/auth/contracts/PasswordAuthProviderOptions.ts +30 -0
- package/src/auth/contracts/PasswordSuspension.ts +7 -0
- package/src/auth/contracts/PasswordSuspensionOptions.ts +10 -0
- package/src/auth/contracts/index.ts +3 -0
- package/src/auth/examples/runPasswordAuth.ts +6 -6
- package/src/auth/index.ts +2 -0
- package/src/auth/providers/PasswordAuthProvider.ts +96 -30
- package/src/auth/providers/resolveAuthProviders.ts +1 -0
- package/src/cli/Cli.ts +9 -0
- package/src/cli/README.md +19 -0
- package/src/cli/commands/repl.ts +2 -1
- package/src/cli/contracts/CliCommand.ts +2 -0
- package/src/cli/contracts/CliCommandInfo.ts +13 -0
- package/src/cli/contracts/index.ts +1 -0
- package/src/cli/index.ts +1 -0
- package/src/cli/listDb3Commands.ts +12 -0
- package/src/cli/runDb3.ts +5 -51
- package/src/cli/withDb3Cli.ts +55 -0
- package/src/db/ActiveQueryBuilder.ts +12 -0
- package/src/db/ActiveRecord.ts +9 -0
- package/src/db/README.md +45 -1
- package/src/db/connection.ts +12 -1
- package/src/db/examples/FieldNote.ts +7 -13
- package/src/db/examples/KnowledgeNote.ts +7 -13
- package/src/db/examples/runNoteMigrations.ts +11 -11
- package/src/db/fields/TimestampField.ts +8 -17
- package/src/db/migrations/DatabaseMigrationManager.ts +12 -4
- package/src/db/migrations/contracts/DatabaseMigration.ts +9 -0
- package/src/db/migrations/index.ts +1 -1
- package/src/db/migrations/{KnexMigrationRenderer.ts → renderKnexMigration.ts} +8 -14
- package/src/flows/FlowCompiler.ts +1 -1
- package/src/flows/Flows.ts +1 -1
- package/src/flows/index.ts +1 -1
- package/src/health/Health.ts +163 -0
- package/src/health/README.md +46 -0
- package/src/health/contracts/Health.ts +47 -0
- package/src/health/contracts/HealthHttp.ts +19 -0
- package/src/health/contracts/index.ts +2 -0
- package/src/health/databaseHealthCheck.ts +21 -0
- package/src/health/fastify.ts +49 -0
- package/src/health/index.ts +3 -0
- package/src/in-app/InApp.ts +173 -0
- package/src/in-app/InAppError.ts +8 -0
- package/src/in-app/InAppRecord.ts +41 -0
- package/src/in-app/README.md +193 -0
- package/src/in-app/contracts/InAppInbox.ts +51 -0
- package/src/in-app/contracts/InAppMessage.ts +19 -0
- package/src/in-app/contracts/InAppScope.ts +12 -0
- package/src/in-app/contracts/index.ts +3 -0
- package/src/in-app/examples/sendReportReady.ts +14 -0
- package/src/in-app/index.ts +4 -0
- package/src/in-app/validation.ts +49 -0
- package/src/index.ts +2 -22
- package/src/logging/DevelopmentConsole.ts +154 -0
- package/src/logging/Log.ts +5 -2
- package/src/logging/PrettyLogFormatter.ts +165 -0
- package/src/logging/README.md +52 -109
- package/src/logging/acquireDevelopmentConsole.ts +19 -0
- package/src/logging/contracts/DevelopmentConsoleOptions.ts +13 -0
- package/src/logging/contracts/EmailLogOptions.ts +9 -0
- package/src/logging/contracts/HttpExchangeMonitorOptions.ts +13 -0
- package/src/logging/contracts/LogTransportOptions.ts +10 -0
- package/src/logging/contracts/LoggingOptions.ts +12 -1
- package/src/logging/contracts/index.ts +4 -0
- package/src/logging/development/README.md +88 -0
- package/src/logging/drivers/PinoLoggerDriver.ts +72 -20
- package/src/logging/examples/runDevelopmentLogs.ts +36 -0
- package/src/logging/formatLogEmail.ts +24 -0
- package/src/logging/highlightQueueMessage.ts +38 -0
- package/src/logging/httpBodyCapture.ts +393 -0
- package/src/logging/index.ts +2 -0
- package/src/logging/redactLogEmail.ts +12 -0
- package/src/logging/registerHttpExchangeMonitor.ts +45 -0
- package/src/logging/transports/EmailLogTransport.ts +46 -0
- package/src/mail/Mail.ts +5 -0
- package/src/mail/MailDeliveryError.ts +8 -0
- package/src/mail/README.md +11 -1
- package/src/mail/index.ts +1 -0
- package/src/mail/transports/MailgunTransport.ts +2 -0
- package/src/mail/transports/ResendTransport.ts +24 -22
- package/src/media/MediaManager.ts +31 -10
- package/src/media/README.md +4 -0
- package/src/media/examples/runPrivateFiles.ts +2 -2
- package/src/network/BlockedUrlError.ts +19 -0
- package/src/network/README.md +133 -0
- package/src/network/assertPublicUrl.ts +77 -0
- package/src/network/contracts/GuardedFetch.ts +40 -0
- package/src/network/contracts/PublicUrlOptions.ts +17 -0
- package/src/network/contracts/index.ts +2 -0
- package/src/network/examples/runGuardedFetch.ts +35 -0
- package/src/network/guardedFetch.ts +150 -0
- package/src/network/index.ts +6 -0
- package/src/network/playwright/GuardedBrowserProxy.ts +172 -0
- package/src/network/playwright/contracts/GuardedBrowserContextOptions.ts +43 -0
- package/src/network/playwright/contracts/index.ts +1 -0
- package/src/network/playwright/index.ts +2 -0
- package/src/network/playwright/newGuardedBrowserContext.ts +74 -0
- package/src/network/privateNetworkAddresses.ts +166 -0
- package/src/network/publicAddressLookup.ts +49 -0
- package/src/notifications/Notifications.ts +105 -0
- package/src/notifications/README.md +59 -0
- package/src/notifications/contracts/Notification.ts +65 -0
- package/src/notifications/contracts/NotificationDelivery.ts +11 -0
- package/src/notifications/contracts/index.ts +2 -0
- package/src/notifications/examples/ReportReadyNotification.ts +31 -0
- package/src/notifications/index.ts +2 -0
- package/src/queue/JobRunAttempt.ts +17 -0
- package/src/queue/JobRunEvent.ts +16 -0
- package/src/queue/JobRunStoppedError.ts +8 -0
- package/src/queue/Queue.ts +112 -11
- package/src/queue/QueueTerminalError.ts +12 -0
- package/src/queue/QueueWorker.ts +86 -7
- package/src/queue/QueueWorkerReporter.ts +59 -0
- package/src/queue/QueueableJob.ts +2 -2
- package/src/queue/README.md +142 -1
- package/src/queue/RunnableJob.ts +272 -0
- package/src/queue/console.ts +54 -21
- package/src/queue/contracts/QueueDriver.ts +9 -0
- package/src/queue/contracts/QueueJobRunner.ts +4 -0
- package/src/queue/contracts/QueuePayload.ts +1 -1
- package/src/queue/contracts/QueueSelection.ts +11 -0
- package/src/queue/contracts/QueueService.ts +19 -4
- package/src/queue/contracts/QueueWorkerLifecycle.ts +2 -2
- package/src/queue/contracts/QueueWorkerSnapshot.ts +15 -0
- package/src/queue/contracts/QueueableJob.ts +7 -3
- package/src/queue/contracts/QueueableJobContract.ts +13 -0
- package/src/queue/contracts/index.ts +6 -0
- package/src/queue/drivers/DatabaseQueueDriver.ts +25 -3
- package/src/queue/drivers/RedisQueueDriver.ts +36 -0
- package/src/queue/examples/runQueueSelection.ts +34 -0
- package/src/queue/index.ts +7 -0
- package/src/queue/jobEnvelopeHasPrefix.ts +6 -0
- package/src/scheduler/README.md +50 -9
- package/src/scheduler/ScheduledEvent.ts +20 -5
- package/src/scheduler/ScheduledJob.ts +1 -1
- package/src/scheduler/Scheduler.ts +73 -27
- package/src/scheduler/SchedulerCheckpointRecord.ts +51 -0
- package/src/scheduler/SchedulerWorker.ts +54 -19
- package/src/scheduler/console.ts +3 -1
- package/src/scheduler/contracts/Schedule.ts +22 -0
- package/src/scheduler/contracts/Scheduler.ts +21 -6
- package/src/scheduler/contracts/SchedulerCheckpoint.ts +23 -0
- package/src/scheduler/contracts/SchedulerConsole.ts +5 -0
- package/src/scheduler/contracts/SchedulerWorker.ts +6 -1
- package/src/scheduler/contracts/index.ts +2 -0
- package/src/scheduler/examples/runSchedulerWindow.ts +54 -0
- package/src/scheduler/index.ts +1 -0
- package/src/server/App.ts +73 -10
- package/src/server/README.md +95 -2
- package/src/server/contracts/HttpErrorHandlerOptions.ts +29 -0
- package/src/server/contracts/index.ts +1 -0
- package/src/server/examples/createFirstServer.ts +5 -3
- package/src/server/index.ts +4 -0
- package/src/server/publicServerErrorMessage.ts +17 -0
- package/src/server/registerBrowserJsonFormatting.ts +94 -0
- package/src/server/registerHttpErrorHandler.ts +96 -0
- package/src/ssr/README.md +6 -0
- package/src/ssr/vite/contracts/ViteSsrOptions.ts +2 -0
- package/src/ssr/vite/fastifyViteSsr.ts +4 -3
- package/src/storage/drivers/FlystorageDisk.ts +2 -2
- package/src/storage/index.ts +2 -2
- package/src/websocket/README.md +458 -0
- package/src/websocket/WebSocketChannels.ts +99 -0
- package/src/websocket/WebSocketConnection.ts +162 -0
- package/src/websocket/WebSockets.ts +157 -0
- package/src/websocket/client/WebSocketClient.ts +188 -0
- package/src/websocket/client/index.ts +3 -0
- package/src/websocket/contracts/WebSocketChannel.ts +23 -0
- package/src/websocket/contracts/WebSocketClient.ts +48 -0
- package/src/websocket/contracts/WebSocketEndpoint.ts +46 -0
- package/src/websocket/contracts/WebSocketOptions.ts +50 -0
- package/src/websocket/contracts/WebSocketPresence.ts +6 -0
- package/src/websocket/contracts/WebSocketServiceOptions.ts +12 -0
- package/src/websocket/contracts/index.ts +6 -0
- package/src/websocket/defineChannel.ts +14 -0
- package/src/websocket/defineWebSocket.ts +15 -0
- package/src/websocket/examples/board/LiveBoard.ts +97 -0
- package/src/websocket/examples/board/SummarizeBoardJob.ts +52 -0
- package/src/websocket/examples/board/boardSnapshot.ts +16 -0
- package/src/websocket/examples/board/createBoardClient.ts +43 -0
- package/src/websocket/examples/board/createBoardStore.ts +58 -0
- package/src/websocket/examples/board/registerBoardRoutes.ts +31 -0
- package/src/websocket/examples/createChannelSync.ts +66 -0
- package/src/websocket/examples/deploymentEndpoint.ts +13 -0
- package/src/websocket/examples/deploymentSnapshot.ts +36 -0
- package/src/websocket/examples/resourceChannels.ts +18 -0
- package/src/websocket/examples/userEndpoint.ts +27 -0
- package/src/websocket/fastify.ts +39 -0
- package/src/websocket/index.ts +5 -0
- package/templates/AGENTS.md +33 -2
- /package/dist/flows/{FlowValueValidator.d.ts → flowValueValidator.d.ts} +0 -0
- /package/dist/flows/{FlowValueValidator.js → flowValueValidator.js} +0 -0
- /package/dist/storage/{mime.d.ts → mimeTypeFromPath.d.ts} +0 -0
- /package/dist/storage/{mime.js → mimeTypeFromPath.js} +0 -0
- /package/dist/storage/{contents.d.ts → storageContentsToBuffer.d.ts} +0 -0
- /package/dist/storage/{contents.js → storageContentsToBuffer.js} +0 -0
- /package/src/flows/{FlowValueValidator.ts → flowValueValidator.ts} +0 -0
- /package/src/storage/{mime.ts → mimeTypeFromPath.ts} +0 -0
- /package/src/storage/{contents.ts → storageContentsToBuffer.ts} +0 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { isIP } from 'node:net';
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes a URL hostname for address classification.
|
|
4
|
+
*
|
|
5
|
+
* WHATWG URL parsing already canonicalizes numeric IPv4 forms such as
|
|
6
|
+
* `2130706433` and `0x7f.1`. This helper additionally lowercases the value,
|
|
7
|
+
* removes IPv6 brackets and drops one trailing root-label dot so `localhost.`
|
|
8
|
+
* and `localhost` are treated the same.
|
|
9
|
+
*
|
|
10
|
+
* @param hostname - `URL.hostname` value to normalize.
|
|
11
|
+
* @returns Lowercase hostname or IP literal without brackets or a trailing dot.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* normalizedUrlHostname(new URL('http://[::1]/').hostname); // '::1'
|
|
15
|
+
*/
|
|
16
|
+
export function normalizedUrlHostname(hostname) {
|
|
17
|
+
return hostname.toLowerCase().replace(/^\[|\]$/g, '').replace(/\.$/, '');
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Checks whether a hostname is reserved for the local machine.
|
|
21
|
+
*
|
|
22
|
+
* DNS names are otherwise judged by the addresses they resolve to, so this
|
|
23
|
+
* only covers names that never need a DNS query to reach loopback.
|
|
24
|
+
*
|
|
25
|
+
* @param hostname - Hostname normalized with {@link normalizedUrlHostname}.
|
|
26
|
+
* @returns True for `localhost` and any `*.localhost` name.
|
|
27
|
+
*/
|
|
28
|
+
export function isPrivateHostname(hostname) {
|
|
29
|
+
return hostname === 'localhost' || hostname.endsWith('.localhost');
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Checks whether an IP address must not be reached by server-side requests.
|
|
33
|
+
*
|
|
34
|
+
* The policy blocks loopback, private, link-local (including cloud metadata),
|
|
35
|
+
* carrier-grade NAT, benchmarking, documentation, multicast and reserved
|
|
36
|
+
* ranges. IPv6 forms that embed an IPv4 address (mapped, NAT64 and 6to4) are
|
|
37
|
+
* judged by the embedded address, and tunnelling or deprecated forms that can
|
|
38
|
+
* reach IPv4 hosts indirectly are blocked outright. Values that are not valid
|
|
39
|
+
* IP literals return false so callers can resolve them as hostnames instead.
|
|
40
|
+
*
|
|
41
|
+
* @param address - IPv4 or IPv6 literal, with or without IPv6 brackets.
|
|
42
|
+
* @returns True when the address is private, local or reserved.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* isPrivateIpAddress('169.254.169.254'); // true
|
|
46
|
+
* isPrivateIpAddress('::ffff:7f00:1'); // true (IPv4-mapped 127.0.0.1)
|
|
47
|
+
* isPrivateIpAddress('93.184.216.34'); // false
|
|
48
|
+
*/
|
|
49
|
+
export function isPrivateIpAddress(address) {
|
|
50
|
+
const normalized = normalizedUrlHostname(address).replace(/%.*$/, '');
|
|
51
|
+
const version = isIP(normalized);
|
|
52
|
+
if (version === 4)
|
|
53
|
+
return isPrivateIpv4Octets(normalized.split('.').map(Number));
|
|
54
|
+
if (version === 6)
|
|
55
|
+
return isPrivateIpv6Hextets(expandIpv6(normalized));
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Applies the IPv4 reserved-range policy to four parsed octets.
|
|
60
|
+
*
|
|
61
|
+
* @param octets - Parsed IPv4 octets.
|
|
62
|
+
* @returns True when the address belongs to a blocked range.
|
|
63
|
+
*/
|
|
64
|
+
function isPrivateIpv4Octets(octets) {
|
|
65
|
+
if (octets.length !== 4 || octets.some(octet => !Number.isInteger(octet) || octet < 0 || octet > 255)) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
const [first, second, third] = octets;
|
|
69
|
+
return first === 0
|
|
70
|
+
|| first === 10
|
|
71
|
+
|| first === 127
|
|
72
|
+
|| (first === 100 && second >= 64 && second <= 127)
|
|
73
|
+
|| (first === 169 && second === 254)
|
|
74
|
+
|| (first === 172 && second >= 16 && second <= 31)
|
|
75
|
+
|| (first === 192 && second === 0 && (third === 0 || third === 2))
|
|
76
|
+
|| (first === 192 && second === 88 && third === 99)
|
|
77
|
+
|| (first === 192 && second === 168)
|
|
78
|
+
|| (first === 198 && (second === 18 || second === 19))
|
|
79
|
+
|| (first === 198 && second === 51 && third === 100)
|
|
80
|
+
|| (first === 203 && second === 0 && third === 113)
|
|
81
|
+
|| first >= 224;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Applies the IPv6 reserved-range policy to eight expanded hextets.
|
|
85
|
+
*
|
|
86
|
+
* @param hextets - Expanded IPv6 address, or null when it could not be parsed.
|
|
87
|
+
* @returns True when the address belongs to a blocked range.
|
|
88
|
+
*/
|
|
89
|
+
function isPrivateIpv6Hextets(hextets) {
|
|
90
|
+
if (!hextets)
|
|
91
|
+
return true;
|
|
92
|
+
const [h0, h1, h2, h3, h4, h5, h6, h7] = hextets;
|
|
93
|
+
const leadingZeros = h0 === 0 && h1 === 0 && h2 === 0 && h3 === 0 && h4 === 0;
|
|
94
|
+
// ::ffff:a.b.c.d IPv4-mapped addresses reach the embedded IPv4 host.
|
|
95
|
+
if (leadingZeros && h5 === 0xffff)
|
|
96
|
+
return isPrivateIpv4Octets(ipv4FromHextets(h6, h7));
|
|
97
|
+
// ::, ::1 and deprecated ::a.b.c.d IPv4-compatible addresses.
|
|
98
|
+
if (leadingZeros && h5 === 0)
|
|
99
|
+
return true;
|
|
100
|
+
// 64:ff9b::/96 well-known NAT64 prefix translates to the embedded IPv4 host.
|
|
101
|
+
if (h0 === 0x64 && h1 === 0xff9b && h2 === 0 && h3 === 0 && h4 === 0 && h5 === 0) {
|
|
102
|
+
return isPrivateIpv4Octets(ipv4FromHextets(h6, h7));
|
|
103
|
+
}
|
|
104
|
+
// 64:ff9b:1::/48 local-use NAT64.
|
|
105
|
+
if (h0 === 0x64 && h1 === 0xff9b && h2 === 1)
|
|
106
|
+
return true;
|
|
107
|
+
// 2002::/16 6to4 embeds the relay's IPv4 address in the next 32 bits.
|
|
108
|
+
if (h0 === 0x2002)
|
|
109
|
+
return isPrivateIpv4Octets(ipv4FromHextets(h1, h2));
|
|
110
|
+
// 2001::/32 Teredo tunnelling and 2001:db8::/32 documentation.
|
|
111
|
+
if (h0 === 0x2001 && (h1 === 0 || h1 === 0xdb8))
|
|
112
|
+
return true;
|
|
113
|
+
// 100::/64 discard-only.
|
|
114
|
+
if (h0 === 0x100 && h1 === 0 && h2 === 0 && h3 === 0)
|
|
115
|
+
return true;
|
|
116
|
+
return (h0 & 0xfe00) === 0xfc00 // fc00::/7 unique local
|
|
117
|
+
|| (h0 & 0xffc0) === 0xfe80 // fe80::/10 link-local
|
|
118
|
+
|| (h0 & 0xffc0) === 0xfec0 // fec0::/10 deprecated site-local
|
|
119
|
+
|| (h0 & 0xff00) === 0xff00; // ff00::/8 multicast
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Converts two hextets holding an embedded IPv4 address into octets.
|
|
123
|
+
*
|
|
124
|
+
* @param high - Hextet containing the first two octets.
|
|
125
|
+
* @param low - Hextet containing the last two octets.
|
|
126
|
+
* @returns Four IPv4 octets.
|
|
127
|
+
*/
|
|
128
|
+
function ipv4FromHextets(high, low) {
|
|
129
|
+
return [high >> 8, high & 0xff, low >> 8, low & 0xff];
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Expands a valid IPv6 literal into eight numeric hextets.
|
|
133
|
+
*
|
|
134
|
+
* Supports `::` compression and a trailing dotted IPv4 suffix.
|
|
135
|
+
*
|
|
136
|
+
* @param address - IPv6 literal already validated by `net.isIP`.
|
|
137
|
+
* @returns Eight hextets, or null when the literal cannot be expanded.
|
|
138
|
+
*/
|
|
139
|
+
function expandIpv6(address) {
|
|
140
|
+
let value = address;
|
|
141
|
+
const dotted = value.match(/^(.*:)(\d+\.\d+\.\d+\.\d+)$/);
|
|
142
|
+
if (dotted) {
|
|
143
|
+
const octets = dotted[2].split('.').map(Number);
|
|
144
|
+
value = `${dotted[1]}${((octets[0] << 8) | octets[1]).toString(16)}:${((octets[2] << 8) | octets[3]).toString(16)}`;
|
|
145
|
+
}
|
|
146
|
+
const [head, tail] = value.split('::');
|
|
147
|
+
const headParts = head ? head.split(':') : [];
|
|
148
|
+
const tailParts = tail === undefined ? [] : tail ? tail.split(':') : [];
|
|
149
|
+
const missing = 8 - headParts.length - tailParts.length;
|
|
150
|
+
if (tail === undefined ? missing !== 0 : missing < 0)
|
|
151
|
+
return null;
|
|
152
|
+
const hextets = [...headParts, ...Array(tail === undefined ? 0 : missing).fill('0'), ...tailParts]
|
|
153
|
+
.map(part => Number.parseInt(part, 16));
|
|
154
|
+
return hextets.length === 8 && hextets.every(part => Number.isInteger(part) && part >= 0 && part <= 0xffff)
|
|
155
|
+
? hextets
|
|
156
|
+
: null;
|
|
157
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type LookupAddress, type LookupOptions } from 'node:dns';
|
|
2
|
+
/** Callback shape used by `dns.lookup` for both single and `all` results. */
|
|
3
|
+
type LookupCallback = (error: NodeJS.ErrnoException | null, address: string | LookupAddress[], family?: number) => void;
|
|
4
|
+
/**
|
|
5
|
+
* DNS lookup that refuses to connect to private, local or reserved addresses.
|
|
6
|
+
*
|
|
7
|
+
* It has the same signature as `dns.lookup`, so it can be passed as the
|
|
8
|
+
* `lookup` socket option of Node's `http`, `https`, `net` and `tls` modules and
|
|
9
|
+
* to clients built on them (for example undici's `connect.lookup` or got's
|
|
10
|
+
* `dnsLookup`). Because the check runs when the socket connects, the address
|
|
11
|
+
* that is validated is the address that is used, which closes the DNS
|
|
12
|
+
* rebinding gap left by checking a hostname before a separate request.
|
|
13
|
+
*
|
|
14
|
+
* Node does not call `lookup` for IP-literal hosts, so literals (including
|
|
15
|
+
* redirect targets) must still be checked with {@link assertPublicUrl}.
|
|
16
|
+
*
|
|
17
|
+
* @param hostname - Hostname being connected to.
|
|
18
|
+
* @param options - Lookup options supplied by the socket layer.
|
|
19
|
+
* @param callback - Receives the validated address(es) or a `BlockedUrlError`.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* import { Agent } from 'undici';
|
|
23
|
+
* const dispatcher = new Agent({ connect: { lookup: publicAddressLookup } });
|
|
24
|
+
*/
|
|
25
|
+
export declare function publicAddressLookup(hostname: string, options: LookupOptions, callback: LookupCallback): void;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { lookup } from 'node:dns';
|
|
2
|
+
import { BlockedUrlError } from './BlockedUrlError.js';
|
|
3
|
+
import { PRIVATE_DESTINATION_MESSAGE } from './assertPublicUrl.js';
|
|
4
|
+
import { isPrivateIpAddress } from './privateNetworkAddresses.js';
|
|
5
|
+
/**
|
|
6
|
+
* DNS lookup that refuses to connect to private, local or reserved addresses.
|
|
7
|
+
*
|
|
8
|
+
* It has the same signature as `dns.lookup`, so it can be passed as the
|
|
9
|
+
* `lookup` socket option of Node's `http`, `https`, `net` and `tls` modules and
|
|
10
|
+
* to clients built on them (for example undici's `connect.lookup` or got's
|
|
11
|
+
* `dnsLookup`). Because the check runs when the socket connects, the address
|
|
12
|
+
* that is validated is the address that is used, which closes the DNS
|
|
13
|
+
* rebinding gap left by checking a hostname before a separate request.
|
|
14
|
+
*
|
|
15
|
+
* Node does not call `lookup` for IP-literal hosts, so literals (including
|
|
16
|
+
* redirect targets) must still be checked with {@link assertPublicUrl}.
|
|
17
|
+
*
|
|
18
|
+
* @param hostname - Hostname being connected to.
|
|
19
|
+
* @param options - Lookup options supplied by the socket layer.
|
|
20
|
+
* @param callback - Receives the validated address(es) or a `BlockedUrlError`.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* import { Agent } from 'undici';
|
|
24
|
+
* const dispatcher = new Agent({ connect: { lookup: publicAddressLookup } });
|
|
25
|
+
*/
|
|
26
|
+
export function publicAddressLookup(hostname, options, callback) {
|
|
27
|
+
lookup(hostname, { ...options, all: true }, (error, addresses) => {
|
|
28
|
+
if (error) {
|
|
29
|
+
callback(error, []);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (addresses.length === 0 || addresses.some(entry => isPrivateIpAddress(entry.address))) {
|
|
33
|
+
callback(Object.assign(new BlockedUrlError(PRIVATE_DESTINATION_MESSAGE), { code: 'ERR_BLOCKED_ADDRESS' }), []);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (options.all) {
|
|
37
|
+
callback(null, addresses);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
callback(null, addresses[0].address, addresses[0].family);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { UserIdentity, UserIdentityModel } from '../auth/index.js';
|
|
2
|
+
import type { InApp } from '../in-app/index.js';
|
|
3
|
+
import type { Mail } from '../mail/index.js';
|
|
4
|
+
import type * as notifications from './contracts/index.js';
|
|
5
|
+
/** Coordinates application-owned notification classes with framework channels. */
|
|
6
|
+
export declare class Notifications<TUser extends UserIdentity = UserIdentity> {
|
|
7
|
+
#private;
|
|
8
|
+
private readonly inApp;
|
|
9
|
+
private readonly mail;
|
|
10
|
+
private readonly identityModel;
|
|
11
|
+
/**
|
|
12
|
+
* Creates the notification coordinator used by app().notifications.
|
|
13
|
+
*
|
|
14
|
+
* @param inApp - Durable framework inbox service.
|
|
15
|
+
* @param mail - Provider-neutral framework mail service.
|
|
16
|
+
* @param identityModel - Application identity model used to resolve ID recipients.
|
|
17
|
+
*/
|
|
18
|
+
constructor(inApp: InApp, mail: Mail, identityModel: UserIdentityModel<TUser>);
|
|
19
|
+
/**
|
|
20
|
+
* Delivers one notification to one or more users through its `via()` channels.
|
|
21
|
+
*
|
|
22
|
+
* @param recipients - User model, ID, or an array mixing both forms.
|
|
23
|
+
* @param notification - Application-owned routing and channel renderers.
|
|
24
|
+
* @returns One delivery result per distinct resolved user.
|
|
25
|
+
*/
|
|
26
|
+
send(recipients: notifications.NotificationRecipient<TUser> | readonly notifications.NotificationRecipient<TUser>[], notification: notifications.Notification<TUser>): Promise<notifications.NotificationDelivery[]>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
/** Coordinates application-owned notification classes with framework channels. */
|
|
3
|
+
export class Notifications {
|
|
4
|
+
inApp;
|
|
5
|
+
mail;
|
|
6
|
+
identityModel;
|
|
7
|
+
/**
|
|
8
|
+
* Creates the notification coordinator used by app().notifications.
|
|
9
|
+
*
|
|
10
|
+
* @param inApp - Durable framework inbox service.
|
|
11
|
+
* @param mail - Provider-neutral framework mail service.
|
|
12
|
+
* @param identityModel - Application identity model used to resolve ID recipients.
|
|
13
|
+
*/
|
|
14
|
+
constructor(inApp, mail, identityModel) {
|
|
15
|
+
this.inApp = inApp;
|
|
16
|
+
this.mail = mail;
|
|
17
|
+
this.identityModel = identityModel;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Delivers one notification to one or more users through its `via()` channels.
|
|
21
|
+
*
|
|
22
|
+
* @param recipients - User model, ID, or an array mixing both forms.
|
|
23
|
+
* @param notification - Application-owned routing and channel renderers.
|
|
24
|
+
* @returns One delivery result per distinct resolved user.
|
|
25
|
+
*/
|
|
26
|
+
async send(recipients, notification) {
|
|
27
|
+
if (!notification.type?.trim())
|
|
28
|
+
throw new Error('Notification type is required.');
|
|
29
|
+
const users = await this.#resolveUsers(recipients);
|
|
30
|
+
const deliveries = [];
|
|
31
|
+
for (const user of users)
|
|
32
|
+
deliveries.push(await this.#deliver(user, notification));
|
|
33
|
+
return deliveries;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Delivers selected channels for one canonical user.
|
|
37
|
+
*
|
|
38
|
+
* @param user - Resolved application identity.
|
|
39
|
+
* @param notification - Application-owned routing and content definition.
|
|
40
|
+
* @returns Accepted in-app and mail outcomes for the recipient.
|
|
41
|
+
*/
|
|
42
|
+
async #deliver(user, notification) {
|
|
43
|
+
const userId = String(user.id);
|
|
44
|
+
const channels = [...new Set(notification.via(user))];
|
|
45
|
+
if (!channels.length)
|
|
46
|
+
return { userId, inApp: null, mail: null };
|
|
47
|
+
if (channels.some(channel => !['inApp', 'mail'].includes(channel)))
|
|
48
|
+
throw new Error(`Notification "${notification.type}" selected an unsupported channel.`);
|
|
49
|
+
const scope = notification.scope?.(user) ?? { type: 'account' };
|
|
50
|
+
const key = notification.key?.(user);
|
|
51
|
+
let inApp = null;
|
|
52
|
+
let mail = null;
|
|
53
|
+
if (channels.includes('inApp')) {
|
|
54
|
+
if (!notification.toInApp)
|
|
55
|
+
throw new Error(`Notification "${notification.type}" selected inApp without a toInApp() renderer.`);
|
|
56
|
+
[inApp] = await this.inApp.send(userId, notification.toInApp(user), { scope, type: notification.type, key });
|
|
57
|
+
}
|
|
58
|
+
if (channels.includes('mail')) {
|
|
59
|
+
if (!notification.toMail)
|
|
60
|
+
throw new Error(`Notification "${notification.type}" selected mail without a toMail() renderer.`);
|
|
61
|
+
mail = await this.mail.send(withDeliveryKey(notification.toMail(user), notification.type, key, userId));
|
|
62
|
+
}
|
|
63
|
+
return { userId, inApp, mail };
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Resolves model and ID inputs, rejecting missing identities before delivery.
|
|
67
|
+
*
|
|
68
|
+
* @param recipients - User model, ID, or bounded array of either form.
|
|
69
|
+
* @returns Distinct canonical users in first-seen order.
|
|
70
|
+
*/
|
|
71
|
+
async #resolveUsers(recipients) {
|
|
72
|
+
const input = Array.isArray(recipients) ? recipients : [recipients];
|
|
73
|
+
if (input.length > 100)
|
|
74
|
+
throw new Error('Notifications accepts at most 100 recipients per send.');
|
|
75
|
+
const users = new Map();
|
|
76
|
+
for (const recipient of input) {
|
|
77
|
+
const user = typeof recipient === 'string' ? await this.identityModel.find(recipient) : recipient;
|
|
78
|
+
if (!user?.id)
|
|
79
|
+
throw new Error('Notification recipient is unavailable.');
|
|
80
|
+
users.set(String(user.id), user);
|
|
81
|
+
}
|
|
82
|
+
return [...users.values()];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Adds a stable provider retry identity when the renderer did not provide one.
|
|
87
|
+
*
|
|
88
|
+
* @param message - Provider-neutral mail content rendered by the notification.
|
|
89
|
+
* @param type - Stable notification type.
|
|
90
|
+
* @param key - Optional application-owned occurrence key.
|
|
91
|
+
* @param userId - Canonical recipient identity.
|
|
92
|
+
* @returns Original or copied message with an idempotency key when possible.
|
|
93
|
+
*/
|
|
94
|
+
function withDeliveryKey(message, type, key, userId) {
|
|
95
|
+
if (message.idempotencyKey || !key)
|
|
96
|
+
return message;
|
|
97
|
+
const hash = createHash('sha256').update(JSON.stringify([type, key, userId])).digest('hex');
|
|
98
|
+
return { ...message, idempotencyKey: `notification/${hash}` };
|
|
99
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { InAppMessage, InAppScope } from '../../in-app/index.js';
|
|
2
|
+
import type { MailMessage } from '../../mail/index.js';
|
|
3
|
+
/** Framework delivery channels currently supported by notification classes. */
|
|
4
|
+
export type NotificationChannel = 'inApp' | 'mail';
|
|
5
|
+
/** Minimum persisted identity accepted by the notification service. */
|
|
6
|
+
export interface NotificationUser {
|
|
7
|
+
/** Stable application identity used for delivery ownership and deduplication. */
|
|
8
|
+
id: string | null;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Application-owned notification content and routing policy.
|
|
12
|
+
*
|
|
13
|
+
* Channel renderers return data only. They must not persist messages, contact
|
|
14
|
+
* providers or depend on an active HTTP request.
|
|
15
|
+
*/
|
|
16
|
+
export interface Notification<TUser extends NotificationUser = NotificationUser> {
|
|
17
|
+
/** Stable application-owned type used for inbox filtering and deduplication. */
|
|
18
|
+
readonly type: string;
|
|
19
|
+
/**
|
|
20
|
+
* Selects delivery channels for one resolved user.
|
|
21
|
+
*
|
|
22
|
+
* @param user - Persisted recipient, available for future preference checks.
|
|
23
|
+
* @returns Distinct supported channels to deliver.
|
|
24
|
+
*/
|
|
25
|
+
via(user: TUser): readonly NotificationChannel[];
|
|
26
|
+
/**
|
|
27
|
+
* Resolves recipient scope for authorization and inbox queries.
|
|
28
|
+
*
|
|
29
|
+
* @param user - Persisted recipient receiving this occurrence.
|
|
30
|
+
* @returns Account scope by default, or an application-owned scope.
|
|
31
|
+
*/
|
|
32
|
+
scope?(user: TUser): InAppScope;
|
|
33
|
+
/**
|
|
34
|
+
* Returns a stable business identity used to deduplicate retries.
|
|
35
|
+
*
|
|
36
|
+
* @param user - Persisted recipient receiving this occurrence.
|
|
37
|
+
* @returns Application-owned occurrence key, or undefined for no deduplication.
|
|
38
|
+
*/
|
|
39
|
+
key?(user: TUser): string | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Renders durable in-app content when `via()` selects `inApp`.
|
|
42
|
+
*
|
|
43
|
+
* @param user - Persisted recipient receiving this occurrence.
|
|
44
|
+
* @returns Validated content stored in the recipient's inbox.
|
|
45
|
+
*/
|
|
46
|
+
toInApp?(user: TUser): InAppMessage;
|
|
47
|
+
/**
|
|
48
|
+
* Renders email content when `via()` selects `mail`.
|
|
49
|
+
*
|
|
50
|
+
* @param user - Persisted recipient receiving this occurrence.
|
|
51
|
+
* @returns Provider-neutral mail content ready for the configured transport.
|
|
52
|
+
*/
|
|
53
|
+
toMail?(user: TUser): MailMessage;
|
|
54
|
+
}
|
|
55
|
+
/** User model or stable ID accepted by notification delivery. */
|
|
56
|
+
export type NotificationRecipient<TUser extends NotificationUser> = TUser | string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { InAppAcceptance } from '../../in-app/index.js';
|
|
2
|
+
import type { MailDelivery } from '../../mail/index.js';
|
|
3
|
+
/** Accepted channel outcomes for one resolved user. */
|
|
4
|
+
export interface NotificationDelivery {
|
|
5
|
+
/** Stable recipient identity. */
|
|
6
|
+
userId: string;
|
|
7
|
+
/** Durable in-app acceptance, or null when the notification omitted the channel. */
|
|
8
|
+
inApp: InAppAcceptance | null;
|
|
9
|
+
/** Mail transport acceptance, or null when the renderer omitted the channel. */
|
|
10
|
+
mail: MailDelivery | null;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ActiveRecord } from '../db/ActiveRecord.js';
|
|
2
|
+
declare const JobRunAttempt_base: import("../db/index.js").DefinedActiveRecord<typeof ActiveRecord, {
|
|
3
|
+
id: import("../db/index.js").UlidField;
|
|
4
|
+
runId: import("../db/index.js").StringField;
|
|
5
|
+
tenantId: import("../db/index.js").StringField;
|
|
6
|
+
attempt: import("../db/index.js").IntegerField;
|
|
7
|
+
deliveryId: import("../db/index.js").StringField;
|
|
8
|
+
status: import("../db/index.js").StringField;
|
|
9
|
+
error: import("../db/index.js").TextField;
|
|
10
|
+
startedAt: import("../db/index.js").TimestampField;
|
|
11
|
+
completedAt: import("../db/index.js").TimestampField;
|
|
12
|
+
}>;
|
|
13
|
+
/** Retains each execution boundary, including attempts interrupted before a handler could fail itself. */
|
|
14
|
+
export declare class JobRunAttempt extends JobRunAttempt_base {
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ActiveRecord } from '../db/ActiveRecord.js';
|
|
2
|
+
/** Retains each execution boundary, including attempts interrupted before a handler could fail itself. */
|
|
3
|
+
export class JobRunAttempt extends ActiveRecord.define({
|
|
4
|
+
table: 'job_run_attempts',
|
|
5
|
+
fields: field => ({
|
|
6
|
+
id: field.ulid(),
|
|
7
|
+
runId: field.string({ column: 'run_id', required: true, length: 26, index: true }),
|
|
8
|
+
tenantId: field.string({ column: 'tenant_id', required: true, length: 100, index: true }),
|
|
9
|
+
attempt: field.integer({ required: true }),
|
|
10
|
+
deliveryId: field.string({ column: 'delivery_id', required: true, length: 100 }),
|
|
11
|
+
status: field.string({ required: true, length: 30 }),
|
|
12
|
+
error: field.text(),
|
|
13
|
+
startedAt: field.timestamp({ column: 'started_at', required: true }),
|
|
14
|
+
completedAt: field.timestamp({ column: 'completed_at' }),
|
|
15
|
+
}),
|
|
16
|
+
}) {
|
|
17
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ActiveRecord } from '../db/ActiveRecord.js';
|
|
2
|
+
declare const JobRunEvent_base: import("../db/index.js").DefinedActiveRecord<typeof ActiveRecord, {
|
|
3
|
+
id: import("../db/index.js").UlidField;
|
|
4
|
+
runId: import("../db/index.js").StringField;
|
|
5
|
+
tenantId: import("../db/index.js").StringField;
|
|
6
|
+
attempt: import("../db/index.js").IntegerField;
|
|
7
|
+
level: import("../db/index.js").ChoiceStringField;
|
|
8
|
+
message: import("../db/index.js").StringField;
|
|
9
|
+
data: import("../db/index.js").JsonField<Record<string, unknown> | null>;
|
|
10
|
+
createdAt: import("../db/index.js").TimestampField;
|
|
11
|
+
}>;
|
|
12
|
+
/** Append-only diagnostic evidence for a run; applications control access and retention. */
|
|
13
|
+
export declare class JobRunEvent extends JobRunEvent_base {
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ActiveRecord } from '../db/ActiveRecord.js';
|
|
2
|
+
/** Append-only diagnostic evidence for a run; applications control access and retention. */
|
|
3
|
+
export class JobRunEvent extends ActiveRecord.define({
|
|
4
|
+
table: 'job_run_events',
|
|
5
|
+
fields: field => ({
|
|
6
|
+
id: field.ulid(),
|
|
7
|
+
runId: field.string({ column: 'run_id', required: true, length: 26, index: true }),
|
|
8
|
+
tenantId: field.string({ column: 'tenant_id', required: true, length: 100, index: true }),
|
|
9
|
+
attempt: field.integer({ required: true, default: 0 }),
|
|
10
|
+
level: field.choice({ choices: ['info', 'warning', 'error'], required: true, default: 'info' }),
|
|
11
|
+
message: field.string({ required: true, length: 1024 }),
|
|
12
|
+
data: field.json(),
|
|
13
|
+
createdAt: field.timestamp({ column: 'created_at', auto: 'create' }),
|
|
14
|
+
}),
|
|
15
|
+
}) {
|
|
16
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Cooperative stop requested by an operator or a job-owned blocking policy. */
|
|
2
|
+
export declare class JobRunStoppedError extends Error {
|
|
3
|
+
readonly status: 'blocked' | 'cancelled';
|
|
4
|
+
/** Captures a durable stop reason without treating expected stops as provider exceptions. */
|
|
5
|
+
constructor(status: 'blocked' | 'cancelled', message: string);
|
|
6
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Cooperative stop requested by an operator or a job-owned blocking policy. */
|
|
2
|
+
export class JobRunStoppedError extends Error {
|
|
3
|
+
status;
|
|
4
|
+
/** Captures a durable stop reason without treating expected stops as provider exceptions. */
|
|
5
|
+
constructor(status, message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.status = status;
|
|
8
|
+
this.name = 'JobRunStoppedError';
|
|
9
|
+
}
|
|
10
|
+
}
|
package/dist/queue/Queue.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import type { QueueableJobContract as QueueableJob } from './contracts/QueueableJobContract.js';
|
|
1
2
|
import type { Database } from '../db/index.js';
|
|
2
3
|
import { type QueueMonitor } from './queueMonitor.js';
|
|
3
4
|
import { QueueEvents } from './QueueEvents.js';
|
|
4
5
|
import { QueueWorker } from './QueueWorker.js';
|
|
5
|
-
import { type QueueableJob } from './QueueableJob.js';
|
|
6
6
|
import type * as queue from './contracts/index.js';
|
|
7
7
|
export type { QueueOptions, QueueService, QueueWorkOptions } from './contracts/index.js';
|
|
8
8
|
/**
|
|
@@ -12,6 +12,7 @@ export type { QueueOptions, QueueService, QueueWorkOptions } from './contracts/i
|
|
|
12
12
|
* callers can either process one job at a time or start a worker loop over the same API.
|
|
13
13
|
*/
|
|
14
14
|
export declare class Queue implements queue.QueueService {
|
|
15
|
+
#private;
|
|
15
16
|
private readonly db;
|
|
16
17
|
private readonly options;
|
|
17
18
|
private readonly handlers;
|
|
@@ -20,9 +21,17 @@ export declare class Queue implements queue.QueueService {
|
|
|
20
21
|
readonly events: QueueEvents;
|
|
21
22
|
constructor(db: Database, options?: queue.QueueOptions);
|
|
22
23
|
/**
|
|
23
|
-
* Returns the
|
|
24
|
+
* Returns the configured transport name for atomic database dispatch.
|
|
24
25
|
*/
|
|
26
|
+
get driverName(): string;
|
|
27
|
+
/** Reports worker presence through the application-owned sink without changing delivery semantics. */
|
|
28
|
+
reportWorker(snapshot: queue.QueueWorkerSnapshot): Promise<void>;
|
|
29
|
+
/** Returns the optional queue lifecycle monitor. */
|
|
25
30
|
get queueMonitor(): QueueMonitor | null;
|
|
31
|
+
/** Registers app-owned stable job names atomically and returns cleanup for this process only. */
|
|
32
|
+
registerJobs(owner: string, jobs: readonly queue.QueueableJobClass[], run?: queue.QueueJobRunner): () => void;
|
|
33
|
+
/** Checks active, delayed, reserved and chained payloads after producers have been quiesced. */
|
|
34
|
+
hasPendingJobs(jobPrefix: string): Promise<boolean>;
|
|
26
35
|
/**
|
|
27
36
|
* Returns recent terminal failures from the configured queue driver.
|
|
28
37
|
*
|
|
@@ -125,9 +134,15 @@ export declare class Queue implements queue.QueueService {
|
|
|
125
134
|
*/
|
|
126
135
|
private lostLeaseError;
|
|
127
136
|
/**
|
|
128
|
-
*
|
|
137
|
+
* Discovers named queues without reading or changing job payloads.
|
|
138
|
+
* @throws When a custom driver does not implement wildcard discovery.
|
|
129
139
|
*/
|
|
130
|
-
|
|
140
|
+
queueNames(): Promise<string[]>;
|
|
141
|
+
/**
|
|
142
|
+
* Starts a polling worker for a named queue or selection unless disabled.
|
|
143
|
+
* @example queue.startWorker({ queues: '*', excludeQueues: ['articles'] });
|
|
144
|
+
*/
|
|
145
|
+
startWorker(queue?: string | queue.QueueSelection, options?: queue.QueueWorkerOptions): QueueWorker | null;
|
|
131
146
|
private resolveDriver;
|
|
132
147
|
/**
|
|
133
148
|
* Returns a positive reservation timeout for queue claims and heartbeats.
|