@digisglobal/omnivox-sdk 0.9.0 → 0.10.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/dist/index.cjs +178 -0
- package/dist/index.d.cts +296 -8
- package/dist/index.d.ts +296 -8
- package/dist/index.js +175 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -25,13 +25,16 @@ __export(index_exports, {
|
|
|
25
25
|
createAgentsModule: () => createAgentsModule,
|
|
26
26
|
createApiKeyTokenProvider: () => createApiKeyTokenProvider,
|
|
27
27
|
createAttachmentsModule: () => createAttachmentsModule,
|
|
28
|
+
createAuditModule: () => createAuditModule,
|
|
28
29
|
createAuthMeModule: () => createAuthMeModule,
|
|
29
30
|
createCannedResponsesModule: () => createCannedResponsesModule,
|
|
30
31
|
createChannelsModule: () => createChannelsModule,
|
|
31
32
|
createContactsModule: () => createContactsModule,
|
|
32
33
|
createConversationsModule: () => createConversationsModule,
|
|
34
|
+
createDashboardModule: () => createDashboardModule,
|
|
33
35
|
createMessagesModule: () => createMessagesModule,
|
|
34
36
|
createOmnivoxClient: () => createOmnivoxClient,
|
|
37
|
+
createParticipantsModule: () => createParticipantsModule,
|
|
35
38
|
createSessionTokenProvider: () => createSessionTokenProvider,
|
|
36
39
|
createTemplatesModule: () => createTemplatesModule,
|
|
37
40
|
createTenantsModule: () => createTenantsModule,
|
|
@@ -160,6 +163,15 @@ var getConversationsControllerUpdateStatusUrl = (id) => {
|
|
|
160
163
|
var getConversationsControllerAssignUrl = (id) => {
|
|
161
164
|
return `/api/v1/conversations/${id}/assign`;
|
|
162
165
|
};
|
|
166
|
+
var getConversationsControllerAddParticipantUrl = (id) => {
|
|
167
|
+
return `/api/v1/conversations/${id}/participants`;
|
|
168
|
+
};
|
|
169
|
+
var getConversationsControllerListParticipantsUrl = (id) => {
|
|
170
|
+
return `/api/v1/conversations/${id}/participants`;
|
|
171
|
+
};
|
|
172
|
+
var getConversationsControllerRemoveParticipantUrl = (id, agentId) => {
|
|
173
|
+
return `/api/v1/conversations/${id}/participants/${agentId}`;
|
|
174
|
+
};
|
|
163
175
|
var getConversationsControllerListLobbyUrl = (params) => {
|
|
164
176
|
const normalizedParams = new URLSearchParams();
|
|
165
177
|
Object.entries(params || {}).forEach(([key, value]) => {
|
|
@@ -329,6 +341,29 @@ var getAttachmentsControllerUploadUrl = () => {
|
|
|
329
341
|
var getAttachmentsControllerGetDownloadUrlUrl = (id) => {
|
|
330
342
|
return `/api/v1/attachments/${id}/url`;
|
|
331
343
|
};
|
|
344
|
+
var getDashboardControllerGetStatsUrl = () => {
|
|
345
|
+
return `/api/v1/dashboard/stats`;
|
|
346
|
+
};
|
|
347
|
+
var getDashboardControllerGetRecentActivityUrl = (params) => {
|
|
348
|
+
const normalizedParams = new URLSearchParams();
|
|
349
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
350
|
+
if (value !== void 0) {
|
|
351
|
+
normalizedParams.append(key, value === null ? "null" : String(value));
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
const stringifiedParams = normalizedParams.toString();
|
|
355
|
+
return stringifiedParams.length > 0 ? `/api/v1/dashboard/recent-activity?${stringifiedParams}` : `/api/v1/dashboard/recent-activity`;
|
|
356
|
+
};
|
|
357
|
+
var getAuditLogControllerListUrl = (params) => {
|
|
358
|
+
const normalizedParams = new URLSearchParams();
|
|
359
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
360
|
+
if (value !== void 0) {
|
|
361
|
+
normalizedParams.append(key, value === null ? "null" : String(value));
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
const stringifiedParams = normalizedParams.toString();
|
|
365
|
+
return stringifiedParams.length > 0 ? `/api/v1/audit-log?${stringifiedParams}` : `/api/v1/audit-log`;
|
|
366
|
+
};
|
|
332
367
|
|
|
333
368
|
// src/pagination/pagination.ts
|
|
334
369
|
var MAX_PAGE_SIZE = 100;
|
|
@@ -745,6 +780,60 @@ function createConversationsModule(options) {
|
|
|
745
780
|
};
|
|
746
781
|
}
|
|
747
782
|
|
|
783
|
+
// src/conversations/participants.ts
|
|
784
|
+
function createParticipantsModule(options) {
|
|
785
|
+
const baseUrl = options.baseUrl;
|
|
786
|
+
function buildInit(method, body) {
|
|
787
|
+
return {
|
|
788
|
+
method,
|
|
789
|
+
credentials: options.getCredentials(),
|
|
790
|
+
headers: {
|
|
791
|
+
"Content-Type": "application/json",
|
|
792
|
+
...options.getHeaders()
|
|
793
|
+
},
|
|
794
|
+
...body !== void 0 ? { body: JSON.stringify(body) } : {}
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
return {
|
|
798
|
+
/**
|
|
799
|
+
* Add (or re-add) an agent as a conversation participant with a role.
|
|
800
|
+
* Idempotent per active membership — re-adding an active participant
|
|
801
|
+
* updates its role; a second OWNER co-owns (no demotion of other owners).
|
|
802
|
+
* Calls POST /api/v1/conversations/:id/participants.
|
|
803
|
+
*/
|
|
804
|
+
async add(conversationId, input) {
|
|
805
|
+
const path = getConversationsControllerAddParticipantUrl(conversationId);
|
|
806
|
+
const url = `${baseUrl}${path}`;
|
|
807
|
+
const res = await fetch(url, buildInit("POST", input));
|
|
808
|
+
return parseEnvelopedResponse(res);
|
|
809
|
+
},
|
|
810
|
+
/**
|
|
811
|
+
* End an active membership for an agent. Idempotent — removing a
|
|
812
|
+
* non-participant is a no-op ({ removed: 0 }).
|
|
813
|
+
* Calls DELETE /api/v1/conversations/:id/participants/:agentId.
|
|
814
|
+
*/
|
|
815
|
+
async remove(conversationId, agentId) {
|
|
816
|
+
const path = getConversationsControllerRemoveParticipantUrl(
|
|
817
|
+
conversationId,
|
|
818
|
+
agentId
|
|
819
|
+
);
|
|
820
|
+
const url = `${baseUrl}${path}`;
|
|
821
|
+
const res = await fetch(url, buildInit("DELETE"));
|
|
822
|
+
return parseEnvelopedResponse(res);
|
|
823
|
+
},
|
|
824
|
+
/**
|
|
825
|
+
* List the ACTIVE (leftAt IS NULL) participants of a conversation.
|
|
826
|
+
* Calls GET /api/v1/conversations/:id/participants.
|
|
827
|
+
*/
|
|
828
|
+
async list(conversationId) {
|
|
829
|
+
const path = getConversationsControllerListParticipantsUrl(conversationId);
|
|
830
|
+
const url = `${baseUrl}${path}`;
|
|
831
|
+
const res = await fetch(url, buildInit("GET"));
|
|
832
|
+
return parseEnvelopedResponse(res);
|
|
833
|
+
}
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
|
|
748
837
|
// src/messages/messages.ts
|
|
749
838
|
function createMessagesModule(options) {
|
|
750
839
|
const baseUrl = options.baseUrl;
|
|
@@ -1240,6 +1329,89 @@ function createWhatsAppBusinessAccountsModule(options) {
|
|
|
1240
1329
|
};
|
|
1241
1330
|
}
|
|
1242
1331
|
|
|
1332
|
+
// src/dashboard/dashboard.ts
|
|
1333
|
+
function createDashboardModule(options) {
|
|
1334
|
+
const baseUrl = options.baseUrl;
|
|
1335
|
+
function buildInit() {
|
|
1336
|
+
return {
|
|
1337
|
+
method: "GET",
|
|
1338
|
+
credentials: options.getCredentials(),
|
|
1339
|
+
headers: {
|
|
1340
|
+
"Content-Type": "application/json",
|
|
1341
|
+
...options.getHeaders()
|
|
1342
|
+
}
|
|
1343
|
+
};
|
|
1344
|
+
}
|
|
1345
|
+
return {
|
|
1346
|
+
/**
|
|
1347
|
+
* Fetch the tenant dashboard KPIs.
|
|
1348
|
+
* Calls GET /api/v1/dashboard/stats.
|
|
1349
|
+
*/
|
|
1350
|
+
async stats() {
|
|
1351
|
+
const path = getDashboardControllerGetStatsUrl();
|
|
1352
|
+
const url = `${baseUrl}${path}`;
|
|
1353
|
+
const res = await fetch(url, buildInit());
|
|
1354
|
+
return parseEnvelopedResponse(res);
|
|
1355
|
+
},
|
|
1356
|
+
/**
|
|
1357
|
+
* List the tenant's recent conversation/message activity feed
|
|
1358
|
+
* (newest first, paginated). pageSize is clamped to 100 per the API
|
|
1359
|
+
* contract. Calls GET /api/v1/dashboard/recent-activity.
|
|
1360
|
+
*/
|
|
1361
|
+
async recentActivity(opts = { page: 1, pageSize: 25 }) {
|
|
1362
|
+
const { page, pageSize } = buildPageParams(opts);
|
|
1363
|
+
const path = getDashboardControllerGetRecentActivityUrl({
|
|
1364
|
+
page,
|
|
1365
|
+
pageSize
|
|
1366
|
+
});
|
|
1367
|
+
const url = `${baseUrl}${path}`;
|
|
1368
|
+
const res = await fetch(url, buildInit());
|
|
1369
|
+
return parseResponse(res);
|
|
1370
|
+
}
|
|
1371
|
+
};
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
// src/audit/audit.ts
|
|
1375
|
+
function createAuditModule(options) {
|
|
1376
|
+
const baseUrl = options.baseUrl;
|
|
1377
|
+
function buildInit() {
|
|
1378
|
+
return {
|
|
1379
|
+
method: "GET",
|
|
1380
|
+
credentials: options.getCredentials(),
|
|
1381
|
+
headers: {
|
|
1382
|
+
"Content-Type": "application/json",
|
|
1383
|
+
...options.getHeaders()
|
|
1384
|
+
}
|
|
1385
|
+
};
|
|
1386
|
+
}
|
|
1387
|
+
return {
|
|
1388
|
+
/**
|
|
1389
|
+
* List the tenant audit trail (newest first, paginated).
|
|
1390
|
+
* pageSize is clamped to 100 per the API contract.
|
|
1391
|
+
* Calls GET /api/v1/audit-log.
|
|
1392
|
+
*/
|
|
1393
|
+
async list(opts = {}) {
|
|
1394
|
+
const { page, pageSize } = buildPageParams({
|
|
1395
|
+
page: opts.page ?? 1,
|
|
1396
|
+
pageSize: opts.pageSize ?? 25
|
|
1397
|
+
});
|
|
1398
|
+
const params = {
|
|
1399
|
+
...opts.resourceType !== void 0 ? { resourceType: opts.resourceType } : {},
|
|
1400
|
+
...opts.resourceId !== void 0 ? { resourceId: opts.resourceId } : {},
|
|
1401
|
+
...opts.actorId !== void 0 ? { actorId: opts.actorId } : {},
|
|
1402
|
+
...opts.from !== void 0 ? { from: opts.from } : {},
|
|
1403
|
+
...opts.to !== void 0 ? { to: opts.to } : {},
|
|
1404
|
+
page,
|
|
1405
|
+
pageSize
|
|
1406
|
+
};
|
|
1407
|
+
const path = getAuditLogControllerListUrl(params);
|
|
1408
|
+
const url = `${baseUrl}${path}`;
|
|
1409
|
+
const res = await fetch(url, buildInit());
|
|
1410
|
+
return parseResponse(res);
|
|
1411
|
+
}
|
|
1412
|
+
};
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1243
1415
|
// src/ws/ws-client.ts
|
|
1244
1416
|
var import_socket = require("socket.io-client");
|
|
1245
1417
|
function createWsClient(options) {
|
|
@@ -1330,11 +1502,14 @@ function createOmnivoxClient(options) {
|
|
|
1330
1502
|
channels: createChannelsModule(moduleOptions),
|
|
1331
1503
|
contacts: createContactsModule(moduleOptions),
|
|
1332
1504
|
conversations: createConversationsModule(moduleOptions),
|
|
1505
|
+
participants: createParticipantsModule(moduleOptions),
|
|
1333
1506
|
messages: createMessagesModule(moduleOptions),
|
|
1334
1507
|
templates: createTemplatesModule(moduleOptions),
|
|
1335
1508
|
cannedResponses: createCannedResponsesModule(moduleOptions),
|
|
1336
1509
|
attachments: createAttachmentsModule(moduleOptions),
|
|
1337
1510
|
whatsappBusinessAccounts: createWhatsAppBusinessAccountsModule(moduleOptions),
|
|
1511
|
+
dashboard: createDashboardModule(moduleOptions),
|
|
1512
|
+
audit: createAuditModule(moduleOptions),
|
|
1338
1513
|
/**
|
|
1339
1514
|
* Creates a WebSocket client connected to the `/ws/chat` namespace.
|
|
1340
1515
|
*
|
|
@@ -1390,13 +1565,16 @@ function createSessionTokenProvider() {
|
|
|
1390
1565
|
createAgentsModule,
|
|
1391
1566
|
createApiKeyTokenProvider,
|
|
1392
1567
|
createAttachmentsModule,
|
|
1568
|
+
createAuditModule,
|
|
1393
1569
|
createAuthMeModule,
|
|
1394
1570
|
createCannedResponsesModule,
|
|
1395
1571
|
createChannelsModule,
|
|
1396
1572
|
createContactsModule,
|
|
1397
1573
|
createConversationsModule,
|
|
1574
|
+
createDashboardModule,
|
|
1398
1575
|
createMessagesModule,
|
|
1399
1576
|
createOmnivoxClient,
|
|
1577
|
+
createParticipantsModule,
|
|
1400
1578
|
createSessionTokenProvider,
|
|
1401
1579
|
createTemplatesModule,
|
|
1402
1580
|
createTenantsModule,
|
package/dist/index.d.cts
CHANGED
|
@@ -33,6 +33,169 @@ declare function createApiKeyTokenProvider(apiKey: string): TokenProvider;
|
|
|
33
33
|
*/
|
|
34
34
|
declare function createSessionTokenProvider(): TokenProvider;
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Audit module — hand-written typed wrapper over the generated client.
|
|
38
|
+
*
|
|
39
|
+
* Exposes the F16 audit-log read surface:
|
|
40
|
+
* - list(opts) → GET /api/v1/audit-log (pageSize capped at 100)
|
|
41
|
+
*
|
|
42
|
+
* Filterable by resourceType, resourceId, actorId and a createdAt time range
|
|
43
|
+
* (from/to), paginated, newest first. Read requires the AuditEntry read
|
|
44
|
+
* ability (global ADMIN agent or api_key/system actor).
|
|
45
|
+
*
|
|
46
|
+
* Never re-exports symbols from _generated/.
|
|
47
|
+
* Contains no business logic — typed transport only.
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
/** Options to construct the audit module. */
|
|
51
|
+
interface AuditModuleOptions extends TokenProvider {
|
|
52
|
+
/** Base URL of the Omnivox API (e.g. "https://api.omnivox.io"). */
|
|
53
|
+
baseUrl: string;
|
|
54
|
+
}
|
|
55
|
+
/** One audit-trail entry returned by GET /api/v1/audit-log. */
|
|
56
|
+
interface AuditEntry {
|
|
57
|
+
id: string;
|
|
58
|
+
/** Actor kind that produced the entry (e.g. "agent" | "api_key" | "system"). */
|
|
59
|
+
actorType: string;
|
|
60
|
+
/** Acting identity id; null for system-originated entries. */
|
|
61
|
+
actorId: string | null;
|
|
62
|
+
/** The audited action (e.g. "contact.update"). */
|
|
63
|
+
action: string;
|
|
64
|
+
/** The audited resource kind (e.g. "Contact"). */
|
|
65
|
+
resourceType: string;
|
|
66
|
+
/** The audited resource id. */
|
|
67
|
+
resourceId: string;
|
|
68
|
+
/** JSON-Patch-array diff of the change (forward-compat shape). */
|
|
69
|
+
diff: unknown;
|
|
70
|
+
/** Correlation id linking related entries; null when absent. */
|
|
71
|
+
correlationId: string | null;
|
|
72
|
+
createdAt: string;
|
|
73
|
+
[key: string]: unknown;
|
|
74
|
+
}
|
|
75
|
+
/** Paginated list response. */
|
|
76
|
+
interface PagedList$7<T> {
|
|
77
|
+
data: T[];
|
|
78
|
+
meta: {
|
|
79
|
+
page: number;
|
|
80
|
+
pageSize: number;
|
|
81
|
+
total: number;
|
|
82
|
+
hasNextPage: boolean;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/** Filter + pagination options for audit.list(). */
|
|
86
|
+
interface AuditListOpts {
|
|
87
|
+
/** Filter to entries whose resourceType matches exactly. */
|
|
88
|
+
resourceType?: string;
|
|
89
|
+
/** Filter to entries whose resourceId matches exactly. */
|
|
90
|
+
resourceId?: string;
|
|
91
|
+
/** Filter to entries produced by this actor id. */
|
|
92
|
+
actorId?: string;
|
|
93
|
+
/** Inclusive lower bound on createdAt (ISO 8601 date-time). */
|
|
94
|
+
from?: string;
|
|
95
|
+
/** Inclusive upper bound on createdAt (ISO 8601 date-time). */
|
|
96
|
+
to?: string;
|
|
97
|
+
/** Page number (1-based, default 1). */
|
|
98
|
+
page?: number;
|
|
99
|
+
/** Entries per page (default 25, clamped to 100). */
|
|
100
|
+
pageSize?: number;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Creates the audit module — a thin typed wrapper over the generated client.
|
|
104
|
+
*/
|
|
105
|
+
declare function createAuditModule(options: AuditModuleOptions): {
|
|
106
|
+
/**
|
|
107
|
+
* List the tenant audit trail (newest first, paginated).
|
|
108
|
+
* pageSize is clamped to 100 per the API contract.
|
|
109
|
+
* Calls GET /api/v1/audit-log.
|
|
110
|
+
*/
|
|
111
|
+
list(opts?: AuditListOpts): Promise<PagedList$7<AuditEntry>>;
|
|
112
|
+
};
|
|
113
|
+
/** Return type of createAuditModule. */
|
|
114
|
+
type AuditModule = ReturnType<typeof createAuditModule>;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Dashboard module — hand-written typed wrapper over the generated client.
|
|
118
|
+
*
|
|
119
|
+
* Exposes the F14 dashboard read surface:
|
|
120
|
+
* - stats() → GET /api/v1/dashboard/stats
|
|
121
|
+
* - recentActivity(opts) → GET /api/v1/dashboard/recent-activity (pageSize capped at 100)
|
|
122
|
+
*
|
|
123
|
+
* Never re-exports symbols from _generated/.
|
|
124
|
+
* Contains no business logic — typed transport only.
|
|
125
|
+
*/
|
|
126
|
+
|
|
127
|
+
/** Options to construct the dashboard module. */
|
|
128
|
+
interface DashboardModuleOptions extends TokenProvider {
|
|
129
|
+
/** Base URL of the Omnivox API (e.g. "https://api.omnivox.io"). */
|
|
130
|
+
baseUrl: string;
|
|
131
|
+
}
|
|
132
|
+
/** Tenant dashboard KPIs returned by GET /api/v1/dashboard/stats. */
|
|
133
|
+
interface DashboardStats {
|
|
134
|
+
/** Conversations not yet CLOSED (PENDING | OPEN | ON_HOLD). */
|
|
135
|
+
activeConversationsCount: number;
|
|
136
|
+
/** All contacts for the tenant. */
|
|
137
|
+
contactsCount: number;
|
|
138
|
+
/** OPEN conversations grouped by the linked contact identity's channel type. */
|
|
139
|
+
openByChannel: {
|
|
140
|
+
WHATSAPP: number;
|
|
141
|
+
EMAIL: number;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* OPEN conversations where the authenticated agent is an ACTIVE OWNER
|
|
145
|
+
* participant. 0 for api_key/system actors (no acting agent identity).
|
|
146
|
+
*/
|
|
147
|
+
myOpenCount: number;
|
|
148
|
+
}
|
|
149
|
+
/** One item in the tenant recent-activity feed. */
|
|
150
|
+
interface RecentActivityItem {
|
|
151
|
+
/** The underlying Message row's id — stable per-item identity for the feed. */
|
|
152
|
+
id: string;
|
|
153
|
+
conversationId: string;
|
|
154
|
+
/** The parent conversation's CURRENT status (not the status at message time). */
|
|
155
|
+
conversationStatus: 'PENDING' | 'OPEN' | 'ON_HOLD' | 'CLOSED';
|
|
156
|
+
/** The linked contact identity's channel type — same values as `openByChannel`. */
|
|
157
|
+
channelType: 'WHATSAPP' | 'EMAIL';
|
|
158
|
+
direction: 'INBOUND' | 'OUTBOUND';
|
|
159
|
+
type: 'TEXT' | 'IMAGE' | 'DOCUMENT' | 'AUDIO' | 'VIDEO' | 'TEMPLATE';
|
|
160
|
+
status: 'QUEUED' | 'SENT' | 'DELIVERED' | 'READ' | 'FAILED';
|
|
161
|
+
content: unknown;
|
|
162
|
+
createdAt: string;
|
|
163
|
+
[key: string]: unknown;
|
|
164
|
+
}
|
|
165
|
+
/** Paginated list response. */
|
|
166
|
+
interface PagedList$6<T> {
|
|
167
|
+
data: T[];
|
|
168
|
+
meta: {
|
|
169
|
+
page: number;
|
|
170
|
+
pageSize: number;
|
|
171
|
+
total: number;
|
|
172
|
+
hasNextPage: boolean;
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/** Pagination options for recentActivity(). */
|
|
176
|
+
interface RecentActivityListOpts {
|
|
177
|
+
page: number;
|
|
178
|
+
pageSize: number;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Creates the dashboard module — a thin typed wrapper over the generated client.
|
|
182
|
+
*/
|
|
183
|
+
declare function createDashboardModule(options: DashboardModuleOptions): {
|
|
184
|
+
/**
|
|
185
|
+
* Fetch the tenant dashboard KPIs.
|
|
186
|
+
* Calls GET /api/v1/dashboard/stats.
|
|
187
|
+
*/
|
|
188
|
+
stats(): Promise<DashboardStats>;
|
|
189
|
+
/**
|
|
190
|
+
* List the tenant's recent conversation/message activity feed
|
|
191
|
+
* (newest first, paginated). pageSize is clamped to 100 per the API
|
|
192
|
+
* contract. Calls GET /api/v1/dashboard/recent-activity.
|
|
193
|
+
*/
|
|
194
|
+
recentActivity(opts?: RecentActivityListOpts): Promise<PagedList$6<RecentActivityItem>>;
|
|
195
|
+
};
|
|
196
|
+
/** Return type of createDashboardModule. */
|
|
197
|
+
type DashboardModule = ReturnType<typeof createDashboardModule>;
|
|
198
|
+
|
|
36
199
|
/**
|
|
37
200
|
* Canned-responses module — hand-written typed wrapper over the generated client.
|
|
38
201
|
*
|
|
@@ -582,12 +745,30 @@ interface PickupInput {
|
|
|
582
745
|
agentId: string;
|
|
583
746
|
[key: string]: unknown;
|
|
584
747
|
}
|
|
585
|
-
/**
|
|
748
|
+
/**
|
|
749
|
+
* Base conversation resource shape returned by the API. This is what
|
|
750
|
+
* reopenOrCreate/updateStatus/assign respond with — those routes mutate the
|
|
751
|
+
* conversation or its participants but do not re-derive ownerAgentIds, so it
|
|
752
|
+
* is intentionally absent here. Adding it as required on this type would be a
|
|
753
|
+
* false type guarantee for those three methods.
|
|
754
|
+
*/
|
|
586
755
|
interface ConversationItem {
|
|
587
756
|
id: string;
|
|
588
757
|
status: string;
|
|
589
758
|
[key: string]: unknown;
|
|
590
759
|
}
|
|
760
|
+
/**
|
|
761
|
+
* LIST/DETAIL conversation resource shape — the base item plus
|
|
762
|
+
* `ownerAgentIds`, the agentIds of the conversation's ACTIVE OWNER
|
|
763
|
+
* participants (role=OWNER, leftAt IS NULL), ordered by joinedAt then
|
|
764
|
+
* agentId. An empty array means the conversation is unassigned. Only the
|
|
765
|
+
* LIST (`list()`) and DETAIL (`get()`) responses populate this field (FF-A);
|
|
766
|
+
* ownership lives in ConversationParticipant after F10. Mirrors the API's own
|
|
767
|
+
* ConversationOwnershipResult split (apps/api/src/conversations/conversations.service.ts).
|
|
768
|
+
*/
|
|
769
|
+
interface ConversationListItem extends ConversationItem {
|
|
770
|
+
ownerAgentIds: string[];
|
|
771
|
+
}
|
|
591
772
|
/** Lobby entry resource shape returned by the API. */
|
|
592
773
|
interface LobbyEntry {
|
|
593
774
|
id: string;
|
|
@@ -648,7 +829,7 @@ declare function createConversationsModule(options: ConversationsModuleOptions):
|
|
|
648
829
|
* pageSize is clamped to 100 per the API contract.
|
|
649
830
|
* Calls GET /api/v1/conversations.
|
|
650
831
|
*/
|
|
651
|
-
list(opts?: ConversationListOpts): Promise<PagedList$3<
|
|
832
|
+
list(opts?: ConversationListOpts): Promise<PagedList$3<ConversationListItem>>;
|
|
652
833
|
/**
|
|
653
834
|
* Update a conversation status via the state machine.
|
|
654
835
|
* Calls PATCH /api/v1/conversations/:id/status.
|
|
@@ -669,7 +850,7 @@ declare function createConversationsModule(options: ConversationsModuleOptions):
|
|
|
669
850
|
* Get a single conversation by ID.
|
|
670
851
|
* Calls GET /api/v1/conversations/:id.
|
|
671
852
|
*/
|
|
672
|
-
get(id: string): Promise<
|
|
853
|
+
get(id: string): Promise<ConversationListItem>;
|
|
673
854
|
/**
|
|
674
855
|
* Pick up a lobby entry (atomic 4-step transaction).
|
|
675
856
|
* Returns the resulting conversation + entry ids.
|
|
@@ -1038,11 +1219,12 @@ declare function createTenantsModule(options: TenantsModuleOptions): {
|
|
|
1038
1219
|
type TenantsModule = ReturnType<typeof createTenantsModule>;
|
|
1039
1220
|
|
|
1040
1221
|
/**
|
|
1041
|
-
* WS-only event payload registry — single source of truth for the
|
|
1222
|
+
* WS-only event payload registry — single source of truth for the six
|
|
1042
1223
|
* WS-only events that have no REST/openapi counterpart and therefore no
|
|
1043
1224
|
* orval → _generated pipeline:
|
|
1044
1225
|
*
|
|
1045
|
-
* typing:indicator · message:read:update · participant:joined ·
|
|
1226
|
+
* typing:indicator · message:read:update · participant:joined ·
|
|
1227
|
+
* participant:left · participant:added · participant:removed
|
|
1046
1228
|
*
|
|
1047
1229
|
* The runtime constant {@link WS_EVENT_REGISTRY} must stay byte-identical with
|
|
1048
1230
|
* ws-event-shapes.fixture.json. Two contract tests enforce this:
|
|
@@ -1087,6 +1269,28 @@ interface ParticipantPayload {
|
|
|
1087
1269
|
actor: unknown;
|
|
1088
1270
|
[key: string]: unknown;
|
|
1089
1271
|
}
|
|
1272
|
+
/**
|
|
1273
|
+
* Payload for the `participant:added` server → client event (F10/T08).
|
|
1274
|
+
* Emitted when an agent is added to a conversation's participant set — a
|
|
1275
|
+
* server-side membership mutation, distinct from the `participant:joined`
|
|
1276
|
+
* presence event.
|
|
1277
|
+
*/
|
|
1278
|
+
interface ParticipantAddedPayload {
|
|
1279
|
+
conversationId: string;
|
|
1280
|
+
agentId: string;
|
|
1281
|
+
role: string;
|
|
1282
|
+
[key: string]: unknown;
|
|
1283
|
+
}
|
|
1284
|
+
/**
|
|
1285
|
+
* Payload for the `participant:removed` server → client event (F10/T08).
|
|
1286
|
+
* Emitted when an agent is removed from a conversation's participant set; the
|
|
1287
|
+
* removed agent's sockets are also force-evicted from the room server-side.
|
|
1288
|
+
*/
|
|
1289
|
+
interface ParticipantRemovedPayload {
|
|
1290
|
+
conversationId: string;
|
|
1291
|
+
agentId: string;
|
|
1292
|
+
[key: string]: unknown;
|
|
1293
|
+
}
|
|
1090
1294
|
|
|
1091
1295
|
/**
|
|
1092
1296
|
* WebSocket client — hand-written typed wrapper over socket.io-client.
|
|
@@ -1160,6 +1364,8 @@ interface WsEventPayloads {
|
|
|
1160
1364
|
'message:read:update': MessageReadUpdatePayload;
|
|
1161
1365
|
'participant:joined': ParticipantPayload;
|
|
1162
1366
|
'participant:left': ParticipantPayload;
|
|
1367
|
+
'participant:added': ParticipantAddedPayload;
|
|
1368
|
+
'participant:removed': ParticipantRemovedPayload;
|
|
1163
1369
|
'typing:indicator': TypingIndicatorPayload;
|
|
1164
1370
|
}
|
|
1165
1371
|
/** The WebSocket client returned by {@link createWsClient}. */
|
|
@@ -1291,14 +1497,19 @@ declare function createOmnivoxClient(options: OmnivoxClientOptions): {
|
|
|
1291
1497
|
};
|
|
1292
1498
|
conversations: {
|
|
1293
1499
|
reopenOrCreate(input: ReopenOrCreateInput): Promise<ConversationItem>;
|
|
1294
|
-
list(opts?: ConversationListOpts): Promise<PagedList$3<
|
|
1500
|
+
list(opts?: ConversationListOpts): Promise<PagedList$3<ConversationListItem>>;
|
|
1295
1501
|
updateStatus(id: string, input: UpdateStatusInput): Promise<ConversationItem>;
|
|
1296
1502
|
assign(id: string, input: AssignInput): Promise<ConversationItem>;
|
|
1297
1503
|
listLobby(opts?: LobbyListOpts): Promise<PagedList$3<LobbyEntry>>;
|
|
1298
|
-
get(id: string): Promise<
|
|
1504
|
+
get(id: string): Promise<ConversationListItem>;
|
|
1299
1505
|
pickup(entryId: string, input: PickupInput): Promise<PickupResult>;
|
|
1300
1506
|
whatsappRecoveryOptions(id: string): Promise<WhatsAppRecoveryOption[]>;
|
|
1301
1507
|
};
|
|
1508
|
+
participants: {
|
|
1509
|
+
add(conversationId: string, input: AddParticipantInput): Promise<ParticipantItem>;
|
|
1510
|
+
remove(conversationId: string, agentId: string): Promise<RemoveParticipantResult>;
|
|
1511
|
+
list(conversationId: string): Promise<ParticipantItem[]>;
|
|
1512
|
+
};
|
|
1302
1513
|
messages: {
|
|
1303
1514
|
send(input: SendMessageInput): Promise<MessageItem>;
|
|
1304
1515
|
list(opts: MessageListOpts): Promise<PagedList$4<MessageItem>>;
|
|
@@ -1344,6 +1555,13 @@ declare function createOmnivoxClient(options: OmnivoxClientOptions): {
|
|
|
1344
1555
|
name: string;
|
|
1345
1556
|
}): Promise<WhatsAppBusinessAccountItem>;
|
|
1346
1557
|
};
|
|
1558
|
+
dashboard: {
|
|
1559
|
+
stats(): Promise<DashboardStats>;
|
|
1560
|
+
recentActivity(opts?: RecentActivityListOpts): Promise<PagedList$6<RecentActivityItem>>;
|
|
1561
|
+
};
|
|
1562
|
+
audit: {
|
|
1563
|
+
list(opts?: AuditListOpts): Promise<PagedList$7<AuditEntry>>;
|
|
1564
|
+
};
|
|
1347
1565
|
/**
|
|
1348
1566
|
* Creates a WebSocket client connected to the `/ws/chat` namespace.
|
|
1349
1567
|
*
|
|
@@ -1639,6 +1857,76 @@ declare function createChannelsModule(options: ChannelsModuleOptions): {
|
|
|
1639
1857
|
/** Return type of createChannelsModule. */
|
|
1640
1858
|
type ChannelsModule = ReturnType<typeof createChannelsModule>;
|
|
1641
1859
|
|
|
1860
|
+
/**
|
|
1861
|
+
* Conversation participants module — hand-written typed wrapper over the
|
|
1862
|
+
* generated client (F10/T09).
|
|
1863
|
+
*
|
|
1864
|
+
* Exposes the participant-management surface for the conversations resource:
|
|
1865
|
+
* - add(conversationId, input) → POST /api/v1/conversations/:id/participants
|
|
1866
|
+
* - remove(conversationId, agentId) → DELETE /api/v1/conversations/:id/participants/:agentId
|
|
1867
|
+
* - list(conversationId) → GET /api/v1/conversations/:id/participants
|
|
1868
|
+
*
|
|
1869
|
+
* All three routes are guarded server-side by CASL abilities (grant for
|
|
1870
|
+
* add/remove, read for list) — a 403 surfaces as an {@link OmnivoxRequestError}
|
|
1871
|
+
* with `status === 403` like any other rejected request.
|
|
1872
|
+
*
|
|
1873
|
+
* Never re-exports symbols from _generated/.
|
|
1874
|
+
* Contains no business logic — typed transport only.
|
|
1875
|
+
*/
|
|
1876
|
+
|
|
1877
|
+
/** Options to construct the participants module. */
|
|
1878
|
+
interface ParticipantsModuleOptions extends TokenProvider {
|
|
1879
|
+
/** Base URL of the Omnivox API (e.g. "https://api.omnivox.io"). */
|
|
1880
|
+
baseUrl: string;
|
|
1881
|
+
}
|
|
1882
|
+
/** A conversation participant's per-conversation role. */
|
|
1883
|
+
type ParticipantRole = 'OWNER' | 'AGENT' | 'VIEWER';
|
|
1884
|
+
/** Input for adding (or re-adding) a participant. */
|
|
1885
|
+
interface AddParticipantInput {
|
|
1886
|
+
agentId: string;
|
|
1887
|
+
role: ParticipantRole;
|
|
1888
|
+
[key: string]: unknown;
|
|
1889
|
+
}
|
|
1890
|
+
/** Participant resource shape returned by the API (no tenantId leak). */
|
|
1891
|
+
interface ParticipantItem {
|
|
1892
|
+
id: string;
|
|
1893
|
+
conversationId: string;
|
|
1894
|
+
agentId: string;
|
|
1895
|
+
role: ParticipantRole;
|
|
1896
|
+
joinedAt: string;
|
|
1897
|
+
leftAt: string | null;
|
|
1898
|
+
[key: string]: unknown;
|
|
1899
|
+
}
|
|
1900
|
+
/** Result of removing a participant — the number of memberships ended (0 or 1). */
|
|
1901
|
+
interface RemoveParticipantResult {
|
|
1902
|
+
removed: number;
|
|
1903
|
+
}
|
|
1904
|
+
/**
|
|
1905
|
+
* Creates the participants module — a thin typed wrapper over the generated client.
|
|
1906
|
+
*/
|
|
1907
|
+
declare function createParticipantsModule(options: ParticipantsModuleOptions): {
|
|
1908
|
+
/**
|
|
1909
|
+
* Add (or re-add) an agent as a conversation participant with a role.
|
|
1910
|
+
* Idempotent per active membership — re-adding an active participant
|
|
1911
|
+
* updates its role; a second OWNER co-owns (no demotion of other owners).
|
|
1912
|
+
* Calls POST /api/v1/conversations/:id/participants.
|
|
1913
|
+
*/
|
|
1914
|
+
add(conversationId: string, input: AddParticipantInput): Promise<ParticipantItem>;
|
|
1915
|
+
/**
|
|
1916
|
+
* End an active membership for an agent. Idempotent — removing a
|
|
1917
|
+
* non-participant is a no-op ({ removed: 0 }).
|
|
1918
|
+
* Calls DELETE /api/v1/conversations/:id/participants/:agentId.
|
|
1919
|
+
*/
|
|
1920
|
+
remove(conversationId: string, agentId: string): Promise<RemoveParticipantResult>;
|
|
1921
|
+
/**
|
|
1922
|
+
* List the ACTIVE (leftAt IS NULL) participants of a conversation.
|
|
1923
|
+
* Calls GET /api/v1/conversations/:id/participants.
|
|
1924
|
+
*/
|
|
1925
|
+
list(conversationId: string): Promise<ParticipantItem[]>;
|
|
1926
|
+
};
|
|
1927
|
+
/** Return type of createParticipantsModule. */
|
|
1928
|
+
type ParticipantsModule = ReturnType<typeof createParticipantsModule>;
|
|
1929
|
+
|
|
1642
1930
|
/**
|
|
1643
1931
|
* Attachments module — hand-written typed wrapper over the generated client.
|
|
1644
1932
|
*
|
|
@@ -1807,4 +2095,4 @@ declare function createWhatsAppBusinessAccountsModule(options: WhatsAppBusinessA
|
|
|
1807
2095
|
/** Return type of createWhatsAppBusinessAccountsModule. */
|
|
1808
2096
|
type WhatsAppBusinessAccountsModule = ReturnType<typeof createWhatsAppBusinessAccountsModule>;
|
|
1809
2097
|
|
|
1810
|
-
export { type AddIdentityInput, type AgentItem, type AgentsModule, type AgentsModuleOptions, type ApiKeyItem, type AssignInput, type AttachmentUploadResult, type AttachmentUrlResult, type AttachmentsModule, type AttachmentsModuleOptions, type AuthMeAgent, type AuthMeModule, type AuthMeModuleOptions, type AuthMeResponse, type AuthMeTenant, type AuthorDraftInput, type BasicEmailChannelConfig, type BasicEmailChannelSecret, type CannedResponseItem, type CannedResponseListOpts, type CannedResponseSearchOpts, type CannedResponsesModule, type CannedResponsesModuleOptions, type Channel, type ChannelListItem, type ChannelStatus, type ChannelType, type ChannelsModule, type ChannelsModuleOptions, type ContactChannel, type ContactConversationSummary, type ContactFieldDefinition, type ContactFieldValue, type ContactFieldValueInput, type ContactIdentity, type ContactIdentityInput, type ContactItem, type ContactSearchOpts, type ContactTag, type ContactsMetadata, type ContactsModule, type ContactsModuleOptions, type ConversationItem, type ConversationListOpts, type ConversationsModule, type ConversationsModuleOptions, type CreateAgentInput, type CreateApiKeyInput, type CreateApiKeyResponse, type CreateCannedResponseInput, type CreateChannelBody, type CreateContactInput, type CreateEmailChannelBody, type CreateEmailTemplateInput, type CreateWhatsAppBusinessAccountBody, type CreateWhatsAppChannelBody, type CredentialsMode, type EmailChannelConfig, type EmailChannelSecret, type EmailImapConfig, type EmailSmtpConfig, type EmailTemplateItem, type EmailTemplateListOpts, type ImportApprovedResult, type ImportedTemplateResult, type LobbyEntry, type LobbyListOpts, type MessageItem, type MessageListOpts, type MessageReadUpdatePayload, type MessageStatusPayload, type MessagesModule, type MessagesModuleOptions, type OAuth2CertificateEmailChannelSecret, type OAuth2ClientSecretEmailChannelSecret, type OAuth2EmailChannelConfig, type OAuth2EmailChannelSecret, type OmnivoxClient, type OmnivoxClientOptions, OmnivoxRequestError, type PageOpts, type PageParams, type PagedResponse, type ParticipantPayload, type PatchContactInput, type PatchEmailTemplateInput, type PickupInput, type ReopenOrCreateInput, type RevokeApiKeyResponse, type SendMessageInput, type SendTemplateInput, type SubmitResult, type TemplatesModule, type TemplatesModuleOptions, type TenantsModule, type TenantsModuleOptions, type TokenProvider, type TypingIndicatorPayload, type UpdateCannedResponseInput, type UpdateChannelBody, type UpdateStatusInput, type UpdateWhatsAppTemplateInput, type WhatsAppBusinessAccountItem, type WhatsAppBusinessAccountsModule, type WhatsAppBusinessAccountsModuleOptions, type WhatsAppChannelConfig, type WhatsAppRecoveryOption, type WhatsAppTemplateDetail, type WhatsAppTemplateHistory, type WhatsAppTemplateHistoryEvent, type WhatsAppTemplateHistoryVersion, type WhatsAppTemplateItem, type WhatsAppTemplateListOpts, type WsAuth, type WsClient, type WsClientInstance, type WsClientOptions, type WsConnectionState, type WsEventPayloads, buildPageParams, createAgentsModule, createApiKeyTokenProvider, createAttachmentsModule, createAuthMeModule, createCannedResponsesModule, createChannelsModule, createContactsModule, createConversationsModule, createMessagesModule, createOmnivoxClient, createSessionTokenProvider, createTemplatesModule, createTenantsModule, createWhatsAppBusinessAccountsModule, createWsClient, iteratePages };
|
|
2098
|
+
export { type AddIdentityInput, type AddParticipantInput, type AgentItem, type AgentsModule, type AgentsModuleOptions, type ApiKeyItem, type AssignInput, type AttachmentUploadResult, type AttachmentUrlResult, type AttachmentsModule, type AttachmentsModuleOptions, type AuditEntry, type AuditListOpts, type AuditModule, type AuditModuleOptions, type AuthMeAgent, type AuthMeModule, type AuthMeModuleOptions, type AuthMeResponse, type AuthMeTenant, type AuthorDraftInput, type BasicEmailChannelConfig, type BasicEmailChannelSecret, type CannedResponseItem, type CannedResponseListOpts, type CannedResponseSearchOpts, type CannedResponsesModule, type CannedResponsesModuleOptions, type Channel, type ChannelListItem, type ChannelStatus, type ChannelType, type ChannelsModule, type ChannelsModuleOptions, type ContactChannel, type ContactConversationSummary, type ContactFieldDefinition, type ContactFieldValue, type ContactFieldValueInput, type ContactIdentity, type ContactIdentityInput, type ContactItem, type ContactSearchOpts, type ContactTag, type ContactsMetadata, type ContactsModule, type ContactsModuleOptions, type ConversationItem, type ConversationListItem, type ConversationListOpts, type ConversationsModule, type ConversationsModuleOptions, type CreateAgentInput, type CreateApiKeyInput, type CreateApiKeyResponse, type CreateCannedResponseInput, type CreateChannelBody, type CreateContactInput, type CreateEmailChannelBody, type CreateEmailTemplateInput, type CreateWhatsAppBusinessAccountBody, type CreateWhatsAppChannelBody, type CredentialsMode, type DashboardModule, type DashboardModuleOptions, type DashboardStats, type EmailChannelConfig, type EmailChannelSecret, type EmailImapConfig, type EmailSmtpConfig, type EmailTemplateItem, type EmailTemplateListOpts, type ImportApprovedResult, type ImportedTemplateResult, type LobbyEntry, type LobbyListOpts, type MessageItem, type MessageListOpts, type MessageReadUpdatePayload, type MessageStatusPayload, type MessagesModule, type MessagesModuleOptions, type OAuth2CertificateEmailChannelSecret, type OAuth2ClientSecretEmailChannelSecret, type OAuth2EmailChannelConfig, type OAuth2EmailChannelSecret, type OmnivoxClient, type OmnivoxClientOptions, OmnivoxRequestError, type PageOpts, type PageParams, type PagedResponse, type ParticipantAddedPayload, type ParticipantItem, type ParticipantPayload, type ParticipantRemovedPayload, type ParticipantRole, type ParticipantsModule, type ParticipantsModuleOptions, type PatchContactInput, type PatchEmailTemplateInput, type PickupInput, type RecentActivityItem, type RecentActivityListOpts, type RemoveParticipantResult, type ReopenOrCreateInput, type RevokeApiKeyResponse, type SendMessageInput, type SendTemplateInput, type SubmitResult, type TemplatesModule, type TemplatesModuleOptions, type TenantsModule, type TenantsModuleOptions, type TokenProvider, type TypingIndicatorPayload, type UpdateCannedResponseInput, type UpdateChannelBody, type UpdateStatusInput, type UpdateWhatsAppTemplateInput, type WhatsAppBusinessAccountItem, type WhatsAppBusinessAccountsModule, type WhatsAppBusinessAccountsModuleOptions, type WhatsAppChannelConfig, type WhatsAppRecoveryOption, type WhatsAppTemplateDetail, type WhatsAppTemplateHistory, type WhatsAppTemplateHistoryEvent, type WhatsAppTemplateHistoryVersion, type WhatsAppTemplateItem, type WhatsAppTemplateListOpts, type WsAuth, type WsClient, type WsClientInstance, type WsClientOptions, type WsConnectionState, type WsEventPayloads, buildPageParams, createAgentsModule, createApiKeyTokenProvider, createAttachmentsModule, createAuditModule, createAuthMeModule, createCannedResponsesModule, createChannelsModule, createContactsModule, createConversationsModule, createDashboardModule, createMessagesModule, createOmnivoxClient, createParticipantsModule, createSessionTokenProvider, createTemplatesModule, createTenantsModule, createWhatsAppBusinessAccountsModule, createWsClient, iteratePages };
|
package/dist/index.d.ts
CHANGED
|
@@ -33,6 +33,169 @@ declare function createApiKeyTokenProvider(apiKey: string): TokenProvider;
|
|
|
33
33
|
*/
|
|
34
34
|
declare function createSessionTokenProvider(): TokenProvider;
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Audit module — hand-written typed wrapper over the generated client.
|
|
38
|
+
*
|
|
39
|
+
* Exposes the F16 audit-log read surface:
|
|
40
|
+
* - list(opts) → GET /api/v1/audit-log (pageSize capped at 100)
|
|
41
|
+
*
|
|
42
|
+
* Filterable by resourceType, resourceId, actorId and a createdAt time range
|
|
43
|
+
* (from/to), paginated, newest first. Read requires the AuditEntry read
|
|
44
|
+
* ability (global ADMIN agent or api_key/system actor).
|
|
45
|
+
*
|
|
46
|
+
* Never re-exports symbols from _generated/.
|
|
47
|
+
* Contains no business logic — typed transport only.
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
/** Options to construct the audit module. */
|
|
51
|
+
interface AuditModuleOptions extends TokenProvider {
|
|
52
|
+
/** Base URL of the Omnivox API (e.g. "https://api.omnivox.io"). */
|
|
53
|
+
baseUrl: string;
|
|
54
|
+
}
|
|
55
|
+
/** One audit-trail entry returned by GET /api/v1/audit-log. */
|
|
56
|
+
interface AuditEntry {
|
|
57
|
+
id: string;
|
|
58
|
+
/** Actor kind that produced the entry (e.g. "agent" | "api_key" | "system"). */
|
|
59
|
+
actorType: string;
|
|
60
|
+
/** Acting identity id; null for system-originated entries. */
|
|
61
|
+
actorId: string | null;
|
|
62
|
+
/** The audited action (e.g. "contact.update"). */
|
|
63
|
+
action: string;
|
|
64
|
+
/** The audited resource kind (e.g. "Contact"). */
|
|
65
|
+
resourceType: string;
|
|
66
|
+
/** The audited resource id. */
|
|
67
|
+
resourceId: string;
|
|
68
|
+
/** JSON-Patch-array diff of the change (forward-compat shape). */
|
|
69
|
+
diff: unknown;
|
|
70
|
+
/** Correlation id linking related entries; null when absent. */
|
|
71
|
+
correlationId: string | null;
|
|
72
|
+
createdAt: string;
|
|
73
|
+
[key: string]: unknown;
|
|
74
|
+
}
|
|
75
|
+
/** Paginated list response. */
|
|
76
|
+
interface PagedList$7<T> {
|
|
77
|
+
data: T[];
|
|
78
|
+
meta: {
|
|
79
|
+
page: number;
|
|
80
|
+
pageSize: number;
|
|
81
|
+
total: number;
|
|
82
|
+
hasNextPage: boolean;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/** Filter + pagination options for audit.list(). */
|
|
86
|
+
interface AuditListOpts {
|
|
87
|
+
/** Filter to entries whose resourceType matches exactly. */
|
|
88
|
+
resourceType?: string;
|
|
89
|
+
/** Filter to entries whose resourceId matches exactly. */
|
|
90
|
+
resourceId?: string;
|
|
91
|
+
/** Filter to entries produced by this actor id. */
|
|
92
|
+
actorId?: string;
|
|
93
|
+
/** Inclusive lower bound on createdAt (ISO 8601 date-time). */
|
|
94
|
+
from?: string;
|
|
95
|
+
/** Inclusive upper bound on createdAt (ISO 8601 date-time). */
|
|
96
|
+
to?: string;
|
|
97
|
+
/** Page number (1-based, default 1). */
|
|
98
|
+
page?: number;
|
|
99
|
+
/** Entries per page (default 25, clamped to 100). */
|
|
100
|
+
pageSize?: number;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Creates the audit module — a thin typed wrapper over the generated client.
|
|
104
|
+
*/
|
|
105
|
+
declare function createAuditModule(options: AuditModuleOptions): {
|
|
106
|
+
/**
|
|
107
|
+
* List the tenant audit trail (newest first, paginated).
|
|
108
|
+
* pageSize is clamped to 100 per the API contract.
|
|
109
|
+
* Calls GET /api/v1/audit-log.
|
|
110
|
+
*/
|
|
111
|
+
list(opts?: AuditListOpts): Promise<PagedList$7<AuditEntry>>;
|
|
112
|
+
};
|
|
113
|
+
/** Return type of createAuditModule. */
|
|
114
|
+
type AuditModule = ReturnType<typeof createAuditModule>;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Dashboard module — hand-written typed wrapper over the generated client.
|
|
118
|
+
*
|
|
119
|
+
* Exposes the F14 dashboard read surface:
|
|
120
|
+
* - stats() → GET /api/v1/dashboard/stats
|
|
121
|
+
* - recentActivity(opts) → GET /api/v1/dashboard/recent-activity (pageSize capped at 100)
|
|
122
|
+
*
|
|
123
|
+
* Never re-exports symbols from _generated/.
|
|
124
|
+
* Contains no business logic — typed transport only.
|
|
125
|
+
*/
|
|
126
|
+
|
|
127
|
+
/** Options to construct the dashboard module. */
|
|
128
|
+
interface DashboardModuleOptions extends TokenProvider {
|
|
129
|
+
/** Base URL of the Omnivox API (e.g. "https://api.omnivox.io"). */
|
|
130
|
+
baseUrl: string;
|
|
131
|
+
}
|
|
132
|
+
/** Tenant dashboard KPIs returned by GET /api/v1/dashboard/stats. */
|
|
133
|
+
interface DashboardStats {
|
|
134
|
+
/** Conversations not yet CLOSED (PENDING | OPEN | ON_HOLD). */
|
|
135
|
+
activeConversationsCount: number;
|
|
136
|
+
/** All contacts for the tenant. */
|
|
137
|
+
contactsCount: number;
|
|
138
|
+
/** OPEN conversations grouped by the linked contact identity's channel type. */
|
|
139
|
+
openByChannel: {
|
|
140
|
+
WHATSAPP: number;
|
|
141
|
+
EMAIL: number;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* OPEN conversations where the authenticated agent is an ACTIVE OWNER
|
|
145
|
+
* participant. 0 for api_key/system actors (no acting agent identity).
|
|
146
|
+
*/
|
|
147
|
+
myOpenCount: number;
|
|
148
|
+
}
|
|
149
|
+
/** One item in the tenant recent-activity feed. */
|
|
150
|
+
interface RecentActivityItem {
|
|
151
|
+
/** The underlying Message row's id — stable per-item identity for the feed. */
|
|
152
|
+
id: string;
|
|
153
|
+
conversationId: string;
|
|
154
|
+
/** The parent conversation's CURRENT status (not the status at message time). */
|
|
155
|
+
conversationStatus: 'PENDING' | 'OPEN' | 'ON_HOLD' | 'CLOSED';
|
|
156
|
+
/** The linked contact identity's channel type — same values as `openByChannel`. */
|
|
157
|
+
channelType: 'WHATSAPP' | 'EMAIL';
|
|
158
|
+
direction: 'INBOUND' | 'OUTBOUND';
|
|
159
|
+
type: 'TEXT' | 'IMAGE' | 'DOCUMENT' | 'AUDIO' | 'VIDEO' | 'TEMPLATE';
|
|
160
|
+
status: 'QUEUED' | 'SENT' | 'DELIVERED' | 'READ' | 'FAILED';
|
|
161
|
+
content: unknown;
|
|
162
|
+
createdAt: string;
|
|
163
|
+
[key: string]: unknown;
|
|
164
|
+
}
|
|
165
|
+
/** Paginated list response. */
|
|
166
|
+
interface PagedList$6<T> {
|
|
167
|
+
data: T[];
|
|
168
|
+
meta: {
|
|
169
|
+
page: number;
|
|
170
|
+
pageSize: number;
|
|
171
|
+
total: number;
|
|
172
|
+
hasNextPage: boolean;
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/** Pagination options for recentActivity(). */
|
|
176
|
+
interface RecentActivityListOpts {
|
|
177
|
+
page: number;
|
|
178
|
+
pageSize: number;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Creates the dashboard module — a thin typed wrapper over the generated client.
|
|
182
|
+
*/
|
|
183
|
+
declare function createDashboardModule(options: DashboardModuleOptions): {
|
|
184
|
+
/**
|
|
185
|
+
* Fetch the tenant dashboard KPIs.
|
|
186
|
+
* Calls GET /api/v1/dashboard/stats.
|
|
187
|
+
*/
|
|
188
|
+
stats(): Promise<DashboardStats>;
|
|
189
|
+
/**
|
|
190
|
+
* List the tenant's recent conversation/message activity feed
|
|
191
|
+
* (newest first, paginated). pageSize is clamped to 100 per the API
|
|
192
|
+
* contract. Calls GET /api/v1/dashboard/recent-activity.
|
|
193
|
+
*/
|
|
194
|
+
recentActivity(opts?: RecentActivityListOpts): Promise<PagedList$6<RecentActivityItem>>;
|
|
195
|
+
};
|
|
196
|
+
/** Return type of createDashboardModule. */
|
|
197
|
+
type DashboardModule = ReturnType<typeof createDashboardModule>;
|
|
198
|
+
|
|
36
199
|
/**
|
|
37
200
|
* Canned-responses module — hand-written typed wrapper over the generated client.
|
|
38
201
|
*
|
|
@@ -582,12 +745,30 @@ interface PickupInput {
|
|
|
582
745
|
agentId: string;
|
|
583
746
|
[key: string]: unknown;
|
|
584
747
|
}
|
|
585
|
-
/**
|
|
748
|
+
/**
|
|
749
|
+
* Base conversation resource shape returned by the API. This is what
|
|
750
|
+
* reopenOrCreate/updateStatus/assign respond with — those routes mutate the
|
|
751
|
+
* conversation or its participants but do not re-derive ownerAgentIds, so it
|
|
752
|
+
* is intentionally absent here. Adding it as required on this type would be a
|
|
753
|
+
* false type guarantee for those three methods.
|
|
754
|
+
*/
|
|
586
755
|
interface ConversationItem {
|
|
587
756
|
id: string;
|
|
588
757
|
status: string;
|
|
589
758
|
[key: string]: unknown;
|
|
590
759
|
}
|
|
760
|
+
/**
|
|
761
|
+
* LIST/DETAIL conversation resource shape — the base item plus
|
|
762
|
+
* `ownerAgentIds`, the agentIds of the conversation's ACTIVE OWNER
|
|
763
|
+
* participants (role=OWNER, leftAt IS NULL), ordered by joinedAt then
|
|
764
|
+
* agentId. An empty array means the conversation is unassigned. Only the
|
|
765
|
+
* LIST (`list()`) and DETAIL (`get()`) responses populate this field (FF-A);
|
|
766
|
+
* ownership lives in ConversationParticipant after F10. Mirrors the API's own
|
|
767
|
+
* ConversationOwnershipResult split (apps/api/src/conversations/conversations.service.ts).
|
|
768
|
+
*/
|
|
769
|
+
interface ConversationListItem extends ConversationItem {
|
|
770
|
+
ownerAgentIds: string[];
|
|
771
|
+
}
|
|
591
772
|
/** Lobby entry resource shape returned by the API. */
|
|
592
773
|
interface LobbyEntry {
|
|
593
774
|
id: string;
|
|
@@ -648,7 +829,7 @@ declare function createConversationsModule(options: ConversationsModuleOptions):
|
|
|
648
829
|
* pageSize is clamped to 100 per the API contract.
|
|
649
830
|
* Calls GET /api/v1/conversations.
|
|
650
831
|
*/
|
|
651
|
-
list(opts?: ConversationListOpts): Promise<PagedList$3<
|
|
832
|
+
list(opts?: ConversationListOpts): Promise<PagedList$3<ConversationListItem>>;
|
|
652
833
|
/**
|
|
653
834
|
* Update a conversation status via the state machine.
|
|
654
835
|
* Calls PATCH /api/v1/conversations/:id/status.
|
|
@@ -669,7 +850,7 @@ declare function createConversationsModule(options: ConversationsModuleOptions):
|
|
|
669
850
|
* Get a single conversation by ID.
|
|
670
851
|
* Calls GET /api/v1/conversations/:id.
|
|
671
852
|
*/
|
|
672
|
-
get(id: string): Promise<
|
|
853
|
+
get(id: string): Promise<ConversationListItem>;
|
|
673
854
|
/**
|
|
674
855
|
* Pick up a lobby entry (atomic 4-step transaction).
|
|
675
856
|
* Returns the resulting conversation + entry ids.
|
|
@@ -1038,11 +1219,12 @@ declare function createTenantsModule(options: TenantsModuleOptions): {
|
|
|
1038
1219
|
type TenantsModule = ReturnType<typeof createTenantsModule>;
|
|
1039
1220
|
|
|
1040
1221
|
/**
|
|
1041
|
-
* WS-only event payload registry — single source of truth for the
|
|
1222
|
+
* WS-only event payload registry — single source of truth for the six
|
|
1042
1223
|
* WS-only events that have no REST/openapi counterpart and therefore no
|
|
1043
1224
|
* orval → _generated pipeline:
|
|
1044
1225
|
*
|
|
1045
|
-
* typing:indicator · message:read:update · participant:joined ·
|
|
1226
|
+
* typing:indicator · message:read:update · participant:joined ·
|
|
1227
|
+
* participant:left · participant:added · participant:removed
|
|
1046
1228
|
*
|
|
1047
1229
|
* The runtime constant {@link WS_EVENT_REGISTRY} must stay byte-identical with
|
|
1048
1230
|
* ws-event-shapes.fixture.json. Two contract tests enforce this:
|
|
@@ -1087,6 +1269,28 @@ interface ParticipantPayload {
|
|
|
1087
1269
|
actor: unknown;
|
|
1088
1270
|
[key: string]: unknown;
|
|
1089
1271
|
}
|
|
1272
|
+
/**
|
|
1273
|
+
* Payload for the `participant:added` server → client event (F10/T08).
|
|
1274
|
+
* Emitted when an agent is added to a conversation's participant set — a
|
|
1275
|
+
* server-side membership mutation, distinct from the `participant:joined`
|
|
1276
|
+
* presence event.
|
|
1277
|
+
*/
|
|
1278
|
+
interface ParticipantAddedPayload {
|
|
1279
|
+
conversationId: string;
|
|
1280
|
+
agentId: string;
|
|
1281
|
+
role: string;
|
|
1282
|
+
[key: string]: unknown;
|
|
1283
|
+
}
|
|
1284
|
+
/**
|
|
1285
|
+
* Payload for the `participant:removed` server → client event (F10/T08).
|
|
1286
|
+
* Emitted when an agent is removed from a conversation's participant set; the
|
|
1287
|
+
* removed agent's sockets are also force-evicted from the room server-side.
|
|
1288
|
+
*/
|
|
1289
|
+
interface ParticipantRemovedPayload {
|
|
1290
|
+
conversationId: string;
|
|
1291
|
+
agentId: string;
|
|
1292
|
+
[key: string]: unknown;
|
|
1293
|
+
}
|
|
1090
1294
|
|
|
1091
1295
|
/**
|
|
1092
1296
|
* WebSocket client — hand-written typed wrapper over socket.io-client.
|
|
@@ -1160,6 +1364,8 @@ interface WsEventPayloads {
|
|
|
1160
1364
|
'message:read:update': MessageReadUpdatePayload;
|
|
1161
1365
|
'participant:joined': ParticipantPayload;
|
|
1162
1366
|
'participant:left': ParticipantPayload;
|
|
1367
|
+
'participant:added': ParticipantAddedPayload;
|
|
1368
|
+
'participant:removed': ParticipantRemovedPayload;
|
|
1163
1369
|
'typing:indicator': TypingIndicatorPayload;
|
|
1164
1370
|
}
|
|
1165
1371
|
/** The WebSocket client returned by {@link createWsClient}. */
|
|
@@ -1291,14 +1497,19 @@ declare function createOmnivoxClient(options: OmnivoxClientOptions): {
|
|
|
1291
1497
|
};
|
|
1292
1498
|
conversations: {
|
|
1293
1499
|
reopenOrCreate(input: ReopenOrCreateInput): Promise<ConversationItem>;
|
|
1294
|
-
list(opts?: ConversationListOpts): Promise<PagedList$3<
|
|
1500
|
+
list(opts?: ConversationListOpts): Promise<PagedList$3<ConversationListItem>>;
|
|
1295
1501
|
updateStatus(id: string, input: UpdateStatusInput): Promise<ConversationItem>;
|
|
1296
1502
|
assign(id: string, input: AssignInput): Promise<ConversationItem>;
|
|
1297
1503
|
listLobby(opts?: LobbyListOpts): Promise<PagedList$3<LobbyEntry>>;
|
|
1298
|
-
get(id: string): Promise<
|
|
1504
|
+
get(id: string): Promise<ConversationListItem>;
|
|
1299
1505
|
pickup(entryId: string, input: PickupInput): Promise<PickupResult>;
|
|
1300
1506
|
whatsappRecoveryOptions(id: string): Promise<WhatsAppRecoveryOption[]>;
|
|
1301
1507
|
};
|
|
1508
|
+
participants: {
|
|
1509
|
+
add(conversationId: string, input: AddParticipantInput): Promise<ParticipantItem>;
|
|
1510
|
+
remove(conversationId: string, agentId: string): Promise<RemoveParticipantResult>;
|
|
1511
|
+
list(conversationId: string): Promise<ParticipantItem[]>;
|
|
1512
|
+
};
|
|
1302
1513
|
messages: {
|
|
1303
1514
|
send(input: SendMessageInput): Promise<MessageItem>;
|
|
1304
1515
|
list(opts: MessageListOpts): Promise<PagedList$4<MessageItem>>;
|
|
@@ -1344,6 +1555,13 @@ declare function createOmnivoxClient(options: OmnivoxClientOptions): {
|
|
|
1344
1555
|
name: string;
|
|
1345
1556
|
}): Promise<WhatsAppBusinessAccountItem>;
|
|
1346
1557
|
};
|
|
1558
|
+
dashboard: {
|
|
1559
|
+
stats(): Promise<DashboardStats>;
|
|
1560
|
+
recentActivity(opts?: RecentActivityListOpts): Promise<PagedList$6<RecentActivityItem>>;
|
|
1561
|
+
};
|
|
1562
|
+
audit: {
|
|
1563
|
+
list(opts?: AuditListOpts): Promise<PagedList$7<AuditEntry>>;
|
|
1564
|
+
};
|
|
1347
1565
|
/**
|
|
1348
1566
|
* Creates a WebSocket client connected to the `/ws/chat` namespace.
|
|
1349
1567
|
*
|
|
@@ -1639,6 +1857,76 @@ declare function createChannelsModule(options: ChannelsModuleOptions): {
|
|
|
1639
1857
|
/** Return type of createChannelsModule. */
|
|
1640
1858
|
type ChannelsModule = ReturnType<typeof createChannelsModule>;
|
|
1641
1859
|
|
|
1860
|
+
/**
|
|
1861
|
+
* Conversation participants module — hand-written typed wrapper over the
|
|
1862
|
+
* generated client (F10/T09).
|
|
1863
|
+
*
|
|
1864
|
+
* Exposes the participant-management surface for the conversations resource:
|
|
1865
|
+
* - add(conversationId, input) → POST /api/v1/conversations/:id/participants
|
|
1866
|
+
* - remove(conversationId, agentId) → DELETE /api/v1/conversations/:id/participants/:agentId
|
|
1867
|
+
* - list(conversationId) → GET /api/v1/conversations/:id/participants
|
|
1868
|
+
*
|
|
1869
|
+
* All three routes are guarded server-side by CASL abilities (grant for
|
|
1870
|
+
* add/remove, read for list) — a 403 surfaces as an {@link OmnivoxRequestError}
|
|
1871
|
+
* with `status === 403` like any other rejected request.
|
|
1872
|
+
*
|
|
1873
|
+
* Never re-exports symbols from _generated/.
|
|
1874
|
+
* Contains no business logic — typed transport only.
|
|
1875
|
+
*/
|
|
1876
|
+
|
|
1877
|
+
/** Options to construct the participants module. */
|
|
1878
|
+
interface ParticipantsModuleOptions extends TokenProvider {
|
|
1879
|
+
/** Base URL of the Omnivox API (e.g. "https://api.omnivox.io"). */
|
|
1880
|
+
baseUrl: string;
|
|
1881
|
+
}
|
|
1882
|
+
/** A conversation participant's per-conversation role. */
|
|
1883
|
+
type ParticipantRole = 'OWNER' | 'AGENT' | 'VIEWER';
|
|
1884
|
+
/** Input for adding (or re-adding) a participant. */
|
|
1885
|
+
interface AddParticipantInput {
|
|
1886
|
+
agentId: string;
|
|
1887
|
+
role: ParticipantRole;
|
|
1888
|
+
[key: string]: unknown;
|
|
1889
|
+
}
|
|
1890
|
+
/** Participant resource shape returned by the API (no tenantId leak). */
|
|
1891
|
+
interface ParticipantItem {
|
|
1892
|
+
id: string;
|
|
1893
|
+
conversationId: string;
|
|
1894
|
+
agentId: string;
|
|
1895
|
+
role: ParticipantRole;
|
|
1896
|
+
joinedAt: string;
|
|
1897
|
+
leftAt: string | null;
|
|
1898
|
+
[key: string]: unknown;
|
|
1899
|
+
}
|
|
1900
|
+
/** Result of removing a participant — the number of memberships ended (0 or 1). */
|
|
1901
|
+
interface RemoveParticipantResult {
|
|
1902
|
+
removed: number;
|
|
1903
|
+
}
|
|
1904
|
+
/**
|
|
1905
|
+
* Creates the participants module — a thin typed wrapper over the generated client.
|
|
1906
|
+
*/
|
|
1907
|
+
declare function createParticipantsModule(options: ParticipantsModuleOptions): {
|
|
1908
|
+
/**
|
|
1909
|
+
* Add (or re-add) an agent as a conversation participant with a role.
|
|
1910
|
+
* Idempotent per active membership — re-adding an active participant
|
|
1911
|
+
* updates its role; a second OWNER co-owns (no demotion of other owners).
|
|
1912
|
+
* Calls POST /api/v1/conversations/:id/participants.
|
|
1913
|
+
*/
|
|
1914
|
+
add(conversationId: string, input: AddParticipantInput): Promise<ParticipantItem>;
|
|
1915
|
+
/**
|
|
1916
|
+
* End an active membership for an agent. Idempotent — removing a
|
|
1917
|
+
* non-participant is a no-op ({ removed: 0 }).
|
|
1918
|
+
* Calls DELETE /api/v1/conversations/:id/participants/:agentId.
|
|
1919
|
+
*/
|
|
1920
|
+
remove(conversationId: string, agentId: string): Promise<RemoveParticipantResult>;
|
|
1921
|
+
/**
|
|
1922
|
+
* List the ACTIVE (leftAt IS NULL) participants of a conversation.
|
|
1923
|
+
* Calls GET /api/v1/conversations/:id/participants.
|
|
1924
|
+
*/
|
|
1925
|
+
list(conversationId: string): Promise<ParticipantItem[]>;
|
|
1926
|
+
};
|
|
1927
|
+
/** Return type of createParticipantsModule. */
|
|
1928
|
+
type ParticipantsModule = ReturnType<typeof createParticipantsModule>;
|
|
1929
|
+
|
|
1642
1930
|
/**
|
|
1643
1931
|
* Attachments module — hand-written typed wrapper over the generated client.
|
|
1644
1932
|
*
|
|
@@ -1807,4 +2095,4 @@ declare function createWhatsAppBusinessAccountsModule(options: WhatsAppBusinessA
|
|
|
1807
2095
|
/** Return type of createWhatsAppBusinessAccountsModule. */
|
|
1808
2096
|
type WhatsAppBusinessAccountsModule = ReturnType<typeof createWhatsAppBusinessAccountsModule>;
|
|
1809
2097
|
|
|
1810
|
-
export { type AddIdentityInput, type AgentItem, type AgentsModule, type AgentsModuleOptions, type ApiKeyItem, type AssignInput, type AttachmentUploadResult, type AttachmentUrlResult, type AttachmentsModule, type AttachmentsModuleOptions, type AuthMeAgent, type AuthMeModule, type AuthMeModuleOptions, type AuthMeResponse, type AuthMeTenant, type AuthorDraftInput, type BasicEmailChannelConfig, type BasicEmailChannelSecret, type CannedResponseItem, type CannedResponseListOpts, type CannedResponseSearchOpts, type CannedResponsesModule, type CannedResponsesModuleOptions, type Channel, type ChannelListItem, type ChannelStatus, type ChannelType, type ChannelsModule, type ChannelsModuleOptions, type ContactChannel, type ContactConversationSummary, type ContactFieldDefinition, type ContactFieldValue, type ContactFieldValueInput, type ContactIdentity, type ContactIdentityInput, type ContactItem, type ContactSearchOpts, type ContactTag, type ContactsMetadata, type ContactsModule, type ContactsModuleOptions, type ConversationItem, type ConversationListOpts, type ConversationsModule, type ConversationsModuleOptions, type CreateAgentInput, type CreateApiKeyInput, type CreateApiKeyResponse, type CreateCannedResponseInput, type CreateChannelBody, type CreateContactInput, type CreateEmailChannelBody, type CreateEmailTemplateInput, type CreateWhatsAppBusinessAccountBody, type CreateWhatsAppChannelBody, type CredentialsMode, type EmailChannelConfig, type EmailChannelSecret, type EmailImapConfig, type EmailSmtpConfig, type EmailTemplateItem, type EmailTemplateListOpts, type ImportApprovedResult, type ImportedTemplateResult, type LobbyEntry, type LobbyListOpts, type MessageItem, type MessageListOpts, type MessageReadUpdatePayload, type MessageStatusPayload, type MessagesModule, type MessagesModuleOptions, type OAuth2CertificateEmailChannelSecret, type OAuth2ClientSecretEmailChannelSecret, type OAuth2EmailChannelConfig, type OAuth2EmailChannelSecret, type OmnivoxClient, type OmnivoxClientOptions, OmnivoxRequestError, type PageOpts, type PageParams, type PagedResponse, type ParticipantPayload, type PatchContactInput, type PatchEmailTemplateInput, type PickupInput, type ReopenOrCreateInput, type RevokeApiKeyResponse, type SendMessageInput, type SendTemplateInput, type SubmitResult, type TemplatesModule, type TemplatesModuleOptions, type TenantsModule, type TenantsModuleOptions, type TokenProvider, type TypingIndicatorPayload, type UpdateCannedResponseInput, type UpdateChannelBody, type UpdateStatusInput, type UpdateWhatsAppTemplateInput, type WhatsAppBusinessAccountItem, type WhatsAppBusinessAccountsModule, type WhatsAppBusinessAccountsModuleOptions, type WhatsAppChannelConfig, type WhatsAppRecoveryOption, type WhatsAppTemplateDetail, type WhatsAppTemplateHistory, type WhatsAppTemplateHistoryEvent, type WhatsAppTemplateHistoryVersion, type WhatsAppTemplateItem, type WhatsAppTemplateListOpts, type WsAuth, type WsClient, type WsClientInstance, type WsClientOptions, type WsConnectionState, type WsEventPayloads, buildPageParams, createAgentsModule, createApiKeyTokenProvider, createAttachmentsModule, createAuthMeModule, createCannedResponsesModule, createChannelsModule, createContactsModule, createConversationsModule, createMessagesModule, createOmnivoxClient, createSessionTokenProvider, createTemplatesModule, createTenantsModule, createWhatsAppBusinessAccountsModule, createWsClient, iteratePages };
|
|
2098
|
+
export { type AddIdentityInput, type AddParticipantInput, type AgentItem, type AgentsModule, type AgentsModuleOptions, type ApiKeyItem, type AssignInput, type AttachmentUploadResult, type AttachmentUrlResult, type AttachmentsModule, type AttachmentsModuleOptions, type AuditEntry, type AuditListOpts, type AuditModule, type AuditModuleOptions, type AuthMeAgent, type AuthMeModule, type AuthMeModuleOptions, type AuthMeResponse, type AuthMeTenant, type AuthorDraftInput, type BasicEmailChannelConfig, type BasicEmailChannelSecret, type CannedResponseItem, type CannedResponseListOpts, type CannedResponseSearchOpts, type CannedResponsesModule, type CannedResponsesModuleOptions, type Channel, type ChannelListItem, type ChannelStatus, type ChannelType, type ChannelsModule, type ChannelsModuleOptions, type ContactChannel, type ContactConversationSummary, type ContactFieldDefinition, type ContactFieldValue, type ContactFieldValueInput, type ContactIdentity, type ContactIdentityInput, type ContactItem, type ContactSearchOpts, type ContactTag, type ContactsMetadata, type ContactsModule, type ContactsModuleOptions, type ConversationItem, type ConversationListItem, type ConversationListOpts, type ConversationsModule, type ConversationsModuleOptions, type CreateAgentInput, type CreateApiKeyInput, type CreateApiKeyResponse, type CreateCannedResponseInput, type CreateChannelBody, type CreateContactInput, type CreateEmailChannelBody, type CreateEmailTemplateInput, type CreateWhatsAppBusinessAccountBody, type CreateWhatsAppChannelBody, type CredentialsMode, type DashboardModule, type DashboardModuleOptions, type DashboardStats, type EmailChannelConfig, type EmailChannelSecret, type EmailImapConfig, type EmailSmtpConfig, type EmailTemplateItem, type EmailTemplateListOpts, type ImportApprovedResult, type ImportedTemplateResult, type LobbyEntry, type LobbyListOpts, type MessageItem, type MessageListOpts, type MessageReadUpdatePayload, type MessageStatusPayload, type MessagesModule, type MessagesModuleOptions, type OAuth2CertificateEmailChannelSecret, type OAuth2ClientSecretEmailChannelSecret, type OAuth2EmailChannelConfig, type OAuth2EmailChannelSecret, type OmnivoxClient, type OmnivoxClientOptions, OmnivoxRequestError, type PageOpts, type PageParams, type PagedResponse, type ParticipantAddedPayload, type ParticipantItem, type ParticipantPayload, type ParticipantRemovedPayload, type ParticipantRole, type ParticipantsModule, type ParticipantsModuleOptions, type PatchContactInput, type PatchEmailTemplateInput, type PickupInput, type RecentActivityItem, type RecentActivityListOpts, type RemoveParticipantResult, type ReopenOrCreateInput, type RevokeApiKeyResponse, type SendMessageInput, type SendTemplateInput, type SubmitResult, type TemplatesModule, type TemplatesModuleOptions, type TenantsModule, type TenantsModuleOptions, type TokenProvider, type TypingIndicatorPayload, type UpdateCannedResponseInput, type UpdateChannelBody, type UpdateStatusInput, type UpdateWhatsAppTemplateInput, type WhatsAppBusinessAccountItem, type WhatsAppBusinessAccountsModule, type WhatsAppBusinessAccountsModuleOptions, type WhatsAppChannelConfig, type WhatsAppRecoveryOption, type WhatsAppTemplateDetail, type WhatsAppTemplateHistory, type WhatsAppTemplateHistoryEvent, type WhatsAppTemplateHistoryVersion, type WhatsAppTemplateItem, type WhatsAppTemplateListOpts, type WsAuth, type WsClient, type WsClientInstance, type WsClientOptions, type WsConnectionState, type WsEventPayloads, buildPageParams, createAgentsModule, createApiKeyTokenProvider, createAttachmentsModule, createAuditModule, createAuthMeModule, createCannedResponsesModule, createChannelsModule, createContactsModule, createConversationsModule, createDashboardModule, createMessagesModule, createOmnivoxClient, createParticipantsModule, createSessionTokenProvider, createTemplatesModule, createTenantsModule, createWhatsAppBusinessAccountsModule, createWsClient, iteratePages };
|
package/dist/index.js
CHANGED
|
@@ -117,6 +117,15 @@ var getConversationsControllerUpdateStatusUrl = (id) => {
|
|
|
117
117
|
var getConversationsControllerAssignUrl = (id) => {
|
|
118
118
|
return `/api/v1/conversations/${id}/assign`;
|
|
119
119
|
};
|
|
120
|
+
var getConversationsControllerAddParticipantUrl = (id) => {
|
|
121
|
+
return `/api/v1/conversations/${id}/participants`;
|
|
122
|
+
};
|
|
123
|
+
var getConversationsControllerListParticipantsUrl = (id) => {
|
|
124
|
+
return `/api/v1/conversations/${id}/participants`;
|
|
125
|
+
};
|
|
126
|
+
var getConversationsControllerRemoveParticipantUrl = (id, agentId) => {
|
|
127
|
+
return `/api/v1/conversations/${id}/participants/${agentId}`;
|
|
128
|
+
};
|
|
120
129
|
var getConversationsControllerListLobbyUrl = (params) => {
|
|
121
130
|
const normalizedParams = new URLSearchParams();
|
|
122
131
|
Object.entries(params || {}).forEach(([key, value]) => {
|
|
@@ -286,6 +295,29 @@ var getAttachmentsControllerUploadUrl = () => {
|
|
|
286
295
|
var getAttachmentsControllerGetDownloadUrlUrl = (id) => {
|
|
287
296
|
return `/api/v1/attachments/${id}/url`;
|
|
288
297
|
};
|
|
298
|
+
var getDashboardControllerGetStatsUrl = () => {
|
|
299
|
+
return `/api/v1/dashboard/stats`;
|
|
300
|
+
};
|
|
301
|
+
var getDashboardControllerGetRecentActivityUrl = (params) => {
|
|
302
|
+
const normalizedParams = new URLSearchParams();
|
|
303
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
304
|
+
if (value !== void 0) {
|
|
305
|
+
normalizedParams.append(key, value === null ? "null" : String(value));
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
const stringifiedParams = normalizedParams.toString();
|
|
309
|
+
return stringifiedParams.length > 0 ? `/api/v1/dashboard/recent-activity?${stringifiedParams}` : `/api/v1/dashboard/recent-activity`;
|
|
310
|
+
};
|
|
311
|
+
var getAuditLogControllerListUrl = (params) => {
|
|
312
|
+
const normalizedParams = new URLSearchParams();
|
|
313
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
314
|
+
if (value !== void 0) {
|
|
315
|
+
normalizedParams.append(key, value === null ? "null" : String(value));
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
const stringifiedParams = normalizedParams.toString();
|
|
319
|
+
return stringifiedParams.length > 0 ? `/api/v1/audit-log?${stringifiedParams}` : `/api/v1/audit-log`;
|
|
320
|
+
};
|
|
289
321
|
|
|
290
322
|
// src/pagination/pagination.ts
|
|
291
323
|
var MAX_PAGE_SIZE = 100;
|
|
@@ -702,6 +734,60 @@ function createConversationsModule(options) {
|
|
|
702
734
|
};
|
|
703
735
|
}
|
|
704
736
|
|
|
737
|
+
// src/conversations/participants.ts
|
|
738
|
+
function createParticipantsModule(options) {
|
|
739
|
+
const baseUrl = options.baseUrl;
|
|
740
|
+
function buildInit(method, body) {
|
|
741
|
+
return {
|
|
742
|
+
method,
|
|
743
|
+
credentials: options.getCredentials(),
|
|
744
|
+
headers: {
|
|
745
|
+
"Content-Type": "application/json",
|
|
746
|
+
...options.getHeaders()
|
|
747
|
+
},
|
|
748
|
+
...body !== void 0 ? { body: JSON.stringify(body) } : {}
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
return {
|
|
752
|
+
/**
|
|
753
|
+
* Add (or re-add) an agent as a conversation participant with a role.
|
|
754
|
+
* Idempotent per active membership — re-adding an active participant
|
|
755
|
+
* updates its role; a second OWNER co-owns (no demotion of other owners).
|
|
756
|
+
* Calls POST /api/v1/conversations/:id/participants.
|
|
757
|
+
*/
|
|
758
|
+
async add(conversationId, input) {
|
|
759
|
+
const path = getConversationsControllerAddParticipantUrl(conversationId);
|
|
760
|
+
const url = `${baseUrl}${path}`;
|
|
761
|
+
const res = await fetch(url, buildInit("POST", input));
|
|
762
|
+
return parseEnvelopedResponse(res);
|
|
763
|
+
},
|
|
764
|
+
/**
|
|
765
|
+
* End an active membership for an agent. Idempotent — removing a
|
|
766
|
+
* non-participant is a no-op ({ removed: 0 }).
|
|
767
|
+
* Calls DELETE /api/v1/conversations/:id/participants/:agentId.
|
|
768
|
+
*/
|
|
769
|
+
async remove(conversationId, agentId) {
|
|
770
|
+
const path = getConversationsControllerRemoveParticipantUrl(
|
|
771
|
+
conversationId,
|
|
772
|
+
agentId
|
|
773
|
+
);
|
|
774
|
+
const url = `${baseUrl}${path}`;
|
|
775
|
+
const res = await fetch(url, buildInit("DELETE"));
|
|
776
|
+
return parseEnvelopedResponse(res);
|
|
777
|
+
},
|
|
778
|
+
/**
|
|
779
|
+
* List the ACTIVE (leftAt IS NULL) participants of a conversation.
|
|
780
|
+
* Calls GET /api/v1/conversations/:id/participants.
|
|
781
|
+
*/
|
|
782
|
+
async list(conversationId) {
|
|
783
|
+
const path = getConversationsControllerListParticipantsUrl(conversationId);
|
|
784
|
+
const url = `${baseUrl}${path}`;
|
|
785
|
+
const res = await fetch(url, buildInit("GET"));
|
|
786
|
+
return parseEnvelopedResponse(res);
|
|
787
|
+
}
|
|
788
|
+
};
|
|
789
|
+
}
|
|
790
|
+
|
|
705
791
|
// src/messages/messages.ts
|
|
706
792
|
function createMessagesModule(options) {
|
|
707
793
|
const baseUrl = options.baseUrl;
|
|
@@ -1197,6 +1283,89 @@ function createWhatsAppBusinessAccountsModule(options) {
|
|
|
1197
1283
|
};
|
|
1198
1284
|
}
|
|
1199
1285
|
|
|
1286
|
+
// src/dashboard/dashboard.ts
|
|
1287
|
+
function createDashboardModule(options) {
|
|
1288
|
+
const baseUrl = options.baseUrl;
|
|
1289
|
+
function buildInit() {
|
|
1290
|
+
return {
|
|
1291
|
+
method: "GET",
|
|
1292
|
+
credentials: options.getCredentials(),
|
|
1293
|
+
headers: {
|
|
1294
|
+
"Content-Type": "application/json",
|
|
1295
|
+
...options.getHeaders()
|
|
1296
|
+
}
|
|
1297
|
+
};
|
|
1298
|
+
}
|
|
1299
|
+
return {
|
|
1300
|
+
/**
|
|
1301
|
+
* Fetch the tenant dashboard KPIs.
|
|
1302
|
+
* Calls GET /api/v1/dashboard/stats.
|
|
1303
|
+
*/
|
|
1304
|
+
async stats() {
|
|
1305
|
+
const path = getDashboardControllerGetStatsUrl();
|
|
1306
|
+
const url = `${baseUrl}${path}`;
|
|
1307
|
+
const res = await fetch(url, buildInit());
|
|
1308
|
+
return parseEnvelopedResponse(res);
|
|
1309
|
+
},
|
|
1310
|
+
/**
|
|
1311
|
+
* List the tenant's recent conversation/message activity feed
|
|
1312
|
+
* (newest first, paginated). pageSize is clamped to 100 per the API
|
|
1313
|
+
* contract. Calls GET /api/v1/dashboard/recent-activity.
|
|
1314
|
+
*/
|
|
1315
|
+
async recentActivity(opts = { page: 1, pageSize: 25 }) {
|
|
1316
|
+
const { page, pageSize } = buildPageParams(opts);
|
|
1317
|
+
const path = getDashboardControllerGetRecentActivityUrl({
|
|
1318
|
+
page,
|
|
1319
|
+
pageSize
|
|
1320
|
+
});
|
|
1321
|
+
const url = `${baseUrl}${path}`;
|
|
1322
|
+
const res = await fetch(url, buildInit());
|
|
1323
|
+
return parseResponse(res);
|
|
1324
|
+
}
|
|
1325
|
+
};
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
// src/audit/audit.ts
|
|
1329
|
+
function createAuditModule(options) {
|
|
1330
|
+
const baseUrl = options.baseUrl;
|
|
1331
|
+
function buildInit() {
|
|
1332
|
+
return {
|
|
1333
|
+
method: "GET",
|
|
1334
|
+
credentials: options.getCredentials(),
|
|
1335
|
+
headers: {
|
|
1336
|
+
"Content-Type": "application/json",
|
|
1337
|
+
...options.getHeaders()
|
|
1338
|
+
}
|
|
1339
|
+
};
|
|
1340
|
+
}
|
|
1341
|
+
return {
|
|
1342
|
+
/**
|
|
1343
|
+
* List the tenant audit trail (newest first, paginated).
|
|
1344
|
+
* pageSize is clamped to 100 per the API contract.
|
|
1345
|
+
* Calls GET /api/v1/audit-log.
|
|
1346
|
+
*/
|
|
1347
|
+
async list(opts = {}) {
|
|
1348
|
+
const { page, pageSize } = buildPageParams({
|
|
1349
|
+
page: opts.page ?? 1,
|
|
1350
|
+
pageSize: opts.pageSize ?? 25
|
|
1351
|
+
});
|
|
1352
|
+
const params = {
|
|
1353
|
+
...opts.resourceType !== void 0 ? { resourceType: opts.resourceType } : {},
|
|
1354
|
+
...opts.resourceId !== void 0 ? { resourceId: opts.resourceId } : {},
|
|
1355
|
+
...opts.actorId !== void 0 ? { actorId: opts.actorId } : {},
|
|
1356
|
+
...opts.from !== void 0 ? { from: opts.from } : {},
|
|
1357
|
+
...opts.to !== void 0 ? { to: opts.to } : {},
|
|
1358
|
+
page,
|
|
1359
|
+
pageSize
|
|
1360
|
+
};
|
|
1361
|
+
const path = getAuditLogControllerListUrl(params);
|
|
1362
|
+
const url = `${baseUrl}${path}`;
|
|
1363
|
+
const res = await fetch(url, buildInit());
|
|
1364
|
+
return parseResponse(res);
|
|
1365
|
+
}
|
|
1366
|
+
};
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1200
1369
|
// src/ws/ws-client.ts
|
|
1201
1370
|
import { io } from "socket.io-client";
|
|
1202
1371
|
function createWsClient(options) {
|
|
@@ -1287,11 +1456,14 @@ function createOmnivoxClient(options) {
|
|
|
1287
1456
|
channels: createChannelsModule(moduleOptions),
|
|
1288
1457
|
contacts: createContactsModule(moduleOptions),
|
|
1289
1458
|
conversations: createConversationsModule(moduleOptions),
|
|
1459
|
+
participants: createParticipantsModule(moduleOptions),
|
|
1290
1460
|
messages: createMessagesModule(moduleOptions),
|
|
1291
1461
|
templates: createTemplatesModule(moduleOptions),
|
|
1292
1462
|
cannedResponses: createCannedResponsesModule(moduleOptions),
|
|
1293
1463
|
attachments: createAttachmentsModule(moduleOptions),
|
|
1294
1464
|
whatsappBusinessAccounts: createWhatsAppBusinessAccountsModule(moduleOptions),
|
|
1465
|
+
dashboard: createDashboardModule(moduleOptions),
|
|
1466
|
+
audit: createAuditModule(moduleOptions),
|
|
1295
1467
|
/**
|
|
1296
1468
|
* Creates a WebSocket client connected to the `/ws/chat` namespace.
|
|
1297
1469
|
*
|
|
@@ -1346,13 +1518,16 @@ export {
|
|
|
1346
1518
|
createAgentsModule,
|
|
1347
1519
|
createApiKeyTokenProvider,
|
|
1348
1520
|
createAttachmentsModule,
|
|
1521
|
+
createAuditModule,
|
|
1349
1522
|
createAuthMeModule,
|
|
1350
1523
|
createCannedResponsesModule,
|
|
1351
1524
|
createChannelsModule,
|
|
1352
1525
|
createContactsModule,
|
|
1353
1526
|
createConversationsModule,
|
|
1527
|
+
createDashboardModule,
|
|
1354
1528
|
createMessagesModule,
|
|
1355
1529
|
createOmnivoxClient,
|
|
1530
|
+
createParticipantsModule,
|
|
1356
1531
|
createSessionTokenProvider,
|
|
1357
1532
|
createTemplatesModule,
|
|
1358
1533
|
createTenantsModule,
|