@digisglobal/omnivox-sdk 0.3.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.
@@ -0,0 +1,899 @@
1
+ /**
2
+ * Token-provider abstraction for the Omnivox SDK.
3
+ *
4
+ * Two modes:
5
+ * - API-key: attaches an `x-api-key` header; sets credentials to 'omit'.
6
+ * - Session/cookie: sets credentials to 'include'; attaches no extra headers.
7
+ *
8
+ * The transport reads from the provider per request (not once at construction).
9
+ * Both factories are tree-shakeable — no side effects at module level.
10
+ */
11
+ /**
12
+ * fetch `credentials` mode.
13
+ * Mirrors the browser's `RequestCredentials` without requiring DOM types.
14
+ */
15
+ type CredentialsMode = 'omit' | 'include' | 'same-origin';
16
+ /** Contract that every token provider must satisfy. */
17
+ interface TokenProvider {
18
+ /** HTTP headers to attach to every request (e.g. x-api-key). */
19
+ getHeaders(): Record<string, string>;
20
+ /** fetch `credentials` mode for this provider. */
21
+ getCredentials(): CredentialsMode;
22
+ }
23
+ /**
24
+ * Creates a token provider that authenticates via the `x-api-key` header.
25
+ * Matches the `@ApiSecurity('x-api-key')` guard on the Omnivox API.
26
+ * Browser cookies are explicitly excluded (credentials: 'omit').
27
+ */
28
+ declare function createApiKeyTokenProvider(apiKey: string): TokenProvider;
29
+ /**
30
+ * Creates a token provider for cookie/session-based authentication (Console use-case).
31
+ * Sets fetch `credentials` to 'include' so the browser sends the session cookie.
32
+ * Attaches no explicit headers — the cookie is handled by the browser automatically.
33
+ */
34
+ declare function createSessionTokenProvider(): TokenProvider;
35
+
36
+ /**
37
+ * Messages module — hand-written typed wrapper over the generated client.
38
+ *
39
+ * Exposes the Phase-1 messaging surface for the messages resource:
40
+ * - send(input) → POST /api/v1/messages
41
+ * - list(opts) → GET /api/v1/messages (pageSize capped at 100)
42
+ * - get(id) → GET /api/v1/messages/:id
43
+ * - delete(id) → DELETE /api/v1/messages/:id
44
+ *
45
+ * Never re-exports symbols from _generated/.
46
+ * Contains no business logic — typed transport only.
47
+ */
48
+
49
+ /** Options to construct the messages module. */
50
+ interface MessagesModuleOptions extends TokenProvider {
51
+ /** Base URL of the Omnivox API (e.g. "https://api.omnivox.io"). */
52
+ baseUrl: string;
53
+ }
54
+ /** Input for sending a message. */
55
+ interface SendMessageInput {
56
+ conversationId: string;
57
+ body: string;
58
+ [key: string]: unknown;
59
+ }
60
+ /** Message resource shape returned by the API. */
61
+ interface MessageItem {
62
+ id: string;
63
+ conversationId: string;
64
+ body: string;
65
+ [key: string]: unknown;
66
+ }
67
+ /** Paginated list response. */
68
+ interface PagedList$4<T> {
69
+ data: T[];
70
+ meta: {
71
+ page: number;
72
+ pageSize: number;
73
+ total: number;
74
+ hasNextPage: boolean;
75
+ };
76
+ }
77
+ /** Pagination + filter options for messages.list(). */
78
+ interface MessageListOpts {
79
+ conversationId: string;
80
+ page: number;
81
+ pageSize: number;
82
+ includeDeleted?: boolean;
83
+ }
84
+ /**
85
+ * Creates the messages module — a thin typed wrapper over the generated client.
86
+ */
87
+ declare function createMessagesModule(options: MessagesModuleOptions): {
88
+ /**
89
+ * Send a message in a conversation.
90
+ * Calls POST /api/v1/messages.
91
+ */
92
+ send(input: SendMessageInput): Promise<MessageItem>;
93
+ /**
94
+ * List messages in a conversation (newest first, paginated).
95
+ * pageSize is clamped to 100 per the API contract.
96
+ * Calls GET /api/v1/messages.
97
+ */
98
+ list(opts: MessageListOpts): Promise<PagedList$4<MessageItem>>;
99
+ /**
100
+ * Fetch a single message by ID.
101
+ * Calls GET /api/v1/messages/:id.
102
+ */
103
+ get(id: string): Promise<MessageItem>;
104
+ /**
105
+ * Soft-delete a message (sets deletedAt; row preserved).
106
+ * Calls DELETE /api/v1/messages/:id.
107
+ */
108
+ delete(id: string): Promise<void>;
109
+ };
110
+ /** Return type of createMessagesModule. */
111
+ type MessagesModule = ReturnType<typeof createMessagesModule>;
112
+
113
+ /**
114
+ * Conversations module — hand-written typed wrapper over the generated client.
115
+ *
116
+ * Exposes the Phase-1 messaging surface for the conversations resource:
117
+ * - reopenOrCreate(input) → POST /api/v1/conversations/reopen-or-create
118
+ * - list(opts) → GET /api/v1/conversations (pageSize capped at 100)
119
+ * - updateStatus(id, input) → PATCH /api/v1/conversations/:id/status
120
+ * - assign(id, input) → PATCH /api/v1/conversations/:id/assign
121
+ * - listLobby(opts) → GET /api/v1/conversations/lobby (pageSize capped at 100)
122
+ * - pickup(entryId, input) → POST /api/v1/conversations/lobby/:entryId/pickup
123
+ *
124
+ * Never re-exports symbols from _generated/.
125
+ * Contains no business logic — typed transport only.
126
+ */
127
+
128
+ /** Options to construct the conversations module. */
129
+ interface ConversationsModuleOptions extends TokenProvider {
130
+ /** Base URL of the Omnivox API (e.g. "https://api.omnivox.io"). */
131
+ baseUrl: string;
132
+ }
133
+ /** Input for reopen-or-create. */
134
+ interface ReopenOrCreateInput {
135
+ contactIdentityId: string;
136
+ /**
137
+ * The channel to pin the conversation to (channel-as-connection Stage 5).
138
+ * Optional: when omitted, the API falls back to the tenant's default channel
139
+ * for the identity's type, or the sole channel of that type, and returns 400
140
+ * when ambiguous. The single-active-conversation rule is per
141
+ * (contactIdentity, channel).
142
+ */
143
+ channelId?: string;
144
+ [key: string]: unknown;
145
+ }
146
+ /** Input for updating conversation status. */
147
+ interface UpdateStatusInput {
148
+ status: string;
149
+ [key: string]: unknown;
150
+ }
151
+ /** Input for assigning a conversation. */
152
+ interface AssignInput {
153
+ agentId: string;
154
+ [key: string]: unknown;
155
+ }
156
+ /** Input for picking up a lobby entry. */
157
+ interface PickupInput {
158
+ agentId: string;
159
+ [key: string]: unknown;
160
+ }
161
+ /** Conversation resource shape returned by the API. */
162
+ interface ConversationItem {
163
+ id: string;
164
+ status: string;
165
+ [key: string]: unknown;
166
+ }
167
+ /** Lobby entry resource shape returned by the API. */
168
+ interface LobbyEntry {
169
+ id: string;
170
+ [key: string]: unknown;
171
+ }
172
+ /** Paginated list response. */
173
+ interface PagedList$3<T> {
174
+ data: T[];
175
+ meta: {
176
+ page: number;
177
+ pageSize: number;
178
+ total: number;
179
+ hasNextPage: boolean;
180
+ };
181
+ }
182
+ /** Pagination + filter options for conversations.list(). */
183
+ interface ConversationListOpts {
184
+ page: number;
185
+ pageSize: number;
186
+ contactId?: string;
187
+ assignedAgentId?: string;
188
+ channel?: string;
189
+ status?: string;
190
+ }
191
+ /** Pagination options for conversations.listLobby(). */
192
+ interface LobbyListOpts {
193
+ page: number;
194
+ pageSize: number;
195
+ }
196
+ /**
197
+ * Creates the conversations module — a thin typed wrapper over the generated client.
198
+ */
199
+ declare function createConversationsModule(options: ConversationsModuleOptions): {
200
+ /**
201
+ * Idempotent reopen-or-create for a contact identity.
202
+ * Returns the existing non-CLOSED conversation (200) or creates a new OPEN one (201).
203
+ * Calls POST /api/v1/conversations/reopen-or-create.
204
+ */
205
+ reopenOrCreate(input: ReopenOrCreateInput): Promise<ConversationItem>;
206
+ /**
207
+ * List conversations with optional filters (paginated, sorted deterministically).
208
+ * pageSize is clamped to 100 per the API contract.
209
+ * Calls GET /api/v1/conversations.
210
+ */
211
+ list(opts?: ConversationListOpts): Promise<PagedList$3<ConversationItem>>;
212
+ /**
213
+ * Update a conversation status via the state machine.
214
+ * Calls PATCH /api/v1/conversations/:id/status.
215
+ */
216
+ updateStatus(id: string, input: UpdateStatusInput): Promise<ConversationItem>;
217
+ /**
218
+ * Assign a conversation to an agent.
219
+ * Calls PATCH /api/v1/conversations/:id/assign.
220
+ */
221
+ assign(id: string, input: AssignInput): Promise<ConversationItem>;
222
+ /**
223
+ * List lobby entries awaiting pickup (paginated, sorted by receivedAt DESC).
224
+ * pageSize is clamped to 100 per the API contract.
225
+ * Calls GET /api/v1/conversations/lobby.
226
+ */
227
+ listLobby(opts?: LobbyListOpts): Promise<PagedList$3<LobbyEntry>>;
228
+ /**
229
+ * Get a single conversation by ID.
230
+ * Calls GET /api/v1/conversations/:id.
231
+ */
232
+ get(id: string): Promise<ConversationItem>;
233
+ /**
234
+ * Pick up a lobby entry (atomic 4-step transaction).
235
+ * Returns the resulting conversation.
236
+ * Calls POST /api/v1/conversations/lobby/:entryId/pickup.
237
+ */
238
+ pickup(entryId: string, input: PickupInput): Promise<{
239
+ data: ConversationItem;
240
+ }>;
241
+ };
242
+ /** Return type of createConversationsModule. */
243
+ type ConversationsModule = ReturnType<typeof createConversationsModule>;
244
+
245
+ /**
246
+ * Contacts module — hand-written typed wrapper over the generated client.
247
+ *
248
+ * Exposes the Phase-1 messaging surface for the contacts resource:
249
+ * - create(input) → POST /api/v1/contacts
250
+ * - search(opts) → GET /api/v1/contacts (pageSize capped at 100)
251
+ * - detail(id) → GET /api/v1/contacts/:id
252
+ * - metadata() → GET /api/v1/contacts/metadata
253
+ * - patch(id, input) → PATCH /api/v1/contacts/:id
254
+ * - addIdentity(id, input) → POST /api/v1/contacts/:id/identities
255
+ *
256
+ * Never re-exports symbols from _generated/.
257
+ * Contains no business logic — typed transport only.
258
+ */
259
+
260
+ /** Options to construct the contacts module. */
261
+ interface ContactsModuleOptions extends TokenProvider {
262
+ /** Base URL of the Omnivox API (e.g. "https://api.omnivox.io"). */
263
+ baseUrl: string;
264
+ }
265
+ /** Identity shape for creating a contact. */
266
+ interface ContactIdentityInput {
267
+ channel: string;
268
+ value: string;
269
+ [key: string]: unknown;
270
+ }
271
+ /** Input for creating a contact. */
272
+ interface CreateContactInput {
273
+ displayName: string;
274
+ identities: ContactIdentityInput[];
275
+ [key: string]: unknown;
276
+ }
277
+ /** Input for patching a contact. */
278
+ interface PatchContactInput {
279
+ displayName?: string;
280
+ isActive?: boolean;
281
+ [key: string]: unknown;
282
+ }
283
+ /** Input for adding an identity to a contact. */
284
+ interface AddIdentityInput {
285
+ channel: string;
286
+ value: string;
287
+ [key: string]: unknown;
288
+ }
289
+ /** Contact identity resource shape. */
290
+ interface ContactIdentity {
291
+ id: string;
292
+ channel: string;
293
+ value: string;
294
+ [key: string]: unknown;
295
+ }
296
+ /** Contact resource shape returned by the API. */
297
+ interface ContactItem {
298
+ id: string;
299
+ displayName: string;
300
+ identities?: ContactIdentity[];
301
+ [key: string]: unknown;
302
+ }
303
+ /** Contacts metadata (tag catalog and custom-field definitions). */
304
+ interface ContactsMetadata {
305
+ tags: unknown[];
306
+ customFields: unknown[];
307
+ [key: string]: unknown;
308
+ }
309
+ /** Paginated list response. */
310
+ interface PagedList$2<T> {
311
+ data: T[];
312
+ meta: {
313
+ page: number;
314
+ pageSize: number;
315
+ total: number;
316
+ hasNextPage: boolean;
317
+ };
318
+ }
319
+ /** Pagination + search options for contacts.search(). */
320
+ interface ContactSearchOpts {
321
+ page: number;
322
+ pageSize: number;
323
+ q?: string;
324
+ [key: string]: unknown;
325
+ }
326
+ /**
327
+ * Creates the contacts module — a thin typed wrapper over the generated client.
328
+ */
329
+ declare function createContactsModule(options: ContactsModuleOptions): {
330
+ /**
331
+ * Create a contact with channel identity/identities.
332
+ * Calls POST /api/v1/contacts.
333
+ */
334
+ create(input: CreateContactInput): Promise<ContactItem>;
335
+ /**
336
+ * Search contacts by display name or raw identifier.
337
+ * pageSize is clamped to 100 per the API contract.
338
+ * Calls GET /api/v1/contacts.
339
+ */
340
+ search(opts: ContactSearchOpts): Promise<PagedList$2<ContactItem>>;
341
+ /**
342
+ * Get contact detail with identities, tags, field values.
343
+ * Calls GET /api/v1/contacts/:id.
344
+ */
345
+ detail(id: string): Promise<ContactItem>;
346
+ /**
347
+ * Return the tenant's tag catalog and custom-field definitions.
348
+ * Calls GET /api/v1/contacts/metadata.
349
+ */
350
+ metadata(): Promise<ContactsMetadata>;
351
+ /**
352
+ * Partially update a contact.
353
+ * Calls PATCH /api/v1/contacts/:id.
354
+ */
355
+ patch(id: string, input: PatchContactInput): Promise<ContactItem>;
356
+ /**
357
+ * Add a channel identity to an existing contact.
358
+ * Calls POST /api/v1/contacts/:id/identities.
359
+ */
360
+ addIdentity(id: string, input: AddIdentityInput): Promise<ContactIdentity>;
361
+ };
362
+ /** Return type of createContactsModule. */
363
+ type ContactsModule = ReturnType<typeof createContactsModule>;
364
+
365
+ /**
366
+ * Agents module — hand-written typed wrapper over the generated client.
367
+ *
368
+ * Exposes the Phase-1 config surface for the agents resource:
369
+ * - create(input) → POST /api/v1/agents
370
+ * - list(opts) → GET /api/v1/agents (pageSize capped at 100)
371
+ * - get(id) → GET /api/v1/agents/:id
372
+ *
373
+ * Never re-exports symbols from _generated/.
374
+ * Contains no business logic — typed transport only.
375
+ */
376
+
377
+ /** Options to construct the agents module. */
378
+ interface AgentsModuleOptions extends TokenProvider {
379
+ /** Base URL of the Omnivox API (e.g. "https://api.omnivox.io"). */
380
+ baseUrl: string;
381
+ }
382
+ /** Input for creating an agent. */
383
+ interface CreateAgentInput {
384
+ displayName: string;
385
+ email: string;
386
+ [key: string]: unknown;
387
+ }
388
+ /** Agent resource shape returned by the API. */
389
+ interface AgentItem {
390
+ id: string;
391
+ displayName: string;
392
+ email: string;
393
+ [key: string]: unknown;
394
+ }
395
+ /** Paginated list response. */
396
+ interface PagedList$1<T> {
397
+ data: T[];
398
+ meta: {
399
+ page: number;
400
+ pageSize: number;
401
+ total: number;
402
+ hasNextPage: boolean;
403
+ };
404
+ }
405
+ /** Pagination options for list. */
406
+ interface PageOpts {
407
+ page: number;
408
+ pageSize: number;
409
+ }
410
+ /**
411
+ * Creates the agents module — a thin typed wrapper over the generated client.
412
+ */
413
+ declare function createAgentsModule(options: AgentsModuleOptions): {
414
+ /**
415
+ * Create an agent for the authenticated tenant.
416
+ * Calls POST /api/v1/agents.
417
+ */
418
+ create(input: CreateAgentInput): Promise<AgentItem>;
419
+ /**
420
+ * List agents for the authenticated tenant (paginated, sorted deterministically).
421
+ * pageSize is clamped to 100 per the API contract.
422
+ * Calls GET /api/v1/agents.
423
+ */
424
+ list(opts?: PageOpts): Promise<PagedList$1<AgentItem>>;
425
+ /**
426
+ * Get an agent by ID.
427
+ * Calls GET /api/v1/agents/:id.
428
+ */
429
+ get(id: string): Promise<AgentItem>;
430
+ };
431
+ /** Return type of createAgentsModule. */
432
+ type AgentsModule = ReturnType<typeof createAgentsModule>;
433
+
434
+ /**
435
+ * Tenants module — hand-written typed wrapper over the generated client.
436
+ *
437
+ * Exposes the Phase-1 config surface for the tenants resource:
438
+ * - channels.list(tenantId) → GET /api/v1/tenants/:id/channels
439
+ * - apiKeys.list(tenantId) → GET /api/v1/tenants/:id/api-keys
440
+ * - apiKeys.create(tenantId, input) → POST /api/v1/tenants/:id/api-keys
441
+ * - apiKeys.revoke(tenantId, keyId) → DELETE /api/v1/tenants/:id/api-keys/:keyId
442
+ *
443
+ * Never re-exports symbols from _generated/.
444
+ * Contains no business logic — typed transport only.
445
+ */
446
+
447
+ /** Options to construct the tenants module. */
448
+ interface TenantsModuleOptions extends TokenProvider {
449
+ /** Base URL of the Omnivox API (e.g. "https://api.omnivox.io"). */
450
+ baseUrl: string;
451
+ }
452
+ /** Shape returned by tenants.channels.list(). */
453
+ interface ChannelListItem {
454
+ id: string;
455
+ type: string;
456
+ name: string;
457
+ status: string;
458
+ isDefault: boolean;
459
+ lastVerifiedAt: string | null;
460
+ [key: string]: unknown;
461
+ }
462
+ /** Shape returned by tenants.apiKeys.list() items. */
463
+ interface ApiKeyItem {
464
+ id: string;
465
+ label: string;
466
+ prefix: string;
467
+ scopes: string[];
468
+ status: 'ACTIVE' | 'REVOKED';
469
+ lastUsedAt: string | null;
470
+ createdAt: string;
471
+ }
472
+ /** Input for tenants.apiKeys.create(). */
473
+ interface CreateApiKeyInput {
474
+ /** Human-readable label for the key. */
475
+ label: string;
476
+ /** Permission scopes. Defaults to ['*'] (all permissions). */
477
+ scopes?: string[];
478
+ }
479
+ /** Response from tenants.apiKeys.create() — includes raw key shown once. */
480
+ interface CreateApiKeyResponse {
481
+ data: {
482
+ id: string;
483
+ label: string;
484
+ prefix: string;
485
+ scopes: string[];
486
+ status: 'ACTIVE' | 'REVOKED';
487
+ lastUsedAt: string | null;
488
+ createdAt: string;
489
+ /** Raw key value — shown once and never again. */
490
+ raw: string;
491
+ };
492
+ }
493
+ /** Response from tenants.apiKeys.revoke(). */
494
+ interface RevokeApiKeyResponse {
495
+ data: {
496
+ id: string;
497
+ status: 'REVOKED';
498
+ };
499
+ }
500
+ /** Paginated list response. */
501
+ interface PagedList<T> {
502
+ data: T[];
503
+ meta: {
504
+ page: number;
505
+ pageSize: number;
506
+ total: number;
507
+ hasNextPage: boolean;
508
+ };
509
+ }
510
+ /**
511
+ * Creates the tenants module — a thin typed wrapper over the generated client.
512
+ * The `baseUrl`, `getHeaders`, and `getCredentials` come from the SDK client
513
+ * instance (typically via a TokenProvider).
514
+ */
515
+ declare function createTenantsModule(options: TenantsModuleOptions): {
516
+ /** Channels sub-surface scoped to a tenant. */
517
+ channels: {
518
+ /**
519
+ * List channels for a tenant (non-secret view).
520
+ * Calls GET /api/v1/tenants/:id/channels.
521
+ */
522
+ list(tenantId: string, opts?: {
523
+ page: number;
524
+ pageSize: number;
525
+ }): Promise<PagedList<ChannelListItem>>;
526
+ };
527
+ /** API-keys sub-surface scoped to a tenant. */
528
+ apiKeys: {
529
+ /**
530
+ * List API keys for a tenant (metadata only — never exposes secrets).
531
+ * Calls GET /api/v1/tenants/:id/api-keys.
532
+ */
533
+ list(tenantId: string, opts?: {
534
+ page: number;
535
+ pageSize: number;
536
+ }): Promise<PagedList<ApiKeyItem>>;
537
+ /**
538
+ * Create a new API key for a tenant. Returns the key metadata plus the
539
+ * raw key value (shown once — the API will never return it again).
540
+ * Calls POST /api/v1/tenants/:id/api-keys.
541
+ */
542
+ create(tenantId: string, input: CreateApiKeyInput): Promise<CreateApiKeyResponse>;
543
+ /**
544
+ * Revoke an existing API key immediately.
545
+ * Calls DELETE /api/v1/tenants/:id/api-keys/:keyId.
546
+ */
547
+ revoke(tenantId: string, keyId: string): Promise<RevokeApiKeyResponse>;
548
+ };
549
+ };
550
+ /** Return type of createTenantsModule. */
551
+ type TenantsModule = ReturnType<typeof createTenantsModule>;
552
+
553
+ /** Options for {@link createOmnivoxClient}. */
554
+ interface OmnivoxClientOptions {
555
+ /** Base URL of the Omnivox API (e.g. "https://api.omnivox.io"). */
556
+ baseUrl: string;
557
+ /**
558
+ * Auth strategy for every request: an API-key provider for host apps or a
559
+ * session/cookie provider for the Console. Read per request.
560
+ */
561
+ tokenProvider: TokenProvider;
562
+ }
563
+ /**
564
+ * Creates a composed Omnivox client exposing every Phase-1 resource module.
565
+ * The token provider is read per request (not captured at construction), so
566
+ * the same client follows a rotating key or refreshed session transparently.
567
+ */
568
+ declare function createOmnivoxClient(options: OmnivoxClientOptions): {
569
+ auth: {
570
+ me(): Promise<AuthMeResponse>;
571
+ };
572
+ tenants: {
573
+ channels: {
574
+ list(tenantId: string, opts?: {
575
+ page: number;
576
+ pageSize: number;
577
+ }): Promise<PagedList<ChannelListItem>>;
578
+ };
579
+ apiKeys: {
580
+ list(tenantId: string, opts?: {
581
+ page: number;
582
+ pageSize: number;
583
+ }): Promise<PagedList<ApiKeyItem>>;
584
+ create(tenantId: string, input: CreateApiKeyInput): Promise<CreateApiKeyResponse>;
585
+ revoke(tenantId: string, keyId: string): Promise<RevokeApiKeyResponse>;
586
+ };
587
+ };
588
+ agents: {
589
+ create(input: CreateAgentInput): Promise<AgentItem>;
590
+ list(opts?: PageOpts): Promise<PagedList$1<AgentItem>>;
591
+ get(id: string): Promise<AgentItem>;
592
+ };
593
+ channels: {
594
+ create(tenantId: string, body: CreateChannelBody): Promise<Channel>;
595
+ get(tenantId: string, channelId: string): Promise<Channel>;
596
+ update(tenantId: string, channelId: string, body: UpdateChannelBody): Promise<Channel>;
597
+ verify(tenantId: string, channelId: string): Promise<void>;
598
+ };
599
+ contacts: {
600
+ create(input: CreateContactInput): Promise<ContactItem>;
601
+ search(opts: ContactSearchOpts): Promise<PagedList$2<ContactItem>>;
602
+ detail(id: string): Promise<ContactItem>;
603
+ metadata(): Promise<ContactsMetadata>;
604
+ patch(id: string, input: PatchContactInput): Promise<ContactItem>;
605
+ addIdentity(id: string, input: AddIdentityInput): Promise<ContactIdentity>;
606
+ };
607
+ conversations: {
608
+ reopenOrCreate(input: ReopenOrCreateInput): Promise<ConversationItem>;
609
+ list(opts?: ConversationListOpts): Promise<PagedList$3<ConversationItem>>;
610
+ updateStatus(id: string, input: UpdateStatusInput): Promise<ConversationItem>;
611
+ assign(id: string, input: AssignInput): Promise<ConversationItem>;
612
+ listLobby(opts?: LobbyListOpts): Promise<PagedList$3<LobbyEntry>>;
613
+ get(id: string): Promise<ConversationItem>;
614
+ pickup(entryId: string, input: PickupInput): Promise<{
615
+ data: ConversationItem;
616
+ }>;
617
+ };
618
+ messages: {
619
+ send(input: SendMessageInput): Promise<MessageItem>;
620
+ list(opts: MessageListOpts): Promise<PagedList$4<MessageItem>>;
621
+ get(id: string): Promise<MessageItem>;
622
+ delete(id: string): Promise<void>;
623
+ };
624
+ };
625
+ /** Composed client returned by {@link createOmnivoxClient}. */
626
+ type OmnivoxClient = ReturnType<typeof createOmnivoxClient>;
627
+
628
+ /**
629
+ * Auth module — GET /api/v1/auth/me
630
+ *
631
+ * Returns the session subject, active tenant, and (for session actors) the
632
+ * acting Agent. For API-key actors the agent field is null.
633
+ *
634
+ * Hand-written typed transport — never imports from _generated/.
635
+ */
636
+
637
+ /** The tenant fragment returned by /auth/me */
638
+ interface AuthMeTenant {
639
+ id: string;
640
+ slug: string;
641
+ name: string;
642
+ }
643
+ /** The agent fragment returned by /auth/me (null for API-key actors) */
644
+ interface AuthMeAgent {
645
+ id: string;
646
+ displayName: string;
647
+ role: string;
648
+ }
649
+ /** Full /auth/me response shape (inside the { data } envelope) */
650
+ interface AuthMeResponse {
651
+ subject: string;
652
+ tenant: AuthMeTenant;
653
+ agent: AuthMeAgent | null;
654
+ }
655
+ /** Options to construct the auth-me module. */
656
+ interface AuthMeModuleOptions extends TokenProvider {
657
+ /** Base URL of the Omnivox API (e.g. "https://api.omnivox.io"). */
658
+ baseUrl: string;
659
+ }
660
+ /**
661
+ * Creates the auth-me module — a thin typed wrapper for GET /api/v1/auth/me.
662
+ */
663
+ declare function createAuthMeModule(options: AuthMeModuleOptions): {
664
+ /**
665
+ * Get the identity context for the authenticated actor.
666
+ * Calls GET /api/v1/auth/me.
667
+ *
668
+ * Returns the unwrapped { subject, tenant, agent } object.
669
+ * Throws an OmnivoxRequestError (carrying `status`) on any non-OK response,
670
+ * including 401 when unauthenticated.
671
+ */
672
+ me(): Promise<AuthMeResponse>;
673
+ };
674
+ /** Return type of createAuthMeModule. */
675
+ type AuthMeModule = ReturnType<typeof createAuthMeModule>;
676
+
677
+ /**
678
+ * Shared response helper for the hand-written SDK transport.
679
+ *
680
+ * Every resource module performed the same read: skip the body for no-content
681
+ * statuses, otherwise `JSON.parse` the text and return it — but none checked
682
+ * `res.ok`, so an API error envelope (`{ error: { code, message } }`) was
683
+ * happily returned as if it were successful data. Callers (e.g. React Query)
684
+ * then cached the error shape as a successful result.
685
+ *
686
+ * `parseResponse` centralises that read and throws {@link OmnivoxRequestError}
687
+ * on any non-2xx status, carrying the status code and the parsed error body so
688
+ * callers can branch on `err.status` or inspect `err.body`.
689
+ *
690
+ * Typed transport only — no business logic.
691
+ */
692
+ /**
693
+ * Error thrown when an Omnivox API request resolves with a non-2xx status.
694
+ * Exposes the HTTP `status` and the parsed (or raw) error `body`.
695
+ */
696
+ declare class OmnivoxRequestError extends Error {
697
+ /** HTTP status code of the failed response. */
698
+ readonly status: number;
699
+ /** Parsed error envelope, or the raw text when the body was not JSON. */
700
+ readonly body: unknown;
701
+ constructor(status: number, body: unknown);
702
+ }
703
+
704
+ /**
705
+ * Uniform pagination helper for the Omnivox SDK.
706
+ *
707
+ * Page-based, caps pageSize at 100 (matching the API contract).
708
+ * Tree-shakeable — no side effects at module level.
709
+ * Does not import from apps/api.
710
+ */
711
+ /** Parameters for a single page request. */
712
+ interface PageParams {
713
+ page: number;
714
+ pageSize: number;
715
+ }
716
+ /** Shape returned by list endpoints. */
717
+ interface PagedResponse<T> {
718
+ data: T[];
719
+ meta: {
720
+ page: number;
721
+ pageSize: number;
722
+ total: number;
723
+ hasNextPage: boolean;
724
+ };
725
+ }
726
+ /**
727
+ * Normalises caller-supplied pagination options.
728
+ * Clamps `pageSize` to `MAX_PAGE_SIZE`; passes `page` through unchanged.
729
+ */
730
+ declare function buildPageParams(opts: PageParams): PageParams;
731
+ /**
732
+ * Iterates over all pages returned by `fetchPage`, collecting every item.
733
+ *
734
+ * - Clamps `pageSize` via `buildPageParams` before the first call.
735
+ * - Increments `page` after each response that has `hasNextPage: true`.
736
+ * - Stops as soon as `hasNextPage` is `false`.
737
+ * - Returns `[]` when the first page contains no items.
738
+ */
739
+ declare function iteratePages<T>(fetchPage: (params: PageParams) => Promise<PagedResponse<T>>, opts: PageParams): Promise<T[]>;
740
+
741
+ /**
742
+ * Channels module — hand-written typed wrapper over the generated client.
743
+ *
744
+ * Exposes the id-based channel surface (channel-as-connection Stage 3):
745
+ * - create(tenantId, body) → POST /api/v1/tenants/:id/channels
746
+ * - get(tenantId, channelId) → GET /api/v1/tenants/:id/channels/:channelId
747
+ * - update(tenantId, channelId, body) → PATCH /api/v1/tenants/:id/channels/:channelId
748
+ * - verify(tenantId, channelId) → POST /api/v1/tenants/:id/channels/:channelId/verify
749
+ *
750
+ * Never re-exports symbols from _generated/.
751
+ * Contains no business logic — typed transport only.
752
+ */
753
+
754
+ /** Channel types supported in Phase 1. */
755
+ type ChannelType = 'WHATSAPP' | 'EMAIL';
756
+ /** Channel lifecycle status. */
757
+ type ChannelStatus = 'ACTIVE' | 'DISABLED';
758
+ /** Options to construct the channels module. */
759
+ interface ChannelsModuleOptions extends TokenProvider {
760
+ /** Base URL of the Omnivox API (e.g. "https://api.omnivox.io"). */
761
+ baseUrl: string;
762
+ }
763
+ /** WhatsApp channel config (stored on the row). */
764
+ interface WhatsAppChannelConfig {
765
+ phoneNumberId: string;
766
+ wabaId: string;
767
+ }
768
+ /** POST body to create a WhatsApp channel. */
769
+ interface CreateWhatsAppChannelBody {
770
+ type: 'WHATSAPP';
771
+ name: string;
772
+ config: WhatsAppChannelConfig;
773
+ /** The WABA that owns this channel's secret material (ADR-0030). */
774
+ whatsAppBusinessAccountId: string;
775
+ isDefault?: boolean;
776
+ }
777
+ /** SMTP transport config block (shared by basic + oauth2 email). */
778
+ interface EmailSmtpConfig {
779
+ host: string;
780
+ port: number;
781
+ secure: boolean;
782
+ fromAddress: string;
783
+ fromName: string;
784
+ }
785
+ /** IMAP transport config block (shared by basic + oauth2 email). */
786
+ interface EmailImapConfig {
787
+ host: string;
788
+ port: number;
789
+ secure: boolean;
790
+ mailbox: string;
791
+ pollIntervalSeconds: number;
792
+ }
793
+ /** Basic-auth (SMTP/IMAP password) email config. */
794
+ interface BasicEmailChannelConfig {
795
+ authMode: 'basic';
796
+ smtp: EmailSmtpConfig;
797
+ imap: EmailImapConfig;
798
+ }
799
+ /** Basic-auth email secret. */
800
+ interface BasicEmailChannelSecret {
801
+ authMode: 'basic';
802
+ smtpUser: string;
803
+ smtpPass: string;
804
+ imapUser: string;
805
+ imapPass: string;
806
+ }
807
+ /** OAuth2 client-credentials (M365) email config. */
808
+ interface OAuth2EmailChannelConfig {
809
+ authMode: 'oauth2';
810
+ provider: 'microsoft365';
811
+ directoryId: string;
812
+ clientId: string;
813
+ credentialType: 'clientSecret' | 'certificate';
814
+ scope?: string;
815
+ smtp: EmailSmtpConfig;
816
+ imap: EmailImapConfig;
817
+ }
818
+ /** OAuth2 secret — Azure app-registration client secret. */
819
+ interface OAuth2ClientSecretEmailChannelSecret {
820
+ authMode: 'oauth2';
821
+ credentialType: 'clientSecret';
822
+ clientSecret: string;
823
+ }
824
+ /** OAuth2 secret — certificate private key + SHA-1 thumbprint. */
825
+ interface OAuth2CertificateEmailChannelSecret {
826
+ authMode: 'oauth2';
827
+ credentialType: 'certificate';
828
+ privateKey: string;
829
+ thumbprint: string;
830
+ }
831
+ /** OAuth2 email secret — discriminated on `credentialType`. */
832
+ type OAuth2EmailChannelSecret = OAuth2ClientSecretEmailChannelSecret | OAuth2CertificateEmailChannelSecret;
833
+ /** Email channel config — discriminated on `authMode`. */
834
+ type EmailChannelConfig = BasicEmailChannelConfig | OAuth2EmailChannelConfig;
835
+ /** Email channel secret — discriminated on `authMode`. */
836
+ type EmailChannelSecret = BasicEmailChannelSecret | OAuth2EmailChannelSecret;
837
+ /** POST body to create an Email channel. */
838
+ interface CreateEmailChannelBody {
839
+ type: 'EMAIL';
840
+ name: string;
841
+ config: EmailChannelConfig;
842
+ secret: EmailChannelSecret;
843
+ isDefault?: boolean;
844
+ }
845
+ /** POST body to create any channel — discriminated on `type`. */
846
+ type CreateChannelBody = CreateWhatsAppChannelBody | CreateEmailChannelBody;
847
+ /** PATCH body to update a channel (all fields optional; `type` is immutable). */
848
+ interface UpdateChannelBody {
849
+ name?: string;
850
+ status?: ChannelStatus;
851
+ isDefault?: boolean;
852
+ config?: Record<string, unknown>;
853
+ /** Email only — rotates the stored secret (WhatsApp secret lives on its WABA). */
854
+ secret?: Record<string, unknown>;
855
+ }
856
+ /** Channel resource shape returned by the API (no secrets exposed). */
857
+ interface Channel {
858
+ id: string;
859
+ type: ChannelType;
860
+ name: string;
861
+ status: ChannelStatus;
862
+ isDefault: boolean;
863
+ lastVerifiedAt: string | null;
864
+ webhookUrl?: string | null;
865
+ [key: string]: unknown;
866
+ }
867
+ /**
868
+ * Creates the channels module — a thin typed wrapper over the generated client.
869
+ * Covers the id-based channel surface (create/get/update/verify).
870
+ */
871
+ declare function createChannelsModule(options: ChannelsModuleOptions): {
872
+ /**
873
+ * Create a channel. For WhatsApp the secret material lives on the linked
874
+ * WABA (no inline secret); for Email the `{ config, secret }` envelope is
875
+ * sent verbatim — secret goes to the SecretsProvider and is never echoed.
876
+ * Calls POST /api/v1/tenants/:id/channels.
877
+ */
878
+ create(tenantId: string, body: CreateChannelBody): Promise<Channel>;
879
+ /**
880
+ * Get a single channel by id (config + name/status/isDefault/type +
881
+ * webhookUrl for WhatsApp; no secrets).
882
+ * Calls GET /api/v1/tenants/:id/channels/:channelId.
883
+ */
884
+ get(tenantId: string, channelId: string): Promise<Channel>;
885
+ /**
886
+ * Update a channel (name/status/isDefault/config; Email may rotate secret).
887
+ * Calls PATCH /api/v1/tenants/:id/channels/:channelId.
888
+ */
889
+ update(tenantId: string, channelId: string, body: UpdateChannelBody): Promise<Channel>;
890
+ /**
891
+ * Verify a channel through its adapter; on success sets lastVerifiedAt.
892
+ * Calls POST /api/v1/tenants/:id/channels/:channelId/verify.
893
+ */
894
+ verify(tenantId: string, channelId: string): Promise<void>;
895
+ };
896
+ /** Return type of createChannelsModule. */
897
+ type ChannelsModule = ReturnType<typeof createChannelsModule>;
898
+
899
+ export { type AddIdentityInput, type AgentItem, type AgentsModule, type AgentsModuleOptions, type ApiKeyItem, type AssignInput, type AuthMeAgent, type AuthMeModule, type AuthMeModuleOptions, type AuthMeResponse, type AuthMeTenant, type BasicEmailChannelConfig, type BasicEmailChannelSecret, type Channel, type ChannelListItem, type ChannelStatus, type ChannelType, type ChannelsModule, type ChannelsModuleOptions, type ContactIdentity, type ContactIdentityInput, type ContactItem, type ContactSearchOpts, type ContactsMetadata, type ContactsModule, type ContactsModuleOptions, type ConversationItem, type ConversationListOpts, type ConversationsModule, type ConversationsModuleOptions, type CreateAgentInput, type CreateApiKeyInput, type CreateApiKeyResponse, type CreateChannelBody, type CreateContactInput, type CreateEmailChannelBody, type CreateWhatsAppChannelBody, type CredentialsMode, type EmailChannelConfig, type EmailChannelSecret, type EmailImapConfig, type EmailSmtpConfig, type LobbyEntry, type LobbyListOpts, type MessageItem, type MessageListOpts, type MessagesModule, type MessagesModuleOptions, type OAuth2CertificateEmailChannelSecret, type OAuth2ClientSecretEmailChannelSecret, type OAuth2EmailChannelConfig, type OAuth2EmailChannelSecret, type OmnivoxClient, type OmnivoxClientOptions, OmnivoxRequestError, type PageOpts, type PageParams, type PagedResponse, type PatchContactInput, type PickupInput, type ReopenOrCreateInput, type RevokeApiKeyResponse, type SendMessageInput, type TenantsModule, type TenantsModuleOptions, type TokenProvider, type UpdateChannelBody, type UpdateStatusInput, type WhatsAppChannelConfig, buildPageParams, createAgentsModule, createApiKeyTokenProvider, createAuthMeModule, createChannelsModule, createContactsModule, createConversationsModule, createMessagesModule, createOmnivoxClient, createSessionTokenProvider, createTenantsModule, iteratePages };