Skip to content

@lastshotlabs/slingshot-push

npm install @lastshotlabs/slingshot-push

Build a deterministic provider idempotency key for a given delivery attempt.

The same (deliveryId, attempt) pair always produces the same string. Pass this value to upstream provider APIs that accept an idempotency token so retries within the same attempt do not produce duplicate sends.

function buildProviderIdempotencyKey(deliveryId: string, attempt: number): string

Source: packages/slingshot-push/src/lib/idempotency.ts

Compile declarative formatter templates into a runtime formatter table.

function compilePushFormatters(templates: Partial<Record<string, PushFormatterTemplate>> = {},): CompiledPushFormatterTable

Source: packages/slingshot-push/src/formatter.ts

Create a notifications delivery adapter backed by the push router.

function createPushDeliveryAdapter(opts: { router: PushRouter; formatters: CompiledPushFormatterTable; skipSources?: string[]; defaults?: NotificationDefaults; /** * Per-call override forwarded into `router.sendToUser`. When omitted, the * router falls back to its construction-time default. */ providerTimeoutMs?: number; }): DeliveryAdapter

Source: packages/slingshot-push/src/deliveryAdapter.ts

Create the multi-provider push package.

Validates rawConfig via pushPluginConfigSchema, mounts the four push entities (subscriptions, topics, topic memberships, deliveries) through the declarative package authoring path, wires Web Push / APNS / FCM providers, mounts the bespoke topic-subscribe / unsubscribe / ack routes, and registers a delivery adapter with slingshot-notifications when present.

Cross-package consumers resolve the runtime via PushRuntimeCap and the aggregated health snapshot via PushHealthCap.

function createPushPackage(rawConfig: PushPluginConfig): SlingshotPackageDefinition

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

Cancellable sleep used by router retry backoff. When signal is provided and aborted, the sleep rejects immediately with an 'aborted' error so the outer retry loop can unwind and stop spawning further attempts. Without cancellation, in-flight sleeps would tick through stop() and continue touching repositories long after teardown began. P-PUSH-6.

function createPushRouter(options: { providers: Readonly<Partial<Record<PushPlatform, PushProvider>>>; repos: PushRouterRepos; retries?: { maxAttempts?: number; initialDelayMs?: number; maxDelayMs?: number }; bus?: DynamicBus; /** Maximum milliseconds for a single provider.send() call before it is treated as transient failure. Default: 30000. */ providerTimeoutMs?: number; /** Subscriptions per topic-fan-out batch. Default: 1000. */ topicFanoutBatchSize?: number; /** Max concurrent in-flight batches before back-pressure kicks in. Default: 10. */ topicFanoutMaxPending?: number; /** * Optional metrics sink. When provided, the router records per-send * counters/timings, topic fan-out counters, subscription-cleanup counters, * and per-provider circuit-breaker / consecutive-failure gauges so * operators can wire ad-hoc dashboards without parsing logs. Defaults to * a no-op emitter. */ metrics?: MetricsEmitter; /** * Maximum subscriptions that may receive a single topic publish before the * router emits `push:topic.fanout.truncated`, returns a partial result, and * stops scheduling further batches. Default: 10000. P-PUSH-11. */ topicMaxRecipients?: number; /** * Router-level circuit breaker threshold — consecutive total-fan-out * failures (every subscription in a sendToUser/sendToUsers/publishTopic * returned allFailed) before the breaker opens and short-circuits * subsequent sends. Default: 10. Set to 0 to disable the router-level * breaker. */ routerCircuitBreakerThreshold?: number; /** * Router-level circuit breaker cooldown in ms before admitting a * half-open probe after the breaker opens. Default: 30000. */ routerCircuitBreakerCooldownMs?: number; }): PushRouter

Source: packages/slingshot-push/src/router.ts

Build a deterministic provider idempotency key for a given delivery attempt.

The same (deliveryId, attempt) pair always produces the same string. Pass this value to upstream provider APIs that accept an idempotency token so retries within the same attempt do not produce duplicate sends.

function deriveUuidV4FromKey(key: string): string

Source: packages/slingshot-push/src/lib/idempotency.ts

Public contract for slingshot-push.

Cross-package consumers (notably slingshot-chat for formatter registration) resolve PushRuntimeCap through ctx.capabilities.require(...).

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

Public contract for slingshot-push.

Cross-package consumers (notably slingshot-chat for formatter registration) resolve PushRuntimeCap through ctx.capabilities.require(...).

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

Imperative formatter escape hatch used after config compilation.

FieldDescription
androidService-account private key used to authenticate with Firebase.
enabledPlatformsPlatforms this plugin should deliver to. One or more of: web, ios, android.
iosDefault iOS app bundle identifier used when a notification does not provide one. Omit to require bundle IDs per target.’, ), defaultEnvironment: z .enum([‘sandbox’, ‘production’]) .optional() .describe( ‘Default APNS environment. One of: sandbox, production. Omit to use the provider default.’, ), }) .optional() .describe(‘iOS push configuration for APNS delivery. Omit when iOS push is not enabled.
notificationsDefault notification icon URL. Omit to send no default icon.
webWeb push configuration for browser clients. Omit when web push is not enabled.

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

Public contract for slingshot-push.

Cross-package consumers (notably slingshot-chat for formatter registration) resolve PushRuntimeCap through ctx.capabilities.require(...).

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

Entity definition for one delivery attempt against one subscription.

Source: packages/slingshot-push/src/entities/pushDelivery.ts

Store-type keyed factories for PushSubscription.

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

Entity definition for one delivery attempt against one subscription.

Source: packages/slingshot-push/src/entities/pushDelivery.ts

Public contract for slingshot-push.

Cross-package consumers (notably slingshot-chat for formatter registration) resolve PushRuntimeCap through ctx.capabilities.require(...).

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

Entity definition for persisted device subscriptions across all platforms.

Source: packages/slingshot-push/src/entities/pushSubscription.ts

Store-type keyed factories for PushSubscription.

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

Entity definition for persisted device subscriptions across all platforms.

Source: packages/slingshot-push/src/entities/pushSubscription.ts

Entity definition for named push topics.

Source: packages/slingshot-push/src/entities/pushTopic.ts

Store-type keyed factories for PushSubscription.

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

Entity definition linking subscriptions to topics.

Source: packages/slingshot-push/src/entities/pushTopicMembership.ts

Store-type keyed factories for PushSubscription.

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

Entity definition linking subscriptions to topics.

Source: packages/slingshot-push/src/entities/pushTopicMembership.ts

Entity definition for named push topics.

Source: packages/slingshot-push/src/entities/pushTopic.ts

Errors thrown by the push notification plugin.

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

Default consecutive token-fetch failures before classifying further attempts as permanent. Prevents infinite retry loops when service-account credentials are invalid or the FCM project is misconfigured.

Source: packages/slingshot-push/src/providers/fcm.ts

Errors thrown by the push notification plugin.

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

Errors thrown by the push notification plugin.

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

Errors thrown by the push notification plugin.

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

Compiled formatter registry used by the push delivery adapter.

Source: packages/slingshot-push/src/state.ts

Imperative formatter escape hatch used after config compilation.

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

Supported push delivery platforms.

Source: packages/slingshot-push/src/types/models.ts

Supported push delivery platforms.

Source: packages/slingshot-push/src/types/models.ts

Public contract for slingshot-push.

Cross-package consumers (notably slingshot-chat for formatter registration) resolve PushRuntimeCap through ctx.capabilities.require(...).

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

Imperative formatter escape hatch used after config compilation.

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

Supported push delivery platforms.

Source: packages/slingshot-push/src/types/models.ts

Public contract for slingshot-push.

Cross-package consumers (notably slingshot-chat for formatter registration) resolve PushRuntimeCap through ctx.capabilities.require(...).

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

Compiled formatter registry used by the push delivery adapter.

Source: packages/slingshot-push/src/state.ts

Per-provider observability snapshot. Cross-package consumers should read the aggregated push health via PushHealthCap; this provider-internal getHealth() hook is what the package uses to populate that capability.

Implementations must keep this cheap (no I/O) — it is read from a health endpoint and may be polled.

Source: packages/slingshot-push/src/providers/provider.ts

Per-provider observability snapshot. Cross-package consumers should read the aggregated push health via PushHealthCap; this provider-internal getHealth() hook is what the package uses to populate that capability.

Implementations must keep this cheap (no I/O) — it is read from a health endpoint and may be polled.

Source: packages/slingshot-push/src/providers/provider.ts

Cancellable sleep used by router retry backoff. When signal is provided and aborted, the sleep rejects immediately with an 'aborted' error so the outer retry loop can unwind and stop spawning further attempts. Without cancellation, in-flight sleeps would tick through stop() and continue touching repositories long after teardown began. P-PUSH-6.

Source: packages/slingshot-push/src/router.ts

Cancellable sleep used by router retry backoff. When signal is provided and aborted, the sleep rejects immediately with an 'aborted' error so the outer retry loop can unwind and stop spawning further attempts. Without cancellation, in-flight sleeps would tick through stop() and continue touching repositories long after teardown began. P-PUSH-6.

Source: packages/slingshot-push/src/router.ts

Supported push delivery platforms.

Source: packages/slingshot-push/src/types/models.ts

Cancellable sleep used by router retry backoff. When signal is provided and aborted, the sleep rejects immediately with an 'aborted' error so the outer retry loop can unwind and stop spawning further attempts. Without cancellation, in-flight sleeps would tick through stop() and continue touching repositories long after teardown began. P-PUSH-6.

Source: packages/slingshot-push/src/router.ts

Supported push delivery platforms.

Source: packages/slingshot-push/src/types/models.ts

Supported push delivery platforms.

Source: packages/slingshot-push/src/types/models.ts

Supported push delivery platforms.

Source: packages/slingshot-push/src/types/models.ts

Imperative formatter escape hatch used after config compilation.

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

Supported push delivery platforms.

Source: packages/slingshot-push/src/types/models.ts

Imperative formatter escape hatch used after config compilation.

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

Supported push delivery platforms.

Source: packages/slingshot-push/src/types/models.ts

Imperative formatter escape hatch used after config compilation.

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

Imperative formatter escape hatch used after config compilation.

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