@hirefinn/sdk 0.3.0 → 0.5.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/README.md +34 -14
- package/dist/cjs/core.d.ts +16 -3
- package/dist/cjs/core.js +23 -6
- package/dist/cjs/errors.d.ts +1 -1
- package/dist/cjs/errors.js +11 -0
- package/dist/cjs/generated/openapi.d.ts +3258 -652
- package/dist/cjs/generated/operations.d.ts +2 -2
- package/dist/cjs/generated/operations.js +39 -28
- package/dist/cjs/generated/resources.d.ts +206 -27
- package/dist/cjs/generated/resources.js +95 -16
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +4 -1
- package/dist/cjs/pagination.d.ts +3 -0
- package/dist/cjs/pagination.js +26 -5
- package/dist/cjs/resources.d.ts +17 -3
- package/dist/cjs/resources.js +7 -2
- package/dist/cjs/webhooks.d.ts +11 -1
- package/dist/esm/core.d.ts +16 -3
- package/dist/esm/core.js +22 -5
- package/dist/esm/errors.d.ts +1 -1
- package/dist/esm/errors.js +11 -0
- package/dist/esm/generated/openapi.d.ts +3258 -652
- package/dist/esm/generated/operations.d.ts +2 -2
- package/dist/esm/generated/operations.js +39 -28
- package/dist/esm/generated/resources.d.ts +206 -27
- package/dist/esm/generated/resources.js +95 -16
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/pagination.d.ts +3 -0
- package/dist/esm/pagination.js +25 -5
- package/dist/esm/resources.d.ts +17 -3
- package/dist/esm/resources.js +8 -3
- package/dist/esm/webhooks.d.ts +11 -1
- package/package.json +1 -1
|
@@ -17,105 +17,105 @@ export class CallsGenerated extends Resource {
|
|
|
17
17
|
export class FinnsGenerated extends Resource {
|
|
18
18
|
/**
|
|
19
19
|
* Draft a Finn with AI.
|
|
20
|
-
* `POST /finns/generate`, operationId `generateFinn`.
|
|
20
|
+
* `POST /finns/generate`, operationId `generateFinn`, scope `finn:write`.
|
|
21
21
|
*/
|
|
22
22
|
generate(body, options) {
|
|
23
23
|
return this.do('post', '/finns/generate', { body }, options);
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* Read a Finn's call flow.
|
|
27
|
-
* `GET /finns/{finn_id}/flow`, operationId `getFinnFlow`.
|
|
27
|
+
* `GET /finns/{finn_id}/flow`, operationId `getFinnFlow`, scope `finn:read`.
|
|
28
28
|
*/
|
|
29
29
|
getFlow(finnId, options) {
|
|
30
30
|
return this.do('get', '/finns/{finn_id}/flow', { path: { finn_id: finnId } }, options);
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* Turn a Finn's call flow on.
|
|
34
|
-
* `POST /finns/{finn_id}/flow/enable`, operationId `enableFinnFlow`.
|
|
34
|
+
* `POST /finns/{finn_id}/flow/enable`, operationId `enableFinnFlow`, scope `finn:write`.
|
|
35
35
|
*/
|
|
36
36
|
enableFlow(finnId, options) {
|
|
37
37
|
return this.do('post', '/finns/{finn_id}/flow/enable', { path: { finn_id: finnId } }, options);
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* Turn a Finn's call flow off.
|
|
41
|
-
* `POST /finns/{finn_id}/flow/disable`, operationId `disableFinnFlow`.
|
|
41
|
+
* `POST /finns/{finn_id}/flow/disable`, operationId `disableFinnFlow`, scope `finn:write`.
|
|
42
42
|
*/
|
|
43
43
|
disableFlow(finnId, options) {
|
|
44
44
|
return this.do('post', '/finns/{finn_id}/flow/disable', { path: { finn_id: finnId } }, options);
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
47
|
* Read a Finn's settings.
|
|
48
|
-
* `GET /finns/{finn_id}/settings`, operationId `getFinnSettings`.
|
|
48
|
+
* `GET /finns/{finn_id}/settings`, operationId `getFinnSettings`, scope `finn:read`.
|
|
49
49
|
*/
|
|
50
50
|
getSettings(finnId, options) {
|
|
51
51
|
return this.do('get', '/finns/{finn_id}/settings', { path: { finn_id: finnId } }, options);
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* Read a Finn's variables.
|
|
55
|
-
* `GET /finns/{finn_id}/variables`, operationId `getFinnVariables`.
|
|
55
|
+
* `GET /finns/{finn_id}/variables`, operationId `getFinnVariables`, scope `finn:read`.
|
|
56
56
|
*/
|
|
57
57
|
getVariables(finnId, options) {
|
|
58
58
|
return this.do('get', '/finns/{finn_id}/variables', { path: { finn_id: finnId } }, options);
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
61
|
* Edit a Finn's variables.
|
|
62
|
-
* `PATCH /finns/{finn_id}/variables`, operationId `updateFinnVariables`.
|
|
62
|
+
* `PATCH /finns/{finn_id}/variables`, operationId `updateFinnVariables`, scope `finn:write`.
|
|
63
63
|
*/
|
|
64
64
|
updateVariables(finnId, body, options) {
|
|
65
65
|
return this.do('patch', '/finns/{finn_id}/variables', { path: { finn_id: finnId }, body }, options);
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
68
|
* Edit a Finn's agent handbook.
|
|
69
|
-
* `PATCH /finns/{finn_id}/handbook`, operationId `updateFinnHandbook`.
|
|
69
|
+
* `PATCH /finns/{finn_id}/handbook`, operationId `updateFinnHandbook`, scope `finn:write`.
|
|
70
70
|
*/
|
|
71
71
|
updateHandbook(finnId, body, options) {
|
|
72
72
|
return this.do('patch', '/finns/{finn_id}/handbook', { path: { finn_id: finnId }, body }, options);
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
75
|
* Edit a Finn's speech settings.
|
|
76
|
-
* `PATCH /finns/{finn_id}/speech_settings`, operationId `updateFinnSpeechSettings`.
|
|
76
|
+
* `PATCH /finns/{finn_id}/speech_settings`, operationId `updateFinnSpeechSettings`, scope `finn:write`.
|
|
77
77
|
*/
|
|
78
78
|
updateSpeechSettings(finnId, body, options) {
|
|
79
79
|
return this.do('patch', '/finns/{finn_id}/speech_settings', { path: { finn_id: finnId }, body }, options);
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
82
|
* Edit a draft Finn.
|
|
83
|
-
* `PATCH /finns/{finn_id}/draft`, operationId `updateFinnDraft`.
|
|
83
|
+
* `PATCH /finns/{finn_id}/draft`, operationId `updateFinnDraft`, scope `finn:write`.
|
|
84
84
|
*/
|
|
85
85
|
updateDraft(finnId, body, options) {
|
|
86
86
|
return this.do('patch', '/finns/{finn_id}/draft', { path: { finn_id: finnId }, body }, options);
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
89
|
* Copy a Finn.
|
|
90
|
-
* `POST /finns/{finn_id}/duplicate`, operationId `duplicateFinn`.
|
|
90
|
+
* `POST /finns/{finn_id}/duplicate`, operationId `duplicateFinn`, scope `finn:write`.
|
|
91
91
|
*/
|
|
92
92
|
duplicate(finnId, body, options) {
|
|
93
93
|
return this.do('post', '/finns/{finn_id}/duplicate', { path: { finn_id: finnId }, body }, options);
|
|
94
94
|
}
|
|
95
95
|
/**
|
|
96
96
|
* Read a Finn's share link.
|
|
97
|
-
* `GET /finns/{finn_id}/share_link`, operationId `getFinnShareLink`.
|
|
97
|
+
* `GET /finns/{finn_id}/share_link`, operationId `getFinnShareLink`, scope `finn:read`.
|
|
98
98
|
*/
|
|
99
99
|
getShareLink(finnId, options) {
|
|
100
100
|
return this.do('get', '/finns/{finn_id}/share_link', { path: { finn_id: finnId } }, options);
|
|
101
101
|
}
|
|
102
102
|
/**
|
|
103
103
|
* Get or make a Finn's share link.
|
|
104
|
-
* `POST /finns/{finn_id}/share_link`, operationId `createFinnShareLink`.
|
|
104
|
+
* `POST /finns/{finn_id}/share_link`, operationId `createFinnShareLink`, scope `finn:write`.
|
|
105
105
|
*/
|
|
106
106
|
createShareLink(finnId, options) {
|
|
107
107
|
return this.do('post', '/finns/{finn_id}/share_link', { path: { finn_id: finnId } }, options);
|
|
108
108
|
}
|
|
109
109
|
/**
|
|
110
110
|
* A Finn's call stats.
|
|
111
|
-
* `GET /finns/{finn_id}/stats`, operationId `getFinnStats`.
|
|
111
|
+
* `GET /finns/{finn_id}/stats`, operationId `getFinnStats`, scope `finn:read`.
|
|
112
112
|
*/
|
|
113
113
|
getStats(finnId, query, options) {
|
|
114
114
|
return this.do('get', '/finns/{finn_id}/stats', { path: { finn_id: finnId }, query }, options);
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
117
|
* Summarize a Finn's call outcomes.
|
|
118
|
-
* `GET /finns/{finn_id}/outcomes`, operationId `getFinnOutcomes`.
|
|
118
|
+
* `GET /finns/{finn_id}/outcomes`, operationId `getFinnOutcomes`, scope `finn:read`.
|
|
119
119
|
*/
|
|
120
120
|
getOutcomes(finnId, query, options) {
|
|
121
121
|
return this.do('get', '/finns/{finn_id}/outcomes', { path: { finn_id: finnId }, query }, options);
|
|
@@ -170,11 +170,40 @@ export class ApprovalsGenerated extends Resource {
|
|
|
170
170
|
* Generated methods for the Agents tag; `Agents` in src/resources.ts adds the hand-written ones.
|
|
171
171
|
*/
|
|
172
172
|
export class AgentsGenerated extends Resource {
|
|
173
|
+
/**
|
|
174
|
+
* Archive an agent.
|
|
175
|
+
* `POST /agents/{id}/archive`, operationId `archiveAgent`, scope `operator:build`.
|
|
176
|
+
*/
|
|
177
|
+
archive(id, options) {
|
|
178
|
+
return this.do('post', '/agents/{id}/archive', { path: { id } }, options);
|
|
179
|
+
}
|
|
173
180
|
}
|
|
174
181
|
/**
|
|
175
182
|
* Generated methods for the Chat tag; `Chat` in src/resources.ts adds the hand-written ones.
|
|
176
183
|
*/
|
|
177
184
|
export class ChatGenerated extends Resource {
|
|
185
|
+
/**
|
|
186
|
+
* Get a chat agent's settings.
|
|
187
|
+
* `GET /chat/agents/{agent_id}`, operationId `getChatAgent`, scope `chat:read`.
|
|
188
|
+
*/
|
|
189
|
+
getAgent(agentId, options) {
|
|
190
|
+
return this.do('get', '/chat/agents/{agent_id}', { path: { agent_id: agentId } }, options);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Change a chat agent's settings.
|
|
194
|
+
* `PATCH /chat/agents/{agent_id}`, operationId `updateChatAgent`, scope `chat:write`.
|
|
195
|
+
* May answer `pending_approval` (see isPendingApproval).
|
|
196
|
+
*/
|
|
197
|
+
updateAgent(agentId, body, options) {
|
|
198
|
+
return this.do('patch', '/chat/agents/{agent_id}', { path: { agent_id: agentId }, body }, options);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Test a chat agent.
|
|
202
|
+
* `POST /chat/agents/{agent_id}/test_turn`, operationId `testChatAgent`, scope `chat:write`.
|
|
203
|
+
*/
|
|
204
|
+
testAgent(agentId, body, options) {
|
|
205
|
+
return this.do('post', '/chat/agents/{agent_id}/test_turn', { path: { agent_id: agentId }, body }, options);
|
|
206
|
+
}
|
|
178
207
|
}
|
|
179
208
|
/**
|
|
180
209
|
* CRM: records, stages, forms, documents, follow-ups, views and imports (`/crm`). Reached as `finn.crm`.
|
|
@@ -527,6 +556,27 @@ export class Dialer extends Resource {
|
|
|
527
556
|
getLeadBrief(id, query, options) {
|
|
528
557
|
return this.do('get', '/dialer/leads/{id}/brief', { path: { id }, query }, options);
|
|
529
558
|
}
|
|
559
|
+
/**
|
|
560
|
+
* Mark a dialer follow-up done.
|
|
561
|
+
* `POST /dialer/follow-ups/{call_id}/done`, operationId `markDialerFollowUpDone`, scope `dialer:write`.
|
|
562
|
+
*/
|
|
563
|
+
markFollowUpDone(callId, options) {
|
|
564
|
+
return this.do('post', '/dialer/follow-ups/{call_id}/done', { path: { call_id: callId } }, options);
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Set a finished call's disposition.
|
|
568
|
+
* `PUT /dialer/calls/{call_id}/disposition`, operationId `setDialerCallDisposition`, scope `dialer:write`.
|
|
569
|
+
*/
|
|
570
|
+
setCallDisposition(callId, body, options) {
|
|
571
|
+
return this.do('put', '/dialer/calls/{call_id}/disposition', { path: { call_id: callId }, body }, options);
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* Add a note to a finished call.
|
|
575
|
+
* `POST /dialer/calls/{call_id}/notes`, operationId `addDialerCallNote`, scope `dialer:write`.
|
|
576
|
+
*/
|
|
577
|
+
addCallNote(callId, body, options) {
|
|
578
|
+
return this.do('post', '/dialer/calls/{call_id}/notes', { path: { call_id: callId }, body }, options);
|
|
579
|
+
}
|
|
530
580
|
}
|
|
531
581
|
/**
|
|
532
582
|
* Webhook endpoints, their deliveries, and the event types (`/webhook_endpoints`, `/events`). Reached as `finn.webhooks`.
|
|
@@ -583,12 +633,33 @@ export class Webhooks extends Resource {
|
|
|
583
633
|
return this.pager('/webhook_endpoints/{id}/deliveries', cursorStrategy('data'), query, { id }, options);
|
|
584
634
|
}
|
|
585
635
|
/**
|
|
586
|
-
* List webhook
|
|
636
|
+
* List webhook event types.
|
|
587
637
|
* `GET /events`, operationId `listEventTypes`, scope `admin:webhooks`.
|
|
588
638
|
*/
|
|
589
639
|
listEventTypes(options) {
|
|
590
640
|
return this.do('get', '/events', {}, options);
|
|
591
641
|
}
|
|
642
|
+
/**
|
|
643
|
+
* Send a test event.
|
|
644
|
+
* `POST /webhook_endpoints/{id}/test`, operationId `testWebhookEndpoint`, scope `admin:webhooks`.
|
|
645
|
+
*/
|
|
646
|
+
testEndpoint(id, options) {
|
|
647
|
+
return this.do('post', '/webhook_endpoints/{id}/test', { path: { id } }, options);
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* Redeliver an event.
|
|
651
|
+
* `POST /webhook_endpoints/{id}/deliveries/{delivery_id}/redeliver`, operationId `redeliverWebhookDelivery`, scope `admin:webhooks`.
|
|
652
|
+
*/
|
|
653
|
+
redeliverDelivery(id, deliveryId, options) {
|
|
654
|
+
return this.do('post', '/webhook_endpoints/{id}/deliveries/{delivery_id}/redeliver', { path: { id, delivery_id: deliveryId } }, options);
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* Rotate the signing secret.
|
|
658
|
+
* `POST /webhook_endpoints/{id}/rotate_secret`, operationId `rotateWebhookEndpointSecret`, scope `admin:webhooks`.
|
|
659
|
+
*/
|
|
660
|
+
rotateEndpointSecret(id, options) {
|
|
661
|
+
return this.do('post', '/webhook_endpoints/{id}/rotate_secret', { path: { id } }, options);
|
|
662
|
+
}
|
|
592
663
|
}
|
|
593
664
|
/**
|
|
594
665
|
* The organization, its members, integrations and API keys (read only). Reached as `finn.organization`.
|
|
@@ -634,6 +705,13 @@ export class Organization extends Resource {
|
|
|
634
705
|
listAllApiKeys(query, options) {
|
|
635
706
|
return this.pager('/organization/api_keys', cursorStrategy('data'), query, undefined, options);
|
|
636
707
|
}
|
|
708
|
+
/**
|
|
709
|
+
* Get API usage by key and day.
|
|
710
|
+
* `GET /usage`, operationId `getUsage`, scope `admin:read`.
|
|
711
|
+
*/
|
|
712
|
+
getUsage(query, options) {
|
|
713
|
+
return this.do('get', '/usage', { query }, options);
|
|
714
|
+
}
|
|
637
715
|
}
|
|
638
716
|
/**
|
|
639
717
|
* Sales plays, prospects, drafts and threads (`/sales`). Reached as `finn.sales`.
|
|
@@ -668,6 +746,7 @@ export class Sales extends Resource {
|
|
|
668
746
|
/**
|
|
669
747
|
* Run a play.
|
|
670
748
|
* `POST /sales/plays/{slug}/run`, operationId `runSalesPlay`, scope `sales:write`.
|
|
749
|
+
* May answer `pending_approval` (see isPendingApproval).
|
|
671
750
|
* @experimental The Sales API is switched off for every organization, so these calls answer an error until it is switched on for yours. Names and shapes may change without a major version.
|
|
672
751
|
*/
|
|
673
752
|
runPlay(slug, options) {
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export { Finn } from './client.js';
|
|
2
2
|
export { Finn as default } from './client.js';
|
|
3
|
-
export { FinnCore, DEFAULT_BASE_URL, SDK_VERSION, AUTO_IDEMPOTENCY_ROUTES, IDEMPOTENT_WRITE_ROUTES, honoursIdempotencyKey, idempotencyKey, } from './core.js';
|
|
3
|
+
export { FinnCore, DEFAULT_BASE_URL, SDK_VERSION, DEFAULT_FINN_VERSION, AUTO_IDEMPOTENCY_ROUTES, IDEMPOTENT_WRITE_ROUTES, honoursIdempotencyKey, idempotencyKey, DEFAULT_MAX_RETRY_WAIT_MS, } from './core.js';
|
|
4
4
|
export { verifyWebhook, signWebhookPayload, parseSignatureHeader, timingSafeEqual, FinnWebhookVerificationError, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_EVENT_HEADER, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, } from './webhooks.js';
|
|
5
5
|
export type { VerifyWebhookOptions, WebhookEvent } from './webhooks.js';
|
|
6
6
|
export type { FinnOptions, RawRequest } from './core.js';
|
|
7
7
|
export { FinnSdkError, FinnError, FinnConnectionError, FinnTimeoutError, FinnApprovalTimeoutError, codeForStatus, parseRetryAfterSeconds, } from './errors.js';
|
|
8
8
|
export type { FinnErrorCode, FinnFieldError } from './errors.js';
|
|
9
9
|
export { isPendingApproval } from './approval.js';
|
|
10
|
-
export { Paginator, cursorStrategy, offsetStrategy, pageStrategy, beforeStrategy } from './pagination.js';
|
|
10
|
+
export { Paginator, cursorStrategy, offsetStrategy, pageStrategy, beforeStrategy, afterStrategy } from './pagination.js';
|
|
11
11
|
export type { PageStrategy } from './pagination.js';
|
|
12
12
|
export * from './resources.js';
|
|
13
13
|
export type { ApprovalHold, BodyOf, FinnResponse, HoldAction, HoldStatus, HoldableRoute, HttpMethod, Operation, PathParamsOf, PathsFor, PendingApproval, QueryOf, RequestOptions, RequestParams, ResponseOf, ResultOf, Schemas, components, operations, paths, } from './types.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { Finn } from './client.js';
|
|
2
2
|
export { Finn as default } from './client.js';
|
|
3
|
-
export { FinnCore, DEFAULT_BASE_URL, SDK_VERSION, AUTO_IDEMPOTENCY_ROUTES, IDEMPOTENT_WRITE_ROUTES, honoursIdempotencyKey, idempotencyKey, } from './core.js';
|
|
3
|
+
export { FinnCore, DEFAULT_BASE_URL, SDK_VERSION, DEFAULT_FINN_VERSION, AUTO_IDEMPOTENCY_ROUTES, IDEMPOTENT_WRITE_ROUTES, honoursIdempotencyKey, idempotencyKey, DEFAULT_MAX_RETRY_WAIT_MS, } from './core.js';
|
|
4
4
|
export { verifyWebhook, signWebhookPayload, parseSignatureHeader, timingSafeEqual, FinnWebhookVerificationError, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_EVENT_HEADER, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, } from './webhooks.js';
|
|
5
5
|
export { FinnSdkError, FinnError, FinnConnectionError, FinnTimeoutError, FinnApprovalTimeoutError, codeForStatus, parseRetryAfterSeconds, } from './errors.js';
|
|
6
6
|
export { isPendingApproval } from './approval.js';
|
|
7
|
-
export { Paginator, cursorStrategy, offsetStrategy, pageStrategy, beforeStrategy } from './pagination.js';
|
|
7
|
+
export { Paginator, cursorStrategy, offsetStrategy, pageStrategy, beforeStrategy, afterStrategy } from './pagination.js';
|
|
8
8
|
export * from './resources.js';
|
package/dist/esm/pagination.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* - offset (older voice lists: calls, finns, audiences, ...): `?limit=&offset=` → `{ data, limit, offset, total? }`
|
|
6
6
|
* - page (contacts): `?page=&page_size=` → `{ contacts, page, totalPages }`
|
|
7
7
|
* - before (cases, timeline): `?before=` → `{ cases, next_before }` or `{ items, next }`
|
|
8
|
+
* - after (case events): `?after=&limit=` → `{ events, next_after }`
|
|
8
9
|
*
|
|
9
10
|
* for await (const call of finn.calls.listAll({ status: 'completed' })) { ... }
|
|
10
11
|
* for await (const page of finn.calls.listAll().pages()) { ... }
|
|
@@ -33,4 +34,6 @@ export declare function offsetStrategy<Item>(key?: string): PageStrategy<unknown
|
|
|
33
34
|
export declare function pageStrategy<Item>(key: string): PageStrategy<unknown, Item>;
|
|
34
35
|
/** `?before=` lists answering `{ [key], [nextKey] }`. */
|
|
35
36
|
export declare function beforeStrategy<Item>(key: string, nextKey: string): PageStrategy<unknown, Item>;
|
|
37
|
+
/** `?after=` lists answering `{ [key], [nextKey] }`, where `nextKey` is the last sequence number on the page. */
|
|
38
|
+
export declare function afterStrategy<Item>(key: string, nextKey: string): PageStrategy<unknown, Item>;
|
|
36
39
|
export {};
|
package/dist/esm/pagination.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* - offset (older voice lists: calls, finns, audiences, ...): `?limit=&offset=` → `{ data, limit, offset, total? }`
|
|
6
6
|
* - page (contacts): `?page=&page_size=` → `{ contacts, page, totalPages }`
|
|
7
7
|
* - before (cases, timeline): `?before=` → `{ cases, next_before }` or `{ items, next }`
|
|
8
|
+
* - after (case events): `?after=&limit=` → `{ events, next_after }`
|
|
8
9
|
*
|
|
9
10
|
* for await (const call of finn.calls.listAll({ status: 'completed' })) { ... }
|
|
10
11
|
* for await (const page of finn.calls.listAll().pages()) { ... }
|
|
@@ -36,8 +37,9 @@ export class Paginator {
|
|
|
36
37
|
while (query) {
|
|
37
38
|
const res = await __classPrivateFieldGet(this, _Paginator_fetchPage, "f").call(this, query);
|
|
38
39
|
yield res;
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
// An empty page ends the list only when the strategy finds no next page: the API filters some lists after
|
|
41
|
+
// paging (hidden cases, chat notes), so a page can come back empty with a cursor that still moves on.
|
|
42
|
+
query = __classPrivateFieldGet(this, _Paginator_strategy, "f").next(res, query, __classPrivateFieldGet(this, _Paginator_strategy, "f").items(res).length);
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
async *[(_Paginator_fetchPage = new WeakMap(), _Paginator_strategy = new WeakMap(), _Paginator_query = new WeakMap(), Symbol.asyncIterator)]() {
|
|
@@ -66,7 +68,7 @@ export function cursorStrategy(key = 'data') {
|
|
|
66
68
|
next: (res, query) => {
|
|
67
69
|
const r = rec(res);
|
|
68
70
|
const cursor = r.next_cursor;
|
|
69
|
-
if (r.has_more === false || typeof cursor !== 'string' || cursor === '')
|
|
71
|
+
if (r.has_more === false || typeof cursor !== 'string' || cursor === '' || cursor === query.cursor)
|
|
70
72
|
return null;
|
|
71
73
|
return { ...query, cursor };
|
|
72
74
|
},
|
|
@@ -77,6 +79,8 @@ export function offsetStrategy(key = 'data') {
|
|
|
77
79
|
return {
|
|
78
80
|
items: (res) => arr(rec(res)[key]),
|
|
79
81
|
next: (res, query, count) => {
|
|
82
|
+
if (count === 0)
|
|
83
|
+
return null;
|
|
80
84
|
const r = rec(res);
|
|
81
85
|
const offset = typeof r.offset === 'number' ? r.offset : Number(query.offset ?? 0);
|
|
82
86
|
const limit = typeof r.limit === 'number' ? r.limit : Number(query.limit ?? count);
|
|
@@ -93,7 +97,9 @@ export function offsetStrategy(key = 'data') {
|
|
|
93
97
|
export function pageStrategy(key) {
|
|
94
98
|
return {
|
|
95
99
|
items: (res) => arr(rec(res)[key]),
|
|
96
|
-
next: (res, query) => {
|
|
100
|
+
next: (res, query, count) => {
|
|
101
|
+
if (count === 0)
|
|
102
|
+
return null;
|
|
97
103
|
const r = rec(res);
|
|
98
104
|
const page = typeof r.page === 'number' ? r.page : Number(query.page ?? 1);
|
|
99
105
|
if (typeof r.totalPages === 'number' && page >= r.totalPages)
|
|
@@ -108,9 +114,23 @@ export function beforeStrategy(key, nextKey) {
|
|
|
108
114
|
items: (res) => arr(rec(res)[key]),
|
|
109
115
|
next: (res, query) => {
|
|
110
116
|
const next = rec(res)[nextKey];
|
|
111
|
-
if (next === null || next === undefined || next === '')
|
|
117
|
+
if (next === null || next === undefined || next === '' || String(next) === String(query.before ?? ''))
|
|
112
118
|
return null;
|
|
113
119
|
return { ...query, before: next };
|
|
114
120
|
},
|
|
115
121
|
};
|
|
116
122
|
}
|
|
123
|
+
/** `?after=` lists answering `{ [key], [nextKey] }`, where `nextKey` is the last sequence number on the page. */
|
|
124
|
+
export function afterStrategy(key, nextKey) {
|
|
125
|
+
return {
|
|
126
|
+
items: (res) => arr(rec(res)[key]),
|
|
127
|
+
next: (res, query, count) => {
|
|
128
|
+
const next = rec(res)[nextKey];
|
|
129
|
+
if (typeof next !== 'number' || String(next) === String(query.after ?? ''))
|
|
130
|
+
return null;
|
|
131
|
+
if (query.limit !== undefined && count < Number(query.limit))
|
|
132
|
+
return null;
|
|
133
|
+
return { ...query, after: next };
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
}
|
package/dist/esm/resources.d.ts
CHANGED
|
@@ -257,7 +257,7 @@ export declare class Deployments extends DeploymentsGenerated {
|
|
|
257
257
|
createInbound(body: B<'/deployments/inbound', 'post'>, options?: RequestOptions): Promise<{
|
|
258
258
|
success: true;
|
|
259
259
|
data: import("./types.js").components["schemas"]["Deployment"];
|
|
260
|
-
}>;
|
|
260
|
+
} | import("./types.js").PendingApproval>;
|
|
261
261
|
retrieve(id: Id, options?: RequestOptions): Promise<{
|
|
262
262
|
success: true;
|
|
263
263
|
data: import("./types.js").components["schemas"]["Deployment"];
|
|
@@ -475,10 +475,24 @@ export declare class Cases extends CasesGenerated {
|
|
|
475
475
|
} & {
|
|
476
476
|
[key: string]: unknown;
|
|
477
477
|
}>;
|
|
478
|
-
|
|
478
|
+
/** One page of a case's events: pass the previous page's `next_after` as `after` for the next one. */
|
|
479
|
+
listEvents(id: Id, query?: Q<'/cases/{id}/events', 'get'>, options?: RequestOptions): Promise<{
|
|
479
480
|
events: import("./types.js").components["schemas"]["CaseEvent"][];
|
|
480
481
|
next_after: number;
|
|
481
482
|
}>;
|
|
483
|
+
/** Every event of a case, oldest first, page by page (follows `next_after`). */
|
|
484
|
+
listAllEvents(id: Id, query?: Q<'/cases/{id}/events', 'get'>, options?: RequestOptions): import("./pagination.js").Paginator<{
|
|
485
|
+
seq: number;
|
|
486
|
+
type: string;
|
|
487
|
+
actor_type: string;
|
|
488
|
+
actor_id?: string;
|
|
489
|
+
step_id?: string;
|
|
490
|
+
thread_id?: string;
|
|
491
|
+
data?: unknown;
|
|
492
|
+
at: string;
|
|
493
|
+
} & {
|
|
494
|
+
[key: string]: unknown;
|
|
495
|
+
}, unknown>;
|
|
482
496
|
/** Start a case on an agent. Gets an automatic Idempotency-Key. May answer `pending_approval` (see isPendingApproval). */
|
|
483
497
|
start(agentId: Id, body?: B<'/agents/{id}/cases', 'post'>, options?: RequestOptions): Promise<{
|
|
484
498
|
case_id: string;
|
|
@@ -822,7 +836,7 @@ export declare class ChatContacts extends Resource {
|
|
|
822
836
|
}>;
|
|
823
837
|
update(id: Id, body: B<'/chat/contacts/{id}', 'patch'>, options?: RequestOptions): Promise<{
|
|
824
838
|
[key: string]: unknown;
|
|
825
|
-
}>;
|
|
839
|
+
} | import("./types.js").PendingApproval>;
|
|
826
840
|
}
|
|
827
841
|
export declare class Chat extends ChatGenerated {
|
|
828
842
|
readonly conversations: ChatConversations;
|
package/dist/esm/resources.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FinnApprovalTimeoutError } from './errors.js';
|
|
2
|
-
import { beforeStrategy, cursorStrategy, offsetStrategy, pageStrategy } from './pagination.js';
|
|
2
|
+
import { afterStrategy, beforeStrategy, cursorStrategy, offsetStrategy, pageStrategy } from './pagination.js';
|
|
3
3
|
import { Resource } from './resource.js';
|
|
4
4
|
import { AgentsGenerated, ApprovalsGenerated, AudiencesGenerated, CallsGenerated, CasesGenerated, ChatGenerated, ContactsGenerated, DeploymentsGenerated, DoNotCallGenerated, FinnsGenerated, PhoneNumbersGenerated, VoicesGenerated, WalletGenerated, } from './generated/resources.js';
|
|
5
5
|
export { Crm, Dialer, Organization, Sales, Webhooks } from './generated/resources.js';
|
|
@@ -210,8 +210,13 @@ export class Cases extends CasesGenerated {
|
|
|
210
210
|
retrieve(id, options) {
|
|
211
211
|
return this.do('get', '/cases/{id}', { path: { id } }, options);
|
|
212
212
|
}
|
|
213
|
-
|
|
214
|
-
|
|
213
|
+
/** One page of a case's events: pass the previous page's `next_after` as `after` for the next one. */
|
|
214
|
+
listEvents(id, query, options) {
|
|
215
|
+
return this.do('get', '/cases/{id}/events', { path: { id }, query }, options);
|
|
216
|
+
}
|
|
217
|
+
/** Every event of a case, oldest first, page by page (follows `next_after`). */
|
|
218
|
+
listAllEvents(id, query, options) {
|
|
219
|
+
return this.pager('/cases/{id}/events', afterStrategy('events', 'next_after'), query, { id }, options);
|
|
215
220
|
}
|
|
216
221
|
/** Start a case on an agent. Gets an automatic Idempotency-Key. May answer `pending_approval` (see isPendingApproval). */
|
|
217
222
|
start(agentId, body, options) {
|
package/dist/esm/webhooks.d.ts
CHANGED
|
@@ -12,11 +12,21 @@ export declare const WEBHOOK_SIGNATURE_HEADER = "X-Finn-Signature";
|
|
|
12
12
|
export declare const WEBHOOK_EVENT_HEADER = "X-Finn-Event";
|
|
13
13
|
/** Default largest gap, in seconds, between the signed timestamp and now. */
|
|
14
14
|
export declare const DEFAULT_WEBHOOK_TOLERANCE_SECONDS = 300;
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* The body of a webhook delivery (the Finn envelope). Endpoints imported from Finn Chat with the `chat` envelope get
|
|
17
|
+
* Finn Chat's own body instead: `{ id, event, createdAt, orgId, data }`.
|
|
18
|
+
*/
|
|
16
19
|
export interface WebhookEvent<T = Record<string, unknown>> {
|
|
17
20
|
/** e.g. `call.completed`, `contact.created`, `case.completed`. */
|
|
18
21
|
event: string;
|
|
22
|
+
/** Unique per event, and the same on every retry or redelivery of it: dedupe on it. */
|
|
23
|
+
event_id?: string;
|
|
24
|
+
/** When this delivery was sent. */
|
|
19
25
|
created_at: string;
|
|
26
|
+
/** When the event happened. */
|
|
27
|
+
occurred_at?: string;
|
|
28
|
+
/** The organization the event belongs to. */
|
|
29
|
+
org_id?: string;
|
|
20
30
|
data: T;
|
|
21
31
|
}
|
|
22
32
|
/** The delivery's signature is missing, malformed, wrong or too old. Answer the request with a 400. */
|