import type { CampaignReceiver } from '../internal/receiver-file'; /** * Most recipients one bulk campaign may carry. * * The same ceiling the panel has always enforced. It is not arbitrary: the list * is encrypted into a single file and read back into memory by the campaign * manager, so this is the point at which "one campaign" stops being a sensible * unit of work. */ export declare const MAX_BULK_RECEIVERS = 1000000; /** * How a bulk audience is described. * * Four shapes, because there are four ways a person actually has this data to * hand. All of them end as the same encrypted file; the difference is only how * much parsing the SDK does on the way. */ export type BulkAudienceInput = /** * Just numbers, with no per-recipient variables. * * Accepts an array, or one string holding many -- a textarea's contents, * separated by commas, newlines, semicolons or spaces, in any combination. */ { numbers: string | readonly string[]; dedupe?: boolean; } /** * Raw CSV or TSV text whose first row is the header. * * `recipientColumn` names the header holding the number; every column, * including that one, also becomes a template variable. The delimiter is * detected from the header row unless you pass one. */ | { csv: string; recipientColumn: string; delimiter?: string; dedupe?: boolean; } /** * Rows you have already parsed -- from your own CSV reader, a spreadsheet API, * or a database query. */ | { rows: readonly Record[]; recipientColumn: string; dedupe?: boolean; } /** Receivers you have already built. The escape hatch; nothing is inferred. */ | { receivers: readonly CampaignReceiver[]; }; /** What resolving an audience produced, including what it discarded. */ export interface ResolvedAudience { receivers: CampaignReceiver[]; /** Entries that carried no usable digits and were skipped. */ skipped: number; /** Entries dropped because an earlier entry had the same number. */ duplicates: number; } /** * Normalises a column name into a template variable id. * * Lower-cased with every non-alphanumeric character replaced by `_`, which is * what the panel's CSV reader and its paste-a-table path both did -- so a header * of `First Name` is the variable `first_name` here exactly as it was there, and * templates built against the old behaviour keep working. * * A blank header becomes `empty_` rather than `_`, so two unnamed columns * do not collapse into one variable. */ export declare const normaliseColumn: (header: unknown, index: number) => string; /** * Pulls the numbers out of one string, or tidies an array of them. * * Splits on commas, newlines, carriage returns, tabs, semicolons and spaces -- * all of them, in any mixture. The panel chose a single separator per paste * (commas if the text contained any, otherwise newlines), which quietly mangled * the common case of pasting a column from a spreadsheet into a field that * already had comma-separated numbers: the newlines were never split on, so two * numbers merged into one 24-digit number and the send went nowhere. Splitting on * every separator cannot produce that, and for input with one separator it * behaves identically. */ export declare const normaliseNumbers: (input: string | readonly string[]) => string[]; /** * Splits delimited text into a header and rows, RFC 4180 style. * * A proper parser rather than `split(',')`, because a quoted field may contain * the delimiter, a newline, or an escaped quote -- and a currency-formatted * variable (`"1,299"`) is exactly the sort of value that appears in these files. * Splitting naively turns one such row into two bad ones. * * Values stay strings. The panel parsed with `dynamicTyping`, which coerced * numeric-looking cells to JavaScript numbers -- and that silently corrupted the * one column that matters: a 16-digit number exceeds `Number.MAX_SAFE_INTEGER` * and comes back with its last digits changed, while a number written with a * leading zero loses it. Keeping text as text avoids both. */ export declare const parseDelimited: (text: string, delimiter?: string) => { headers: string[]; rows: Record[]; }; /** * Turns parsed rows into receivers. * * Every column becomes a variable, including the recipient column itself -- which * is intentional and matches the panel: a template that greets someone by the * number they were messaged on still works. * * A row whose recipient column holds no digits is skipped rather than failing the * whole batch. In a file of ten thousand rows, a handful of blanks and a trailing * footer line are normal, and refusing the campaign over them would mean the * caller has to clean a file they may not control. The count comes back in * {@link ResolvedAudience.skipped} so the omission is visible rather than silent. */ export declare const buildReceivers: (rows: readonly Record[], recipientColumn: string, options?: { dedupe?: boolean; }) => ResolvedAudience; /** * Resolves any of the four audience shapes into one receiver list. * * De-duplicates by number unless `dedupe: false`. On by default because the cost * of a duplicate here is not a wasted row in a table -- it is the same person * receiving the same marketing message twice, billed twice, and more likely to * report the sender. A caller who genuinely wants two sends to one number can * say so. */ export declare const resolveAudience: (input: BulkAudienceInput) => ResolvedAudience; export type { CampaignReceiver };