import { BaseConnector } from '../../base/base.connector'; import type { IPushOptions, IPushProvider, ISendMessageSuccessResponse, WithPassthrough, PushSendResult, IPushConnector } from '../../types'; import { ChannelTypeEnum } from '../../types'; import type { OneSignalConfig } from './one-signal.config'; import type { OneSignalNarrowedInput } from './one-signal.types'; export declare class OneSignalPushConnector extends BaseConnector implements IPushProvider, IPushConnector { private config; readonly id = "one-signal"; readonly channelType: ChannelTypeEnum.PUSH; constructor(config: OneSignalConfig, fetchImpl?: typeof fetch); /** * Thinwrap-native send. Implements `IPushConnector`. * * Wire body construction (-5): * - `app_id` from config * - `headings: { en: input.title }` (overridable via augmentation `headings`) * - `contents: { en: input.body }` (overridable via augmentation `contents`) * - Recipient routing: by default `include_subscription_ids: [input.to]`. * Any augmentation recipient field (`include_external_user_ids`, * `include_player_ids`, `included_segments`, `excluded_segments`) or * any targeting key in `_passthrough.body` (see `TARGETING_KEYS`) * wins — when set, the default `include_subscription_ids` is omitted. * - Augmentation fields forwarded verbatim (snake_case literals). * * Endpoint + auth by key generation (see `ONE_SIGNAL_ENDPOINT`): an * `os_v2_` App API key goes to `api.onesignal.com` as `Key `, any * other key to the legacy v1 host as `Basic ` (the key itself, no * base64 wrapping). * * Response handling: HTTP 200 with an `id` -> success, even when `errors` * lists some invalid recipients (kept on `raw.errors`). HTTP 200 with no * `id` and an invalid-recipient `errors` array/object -> * `ConnectorError({ providerCode: 'invalid_recipient' })`; any other * missing `id` -> `invalid_request`. */ send(input: OneSignalNarrowedInput): Promise; /** * Build the OneSignal wire body from the narrowed input. Snake-case wire * field names are spelled directly (no `CasingEnum.SNAKE_CASE` transform). */ private buildBody; /** Resolve the endpoint + Authorization header for the key's generation. */ private endpointFor; /** * Body-layer mapping: HTTP 200 with an `errors` field. OneSignal documents * two shapes — string array (`['All included players are not subscribed']`) * and object map (`{ invalid_external_user_ids: [...] }`). Both indicate * invalid recipients on the wrapper's canonical surface. * * Returns `null` when the `errors` field is present but does not match any * known invalid-recipient marker — the caller treats this as success. */ private mapTicketError; /** * HTTP-layer mapping. Parses `Retry-After`: * embeds parsed seconds in `providerMessage` text; raw header value is * attached to `cause.retryAfter`. No structured `retryAfterSeconds` field * Retry is consumer policy (no retryAfterSeconds field) — the wrapper performs no * retry. */ private mapVendorError; sendMessage(options: IPushOptions, bridgeProviderData?: WithPassthrough>): Promise; }