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.
Files changed (97) hide show
  1. package/README.md +127 -25
  2. package/dist/client.d.ts +56 -1
  3. package/dist/client.js +76 -30
  4. package/dist/client.js.map +1 -1
  5. package/dist/http.d.ts +8 -0
  6. package/dist/http.js +10 -3
  7. package/dist/http.js.map +1 -1
  8. package/dist/index.d.ts +16 -1
  9. package/dist/index.js +35 -2
  10. package/dist/index.js.map +1 -1
  11. package/dist/resources/audience/contact-notes.d.ts +51 -0
  12. package/dist/resources/audience/contact-notes.js +70 -0
  13. package/dist/resources/audience/contact-notes.js.map +1 -0
  14. package/dist/resources/audience/contact-tags.d.ts +43 -0
  15. package/dist/resources/audience/contact-tags.js +60 -0
  16. package/dist/resources/audience/contact-tags.js.map +1 -0
  17. package/dist/resources/audience/contacts.d.ts +76 -0
  18. package/dist/resources/audience/contacts.js +103 -0
  19. package/dist/resources/audience/contacts.js.map +1 -0
  20. package/dist/resources/audience/crm-triggers.d.ts +67 -0
  21. package/dist/resources/audience/crm-triggers.js +86 -0
  22. package/dist/resources/audience/crm-triggers.js.map +1 -0
  23. package/dist/resources/audience/custom-fields.d.ts +54 -0
  24. package/dist/resources/audience/custom-fields.js +71 -0
  25. package/dist/resources/audience/custom-fields.js.map +1 -0
  26. package/dist/resources/audience/export-history.d.ts +52 -0
  27. package/dist/resources/audience/export-history.js +67 -0
  28. package/dist/resources/audience/export-history.js.map +1 -0
  29. package/dist/resources/audience/import-history.d.ts +51 -0
  30. package/dist/resources/audience/import-history.js +66 -0
  31. package/dist/resources/audience/import-history.js.map +1 -0
  32. package/dist/resources/audience/segments.d.ts +49 -0
  33. package/dist/resources/audience/segments.js +66 -0
  34. package/dist/resources/audience/segments.js.map +1 -0
  35. package/dist/resources/audience/webhooks.d.ts +68 -0
  36. package/dist/resources/audience/webhooks.js +83 -0
  37. package/dist/resources/audience/webhooks.js.map +1 -0
  38. package/dist/resources/channels/activity.d.ts +25 -0
  39. package/dist/resources/channels/activity.js +34 -0
  40. package/dist/resources/channels/activity.js.map +1 -0
  41. package/dist/resources/channels/billing.d.ts +46 -0
  42. package/dist/resources/channels/billing.js +59 -0
  43. package/dist/resources/channels/billing.js.map +1 -0
  44. package/dist/resources/channels/channels.d.ts +115 -0
  45. package/dist/resources/channels/channels.js +129 -0
  46. package/dist/resources/channels/channels.js.map +1 -0
  47. package/dist/resources/channels/templates.d.ts +90 -0
  48. package/dist/resources/channels/templates.js +109 -0
  49. package/dist/resources/channels/templates.js.map +1 -0
  50. package/dist/resources/channels/wallet.d.ts +25 -0
  51. package/dist/resources/channels/wallet.js +34 -0
  52. package/dist/resources/channels/wallet.js.map +1 -0
  53. package/dist/resources/channels/webhooks.d.ts +60 -0
  54. package/dist/resources/channels/webhooks.js +79 -0
  55. package/dist/resources/channels/webhooks.js.map +1 -0
  56. package/dist/resources/paths.d.ts +12 -0
  57. package/dist/resources/paths.js +17 -0
  58. package/dist/resources/paths.js.map +1 -0
  59. package/dist/types/audience.d.ts +512 -0
  60. package/dist/types/audience.js +3 -0
  61. package/dist/types/audience.js.map +1 -0
  62. package/dist/types/channels.d.ts +383 -0
  63. package/dist/types/channels.js +22 -0
  64. package/dist/types/channels.js.map +1 -0
  65. package/dist/types/common.d.ts +55 -0
  66. package/dist/types/common.js +8 -0
  67. package/dist/types/common.js.map +1 -0
  68. package/dist/types/contact-filter.d.ts +55 -0
  69. package/dist/types/contact-filter.js +11 -0
  70. package/dist/types/contact-filter.js.map +1 -0
  71. package/dist/types/index.d.ts +4 -0
  72. package/dist/types/index.js +21 -0
  73. package/dist/types/index.js.map +1 -0
  74. package/docs/audience/contact-notes.md +129 -0
  75. package/docs/audience/contact-tags.md +109 -0
  76. package/docs/audience/contacts.md +227 -0
  77. package/docs/audience/crm-triggers.md +240 -0
  78. package/docs/audience/custom-fields.md +174 -0
  79. package/docs/audience/exports.md +163 -0
  80. package/docs/audience/imports.md +161 -0
  81. package/docs/audience/segments.md +120 -0
  82. package/docs/audience/webhooks.md +167 -0
  83. package/docs/channels/activity.md +68 -0
  84. package/docs/channels/billing.md +112 -0
  85. package/docs/channels/channel-props.md +290 -0
  86. package/docs/channels/channels.md +199 -0
  87. package/docs/channels/templates.md +224 -0
  88. package/docs/channels/wallet.md +67 -0
  89. package/docs/channels/webhooks.md +152 -0
  90. package/docs/contact-filter.md +157 -0
  91. package/package.json +7 -3
  92. package/dist/resources/channels.d.ts +0 -10
  93. package/dist/resources/channels.js +0 -19
  94. package/dist/resources/channels.js.map +0 -1
  95. package/dist/types.d.ts +0 -70
  96. package/dist/types.js +0 -7
  97. package/dist/types.js.map +0 -1
package/README.md CHANGED
@@ -1,6 +1,14 @@
1
- # CRM SDK
1
+ # ab-ecosystem-cpass
2
2
 
3
- JavaScript/TypeScript client for the CRM gateway.
3
+ JavaScript/TypeScript client for the CRM gateway. Covers the **audience** module
4
+ (contacts and everything hanging off them) and the **channels** module
5
+ (connections, templates, webhooks and the log feeds).
6
+
7
+ - [Install](#install)
8
+ - [Quick start](#quick-start)
9
+ - [Client options](#client-options)
10
+ - [Conventions](#conventions) — pagination, search, filters, scopes, errors
11
+ - [Modules](#modules) — one reference page per resource
4
12
 
5
13
  ## Install
6
14
 
@@ -8,7 +16,10 @@ JavaScript/TypeScript client for the CRM gateway.
8
16
  npm install ab-ecosystem-cpass
9
17
  ```
10
18
 
11
- ## Usage
19
+ Node 18 or newer. The package is dependency-free and ships its own types; it
20
+ uses the global `fetch`, or one you pass in.
21
+
22
+ ## Quick start
12
23
 
13
24
  ```ts
14
25
  import { CrmClient } from 'ab-ecosystem-cpass';
@@ -19,38 +30,45 @@ const crm = new CrmClient({
19
30
  authToken: '<ecosystem bearer token>',
20
31
  });
21
32
 
22
- const { data, nextCursor } = await crm.channels.list({ limit: 20 });
23
- const channel = await crm.channels.get('64ba85075f89cb9bbe30d749');
33
+ // Audience
34
+ const contacts = await crm.contacts.list({ search: 'acme', rows: 50 });
35
+ const tag = await crm.contactTags.create({ name: 'VIP', color: '#f59e0b' });
36
+ await crm.contacts.update(contacts.data[0].id, { tags: [tag.id] });
37
+
38
+ // Channels
39
+ const channels = await crm.channels.list({ type: 'whatsapp', active: true });
40
+ const templates = await crm.templates.list(channels.data[0].id, { status: 'approved' });
24
41
  ```
25
42
 
26
- Every request carries `authorization: Bearer <authToken>`, `client-id` and `origin`.
43
+ Every request carries `authorization: Bearer <authToken>`, `client-id` and
44
+ `origin`.
45
+
46
+ ## Client options
27
47
 
28
48
  | Option | Required | Description |
29
49
  | --- | --- | --- |
30
- | `gatewayUrl` | yes | Base URL of the gateway. |
50
+ | `gatewayUrl` | yes | Base URL of the gateway, without a trailing slash. |
31
51
  | `clientId` | yes | Sent as the `client-id` header. |
32
- | `authToken` | yes | String, or a function returning one per request. |
33
- | `origin` | on Node | Sent as the `origin` header. Browsers set this themselves; on Node the gateway rejects the call without it. |
34
- | `fetch` | no | Custom fetch implementation. |
35
- | `timeoutMs` | no | Request timeout, default 30000. |
52
+ | `authToken` | yes | A string, or a function returning one per request — sync or async. |
53
+ | `origin` | on Node | Sent as the `origin` header, and must match the token's referer claim. Browsers set this themselves and ignore any override; on Node the gateway rejects the call without it. |
54
+ | `fetch` | no | Custom fetch implementation. Defaults to the global one. |
55
+ | `timeoutMs` | no | Request timeout in milliseconds. Default `30000`. |
36
56
 
37
57
  ### Node
38
58
 
39
- Browsers attach `Origin` automatically and ignore any override, so `origin` only
40
- needs setting outside the browser:
41
-
42
59
  ```ts
43
60
  const crm = new CrmClient({
44
61
  gatewayUrl: 'https://api.example.com',
45
62
  clientId: 'tpc_xxxxxxxxxxxxxxxx',
46
63
  authToken: process.env.CRM_TOKEN!,
47
- origin: 'https://app.example.com', // must match the token's referer claim
64
+ origin: 'https://app.example.com',
48
65
  });
49
66
  ```
50
67
 
51
68
  ### Refreshing tokens
52
69
 
53
- Pass a function to resolve the token per request:
70
+ Pass a function and it is called before every request, so a rotating token never
71
+ needs the client rebuilt:
54
72
 
55
73
  ```ts
56
74
  const crm = new CrmClient({
@@ -60,7 +78,67 @@ const crm = new CrmClient({
60
78
  });
61
79
  ```
62
80
 
63
- ## Errors
81
+ ## Conventions
82
+
83
+ ### Two kinds of pagination
84
+
85
+ Most lists are **offset paginated** and answer `Paginated<T>`:
86
+
87
+ ```ts
88
+ { data: T[], pagination: { page, rows, total, pages } }
89
+ ```
90
+
91
+ Send `{ page, rows, search }`. `page` is 1-based and defaults to `1`; `rows`
92
+ defaults to `25` and caps at `100`; `search` is trimmed and must be 1–120
93
+ characters. Which fields `search` matches is per resource and is stated on each
94
+ page.
95
+
96
+ Two endpoints — **contact notes** and **audience webhooks** — are **cursor
97
+ paginated** and answer `Page<T>`:
98
+
99
+ ```ts
100
+ { data: T[], nextCursor: string | null }
101
+ ```
102
+
103
+ Send `{ limit, cursor }`. `limit` defaults to `50` and caps at `100`; pass the
104
+ previous response's `nextCursor` to continue, and stop when it is `null`. These
105
+ two page through rows that are appended constantly, where an offset would shift
106
+ under a caller mid-walk.
107
+
108
+ `crm.contacts.iterate(query)` walks every page of the contact list for you.
109
+
110
+ ### Query values that are objects
111
+
112
+ `filter`, `range`, and the billing list's `template` / `country` / `campaign`
113
+ arrays are sent as JSON on the query string. Pass them as real values — the SDK
114
+ serialises them:
115
+
116
+ ```ts
117
+ await crm.billing.list('all', {
118
+ range: { start: 1767225600, end: 1769817600 },
119
+ country: ['IN', 'US'],
120
+ });
121
+ ```
122
+
123
+ ### The contact filter
124
+
125
+ One condition DSL is shared by four places: `contacts.list({ filter })`, a saved
126
+ `Segment`, a CRM trigger's `filters`, and an export's `config.filter`. It has
127
+ its own page: **[contact filter](docs/contact-filter.md)**.
128
+
129
+ ### Scoping
130
+
131
+ Audience rows belong to an account, and a request carries two identities: the
132
+ caller, and the account they act for. Reads match either; writes land on the
133
+ caller's own. Audience webhooks are the exception — they are scoped by tenant.
134
+
135
+ ### Scopes
136
+
137
+ Every method documents the scope its route requires, such as `contacts:read` or
138
+ `channels:write`. They are listed for planning; the gateway does not enforce
139
+ them yet.
140
+
141
+ ### Errors
64
142
 
65
143
  | Error | When |
66
144
  | --- | --- |
@@ -71,18 +149,42 @@ const crm = new CrmClient({
71
149
  import { CrmApiError, CrmConfigError } from 'ab-ecosystem-cpass';
72
150
 
73
151
  try {
74
- await crm.channels.list();
152
+ await crm.contacts.get(id);
75
153
  } catch (err) {
76
154
  if (err instanceof CrmConfigError) console.error('bad SDK setup:', err.message);
77
- else if (err instanceof CrmApiError) console.error(err.status, err.code, err.message);
155
+ else if (err instanceof CrmApiError) console.error(err.status, err.code, err.message, err.details);
78
156
  }
79
157
  ```
80
158
 
81
- ## API
159
+ Common codes: `422` for a body or query that fails validation (`details` lists
160
+ the paths), `404 not_found`, `409 conflict` for a name or slug already taken.
82
161
 
83
- Only the channel module ships in this release.
162
+ ## Modules
84
163
 
85
- | Method | Endpoint |
86
- | --- | --- |
87
- | `crm.channels.list(query?)` | `GET /v1/channels` |
88
- | `crm.channels.get(id)` | `GET /v1/channels/:id` |
164
+ ### Audience — `/v1/audience`
165
+
166
+ | Resource | Page | Actions |
167
+ | --- | --- | --- |
168
+ | `crm.contacts` | [contacts](docs/audience/contacts.md) | `list` `get` `create` `update` `delete` `iterate` |
169
+ | `crm.contactTags` | [contact tags](docs/audience/contact-tags.md) | `list` `get` `create` `update` `delete` |
170
+ | `crm.contactNotes` | [contact notes](docs/audience/contact-notes.md) | `list` `get` `create` `update` `delete` |
171
+ | `crm.customFields` | [custom fields](docs/audience/custom-fields.md) | `list` `get` `create` `update` `delete` |
172
+ | `crm.segments` | [segments](docs/audience/segments.md) | `list` `get` `create` `update` `delete` |
173
+ | `crm.crmTriggers` | [CRM triggers](docs/audience/crm-triggers.md) | `list` `get` `create` `update` `delete` `logs` |
174
+ | `crm.imports` | [import history](docs/audience/imports.md) | `list` `get` `create` `delete` |
175
+ | `crm.exports` | [export history](docs/audience/exports.md) | `list` `get` `create` `delete` |
176
+ | `crm.webhooks` | [audience webhooks](docs/audience/webhooks.md) | `list` `get` `create` `update` `delete` |
177
+
178
+ ### Channels — `/v1/channels`
179
+
180
+ | Resource | Page | Actions |
181
+ | --- | --- | --- |
182
+ | `crm.channels` | [channels](docs/channels/channels.md) | `list` `get` `updateDetails` `disable` `rotateToken` `getProp` `setProp` |
183
+ | — | [channel properties](docs/channels/channel-props.md) | every `prop` `getProp`/`setProp` accepts |
184
+ | `crm.templates` | [templates](docs/channels/templates.md) | `list` `get` `create` `update` `delete` `sync` |
185
+ | `crm.channelWebhooks` | [channel webhooks](docs/channels/webhooks.md) | `list` `get` `create` `update` `delete` |
186
+ | `crm.billing` | [conversation billing](docs/channels/billing.md) | `list` `stats` |
187
+ | `crm.wallet` | [wallet ledger](docs/channels/wallet.md) | `list` |
188
+ | `crm.activity` | [activity log](docs/channels/activity.md) | `list` |
189
+
190
+ The campaign module is not in this release.
package/dist/client.d.ts CHANGED
@@ -1,6 +1,61 @@
1
1
  import { type ClientOptions } from './http';
2
- import { Channels } from './resources/channels';
2
+ import { Contacts } from './resources/audience/contacts';
3
+ import { ContactTags } from './resources/audience/contact-tags';
4
+ import { ContactNotes } from './resources/audience/contact-notes';
5
+ import { CustomFields } from './resources/audience/custom-fields';
6
+ import { Segments } from './resources/audience/segments';
7
+ import { CrmTriggers } from './resources/audience/crm-triggers';
8
+ import { Imports } from './resources/audience/import-history';
9
+ import { Exports } from './resources/audience/export-history';
10
+ import { Webhooks } from './resources/audience/webhooks';
11
+ import { Channels } from './resources/channels/channels';
12
+ import { Templates } from './resources/channels/templates';
13
+ import { ChannelWebhooks } from './resources/channels/webhooks';
14
+ import { Billing } from './resources/channels/billing';
15
+ import { Wallet } from './resources/channels/wallet';
16
+ import { Activity } from './resources/channels/activity';
17
+ /**
18
+ * One client for the whole gateway. Construct it once and share it: it holds no
19
+ * per-request state, and every resource below runs over the same HTTP client,
20
+ * so options such as the token resolver and the timeout apply everywhere.
21
+ *
22
+ * ```ts
23
+ * const crm = new CrmClient({ gatewayUrl, clientId, authToken });
24
+ *
25
+ * const contacts = await crm.contacts.list({ search: 'acme' });
26
+ * const channels = await crm.channels.list({ type: 'whatsapp' });
27
+ * ```
28
+ */
3
29
  export declare class CrmClient {
30
+ /** Contacts: the people an account talks to. */
31
+ readonly contacts: Contacts;
32
+ /** Contact tags: the labels a contact can carry. */
33
+ readonly contactTags: ContactTags;
34
+ /** Internal notes on a contact. Addressed under their contact. */
35
+ readonly contactNotes: ContactNotes;
36
+ /** Custom fields: the per-account contact schema. */
37
+ readonly customFields: CustomFields;
38
+ /** Segments: saved contact filters. */
39
+ readonly segments: Segments;
40
+ /** CRM triggers: fire a webhook when a contact changes, plus their delivery logs. */
41
+ readonly crmTriggers: CrmTriggers;
42
+ /** Import history: bulk loads of contacts, and their progress. */
43
+ readonly imports: Imports;
44
+ /** Export history: bulk extracts, and their progress. */
45
+ readonly exports: Exports;
46
+ /** Audience webhooks: subscriptions to contact events. */
47
+ readonly webhooks: Webhooks;
48
+ /** Channels, and the provider properties that hang off them. */
4
49
  readonly channels: Channels;
50
+ /** WhatsApp message templates, per channel. */
51
+ readonly templates: Templates;
52
+ /** Channel webhooks: where a channel's message traffic is delivered. */
53
+ readonly channelWebhooks: ChannelWebhooks;
54
+ /** Conversation billing: what each conversation cost. */
55
+ readonly billing: Billing;
56
+ /** Channel wallet ledger. */
57
+ readonly wallet: Wallet;
58
+ /** Channel activity feed. */
59
+ readonly activity: Activity;
5
60
  constructor(options: ClientOptions);
6
61
  }
package/dist/client.js CHANGED
@@ -2,44 +2,90 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CrmClient = void 0;
4
4
  const http_1 = require("./http");
5
- const channels_1 = require("./resources/channels");
6
- // Only the channel module ships in the MVP. The rest stay commented out until
7
- // their services are live behind the gateway.
8
- // import { Contacts } from './resources/contacts';
9
- // import { CustomFields } from './resources/custom-fields';
10
- // import { Segments } from './resources/segments';
11
- // import { CrmTriggers } from './resources/crm-triggers';
12
- // import { ContactImports } from './resources/contact-imports';
13
- // import { ContactExports } from './resources/contact-exports';
14
- // import { Webhooks } from './resources/webhooks';
5
+ // Audience
6
+ const contacts_1 = require("./resources/audience/contacts");
7
+ const contact_tags_1 = require("./resources/audience/contact-tags");
8
+ const contact_notes_1 = require("./resources/audience/contact-notes");
9
+ const custom_fields_1 = require("./resources/audience/custom-fields");
10
+ const segments_1 = require("./resources/audience/segments");
11
+ const crm_triggers_1 = require("./resources/audience/crm-triggers");
12
+ const import_history_1 = require("./resources/audience/import-history");
13
+ const export_history_1 = require("./resources/audience/export-history");
14
+ const webhooks_1 = require("./resources/audience/webhooks");
15
+ // Channels
16
+ const channels_1 = require("./resources/channels/channels");
17
+ const templates_1 = require("./resources/channels/templates");
18
+ const webhooks_2 = require("./resources/channels/webhooks");
19
+ const billing_1 = require("./resources/channels/billing");
20
+ const wallet_1 = require("./resources/channels/wallet");
21
+ const activity_1 = require("./resources/channels/activity");
22
+ // The campaign module is not wired up yet; its resources are still excluded
23
+ // from the build.
15
24
  // import { Campaigns } from './resources/campaigns';
16
25
  // import { CampaignReports } from './resources/campaign-reports';
17
26
  // import { CampaignReportExports } from './resources/campaign-report-exports';
27
+ /**
28
+ * One client for the whole gateway. Construct it once and share it: it holds no
29
+ * per-request state, and every resource below runs over the same HTTP client,
30
+ * so options such as the token resolver and the timeout apply everywhere.
31
+ *
32
+ * ```ts
33
+ * const crm = new CrmClient({ gatewayUrl, clientId, authToken });
34
+ *
35
+ * const contacts = await crm.contacts.list({ search: 'acme' });
36
+ * const channels = await crm.channels.list({ type: 'whatsapp' });
37
+ * ```
38
+ */
18
39
  class CrmClient {
40
+ // -- Audience -------------------------------------------------------------
41
+ /** Contacts: the people an account talks to. */
42
+ contacts;
43
+ /** Contact tags: the labels a contact can carry. */
44
+ contactTags;
45
+ /** Internal notes on a contact. Addressed under their contact. */
46
+ contactNotes;
47
+ /** Custom fields: the per-account contact schema. */
48
+ customFields;
49
+ /** Segments: saved contact filters. */
50
+ segments;
51
+ /** CRM triggers: fire a webhook when a contact changes, plus their delivery logs. */
52
+ crmTriggers;
53
+ /** Import history: bulk loads of contacts, and their progress. */
54
+ imports;
55
+ /** Export history: bulk extracts, and their progress. */
56
+ exports;
57
+ /** Audience webhooks: subscriptions to contact events. */
58
+ webhooks;
59
+ // -- Channels -------------------------------------------------------------
60
+ /** Channels, and the provider properties that hang off them. */
19
61
  channels;
20
- // readonly contacts: Contacts;
21
- // readonly customFields: CustomFields;
22
- // readonly segments: Segments;
23
- // readonly crmTriggers: CrmTriggers;
24
- // readonly contactImports: ContactImports;
25
- // readonly contactExports: ContactExports;
26
- // readonly webhooks: Webhooks;
27
- // readonly campaigns: Campaigns;
28
- // readonly campaignReports: CampaignReports;
29
- // readonly campaignReportExports: CampaignReportExports;
62
+ /** WhatsApp message templates, per channel. */
63
+ templates;
64
+ /** Channel webhooks: where a channel's message traffic is delivered. */
65
+ channelWebhooks;
66
+ /** Conversation billing: what each conversation cost. */
67
+ billing;
68
+ /** Channel wallet ledger. */
69
+ wallet;
70
+ /** Channel activity feed. */
71
+ activity;
30
72
  constructor(options) {
31
73
  const http = new http_1.HttpClient(options);
74
+ this.contacts = new contacts_1.Contacts(http);
75
+ this.contactTags = new contact_tags_1.ContactTags(http);
76
+ this.contactNotes = new contact_notes_1.ContactNotes(http);
77
+ this.customFields = new custom_fields_1.CustomFields(http);
78
+ this.segments = new segments_1.Segments(http);
79
+ this.crmTriggers = new crm_triggers_1.CrmTriggers(http);
80
+ this.imports = new import_history_1.Imports(http);
81
+ this.exports = new export_history_1.Exports(http);
82
+ this.webhooks = new webhooks_1.Webhooks(http);
32
83
  this.channels = new channels_1.Channels(http);
33
- // this.contacts = new Contacts(http);
34
- // this.customFields = new CustomFields(http);
35
- // this.segments = new Segments(http);
36
- // this.crmTriggers = new CrmTriggers(http);
37
- // this.contactImports = new ContactImports(http);
38
- // this.contactExports = new ContactExports(http);
39
- // this.webhooks = new Webhooks(http);
40
- // this.campaigns = new Campaigns(http);
41
- // this.campaignReports = new CampaignReports(http);
42
- // this.campaignReportExports = new CampaignReportExports(http);
84
+ this.templates = new templates_1.Templates(http);
85
+ this.channelWebhooks = new webhooks_2.ChannelWebhooks(http);
86
+ this.billing = new billing_1.Billing(http);
87
+ this.wallet = new wallet_1.Wallet(http);
88
+ this.activity = new activity_1.Activity(http);
43
89
  }
44
90
  }
45
91
  exports.CrmClient = CrmClient;
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,iCAAwD;AACxD,mDAAgD;AAEhD,8EAA8E;AAC9E,8CAA8C;AAC9C,mDAAmD;AACnD,4DAA4D;AAC5D,mDAAmD;AACnD,0DAA0D;AAC1D,gEAAgE;AAChE,gEAAgE;AAChE,mDAAmD;AACnD,qDAAqD;AACrD,kEAAkE;AAClE,+EAA+E;AAE/E,MAAa,SAAS;IACX,QAAQ,CAAW;IAE5B,+BAA+B;IAC/B,uCAAuC;IACvC,+BAA+B;IAC/B,qCAAqC;IACrC,2CAA2C;IAC3C,2CAA2C;IAC3C,+BAA+B;IAC/B,iCAAiC;IACjC,6CAA6C;IAC7C,yDAAyD;IAEzD,YAAY,OAAsB;QAChC,MAAM,IAAI,GAAG,IAAI,iBAAU,CAAC,OAAO,CAAC,CAAC;QAErC,IAAI,CAAC,QAAQ,GAAG,IAAI,mBAAQ,CAAC,IAAI,CAAC,CAAC;QAEnC,sCAAsC;QACtC,8CAA8C;QAC9C,sCAAsC;QACtC,4CAA4C;QAC5C,kDAAkD;QAClD,kDAAkD;QAClD,sCAAsC;QACtC,wCAAwC;QACxC,oDAAoD;QACpD,gEAAgE;IAClE,CAAC;CACF;AA9BD,8BA8BC"}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,iCAAwD;AAExD,WAAW;AACX,4DAAyD;AACzD,oEAAgE;AAChE,sEAAkE;AAClE,sEAAkE;AAClE,4DAAyD;A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CAAC,CAAC;QACnC,IAAI,CAAC,WAAW,GAAG,IAAI,0BAAW,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,OAAO,GAAG,IAAI,wBAAO,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,IAAI,wBAAO,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,IAAI,mBAAQ,CAAC,IAAI,CAAC,CAAC;QAEnC,IAAI,CAAC,QAAQ,GAAG,IAAI,mBAAQ,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,SAAS,GAAG,IAAI,qBAAS,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,eAAe,GAAG,IAAI,0BAAe,CAAC,IAAI,CAAC,CAAC;QACjD,IAAI,CAAC,OAAO,GAAG,IAAI,iBAAO,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,MAAM,GAAG,IAAI,eAAM,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,IAAI,mBAAQ,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;CACF;AAzDD,8BAyDC"}
package/dist/http.d.ts CHANGED
@@ -17,8 +17,16 @@ export interface ClientOptions {
17
17
  timeoutMs?: number;
18
18
  }
19
19
  export interface RequestInitOptions {
20
+ /** Serialised as JSON unless `raw` is set. */
20
21
  body?: unknown;
21
22
  query?: Record<string, unknown>;
23
+ /**
24
+ * Request body sent verbatim, for the endpoints that take file bytes rather
25
+ * than JSON. Takes precedence over `body`.
26
+ */
27
+ raw?: BodyInit;
28
+ /** Overrides `content-type`; required alongside `raw`. */
29
+ contentType?: string;
22
30
  }
23
31
  export declare class HttpClient {
24
32
  private readonly options;
package/dist/http.js CHANGED
@@ -2,6 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HttpClient = void 0;
4
4
  const errors_1 = require("./errors");
5
+ /**
6
+ * Query values the API reads as JSON rather than as a scalar: the contact
7
+ * filter, the unix ranges, and the billing list filters. Anything else is
8
+ * stringified the plain way, and `true`/`false` stay the literals the server
9
+ * parses them back from.
10
+ */
11
+ const queryValue = (value) => typeof value === 'object' ? JSON.stringify(value) : String(value);
5
12
  const browserOrigin = () => typeof globalThis !== 'undefined' &&
6
13
  typeof globalThis.location?.origin === 'string'
7
14
  ? globalThis.location.origin
@@ -38,19 +45,19 @@ class HttpClient {
38
45
  const url = new URL(`${this.gatewayUrl}${path}`);
39
46
  for (const [key, value] of Object.entries(init.query ?? {})) {
40
47
  if (value !== undefined && value !== null)
41
- url.searchParams.set(key, String(value));
48
+ url.searchParams.set(key, queryValue(value));
42
49
  }
43
50
  const origin = this.options.origin ?? browserOrigin();
44
51
  const send = this.options.fetch ?? fetch;
45
52
  const response = await send(url.toString(), {
46
53
  method,
47
54
  headers: {
48
- 'content-type': 'application/json',
55
+ 'content-type': init.contentType ?? 'application/json',
49
56
  authorization: `Bearer ${token}`,
50
57
  'client-id': this.options.clientId.trim(),
51
58
  ...(origin ? { origin } : {}),
52
59
  },
53
- body: init.body === undefined ? undefined : JSON.stringify(init.body),
60
+ body: init.raw ?? (init.body === undefined ? undefined : JSON.stringify(init.body)),
54
61
  signal: AbortSignal.timeout(this.options.timeoutMs ?? 30_000),
55
62
  });
56
63
  if (!response.ok)
package/dist/http.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":";;;AAAA,qCAAuD;AA0BvD,MAAM,aAAa,GAAG,GAAuB,EAAE,CAC7C,OAAO,UAAU,KAAK,WAAW;IACjC,OAAQ,UAAiD,CAAC,QAAQ,EAAE,MAAM,KAAK,QAAQ;IACrF,CAAC,CAAE,UAA0D,CAAC,QAAQ,CAAC,MAAM;IAC7E,CAAC,CAAC,SAAS,CAAC;AAEhB,MAAa,UAAU;IAGQ;IAFZ,UAAU,CAAS;IAEpC,YAA6B,OAAsB;QAAtB,YAAO,GAA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AAO,CAAC,KAAK,IAAI,KAAK,CAAC;QACzC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE;YAC1C,MAAM;YACN,OAAO,EAAE;gBACP,cAAc,EAAE,IAAI,CAAC,WAAW,IAAI,kBAAkB;gBACtD,aAAa,EAAE,UAAU,KAAK,EAAE;gBAChC,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE;gBACzC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC9B;YACD,IAAI,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACnF,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,MAAM,CAAC;SAC9D,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE;YAAE,MAAM,MAAM,oBAAW,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QACjE,OAAO,CAAC,QAAQ,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAM,CAAC;IAC5E,CAAC;CACF;AAvDD,gCAuDC"}
package/dist/index.d.ts CHANGED
@@ -2,4 +2,19 @@ export * from './client';
2
2
  export * from './http';
3
3
  export * from './errors';
4
4
  export * from './types';
5
- export { Channels } from './resources/channels';
5
+ export { AUDIENCE, CHANNELS } from './resources/paths';
6
+ export { Contacts } from './resources/audience/contacts';
7
+ export { ContactTags } from './resources/audience/contact-tags';
8
+ export { ContactNotes } from './resources/audience/contact-notes';
9
+ export { CustomFields } from './resources/audience/custom-fields';
10
+ export { Segments } from './resources/audience/segments';
11
+ export { CrmTriggers } from './resources/audience/crm-triggers';
12
+ export { Imports } from './resources/audience/import-history';
13
+ export { Exports } from './resources/audience/export-history';
14
+ export { Webhooks } from './resources/audience/webhooks';
15
+ export { Channels, type SetPropOptions } from './resources/channels/channels';
16
+ export { Templates } from './resources/channels/templates';
17
+ export { ChannelWebhooks } from './resources/channels/webhooks';
18
+ export { Billing } from './resources/channels/billing';
19
+ export { Wallet } from './resources/channels/wallet';
20
+ export { Activity } from './resources/channels/activity';
package/dist/index.js CHANGED
@@ -14,11 +14,44 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.Channels = void 0;
17
+ exports.Activity = exports.Wallet = exports.Billing = exports.ChannelWebhooks = exports.Templates = exports.Channels = exports.Webhooks = exports.Exports = exports.Imports = exports.CrmTriggers = exports.Segments = exports.CustomFields = exports.ContactNotes = exports.ContactTags = exports.Contacts = exports.CHANNELS = exports.AUDIENCE = void 0;
18
18
  __exportStar(require("./client"), exports);
19
19
  __exportStar(require("./http"), exports);
20
20
  __exportStar(require("./errors"), exports);
21
21
  __exportStar(require("./types"), exports);
22
- var channels_1 = require("./resources/channels");
22
+ var paths_1 = require("./resources/paths");
23
+ Object.defineProperty(exports, "AUDIENCE", { enumerable: true, get: function () { return paths_1.AUDIENCE; } });
24
+ Object.defineProperty(exports, "CHANNELS", { enumerable: true, get: function () { return paths_1.CHANNELS; } });
25
+ // Audience
26
+ var contacts_1 = require("./resources/audience/contacts");
27
+ Object.defineProperty(exports, "Contacts", { enumerable: true, get: function () { return contacts_1.Contacts; } });
28
+ var contact_tags_1 = require("./resources/audience/contact-tags");
29
+ Object.defineProperty(exports, "ContactTags", { enumerable: true, get: function () { return contact_tags_1.ContactTags; } });
30
+ var contact_notes_1 = require("./resources/audience/contact-notes");
31
+ Object.defineProperty(exports, "ContactNotes", { enumerable: true, get: function () { return contact_notes_1.ContactNotes; } });
32
+ var custom_fields_1 = require("./resources/audience/custom-fields");
33
+ Object.defineProperty(exports, "CustomFields", { enumerable: true, get: function () { return custom_fields_1.CustomFields; } });
34
+ var segments_1 = require("./resources/audience/segments");
35
+ Object.defineProperty(exports, "Segments", { enumerable: true, get: function () { return segments_1.Segments; } });
36
+ var crm_triggers_1 = require("./resources/audience/crm-triggers");
37
+ Object.defineProperty(exports, "CrmTriggers", { enumerable: true, get: function () { return crm_triggers_1.CrmTriggers; } });
38
+ var import_history_1 = require("./resources/audience/import-history");
39
+ Object.defineProperty(exports, "Imports", { enumerable: true, get: function () { return import_history_1.Imports; } });
40
+ var export_history_1 = require("./resources/audience/export-history");
41
+ Object.defineProperty(exports, "Exports", { enumerable: true, get: function () { return export_history_1.Exports; } });
42
+ var webhooks_1 = require("./resources/audience/webhooks");
43
+ Object.defineProperty(exports, "Webhooks", { enumerable: true, get: function () { return webhooks_1.Webhooks; } });
44
+ // Channels
45
+ var channels_1 = require("./resources/channels/channels");
23
46
  Object.defineProperty(exports, "Channels", { enumerable: true, get: function () { return channels_1.Channels; } });
47
+ var templates_1 = require("./resources/channels/templates");
48
+ Object.defineProperty(exports, "Templates", { enumerable: true, get: function () { return templates_1.Templates; } });
49
+ var webhooks_2 = require("./resources/channels/webhooks");
50
+ Object.defineProperty(exports, "ChannelWebhooks", { enumerable: true, get: function () { return webhooks_2.ChannelWebhooks; } });
51
+ var billing_1 = require("./resources/channels/billing");
52
+ Object.defineProperty(exports, "Billing", { enumerable: true, get: function () { return billing_1.Billing; } });
53
+ var wallet_1 = require("./resources/channels/wallet");
54
+ Object.defineProperty(exports, "Wallet", { enumerable: true, get: function () { return wallet_1.Wallet; } });
55
+ var activity_1 = require("./resources/channels/activity");
56
+ Object.defineProperty(exports, "Activity", { enumerable: true, get: function () { return activity_1.Activity; } });
24
57
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,yCAAuB;AACvB,2CAAyB;AACzB,0CAAwB;AACxB,iDAAgD;AAAvC,oGAAA,QAAQ,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,yCAAuB;AACvB,2CAAyB;AACzB,0CAAwB;AAExB,2CAAuD;AAA9C,iGAAA,QAAQ,OAAA;AAAE,iGAAA,QAAQ,OAAA;AAE3B,WAAW;AACX,0DAAyD;AAAhD,oGAAA,QAAQ,OAAA;AACjB,kEAAgE;AAAvD,2GAAA,WAAW,OAAA;AACpB,oEAAkE;AAAzD,6GAAA,YAAY,OAAA;AACrB,oEAAkE;AAAzD,6GAAA,YAAY,OAAA;AACrB,0DAAyD;AAAhD,oGAAA,QAAQ,OAAA;AACjB,kEAAgE;AAAvD,2GAAA,WAAW,OAAA;AACpB,sEAA8D;AAArD,yGAAA,OAAO,OAAA;AAChB,sEAA8D;AAArD,yGAAA,OAAO,OAAA;AAChB,0DAAyD;AAAhD,oGAAA,QAAQ,OAAA;AAEjB,WAAW;AACX,0DAA8E;AAArE,oGAAA,QAAQ,OAAA;AACjB,4DAA2D;AAAlD,sGAAA,SAAS,OAAA;AAClB,0DAAgE;AAAvD,2GAAA,eAAe,OAAA;AACxB,wDAAuD;AAA9C,kGAAA,OAAO,OAAA;AAChB,sDAAqD;AAA5C,gGAAA,MAAM,OAAA;AACf,0DAAyD;AAAhD,oGAAA,QAAQ,OAAA"}
@@ -0,0 +1,51 @@
1
+ import type { ContactNote, CreateContactNoteInput, ListContactNotesQuery, Page, UpdateContactNoteInput } from '../../types';
2
+ import type { HttpClient } from '../../http';
3
+ /**
4
+ * Internal notes on a contact: free text, attachments, and team members
5
+ * mentioned in them. Notes are never shown to the contact.
6
+ *
7
+ * Every method takes the contact id first -- notes are addressed under their
8
+ * contact, and a note id from another contact is a 404 rather than a match.
9
+ *
10
+ * NOTE: these routes are currently commented out in the audience service's
11
+ * `routes.ts`, so they answer 404 until that line is restored. The contract and
12
+ * the service behind them are complete.
13
+ */
14
+ export declare class ContactNotes {
15
+ private readonly http;
16
+ constructor(http: HttpClient);
17
+ /**
18
+ * `GET /v1/audience/contacts/:contactId/notes` -- cursor paginated, newest
19
+ * first. Notes are appended, so an offset would shift under a caller
20
+ * mid-walk; page with `cursor` from the previous response's `nextCursor`.
21
+ *
22
+ * Scope: `contacts:read`.
23
+ */
24
+ list(contactId: string, query?: Partial<ListContactNotesQuery>): Promise<Page<ContactNote>>;
25
+ /**
26
+ * `GET /v1/audience/contacts/:contactId/notes/:noteId`.
27
+ *
28
+ * Scope: `contacts:read`.
29
+ */
30
+ get(contactId: string, noteId: string): Promise<ContactNote>;
31
+ /**
32
+ * `POST /v1/audience/contacts/:contactId/notes` -- 201 with the created note.
33
+ *
34
+ * Scope: `contacts:write`.
35
+ */
36
+ create(contactId: string, input: CreateContactNoteInput): Promise<ContactNote>;
37
+ /**
38
+ * `PATCH /v1/audience/contacts/:contactId/notes/:noteId` -- a partial update.
39
+ * `attachments` and `mentions` replace their stored value rather than
40
+ * appending to it.
41
+ *
42
+ * Scope: `contacts:write`.
43
+ */
44
+ update(contactId: string, noteId: string, input: UpdateContactNoteInput): Promise<ContactNote>;
45
+ /**
46
+ * `DELETE /v1/audience/contacts/:contactId/notes/:noteId` -- 204, no body.
47
+ *
48
+ * Scope: `contacts:write`.
49
+ */
50
+ delete(contactId: string, noteId: string): Promise<void>;
51
+ }