Skip to content

@lastshotlabs/slingshot-notifications

npm install @lastshotlabs/slingshot-notifications

Control surface for the notification dispatcher, providing start/stop lifecycle and per-tick dispatch execution.

function createIntervalDispatcher(options: CreateIntervalDispatcherOptions,): DispatcherAdapter

Source: packages/slingshot-notifications/src/dispatcher.ts

Notification source identifier (e.g. “community”, “push”). Used for preference resolution and rate-limit scoping.

function createNotificationBuilder(options: CreateNotificationBuilderOptions,): NotificationBuilder

Source: packages/slingshot-notifications/src/builder.ts

Filter list responses by notificationTtlMs so expired rows don’t appear to clients before the periodic sweep deletes them. P-NOTIF-8.

function createNotificationsPackage(rawConfig: Partial<NotificationsPluginConfig> = {},): SlingshotPackageDefinition

Source: packages/slingshot-notifications/src/plugin.ts

Error thrown when notification data exceeds the size cap.

function freezeNotificationData(data: Readonly<Record<string, unknown>>,): Readonly<Record<string, unknown>>

Source: packages/slingshot-notifications/src/data.ts

Resolve the effective notification preference chain for one recipient.

function isWithinQuietHours(prefs: ResolvedPreference, now: Date): boolean

Source: packages/slingshot-notifications/src/preferences.ts

Safely parse a row’s data column. Tolerates the four shapes we see across backends (and one we should not see, but might if the row is corrupt):

  • already-parsed object (memory, mongo, postgres jsonb) -> returned as-is
  • JSON-encoded string (sqlite, legacy postgres rows) -> parsed
  • null/undefined -> undefined
  • corrupt JSON string -> undefined + throttled warn
  • JSON array (data column is supposed to hold a plain object) -> undefined

The data column should never be present as anything other than an object, so we explicitly reject arrays and primitive parse results.

Source: packages/slingshot-notifications/src/entities/notification.ts

Safely parse a row’s data column. Tolerates the four shapes we see across backends (and one we should not see, but might if the row is corrupt):

  • already-parsed object (memory, mongo, postgres jsonb) -> returned as-is
  • JSON-encoded string (sqlite, legacy postgres rows) -> parsed
  • null/undefined -> undefined
  • corrupt JSON string -> undefined + throttled warn
  • JSON array (data column is supposed to hold a plain object) -> undefined

The data column should never be present as anything other than an object, so we explicitly reject arrays and primitive parse results.

Source: packages/slingshot-notifications/src/entities/notification.ts

Notification preference entity.

Source: packages/slingshot-notifications/src/entities/preference.ts

Notification preference entity.

Source: packages/slingshot-notifications/src/entities/preference.ts

Public contract for slingshot-notifications.

Other packages and plugins consume this surface through typed capability handles instead of reaching into NOTIFICATIONS_PLUGIN_STATE_KEY directly. The plugin publishes implementations during setupPost via registerPluginCapabilities; consumers fetch them through ctx.capabilities.require(...) or services.capabilities.require(...) (in out-of-request hooks).

Legacy state-key access (getNotificationsStateOrNull) remains supported for backward compatibility, but new code should consume the contract.

Source: packages/slingshot-notifications/src/public.ts

Public contract for slingshot-notifications.

Other packages and plugins consume this surface through typed capability handles instead of reaching into NOTIFICATIONS_PLUGIN_STATE_KEY directly. The plugin publishes implementations during setupPost via registerPluginCapabilities; consumers fetch them through ctx.capabilities.require(...) or services.capabilities.require(...) (in out-of-request hooks).

Legacy state-key access (getNotificationsStateOrNull) remains supported for backward compatibility, but new code should consume the contract.

Source: packages/slingshot-notifications/src/public.ts

Public contract for slingshot-notifications.

Other packages and plugins consume this surface through typed capability handles instead of reaching into NOTIFICATIONS_PLUGIN_STATE_KEY directly. The plugin publishes implementations during setupPost via registerPluginCapabilities; consumers fetch them through ctx.capabilities.require(...) or services.capabilities.require(...) (in out-of-request hooks).

Legacy state-key access (getNotificationsStateOrNull) remains supported for backward compatibility, but new code should consume the contract.

Source: packages/slingshot-notifications/src/public.ts

Public contract for slingshot-notifications.

Other packages and plugins consume this surface through typed capability handles instead of reaching into NOTIFICATIONS_PLUGIN_STATE_KEY directly. The plugin publishes implementations during setupPost via registerPluginCapabilities; consumers fetch them through ctx.capabilities.require(...) or services.capabilities.require(...) (in out-of-request hooks).

Legacy state-key access (getNotificationsStateOrNull) remains supported for backward compatibility, but new code should consume the contract.

Source: packages/slingshot-notifications/src/public.ts

Runtime schema for validating notifications plugin configuration.

FieldDescription
defaultPreferencesDefault in-app notification preference for new subscriptions. Default: true.
dispatcherMaximum queued notifications processed per dispatcher tick. Default: 500.
rateLimitBackend used to track notification rate limits. Default: memory.
sseEnabledWhether the notification SSE stream is mounted. Default: true.

Source: packages/slingshot-notifications/src/types/config.ts

Resolve the effective notification preference chain for one recipient.

function resolveEffectivePriority(priority: NotificationPriority, prefs: ResolvedPreference, now: Date,): NotificationPriority

Source: packages/slingshot-notifications/src/preferences.ts

Resolve the effective notification preference chain for one recipient.

async function resolvePreferences(adapter: NotificationPreferenceAdapter, userId: string, source: string, type: string, defaults: NotificationPreferenceDefaults = DEFAULT_NOTIFICATION_PREFERENCE_DEFAULTS,): Promise<ResolvedPreference>

Source: packages/slingshot-notifications/src/preferences.ts

Entity runtime factories (adapter, router, routes) for the Notification entity.

Source: packages/slingshot-notifications/src/entities/factories.ts

Entity runtime factories (adapter, router, routes) for the Notification entity.

Source: packages/slingshot-notifications/src/entities/factories.ts

Error thrown when notification data exceeds the size cap.

Source: packages/slingshot-notifications/src/data.ts

Errors thrown by the notifications plugin.

Source: packages/slingshot-notifications/src/errors.ts

Errors thrown by the notifications plugin.

Source: packages/slingshot-notifications/src/errors.ts

Errors thrown by the notifications plugin.

Source: packages/slingshot-notifications/src/errors.ts

Control surface for the notification dispatcher, providing start/stop lifecycle and per-tick dispatch execution.

Source: packages/slingshot-notifications/src/dispatcher.ts

Control surface for the notification dispatcher, providing start/stop lifecycle and per-tick dispatch execution.

Source: packages/slingshot-notifications/src/dispatcher.ts

Control surface for the notification dispatcher, providing start/stop lifecycle and per-tick dispatch execution.

Source: packages/slingshot-notifications/src/dispatcher.ts

Control surface for the notification dispatcher, providing start/stop lifecycle and per-tick dispatch execution.

Source: packages/slingshot-notifications/src/dispatcher.ts

Control surface for the notification dispatcher, providing start/stop lifecycle and per-tick dispatch execution.

Source: packages/slingshot-notifications/src/dispatcher.ts

Persisted notification preference record controlling per-user, per-source, or per-type delivery channel settings.

Source: packages/slingshot-notifications/src/types.ts

Shared notification record / adapter / builder types used across packages.

These types form the typed surface that slingshot-notifications publishes through its Notifications package contract (@lastshotlabs/slingshot-notifications/public.ts). Cross-package consumers resolve the contract handles via ctx.capabilities.require(...) — the legacy NOTIFICATIONS_PLUGIN_STATE_KEY peer-state publish has been removed.

Source: packages/slingshot-core/src/notificationsPeer.ts

Persisted notification preference record controlling per-user, per-source, or per-type delivery channel settings.

Source: packages/slingshot-notifications/src/types.ts

Persisted notification preference record controlling per-user, per-source, or per-type delivery channel settings.

Source: packages/slingshot-notifications/src/types.ts

Public contract for slingshot-notifications.

Other packages and plugins consume this surface through typed capability handles instead of reaching into NOTIFICATIONS_PLUGIN_STATE_KEY directly. The plugin publishes implementations during setupPost via registerPluginCapabilities; consumers fetch them through ctx.capabilities.require(...) or services.capabilities.require(...) (in out-of-request hooks).

Legacy state-key access (getNotificationsStateOrNull) remains supported for backward compatibility, but new code should consume the contract.

Source: packages/slingshot-notifications/src/public.ts

Public contract for slingshot-notifications.

Other packages and plugins consume this surface through typed capability handles instead of reaching into NOTIFICATIONS_PLUGIN_STATE_KEY directly. The plugin publishes implementations during setupPost via registerPluginCapabilities; consumers fetch them through ctx.capabilities.require(...) or services.capabilities.require(...) (in out-of-request hooks).

Legacy state-key access (getNotificationsStateOrNull) remains supported for backward compatibility, but new code should consume the contract.

Source: packages/slingshot-notifications/src/public.ts

Persisted notification preference record controlling per-user, per-source, or per-type delivery channel settings.

Source: packages/slingshot-notifications/src/types.ts

Persisted notification preference record controlling per-user, per-source, or per-type delivery channel settings.

Source: packages/slingshot-notifications/src/types.ts

Persisted notification preference record controlling per-user, per-source, or per-type delivery channel settings.

Source: packages/slingshot-notifications/src/types.ts

Persisted notification preference record controlling per-user, per-source, or per-type delivery channel settings.

Source: packages/slingshot-notifications/src/types.ts

Runtime schema for validating notifications plugin configuration.

Source: packages/slingshot-notifications/src/types/config.ts

Persisted notification preference record controlling per-user, per-source, or per-type delivery channel settings.

Source: packages/slingshot-notifications/src/types.ts

Persisted notification preference record controlling per-user, per-source, or per-type delivery channel settings.

Source: packages/slingshot-notifications/src/types.ts

Persisted notification preference record controlling per-user, per-source, or per-type delivery channel settings.

Source: packages/slingshot-notifications/src/types.ts