@inkbox/sdk 0.4.5 → 0.4.7
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 +163 -36
- package/dist/_http.d.ts +12 -0
- package/dist/_http.d.ts.map +1 -1
- package/dist/_http.js +23 -2
- package/dist/_http.js.map +1 -1
- package/dist/agent_identity.d.ts +138 -6
- package/dist/agent_identity.d.ts.map +1 -1
- package/dist/agent_identity.js +155 -5
- package/dist/agent_identity.js.map +1 -1
- package/dist/identities/resources/identities.d.ts +11 -1
- package/dist/identities/resources/identities.d.ts.map +1 -1
- package/dist/identities/resources/identities.js +14 -1
- package/dist/identities/resources/identities.js.map +1 -1
- package/dist/identities/types.d.ts +15 -6
- package/dist/identities/types.d.ts.map +1 -1
- package/dist/identities/types.js +2 -4
- package/dist/identities/types.js.map +1 -1
- package/dist/imessage/resources/contactRules.d.ts +55 -0
- package/dist/imessage/resources/contactRules.d.ts.map +1 -0
- package/dist/imessage/resources/contactRules.js +85 -0
- package/dist/imessage/resources/contactRules.js.map +1 -0
- package/dist/imessage/resources/imessages.d.ts +168 -0
- package/dist/imessage/resources/imessages.d.ts.map +1 -0
- package/dist/imessage/resources/imessages.js +238 -0
- package/dist/imessage/resources/imessages.js.map +1 -0
- package/dist/imessage/types.d.ts +335 -0
- package/dist/imessage/types.d.ts.map +1 -0
- package/dist/imessage/types.js +209 -0
- package/dist/imessage/types.js.map +1 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/inkbox.d.ts +25 -0
- package/dist/inkbox.d.ts.map +1 -1
- package/dist/inkbox.js +32 -0
- package/dist/inkbox.js.map +1 -1
- package/dist/mail/resources/mailboxes.d.ts +2 -3
- package/dist/mail/resources/mailboxes.d.ts.map +1 -1
- package/dist/mail/resources/mailboxes.js +2 -5
- package/dist/mail/resources/mailboxes.js.map +1 -1
- package/dist/mail/types.d.ts +10 -2
- package/dist/mail/types.d.ts.map +1 -1
- package/dist/mail/types.js +0 -1
- package/dist/mail/types.js.map +1 -1
- package/dist/phone/resources/numbers.d.ts +0 -2
- package/dist/phone/resources/numbers.d.ts.map +1 -1
- package/dist/phone/resources/numbers.js +0 -6
- package/dist/phone/resources/numbers.js.map +1 -1
- package/dist/phone/resources/texts.d.ts +5 -5
- package/dist/phone/resources/texts.js +5 -5
- package/dist/phone/types.d.ts +15 -2
- package/dist/phone/types.d.ts.map +1 -1
- package/dist/phone/types.js +0 -1
- package/dist/phone/types.js.map +1 -1
- package/dist/webhooks/index.d.ts +8 -0
- package/dist/webhooks/index.d.ts.map +1 -0
- package/dist/webhooks/index.js +8 -0
- package/dist/webhooks/index.js.map +1 -0
- package/dist/webhooks/subscriptions.d.ts +96 -0
- package/dist/webhooks/subscriptions.d.ts.map +1 -0
- package/dist/webhooks/subscriptions.js +168 -0
- package/dist/webhooks/subscriptions.js.map +1 -0
- package/dist/webhooks/types.d.ts +173 -11
- package/dist/webhooks/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/webhooks/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal-only barrel for the webhooks module. The public entry
|
|
3
|
+
* point is `sdk/typescript/src/index.ts`; this file is for
|
|
4
|
+
* intra-package imports.
|
|
5
|
+
*/
|
|
6
|
+
export * from "./types.js";
|
|
7
|
+
export * from "./subscriptions.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/webhooks/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Webhook subscriptions — fan-out per (owner, url, event_types).
|
|
3
|
+
*
|
|
4
|
+
* Replaces the legacy per-resource `webhook_url` columns on mailboxes
|
|
5
|
+
* and phone numbers. Use this resource to attach HTTPS receivers to
|
|
6
|
+
* mail (`message.*`), phone-text (`text.*`), or iMessage (`imessage.*`)
|
|
7
|
+
* events. Mail and text subscriptions are owned by the mailbox / phone
|
|
8
|
+
* number; iMessage subscriptions are owned by the agent identity, since
|
|
9
|
+
* shared iMessage pool numbers are not org resources. Incoming-call
|
|
10
|
+
* webhooks (`phone.incoming_call`) are still set on the phone-number
|
|
11
|
+
* resource itself — that channel is a synchronous control-plane
|
|
12
|
+
* callback whose response body drives call routing, so fan-out is not
|
|
13
|
+
* meaningful.
|
|
14
|
+
*/
|
|
15
|
+
import { HttpTransport } from "../_http.js";
|
|
16
|
+
/** Lifecycle status of a subscription row. Callers only ever see `"active"`; deleted subscriptions are not returned by `list` / `get`. */
|
|
17
|
+
export type WebhookSubscriptionStatus = "active" | "deleted";
|
|
18
|
+
export interface WebhookSubscription {
|
|
19
|
+
id: string;
|
|
20
|
+
/** `"org_..."` token; not a UUID. */
|
|
21
|
+
organizationId: string;
|
|
22
|
+
/** Owning mailbox. Exactly one of `mailboxId` / `phoneNumberId` / `agentIdentityId` is non-null. */
|
|
23
|
+
mailboxId: string | null;
|
|
24
|
+
/** Owning phone number. Exactly one of `mailboxId` / `phoneNumberId` / `agentIdentityId` is non-null. */
|
|
25
|
+
phoneNumberId: string | null;
|
|
26
|
+
/** Owning agent identity, for identity-owned iMessage subscriptions. */
|
|
27
|
+
agentIdentityId: string | null;
|
|
28
|
+
url: string;
|
|
29
|
+
/** Wire event-type strings (e.g. `"message.received"`, `"text.sent"`). Not narrowed to a literal union — the catalog is the source of truth. */
|
|
30
|
+
eventTypes: string[];
|
|
31
|
+
status: WebhookSubscriptionStatus;
|
|
32
|
+
createdAt: Date;
|
|
33
|
+
updatedAt: Date;
|
|
34
|
+
}
|
|
35
|
+
export interface RawWebhookSubscription {
|
|
36
|
+
id: string;
|
|
37
|
+
organization_id: string;
|
|
38
|
+
mailbox_id: string | null;
|
|
39
|
+
phone_number_id: string | null;
|
|
40
|
+
agent_identity_id?: string | null;
|
|
41
|
+
url: string;
|
|
42
|
+
event_types: string[];
|
|
43
|
+
status: WebhookSubscriptionStatus;
|
|
44
|
+
created_at: string;
|
|
45
|
+
updated_at: string;
|
|
46
|
+
}
|
|
47
|
+
export declare function parseWebhookSubscription(r: RawWebhookSubscription): WebhookSubscription;
|
|
48
|
+
export interface CreateWebhookSubscriptionOptions {
|
|
49
|
+
mailboxId?: string;
|
|
50
|
+
phoneNumberId?: string;
|
|
51
|
+
agentIdentityId?: string;
|
|
52
|
+
url: string;
|
|
53
|
+
eventTypes: string[];
|
|
54
|
+
}
|
|
55
|
+
export interface UpdateWebhookSubscriptionOptions {
|
|
56
|
+
url?: string;
|
|
57
|
+
eventTypes?: string[];
|
|
58
|
+
}
|
|
59
|
+
export interface ListWebhookSubscriptionsOptions {
|
|
60
|
+
mailboxId?: string;
|
|
61
|
+
phoneNumberId?: string;
|
|
62
|
+
agentIdentityId?: string;
|
|
63
|
+
url?: string;
|
|
64
|
+
eventType?: string;
|
|
65
|
+
}
|
|
66
|
+
export declare class WebhookSubscriptionsResource {
|
|
67
|
+
private readonly http;
|
|
68
|
+
constructor(http: HttpTransport);
|
|
69
|
+
/**
|
|
70
|
+
* List webhook subscriptions visible to the caller. Filters AND-combine;
|
|
71
|
+
* unmatched filters return an empty list. `mailboxId` / `phoneNumberId`
|
|
72
|
+
* / `agentIdentityId` are mutually exclusive — passing more than one
|
|
73
|
+
* yields a 422. Deleted subscriptions are not returned.
|
|
74
|
+
*/
|
|
75
|
+
list(filters?: ListWebhookSubscriptionsOptions): Promise<WebhookSubscription[]>;
|
|
76
|
+
/** Fetch a single subscription by id. Returns 404 if the subscription has been deleted or is not visible to the caller. */
|
|
77
|
+
get(subId: string): Promise<WebhookSubscription>;
|
|
78
|
+
/**
|
|
79
|
+
* Create a webhook subscription. Exactly one of `mailboxId` /
|
|
80
|
+
* `phoneNumberId` / `agentIdentityId` is required; `eventTypes` must
|
|
81
|
+
* be a non-empty list of distinct values belonging to the owner's
|
|
82
|
+
* channel (mailbox → `message.*`, phone number → `text.*`, agent
|
|
83
|
+
* identity → `imessage.*`).
|
|
84
|
+
*/
|
|
85
|
+
create(options: CreateWebhookSubscriptionOptions): Promise<WebhookSubscription>;
|
|
86
|
+
/**
|
|
87
|
+
* Update the destination URL and/or event-type list of a subscription.
|
|
88
|
+
* Omitting both is a no-op. `eventTypes`, if supplied, replaces the
|
|
89
|
+
* stored list and must be non-empty and distinct. Owner FKs are not
|
|
90
|
+
* mutable.
|
|
91
|
+
*/
|
|
92
|
+
update(subId: string, options: UpdateWebhookSubscriptionOptions): Promise<WebhookSubscription>;
|
|
93
|
+
/** Delete a subscription. Subsequent `list` / `get` calls will not return it. */
|
|
94
|
+
delete(subId: string): Promise<void>;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=subscriptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscriptions.d.ts","sourceRoot":"","sources":["../../src/webhooks/subscriptions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAI5C,0IAA0I;AAC1I,MAAM,MAAM,yBAAyB,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE7D,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,qCAAqC;IACrC,cAAc,EAAE,MAAM,CAAC;IACvB,oGAAoG;IACpG,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,yGAAyG;IACzG,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,wEAAwE;IACxE,eAAe,EAAE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,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAEhD;;;;;OAKG;IACG,IAAI,CACR,OAAO,GAAE,+BAAoC,GAC5C,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAWjC,2HAA2H;IACrH,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAKtD;;;;;;OAMG;IACG,MAAM,CACV,OAAO,EAAE,gCAAgC,GACxC,OAAO,CAAC,mBAAmB,CAAC;IA6B/B;;;;;OAKG;IACG,MAAM,CACV,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,gCAAgC,GACxC,OAAO,CAAC,mBAAmB,CAAC;IAmB/B,iFAAiF;IAC3E,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG3C"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Webhook subscriptions — fan-out per (owner, url, event_types).
|
|
3
|
+
*
|
|
4
|
+
* Replaces the legacy per-resource `webhook_url` columns on mailboxes
|
|
5
|
+
* and phone numbers. Use this resource to attach HTTPS receivers to
|
|
6
|
+
* mail (`message.*`), phone-text (`text.*`), or iMessage (`imessage.*`)
|
|
7
|
+
* events. Mail and text subscriptions are owned by the mailbox / phone
|
|
8
|
+
* number; iMessage subscriptions are owned by the agent identity, since
|
|
9
|
+
* shared iMessage pool numbers are not org resources. Incoming-call
|
|
10
|
+
* webhooks (`phone.incoming_call`) are still set on the phone-number
|
|
11
|
+
* resource itself — that channel is a synchronous control-plane
|
|
12
|
+
* callback whose response body drives call routing, so fan-out is not
|
|
13
|
+
* meaningful.
|
|
14
|
+
*/
|
|
15
|
+
const PATH = "/webhooks/subscriptions";
|
|
16
|
+
export function parseWebhookSubscription(r) {
|
|
17
|
+
return {
|
|
18
|
+
id: r.id,
|
|
19
|
+
organizationId: r.organization_id,
|
|
20
|
+
mailboxId: r.mailbox_id,
|
|
21
|
+
phoneNumberId: r.phone_number_id,
|
|
22
|
+
agentIdentityId: r.agent_identity_id ?? null,
|
|
23
|
+
url: r.url,
|
|
24
|
+
eventTypes: r.event_types,
|
|
25
|
+
status: r.status,
|
|
26
|
+
createdAt: new Date(r.created_at),
|
|
27
|
+
updatedAt: new Date(r.updated_at),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const INCOMING_CALL = "phone.incoming_call";
|
|
31
|
+
function assertUrlNotNull(url) {
|
|
32
|
+
if (url === null) {
|
|
33
|
+
throw new Error("url must not be null; pass a string, or omit the field to leave it unchanged");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function assertEventTypesNotNull(eventTypes) {
|
|
37
|
+
if (eventTypes === null) {
|
|
38
|
+
throw new Error("eventTypes must not be null; pass a non-empty array, or omit the field to leave it unchanged");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function assertEventTypesNonEmptyDistinct(eventTypes) {
|
|
42
|
+
if (eventTypes.length === 0) {
|
|
43
|
+
throw new Error("eventTypes must be a non-empty list");
|
|
44
|
+
}
|
|
45
|
+
const seen = new Set();
|
|
46
|
+
for (const e of eventTypes) {
|
|
47
|
+
if (seen.has(e)) {
|
|
48
|
+
throw new Error(`eventTypes contains duplicate value: '${e}'`);
|
|
49
|
+
}
|
|
50
|
+
seen.add(e);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function assertNoIncomingCall(eventTypes) {
|
|
54
|
+
if (eventTypes.includes(INCOMING_CALL)) {
|
|
55
|
+
throw new Error(`event_type '${INCOMING_CALL}' is not stored in webhook subscriptions; ` +
|
|
56
|
+
"set it on the phone number's `incomingCallWebhookUrl` field instead");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const OWNER_EVENT_PREFIXES = {
|
|
60
|
+
mailbox: "message.",
|
|
61
|
+
phone_number: "text.",
|
|
62
|
+
agent_identity: "imessage.",
|
|
63
|
+
};
|
|
64
|
+
function assertChannelCoherence(owner, eventTypes) {
|
|
65
|
+
const expectedPrefix = OWNER_EVENT_PREFIXES[owner];
|
|
66
|
+
for (const e of eventTypes) {
|
|
67
|
+
if (e.startsWith(expectedPrefix))
|
|
68
|
+
continue;
|
|
69
|
+
for (const [otherOwner, otherPrefix] of Object.entries(OWNER_EVENT_PREFIXES)) {
|
|
70
|
+
if (otherOwner !== owner && e.startsWith(otherPrefix)) {
|
|
71
|
+
throw new Error(`event_type '${e}' does not belong to the ${owner} ` +
|
|
72
|
+
`channel (it belongs to ${otherOwner})`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
throw new Error(`event_type '${e}' does not belong to any known channel`);
|
|
76
|
+
}
|
|
77
|
+
// INCOMING_CALL is rejected by assertNoIncomingCall earlier.
|
|
78
|
+
}
|
|
79
|
+
export class WebhookSubscriptionsResource {
|
|
80
|
+
http;
|
|
81
|
+
constructor(http) {
|
|
82
|
+
this.http = http;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* List webhook subscriptions visible to the caller. Filters AND-combine;
|
|
86
|
+
* unmatched filters return an empty list. `mailboxId` / `phoneNumberId`
|
|
87
|
+
* / `agentIdentityId` are mutually exclusive — passing more than one
|
|
88
|
+
* yields a 422. Deleted subscriptions are not returned.
|
|
89
|
+
*/
|
|
90
|
+
async list(filters = {}) {
|
|
91
|
+
const params = {};
|
|
92
|
+
if (filters.mailboxId !== undefined)
|
|
93
|
+
params["mailbox_id"] = filters.mailboxId;
|
|
94
|
+
if (filters.phoneNumberId !== undefined)
|
|
95
|
+
params["phone_number_id"] = filters.phoneNumberId;
|
|
96
|
+
if (filters.agentIdentityId !== undefined)
|
|
97
|
+
params["agent_identity_id"] = filters.agentIdentityId;
|
|
98
|
+
if (filters.url !== undefined)
|
|
99
|
+
params["url"] = filters.url;
|
|
100
|
+
if (filters.eventType !== undefined)
|
|
101
|
+
params["event_type"] = filters.eventType;
|
|
102
|
+
const data = await this.http.get(PATH, params);
|
|
103
|
+
return data.subscriptions.map(parseWebhookSubscription);
|
|
104
|
+
}
|
|
105
|
+
/** Fetch a single subscription by id. Returns 404 if the subscription has been deleted or is not visible to the caller. */
|
|
106
|
+
async get(subId) {
|
|
107
|
+
const data = await this.http.get(`${PATH}/${subId}`);
|
|
108
|
+
return parseWebhookSubscription(data);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Create a webhook subscription. Exactly one of `mailboxId` /
|
|
112
|
+
* `phoneNumberId` / `agentIdentityId` is required; `eventTypes` must
|
|
113
|
+
* be a non-empty list of distinct values belonging to the owner's
|
|
114
|
+
* channel (mailbox → `message.*`, phone number → `text.*`, agent
|
|
115
|
+
* identity → `imessage.*`).
|
|
116
|
+
*/
|
|
117
|
+
async create(options) {
|
|
118
|
+
const owners = {
|
|
119
|
+
mailbox: options.mailboxId,
|
|
120
|
+
phone_number: options.phoneNumberId,
|
|
121
|
+
agent_identity: options.agentIdentityId,
|
|
122
|
+
};
|
|
123
|
+
const populated = Object.entries(owners)
|
|
124
|
+
.filter(([, value]) => value !== undefined && value !== null);
|
|
125
|
+
if (populated.length !== 1) {
|
|
126
|
+
throw new Error("Exactly one of mailboxId, phoneNumberId, or agentIdentityId must be provided");
|
|
127
|
+
}
|
|
128
|
+
const [owner, ownerId] = populated[0];
|
|
129
|
+
assertUrlNotNull(options.url);
|
|
130
|
+
assertEventTypesNotNull(options.eventTypes);
|
|
131
|
+
assertEventTypesNonEmptyDistinct(options.eventTypes);
|
|
132
|
+
assertNoIncomingCall(options.eventTypes);
|
|
133
|
+
assertChannelCoherence(owner, options.eventTypes);
|
|
134
|
+
const body = {
|
|
135
|
+
url: options.url,
|
|
136
|
+
event_types: options.eventTypes,
|
|
137
|
+
[`${owner}_id`]: ownerId,
|
|
138
|
+
};
|
|
139
|
+
const data = await this.http.post(PATH, body);
|
|
140
|
+
return parseWebhookSubscription(data);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Update the destination URL and/or event-type list of a subscription.
|
|
144
|
+
* Omitting both is a no-op. `eventTypes`, if supplied, replaces the
|
|
145
|
+
* stored list and must be non-empty and distinct. Owner FKs are not
|
|
146
|
+
* mutable.
|
|
147
|
+
*/
|
|
148
|
+
async update(subId, options) {
|
|
149
|
+
const body = {};
|
|
150
|
+
if (options.url !== undefined) {
|
|
151
|
+
assertUrlNotNull(options.url);
|
|
152
|
+
body["url"] = options.url;
|
|
153
|
+
}
|
|
154
|
+
if (options.eventTypes !== undefined) {
|
|
155
|
+
assertEventTypesNotNull(options.eventTypes);
|
|
156
|
+
assertEventTypesNonEmptyDistinct(options.eventTypes);
|
|
157
|
+
assertNoIncomingCall(options.eventTypes);
|
|
158
|
+
body["event_types"] = options.eventTypes;
|
|
159
|
+
}
|
|
160
|
+
const data = await this.http.patch(`${PATH}/${subId}`, body);
|
|
161
|
+
return parseWebhookSubscription(data);
|
|
162
|
+
}
|
|
163
|
+
/** Delete a subscription. Subsequent `list` / `get` calls will not return it. */
|
|
164
|
+
async delete(subId) {
|
|
165
|
+
await this.http.delete(`${PATH}/${subId}`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=subscriptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscriptions.js","sourceRoot":"","sources":["../../src/webhooks/subscriptions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,MAAM,IAAI,GAAG,yBAAyB,CAAC;AAwCvC,MAAM,UAAU,wBAAwB,CACtC,CAAyB;IAEzB,OAAO;QACL,EAAE,EAAE,CAAC,CAAC,EAAE;QACR,cAAc,EAAE,CAAC,CAAC,eAAe;QACjC,SAAS,EAAE,CAAC,CAAC,UAAU;QACvB,aAAa,EAAE,CAAC,CAAC,eAAe;QAChC,eAAe,EAAE,CAAC,CAAC,iBAAiB,IAAI,IAAI;QAC5C,GAAG,EAAE,CAAC,CAAC,GAAG;QACV,UAAU,EAAE,CAAC,CAAC,WAAW;QACzB,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB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,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC;IAC7C,CAAC;CACF"}
|
package/dist/webhooks/types.d.ts
CHANGED
|
@@ -18,16 +18,26 @@ export type CallDirectionWire = "outbound" | "inbound";
|
|
|
18
18
|
export type CallStatusWire = "initiated" | "ringing" | "answered" | "completed" | "failed" | "canceled";
|
|
19
19
|
export type HangupReasonWire = "local" | "remote" | "max_duration" | "voicemail" | "rejected";
|
|
20
20
|
/**
|
|
21
|
-
* Address-book match for
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* Address-book match for a remote party on a phone or text webhook
|
|
22
|
+
* event. Surfaced as a list — pass `id` to `inkbox.contacts.get()` to
|
|
23
|
+
* hydrate.
|
|
24
24
|
*/
|
|
25
25
|
export interface WebhookContact {
|
|
26
26
|
id: string;
|
|
27
27
|
name: string;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Identity match for a remote party on a phone or text webhook event.
|
|
31
|
+
* Set when the remote party is an active agent identity in the same
|
|
32
|
+
* org that is visible to the receiver.
|
|
33
|
+
*/
|
|
34
|
+
export interface WebhookAgentIdentity {
|
|
35
|
+
id: string;
|
|
36
|
+
agent_handle: string;
|
|
37
|
+
display_name: string | null;
|
|
38
|
+
}
|
|
29
39
|
export type MailWebhookEventType = "message.received" | "message.sent" | "message.forwarded" | "message.delivered" | "message.bounced" | "message.failed";
|
|
30
|
-
/** Which recipient list a mail webhook contact was matched from. */
|
|
40
|
+
/** Which recipient list a mail webhook contact/identity was matched from. */
|
|
31
41
|
export type MailContactBucket = "from" | "to" | "cc" | "bcc";
|
|
32
42
|
/**
|
|
33
43
|
* Per-recipient address-book match on a mail webhook event.
|
|
@@ -47,6 +57,18 @@ export interface WebhookMailContact {
|
|
|
47
57
|
id: string;
|
|
48
58
|
name: string;
|
|
49
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Per-recipient identity match on a mail webhook event. Same shape as
|
|
62
|
+
* `WebhookMailContact` but with `agent_handle` / `display_name`
|
|
63
|
+
* instead of `name`.
|
|
64
|
+
*/
|
|
65
|
+
export interface WebhookMailAgentIdentity {
|
|
66
|
+
bucket: MailContactBucket;
|
|
67
|
+
address: string;
|
|
68
|
+
id: string;
|
|
69
|
+
agent_handle: string;
|
|
70
|
+
display_name: string | null;
|
|
71
|
+
}
|
|
50
72
|
/**
|
|
51
73
|
* Stored mail message. `message_id` is the RFC 5322 `Message-ID`
|
|
52
74
|
* header value (not Inkbox's row id — that's `id`). `bcc_addresses` is
|
|
@@ -77,20 +99,40 @@ export interface MailWebhookPayload {
|
|
|
77
99
|
data: {
|
|
78
100
|
message: MailWebhookMessage;
|
|
79
101
|
/**
|
|
80
|
-
* Per-recipient matches. Always present, possibly
|
|
81
|
-
* order is `from` → `to` → `cc` → `bcc`, then within
|
|
82
|
-
* by source-field order; receivers should pair by
|
|
102
|
+
* Per-recipient address-book matches. Always present, possibly
|
|
103
|
+
* empty. Wire order is `from` → `to` → `cc` → `bcc`, then within
|
|
104
|
+
* each bucket by source-field order; receivers should pair by
|
|
83
105
|
* `(bucket, address)` rather than relying on the order. Up to 50
|
|
84
106
|
* distinct normalized addresses are resolved per event; over-cap
|
|
85
107
|
* inputs and resolver failures both fall back to an empty list.
|
|
86
108
|
*/
|
|
87
109
|
contacts: WebhookMailContact[];
|
|
110
|
+
/**
|
|
111
|
+
* Per-recipient identity matches. Always present, possibly empty.
|
|
112
|
+
* Same matching rules as `contacts`. A peer can match both a
|
|
113
|
+
* contact and an agent identity — two rows are emitted; receivers
|
|
114
|
+
* decide precedence.
|
|
115
|
+
*/
|
|
116
|
+
agent_identities: WebhookMailAgentIdentity[];
|
|
88
117
|
};
|
|
89
118
|
}
|
|
90
119
|
export type TextWebhookEventType = "text.received" | "text.sent" | "text.delivered" | "text.delivery_failed" | "text.delivery_unconfirmed";
|
|
91
120
|
/**
|
|
92
121
|
* Stored text message. `is_blocked` is not part of the wire body —
|
|
93
122
|
* blocked texts never reach the webhook.
|
|
123
|
+
*
|
|
124
|
+
* Field population by traffic shape:
|
|
125
|
+
* - `remote_phone_number`: populated on inbound and on outbound 1:1;
|
|
126
|
+
* `null` on group outbound (per-recipient state lives in
|
|
127
|
+
* `recipients[]`).
|
|
128
|
+
* - `delivery_status`: populated on outbound. On group outbound this
|
|
129
|
+
* is the message-level rollup across `recipients[]`; on inbound it
|
|
130
|
+
* is `null`.
|
|
131
|
+
* - Legacy top-level lifecycle details (`error_code`, `error_detail`,
|
|
132
|
+
* `sent_at`, `delivered_at`, `failed_at`): populated only on
|
|
133
|
+
* outbound 1:1. On group outbound the per-recipient values live in
|
|
134
|
+
* `recipients[]`; on inbound there is no carrier lifecycle to track,
|
|
135
|
+
* so all five are `null`.
|
|
94
136
|
*/
|
|
95
137
|
export interface TextWebhookMessage {
|
|
96
138
|
id: string;
|
|
@@ -110,6 +152,12 @@ export interface TextWebhookMessage {
|
|
|
110
152
|
failed_at: string | null;
|
|
111
153
|
conversation_id: string | null;
|
|
112
154
|
sender_phone_number: string | null;
|
|
155
|
+
/**
|
|
156
|
+
* `null` on inbound (and rows that didn't eager-load recipients);
|
|
157
|
+
* a one-element list on outbound 1:1 (the legacy 1:1 lifecycle
|
|
158
|
+
* fields above are hoisted from that entry); multiple entries on
|
|
159
|
+
* group outbound.
|
|
160
|
+
*/
|
|
113
161
|
recipients: RawTextMessageRecipient[] | null;
|
|
114
162
|
created_at: string;
|
|
115
163
|
updated_at: string;
|
|
@@ -119,14 +167,125 @@ export interface TextWebhookPayload {
|
|
|
119
167
|
timestamp: string;
|
|
120
168
|
data: {
|
|
121
169
|
text_message: TextWebhookMessage;
|
|
122
|
-
|
|
170
|
+
/** Address-book matches for the remote party (or parties). Always present, possibly empty. */
|
|
171
|
+
contacts: WebhookContact[];
|
|
172
|
+
/** Identity matches for the remote party (or parties). Always present, possibly empty. */
|
|
173
|
+
agent_identities: WebhookAgentIdentity[];
|
|
174
|
+
/**
|
|
175
|
+
* For outbound group lifecycle events, the specific recipient this
|
|
176
|
+
* event is about. `null` on inbound and on 1:1 outbound (where
|
|
177
|
+
* `text_message.remote_phone_number` already identifies the
|
|
178
|
+
* recipient).
|
|
179
|
+
*/
|
|
123
180
|
recipient_phone_number: string | null;
|
|
124
181
|
};
|
|
125
182
|
}
|
|
183
|
+
export type IMessageWebhookEventType = "imessage.received" | "imessage.reaction_received" | "imessage.sent" | "imessage.delivered" | "imessage.delivery_failed";
|
|
184
|
+
export type IMessageDirectionWire = "inbound" | "outbound";
|
|
185
|
+
export type IMessageServiceWire = "imessage" | "sms" | "rcs";
|
|
186
|
+
export type IMessageTypeWire = "message" | "carousel";
|
|
187
|
+
export type IMessageDeliveryStatusWire = "registered" | "pending" | "queued" | "accepted" | "sent" | "delivered" | "declined" | "error" | "received";
|
|
188
|
+
export type IMessageReactionTypeWire = "love" | "like" | "dislike" | "laugh" | "emphasize" | "question" | "custom";
|
|
189
|
+
export type IMessageSendStyleWire = "celebration" | "shooting_star" | "fireworks" | "lasers" | "love" | "confetti" | "balloons" | "spotlight" | "echo" | "invisible" | "gentle" | "loud" | "slam";
|
|
190
|
+
/** iMessage media attachment (snake_case wire shape). */
|
|
191
|
+
export interface IMessageMediaItemWire {
|
|
192
|
+
content_type: string | null;
|
|
193
|
+
size: number | null;
|
|
194
|
+
url: string;
|
|
195
|
+
}
|
|
196
|
+
/** Per-recipient outbound iMessage delivery state. */
|
|
197
|
+
export interface IMessageRecipientWire {
|
|
198
|
+
remote_number: string;
|
|
199
|
+
delivery_status: IMessageDeliveryStatusWire | null;
|
|
200
|
+
service: IMessageServiceWire | null;
|
|
201
|
+
error_code: string | null;
|
|
202
|
+
error_message: string | null;
|
|
203
|
+
error_reason: string | null;
|
|
204
|
+
error_detail: string | null;
|
|
205
|
+
sent_at: string | null;
|
|
206
|
+
delivered_at: string | null;
|
|
207
|
+
failed_at: string | null;
|
|
208
|
+
}
|
|
209
|
+
/** A live tapback attached to a message (snake_case wire shape). */
|
|
210
|
+
export interface IMessageMessageReactionWire {
|
|
211
|
+
id: string;
|
|
212
|
+
direction: IMessageDirectionWire;
|
|
213
|
+
reaction: IMessageReactionTypeWire;
|
|
214
|
+
custom_emoji: string | null;
|
|
215
|
+
remote_number: string;
|
|
216
|
+
part_index: number;
|
|
217
|
+
created_at: string;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Stored iMessage. `is_blocked` is not part of the wire body — blocked
|
|
221
|
+
* messages never reach the webhook. There is no local-number field:
|
|
222
|
+
* shared pool lines are hidden from agents, so the message is
|
|
223
|
+
* identified by `conversation_id` and the counterparty `remote_number`
|
|
224
|
+
* only.
|
|
225
|
+
*/
|
|
226
|
+
export interface IMessageWebhookMessage {
|
|
227
|
+
id: string;
|
|
228
|
+
conversation_id: string;
|
|
229
|
+
assignment_id: string;
|
|
230
|
+
direction: IMessageDirectionWire;
|
|
231
|
+
remote_number: string;
|
|
232
|
+
content: string | null;
|
|
233
|
+
message_type: IMessageTypeWire;
|
|
234
|
+
service: IMessageServiceWire;
|
|
235
|
+
send_style: IMessageSendStyleWire | null;
|
|
236
|
+
media: IMessageMediaItemWire[] | null;
|
|
237
|
+
was_downgraded: boolean | null;
|
|
238
|
+
status: IMessageDeliveryStatusWire | null;
|
|
239
|
+
error_code: string | null;
|
|
240
|
+
error_message: string | null;
|
|
241
|
+
error_reason: string | null;
|
|
242
|
+
error_detail: string | null;
|
|
243
|
+
is_read: boolean;
|
|
244
|
+
recipients: IMessageRecipientWire[] | null;
|
|
245
|
+
reactions: IMessageMessageReactionWire[] | null;
|
|
246
|
+
created_at: string;
|
|
247
|
+
updated_at: string;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* A tapback reaction on an iMessage (snake_case wire shape).
|
|
251
|
+
* `custom_emoji` carries the literal emoji when `reaction` is
|
|
252
|
+
* `"custom"`; `null` for the classic six.
|
|
253
|
+
*/
|
|
254
|
+
export interface IMessageWebhookReaction {
|
|
255
|
+
id: string;
|
|
256
|
+
conversation_id: string;
|
|
257
|
+
assignment_id: string;
|
|
258
|
+
target_message_id: string;
|
|
259
|
+
direction: IMessageDirectionWire;
|
|
260
|
+
reaction: IMessageReactionTypeWire;
|
|
261
|
+
custom_emoji: string | null;
|
|
262
|
+
remote_number: string;
|
|
263
|
+
part_index: number;
|
|
264
|
+
created_at: string;
|
|
265
|
+
updated_at: string;
|
|
266
|
+
}
|
|
267
|
+
export interface IMessageWebhookPayload {
|
|
268
|
+
event_type: IMessageWebhookEventType;
|
|
269
|
+
/** ISO 8601 datetime. */
|
|
270
|
+
timestamp: string;
|
|
271
|
+
data: {
|
|
272
|
+
/** Populated on `imessage.received` and the delivery-lifecycle events
|
|
273
|
+
* (`imessage.sent` / `imessage.delivered` / `imessage.delivery_failed`);
|
|
274
|
+
* `null` on reaction events. */
|
|
275
|
+
message: IMessageWebhookMessage | null;
|
|
276
|
+
/** Populated on `imessage.reaction_received`; `null` on message events. */
|
|
277
|
+
reaction: IMessageWebhookReaction | null;
|
|
278
|
+
/** Address-book matches for the remote party. Always present, possibly empty. */
|
|
279
|
+
contacts: WebhookContact[];
|
|
280
|
+
/** Identity matches for the remote party. Always present, possibly empty. */
|
|
281
|
+
agent_identities: WebhookAgentIdentity[];
|
|
282
|
+
};
|
|
283
|
+
}
|
|
126
284
|
/**
|
|
127
285
|
* Inbound call payload. **Flat** — no `{ event_type, timestamp, data }`
|
|
128
|
-
* envelope; `
|
|
129
|
-
* of the wire body — blocked calls never
|
|
286
|
+
* envelope; `contacts` / `agent_identities` sit at the top level.
|
|
287
|
+
* `is_blocked` is not part of the wire body — blocked calls never
|
|
288
|
+
* reach the webhook.
|
|
130
289
|
*/
|
|
131
290
|
export interface PhoneIncomingCallWebhookPayload {
|
|
132
291
|
id: string;
|
|
@@ -143,6 +302,9 @@ export interface PhoneIncomingCallWebhookPayload {
|
|
|
143
302
|
created_at: string;
|
|
144
303
|
updated_at: string;
|
|
145
304
|
rate_limit: RawRateLimitInfo | null;
|
|
146
|
-
|
|
305
|
+
/** Address-book matches for the remote party. Always present, possibly empty. */
|
|
306
|
+
contacts: WebhookContact[];
|
|
307
|
+
/** Identity matches for the remote party. Always present, possibly empty. */
|
|
308
|
+
agent_identities: WebhookAgentIdentity[];
|
|
147
309
|
}
|
|
148
310
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/webhooks/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,mBAAmB,CAAC;AAI3B,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,UAAU,CAAC;AAE1D,MAAM,MAAM,aAAa,GACrB,QAAQ,GACR,MAAM,GACN,WAAW,GACX,SAAS,GACT,QAAQ,GACR,UAAU,GACV,SAAS,CAAC;AAEd,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,UAAU,CAAC;AAEvD,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,KAAK,CAAC;AAEzC,MAAM,MAAM,qBAAqB,GAC7B,QAAQ,GACR,MAAM,GACN,WAAW,GACX,iBAAiB,GACjB,sBAAsB,GACtB,gBAAgB,CAAC;AAErB,MAAM,MAAM,qBAAqB,GAAG,gBAAgB,GAAG,YAAY,CAAC;AAEpE,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,SAAS,CAAC;AAEvD,MAAM,MAAM,cAAc,GACtB,WAAW,GACX,SAAS,GACT,UAAU,GACV,WAAW,GACX,QAAQ,GACR,UAAU,CAAC;AAEf,MAAM,MAAM,gBAAgB,GACxB,OAAO,GACP,QAAQ,GACR,cAAc,GACd,WAAW,GACX,UAAU,CAAC;AAIf;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd;AAID,MAAM,MAAM,oBAAoB,GAC5B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