ab-ecosystem-cpass 0.1.0 → 1.0.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.
- package/README.md +127 -25
- package/dist/client.d.ts +56 -1
- package/dist/client.js +76 -30
- package/dist/client.js.map +1 -1
- package/dist/http.d.ts +8 -0
- package/dist/http.js +10 -3
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.js +35 -2
- package/dist/index.js.map +1 -1
- package/dist/resources/audience/contact-notes.d.ts +51 -0
- package/dist/resources/audience/contact-notes.js +70 -0
- package/dist/resources/audience/contact-notes.js.map +1 -0
- package/dist/resources/audience/contact-tags.d.ts +43 -0
- package/dist/resources/audience/contact-tags.js +60 -0
- package/dist/resources/audience/contact-tags.js.map +1 -0
- package/dist/resources/audience/contacts.d.ts +76 -0
- package/dist/resources/audience/contacts.js +103 -0
- package/dist/resources/audience/contacts.js.map +1 -0
- package/dist/resources/audience/crm-triggers.d.ts +67 -0
- package/dist/resources/audience/crm-triggers.js +86 -0
- package/dist/resources/audience/crm-triggers.js.map +1 -0
- package/dist/resources/audience/custom-fields.d.ts +54 -0
- package/dist/resources/audience/custom-fields.js +71 -0
- package/dist/resources/audience/custom-fields.js.map +1 -0
- package/dist/resources/audience/export-history.d.ts +52 -0
- package/dist/resources/audience/export-history.js +67 -0
- package/dist/resources/audience/export-history.js.map +1 -0
- package/dist/resources/audience/import-history.d.ts +51 -0
- package/dist/resources/audience/import-history.js +66 -0
- package/dist/resources/audience/import-history.js.map +1 -0
- package/dist/resources/audience/segments.d.ts +49 -0
- package/dist/resources/audience/segments.js +66 -0
- package/dist/resources/audience/segments.js.map +1 -0
- package/dist/resources/audience/webhooks.d.ts +68 -0
- package/dist/resources/audience/webhooks.js +83 -0
- package/dist/resources/audience/webhooks.js.map +1 -0
- package/dist/resources/channels/activity.d.ts +25 -0
- package/dist/resources/channels/activity.js +34 -0
- package/dist/resources/channels/activity.js.map +1 -0
- package/dist/resources/channels/billing.d.ts +46 -0
- package/dist/resources/channels/billing.js +59 -0
- package/dist/resources/channels/billing.js.map +1 -0
- package/dist/resources/channels/channels.d.ts +115 -0
- package/dist/resources/channels/channels.js +129 -0
- package/dist/resources/channels/channels.js.map +1 -0
- package/dist/resources/channels/templates.d.ts +90 -0
- package/dist/resources/channels/templates.js +109 -0
- package/dist/resources/channels/templates.js.map +1 -0
- package/dist/resources/channels/wallet.d.ts +25 -0
- package/dist/resources/channels/wallet.js +34 -0
- package/dist/resources/channels/wallet.js.map +1 -0
- package/dist/resources/channels/webhooks.d.ts +60 -0
- package/dist/resources/channels/webhooks.js +79 -0
- package/dist/resources/channels/webhooks.js.map +1 -0
- package/dist/resources/paths.d.ts +12 -0
- package/dist/resources/paths.js +17 -0
- package/dist/resources/paths.js.map +1 -0
- package/dist/types/audience.d.ts +512 -0
- package/dist/types/audience.js +3 -0
- package/dist/types/audience.js.map +1 -0
- package/dist/types/channels.d.ts +383 -0
- package/dist/types/channels.js +22 -0
- package/dist/types/channels.js.map +1 -0
- package/dist/types/common.d.ts +55 -0
- package/dist/types/common.js +8 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/contact-filter.d.ts +55 -0
- package/dist/types/contact-filter.js +11 -0
- package/dist/types/contact-filter.js.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.js +21 -0
- package/dist/types/index.js.map +1 -0
- package/docs/audience/contact-notes.md +129 -0
- package/docs/audience/contact-tags.md +109 -0
- package/docs/audience/contacts.md +227 -0
- package/docs/audience/crm-triggers.md +240 -0
- package/docs/audience/custom-fields.md +174 -0
- package/docs/audience/exports.md +163 -0
- package/docs/audience/imports.md +161 -0
- package/docs/audience/segments.md +120 -0
- package/docs/audience/webhooks.md +167 -0
- package/docs/channels/activity.md +68 -0
- package/docs/channels/billing.md +112 -0
- package/docs/channels/channel-props.md +290 -0
- package/docs/channels/channels.md +199 -0
- package/docs/channels/templates.md +224 -0
- package/docs/channels/wallet.md +67 -0
- package/docs/channels/webhooks.md +152 -0
- package/docs/contact-filter.md +157 -0
- package/package.json +7 -3
- package/dist/resources/channels.d.ts +0 -10
- package/dist/resources/channels.js +0 -19
- package/dist/resources/channels.js.map +0 -1
- package/dist/types.d.ts +0 -70
- package/dist/types.js +0 -7
- package/dist/types.js.map +0 -1
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Channels service types: channels, their provider properties, templates,
|
|
3
|
+
* webhooks, and the three log feeds that hang off a channel.
|
|
4
|
+
* Mirrors `packages/contracts/src/channels/*`.
|
|
5
|
+
*/
|
|
6
|
+
import type { IsoDate, JsonObject, ListQuery } from './common';
|
|
7
|
+
/** Channel category, as stored in `meta.category`. */
|
|
8
|
+
export type ChannelType = 'whatsapp' | 'sms' | 'email' | 'rcs' | 'webchat';
|
|
9
|
+
/** Connection health reported by the provider. */
|
|
10
|
+
export type ChannelStatus = 'connected' | 'disconnected' | 'error';
|
|
11
|
+
/** Currencies a channel can be billed in. */
|
|
12
|
+
export type ChannelCurrency = 'USD' | 'EUR' | 'INR' | 'IDR';
|
|
13
|
+
export interface ChannelMeta {
|
|
14
|
+
/** The channel category: whatsapp, sms, email, rcs, webchat. */
|
|
15
|
+
category: string;
|
|
16
|
+
/** BSP or integration behind the channel, e.g. `EMBEDDED_PNCL_BILLING`. */
|
|
17
|
+
provider: string;
|
|
18
|
+
support_template: boolean;
|
|
19
|
+
show_template: boolean;
|
|
20
|
+
bypass_webhook_verification: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** Provider identifiers, flattened out of the channel's private auth block. */
|
|
23
|
+
export interface ChannelCloud {
|
|
24
|
+
instagram_id: string;
|
|
25
|
+
is_instagram_business_login: boolean;
|
|
26
|
+
waba_id: string;
|
|
27
|
+
/** Meta business id. */
|
|
28
|
+
business: string;
|
|
29
|
+
phone_number_id: string;
|
|
30
|
+
is_on_biz_app: boolean;
|
|
31
|
+
/** Graph API version the channel talks. */
|
|
32
|
+
version: string;
|
|
33
|
+
auto_read_receipt: number;
|
|
34
|
+
upgrade_eligibility: boolean;
|
|
35
|
+
/** `completed` once the number is registered with the BSP. */
|
|
36
|
+
wa_biz_registration: 'pending' | 'completed';
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Balances are stored as ten-thousandths and divided down here, to four decimal
|
|
40
|
+
* places. `'NULL'` when the agency has hidden the wallet from this caller.
|
|
41
|
+
*/
|
|
42
|
+
export interface ChannelWallet {
|
|
43
|
+
balance: number | 'NULL';
|
|
44
|
+
currency: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A channel as the list and detail endpoints return it. Credentials and the
|
|
48
|
+
* private auth block are stripped; what remains is safe to hand a console.
|
|
49
|
+
*/
|
|
50
|
+
export interface Channel {
|
|
51
|
+
id: string;
|
|
52
|
+
/** Enabled/disabled by the owner -- not the connection state. */
|
|
53
|
+
active: boolean;
|
|
54
|
+
ecom?: {
|
|
55
|
+
store_status: boolean;
|
|
56
|
+
store?: string;
|
|
57
|
+
};
|
|
58
|
+
basic_details: {
|
|
59
|
+
name: string;
|
|
60
|
+
color_code: string;
|
|
61
|
+
channel_identity: string;
|
|
62
|
+
};
|
|
63
|
+
meta: ChannelMeta;
|
|
64
|
+
wallet: ChannelWallet;
|
|
65
|
+
/** Messages per second the campaign runner may push. Defaults to 10. */
|
|
66
|
+
campaign_tps: number;
|
|
67
|
+
upgraded_webhook_listener: boolean;
|
|
68
|
+
cloud: ChannelCloud;
|
|
69
|
+
/** Reachable only over the API, with no console inbox. */
|
|
70
|
+
api_only: boolean;
|
|
71
|
+
/** Reachable only from the CRM. */
|
|
72
|
+
crm_only: boolean;
|
|
73
|
+
mm_lite_enabled: boolean;
|
|
74
|
+
/** Short-lived encrypted handle for the channel, minted per response. */
|
|
75
|
+
access_token: string;
|
|
76
|
+
[key: string]: unknown;
|
|
77
|
+
}
|
|
78
|
+
/** `channels.get` wraps its payload, and returns `{ data: {} }` when nothing matches. */
|
|
79
|
+
export interface ChannelResponse {
|
|
80
|
+
data: Channel | Record<string, never>;
|
|
81
|
+
}
|
|
82
|
+
/** `search` matches the channel name and its identity (number, handle, address). */
|
|
83
|
+
export interface ListChannelsQuery extends ListQuery {
|
|
84
|
+
/** Quick filter: channel category. */
|
|
85
|
+
type?: ChannelType;
|
|
86
|
+
/** Quick filter: enabled/disabled by the owner, not the connection state. */
|
|
87
|
+
active?: boolean;
|
|
88
|
+
/** Quick filter: connection health. */
|
|
89
|
+
status?: ChannelStatus;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* What the console may change about a channel itself. At least one field is
|
|
93
|
+
* required. Everything else about a channel is provider state and moves
|
|
94
|
+
* through the property endpoints.
|
|
95
|
+
*/
|
|
96
|
+
export interface UpdateChannelDetailsInput {
|
|
97
|
+
/** 1..120 characters. */
|
|
98
|
+
name?: string;
|
|
99
|
+
/** Hex colour, `#075E54` or `#fff`. */
|
|
100
|
+
color?: string;
|
|
101
|
+
/**
|
|
102
|
+
* Only moves on a WhatsApp channel with an empty wallet: a balance carried
|
|
103
|
+
* across a switch would be worth a different amount on the other side.
|
|
104
|
+
* Rejected with `409 wallet_not_empty` otherwise.
|
|
105
|
+
*/
|
|
106
|
+
currency?: ChannelCurrency;
|
|
107
|
+
}
|
|
108
|
+
/** Returned by the operations that report success without a body of their own. */
|
|
109
|
+
export interface ChannelActionResult {
|
|
110
|
+
success: true;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Readable channel properties. Each one reads something that lives with the
|
|
114
|
+
* provider (Meta Graph, mostly) or in local configuration, rather than on the
|
|
115
|
+
* channel document.
|
|
116
|
+
*/
|
|
117
|
+
export type ChannelGetProp = 'general' | 'business_profile' | 'message_analytics' | 'business_compliance' | 'business_commerce' | 'qr_code' | 'redirect_url' | 'fetch_channel_queue' | 'recharge_url' | 'channel_config' | 'conversation_automation' | 'token';
|
|
118
|
+
/** Writable channel properties. */
|
|
119
|
+
export type ChannelSetProp = 'business_profile' | 'profile_pic' | 'business_compliance' | 'resumable_upload' | 'business_commerce' | 'qr_code' | 'upload_media' | 'wa_pin_update' | 'wa_deregister' | 'wa_biz_update' | 'webhook_listener_update' | 'wa_request_otp' | 'migrate_number' | 'wa_submit_otp' | 'test_message' | 'conversation_analytics' | 'conversation_automation' | 'whatsapp_business_encryption' | 'delete_channel_queue' | 'enable_whatsapp_direct' | 'disable_whatsapp_direct';
|
|
120
|
+
/** Meta Business Suite pages `redirect_url` can hand the console a link to. */
|
|
121
|
+
export type ChannelRedirectTarget = 'meta_catalog_manager' | 'link_whatsApp_catalog' | 'wa_manager' | 'business';
|
|
122
|
+
/**
|
|
123
|
+
* Props whose request body is the raw file bytes rather than JSON. Pass a
|
|
124
|
+
* `Blob`, `ArrayBuffer` or `Uint8Array` to `channels.setProp` for these, and a
|
|
125
|
+
* `contentType`; anything else is sent as JSON.
|
|
126
|
+
*/
|
|
127
|
+
export declare const BINARY_CHANNEL_PROPS: readonly ["profile_pic", "resumable_upload", "upload_media"];
|
|
128
|
+
export type BinaryChannelProp = (typeof BINARY_CHANNEL_PROPS)[number];
|
|
129
|
+
/**
|
|
130
|
+
* Every property call answers in this envelope. `data` is whatever the provider
|
|
131
|
+
* returned and is deliberately untyped -- its shape follows `prop`.
|
|
132
|
+
*/
|
|
133
|
+
export interface ChannelPropResponse<T = unknown> {
|
|
134
|
+
data: T;
|
|
135
|
+
/** Echo of the property that was read or written. */
|
|
136
|
+
prop: string;
|
|
137
|
+
/** Echo of the channel id. */
|
|
138
|
+
channel: string;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Not every channel category supports every property. WhatsApp supports all of
|
|
142
|
+
* them; RCS reads `fetch_channel_queue`, `recharge_url` and `token`, and writes
|
|
143
|
+
* `test_message`. Anything else answers `400 unsupported_channel_prop`.
|
|
144
|
+
*/
|
|
145
|
+
export type ChannelPropBody = JsonObject | Blob | ArrayBuffer | Uint8Array;
|
|
146
|
+
/** Review state. `draft` is local only; the rest mirror Meta. */
|
|
147
|
+
export type TemplateStatus = 'draft' | 'pending' | 'approved' | 'rejected';
|
|
148
|
+
export type TemplateCategory = 'MARKETING' | 'UTILITY' | 'AUTHENTICATION';
|
|
149
|
+
/** `AUTO_GENERATED` templates are created by the platform, not by a caller. */
|
|
150
|
+
export type TemplateSource = 'MANUAL' | 'AUTO_GENERATED';
|
|
151
|
+
/** Whether placeholders are `{{1}}` or `{{name}}`. */
|
|
152
|
+
export type TemplateParameterFormat = 'POSITIONAL' | 'NAMED';
|
|
153
|
+
/** Click-to-WhatsApp ad attribution, when the template is tied to one. */
|
|
154
|
+
export interface TemplateAdDetails {
|
|
155
|
+
ad_account: string;
|
|
156
|
+
ad_campaign: string;
|
|
157
|
+
ad_set: string;
|
|
158
|
+
ad_id: string;
|
|
159
|
+
}
|
|
160
|
+
export interface Template {
|
|
161
|
+
id: string;
|
|
162
|
+
channelId: string;
|
|
163
|
+
type: 'whatsapp';
|
|
164
|
+
status: TemplateStatus;
|
|
165
|
+
source: TemplateSource;
|
|
166
|
+
/** Meta's own id; absent while the template is still a local draft. */
|
|
167
|
+
templateId?: string;
|
|
168
|
+
name: string;
|
|
169
|
+
category: TemplateCategory;
|
|
170
|
+
subCategory: string;
|
|
171
|
+
parameterFormat: TemplateParameterFormat;
|
|
172
|
+
/** BCP-47 code, e.g. `en_US`. */
|
|
173
|
+
language: string;
|
|
174
|
+
/** Identity of the template within the channel: name plus language. */
|
|
175
|
+
hash: string;
|
|
176
|
+
adDetails: TemplateAdDetails;
|
|
177
|
+
/** Meta's component array: HEADER, BODY, FOOTER, BUTTONS. */
|
|
178
|
+
components: JsonObject[];
|
|
179
|
+
/** The last payload sent to Meta. */
|
|
180
|
+
payload?: JsonObject;
|
|
181
|
+
extra?: JsonObject;
|
|
182
|
+
createdAt: IsoDate;
|
|
183
|
+
updatedAt: IsoDate;
|
|
184
|
+
}
|
|
185
|
+
export interface CreateTemplateInput {
|
|
186
|
+
/** Lowercase letters, digits and underscores, 1..512 characters. */
|
|
187
|
+
name: string;
|
|
188
|
+
category: TemplateCategory;
|
|
189
|
+
/** Up to 120 characters. Default `''`. */
|
|
190
|
+
subCategory?: string;
|
|
191
|
+
/** 2..15 characters, e.g. `en` or `en_US`. */
|
|
192
|
+
language: string;
|
|
193
|
+
/** Default `'POSITIONAL'`. */
|
|
194
|
+
parameterFormat?: TemplateParameterFormat;
|
|
195
|
+
/** Default `'MANUAL'`. */
|
|
196
|
+
source?: TemplateSource;
|
|
197
|
+
/** At least one component. */
|
|
198
|
+
components: JsonObject[];
|
|
199
|
+
payload?: JsonObject;
|
|
200
|
+
extra?: JsonObject;
|
|
201
|
+
adDetails?: Partial<TemplateAdDetails>;
|
|
202
|
+
/** Submit to Meta straight away instead of keeping a local draft. Default `false`. */
|
|
203
|
+
applyForApproval?: boolean;
|
|
204
|
+
}
|
|
205
|
+
/** At least one field is required. */
|
|
206
|
+
export type UpdateTemplateInput = Partial<CreateTemplateInput> & {
|
|
207
|
+
status?: TemplateStatus;
|
|
208
|
+
};
|
|
209
|
+
/** `search` matches the template name and sub-category. */
|
|
210
|
+
export interface ListTemplatesQuery extends ListQuery {
|
|
211
|
+
status?: TemplateStatus;
|
|
212
|
+
category?: TemplateCategory;
|
|
213
|
+
parameterFormat?: TemplateParameterFormat;
|
|
214
|
+
/** Exact language code. */
|
|
215
|
+
language?: string;
|
|
216
|
+
}
|
|
217
|
+
/** What a `sync` pulled in from Meta. */
|
|
218
|
+
export interface TemplateSyncResult {
|
|
219
|
+
/** Templates Meta returned. */
|
|
220
|
+
fetched: number;
|
|
221
|
+
created: number;
|
|
222
|
+
updated: number;
|
|
223
|
+
/** Returned by Meta but not storable, e.g. an unknown category. */
|
|
224
|
+
skipped: number;
|
|
225
|
+
}
|
|
226
|
+
/** Channel events a webhook can subscribe to. */
|
|
227
|
+
export type ChannelWebhookEvent = 'incoming' | 'sent' | 'delivered' | 'read' | 'failed' | 'deleted' | 'template' | 'account' | 'phone_number' | 'calls';
|
|
228
|
+
export declare const CHANNEL_WEBHOOK_EVENTS: readonly ChannelWebhookEvent[];
|
|
229
|
+
/** Where the webhook was created from. */
|
|
230
|
+
export type ChannelWebhookSource = 'PANEL' | 'API';
|
|
231
|
+
/**
|
|
232
|
+
* Audit trail: who created or last changed the webhook, and from where. Set by
|
|
233
|
+
* the service from the caller's identity and IP, never by the caller.
|
|
234
|
+
*/
|
|
235
|
+
export interface ChannelWebhookMeta {
|
|
236
|
+
source: ChannelWebhookSource;
|
|
237
|
+
createdBy?: string;
|
|
238
|
+
createdIp?: string;
|
|
239
|
+
updatedBy?: string;
|
|
240
|
+
updatedIp?: string;
|
|
241
|
+
}
|
|
242
|
+
export interface ChannelWebhook {
|
|
243
|
+
id: string;
|
|
244
|
+
channelId: string;
|
|
245
|
+
title: string;
|
|
246
|
+
active: boolean;
|
|
247
|
+
events: ChannelWebhookEvent[];
|
|
248
|
+
url: string;
|
|
249
|
+
meta?: ChannelWebhookMeta;
|
|
250
|
+
createdAt: IsoDate;
|
|
251
|
+
updatedAt: IsoDate;
|
|
252
|
+
}
|
|
253
|
+
export interface CreateChannelWebhookInput {
|
|
254
|
+
/** 1..120 characters. Default `'CRM Channel Webhook'`. */
|
|
255
|
+
title?: string;
|
|
256
|
+
/** Valid absolute URL, up to 2048 characters. */
|
|
257
|
+
url: string;
|
|
258
|
+
/** At least one event. */
|
|
259
|
+
events: ChannelWebhookEvent[];
|
|
260
|
+
/** Default `true`. */
|
|
261
|
+
active?: boolean;
|
|
262
|
+
}
|
|
263
|
+
/** At least one field is required. */
|
|
264
|
+
export type UpdateChannelWebhookInput = Partial<CreateChannelWebhookInput>;
|
|
265
|
+
/** `search` matches the webhook title and URL. */
|
|
266
|
+
export interface ListChannelWebhooksQuery extends ListQuery {
|
|
267
|
+
/** Quick filter: enabled/disabled. */
|
|
268
|
+
active?: boolean;
|
|
269
|
+
/** Quick filter: webhooks subscribed to this event. */
|
|
270
|
+
event?: ChannelWebhookEvent;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* A window in unix seconds. `0` on either end means "no bound", the way the
|
|
274
|
+
* console sends it. Serialised to JSON by the SDK before it goes on the query
|
|
275
|
+
* string: `range={"start":1767225600,"end":1769817600}`.
|
|
276
|
+
*/
|
|
277
|
+
export interface UnixRange {
|
|
278
|
+
start: number;
|
|
279
|
+
end: number;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* `summary` totals by currency (across all channels) or by message category
|
|
283
|
+
* (one channel); `day_wise` totals per calendar day.
|
|
284
|
+
*/
|
|
285
|
+
export type BillingStat = 'summary' | 'day_wise';
|
|
286
|
+
/** One billed conversation. */
|
|
287
|
+
export interface BillingLog {
|
|
288
|
+
id: string;
|
|
289
|
+
/** The conversation the charge belongs to. */
|
|
290
|
+
chatId?: string;
|
|
291
|
+
/** The recipient, as the channel addresses them. */
|
|
292
|
+
identifier: string;
|
|
293
|
+
deduction: {
|
|
294
|
+
/** `false` for free-tier conversations, which are logged but not charged. */
|
|
295
|
+
billable: boolean;
|
|
296
|
+
amount: number;
|
|
297
|
+
currency: string;
|
|
298
|
+
};
|
|
299
|
+
/** Provider detail: recipient country, category, template, campaign, message id. */
|
|
300
|
+
meta?: JsonObject;
|
|
301
|
+
createdAt: IsoDate;
|
|
302
|
+
updatedAt: IsoDate;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* `search` matches the recipient identifier and the `meta` fields: recipient,
|
|
306
|
+
* category, country and message id.
|
|
307
|
+
*/
|
|
308
|
+
export interface ListBillingLogsQuery extends ListQuery {
|
|
309
|
+
/** Restrict to a period. */
|
|
310
|
+
range?: UnixRange;
|
|
311
|
+
/** Return aggregates instead of rows; changes the response shape. */
|
|
312
|
+
stat?: BillingStat;
|
|
313
|
+
/** Quick filter: templates the conversation was billed against. */
|
|
314
|
+
template?: string[];
|
|
315
|
+
/** Quick filter: recipient country codes. */
|
|
316
|
+
country?: string[];
|
|
317
|
+
/** Quick filter: campaigns that produced the conversation. */
|
|
318
|
+
campaign?: string[];
|
|
319
|
+
}
|
|
320
|
+
export interface BillingStatRow {
|
|
321
|
+
/** Currency, category or date, depending on the requested `stat`. */
|
|
322
|
+
group: string;
|
|
323
|
+
totalRecords: number;
|
|
324
|
+
totalDeductionAmount: number;
|
|
325
|
+
}
|
|
326
|
+
export interface BillingStats {
|
|
327
|
+
data: BillingStatRow[];
|
|
328
|
+
stat: BillingStat;
|
|
329
|
+
}
|
|
330
|
+
/** Money into the channel wallet, or out of it. */
|
|
331
|
+
export type WalletLogType = 'credit' | 'debit';
|
|
332
|
+
export interface WalletLog {
|
|
333
|
+
id: string;
|
|
334
|
+
type: WalletLogType;
|
|
335
|
+
currency: string;
|
|
336
|
+
note: string;
|
|
337
|
+
/** Stored as ten-thousandths, like the raw channel wallet balance. */
|
|
338
|
+
amount: number;
|
|
339
|
+
startBalance: number;
|
|
340
|
+
endBalance: number;
|
|
341
|
+
status: string;
|
|
342
|
+
category: string;
|
|
343
|
+
createdAt: IsoDate;
|
|
344
|
+
updatedAt: IsoDate;
|
|
345
|
+
}
|
|
346
|
+
/** `search` matches the note, the category and the status. */
|
|
347
|
+
export interface ListWalletLogsQuery extends ListQuery {
|
|
348
|
+
/** Quick filter: credits or debits only. */
|
|
349
|
+
type?: WalletLogType;
|
|
350
|
+
/** Restrict to a period. */
|
|
351
|
+
range?: UnixRange;
|
|
352
|
+
}
|
|
353
|
+
/** Who caused the entry. */
|
|
354
|
+
export type ActivitySource = 'user' | 'agency' | 'system';
|
|
355
|
+
/** Wallet movements share the feed with ordinary channel activity. */
|
|
356
|
+
export type ActivityLogType = 'wallet' | 'activity';
|
|
357
|
+
export interface ActivityLog {
|
|
358
|
+
id: string;
|
|
359
|
+
source: {
|
|
360
|
+
type?: ActivitySource;
|
|
361
|
+
id?: string;
|
|
362
|
+
};
|
|
363
|
+
log: {
|
|
364
|
+
type?: ActivityLogType;
|
|
365
|
+
/** Machine name, e.g. `template.approved`. */
|
|
366
|
+
event: string;
|
|
367
|
+
/** Human-readable line for the feed. */
|
|
368
|
+
message: string;
|
|
369
|
+
};
|
|
370
|
+
createdAt: IsoDate;
|
|
371
|
+
updatedAt: IsoDate;
|
|
372
|
+
}
|
|
373
|
+
/** `search` matches the event name and the message. */
|
|
374
|
+
export interface ListActivityLogsQuery extends ListQuery {
|
|
375
|
+
/** Quick filter: wallet movements or general activity. */
|
|
376
|
+
type?: ActivityLogType;
|
|
377
|
+
/** Quick filter: entries caused by the user, the agency, or the platform. */
|
|
378
|
+
source?: ActivitySource;
|
|
379
|
+
/** Quick filter: a single event name, 1..120 characters. */
|
|
380
|
+
event?: string;
|
|
381
|
+
/** Restrict to a period. */
|
|
382
|
+
range?: UnixRange;
|
|
383
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CHANNEL_WEBHOOK_EVENTS = exports.BINARY_CHANNEL_PROPS = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Props whose request body is the raw file bytes rather than JSON. Pass a
|
|
6
|
+
* `Blob`, `ArrayBuffer` or `Uint8Array` to `channels.setProp` for these, and a
|
|
7
|
+
* `contentType`; anything else is sent as JSON.
|
|
8
|
+
*/
|
|
9
|
+
exports.BINARY_CHANNEL_PROPS = ['profile_pic', 'resumable_upload', 'upload_media'];
|
|
10
|
+
exports.CHANNEL_WEBHOOK_EVENTS = [
|
|
11
|
+
'incoming',
|
|
12
|
+
'sent',
|
|
13
|
+
'delivered',
|
|
14
|
+
'read',
|
|
15
|
+
'failed',
|
|
16
|
+
'deleted',
|
|
17
|
+
'template',
|
|
18
|
+
'account',
|
|
19
|
+
'phone_number',
|
|
20
|
+
'calls',
|
|
21
|
+
];
|
|
22
|
+
//# sourceMappingURL=channels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channels.js","sourceRoot":"","sources":["../../src/types/channels.ts"],"names":[],"mappings":";;;AA8KA;;;;GAIG;AACU,QAAA,oBAAoB,GAAG,CAAC,aAAa,EAAE,kBAAkB,EAAE,cAAc,CAAU,CAAC;AAoIpF,QAAA,sBAAsB,GAAmC;IACpE,UAAU;IACV,MAAM;IACN,WAAW;IACX,MAAM;IACN,QAAQ;IACR,SAAS;IACT,UAAU;IACV,SAAS;IACT,cAAc;IACd,OAAO;CACR,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shapes shared by every module. Declared here rather than imported from
|
|
3
|
+
* `@crm/contracts` so the published package has no private dependencies; they
|
|
4
|
+
* are kept in step with the zod schemas in `packages/contracts/src/common.ts`.
|
|
5
|
+
*/
|
|
6
|
+
/** A 24-character hex MongoDB id. Aliased for readability, not enforced. */
|
|
7
|
+
export type ObjectId = string;
|
|
8
|
+
/** An ISO-8601 timestamp string, e.g. `2026-03-14T09:21:55.412Z`. */
|
|
9
|
+
export type IsoDate = string;
|
|
10
|
+
/** An untyped JSON object, as a `Record<string, unknown>`. */
|
|
11
|
+
export type JsonObject = Record<string, unknown>;
|
|
12
|
+
/**
|
|
13
|
+
* Cursor pagination. Used by the two endpoints that page through rows written
|
|
14
|
+
* by the platform rather than by a caller: contact notes and audience webhooks.
|
|
15
|
+
*/
|
|
16
|
+
export interface PageQuery {
|
|
17
|
+
/** 1..100, default 50. */
|
|
18
|
+
limit: number;
|
|
19
|
+
/** Opaque marker from the previous page's `nextCursor`. Omit for the first page. */
|
|
20
|
+
cursor?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface Page<T> {
|
|
23
|
+
data: T[];
|
|
24
|
+
/** `null` on the last page. */
|
|
25
|
+
nextCursor: string | null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Offset pagination with free-text search, used by every other list endpoint.
|
|
29
|
+
* Which fields `search` matches is per resource and documented with it.
|
|
30
|
+
*/
|
|
31
|
+
export interface ListQuery {
|
|
32
|
+
/** 1-based, default 1. */
|
|
33
|
+
page: number;
|
|
34
|
+
/** Rows per page, 1..100, default 25. */
|
|
35
|
+
rows: number;
|
|
36
|
+
/** Trimmed, 1..120 characters. Omit for no search. */
|
|
37
|
+
search?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface PaginationMeta {
|
|
40
|
+
page: number;
|
|
41
|
+
rows: number;
|
|
42
|
+
/** Rows matching the filter, across all pages. */
|
|
43
|
+
total: number;
|
|
44
|
+
/** Number of pages for `total` at `rows` per page; at least 1. */
|
|
45
|
+
pages: number;
|
|
46
|
+
}
|
|
47
|
+
export interface Paginated<T> {
|
|
48
|
+
data: T[];
|
|
49
|
+
pagination: PaginationMeta;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Every list method takes its query as a partial: the server applies the
|
|
53
|
+
* defaults above for anything left out.
|
|
54
|
+
*/
|
|
55
|
+
export type QueryOf<T> = Partial<T>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shapes shared by every module. Declared here rather than imported from
|
|
4
|
+
* `@crm/contracts` so the published package has no private dependencies; they
|
|
5
|
+
* are kept in step with the zod schemas in `packages/contracts/src/common.ts`.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":";AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The contact filter DSL.
|
|
3
|
+
*
|
|
4
|
+
* One vocabulary, four callers: `GET /contacts?filter=`, a saved `Segment`, a
|
|
5
|
+
* `CrmTrigger`'s `filters`, and an export's `config.filter`. Conditions are a
|
|
6
|
+
* flat list rather than a tree -- `and` binds tighter than `or`, so the list is
|
|
7
|
+
* split on every `or`, each run is `and`ed, and the runs are `or`ed together.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Comparison vocabulary. Which of these a condition may use depends on its
|
|
11
|
+
* `field_type`; combinations that have no meaning are rejected by the server.
|
|
12
|
+
*/
|
|
13
|
+
export type ContactFilterCondition = 'equal to' | 'not equal to' | 'start with' | 'end with' | 'contains' | 'does not contains' | 'is empty' | 'is not empty' | 'greater than' | 'greater than or equal to' | 'less than' | 'less than or equal to' | 'is' | 'after' | 'before' | 'between' | 'within' | 'is null' | 'is not null' | 'exist' | 'does not exist';
|
|
14
|
+
/** `string` is not a custom field data type; clients send it for untyped values. */
|
|
15
|
+
export type ContactFilterFieldType = 'string' | 'text' | 'url' | 'email' | 'phone' | 'country' | 'language' | 'timezone' | 'dial_code' | 'dropdown' | 'multi_select' | 'textarea' | 'checkbox' | 'address' | 'location' | 'attachment' | 'number' | 'decimal' | 'amount' | 'percent' | 'date' | 'timestamp' | 'periodic_time';
|
|
16
|
+
/** Anchors a relative `within` window against the moment the query runs. */
|
|
17
|
+
export type ContactFilterDirection = 'LAST' | 'TODAY' | 'NEXT';
|
|
18
|
+
/** The units `within` counts in. */
|
|
19
|
+
export type ContactFilterTimeUnit = 'days' | 'weeks' | 'months' | 'years' | 'hours' | 'minutes';
|
|
20
|
+
/** Joins a condition to the ones before it. `null` marks the head of the list. */
|
|
21
|
+
export type ContactFilterOperator = 'and' | 'or';
|
|
22
|
+
export interface ContactFilterEntry {
|
|
23
|
+
/** Client-side row id; echoed back untouched. */
|
|
24
|
+
id?: number;
|
|
25
|
+
/** `null` on the first condition, `and`/`or` on the rest. Default `null`. */
|
|
26
|
+
operator?: ContactFilterOperator | null;
|
|
27
|
+
/** A custom field slug, or one of the `SYSTEM_*` fields the translator knows. */
|
|
28
|
+
field_id: string;
|
|
29
|
+
field_type: ContactFilterFieldType;
|
|
30
|
+
condition: ContactFilterCondition;
|
|
31
|
+
/** Empty string where the direction does not apply. Default `''`. */
|
|
32
|
+
direction?: ContactFilterDirection | '';
|
|
33
|
+
/** Empty string where the unit does not apply. Default `''`. */
|
|
34
|
+
timeUnit?: ContactFilterTimeUnit | '';
|
|
35
|
+
/**
|
|
36
|
+
* Scalar for most conditions. `is`/`after`/`before`/`between` on a date carry
|
|
37
|
+
* a JSON array string -- `between` reads two entries, the rest read the first.
|
|
38
|
+
* Omitted for the conditions that take no value (`is empty`, `exist`, ...).
|
|
39
|
+
*/
|
|
40
|
+
value?: unknown;
|
|
41
|
+
/** Minutes-as-milliseconds shift from UTC midnight to the caller's midnight. Default `0`. */
|
|
42
|
+
offset?: number;
|
|
43
|
+
/** `periodic_time` fields need their period to pick a comparison. */
|
|
44
|
+
props?: {
|
|
45
|
+
period?: 'daily' | 'weekly' | 'monthly' | 'annually';
|
|
46
|
+
};
|
|
47
|
+
/** UI hint for whether the condition takes a value; the server ignores it. */
|
|
48
|
+
requireInput?: boolean;
|
|
49
|
+
}
|
|
50
|
+
export interface ContactFilter {
|
|
51
|
+
/** Free-form tag for where the filter came from. Default `'sheet'`. */
|
|
52
|
+
type?: string;
|
|
53
|
+
/** At most 50 conditions. Default `[]`, which matches every contact. */
|
|
54
|
+
conditions?: ContactFilterEntry[];
|
|
55
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The contact filter DSL.
|
|
4
|
+
*
|
|
5
|
+
* One vocabulary, four callers: `GET /contacts?filter=`, a saved `Segment`, a
|
|
6
|
+
* `CrmTrigger`'s `filters`, and an export's `config.filter`. Conditions are a
|
|
7
|
+
* flat list rather than a tree -- `and` binds tighter than `or`, so the list is
|
|
8
|
+
* split on every `or`, each run is `and`ed, and the runs are `or`ed together.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
//# sourceMappingURL=contact-filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contact-filter.js","sourceRoot":"","sources":["../../src/types/contact-filter.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./common"), exports);
|
|
18
|
+
__exportStar(require("./contact-filter"), exports);
|
|
19
|
+
__exportStar(require("./audience"), exports);
|
|
20
|
+
__exportStar(require("./channels"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,mDAAiC;AACjC,6CAA2B;AAC3B,6CAA2B"}
|