@atribu/node 0.1.2 → 0.2.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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/errors.ts","../src/config.ts","../src/retry.ts","../src/version.ts","../src/runtime.ts","../src/http.ts","../src/resources/messages.ts","../src/resources/comments.ts","../src/resources/webhook-subscriptions.ts","../src/resources/webhook-deliveries.ts","../src/retry-wrapper.ts","../src/client.ts"],"names":["code","body"],"mappings":";;;AAiCO,IAAM,WAAA,GAAN,cAA0B,KAAA,CAAM;AAAA,EACrC,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,OAAO,GAAA,CAAA,MAAA,CAAW,IAAA;AAAA,EACzB;AACF;AAEO,IAAM,iBAAA,GAAN,cAAgC,WAAA,CAAY;AAAC;AAE7C,IAAM,oBAAA,GAAN,cAAmC,WAAA,CAAY;AAAA,EAC3C,KAAA;AAAA,EACT,WAAA,CAAY,SAAiB,KAAA,EAAgB;AAC3C,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,KAAA,GAAQ,KAAA;AAAA,EACf;AACF;AASO,IAAM,cAAA,GAAN,cAA6B,WAAA,CAAY;AAAA,EACrC,IAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA,KAAA;AAAA,EACA,YAAA;AAAA,EAET,YAAY,IAAA,EAOT;AACD,IAAA,KAAA,CAAM,IAAI,IAAA,CAAK,IAAI,CAAA,EAAA,EAAK,IAAA,CAAK,OAAO,CAAA,CAAE,CAAA;AACtC,IAAA,IAAA,CAAK,OAAO,IAAA,CAAK,IAAA;AACjB,IAAA,IAAA,CAAK,SAAS,IAAA,CAAK,MAAA;AACnB,IAAA,IAAA,CAAK,YAAY,IAAA,CAAK,SAAA;AACtB,IAAA,IAAA,CAAK,QAAQ,IAAA,CAAK,KAAA;AAClB,IAAA,IA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M,OAAA,GAAU,IAAI,kBAAA,CAAmB,IAAA,CAAK,OAAO,OAAO,CAAA;AAC1D,IAAA,OAAO,aAAA,CAAa,UAAU,OAAO,CAAA;AAAA,EACvC;AAAA,EAEA,OAAe,UAAU,IAAA,EAAoC;AAC3D,IAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,MAAA,CAAO,aAAA,CAAa,SAAS,CAAA;AAClD,IAAA,MAAM,CAAA,GAAI,eAAe,IAAI,CAAA;AAC7B,IAAA,MAAA,CAAO,OAAO,KAAA,EAAO;AAAA,MACnB,KAAA,EAAO,IAAA;AAAA,MACP,UAAU,CAAA,CAAE,QAAA;AAAA,MACZ,UAAU,CAAA,CAAE,QAAA;AAAA,MACZ,UAAU,CAAA,CAAE;AAAA,KACb,CAAA;AACD,IAAA,OAAO,KAAA;AAAA,EACT;AACF","file":"index.cjs","sourcesContent":["/**\n * Atribu error class hierarchy.\n *\n * Why typed errors: consumers need to branch on auth-failure vs rate-limit vs\n * server-error vs validation-error to decide whether to retry, refresh\n * credentials, or surface to the user. A single `Error` with a status code\n * forces every consumer to write the same `if (err.status === 401)` ladder.\n *\n * Why no automatic retries: the SDK derives a `retry` hint from status +\n * Retry-After + error code, but consumers' queue/job systems decide whether\n * to act on it. Auto-retry inside the SDK hides backpressure signals and\n * makes error budgets opaque.\n */\n\nimport type { RetryHint } from \"./retry\";\n\nexport type ApiErrorCode =\n | \"unauthorized\"\n | \"forbidden\"\n | \"insufficient_scope\"\n | \"not_found\"\n | \"invalid_parameter\"\n | \"invalid_request\"\n | \"validation_error\"\n | \"invalid_content\"\n | \"invalid_date_range\"\n | \"rate_limit_exceeded\"\n | \"connection_not_ready\"\n | \"provider_error\"\n | \"service_unavailable\"\n | \"internal_error\"\n | string;\n\nexport class AtribuError extends Error {\n constructor(message: string) {\n super(message);\n this.name = new.target.name;\n }\n}\n\nexport class AtribuConfigError extends AtribuError {}\n\nexport class AtribuTransportError extends AtribuError {\n readonly cause: unknown;\n constructor(message: string, cause: unknown) {\n super(message);\n this.cause = cause;\n }\n}\n\nexport interface ApiErrorBody {\n code: ApiErrorCode;\n message: string;\n status: number;\n request_id?: string;\n}\n\nexport class AtribuApiError extends AtribuError {\n readonly code: ApiErrorCode;\n readonly status: number;\n readonly requestId: string | null;\n readonly retry: RetryHint;\n readonly responseBody: unknown;\n\n constructor(args: {\n code: ApiErrorCode;\n message: string;\n status: number;\n requestId: string | null;\n retry: RetryHint;\n responseBody: unknown;\n }) {\n super(`[${args.code}] ${args.message}`);\n this.code = args.code;\n this.status = args.status;\n this.requestId = args.requestId;\n this.retry = args.retry;\n this.responseBody = args.responseBody;\n }\n\n isRetryable(): boolean {\n return this.retry.action === \"retry\" || this.retry.action === \"retry_after\";\n }\n isAuthFailure(): boolean {\n return this.status === 401 || this.code === \"unauthorized\";\n }\n isRateLimit(): boolean {\n return this.status === 429 || this.code === \"rate_limit_exceeded\";\n }\n}\n\nexport type OauthErrorCode =\n | \"invalid_request\"\n | \"invalid_client\"\n | \"invalid_grant\"\n | \"unauthorized_client\"\n | \"unsupported_grant_type\"\n | \"invalid_scope\"\n | \"server_error\"\n | \"unsupported_token_type\"\n | string;\n\nexport class AtribuOauthError extends AtribuError {\n readonly code: OauthErrorCode;\n readonly status: number;\n readonly description: string | null;\n\n constructor(args: { code: OauthErrorCode; description: string | null; status: number }) {\n super(`[oauth/${args.code}] ${args.description ?? args.code}`);\n this.code = args.code;\n this.status = args.status;\n this.description = args.description;\n }\n}\n\nexport type WebhookErrorCode =\n | \"missing_signature\"\n | \"malformed_header\"\n | \"expired_timestamp\"\n | \"invalid_signature\";\n\nexport class AtribuWebhookError extends AtribuError {\n readonly code: WebhookErrorCode;\n constructor(code: WebhookErrorCode, message: string) {\n super(message);\n this.code = code;\n }\n}\n","import { AtribuConfigError } from \"./errors\";\n\nexport const DEFAULT_BASE_URL = \"https://www.atribu.app\";\nexport const DEFAULT_TIMEOUT_MS = 30_000;\n\nexport interface AtribuClientConfig {\n apiKey: string;\n baseUrl?: string;\n fetch?: typeof fetch;\n timeoutMs?: number;\n userAgent?: string;\n defaultIdempotencyKeyGenerator?: () => string;\n}\n\nexport interface ResolvedConfig {\n apiKey: string;\n baseUrl: string;\n fetch: typeof fetch;\n timeoutMs: number;\n userAgentSuffix: string | null;\n generateIdempotencyKey: () => string;\n}\n\nexport function resolveConfig(config: AtribuClientConfig): ResolvedConfig {\n if (!config.apiKey || typeof config.apiKey !== \"string\") {\n throw new AtribuConfigError(\"apiKey is required\");\n }\n const fetchImpl = config.fetch ?? globalThis.fetch;\n if (typeof fetchImpl !== \"function\") {\n throw new AtribuConfigError(\n \"globalThis.fetch is not available; pass a `fetch` implementation in config\",\n );\n }\n const baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n return {\n apiKey: config.apiKey,\n baseUrl,\n fetch: fetchImpl,\n timeoutMs: config.timeoutMs ?? DEFAULT_TIMEOUT_MS,\n userAgentSuffix: config.userAgent ?? null,\n generateIdempotencyKey: config.defaultIdempotencyKeyGenerator ?? defaultUuid,\n };\n}\n\nfunction defaultUuid(): string {\n if (typeof crypto !== \"undefined\" && typeof crypto.randomUUID === \"function\") {\n return crypto.randomUUID();\n }\n // Fallback for older runtimes — a v4-ish UUID via Math.random. Not\n // cryptographically strong; idempotency keys don't need to be.\n const hex = \"0123456789abcdef\";\n let out = \"\";\n for (let i = 0; i < 32; i++) {\n const c = Math.floor(Math.random() * 16);\n out += hex[i === 12 ? 4 : i === 16 ? (c & 0x3) | 0x8 : c];\n if (i === 7 || i === 11 || i === 15 || i === 19) out += \"-\";\n }\n return out;\n}\n","/**\n * Retry hints derived from HTTP status + headers.\n *\n * The SDK never retries automatically. It derives a hint and surfaces it on\n * AtribuApiError.retry so consumers' queue systems can decide. Hiding retry\n * logic in the SDK hides backpressure signals.\n */\n\nexport type RetryHint =\n | { action: \"retry\" }\n | { action: \"retry_after\"; retryAfterMs: number }\n | { action: \"refresh_token\" }\n | { action: \"fix_and_retry\" }\n | { action: \"do_not_retry\" };\n\nexport interface DeriveRetryInput {\n status: number;\n retryAfterHeader: string | null;\n errorCode: string | null;\n}\n\nexport function deriveRetryHint(input: DeriveRetryInput): RetryHint {\n const retryAfterMs = parseRetryAfter(input.retryAfterHeader);\n if (retryAfterMs !== null) {\n return { action: \"retry_after\", retryAfterMs };\n }\n if (input.status === 401) return { action: \"refresh_token\" };\n if (input.status === 403 || input.errorCode === \"forbidden\" || input.errorCode === \"insufficient_scope\") {\n return { action: \"do_not_retry\" };\n }\n if (input.status === 408) return { action: \"retry\" };\n if (input.status === 409) return { action: \"fix_and_retry\" };\n if (input.status === 422 || input.errorCode === \"validation_error\" || input.errorCode === \"invalid_content\") {\n return { action: \"fix_and_retry\" };\n }\n if (input.status === 429 || input.errorCode === \"rate_limit_exceeded\") {\n return { action: \"retry_after\", retryAfterMs: 1000 };\n }\n if (input.status >= 500) return { action: \"retry\" };\n if (input.status >= 400) return { action: \"fix_and_retry\" };\n return { action: \"do_not_retry\" };\n}\n\nfunction parseRetryAfter(header: string | null): number | null {\n if (!header) return null;\n const asInt = Number(header);\n if (Number.isFinite(asInt) && asInt >= 0) return Math.round(asInt * 1000);\n const asDate = Date.parse(header);\n if (Number.isFinite(asDate)) return Math.max(0, asDate - Date.now());\n return null;\n}\n","export const SDK_VERSION = \"0.1.2\";\n","export type Runtime = \"node\" | \"bun\" | \"deno\" | \"edge\" | \"browser\" | \"unknown\";\n\ndeclare const Deno: unknown;\ndeclare const Bun: unknown;\ndeclare const EdgeRuntime: unknown;\n\nexport function detectRuntime(): Runtime {\n if (typeof Deno !== \"undefined\") return \"deno\";\n if (typeof Bun !== \"undefined\") return \"bun\";\n if (typeof EdgeRuntime !== \"undefined\") return \"edge\";\n if (\n typeof process !== \"undefined\" &&\n typeof (process as { versions?: { node?: string } }).versions?.node === \"string\"\n ) {\n return \"node\";\n }\n if (typeof window !== \"undefined\" && typeof document !== \"undefined\") return \"browser\";\n return \"unknown\";\n}\n\nexport function runtimeTag(): string {\n const rt = detectRuntime();\n if (rt === \"node\") {\n const v = (process as { versions?: { node?: string } }).versions?.node;\n return v ? `node/${v}` : \"node\";\n }\n return rt;\n}\n","/**\n * HTTP request layer.\n *\n * Single entry point for every API call: handles auth headers, timeout via\n * AbortController, idempotency-key generation, error envelope parsing, and\n * RetryHint derivation. Resources call `request()` and parse `data` from the\n * envelope.\n */\n\nimport {\n AtribuApiError,\n AtribuOauthError,\n AtribuTransportError,\n type ApiErrorBody,\n type ApiErrorCode,\n type OauthErrorCode,\n} from \"./errors\";\nimport { deriveRetryHint } from \"./retry\";\nimport { SDK_VERSION } from \"./version\";\nimport { runtimeTag } from \"./runtime\";\nimport type { ResolvedConfig } from \"./config\";\n\nexport interface RequestOptions {\n method: \"GET\" | \"POST\" | \"PATCH\" | \"DELETE\" | \"PUT\";\n path: string;\n query?: Record<string, string | number | boolean | undefined | null>;\n body?: unknown;\n /** Form-urlencoded body (used by /oauth/token, /oauth/revoke). */\n form?: Record<string, string>;\n /** Override the Authorization header (used by /oauth/* with client-credentials). */\n authOverride?: string;\n idempotencyKey?: string;\n signal?: AbortSignal;\n /** When true, parse 200-body as RFC 6749/7009 OAuth response shape. */\n oauthErrorShape?: boolean;\n /** When true, return raw Response without JSON parse (used by 204 / RFC 7009 empty 200). */\n expectEmpty?: boolean;\n /** Extra headers to merge. */\n headers?: Record<string, string>;\n}\n\nexport interface ApiEnvelope<T> {\n data: T;\n meta?: Record<string, unknown>;\n}\n\nconst SDK_UA = `@atribu/node/${SDK_VERSION} (${runtimeTag()})`;\n\n/**\n * Minimum surface a transport needs to be usable by resources. Lets us\n * stack RetryingHttpClient on top of HttpClient without inheritance.\n */\nexport interface HttpClientLike {\n request<T>(opts: RequestOptions): Promise<T>;\n}\n\nexport class HttpClient implements HttpClientLike {\n constructor(private readonly cfg: ResolvedConfig) {}\n\n async request<T>(opts: RequestOptions): Promise<T> {\n const url = this.buildUrl(opts.path, opts.query);\n const headers = this.buildHeaders(opts);\n\n let body: BodyInit | undefined;\n if (opts.form) {\n body = new URLSearchParams(opts.form).toString();\n } else if (opts.body !== undefined && opts.method !== \"GET\") {\n body = JSON.stringify(opts.body);\n }\n\n const userSignal = opts.signal;\n const timeoutController = new AbortController();\n const timeout = setTimeout(() => timeoutController.abort(), this.cfg.timeoutMs);\n const signal = userSignal ? mergeSignals(userSignal, timeoutController.signal) : timeoutController.signal;\n\n let res: Response;\n try {\n res = await this.cfg.fetch(url, {\n method: opts.method,\n headers,\n body,\n signal,\n });\n } catch (err) {\n clearTimeout(timeout);\n if (err instanceof Error && err.name === \"AbortError\") {\n throw new AtribuTransportError(`Request aborted (timeout ${this.cfg.timeoutMs}ms)`, err);\n }\n throw new AtribuTransportError(\n err instanceof Error ? err.message : \"fetch failed\",\n err,\n );\n }\n clearTimeout(timeout);\n\n if (opts.expectEmpty && res.ok) {\n return undefined as T;\n }\n\n const requestId = res.headers.get(\"x-request-id\");\n const text = await res.text();\n const parsed = text ? safeJson(text) : null;\n\n if (!res.ok) {\n if (opts.oauthErrorShape) {\n const { code, description } = parseOauthError(parsed);\n throw new AtribuOauthError({ code, description, status: res.status });\n }\n const body = (parsed as { error?: ApiErrorBody } | null)?.error ?? null;\n const code: ApiErrorCode = body?.code ?? `http_${res.status}`;\n const message = body?.message ?? `HTTP ${res.status}`;\n const retry = deriveRetryHint({\n status: res.status,\n retryAfterHeader: res.headers.get(\"retry-after\"),\n errorCode: code,\n });\n throw new AtribuApiError({\n code,\n message,\n status: res.status,\n requestId: requestId ?? body?.request_id ?? null,\n retry,\n responseBody: parsed,\n });\n }\n\n return parsed as T;\n }\n\n private buildUrl(path: string, query?: RequestOptions[\"query\"]): string {\n const url = new URL(path.startsWith(\"/\") ? path : `/${path}`, this.cfg.baseUrl);\n if (query) {\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined || value === null) continue;\n url.searchParams.set(key, String(value));\n }\n }\n return url.toString();\n }\n\n private buildHeaders(opts: RequestOptions): Record<string, string> {\n const headers: Record<string, string> = {\n Accept: \"application/json\",\n \"User-Agent\": this.cfg.userAgentSuffix\n ? `${SDK_UA} ${this.cfg.userAgentSuffix}`\n : SDK_UA,\n };\n if (opts.form) {\n headers[\"Content-Type\"] = \"application/x-www-form-urlencoded\";\n } else if (opts.body !== undefined && opts.method !== \"GET\") {\n headers[\"Content-Type\"] = \"application/json\";\n }\n headers.Authorization = opts.authOverride ?? `Bearer ${this.cfg.apiKey}`;\n if (mutating(opts.method)) {\n headers[\"Idempotency-Key\"] = opts.idempotencyKey ?? this.cfg.generateIdempotencyKey();\n }\n if (opts.headers) {\n for (const [k, v] of Object.entries(opts.headers)) headers[k] = v;\n }\n return headers;\n }\n}\n\nfunction mutating(method: RequestOptions[\"method\"]): boolean {\n return method === \"POST\" || method === \"PATCH\" || method === \"PUT\" || method === \"DELETE\";\n}\n\nfunction safeJson(text: string): unknown {\n try {\n return JSON.parse(text);\n } catch {\n return text;\n }\n}\n\nfunction parseOauthError(parsed: unknown): { code: OauthErrorCode; description: string | null } {\n if (parsed && typeof parsed === \"object\") {\n const obj = parsed as { error?: unknown; error_description?: unknown };\n const code = typeof obj.error === \"string\" ? obj.error : \"server_error\";\n const description = typeof obj.error_description === \"string\" ? obj.error_description : null;\n return { code, description };\n }\n return { code: \"server_error\", description: null };\n}\n\nfunction mergeSignals(a: AbortSignal, b: AbortSignal): AbortSignal {\n if (typeof AbortSignal !== \"undefined\" && \"any\" in AbortSignal) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (AbortSignal as unknown as { any: (s: AbortSignal[]) => AbortSignal }).any([a, b]);\n }\n const c = new AbortController();\n const onA = (): void => c.abort(a.reason);\n const onB = (): void => c.abort(b.reason);\n if (a.aborted) c.abort(a.reason);\n else a.addEventListener(\"abort\", onA, { once: true });\n if (b.aborted) c.abort(b.reason);\n else b.addEventListener(\"abort\", onB, { once: true });\n return c.signal;\n}\n","import type { paths } from \"../__generated__/api\";\nimport type { HttpClientLike } from \"../http\";\n\ntype SendBody = NonNullable<\n paths[\"/api/v1/messages\"][\"post\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\n\ntype SendResponse =\n paths[\"/api/v1/messages\"][\"post\"][\"responses\"][200][\"content\"][\"application/json\"];\n\nexport type MessageSendInput = SendBody;\nexport type MessageContent = SendBody[\"content\"];\nexport type MessageSendResponse = SendResponse[\"data\"];\n\nexport interface SendOptions {\n idempotencyKey?: string;\n signal?: AbortSignal;\n}\n\nexport class MessagesResource {\n constructor(private readonly http: HttpClientLike) {}\n\n async send(input: MessageSendInput, opts: SendOptions = {}): Promise<MessageSendResponse> {\n const res = await this.http.request<SendResponse>({\n method: \"POST\",\n path: \"/api/v1/messages\",\n body: input,\n idempotencyKey: opts.idempotencyKey,\n signal: opts.signal,\n });\n return res.data;\n }\n}\n","import type { paths } from \"../__generated__/api\";\nimport type { HttpClientLike } from \"../http\";\n\ntype ReplyBody = NonNullable<\n paths[\"/api/v1/comments/{comment_id}/reply\"][\"post\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\n\ntype PrivateReplyBody = NonNullable<\n paths[\"/api/v1/comments/{comment_id}/private-reply\"][\"post\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\n\ntype ReplyResponse =\n paths[\"/api/v1/comments/{comment_id}/reply\"][\"post\"][\"responses\"][200][\"content\"][\"application/json\"];\n\nexport type CommentReplyInput = ReplyBody & { comment_id: string };\nexport type CommentPrivateReplyInput = PrivateReplyBody & { comment_id: string };\nexport type CommentReplyResponse = ReplyResponse[\"data\"];\n\nexport interface CommentReplyOptions {\n idempotencyKey?: string;\n signal?: AbortSignal;\n}\n\nexport class CommentsResource {\n constructor(private readonly http: HttpClientLike) {}\n\n async reply(\n input: CommentReplyInput,\n opts: CommentReplyOptions = {},\n ): Promise<CommentReplyResponse> {\n const { comment_id, ...body } = input;\n const res = await this.http.request<ReplyResponse>({\n method: \"POST\",\n path: `/api/v1/comments/${encodeURIComponent(comment_id)}/reply`,\n body,\n idempotencyKey: opts.idempotencyKey,\n signal: opts.signal,\n });\n return res.data;\n }\n\n async privateReply(\n input: CommentPrivateReplyInput,\n opts: CommentReplyOptions = {},\n ): Promise<CommentReplyResponse> {\n const { comment_id, ...body } = input;\n const res = await this.http.request<ReplyResponse>({\n method: \"POST\",\n path: `/api/v1/comments/${encodeURIComponent(comment_id)}/private-reply`,\n body,\n idempotencyKey: opts.idempotencyKey,\n signal: opts.signal,\n });\n return res.data;\n }\n}\n","import type { paths } from \"../__generated__/api\";\nimport type { HttpClientLike } from \"../http\";\n\ntype ListResponse =\n paths[\"/api/v1/webhooks/subscriptions\"][\"get\"][\"responses\"][200][\"content\"][\"application/json\"];\ntype CreateBody = NonNullable<\n paths[\"/api/v1/webhooks/subscriptions\"][\"post\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\ntype CreateResponse =\n paths[\"/api/v1/webhooks/subscriptions\"][\"post\"][\"responses\"][201][\"content\"][\"application/json\"];\ntype UpdateBody = NonNullable<\n paths[\"/api/v1/webhooks/subscriptions/{id}\"][\"patch\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\ntype UpdateResponse =\n paths[\"/api/v1/webhooks/subscriptions/{id}\"][\"patch\"][\"responses\"][200][\"content\"][\"application/json\"];\ntype RotateBody = NonNullable<\n NonNullable<\n paths[\"/api/v1/webhooks/subscriptions/{id}/rotate-secret\"][\"post\"][\"requestBody\"]\n >[\"content\"][\"application/json\"]\n>;\ntype RotateResponse =\n paths[\"/api/v1/webhooks/subscriptions/{id}/rotate-secret\"][\"post\"][\"responses\"][200][\"content\"][\"application/json\"];\ntype TestResponse =\n paths[\"/api/v1/webhooks/test/{id}\"][\"post\"][\"responses\"][200][\"content\"][\"application/json\"];\n\nexport type WebhookSubscription = ListResponse[\"data\"][number];\nexport type WebhookSubscriptionWithSecret = CreateResponse[\"data\"];\nexport type WebhookSubscriptionCreateInput = CreateBody;\nexport type WebhookSubscriptionUpdateInput = UpdateBody;\nexport type WebhookSubscriptionRotateOptions = RotateBody;\nexport type WebhookSubscriptionRotateResult = RotateResponse[\"data\"];\nexport type WebhookSubscriptionTestResult = TestResponse[\"data\"];\n\nexport interface MutationOptions {\n idempotencyKey?: string;\n signal?: AbortSignal;\n}\n\nexport class WebhookSubscriptionsResource {\n constructor(private readonly http: HttpClientLike) {}\n\n async list(opts: { signal?: AbortSignal } = {}): Promise<WebhookSubscription[]> {\n const res = await this.http.request<ListResponse>({\n method: \"GET\",\n path: \"/api/v1/webhooks/subscriptions\",\n signal: opts.signal,\n });\n return res.data;\n }\n\n async create(\n input: WebhookSubscriptionCreateInput,\n opts: MutationOptions = {},\n ): Promise<WebhookSubscriptionWithSecret> {\n const res = await this.http.request<CreateResponse>({\n method: \"POST\",\n path: \"/api/v1/webhooks/subscriptions\",\n body: input,\n idempotencyKey: opts.idempotencyKey,\n signal: opts.signal,\n });\n return res.data;\n }\n\n async update(\n id: string,\n input: WebhookSubscriptionUpdateInput,\n opts: MutationOptions = {},\n ): Promise<WebhookSubscription> {\n const res = await this.http.request<UpdateResponse>({\n method: \"PATCH\",\n path: `/api/v1/webhooks/subscriptions/${encodeURIComponent(id)}`,\n body: input,\n idempotencyKey: opts.idempotencyKey,\n signal: opts.signal,\n });\n return res.data;\n }\n\n async delete(id: string, opts: MutationOptions = {}): Promise<void> {\n await this.http.request<void>({\n method: \"DELETE\",\n path: `/api/v1/webhooks/subscriptions/${encodeURIComponent(id)}`,\n idempotencyKey: opts.idempotencyKey,\n signal: opts.signal,\n expectEmpty: true,\n });\n }\n\n async rotateSecret(\n id: string,\n options: WebhookSubscriptionRotateOptions = {},\n opts: MutationOptions = {},\n ): Promise<WebhookSubscriptionRotateResult> {\n const res = await this.http.request<RotateResponse>({\n method: \"POST\",\n path: `/api/v1/webhooks/subscriptions/${encodeURIComponent(id)}/rotate-secret`,\n body: options,\n idempotencyKey: opts.idempotencyKey,\n signal: opts.signal,\n });\n return res.data;\n }\n\n async test(\n id: string,\n opts: MutationOptions = {},\n ): Promise<WebhookSubscriptionTestResult> {\n const res = await this.http.request<TestResponse>({\n method: \"POST\",\n path: `/api/v1/webhooks/test/${encodeURIComponent(id)}`,\n idempotencyKey: opts.idempotencyKey,\n signal: opts.signal,\n });\n return res.data;\n }\n}\n","import type { paths } from \"../__generated__/api\";\nimport type { HttpClientLike } from \"../http\";\n\ntype ReplayResponse =\n paths[\"/api/v1/webhooks/deliveries/{id}/replay\"][\"post\"][\"responses\"][200][\"content\"][\"application/json\"];\n\nexport type WebhookDeliveryReplayResult = ReplayResponse[\"data\"];\n\nexport interface ReplayOptions {\n idempotencyKey?: string;\n signal?: AbortSignal;\n}\n\nexport class WebhookDeliveriesResource {\n constructor(private readonly http: HttpClientLike) {}\n\n async replay(id: string, opts: ReplayOptions = {}): Promise<WebhookDeliveryReplayResult> {\n const res = await this.http.request<ReplayResponse>({\n method: \"POST\",\n path: `/api/v1/webhooks/deliveries/${encodeURIComponent(id)}/replay`,\n idempotencyKey: opts.idempotencyKey,\n signal: opts.signal,\n });\n return res.data;\n }\n}\n","/**\n * Opt-in retry layer.\n *\n * Why opt-in: hiding retries inside the SDK by default obscures backpressure\n * signals and amplifies load on a failing server. Consumers that want them\n * call `.withRetry({...})`; others write their own retry logic against the\n * typed `retry` hint on AtribuApiError.\n *\n * What gets retried:\n * - `AtribuApiError` with `retry.action === \"retry\"` (5xx, 408)\n * - `AtribuApiError` with `retry.action === \"retry_after\"` (429, 503 w/\n * Retry-After) — honors retryAfterMs\n * - `AtribuTransportError` (network glitches, ECONNRESET, timeouts)\n *\n * What does NOT retry:\n * - `AtribuApiError` with `retry.action === \"do_not_retry\"` (403)\n * - `AtribuApiError` with `retry.action === \"fix_and_retry\"` (422 etc — the\n * caller's input is wrong; retrying with the same body won't help)\n * - `AtribuApiError` with `retry.action === \"refresh_token\"` (401 — needs\n * credential refresh, not a retry)\n * - `AtribuConfigError`, `AtribuWebhookError`, anything else\n */\n\nimport {\n AtribuApiError,\n AtribuTransportError,\n type AtribuError,\n} from \"./errors\";\nimport type { HttpClientLike, RequestOptions } from \"./http\";\n\nexport type BackoffStrategy = \"exponential\" | \"fixed\" | \"none\";\n\nexport interface RetryOptions {\n /**\n * Max attempts including the initial call. `maxAttempts: 3` = initial + 2\n * retries. Must be ≥ 1. Default 3.\n */\n maxAttempts?: number;\n /**\n * Backoff strategy between retries. \"exponential\" = `baseDelayMs * 2^n`\n * (capped by `maxDelayMs`). \"fixed\" = `baseDelayMs`. \"none\" = no delay.\n * Default \"exponential\".\n */\n backoff?: BackoffStrategy;\n /** Base delay between retries in ms. Default 500. */\n baseDelayMs?: number;\n /** Cap on the delay between retries. Default 30000 (30s). */\n maxDelayMs?: number;\n /**\n * Jitter factor 0..1. Multiplies the computed delay by `1 + random*jitter`\n * (jitter=0 means deterministic). Default 0.3.\n */\n jitter?: number;\n /** Inject for tests. Default `(ms) => new Promise(r => setTimeout(r, ms))`. */\n sleep?: (ms: number) => Promise<void>;\n /** Inject for jitter tests. Default Math.random. */\n random?: () => number;\n}\n\ninterface ResolvedRetry {\n maxAttempts: number;\n backoff: BackoffStrategy;\n baseDelayMs: number;\n maxDelayMs: number;\n jitter: number;\n sleep: (ms: number) => Promise<void>;\n random: () => number;\n}\n\nfunction resolveRetry(o: RetryOptions): ResolvedRetry {\n return {\n maxAttempts: Math.max(1, o.maxAttempts ?? 3),\n backoff: o.backoff ?? \"exponential\",\n baseDelayMs: Math.max(0, o.baseDelayMs ?? 500),\n maxDelayMs: Math.max(0, o.maxDelayMs ?? 30_000),\n jitter: Math.min(1, Math.max(0, o.jitter ?? 0.3)),\n sleep: o.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms))),\n random: o.random ?? Math.random,\n };\n}\n\nexport class RetryingHttpClient implements HttpClientLike {\n private readonly r: ResolvedRetry;\n constructor(private readonly base: HttpClientLike, options: RetryOptions) {\n this.r = resolveRetry(options);\n }\n\n async request<T>(opts: RequestOptions): Promise<T> {\n let lastErr: unknown;\n for (let attempt = 1; attempt <= this.r.maxAttempts; attempt++) {\n try {\n return await this.base.request<T>(opts);\n } catch (err) {\n lastErr = err;\n if (attempt >= this.r.maxAttempts) throw err;\n const delay = this.computeDelay(err, attempt);\n if (delay === null) throw err; // non-retryable\n if (delay > 0) await this.r.sleep(delay);\n }\n }\n throw lastErr; // unreachable\n }\n\n /**\n * Returns the delay in ms before the next attempt, or null if the error\n * is non-retryable (caller should throw immediately).\n */\n private computeDelay(err: unknown, attempt: number): number | null {\n // Transport errors (network glitches, timeouts) → backoff-based retry\n if (err instanceof AtribuTransportError) {\n return this.applyJitter(this.backoffDelay(attempt));\n }\n if (err instanceof AtribuApiError) {\n const action = err.retry.action;\n if (action === \"retry\") return this.applyJitter(this.backoffDelay(attempt));\n if (action === \"retry_after\") {\n // Honor the server's instruction exactly (no jitter on this one).\n const capped = Math.min(err.retry.retryAfterMs, this.r.maxDelayMs);\n return Math.max(0, capped);\n }\n // do_not_retry / fix_and_retry / refresh_token — caller must handle\n return null;\n }\n return null;\n }\n\n private backoffDelay(attempt: number): number {\n if (this.r.backoff === \"none\") return 0;\n if (this.r.backoff === \"fixed\") return this.r.baseDelayMs;\n // exponential: base * 2^(attempt-1), capped at maxDelayMs\n const raw = this.r.baseDelayMs * Math.pow(2, attempt - 1);\n return Math.min(raw, this.r.maxDelayMs);\n }\n\n private applyJitter(delay: number): number {\n if (this.r.jitter === 0) return delay;\n return Math.round(delay * (1 + this.r.random() * this.r.jitter));\n }\n}\n\nexport function isRetryableError(err: unknown): err is AtribuError {\n if (err instanceof AtribuTransportError) return true;\n if (err instanceof AtribuApiError) {\n return err.retry.action === \"retry\" || err.retry.action === \"retry_after\";\n }\n return false;\n}\n","import { resolveConfig, type AtribuClientConfig } from \"./config\";\nimport { HttpClient, type HttpClientLike } from \"./http\";\nimport { MessagesResource } from \"./resources/messages\";\nimport { CommentsResource } from \"./resources/comments\";\nimport { WebhookSubscriptionsResource } from \"./resources/webhook-subscriptions\";\nimport { WebhookDeliveriesResource } from \"./resources/webhook-deliveries\";\nimport { RetryingHttpClient, type RetryOptions } from \"./retry-wrapper\";\n\ninterface ResourceBundle {\n messages: MessagesResource;\n comments: CommentsResource;\n webhooks: {\n subscriptions: WebhookSubscriptionsResource;\n deliveries: WebhookDeliveriesResource;\n };\n}\n\nfunction buildResources(http: HttpClientLike): ResourceBundle {\n return {\n messages: new MessagesResource(http),\n comments: new CommentsResource(http),\n webhooks: {\n subscriptions: new WebhookSubscriptionsResource(http),\n deliveries: new WebhookDeliveriesResource(http),\n },\n };\n}\n\nexport class AtribuClient {\n readonly messages: MessagesResource;\n readonly comments: CommentsResource;\n readonly webhooks: ResourceBundle[\"webhooks\"];\n\n /** @internal — exposed for `withRetry` chaining; do not depend on this. */\n protected readonly _http: HttpClientLike;\n\n constructor(config: AtribuClientConfig) {\n this._http = new HttpClient(resolveConfig(config));\n const r = buildResources(this._http);\n this.messages = r.messages;\n this.comments = r.comments;\n this.webhooks = r.webhooks;\n }\n\n /**\n * Returns a new AtribuClient that retries on transient errors. The\n * original client is not mutated. The wrapper respects the typed\n * `retry` hint on AtribuApiError — `do_not_retry`, `fix_and_retry`,\n * and `refresh_token` are NOT retried (those need caller action, not\n * a repeat call).\n *\n * @example\n * const client = new AtribuClient({...}).withRetry({\n * maxAttempts: 3,\n * backoff: \"exponential\",\n * baseDelayMs: 500,\n * });\n * await client.messages.send({...});\n */\n withRetry(options: RetryOptions): AtribuClient {\n const wrapped = new RetryingHttpClient(this._http, options);\n return AtribuClient._fromHttp(wrapped);\n }\n\n private static _fromHttp(http: HttpClientLike): AtribuClient {\n const proto = Object.create(AtribuClient.prototype) as object;\n const r = buildResources(http);\n Object.assign(proto, {\n _http: http,\n messages: r.messages,\n comments: r.comments,\n webhooks: r.webhooks,\n });\n return proto as AtribuClient;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/errors.ts","../src/config.ts","../src/retry.ts","../src/version.ts","../src/runtime.ts","../src/http.ts","../src/resources/messages.ts","../src/resources/comments.ts","../src/resources/connections.ts","../src/resources/webhook-subscriptions.ts","../src/resources/webhook-deliveries.ts","../src/resources/whatsapp/templates.ts","../src/resources/whatsapp/broadcasts.ts","../src/resources/whatsapp/index.ts","../src/resources/instagram/triggers.ts","../src/resources/instagram/index.ts","../src/retry-wrapper.ts","../src/client.ts"],"names":["code","body"],"mappings":";;;AAiCO,IAAM,WAAA,GAAN,cAA0B,KAAA,CAAM;AAAA,EACrC,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,OAAO,GAAA,CAAA,MAAA,CAAW,IAAA;AAAA,EACzB;AACF;AAEO,IAAM,iBAAA,GAAN,cAAgC,WAAA,CAAY;AAAC;AAE7C,IAAM,oBAAA,GAAN,cAAmC,WAAA,CAAY;AAAA,EAC3C,KAAA;AAAA,EACT,WAAA,CAAY,SAAiB,KAAA,EAAgB;AAC3C,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,KAAA,GAAQ,KAAA;AAAA,EACf;AACF;AASO,IAAM,cAAA,GAAN,cAA6B,WAAA,CAAY;AAAA,EACrC,IAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA,KAAA;AAAA,EACA,YAAA;AAAA,EAET,YAAY,IAAA,EAOT;AACD,IAAA,KAAA,CAAM,IAAI,IAAA,CAAK,IAAI,CAAA,EAAA,EAAK,IAAA,CAAK,OAAO,CAAA,CAAE,CAAA;AACtC,IAAA,IAAA,CAAK,OAAO,IAAA,CAAK,IAAA;AACjB,IAAA,IAAA,CAAK,SAAS,IAAA,CAAK,MAAA;AACnB,IAAA,IAAA,CAAK,YAAY,IAAA,CAAK,SAAA;AACtB,IAAA,IAAA,CAAK,QAAQ,IAAA,CAAK,KAAA;AAClB,IAAA,IAAA,CAAK,eAAe,IAAA,CAAK,YAAA;AAAA,EAC3B;AAAA,EAEA,WAAA,GAAuB;AACrB,IAAA,OAAO,KAAK,KAAA,CAAM,MAAA,KAAW,OAAA,IAAW,IAAA,CAAK,MAAM,MAAA,KAAW,aAAA;AAAA,E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AAM,CAAA,GAAI,cAAA,CAAe,IAAA,CAAK,KAAK,CAAA;AACnC,IAAA,IAAA,CAAK,WAAW,CAAA,CAAE,QAAA;AAClB,IAAA,IAAA,CAAK,WAAW,CAAA,CAAE,QAAA;AAClB,IAAA,IAAA,CAAK,cAAc,CAAA,CAAE,WAAA;AACrB,IAAA,IAAA,CAAK,WAAW,CAAA,CAAE,QAAA;AAClB,IAAA,IAAA,CAAK,WAAW,CAAA,CAAE,QAAA;AAClB,IAAA,IAAA,CAAK,YAAY,CAAA,CAAE,SAAA;AAAA,EACrB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBA,UAAU,OAAA,EAAqC;AAC7C,IAAA,MAAM,OAAA,GAAU,IAAI,kBAAA,CAAmB,IAAA,CAAK,OAAO,OAAO,CAAA;AAC1D,IAAA,OAAO,aAAA,CAAa,UAAU,OAAO,CAAA;AAAA,EACvC;AAAA,EAEA,OAAe,UAAU,IAAA,EAAoC;AAC3D,IAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,MAAA,CAAO,aAAA,CAAa,SAAS,CAAA;AAClD,IAAA,MAAM,CAAA,GAAI,eAAe,IAAI,CAAA;AAC7B,IAAA,MAAA,CAAO,OAAO,KAAA,EAAO;AAAA,MACnB,KAAA,EAAO,IAAA;AAAA,MACP,UAAU,CAAA,CAAE,QAAA;AAAA,MACZ,UAAU,CAAA,CAAE,QAAA;AAAA,MACZ,aAAa,CAAA,CAAE,WAAA;AAAA,MACf,UAAU,CAAA,CAAE,QAAA;AAAA,MACZ,UAAU,CAAA,CAAE,QAAA;AAAA,MACZ,WAAW,CAAA,CAAE;AAAA,KACd,CAAA;AACD,IAAA,OAAO,KAAA;AAAA,EACT;AACF","file":"index.cjs","sourcesContent":["/**\n * Atribu error class hierarchy.\n *\n * Why typed errors: consumers need to branch on auth-failure vs rate-limit vs\n * server-error vs validation-error to decide whether to retry, refresh\n * credentials, or surface to the user. A single `Error` with a status code\n * forces every consumer to write the same `if (err.status === 401)` ladder.\n *\n * Why no automatic retries: the SDK derives a `retry` hint from status +\n * Retry-After + error code, but consumers' queue/job systems decide whether\n * to act on it. Auto-retry inside the SDK hides backpressure signals and\n * makes error budgets opaque.\n */\n\nimport type { RetryHint } from \"./retry\";\n\nexport type ApiErrorCode =\n | \"unauthorized\"\n | \"forbidden\"\n | \"insufficient_scope\"\n | \"not_found\"\n | \"invalid_parameter\"\n | \"invalid_request\"\n | \"validation_error\"\n | \"invalid_content\"\n | \"invalid_date_range\"\n | \"rate_limit_exceeded\"\n | \"connection_not_ready\"\n | \"provider_error\"\n | \"service_unavailable\"\n | \"internal_error\"\n | string;\n\nexport class AtribuError extends Error {\n constructor(message: string) {\n super(message);\n this.name = new.target.name;\n }\n}\n\nexport class AtribuConfigError extends AtribuError {}\n\nexport class AtribuTransportError extends AtribuError {\n readonly cause: unknown;\n constructor(message: string, cause: unknown) {\n super(message);\n this.cause = cause;\n }\n}\n\nexport interface ApiErrorBody {\n code: ApiErrorCode;\n message: string;\n status: number;\n request_id?: string;\n}\n\nexport class AtribuApiError extends AtribuError {\n readonly code: ApiErrorCode;\n readonly status: number;\n readonly requestId: string | null;\n readonly retry: RetryHint;\n readonly responseBody: unknown;\n\n constructor(args: {\n code: ApiErrorCode;\n message: string;\n status: number;\n requestId: string | null;\n retry: RetryHint;\n responseBody: unknown;\n }) {\n super(`[${args.code}] ${args.message}`);\n this.code = args.code;\n this.status = args.status;\n this.requestId = args.requestId;\n this.retry = args.retry;\n this.responseBody = args.responseBody;\n }\n\n isRetryable(): boolean {\n return this.retry.action === \"retry\" || this.retry.action === \"retry_after\";\n }\n isAuthFailure(): boolean {\n return this.status === 401 || this.code === \"unauthorized\";\n }\n isRateLimit(): boolean {\n return this.status === 429 || this.code === \"rate_limit_exceeded\";\n }\n}\n\nexport type OauthErrorCode =\n | \"invalid_request\"\n | \"invalid_client\"\n | \"invalid_grant\"\n | \"unauthorized_client\"\n | \"unsupported_grant_type\"\n | \"invalid_scope\"\n | \"server_error\"\n | \"unsupported_token_type\"\n | string;\n\nexport class AtribuOauthError extends AtribuError {\n readonly code: OauthErrorCode;\n readonly status: number;\n readonly description: string | null;\n\n constructor(args: { code: OauthErrorCode; description: string | null; status: number }) {\n super(`[oauth/${args.code}] ${args.description ?? args.code}`);\n this.code = args.code;\n this.status = args.status;\n this.description = args.description;\n }\n}\n\nexport type WebhookErrorCode =\n | \"missing_signature\"\n | \"malformed_header\"\n | \"expired_timestamp\"\n | \"invalid_signature\";\n\nexport class AtribuWebhookError extends AtribuError {\n readonly code: WebhookErrorCode;\n constructor(code: WebhookErrorCode, message: string) {\n super(message);\n this.code = code;\n }\n}\n","import { AtribuConfigError } from \"./errors\";\n\nexport const DEFAULT_BASE_URL = \"https://www.atribu.app\";\nexport const DEFAULT_TIMEOUT_MS = 30_000;\n\nexport interface AtribuClientConfig {\n apiKey: string;\n baseUrl?: string;\n fetch?: typeof fetch;\n timeoutMs?: number;\n userAgent?: string;\n defaultIdempotencyKeyGenerator?: () => string;\n}\n\nexport interface ResolvedConfig {\n apiKey: string;\n baseUrl: string;\n fetch: typeof fetch;\n timeoutMs: number;\n userAgentSuffix: string | null;\n generateIdempotencyKey: () => string;\n}\n\nexport function resolveConfig(config: AtribuClientConfig): ResolvedConfig {\n if (!config.apiKey || typeof config.apiKey !== \"string\") {\n throw new AtribuConfigError(\"apiKey is required\");\n }\n const fetchImpl = config.fetch ?? globalThis.fetch;\n if (typeof fetchImpl !== \"function\") {\n throw new AtribuConfigError(\n \"globalThis.fetch is not available; pass a `fetch` implementation in config\",\n );\n }\n const baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, \"\");\n return {\n apiKey: config.apiKey,\n baseUrl,\n fetch: fetchImpl,\n timeoutMs: config.timeoutMs ?? DEFAULT_TIMEOUT_MS,\n userAgentSuffix: config.userAgent ?? null,\n generateIdempotencyKey: config.defaultIdempotencyKeyGenerator ?? defaultUuid,\n };\n}\n\nfunction defaultUuid(): string {\n if (typeof crypto !== \"undefined\" && typeof crypto.randomUUID === \"function\") {\n return crypto.randomUUID();\n }\n // Fallback for older runtimes — a v4-ish UUID via Math.random. Not\n // cryptographically strong; idempotency keys don't need to be.\n const hex = \"0123456789abcdef\";\n let out = \"\";\n for (let i = 0; i < 32; i++) {\n const c = Math.floor(Math.random() * 16);\n out += hex[i === 12 ? 4 : i === 16 ? (c & 0x3) | 0x8 : c];\n if (i === 7 || i === 11 || i === 15 || i === 19) out += \"-\";\n }\n return out;\n}\n","/**\n * Retry hints derived from HTTP status + headers.\n *\n * The SDK never retries automatically. It derives a hint and surfaces it on\n * AtribuApiError.retry so consumers' queue systems can decide. Hiding retry\n * logic in the SDK hides backpressure signals.\n */\n\nexport type RetryHint =\n | { action: \"retry\" }\n | { action: \"retry_after\"; retryAfterMs: number }\n | { action: \"refresh_token\" }\n | { action: \"fix_and_retry\" }\n | { action: \"do_not_retry\" };\n\nexport interface DeriveRetryInput {\n status: number;\n retryAfterHeader: string | null;\n errorCode: string | null;\n}\n\nexport function deriveRetryHint(input: DeriveRetryInput): RetryHint {\n const retryAfterMs = parseRetryAfter(input.retryAfterHeader);\n if (retryAfterMs !== null) {\n return { action: \"retry_after\", retryAfterMs };\n }\n if (input.status === 401) return { action: \"refresh_token\" };\n if (input.status === 403 || input.errorCode === \"forbidden\" || input.errorCode === \"insufficient_scope\") {\n return { action: \"do_not_retry\" };\n }\n if (input.status === 408) return { action: \"retry\" };\n if (input.status === 409) return { action: \"fix_and_retry\" };\n if (input.status === 422 || input.errorCode === \"validation_error\" || input.errorCode === \"invalid_content\") {\n return { action: \"fix_and_retry\" };\n }\n if (input.status === 429 || input.errorCode === \"rate_limit_exceeded\") {\n return { action: \"retry_after\", retryAfterMs: 1000 };\n }\n if (input.status >= 500) return { action: \"retry\" };\n if (input.status >= 400) return { action: \"fix_and_retry\" };\n return { action: \"do_not_retry\" };\n}\n\nfunction parseRetryAfter(header: string | null): number | null {\n if (!header) return null;\n const asInt = Number(header);\n if (Number.isFinite(asInt) && asInt >= 0) return Math.round(asInt * 1000);\n const asDate = Date.parse(header);\n if (Number.isFinite(asDate)) return Math.max(0, asDate - Date.now());\n return null;\n}\n","export const SDK_VERSION = \"0.1.4\";\n","export type Runtime = \"node\" | \"bun\" | \"deno\" | \"edge\" | \"browser\" | \"unknown\";\n\ndeclare const Deno: unknown;\ndeclare const Bun: unknown;\ndeclare const EdgeRuntime: unknown;\n\nexport function detectRuntime(): Runtime {\n if (typeof Deno !== \"undefined\") return \"deno\";\n if (typeof Bun !== \"undefined\") return \"bun\";\n if (typeof EdgeRuntime !== \"undefined\") return \"edge\";\n if (\n typeof process !== \"undefined\" &&\n typeof (process as { versions?: { node?: string } }).versions?.node === \"string\"\n ) {\n return \"node\";\n }\n if (typeof window !== \"undefined\" && typeof document !== \"undefined\") return \"browser\";\n return \"unknown\";\n}\n\nexport function runtimeTag(): string {\n const rt = detectRuntime();\n if (rt === \"node\") {\n const v = (process as { versions?: { node?: string } }).versions?.node;\n return v ? `node/${v}` : \"node\";\n }\n return rt;\n}\n","/**\n * HTTP request layer.\n *\n * Single entry point for every API call: handles auth headers, timeout via\n * AbortController, idempotency-key generation, error envelope parsing, and\n * RetryHint derivation. Resources call `request()` and parse `data` from the\n * envelope.\n */\n\nimport {\n AtribuApiError,\n AtribuOauthError,\n AtribuTransportError,\n type ApiErrorBody,\n type ApiErrorCode,\n type OauthErrorCode,\n} from \"./errors\";\nimport { deriveRetryHint } from \"./retry\";\nimport { SDK_VERSION } from \"./version\";\nimport { runtimeTag } from \"./runtime\";\nimport type { ResolvedConfig } from \"./config\";\n\nexport interface RequestOptions {\n method: \"GET\" | \"POST\" | \"PATCH\" | \"DELETE\" | \"PUT\";\n path: string;\n query?: Record<string, string | number | boolean | undefined | null>;\n body?: unknown;\n /** Form-urlencoded body (used by /oauth/token, /oauth/revoke). */\n form?: Record<string, string>;\n /** Override the Authorization header (used by /oauth/* with client-credentials). */\n authOverride?: string;\n idempotencyKey?: string;\n signal?: AbortSignal;\n /** When true, parse 200-body as RFC 6749/7009 OAuth response shape. */\n oauthErrorShape?: boolean;\n /** When true, return raw Response without JSON parse (used by 204 / RFC 7009 empty 200). */\n expectEmpty?: boolean;\n /** Extra headers to merge. */\n headers?: Record<string, string>;\n}\n\nexport interface ApiEnvelope<T> {\n data: T;\n meta?: Record<string, unknown>;\n}\n\nconst SDK_UA = `@atribu/node/${SDK_VERSION} (${runtimeTag()})`;\n\n/**\n * Minimum surface a transport needs to be usable by resources. Lets us\n * stack RetryingHttpClient on top of HttpClient without inheritance.\n */\nexport interface HttpClientLike {\n request<T>(opts: RequestOptions): Promise<T>;\n}\n\nexport class HttpClient implements HttpClientLike {\n constructor(private readonly cfg: ResolvedConfig) {}\n\n async request<T>(opts: RequestOptions): Promise<T> {\n const url = this.buildUrl(opts.path, opts.query);\n const headers = this.buildHeaders(opts);\n\n let body: BodyInit | undefined;\n if (opts.form) {\n body = new URLSearchParams(opts.form).toString();\n } else if (opts.body !== undefined && opts.method !== \"GET\") {\n body = JSON.stringify(opts.body);\n }\n\n const userSignal = opts.signal;\n const timeoutController = new AbortController();\n const timeout = setTimeout(() => timeoutController.abort(), this.cfg.timeoutMs);\n const signal = userSignal ? mergeSignals(userSignal, timeoutController.signal) : timeoutController.signal;\n\n let res: Response;\n try {\n res = await this.cfg.fetch(url, {\n method: opts.method,\n headers,\n body,\n signal,\n });\n } catch (err) {\n clearTimeout(timeout);\n if (err instanceof Error && err.name === \"AbortError\") {\n throw new AtribuTransportError(`Request aborted (timeout ${this.cfg.timeoutMs}ms)`, err);\n }\n throw new AtribuTransportError(\n err instanceof Error ? err.message : \"fetch failed\",\n err,\n );\n }\n clearTimeout(timeout);\n\n if (opts.expectEmpty && res.ok) {\n return undefined as T;\n }\n\n const requestId = res.headers.get(\"x-request-id\");\n const text = await res.text();\n const parsed = text ? safeJson(text) : null;\n\n if (!res.ok) {\n if (opts.oauthErrorShape) {\n const { code, description } = parseOauthError(parsed);\n throw new AtribuOauthError({ code, description, status: res.status });\n }\n const body = (parsed as { error?: ApiErrorBody } | null)?.error ?? null;\n const code: ApiErrorCode = body?.code ?? `http_${res.status}`;\n const message = body?.message ?? `HTTP ${res.status}`;\n const retry = deriveRetryHint({\n status: res.status,\n retryAfterHeader: res.headers.get(\"retry-after\"),\n errorCode: code,\n });\n throw new AtribuApiError({\n code,\n message,\n status: res.status,\n requestId: requestId ?? body?.request_id ?? null,\n retry,\n responseBody: parsed,\n });\n }\n\n return parsed as T;\n }\n\n private buildUrl(path: string, query?: RequestOptions[\"query\"]): string {\n const url = new URL(path.startsWith(\"/\") ? path : `/${path}`, this.cfg.baseUrl);\n if (query) {\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined || value === null) continue;\n url.searchParams.set(key, String(value));\n }\n }\n return url.toString();\n }\n\n private buildHeaders(opts: RequestOptions): Record<string, string> {\n const headers: Record<string, string> = {\n Accept: \"application/json\",\n \"User-Agent\": this.cfg.userAgentSuffix\n ? `${SDK_UA} ${this.cfg.userAgentSuffix}`\n : SDK_UA,\n };\n if (opts.form) {\n headers[\"Content-Type\"] = \"application/x-www-form-urlencoded\";\n } else if (opts.body !== undefined && opts.method !== \"GET\") {\n headers[\"Content-Type\"] = \"application/json\";\n }\n headers.Authorization = opts.authOverride ?? `Bearer ${this.cfg.apiKey}`;\n if (mutating(opts.method)) {\n headers[\"Idempotency-Key\"] = opts.idempotencyKey ?? this.cfg.generateIdempotencyKey();\n }\n if (opts.headers) {\n for (const [k, v] of Object.entries(opts.headers)) headers[k] = v;\n }\n return headers;\n }\n}\n\nfunction mutating(method: RequestOptions[\"method\"]): boolean {\n return method === \"POST\" || method === \"PATCH\" || method === \"PUT\" || method === \"DELETE\";\n}\n\nfunction safeJson(text: string): unknown {\n try {\n return JSON.parse(text);\n } catch {\n return text;\n }\n}\n\nfunction parseOauthError(parsed: unknown): { code: OauthErrorCode; description: string | null } {\n if (parsed && typeof parsed === \"object\") {\n const obj = parsed as { error?: unknown; error_description?: unknown };\n const code = typeof obj.error === \"string\" ? obj.error : \"server_error\";\n const description = typeof obj.error_description === \"string\" ? obj.error_description : null;\n return { code, description };\n }\n return { code: \"server_error\", description: null };\n}\n\nfunction mergeSignals(a: AbortSignal, b: AbortSignal): AbortSignal {\n if (typeof AbortSignal !== \"undefined\" && \"any\" in AbortSignal) {\n \n return (AbortSignal as unknown as { any: (s: AbortSignal[]) => AbortSignal }).any([a, b]);\n }\n const c = new AbortController();\n const onA = (): void => c.abort(a.reason);\n const onB = (): void => c.abort(b.reason);\n if (a.aborted) c.abort(a.reason);\n else a.addEventListener(\"abort\", onA, { once: true });\n if (b.aborted) c.abort(b.reason);\n else b.addEventListener(\"abort\", onB, { once: true });\n return c.signal;\n}\n","import type { paths } from \"../__generated__/api\";\nimport type { HttpClientLike } from \"../http\";\n\ntype SendBody = NonNullable<\n paths[\"/api/v1/messages\"][\"post\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\n\ntype SendResponse =\n paths[\"/api/v1/messages\"][\"post\"][\"responses\"][200][\"content\"][\"application/json\"];\n\nexport type MessageSendInput = SendBody;\nexport type MessageContent = SendBody[\"content\"];\nexport type MessageSendResponse = SendResponse[\"data\"];\n\nexport interface SendOptions {\n idempotencyKey?: string;\n signal?: AbortSignal;\n}\n\nexport class MessagesResource {\n constructor(private readonly http: HttpClientLike) {}\n\n async send(input: MessageSendInput, opts: SendOptions = {}): Promise<MessageSendResponse> {\n const res = await this.http.request<SendResponse>({\n method: \"POST\",\n path: \"/api/v1/messages\",\n body: input,\n idempotencyKey: opts.idempotencyKey,\n signal: opts.signal,\n });\n return res.data;\n }\n}\n","import type { paths } from \"../__generated__/api\";\nimport type { HttpClientLike } from \"../http\";\n\ntype ReplyBody = NonNullable<\n paths[\"/api/v1/comments/{comment_id}/reply\"][\"post\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\n\ntype PrivateReplyBody = NonNullable<\n paths[\"/api/v1/comments/{comment_id}/private-reply\"][\"post\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\n\ntype ReplyResponse =\n paths[\"/api/v1/comments/{comment_id}/reply\"][\"post\"][\"responses\"][200][\"content\"][\"application/json\"];\n\nexport type CommentReplyInput = ReplyBody & { comment_id: string };\nexport type CommentPrivateReplyInput = PrivateReplyBody & { comment_id: string };\nexport type CommentReplyResponse = ReplyResponse[\"data\"];\n\nexport interface CommentReplyOptions {\n idempotencyKey?: string;\n signal?: AbortSignal;\n}\n\nexport class CommentsResource {\n constructor(private readonly http: HttpClientLike) {}\n\n async reply(\n input: CommentReplyInput,\n opts: CommentReplyOptions = {},\n ): Promise<CommentReplyResponse> {\n const { comment_id, ...body } = input;\n const res = await this.http.request<ReplyResponse>({\n method: \"POST\",\n path: `/api/v1/comments/${encodeURIComponent(comment_id)}/reply`,\n body,\n idempotencyKey: opts.idempotencyKey,\n signal: opts.signal,\n });\n return res.data;\n }\n\n async privateReply(\n input: CommentPrivateReplyInput,\n opts: CommentReplyOptions = {},\n ): Promise<CommentReplyResponse> {\n const { comment_id, ...body } = input;\n const res = await this.http.request<ReplyResponse>({\n method: \"POST\",\n path: `/api/v1/comments/${encodeURIComponent(comment_id)}/private-reply`,\n body,\n idempotencyKey: opts.idempotencyKey,\n signal: opts.signal,\n });\n return res.data;\n }\n}\n","import type { paths } from \"../__generated__/api\";\nimport type { HttpClientLike } from \"../http\";\n\ntype ListResponse =\n paths[\"/api/v1/connections\"][\"get\"][\"responses\"][200][\"content\"][\"application/json\"];\ntype GetResponse =\n paths[\"/api/v1/connections/{id}\"][\"get\"][\"responses\"][200][\"content\"][\"application/json\"];\n\nexport type Connection = ListResponse[\"data\"][number];\n\nexport interface ListOptions {\n channel?: \"whatsapp\" | \"instagram\";\n signal?: AbortSignal;\n}\n\nexport interface MutationOptions {\n idempotencyKey?: string;\n signal?: AbortSignal;\n}\n\nexport class ConnectionsResource {\n constructor(private readonly http: HttpClientLike) {}\n\n async list(opts: ListOptions = {}): Promise<Connection[]> {\n const qs = opts.channel ? `?channel=${encodeURIComponent(opts.channel)}` : \"\";\n const res = await this.http.request<ListResponse>({\n method: \"GET\",\n path: `/api/v1/connections${qs}`,\n signal: opts.signal,\n });\n return res.data;\n }\n\n async get(id: string, opts: { signal?: AbortSignal } = {}): Promise<Connection> {\n const res = await this.http.request<GetResponse>({\n method: \"GET\",\n path: `/api/v1/connections/${encodeURIComponent(id)}`,\n signal: opts.signal,\n });\n return res.data;\n }\n\n /**\n * Revoke this OAuth app's authorization for the connection. Does NOT\n * disconnect the underlying data_connection (other consumers + the\n * Atribu UI still see it). Direct admin keys reject this call with 400.\n */\n async revoke(id: string, opts: MutationOptions = {}): Promise<void> {\n await this.http.request<void>({\n method: \"DELETE\",\n path: `/api/v1/connections/${encodeURIComponent(id)}`,\n idempotencyKey: opts.idempotencyKey,\n signal: opts.signal,\n expectEmpty: true,\n });\n }\n}\n","import type { paths } from \"../__generated__/api\";\nimport type { HttpClientLike } from \"../http\";\n\ntype ListResponse =\n paths[\"/api/v1/webhooks/subscriptions\"][\"get\"][\"responses\"][200][\"content\"][\"application/json\"];\ntype CreateBody = NonNullable<\n paths[\"/api/v1/webhooks/subscriptions\"][\"post\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\ntype CreateResponse =\n paths[\"/api/v1/webhooks/subscriptions\"][\"post\"][\"responses\"][201][\"content\"][\"application/json\"];\ntype UpdateBody = NonNullable<\n paths[\"/api/v1/webhooks/subscriptions/{id}\"][\"patch\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\ntype UpdateResponse =\n paths[\"/api/v1/webhooks/subscriptions/{id}\"][\"patch\"][\"responses\"][200][\"content\"][\"application/json\"];\ntype RotateBody = NonNullable<\n NonNullable<\n paths[\"/api/v1/webhooks/subscriptions/{id}/rotate-secret\"][\"post\"][\"requestBody\"]\n >[\"content\"][\"application/json\"]\n>;\ntype RotateResponse =\n paths[\"/api/v1/webhooks/subscriptions/{id}/rotate-secret\"][\"post\"][\"responses\"][200][\"content\"][\"application/json\"];\ntype TestResponse =\n paths[\"/api/v1/webhooks/test/{id}\"][\"post\"][\"responses\"][200][\"content\"][\"application/json\"];\n\nexport type WebhookSubscription = ListResponse[\"data\"][number];\nexport type WebhookSubscriptionWithSecret = CreateResponse[\"data\"];\nexport type WebhookSubscriptionCreateInput = CreateBody;\nexport type WebhookSubscriptionUpdateInput = UpdateBody;\nexport type WebhookSubscriptionRotateOptions = RotateBody;\nexport type WebhookSubscriptionRotateResult = RotateResponse[\"data\"];\nexport type WebhookSubscriptionTestResult = TestResponse[\"data\"];\n\nexport interface MutationOptions {\n idempotencyKey?: string;\n signal?: AbortSignal;\n}\n\nexport class WebhookSubscriptionsResource {\n constructor(private readonly http: HttpClientLike) {}\n\n async list(opts: { signal?: AbortSignal } = {}): Promise<WebhookSubscription[]> {\n const res = await this.http.request<ListResponse>({\n method: \"GET\",\n path: \"/api/v1/webhooks/subscriptions\",\n signal: opts.signal,\n });\n return res.data;\n }\n\n async create(\n input: WebhookSubscriptionCreateInput,\n opts: MutationOptions = {},\n ): Promise<WebhookSubscriptionWithSecret> {\n const res = await this.http.request<CreateResponse>({\n method: \"POST\",\n path: \"/api/v1/webhooks/subscriptions\",\n body: input,\n idempotencyKey: opts.idempotencyKey,\n signal: opts.signal,\n });\n return res.data;\n }\n\n async update(\n id: string,\n input: WebhookSubscriptionUpdateInput,\n opts: MutationOptions = {},\n ): Promise<WebhookSubscription> {\n const res = await this.http.request<UpdateResponse>({\n method: \"PATCH\",\n path: `/api/v1/webhooks/subscriptions/${encodeURIComponent(id)}`,\n body: input,\n idempotencyKey: opts.idempotencyKey,\n signal: opts.signal,\n });\n return res.data;\n }\n\n async delete(id: string, opts: MutationOptions = {}): Promise<void> {\n await this.http.request<void>({\n method: \"DELETE\",\n path: `/api/v1/webhooks/subscriptions/${encodeURIComponent(id)}`,\n idempotencyKey: opts.idempotencyKey,\n signal: opts.signal,\n expectEmpty: true,\n });\n }\n\n async rotateSecret(\n id: string,\n options: WebhookSubscriptionRotateOptions = {},\n opts: MutationOptions = {},\n ): Promise<WebhookSubscriptionRotateResult> {\n const res = await this.http.request<RotateResponse>({\n method: \"POST\",\n path: `/api/v1/webhooks/subscriptions/${encodeURIComponent(id)}/rotate-secret`,\n body: options,\n idempotencyKey: opts.idempotencyKey,\n signal: opts.signal,\n });\n return res.data;\n }\n\n async test(\n id: string,\n opts: MutationOptions = {},\n ): Promise<WebhookSubscriptionTestResult> {\n const res = await this.http.request<TestResponse>({\n method: \"POST\",\n path: `/api/v1/webhooks/test/${encodeURIComponent(id)}`,\n idempotencyKey: opts.idempotencyKey,\n signal: opts.signal,\n });\n return res.data;\n }\n}\n","import type { paths } from \"../__generated__/api\";\nimport type { HttpClientLike } from \"../http\";\n\ntype ReplayResponse =\n paths[\"/api/v1/webhooks/deliveries/{id}/replay\"][\"post\"][\"responses\"][200][\"content\"][\"application/json\"];\n\nexport type WebhookDeliveryReplayResult = ReplayResponse[\"data\"];\n\nexport interface ReplayOptions {\n idempotencyKey?: string;\n signal?: AbortSignal;\n}\n\nexport class WebhookDeliveriesResource {\n constructor(private readonly http: HttpClientLike) {}\n\n async replay(id: string, opts: ReplayOptions = {}): Promise<WebhookDeliveryReplayResult> {\n const res = await this.http.request<ReplayResponse>({\n method: \"POST\",\n path: `/api/v1/webhooks/deliveries/${encodeURIComponent(id)}/replay`,\n idempotencyKey: opts.idempotencyKey,\n signal: opts.signal,\n });\n return res.data;\n }\n}\n","import type { paths } from \"../../__generated__/api\";\nimport type { HttpClientLike } from \"../../http\";\n\ntype ListResponse =\n paths[\"/api/v1/whatsapp/templates\"][\"get\"][\"responses\"][200][\"content\"][\"application/json\"];\ntype CreateBody = NonNullable<\n paths[\"/api/v1/whatsapp/templates\"][\"post\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\ntype CreateResponse =\n paths[\"/api/v1/whatsapp/templates\"][\"post\"][\"responses\"][201][\"content\"][\"application/json\"];\n\nexport type WhatsAppTemplate = ListResponse[\"data\"][number];\nexport type WhatsAppTemplateCreateInput = CreateBody;\nexport type WhatsAppTemplateCreateResult = CreateResponse[\"data\"];\n\nexport interface ListOptions {\n connectionId: string;\n signal?: AbortSignal;\n}\n\nexport interface DeleteOptions {\n connectionId: string;\n idempotencyKey?: string;\n signal?: AbortSignal;\n}\n\nexport interface CreateOptions {\n idempotencyKey?: string;\n signal?: AbortSignal;\n}\n\nexport class WhatsAppTemplatesResource {\n constructor(private readonly http: HttpClientLike) {}\n\n async list(opts: ListOptions): Promise<WhatsAppTemplate[]> {\n const res = await this.http.request<ListResponse>({\n method: \"GET\",\n path: `/api/v1/whatsapp/templates?connection_id=${encodeURIComponent(opts.connectionId)}`,\n signal: opts.signal,\n });\n return res.data;\n }\n\n async create(\n input: WhatsAppTemplateCreateInput,\n opts: CreateOptions = {},\n ): Promise<WhatsAppTemplateCreateResult> {\n const res = await this.http.request<CreateResponse>({\n method: \"POST\",\n path: \"/api/v1/whatsapp/templates\",\n body: input,\n idempotencyKey: opts.idempotencyKey,\n signal: opts.signal,\n });\n return res.data;\n }\n\n async delete(name: string, opts: DeleteOptions): Promise<void> {\n await this.http.request<void>({\n method: \"DELETE\",\n path: `/api/v1/whatsapp/templates/${encodeURIComponent(name)}?connection_id=${encodeURIComponent(opts.connectionId)}`,\n idempotencyKey: opts.idempotencyKey,\n signal: opts.signal,\n expectEmpty: true,\n });\n }\n}\n","import type { paths } from \"../../__generated__/api\";\nimport type { HttpClientLike } from \"../../http\";\n\ntype ListResponse =\n paths[\"/api/v1/whatsapp/broadcasts\"][\"get\"][\"responses\"][200][\"content\"][\"application/json\"];\ntype CreateBody = NonNullable<\n paths[\"/api/v1/whatsapp/broadcasts\"][\"post\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\ntype CreateResponse =\n paths[\"/api/v1/whatsapp/broadcasts\"][\"post\"][\"responses\"][201][\"content\"][\"application/json\"];\ntype GetResponse =\n paths[\"/api/v1/whatsapp/broadcasts/{id}\"][\"get\"][\"responses\"][200][\"content\"][\"application/json\"];\ntype CancelBody = NonNullable<\n paths[\"/api/v1/whatsapp/broadcasts/{id}\"][\"patch\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\ntype CancelResponse =\n paths[\"/api/v1/whatsapp/broadcasts/{id}\"][\"patch\"][\"responses\"][200][\"content\"][\"application/json\"];\ntype SendResponse =\n paths[\"/api/v1/whatsapp/broadcasts/{id}/send\"][\"post\"][\"responses\"][200][\"content\"][\"application/json\"];\n\nexport type WhatsAppBroadcast = ListResponse[\"data\"][number];\nexport type WhatsAppBroadcastDetail = GetResponse[\"data\"];\nexport type WhatsAppBroadcastCreateInput = CreateBody;\n\nexport interface ListOptions {\n connectionId: string;\n signal?: AbortSignal;\n}\n\nexport interface MutationOptions {\n idempotencyKey?: string;\n signal?: AbortSignal;\n}\n\nexport class WhatsAppBroadcastsResource {\n constructor(private readonly http: HttpClientLike) {}\n\n async list(opts: ListOptions): Promise<WhatsAppBroadcast[]> {\n const res = await this.http.request<ListResponse>({\n method: \"GET\",\n path: `/api/v1/whatsapp/broadcasts?connection_id=${encodeURIComponent(opts.connectionId)}`,\n signal: opts.signal,\n });\n return res.data;\n }\n\n async create(\n input: WhatsAppBroadcastCreateInput,\n opts: MutationOptions = {},\n ): Promise<WhatsAppBroadcast> {\n const res = await this.http.request<CreateResponse>({\n method: \"POST\",\n path: \"/api/v1/whatsapp/broadcasts\",\n body: input,\n idempotencyKey: opts.idempotencyKey,\n signal: opts.signal,\n });\n return res.data;\n }\n\n async get(id: string, opts: { signal?: AbortSignal } = {}): Promise<WhatsAppBroadcastDetail> {\n const res = await this.http.request<GetResponse>({\n method: \"GET\",\n path: `/api/v1/whatsapp/broadcasts/${encodeURIComponent(id)}`,\n signal: opts.signal,\n });\n return res.data;\n }\n\n async cancel(id: string, opts: MutationOptions = {}): Promise<WhatsAppBroadcast> {\n const body: CancelBody = { status: \"cancelled\" };\n const res = await this.http.request<CancelResponse>({\n method: \"PATCH\",\n path: `/api/v1/whatsapp/broadcasts/${encodeURIComponent(id)}`,\n body,\n idempotencyKey: opts.idempotencyKey,\n signal: opts.signal,\n });\n return res.data;\n }\n\n /**\n * Execute the broadcast. Long-running — iterates recipients with 100ms\n * pacing between sends. Consider extending your HTTP client's timeout\n * for broadcasts over a few hundred recipients (the Atribu server caps\n * the route at 300s).\n */\n async send(id: string, opts: MutationOptions = {}): Promise<WhatsAppBroadcast> {\n const res = await this.http.request<SendResponse>({\n method: \"POST\",\n path: `/api/v1/whatsapp/broadcasts/${encodeURIComponent(id)}/send`,\n idempotencyKey: opts.idempotencyKey,\n signal: opts.signal,\n });\n return res.data;\n }\n}\n","import type { HttpClientLike } from \"../../http\";\nimport { WhatsAppTemplatesResource } from \"./templates\";\nimport { WhatsAppBroadcastsResource } from \"./broadcasts\";\n\n/**\n * WhatsApp-specific resource namespace. Mounted on `AtribuClient.whatsapp`.\n * Cross-channel messaging stays on `AtribuClient.messages`.\n */\nexport class WhatsAppNamespace {\n readonly templates: WhatsAppTemplatesResource;\n readonly broadcasts: WhatsAppBroadcastsResource;\n\n constructor(http: HttpClientLike) {\n this.templates = new WhatsAppTemplatesResource(http);\n this.broadcasts = new WhatsAppBroadcastsResource(http);\n }\n}\n\nexport type {\n WhatsAppTemplate,\n WhatsAppTemplateCreateInput,\n WhatsAppTemplateCreateResult,\n} from \"./templates\";\nexport type {\n WhatsAppBroadcast,\n WhatsAppBroadcastDetail,\n WhatsAppBroadcastCreateInput,\n} from \"./broadcasts\";\n","import type { paths } from \"../../__generated__/api\";\nimport type { HttpClientLike } from \"../../http\";\n\ntype ListResponse =\n paths[\"/api/v1/instagram/triggers\"][\"get\"][\"responses\"][200][\"content\"][\"application/json\"];\ntype CreateBody = NonNullable<\n paths[\"/api/v1/instagram/triggers\"][\"post\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\ntype CreateResponse =\n paths[\"/api/v1/instagram/triggers\"][\"post\"][\"responses\"][201][\"content\"][\"application/json\"];\ntype UpdateBody = NonNullable<\n paths[\"/api/v1/instagram/triggers/{id}\"][\"patch\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\ntype UpdateResponse =\n paths[\"/api/v1/instagram/triggers/{id}\"][\"patch\"][\"responses\"][200][\"content\"][\"application/json\"];\ntype TestDmBody = NonNullable<\n paths[\"/api/v1/instagram/triggers/{id}/test-dm\"][\"post\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\ntype TestDmResponse =\n paths[\"/api/v1/instagram/triggers/{id}/test-dm\"][\"post\"][\"responses\"][200][\"content\"][\"application/json\"];\ntype ResumeBody = NonNullable<\n paths[\"/api/v1/instagram/triggers/resume\"][\"post\"][\"requestBody\"]\n>[\"content\"][\"application/json\"];\ntype ResumeResponse =\n paths[\"/api/v1/instagram/triggers/resume\"][\"post\"][\"responses\"][200][\"content\"][\"application/json\"];\n\nexport type InstagramTrigger = ListResponse[\"data\"][number];\nexport type InstagramTriggerCreateInput = CreateBody;\nexport type InstagramTriggerUpdateInput = UpdateBody;\n\nexport interface ListOptions {\n connectionId: string;\n signal?: AbortSignal;\n}\n\nexport interface MutationOptions {\n idempotencyKey?: string;\n signal?: AbortSignal;\n}\n\nexport interface ResumeOptions extends MutationOptions {\n connectionId: string;\n}\n\nexport class InstagramTriggersResource {\n constructor(private readonly http: HttpClientLike) {}\n\n async list(opts: ListOptions): Promise<InstagramTrigger[]> {\n const res = await this.http.request<ListResponse>({\n method: \"GET\",\n path: `/api/v1/instagram/triggers?connection_id=${encodeURIComponent(opts.connectionId)}`,\n signal: opts.signal,\n });\n return res.data;\n }\n\n async create(\n input: InstagramTriggerCreateInput,\n opts: MutationOptions = {},\n ): Promise<InstagramTrigger> {\n const res = await this.http.request<CreateResponse>({\n method: \"POST\",\n path: \"/api/v1/instagram/triggers\",\n body: input,\n idempotencyKey: opts.idempotencyKey,\n signal: opts.signal,\n });\n return res.data;\n }\n\n async update(\n id: string,\n input: InstagramTriggerUpdateInput,\n opts: MutationOptions = {},\n ): Promise<InstagramTrigger> {\n const res = await this.http.request<UpdateResponse>({\n method: \"PATCH\",\n path: `/api/v1/instagram/triggers/${encodeURIComponent(id)}`,\n body: input,\n idempotencyKey: opts.idempotencyKey,\n signal: opts.signal,\n });\n return res.data;\n }\n\n async delete(id: string, opts: MutationOptions = {}): Promise<void> {\n await this.http.request<void>({\n method: \"DELETE\",\n path: `/api/v1/instagram/triggers/${encodeURIComponent(id)}`,\n idempotencyKey: opts.idempotencyKey,\n signal: opts.signal,\n expectEmpty: true,\n });\n }\n\n /**\n * Send the trigger's `opening_message` as a one-off DM to a test IGSID.\n * Uses Meta's HUMAN_AGENT tag — recipient must have DMed the IG account\n * in the past 7 days, otherwise Meta rejects the send.\n */\n async testDm(\n id: string,\n input: TestDmBody,\n opts: MutationOptions = {},\n ): Promise<TestDmResponse[\"data\"]> {\n const res = await this.http.request<TestDmResponse>({\n method: \"POST\",\n path: `/api/v1/instagram/triggers/${encodeURIComponent(id)}/test-dm`,\n body: input,\n idempotencyKey: opts.idempotencyKey,\n signal: opts.signal,\n });\n return res.data;\n }\n\n /**\n * Manually clear the comment-to-DM circuit breaker for the connection's\n * IG account. The breaker normally clears itself once spam signals\n * subside; this method exists for ops intervention.\n */\n async resumeCircuit(opts: ResumeOptions): Promise<ResumeResponse[\"data\"]> {\n const body: ResumeBody = { connection_id: opts.connectionId };\n const res = await this.http.request<ResumeResponse>({\n method: \"POST\",\n path: \"/api/v1/instagram/triggers/resume\",\n body,\n idempotencyKey: opts.idempotencyKey,\n signal: opts.signal,\n });\n return res.data;\n }\n}\n","import type { HttpClientLike } from \"../../http\";\nimport { InstagramTriggersResource } from \"./triggers\";\n\n/**\n * Instagram-specific resource namespace. Mounted on `AtribuClient.instagram`.\n * Cross-channel messaging stays on `AtribuClient.messages` and\n * `AtribuClient.comments`.\n */\nexport class InstagramNamespace {\n readonly triggers: InstagramTriggersResource;\n\n constructor(http: HttpClientLike) {\n this.triggers = new InstagramTriggersResource(http);\n }\n}\n\nexport type {\n InstagramTrigger,\n InstagramTriggerCreateInput,\n InstagramTriggerUpdateInput,\n} from \"./triggers\";\n","/**\n * Opt-in retry layer.\n *\n * Why opt-in: hiding retries inside the SDK by default obscures backpressure\n * signals and amplifies load on a failing server. Consumers that want them\n * call `.withRetry({...})`; others write their own retry logic against the\n * typed `retry` hint on AtribuApiError.\n *\n * What gets retried:\n * - `AtribuApiError` with `retry.action === \"retry\"` (5xx, 408)\n * - `AtribuApiError` with `retry.action === \"retry_after\"` (429, 503 w/\n * Retry-After) — honors retryAfterMs\n * - `AtribuTransportError` (network glitches, ECONNRESET, timeouts)\n *\n * What does NOT retry:\n * - `AtribuApiError` with `retry.action === \"do_not_retry\"` (403)\n * - `AtribuApiError` with `retry.action === \"fix_and_retry\"` (422 etc — the\n * caller's input is wrong; retrying with the same body won't help)\n * - `AtribuApiError` with `retry.action === \"refresh_token\"` (401 — needs\n * credential refresh, not a retry)\n * - `AtribuConfigError`, `AtribuWebhookError`, anything else\n */\n\nimport {\n AtribuApiError,\n AtribuTransportError,\n type AtribuError,\n} from \"./errors\";\nimport type { HttpClientLike, RequestOptions } from \"./http\";\n\nexport type BackoffStrategy = \"exponential\" | \"fixed\" | \"none\";\n\nexport interface RetryOptions {\n /**\n * Max attempts including the initial call. `maxAttempts: 3` = initial + 2\n * retries. Must be ≥ 1. Default 3.\n */\n maxAttempts?: number;\n /**\n * Backoff strategy between retries. \"exponential\" = `baseDelayMs * 2^n`\n * (capped by `maxDelayMs`). \"fixed\" = `baseDelayMs`. \"none\" = no delay.\n * Default \"exponential\".\n */\n backoff?: BackoffStrategy;\n /** Base delay between retries in ms. Default 500. */\n baseDelayMs?: number;\n /** Cap on the delay between retries. Default 30000 (30s). */\n maxDelayMs?: number;\n /**\n * Jitter factor 0..1. Multiplies the computed delay by `1 + random*jitter`\n * (jitter=0 means deterministic). Default 0.3.\n */\n jitter?: number;\n /** Inject for tests. Default `(ms) => new Promise(r => setTimeout(r, ms))`. */\n sleep?: (ms: number) => Promise<void>;\n /** Inject for jitter tests. Default Math.random. */\n random?: () => number;\n}\n\ninterface ResolvedRetry {\n maxAttempts: number;\n backoff: BackoffStrategy;\n baseDelayMs: number;\n maxDelayMs: number;\n jitter: number;\n sleep: (ms: number) => Promise<void>;\n random: () => number;\n}\n\nfunction resolveRetry(o: RetryOptions): ResolvedRetry {\n return {\n maxAttempts: Math.max(1, o.maxAttempts ?? 3),\n backoff: o.backoff ?? \"exponential\",\n baseDelayMs: Math.max(0, o.baseDelayMs ?? 500),\n maxDelayMs: Math.max(0, o.maxDelayMs ?? 30_000),\n jitter: Math.min(1, Math.max(0, o.jitter ?? 0.3)),\n sleep: o.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms))),\n random: o.random ?? Math.random,\n };\n}\n\nexport class RetryingHttpClient implements HttpClientLike {\n private readonly r: ResolvedRetry;\n constructor(private readonly base: HttpClientLike, options: RetryOptions) {\n this.r = resolveRetry(options);\n }\n\n async request<T>(opts: RequestOptions): Promise<T> {\n let lastErr: unknown;\n for (let attempt = 1; attempt <= this.r.maxAttempts; attempt++) {\n try {\n return await this.base.request<T>(opts);\n } catch (err) {\n lastErr = err;\n if (attempt >= this.r.maxAttempts) throw err;\n const delay = this.computeDelay(err, attempt);\n if (delay === null) throw err; // non-retryable\n if (delay > 0) await this.r.sleep(delay);\n }\n }\n throw lastErr; // unreachable\n }\n\n /**\n * Returns the delay in ms before the next attempt, or null if the error\n * is non-retryable (caller should throw immediately).\n */\n private computeDelay(err: unknown, attempt: number): number | null {\n // Transport errors (network glitches, timeouts) → backoff-based retry\n if (err instanceof AtribuTransportError) {\n return this.applyJitter(this.backoffDelay(attempt));\n }\n if (err instanceof AtribuApiError) {\n const action = err.retry.action;\n if (action === \"retry\") return this.applyJitter(this.backoffDelay(attempt));\n if (action === \"retry_after\") {\n // Honor the server's instruction exactly (no jitter on this one).\n const capped = Math.min(err.retry.retryAfterMs, this.r.maxDelayMs);\n return Math.max(0, capped);\n }\n // do_not_retry / fix_and_retry / refresh_token — caller must handle\n return null;\n }\n return null;\n }\n\n private backoffDelay(attempt: number): number {\n if (this.r.backoff === \"none\") return 0;\n if (this.r.backoff === \"fixed\") return this.r.baseDelayMs;\n // exponential: base * 2^(attempt-1), capped at maxDelayMs\n const raw = this.r.baseDelayMs * Math.pow(2, attempt - 1);\n return Math.min(raw, this.r.maxDelayMs);\n }\n\n private applyJitter(delay: number): number {\n if (this.r.jitter === 0) return delay;\n return Math.round(delay * (1 + this.r.random() * this.r.jitter));\n }\n}\n\nexport function isRetryableError(err: unknown): err is AtribuError {\n if (err instanceof AtribuTransportError) return true;\n if (err instanceof AtribuApiError) {\n return err.retry.action === \"retry\" || err.retry.action === \"retry_after\";\n }\n return false;\n}\n","import { resolveConfig, type AtribuClientConfig } from \"./config\";\nimport { HttpClient, type HttpClientLike } from \"./http\";\nimport { MessagesResource } from \"./resources/messages\";\nimport { CommentsResource } from \"./resources/comments\";\nimport { ConnectionsResource } from \"./resources/connections\";\nimport { WebhookSubscriptionsResource } from \"./resources/webhook-subscriptions\";\nimport { WebhookDeliveriesResource } from \"./resources/webhook-deliveries\";\nimport { WhatsAppNamespace } from \"./resources/whatsapp\";\nimport { InstagramNamespace } from \"./resources/instagram\";\nimport { RetryingHttpClient, type RetryOptions } from \"./retry-wrapper\";\n\ninterface ResourceBundle {\n messages: MessagesResource;\n comments: CommentsResource;\n connections: ConnectionsResource;\n webhooks: {\n subscriptions: WebhookSubscriptionsResource;\n deliveries: WebhookDeliveriesResource;\n };\n whatsapp: WhatsAppNamespace;\n instagram: InstagramNamespace;\n}\n\nfunction buildResources(http: HttpClientLike): ResourceBundle {\n return {\n messages: new MessagesResource(http),\n comments: new CommentsResource(http),\n connections: new ConnectionsResource(http),\n webhooks: {\n subscriptions: new WebhookSubscriptionsResource(http),\n deliveries: new WebhookDeliveriesResource(http),\n },\n whatsapp: new WhatsAppNamespace(http),\n instagram: new InstagramNamespace(http),\n };\n}\n\nexport class AtribuClient {\n readonly messages: MessagesResource;\n readonly comments: CommentsResource;\n readonly connections: ConnectionsResource;\n readonly webhooks: ResourceBundle[\"webhooks\"];\n readonly whatsapp: WhatsAppNamespace;\n readonly instagram: InstagramNamespace;\n\n /** @internal — exposed for `withRetry` chaining; do not depend on this. */\n protected readonly _http: HttpClientLike;\n\n constructor(config: AtribuClientConfig) {\n this._http = new HttpClient(resolveConfig(config));\n const r = buildResources(this._http);\n this.messages = r.messages;\n this.comments = r.comments;\n this.connections = r.connections;\n this.webhooks = r.webhooks;\n this.whatsapp = r.whatsapp;\n this.instagram = r.instagram;\n }\n\n /**\n * Returns a new AtribuClient that retries on transient errors. The\n * original client is not mutated. The wrapper respects the typed\n * `retry` hint on AtribuApiError — `do_not_retry`, `fix_and_retry`,\n * and `refresh_token` are NOT retried (those need caller action, not\n * a repeat call).\n *\n * @example\n * const client = new AtribuClient({...}).withRetry({\n * maxAttempts: 3,\n * backoff: \"exponential\",\n * baseDelayMs: 500,\n * });\n * await client.messages.send({...});\n */\n withRetry(options: RetryOptions): AtribuClient {\n const wrapped = new RetryingHttpClient(this._http, options);\n return AtribuClient._fromHttp(wrapped);\n }\n\n private static _fromHttp(http: HttpClientLike): AtribuClient {\n const proto = Object.create(AtribuClient.prototype) as object;\n const r = buildResources(http);\n Object.assign(proto, {\n _http: http,\n messages: r.messages,\n comments: r.comments,\n connections: r.connections,\n webhooks: r.webhooks,\n whatsapp: r.whatsapp,\n instagram: r.instagram,\n });\n return proto as AtribuClient;\n }\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- import { H as HttpClientLike, p as paths, R as RequestOptions } from './api.d-BXINTQo6.cjs';
2
- import { A as AtribuError } from './errors-D3ApBz8J.cjs';
3
- export { a as ApiErrorBody, b as ApiErrorCode, c as AtribuApiError, d as AtribuConfigError, e as AtribuOauthError, f as AtribuTransportError, g as AtribuWebhookError, O as OauthErrorCode, R as RetryHint, W as WebhookErrorCode } from './errors-D3ApBz8J.cjs';
1
+ import { H as HttpClientLike, p as paths, R as RequestOptions } from './api.d-CRypizsD.cjs';
2
+ import { d as AtribuError } from './errors-BLELoojK.cjs';
3
+ export { A as ApiErrorBody, a as ApiErrorCode, b as AtribuApiError, c as AtribuConfigError, e as AtribuOauthError, f as AtribuTransportError, g as AtribuWebhookError, O as OauthErrorCode, R as RetryHint, W as WebhookErrorCode } from './errors-BLELoojK.cjs';
4
4
 
5
5
  interface AtribuClientConfig {
6
6
  apiKey: string;
@@ -47,21 +47,46 @@ declare class CommentsResource {
47
47
  privateReply(input: CommentPrivateReplyInput, opts?: CommentReplyOptions): Promise<CommentReplyResponse>;
48
48
  }
49
49
 
50
- type ListResponse = paths["/api/v1/webhooks/subscriptions"]["get"]["responses"][200]["content"]["application/json"];
51
- type CreateBody = NonNullable<paths["/api/v1/webhooks/subscriptions"]["post"]["requestBody"]>["content"]["application/json"];
52
- type CreateResponse = paths["/api/v1/webhooks/subscriptions"]["post"]["responses"][201]["content"]["application/json"];
53
- type UpdateBody = NonNullable<paths["/api/v1/webhooks/subscriptions/{id}"]["patch"]["requestBody"]>["content"]["application/json"];
50
+ type ListResponse$4 = paths["/api/v1/connections"]["get"]["responses"][200]["content"]["application/json"];
51
+ type Connection = ListResponse$4["data"][number];
52
+ interface ListOptions$3 {
53
+ channel?: "whatsapp" | "instagram";
54
+ signal?: AbortSignal;
55
+ }
56
+ interface MutationOptions$3 {
57
+ idempotencyKey?: string;
58
+ signal?: AbortSignal;
59
+ }
60
+ declare class ConnectionsResource {
61
+ private readonly http;
62
+ constructor(http: HttpClientLike);
63
+ list(opts?: ListOptions$3): Promise<Connection[]>;
64
+ get(id: string, opts?: {
65
+ signal?: AbortSignal;
66
+ }): Promise<Connection>;
67
+ /**
68
+ * Revoke this OAuth app's authorization for the connection. Does NOT
69
+ * disconnect the underlying data_connection (other consumers + the
70
+ * Atribu UI still see it). Direct admin keys reject this call with 400.
71
+ */
72
+ revoke(id: string, opts?: MutationOptions$3): Promise<void>;
73
+ }
74
+
75
+ type ListResponse$3 = paths["/api/v1/webhooks/subscriptions"]["get"]["responses"][200]["content"]["application/json"];
76
+ type CreateBody$3 = NonNullable<paths["/api/v1/webhooks/subscriptions"]["post"]["requestBody"]>["content"]["application/json"];
77
+ type CreateResponse$1 = paths["/api/v1/webhooks/subscriptions"]["post"]["responses"][201]["content"]["application/json"];
78
+ type UpdateBody$1 = NonNullable<paths["/api/v1/webhooks/subscriptions/{id}"]["patch"]["requestBody"]>["content"]["application/json"];
54
79
  type RotateBody = NonNullable<NonNullable<paths["/api/v1/webhooks/subscriptions/{id}/rotate-secret"]["post"]["requestBody"]>["content"]["application/json"]>;
55
80
  type RotateResponse = paths["/api/v1/webhooks/subscriptions/{id}/rotate-secret"]["post"]["responses"][200]["content"]["application/json"];
56
81
  type TestResponse = paths["/api/v1/webhooks/test/{id}"]["post"]["responses"][200]["content"]["application/json"];
57
- type WebhookSubscription = ListResponse["data"][number];
58
- type WebhookSubscriptionWithSecret = CreateResponse["data"];
59
- type WebhookSubscriptionCreateInput = CreateBody;
60
- type WebhookSubscriptionUpdateInput = UpdateBody;
82
+ type WebhookSubscription = ListResponse$3["data"][number];
83
+ type WebhookSubscriptionWithSecret = CreateResponse$1["data"];
84
+ type WebhookSubscriptionCreateInput = CreateBody$3;
85
+ type WebhookSubscriptionUpdateInput = UpdateBody$1;
61
86
  type WebhookSubscriptionRotateOptions = RotateBody;
62
87
  type WebhookSubscriptionRotateResult = RotateResponse["data"];
63
88
  type WebhookSubscriptionTestResult = TestResponse["data"];
64
- interface MutationOptions {
89
+ interface MutationOptions$2 {
65
90
  idempotencyKey?: string;
66
91
  signal?: AbortSignal;
67
92
  }
@@ -71,11 +96,11 @@ declare class WebhookSubscriptionsResource {
71
96
  list(opts?: {
72
97
  signal?: AbortSignal;
73
98
  }): Promise<WebhookSubscription[]>;
74
- create(input: WebhookSubscriptionCreateInput, opts?: MutationOptions): Promise<WebhookSubscriptionWithSecret>;
75
- update(id: string, input: WebhookSubscriptionUpdateInput, opts?: MutationOptions): Promise<WebhookSubscription>;
76
- delete(id: string, opts?: MutationOptions): Promise<void>;
77
- rotateSecret(id: string, options?: WebhookSubscriptionRotateOptions, opts?: MutationOptions): Promise<WebhookSubscriptionRotateResult>;
78
- test(id: string, opts?: MutationOptions): Promise<WebhookSubscriptionTestResult>;
99
+ create(input: WebhookSubscriptionCreateInput, opts?: MutationOptions$2): Promise<WebhookSubscriptionWithSecret>;
100
+ update(id: string, input: WebhookSubscriptionUpdateInput, opts?: MutationOptions$2): Promise<WebhookSubscription>;
101
+ delete(id: string, opts?: MutationOptions$2): Promise<void>;
102
+ rotateSecret(id: string, options?: WebhookSubscriptionRotateOptions, opts?: MutationOptions$2): Promise<WebhookSubscriptionRotateResult>;
103
+ test(id: string, opts?: MutationOptions$2): Promise<WebhookSubscriptionTestResult>;
79
104
  }
80
105
 
81
106
  type ReplayResponse = paths["/api/v1/webhooks/deliveries/{id}/replay"]["post"]["responses"][200]["content"]["application/json"];
@@ -90,6 +115,126 @@ declare class WebhookDeliveriesResource {
90
115
  replay(id: string, opts?: ReplayOptions): Promise<WebhookDeliveryReplayResult>;
91
116
  }
92
117
 
118
+ type ListResponse$2 = paths["/api/v1/whatsapp/templates"]["get"]["responses"][200]["content"]["application/json"];
119
+ type CreateBody$2 = NonNullable<paths["/api/v1/whatsapp/templates"]["post"]["requestBody"]>["content"]["application/json"];
120
+ type CreateResponse = paths["/api/v1/whatsapp/templates"]["post"]["responses"][201]["content"]["application/json"];
121
+ type WhatsAppTemplate = ListResponse$2["data"][number];
122
+ type WhatsAppTemplateCreateInput = CreateBody$2;
123
+ type WhatsAppTemplateCreateResult = CreateResponse["data"];
124
+ interface ListOptions$2 {
125
+ connectionId: string;
126
+ signal?: AbortSignal;
127
+ }
128
+ interface DeleteOptions {
129
+ connectionId: string;
130
+ idempotencyKey?: string;
131
+ signal?: AbortSignal;
132
+ }
133
+ interface CreateOptions {
134
+ idempotencyKey?: string;
135
+ signal?: AbortSignal;
136
+ }
137
+ declare class WhatsAppTemplatesResource {
138
+ private readonly http;
139
+ constructor(http: HttpClientLike);
140
+ list(opts: ListOptions$2): Promise<WhatsAppTemplate[]>;
141
+ create(input: WhatsAppTemplateCreateInput, opts?: CreateOptions): Promise<WhatsAppTemplateCreateResult>;
142
+ delete(name: string, opts: DeleteOptions): Promise<void>;
143
+ }
144
+
145
+ type ListResponse$1 = paths["/api/v1/whatsapp/broadcasts"]["get"]["responses"][200]["content"]["application/json"];
146
+ type CreateBody$1 = NonNullable<paths["/api/v1/whatsapp/broadcasts"]["post"]["requestBody"]>["content"]["application/json"];
147
+ type GetResponse = paths["/api/v1/whatsapp/broadcasts/{id}"]["get"]["responses"][200]["content"]["application/json"];
148
+ type WhatsAppBroadcast = ListResponse$1["data"][number];
149
+ type WhatsAppBroadcastDetail = GetResponse["data"];
150
+ type WhatsAppBroadcastCreateInput = CreateBody$1;
151
+ interface ListOptions$1 {
152
+ connectionId: string;
153
+ signal?: AbortSignal;
154
+ }
155
+ interface MutationOptions$1 {
156
+ idempotencyKey?: string;
157
+ signal?: AbortSignal;
158
+ }
159
+ declare class WhatsAppBroadcastsResource {
160
+ private readonly http;
161
+ constructor(http: HttpClientLike);
162
+ list(opts: ListOptions$1): Promise<WhatsAppBroadcast[]>;
163
+ create(input: WhatsAppBroadcastCreateInput, opts?: MutationOptions$1): Promise<WhatsAppBroadcast>;
164
+ get(id: string, opts?: {
165
+ signal?: AbortSignal;
166
+ }): Promise<WhatsAppBroadcastDetail>;
167
+ cancel(id: string, opts?: MutationOptions$1): Promise<WhatsAppBroadcast>;
168
+ /**
169
+ * Execute the broadcast. Long-running — iterates recipients with 100ms
170
+ * pacing between sends. Consider extending your HTTP client's timeout
171
+ * for broadcasts over a few hundred recipients (the Atribu server caps
172
+ * the route at 300s).
173
+ */
174
+ send(id: string, opts?: MutationOptions$1): Promise<WhatsAppBroadcast>;
175
+ }
176
+
177
+ /**
178
+ * WhatsApp-specific resource namespace. Mounted on `AtribuClient.whatsapp`.
179
+ * Cross-channel messaging stays on `AtribuClient.messages`.
180
+ */
181
+ declare class WhatsAppNamespace {
182
+ readonly templates: WhatsAppTemplatesResource;
183
+ readonly broadcasts: WhatsAppBroadcastsResource;
184
+ constructor(http: HttpClientLike);
185
+ }
186
+
187
+ type ListResponse = paths["/api/v1/instagram/triggers"]["get"]["responses"][200]["content"]["application/json"];
188
+ type CreateBody = NonNullable<paths["/api/v1/instagram/triggers"]["post"]["requestBody"]>["content"]["application/json"];
189
+ type UpdateBody = NonNullable<paths["/api/v1/instagram/triggers/{id}"]["patch"]["requestBody"]>["content"]["application/json"];
190
+ type TestDmBody = NonNullable<paths["/api/v1/instagram/triggers/{id}/test-dm"]["post"]["requestBody"]>["content"]["application/json"];
191
+ type TestDmResponse = paths["/api/v1/instagram/triggers/{id}/test-dm"]["post"]["responses"][200]["content"]["application/json"];
192
+ type ResumeResponse = paths["/api/v1/instagram/triggers/resume"]["post"]["responses"][200]["content"]["application/json"];
193
+ type InstagramTrigger = ListResponse["data"][number];
194
+ type InstagramTriggerCreateInput = CreateBody;
195
+ type InstagramTriggerUpdateInput = UpdateBody;
196
+ interface ListOptions {
197
+ connectionId: string;
198
+ signal?: AbortSignal;
199
+ }
200
+ interface MutationOptions {
201
+ idempotencyKey?: string;
202
+ signal?: AbortSignal;
203
+ }
204
+ interface ResumeOptions extends MutationOptions {
205
+ connectionId: string;
206
+ }
207
+ declare class InstagramTriggersResource {
208
+ private readonly http;
209
+ constructor(http: HttpClientLike);
210
+ list(opts: ListOptions): Promise<InstagramTrigger[]>;
211
+ create(input: InstagramTriggerCreateInput, opts?: MutationOptions): Promise<InstagramTrigger>;
212
+ update(id: string, input: InstagramTriggerUpdateInput, opts?: MutationOptions): Promise<InstagramTrigger>;
213
+ delete(id: string, opts?: MutationOptions): Promise<void>;
214
+ /**
215
+ * Send the trigger's `opening_message` as a one-off DM to a test IGSID.
216
+ * Uses Meta's HUMAN_AGENT tag — recipient must have DMed the IG account
217
+ * in the past 7 days, otherwise Meta rejects the send.
218
+ */
219
+ testDm(id: string, input: TestDmBody, opts?: MutationOptions): Promise<TestDmResponse["data"]>;
220
+ /**
221
+ * Manually clear the comment-to-DM circuit breaker for the connection's
222
+ * IG account. The breaker normally clears itself once spam signals
223
+ * subside; this method exists for ops intervention.
224
+ */
225
+ resumeCircuit(opts: ResumeOptions): Promise<ResumeResponse["data"]>;
226
+ }
227
+
228
+ /**
229
+ * Instagram-specific resource namespace. Mounted on `AtribuClient.instagram`.
230
+ * Cross-channel messaging stays on `AtribuClient.messages` and
231
+ * `AtribuClient.comments`.
232
+ */
233
+ declare class InstagramNamespace {
234
+ readonly triggers: InstagramTriggersResource;
235
+ constructor(http: HttpClientLike);
236
+ }
237
+
93
238
  /**
94
239
  * Opt-in retry layer.
95
240
  *
@@ -158,15 +303,21 @@ declare function isRetryableError(err: unknown): err is AtribuError;
158
303
  interface ResourceBundle {
159
304
  messages: MessagesResource;
160
305
  comments: CommentsResource;
306
+ connections: ConnectionsResource;
161
307
  webhooks: {
162
308
  subscriptions: WebhookSubscriptionsResource;
163
309
  deliveries: WebhookDeliveriesResource;
164
310
  };
311
+ whatsapp: WhatsAppNamespace;
312
+ instagram: InstagramNamespace;
165
313
  }
166
314
  declare class AtribuClient {
167
315
  readonly messages: MessagesResource;
168
316
  readonly comments: CommentsResource;
317
+ readonly connections: ConnectionsResource;
169
318
  readonly webhooks: ResourceBundle["webhooks"];
319
+ readonly whatsapp: WhatsAppNamespace;
320
+ readonly instagram: InstagramNamespace;
170
321
  /** @internal — exposed for `withRetry` chaining; do not depend on this. */
171
322
  protected readonly _http: HttpClientLike;
172
323
  constructor(config: AtribuClientConfig);
@@ -189,10 +340,10 @@ declare class AtribuClient {
189
340
  private static _fromHttp;
190
341
  }
191
342
 
192
- declare const SDK_VERSION = "0.1.2";
343
+ declare const SDK_VERSION = "0.1.4";
193
344
 
194
345
  type Runtime = "node" | "bun" | "deno" | "edge" | "browser" | "unknown";
195
346
  declare function detectRuntime(): Runtime;
196
347
  declare function runtimeTag(): string;
197
348
 
198
- export { AtribuClient, type AtribuClientConfig, AtribuError, type BackoffStrategy, type CommentPrivateReplyInput, type CommentReplyInput, type CommentReplyOptions, type CommentReplyResponse, type MessageContent, type MessageSendInput, type MessageSendResponse, type MutationOptions, type ReplayOptions, type RetryOptions, RetryingHttpClient, type Runtime, SDK_VERSION, type SendOptions, type WebhookDeliveryReplayResult, type WebhookSubscription, type WebhookSubscriptionCreateInput, type WebhookSubscriptionRotateOptions, type WebhookSubscriptionRotateResult, type WebhookSubscriptionTestResult, type WebhookSubscriptionUpdateInput, type WebhookSubscriptionWithSecret, detectRuntime, isRetryableError, runtimeTag };
349
+ export { AtribuClient, type AtribuClientConfig, AtribuError, type BackoffStrategy, type CommentPrivateReplyInput, type CommentReplyInput, type CommentReplyOptions, type CommentReplyResponse, type Connection, type InstagramTrigger, type InstagramTriggerCreateInput, type InstagramTriggerUpdateInput, type MessageContent, type MessageSendInput, type MessageSendResponse, type MutationOptions$2 as MutationOptions, type ReplayOptions, type RetryOptions, RetryingHttpClient, type Runtime, SDK_VERSION, type SendOptions, type WebhookDeliveryReplayResult, type WebhookSubscription, type WebhookSubscriptionCreateInput, type WebhookSubscriptionRotateOptions, type WebhookSubscriptionRotateResult, type WebhookSubscriptionTestResult, type WebhookSubscriptionUpdateInput, type WebhookSubscriptionWithSecret, type WhatsAppBroadcast, type WhatsAppBroadcastCreateInput, type WhatsAppBroadcastDetail, type WhatsAppTemplate, type WhatsAppTemplateCreateInput, type WhatsAppTemplateCreateResult, detectRuntime, isRetryableError, runtimeTag };