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
@@ -0,0 +1,157 @@
1
+ # Contact filter
2
+
3
+ One condition language, four callers:
4
+
5
+ | Where | Shape |
6
+ | --- | --- |
7
+ | `crm.contacts.list({ filter })` | `ContactFilter` — sent as JSON on the query string |
8
+ | `crm.segments.create({ filter })` | `ContactFilter` — stored under a name |
9
+ | `crm.crmTriggers.create({ filters })` | `ContactFilterEntry[]` — flat, not wrapped |
10
+ | `crm.exports.create({ config: { filter } })` | `ContactFilter` |
11
+
12
+ A filter that works in one of these works in all of them, and means the same
13
+ thing: a trigger's `filters` are checked by running the contact list query
14
+ pinned to that one contact.
15
+
16
+ ## Shape
17
+
18
+ ```ts
19
+ interface ContactFilter {
20
+ type?: string; // free-form tag for provenance, default 'sheet'
21
+ conditions?: ContactFilterEntry[]; // at most 50, default [] = match everyone
22
+ }
23
+
24
+ interface ContactFilterEntry {
25
+ id?: number; // your own row id, echoed back
26
+ operator?: 'and' | 'or' | null; // null on the first condition
27
+ field_id: string; // a custom field slug, `tags`, or a SYSTEM_* field
28
+ field_type: ContactFilterFieldType;
29
+ condition: ContactFilterCondition;
30
+ value?: unknown; // omitted for conditions that take none
31
+ direction?: 'LAST' | 'TODAY' | 'NEXT' | '';
32
+ timeUnit?: 'minutes' | 'hours' | 'days' | 'weeks' | 'months' | 'years' | '';
33
+ offset?: number; // caller's midnight, as a ms shift from UTC midnight
34
+ props?: { period?: 'daily' | 'weekly' | 'monthly' | 'annually' };
35
+ requireInput?: boolean; // UI hint, ignored by the server
36
+ }
37
+ ```
38
+
39
+ ## How conditions combine
40
+
41
+ `and` binds tighter than `or`. The list is split on every `or`, each run is
42
+ `and`ed, and the runs are `or`ed together — so this:
43
+
44
+ ```
45
+ A and B or C and D
46
+ ```
47
+
48
+ means `(A and B) or (C and D)`. There is no nesting and no parentheses; when you
49
+ need them, save the inner group as a segment and narrow it with `filter`.
50
+
51
+ The first condition's `operator` is `null`. An empty `conditions` array matches
52
+ every contact.
53
+
54
+ ## Fields
55
+
56
+ | `field_id` | What it addresses |
57
+ | --- | --- |
58
+ | a custom field slug | `contact.custom_field_hash.<slug>` |
59
+ | `tags` | The contact's tags. `value` is one tag id or an array of them; `equal to` is "has any of these", `not equal to` is "has none of them". |
60
+ | `SYSTEM_LAST_SEEN` | `contact.last_seen`, stored as unix **seconds**. |
61
+ | `SYSTEM_CREATED_ON` | `contact.createdAt`, a date. |
62
+ | `SYSTEM_IDENTIFIER` | The identifier of any channel identity — a phone number, handle or address. |
63
+ | `SYSTEM_PROFILE_NAME` | The name on any channel identity. |
64
+
65
+ `SYSTEM_IDENTIFIER` and `SYSTEM_PROFILE_NAME` live in a separate collection, so
66
+ they resolve through a lookup. Negated conditions on them read the way you would
67
+ say them out loud: `SYSTEM_IDENTIFIER not equal to X` means *no* identity holds
68
+ X — not *some* identity holds something else.
69
+
70
+ ## Conditions by field type
71
+
72
+ Four conditions apply to every type, whatever its shape:
73
+
74
+ `is null` · `is not null` · `exist` · `does not exist`
75
+
76
+ Beyond those:
77
+
78
+ | `field_type` | Conditions |
79
+ | --- | --- |
80
+ | `string` `text` `url` `email` `phone` `country` `language` `timezone` `dial_code` `dropdown` | `equal to` `not equal to` `start with` `end with` `contains` `does not contains` `is empty` `is not empty` |
81
+ | `number` | `equal to` `not equal to` `greater than` `greater than or equal to` `less than` `less than or equal to` |
82
+ | `date` `timestamp` | `is` `after` `before` `between` `within` |
83
+ | `periodic_time` | `is` `after` `before` `between` `within` — needs `props.period` |
84
+
85
+ Anything else is rejected with `422`, naming the field and the condition that
86
+ had no meaning for it.
87
+
88
+ ## Values
89
+
90
+ - **Text and number conditions** take a scalar in `value`.
91
+ - **`is` / `after` / `before` / `between`** on a date take a **JSON array
92
+ string**: `between` reads two entries, the rest read the first.
93
+ `value: '["2026-03-01","2026-03-31"]'`.
94
+ - **`within`** reads `direction`, `timeUnit` and a number in `value`: `LAST`
95
+ counts that many units backwards from the caller's midnight, `NEXT` forwards.
96
+ `direction: 'TODAY'` is the exception — it means the caller's current day and
97
+ needs neither `timeUnit` nor `value`. A missing `timeUnit` or an unknown
98
+ `direction` is a `422`.
99
+ - **`is empty` / `is not empty` / `is null` / `exist` / …** take no `value`.
100
+
101
+ ### `offset`
102
+
103
+ Relative windows are anchored to the caller's midnight, not UTC's. `offset` is
104
+ the shift in milliseconds from UTC midnight to yours: IST (+5:30) sends
105
+ `-19800000`. Leave it at `0` to work in UTC.
106
+
107
+ Months and years shift calendar-aware; hours, days and weeks are fixed-width.
108
+
109
+ ## Examples
110
+
111
+ Everyone in Pune, tagged VIP:
112
+
113
+ ```ts
114
+ await crm.contacts.list({
115
+ filter: {
116
+ conditions: [
117
+ { operator: null, field_id: 'city', field_type: 'text', condition: 'equal to', value: 'Pune' },
118
+ { operator: 'and', field_id: 'tags', field_type: 'string', condition: 'equal to', value: [vipTagId] },
119
+ ],
120
+ },
121
+ });
122
+ ```
123
+
124
+ Seen in the last 7 days, or created today:
125
+
126
+ ```ts
127
+ await crm.contacts.list({
128
+ filter: {
129
+ conditions: [
130
+ {
131
+ operator: null,
132
+ field_id: 'SYSTEM_LAST_SEEN',
133
+ field_type: 'timestamp',
134
+ condition: 'within',
135
+ direction: 'LAST',
136
+ timeUnit: 'days',
137
+ value: 7,
138
+ offset: -19800000,
139
+ },
140
+ {
141
+ operator: 'or',
142
+ field_id: 'SYSTEM_CREATED_ON',
143
+ field_type: 'date',
144
+ condition: 'within',
145
+ direction: 'TODAY',
146
+ offset: -19800000,
147
+ },
148
+ ],
149
+ },
150
+ });
151
+ ```
152
+
153
+ No email on file:
154
+
155
+ ```ts
156
+ { operator: null, field_id: 'email', field_type: 'email', condition: 'is empty' }
157
+ ```
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "ab-ecosystem-cpass",
3
- "version": "0.1.0",
4
- "description": "JavaScript/TypeScript SDK for the CPaaS CRM gateway",
3
+ "version": "1.0.0",
4
+ "description": "JavaScript/TypeScript SDK for the CPaaS CRM gateway: audience and channels",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "files": [
9
9
  "dist",
10
+ "docs",
10
11
  "README.md"
11
12
  ],
12
13
  "sideEffects": false,
@@ -17,7 +18,10 @@
17
18
  "crm",
18
19
  "cpaas",
19
20
  "sdk",
20
- "channels"
21
+ "channels",
22
+ "contacts",
23
+ "whatsapp",
24
+ "audience"
21
25
  ],
22
26
  "publishConfig": {
23
27
  "access": "public"
@@ -1,10 +0,0 @@
1
- import type { Channel, ChannelResponse, Page, PageQuery } from '../types';
2
- import type { HttpClient } from '../http';
3
- export declare class Channels {
4
- private readonly http;
5
- constructor(http: HttpClient);
6
- /** `GET /v1/channels` */
7
- list(query?: Partial<PageQuery>): Promise<Page<Channel>>;
8
- /** `GET /v1/channels/:id` */
9
- get(id: string): Promise<ChannelResponse>;
10
- }
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Channels = void 0;
4
- class Channels {
5
- http;
6
- constructor(http) {
7
- this.http = http;
8
- }
9
- /** `GET /v1/channels` */
10
- list(query = {}) {
11
- return this.http.request('GET', '/v1/channels', { query });
12
- }
13
- /** `GET /v1/channels/:id` */
14
- get(id) {
15
- return this.http.request('GET', `/v1/channels/${encodeURIComponent(id)}`);
16
- }
17
- }
18
- exports.Channels = Channels;
19
- //# sourceMappingURL=channels.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"channels.js","sourceRoot":"","sources":["../../src/resources/channels.ts"],"names":[],"mappings":";;;AAGA,MAAa,QAAQ;IACU;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,yBAAyB;IACzB,IAAI,CAAC,QAA4B,EAAE;QACjC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAgB,KAAK,EAAE,cAAc,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED,6BAA6B;IAC7B,GAAG,CAAC,EAAU;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAkB,KAAK,EAAE,gBAAgB,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAC7F,CAAC;CAsBF;AAjCD,4BAiCC"}
package/dist/types.d.ts DELETED
@@ -1,70 +0,0 @@
1
- /**
2
- * Response shapes returned by the gateway. Declared here rather than imported
3
- * from `@crm/contracts` so the published package has no private dependencies.
4
- */
5
- export interface Page<T> {
6
- data: T[];
7
- nextCursor: string | null;
8
- }
9
- export interface PageQuery {
10
- limit: number;
11
- cursor?: string;
12
- }
13
- export interface ChannelMeta {
14
- category: string;
15
- provider: string;
16
- support_template: boolean;
17
- show_template: boolean;
18
- bypass_webhook_verification: boolean;
19
- }
20
- export interface ChannelCloud {
21
- instagram_id: string;
22
- is_instagram_business_login: boolean;
23
- waba_id: string;
24
- business: string;
25
- phone_number_id: string;
26
- is_on_biz_app: boolean;
27
- version: string;
28
- auto_read_receipt: number;
29
- upgrade_eligibility: boolean;
30
- wa_biz_registration: 'pending' | 'completed';
31
- }
32
- export interface ChannelWallet {
33
- free_tier?: number;
34
- free_usage?: number;
35
- /** `'NULL'` when the wallet is not visible to the caller. */
36
- balance: number | 'NULL';
37
- visible?: boolean;
38
- }
39
- export interface Channel {
40
- id: string;
41
- active: boolean;
42
- ecom?: {
43
- store_status: boolean;
44
- store?: string;
45
- };
46
- basic_details: {
47
- name: string;
48
- color_code: string;
49
- channel_identity: string;
50
- };
51
- meta: ChannelMeta;
52
- billing: {
53
- status: boolean;
54
- currency: string;
55
- visible: boolean;
56
- };
57
- wallet: ChannelWallet;
58
- campaign_tps: number;
59
- upgraded_webhook_listener: boolean;
60
- cloud: ChannelCloud;
61
- api_only: boolean;
62
- crm_only: boolean;
63
- mm_lite_enabled: boolean;
64
- access_token: string;
65
- [key: string]: unknown;
66
- }
67
- /** `GET /v1/channels/:id` wraps its payload, and returns `{}` when nothing matches. */
68
- export interface ChannelResponse {
69
- data: Channel | Record<string, never>;
70
- }
package/dist/types.js DELETED
@@ -1,7 +0,0 @@
1
- "use strict";
2
- /**
3
- * Response shapes returned by the gateway. Declared here rather than imported
4
- * from `@crm/contracts` so the published package has no private dependencies.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;GAGG"}