@hirefinn/sdk 0.2.0 → 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.
- package/README.md +39 -9
- package/dist/cjs/client.d.ts +13 -1
- package/dist/cjs/client.js +5 -0
- package/dist/cjs/core.d.ts +1 -1
- package/dist/cjs/core.js +3 -1
- package/dist/cjs/generated/openapi.d.ts +17426 -5875
- package/dist/cjs/generated/operations.d.ts +26 -0
- package/dist/cjs/generated/operations.js +165 -0
- package/dist/cjs/generated/resources.d.ts +887 -0
- package/dist/cjs/generated/resources.js +737 -0
- package/dist/cjs/resource.d.ts +30 -0
- package/dist/cjs/resource.js +23 -0
- package/dist/cjs/resources.d.ts +47 -54
- package/dist/cjs/resources.js +24 -34
- package/dist/cjs/types.d.ts +11 -3
- package/dist/esm/client.d.ts +13 -1
- package/dist/esm/client.js +6 -1
- package/dist/esm/core.d.ts +1 -1
- package/dist/esm/core.js +3 -1
- package/dist/esm/generated/openapi.d.ts +17426 -5875
- package/dist/esm/generated/operations.d.ts +26 -0
- package/dist/esm/generated/operations.js +162 -0
- package/dist/esm/generated/resources.d.ts +887 -0
- package/dist/esm/generated/resources.js +716 -0
- package/dist/esm/resource.d.ts +30 -0
- package/dist/esm/resource.js +19 -0
- package/dist/esm/resources.d.ts +47 -54
- package/dist/esm/resources.js +17 -32
- package/dist/esm/types.d.ts +11 -3
- package/package.json +2 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The base class of every resource (hand-written in resources.ts and generated in generated/resources.ts), and the
|
|
3
|
+
* type shorthands their method signatures use.
|
|
4
|
+
*/
|
|
5
|
+
import type { FinnCore } from './core.js';
|
|
6
|
+
import { Paginator, type PageStrategy } from './pagination.js';
|
|
7
|
+
import type { BodyOf, HttpMethod, Operation, PathsFor, QueryOf, RequestOptions, ResultOf, paths } from './types.js';
|
|
8
|
+
/** The query of (P, M). */
|
|
9
|
+
export type Q<P extends keyof paths, M extends HttpMethod> = QueryOf<Operation<P, M>>;
|
|
10
|
+
/** The request body of (P, M). */
|
|
11
|
+
export type B<P extends keyof paths, M extends HttpMethod> = BodyOf<Operation<P, M>>;
|
|
12
|
+
/** What a method calling (P, M) resolves to. */
|
|
13
|
+
export type R<P extends keyof paths, M extends HttpMethod> = ResultOf<P & string, M, Operation<P, M>>;
|
|
14
|
+
/** The item type of a `{ data: Item[] }` list answer, or unknown. */
|
|
15
|
+
export type DataItem<T> = T extends {
|
|
16
|
+
data?: (infer I)[] | null;
|
|
17
|
+
} ? I : unknown;
|
|
18
|
+
export type Id = string;
|
|
19
|
+
interface Params {
|
|
20
|
+
path?: Record<string, string | number>;
|
|
21
|
+
query?: unknown;
|
|
22
|
+
body?: unknown;
|
|
23
|
+
}
|
|
24
|
+
export declare abstract class Resource {
|
|
25
|
+
protected readonly core: FinnCore;
|
|
26
|
+
constructor(core: FinnCore);
|
|
27
|
+
protected do<M extends HttpMethod, P extends PathsFor<M>>(method: M, path: P, params?: Params, options?: RequestOptions): Promise<R<P, M>>;
|
|
28
|
+
protected pager<Item>(path: PathsFor<'get'>, strategy: PageStrategy<unknown, Item>, query: unknown, pathParams?: Record<string, string>, options?: RequestOptions): Paginator<Item>;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Resource = void 0;
|
|
4
|
+
const pagination_js_1 = require("./pagination.js");
|
|
5
|
+
class Resource {
|
|
6
|
+
constructor(core) {
|
|
7
|
+
this.core = core;
|
|
8
|
+
}
|
|
9
|
+
async do(method, path, params = {}, options) {
|
|
10
|
+
const res = await this.core.rawRequest({
|
|
11
|
+
method,
|
|
12
|
+
path,
|
|
13
|
+
pathParams: params.path,
|
|
14
|
+
query: params.query,
|
|
15
|
+
body: params.body,
|
|
16
|
+
}, options);
|
|
17
|
+
return res.data;
|
|
18
|
+
}
|
|
19
|
+
pager(path, strategy, query, pathParams, options) {
|
|
20
|
+
return new pagination_js_1.Paginator(async (q) => (await this.core.rawRequest({ method: 'get', path, pathParams, query: q }, options)).data, strategy, (query ?? {}));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.Resource = Resource;
|
package/dist/cjs/resources.d.ts
CHANGED
|
@@ -1,27 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Hand-written resource classes: the named methods, pagination helpers and approval waits. Each class extends a
|
|
3
|
+
* generated base (src/generated/resources.ts) that adds a method for every other operation under the same tag, so
|
|
4
|
+
* together they cover every operation in the spec. Every method takes an optional last `options` argument
|
|
5
|
+
* (RequestOptions): idempotencyKey, org, version, maxRetries, timeoutMs, signal, headers.
|
|
5
6
|
*/
|
|
6
7
|
import type { FinnCore } from './core.js';
|
|
7
|
-
import {
|
|
8
|
-
import type { ApprovalHold,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
type Id = string;
|
|
13
|
-
interface Params {
|
|
14
|
-
path?: Record<string, string | number>;
|
|
15
|
-
query?: unknown;
|
|
16
|
-
body?: unknown;
|
|
17
|
-
}
|
|
18
|
-
declare abstract class Resource {
|
|
19
|
-
protected readonly core: FinnCore;
|
|
20
|
-
constructor(core: FinnCore);
|
|
21
|
-
protected do<M extends HttpMethod, P extends PathsFor<M>>(method: M, path: P, params?: Params, options?: RequestOptions): Promise<R<P, M>>;
|
|
22
|
-
protected pager<Item>(path: PathsFor<'get'>, strategy: ReturnType<typeof cursorStrategy<Item>>, query: unknown, pathParams?: Record<string, string>, options?: RequestOptions): Paginator<Item>;
|
|
23
|
-
}
|
|
24
|
-
export declare class Calls extends Resource {
|
|
8
|
+
import { Resource, type B, type Id, type Q } from './resource.js';
|
|
9
|
+
import type { ApprovalHold, RequestOptions, Schemas } from './types.js';
|
|
10
|
+
import { AgentsGenerated, ApprovalsGenerated, AudiencesGenerated, CallsGenerated, CasesGenerated, ChatGenerated, ContactsGenerated, DeploymentsGenerated, DoNotCallGenerated, FinnsGenerated, PhoneNumbersGenerated, VoicesGenerated, WalletGenerated } from './generated/resources.js';
|
|
11
|
+
export { Crm, Dialer, Organization, Sales, Webhooks } from './generated/resources.js';
|
|
12
|
+
export declare class Calls extends CallsGenerated {
|
|
25
13
|
/** Place an outbound call. Gets an automatic Idempotency-Key. May answer `pending_approval` (see isPendingApproval). */
|
|
26
14
|
create(body: B<'/calls', 'post'>, options?: RequestOptions): Promise<{
|
|
27
15
|
success: true;
|
|
@@ -35,7 +23,7 @@ export declare class Calls extends Resource {
|
|
|
35
23
|
offset: number;
|
|
36
24
|
}>;
|
|
37
25
|
/** Every call matching the filters, page by page. */
|
|
38
|
-
listAll(query?: Q<'/calls', 'get'>, options?: RequestOptions): Paginator<{
|
|
26
|
+
listAll(query?: Q<'/calls', 'get'>, options?: RequestOptions): import("./pagination.js").Paginator<{
|
|
39
27
|
call_uuid: string;
|
|
40
28
|
finn_id?: string | null;
|
|
41
29
|
deployment_id?: string | null;
|
|
@@ -55,14 +43,14 @@ export declare class Calls extends Resource {
|
|
|
55
43
|
data: import("./types.js").components["schemas"]["Call"];
|
|
56
44
|
}>;
|
|
57
45
|
}
|
|
58
|
-
export declare class Finns extends
|
|
46
|
+
export declare class Finns extends FinnsGenerated {
|
|
59
47
|
list(query?: Q<'/finns', 'get'>, options?: RequestOptions): Promise<{
|
|
60
48
|
success: true;
|
|
61
49
|
data: import("./types.js").components["schemas"]["Finn"][];
|
|
62
50
|
limit: number;
|
|
63
51
|
offset: number;
|
|
64
52
|
}>;
|
|
65
|
-
listAll(query?: Q<'/finns', 'get'>, options?: RequestOptions): Paginator<{
|
|
53
|
+
listAll(query?: Q<'/finns', 'get'>, options?: RequestOptions): import("./pagination.js").Paginator<{
|
|
66
54
|
id: string;
|
|
67
55
|
name: string;
|
|
68
56
|
status: string;
|
|
@@ -116,7 +104,7 @@ export declare class Finns extends Resource {
|
|
|
116
104
|
data: import("./types.js").components["schemas"]["FinnPostCallAnalysis"];
|
|
117
105
|
}>;
|
|
118
106
|
}
|
|
119
|
-
export declare class Voices extends
|
|
107
|
+
export declare class Voices extends VoicesGenerated {
|
|
120
108
|
list(query?: Q<'/voices', 'get'>, options?: RequestOptions): Promise<{
|
|
121
109
|
success: true;
|
|
122
110
|
data: import("./types.js").components["schemas"]["Voice"][];
|
|
@@ -124,7 +112,7 @@ export declare class Voices extends Resource {
|
|
|
124
112
|
limit: number;
|
|
125
113
|
offset: number;
|
|
126
114
|
}>;
|
|
127
|
-
listAll(query?: Q<'/voices', 'get'>, options?: RequestOptions): Paginator<{
|
|
115
|
+
listAll(query?: Q<'/voices', 'get'>, options?: RequestOptions): import("./pagination.js").Paginator<{
|
|
128
116
|
voice_id: string;
|
|
129
117
|
name: string | null;
|
|
130
118
|
description: string;
|
|
@@ -140,14 +128,14 @@ export declare class Voices extends Resource {
|
|
|
140
128
|
data: import("./types.js").components["schemas"]["Voice"];
|
|
141
129
|
}>;
|
|
142
130
|
}
|
|
143
|
-
export declare class PhoneNumbers extends
|
|
131
|
+
export declare class PhoneNumbers extends PhoneNumbersGenerated {
|
|
144
132
|
list(query?: Q<'/phone_numbers', 'get'>, options?: RequestOptions): Promise<{
|
|
145
133
|
success: true;
|
|
146
134
|
data: import("./types.js").components["schemas"]["PhoneNumber"][];
|
|
147
135
|
limit: number;
|
|
148
136
|
offset: number;
|
|
149
137
|
}>;
|
|
150
|
-
listAll(query?: Q<'/phone_numbers', 'get'>, options?: RequestOptions): Paginator<{
|
|
138
|
+
listAll(query?: Q<'/phone_numbers', 'get'>, options?: RequestOptions): import("./pagination.js").Paginator<{
|
|
151
139
|
id: string;
|
|
152
140
|
phone_number: string;
|
|
153
141
|
status: string;
|
|
@@ -180,14 +168,14 @@ export declare class PhoneNumbers extends Resource {
|
|
|
180
168
|
data: import("./types.js").components["schemas"]["ReleasedPhoneNumber"];
|
|
181
169
|
}>;
|
|
182
170
|
}
|
|
183
|
-
export declare class Audiences extends
|
|
171
|
+
export declare class Audiences extends AudiencesGenerated {
|
|
184
172
|
list(query?: Q<'/audiences', 'get'>, options?: RequestOptions): Promise<{
|
|
185
173
|
success: true;
|
|
186
174
|
data: import("./types.js").components["schemas"]["Audience"][];
|
|
187
175
|
limit: number;
|
|
188
176
|
offset: number;
|
|
189
177
|
}>;
|
|
190
|
-
listAll(query?: Q<'/audiences', 'get'>, options?: RequestOptions): Paginator<{
|
|
178
|
+
listAll(query?: Q<'/audiences', 'get'>, options?: RequestOptions): import("./pagination.js").Paginator<{
|
|
191
179
|
id: string;
|
|
192
180
|
name: string;
|
|
193
181
|
contact_count: number;
|
|
@@ -217,7 +205,7 @@ export declare class Audiences extends Resource {
|
|
|
217
205
|
limit: number;
|
|
218
206
|
offset: number;
|
|
219
207
|
}>;
|
|
220
|
-
listAllContacts(audienceId: Id, query?: Q<'/audiences/{audience_id}/contacts', 'get'>, options?: RequestOptions): Paginator<{
|
|
208
|
+
listAllContacts(audienceId: Id, query?: Q<'/audiences/{audience_id}/contacts', 'get'>, options?: RequestOptions): import("./pagination.js").Paginator<{
|
|
221
209
|
name?: string;
|
|
222
210
|
phone_number?: string;
|
|
223
211
|
country_code?: string;
|
|
@@ -236,14 +224,14 @@ export declare class Audiences extends Resource {
|
|
|
236
224
|
contacts_removed: number;
|
|
237
225
|
}>;
|
|
238
226
|
}
|
|
239
|
-
export declare class Deployments extends
|
|
227
|
+
export declare class Deployments extends DeploymentsGenerated {
|
|
240
228
|
list(query?: Q<'/deployments', 'get'>, options?: RequestOptions): Promise<{
|
|
241
229
|
success: true;
|
|
242
230
|
data: import("./types.js").components["schemas"]["Deployment"][];
|
|
243
231
|
limit: number;
|
|
244
232
|
offset: number;
|
|
245
233
|
}>;
|
|
246
|
-
listAll(query?: Q<'/deployments', 'get'>, options?: RequestOptions): Paginator<{
|
|
234
|
+
listAll(query?: Q<'/deployments', 'get'>, options?: RequestOptions): import("./pagination.js").Paginator<{
|
|
247
235
|
id: string;
|
|
248
236
|
finn_id?: string | null;
|
|
249
237
|
audience_id?: string | null;
|
|
@@ -287,7 +275,7 @@ export declare class Deployments extends Resource {
|
|
|
287
275
|
data: import("./types.js").components["schemas"]["DeploymentAnalytics"];
|
|
288
276
|
}>;
|
|
289
277
|
}
|
|
290
|
-
export declare class Wallet extends
|
|
278
|
+
export declare class Wallet extends WalletGenerated {
|
|
291
279
|
retrieve(options?: RequestOptions): Promise<{
|
|
292
280
|
success: true;
|
|
293
281
|
data: import("./types.js").components["schemas"]["Wallet"];
|
|
@@ -298,7 +286,7 @@ export declare class Wallet extends Resource {
|
|
|
298
286
|
limit: number;
|
|
299
287
|
offset: number;
|
|
300
288
|
}>;
|
|
301
|
-
listAllTransactions(query?: Q<'/wallet/transactions', 'get'>, options?: RequestOptions): Paginator<{
|
|
289
|
+
listAllTransactions(query?: Q<'/wallet/transactions', 'get'>, options?: RequestOptions): import("./pagination.js").Paginator<{
|
|
302
290
|
id: string;
|
|
303
291
|
type: string;
|
|
304
292
|
credits_delta: number;
|
|
@@ -307,7 +295,7 @@ export declare class Wallet extends Resource {
|
|
|
307
295
|
created_at: string;
|
|
308
296
|
}, unknown>;
|
|
309
297
|
}
|
|
310
|
-
export declare class DoNotCall extends
|
|
298
|
+
export declare class DoNotCall extends DoNotCallGenerated {
|
|
311
299
|
list(query?: Q<'/do_not_call', 'get'>, options?: RequestOptions): Promise<{
|
|
312
300
|
success: true;
|
|
313
301
|
data: import("./types.js").components["schemas"]["DoNotCallEntry"][];
|
|
@@ -315,7 +303,7 @@ export declare class DoNotCall extends Resource {
|
|
|
315
303
|
limit: number;
|
|
316
304
|
offset: number;
|
|
317
305
|
}>;
|
|
318
|
-
listAll(query?: Q<'/do_not_call', 'get'>, options?: RequestOptions): Paginator<{
|
|
306
|
+
listAll(query?: Q<'/do_not_call', 'get'>, options?: RequestOptions): import("./pagination.js").Paginator<{
|
|
319
307
|
phone_key: string;
|
|
320
308
|
phone_number: string;
|
|
321
309
|
sources: ("manual" | "crm_stage" | "rep_dialer" | "call_opt_out" | "chat_opt_out" | "import" | "api" | "operator" | "sales_ai")[];
|
|
@@ -337,7 +325,7 @@ export declare class DoNotCall extends Resource {
|
|
|
337
325
|
removed_sources: string[];
|
|
338
326
|
}>;
|
|
339
327
|
}
|
|
340
|
-
export declare class Contacts extends
|
|
328
|
+
export declare class Contacts extends ContactsGenerated {
|
|
341
329
|
list(query?: Q<'/contacts', 'get'>, options?: RequestOptions): Promise<{
|
|
342
330
|
contacts: import("./types.js").components["schemas"]["Record"][];
|
|
343
331
|
totalCount: number;
|
|
@@ -345,7 +333,7 @@ export declare class Contacts extends Resource {
|
|
|
345
333
|
pageSize: number;
|
|
346
334
|
totalPages: number;
|
|
347
335
|
}>;
|
|
348
|
-
listAll(query?: Q<'/contacts', 'get'>, options?: RequestOptions): Paginator<{
|
|
336
|
+
listAll(query?: Q<'/contacts', 'get'>, options?: RequestOptions): import("./pagination.js").Paginator<{
|
|
349
337
|
id: string;
|
|
350
338
|
phone: string;
|
|
351
339
|
phoneKey?: string;
|
|
@@ -401,7 +389,7 @@ export declare class Contacts extends Resource {
|
|
|
401
389
|
[key: string]: number;
|
|
402
390
|
};
|
|
403
391
|
}>;
|
|
404
|
-
timelineAll(id: Id, query?: Q<'/contacts/{id}/timeline', 'get'>, options?: RequestOptions): Paginator<{
|
|
392
|
+
timelineAll(id: Id, query?: Q<'/contacts/{id}/timeline', 'get'>, options?: RequestOptions): import("./pagination.js").Paginator<{
|
|
405
393
|
id: string;
|
|
406
394
|
kind: "call" | "chat" | "message" | "operator" | "note" | "form" | "change" | "file" | "view";
|
|
407
395
|
type?: string;
|
|
@@ -426,12 +414,12 @@ export declare class Contacts extends Resource {
|
|
|
426
414
|
fields: import("./types.js").components["schemas"]["FieldDefinition"][];
|
|
427
415
|
}>;
|
|
428
416
|
}
|
|
429
|
-
export declare class Cases extends
|
|
417
|
+
export declare class Cases extends CasesGenerated {
|
|
430
418
|
list(query?: Q<'/cases', 'get'>, options?: RequestOptions): Promise<{
|
|
431
419
|
cases: import("./types.js").components["schemas"]["CaseSummary"][];
|
|
432
420
|
next_before: string | null;
|
|
433
421
|
}>;
|
|
434
|
-
listAll(query?: Q<'/cases', 'get'>, options?: RequestOptions): Paginator<{
|
|
422
|
+
listAll(query?: Q<'/cases', 'get'>, options?: RequestOptions): import("./pagination.js").Paginator<{
|
|
435
423
|
id: string;
|
|
436
424
|
agent_id: string;
|
|
437
425
|
agent_name: string;
|
|
@@ -510,12 +498,12 @@ export interface WaitForApprovalOptions {
|
|
|
510
498
|
/** Replaces the wait between polls (for tests). */
|
|
511
499
|
sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
|
|
512
500
|
}
|
|
513
|
-
export declare class Approvals extends
|
|
501
|
+
export declare class Approvals extends ApprovalsGenerated {
|
|
514
502
|
list(query?: Q<'/approvals', 'get'>, options?: RequestOptions): Promise<{
|
|
515
|
-
approvals: import("./types.js").components["schemas"]["Approval"][];
|
|
503
|
+
approvals: (import("./types.js").components["schemas"]["Approval"] | import("./types.js").components["schemas"]["ApiHold"])[];
|
|
516
504
|
next_cursor: string | null;
|
|
517
505
|
}>;
|
|
518
|
-
listAll(query?: Q<'/approvals', 'get'>, options?: RequestOptions): Paginator<{
|
|
506
|
+
listAll(query?: Q<'/approvals', 'get'>, options?: RequestOptions): import("./pagination.js").Paginator<{
|
|
519
507
|
id: string;
|
|
520
508
|
case_id: string;
|
|
521
509
|
case_title?: string | null;
|
|
@@ -648,13 +636,13 @@ export declare class Approvals extends Resource {
|
|
|
648
636
|
*/
|
|
649
637
|
wait(id: Id, opts?: WaitForApprovalOptions): Promise<ApprovalHold | Schemas['Approval']>;
|
|
650
638
|
}
|
|
651
|
-
export declare class Agents extends
|
|
639
|
+
export declare class Agents extends AgentsGenerated {
|
|
652
640
|
list(query?: Q<'/agents', 'get'>, options?: RequestOptions): Promise<{
|
|
653
641
|
data: import("./types.js").components["schemas"]["AgentSummary"][];
|
|
654
642
|
next_cursor: string | null;
|
|
655
643
|
has_more: boolean;
|
|
656
644
|
}>;
|
|
657
|
-
listAll(query?: Q<'/agents', 'get'>, options?: RequestOptions): Paginator<{
|
|
645
|
+
listAll(query?: Q<'/agents', 'get'>, options?: RequestOptions): import("./pagination.js").Paginator<{
|
|
658
646
|
id: string;
|
|
659
647
|
name: string;
|
|
660
648
|
status: "draft" | "live" | "paused" | "archived";
|
|
@@ -785,7 +773,7 @@ export declare class ChatConversations extends Resource {
|
|
|
785
773
|
next_cursor: string | null;
|
|
786
774
|
has_more: boolean;
|
|
787
775
|
}>;
|
|
788
|
-
listAll(query?: Q<'/chat/conversations', 'get'>, options?: RequestOptions): Paginator<ChatItem, unknown>;
|
|
776
|
+
listAll(query?: Q<'/chat/conversations', 'get'>, options?: RequestOptions): import("./pagination.js").Paginator<ChatItem, unknown>;
|
|
789
777
|
/** Start a conversation (sends the first message). Gets an automatic Idempotency-Key (the API requires one). May answer `pending_approval`. */
|
|
790
778
|
start(body: B<'/chat/conversations', 'post'>, options?: RequestOptions): Promise<{
|
|
791
779
|
[key: string]: unknown;
|
|
@@ -806,11 +794,17 @@ export declare class ChatConversations extends Resource {
|
|
|
806
794
|
next_cursor: string | null;
|
|
807
795
|
has_more: boolean;
|
|
808
796
|
}>;
|
|
809
|
-
listAllMessages(id: Id, query?: Q<'/chat/conversations/{id}/messages', 'get'>, options?: RequestOptions): Paginator<ChatItem, unknown>;
|
|
797
|
+
listAllMessages(id: Id, query?: Q<'/chat/conversations/{id}/messages', 'get'>, options?: RequestOptions): import("./pagination.js").Paginator<ChatItem, unknown>;
|
|
810
798
|
/** Send a message. Gets an automatic Idempotency-Key (the API requires one). May answer `pending_approval`. */
|
|
811
|
-
send(id: Id, body: B<'/chat/conversations/{id}/messages', 'post'>, options?: RequestOptions): Promise<{
|
|
799
|
+
send(id: Id, body: B<'/chat/conversations/{id}/messages', 'post'>, options?: RequestOptions): Promise<({
|
|
800
|
+
message?: {
|
|
801
|
+
[key: string]: unknown;
|
|
802
|
+
};
|
|
803
|
+
ai_paused?: boolean;
|
|
804
|
+
notice?: string;
|
|
805
|
+
} & {
|
|
812
806
|
[key: string]: unknown;
|
|
813
|
-
} | import("./types.js").PendingApproval>;
|
|
807
|
+
}) | import("./types.js").PendingApproval>;
|
|
814
808
|
}
|
|
815
809
|
export declare class ChatContacts extends Resource {
|
|
816
810
|
list(query?: Q<'/chat/contacts', 'get'>, options?: RequestOptions): Promise<{
|
|
@@ -822,7 +816,7 @@ export declare class ChatContacts extends Resource {
|
|
|
822
816
|
} & {
|
|
823
817
|
total?: number | null;
|
|
824
818
|
}>;
|
|
825
|
-
listAll(query?: Q<'/chat/contacts', 'get'>, options?: RequestOptions): Paginator<ChatItem, unknown>;
|
|
819
|
+
listAll(query?: Q<'/chat/contacts', 'get'>, options?: RequestOptions): import("./pagination.js").Paginator<ChatItem, unknown>;
|
|
826
820
|
retrieve(id: Id, options?: RequestOptions): Promise<{
|
|
827
821
|
[key: string]: unknown;
|
|
828
822
|
}>;
|
|
@@ -830,7 +824,7 @@ export declare class ChatContacts extends Resource {
|
|
|
830
824
|
[key: string]: unknown;
|
|
831
825
|
}>;
|
|
832
826
|
}
|
|
833
|
-
export declare class Chat extends
|
|
827
|
+
export declare class Chat extends ChatGenerated {
|
|
834
828
|
readonly conversations: ChatConversations;
|
|
835
829
|
readonly contacts: ChatContacts;
|
|
836
830
|
constructor(core: FinnCore);
|
|
@@ -842,4 +836,3 @@ export declare class Chat extends Resource {
|
|
|
842
836
|
has_more: boolean;
|
|
843
837
|
}>;
|
|
844
838
|
}
|
|
845
|
-
export {};
|
package/dist/cjs/resources.js
CHANGED
|
@@ -1,28 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Chat = exports.ChatContacts = exports.ChatConversations = exports.Agents = exports.Approvals = exports.Cases = exports.Contacts = exports.DoNotCall = exports.Wallet = exports.Deployments = exports.Audiences = exports.PhoneNumbers = exports.Voices = exports.Finns = exports.Calls = void 0;
|
|
3
|
+
exports.Chat = exports.ChatContacts = exports.ChatConversations = exports.Agents = exports.Approvals = exports.Cases = exports.Contacts = exports.DoNotCall = exports.Wallet = exports.Deployments = exports.Audiences = exports.PhoneNumbers = exports.Voices = exports.Finns = exports.Calls = exports.Webhooks = exports.Sales = exports.Organization = exports.Dialer = exports.Crm = void 0;
|
|
4
4
|
const errors_js_1 = require("./errors.js");
|
|
5
5
|
const pagination_js_1 = require("./pagination.js");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
pathParams: params.path,
|
|
15
|
-
query: params.query,
|
|
16
|
-
body: params.body,
|
|
17
|
-
}, options);
|
|
18
|
-
return res.data;
|
|
19
|
-
}
|
|
20
|
-
pager(path, strategy, query, pathParams, options) {
|
|
21
|
-
return new pagination_js_1.Paginator(async (q) => (await this.core.rawRequest({ method: 'get', path, pathParams, query: q }, options)).data, strategy, (query ?? {}));
|
|
22
|
-
}
|
|
23
|
-
}
|
|
6
|
+
const resource_js_1 = require("./resource.js");
|
|
7
|
+
const resources_js_1 = require("./generated/resources.js");
|
|
8
|
+
var resources_js_2 = require("./generated/resources.js");
|
|
9
|
+
Object.defineProperty(exports, "Crm", { enumerable: true, get: function () { return resources_js_2.Crm; } });
|
|
10
|
+
Object.defineProperty(exports, "Dialer", { enumerable: true, get: function () { return resources_js_2.Dialer; } });
|
|
11
|
+
Object.defineProperty(exports, "Organization", { enumerable: true, get: function () { return resources_js_2.Organization; } });
|
|
12
|
+
Object.defineProperty(exports, "Sales", { enumerable: true, get: function () { return resources_js_2.Sales; } });
|
|
13
|
+
Object.defineProperty(exports, "Webhooks", { enumerable: true, get: function () { return resources_js_2.Webhooks; } });
|
|
24
14
|
// ---------------------------------------------------------------- Voice
|
|
25
|
-
class Calls extends
|
|
15
|
+
class Calls extends resources_js_1.CallsGenerated {
|
|
26
16
|
/** Place an outbound call. Gets an automatic Idempotency-Key. May answer `pending_approval` (see isPendingApproval). */
|
|
27
17
|
create(body, options) {
|
|
28
18
|
return this.do('post', '/calls', { body }, options);
|
|
@@ -39,7 +29,7 @@ class Calls extends Resource {
|
|
|
39
29
|
}
|
|
40
30
|
}
|
|
41
31
|
exports.Calls = Calls;
|
|
42
|
-
class Finns extends
|
|
32
|
+
class Finns extends resources_js_1.FinnsGenerated {
|
|
43
33
|
list(query, options) {
|
|
44
34
|
return this.do('get', '/finns', { query }, options);
|
|
45
35
|
}
|
|
@@ -70,7 +60,7 @@ class Finns extends Resource {
|
|
|
70
60
|
}
|
|
71
61
|
}
|
|
72
62
|
exports.Finns = Finns;
|
|
73
|
-
class Voices extends
|
|
63
|
+
class Voices extends resources_js_1.VoicesGenerated {
|
|
74
64
|
list(query, options) {
|
|
75
65
|
return this.do('get', '/voices', { query }, options);
|
|
76
66
|
}
|
|
@@ -82,7 +72,7 @@ class Voices extends Resource {
|
|
|
82
72
|
}
|
|
83
73
|
}
|
|
84
74
|
exports.Voices = Voices;
|
|
85
|
-
class PhoneNumbers extends
|
|
75
|
+
class PhoneNumbers extends resources_js_1.PhoneNumbersGenerated {
|
|
86
76
|
list(query, options) {
|
|
87
77
|
return this.do('get', '/phone_numbers', { query }, options);
|
|
88
78
|
}
|
|
@@ -104,7 +94,7 @@ class PhoneNumbers extends Resource {
|
|
|
104
94
|
}
|
|
105
95
|
}
|
|
106
96
|
exports.PhoneNumbers = PhoneNumbers;
|
|
107
|
-
class Audiences extends
|
|
97
|
+
class Audiences extends resources_js_1.AudiencesGenerated {
|
|
108
98
|
list(query, options) {
|
|
109
99
|
return this.do('get', '/audiences', { query }, options);
|
|
110
100
|
}
|
|
@@ -134,7 +124,7 @@ class Audiences extends Resource {
|
|
|
134
124
|
}
|
|
135
125
|
}
|
|
136
126
|
exports.Audiences = Audiences;
|
|
137
|
-
class Deployments extends
|
|
127
|
+
class Deployments extends resources_js_1.DeploymentsGenerated {
|
|
138
128
|
list(query, options) {
|
|
139
129
|
return this.do('get', '/deployments', { query }, options);
|
|
140
130
|
}
|
|
@@ -163,7 +153,7 @@ class Deployments extends Resource {
|
|
|
163
153
|
}
|
|
164
154
|
}
|
|
165
155
|
exports.Deployments = Deployments;
|
|
166
|
-
class Wallet extends
|
|
156
|
+
class Wallet extends resources_js_1.WalletGenerated {
|
|
167
157
|
retrieve(options) {
|
|
168
158
|
return this.do('get', '/wallet', {}, options);
|
|
169
159
|
}
|
|
@@ -175,7 +165,7 @@ class Wallet extends Resource {
|
|
|
175
165
|
}
|
|
176
166
|
}
|
|
177
167
|
exports.Wallet = Wallet;
|
|
178
|
-
class DoNotCall extends
|
|
168
|
+
class DoNotCall extends resources_js_1.DoNotCallGenerated {
|
|
179
169
|
list(query, options) {
|
|
180
170
|
return this.do('get', '/do_not_call', { query }, options);
|
|
181
171
|
}
|
|
@@ -192,7 +182,7 @@ class DoNotCall extends Resource {
|
|
|
192
182
|
}
|
|
193
183
|
exports.DoNotCall = DoNotCall;
|
|
194
184
|
// ---------------------------------------------------------------- CRM
|
|
195
|
-
class Contacts extends
|
|
185
|
+
class Contacts extends resources_js_1.ContactsGenerated {
|
|
196
186
|
list(query, options) {
|
|
197
187
|
return this.do('get', '/contacts', { query }, options);
|
|
198
188
|
}
|
|
@@ -227,7 +217,7 @@ class Contacts extends Resource {
|
|
|
227
217
|
}
|
|
228
218
|
exports.Contacts = Contacts;
|
|
229
219
|
// ---------------------------------------------------------------- Operator
|
|
230
|
-
class Cases extends
|
|
220
|
+
class Cases extends resources_js_1.CasesGenerated {
|
|
231
221
|
list(query, options) {
|
|
232
222
|
return this.do('get', '/cases', { query }, options);
|
|
233
223
|
}
|
|
@@ -248,7 +238,7 @@ class Cases extends Resource {
|
|
|
248
238
|
exports.Cases = Cases;
|
|
249
239
|
/** Statuses that are still waiting: holds (`pending`, `running`) and Operator approvals (`open`). */
|
|
250
240
|
const WAITING_STATUSES = new Set(['pending', 'running', 'open', 'pending_approval']);
|
|
251
|
-
class Approvals extends
|
|
241
|
+
class Approvals extends resources_js_1.ApprovalsGenerated {
|
|
252
242
|
list(query, options) {
|
|
253
243
|
return this.do('get', '/approvals', { query }, options);
|
|
254
244
|
}
|
|
@@ -305,7 +295,7 @@ function defaultPollSleep(ms, signal) {
|
|
|
305
295
|
signal?.addEventListener('abort', () => (clearTimeout(t), reject(signal.reason)), { once: true });
|
|
306
296
|
});
|
|
307
297
|
}
|
|
308
|
-
class Agents extends
|
|
298
|
+
class Agents extends resources_js_1.AgentsGenerated {
|
|
309
299
|
list(query, options) {
|
|
310
300
|
return this.do('get', '/agents', { query }, options);
|
|
311
301
|
}
|
|
@@ -341,7 +331,7 @@ class Agents extends Resource {
|
|
|
341
331
|
}
|
|
342
332
|
}
|
|
343
333
|
exports.Agents = Agents;
|
|
344
|
-
class ChatConversations extends Resource {
|
|
334
|
+
class ChatConversations extends resource_js_1.Resource {
|
|
345
335
|
list(query, options) {
|
|
346
336
|
return this.do('get', '/chat/conversations', { query }, options);
|
|
347
337
|
}
|
|
@@ -367,7 +357,7 @@ class ChatConversations extends Resource {
|
|
|
367
357
|
}
|
|
368
358
|
}
|
|
369
359
|
exports.ChatConversations = ChatConversations;
|
|
370
|
-
class ChatContacts extends Resource {
|
|
360
|
+
class ChatContacts extends resource_js_1.Resource {
|
|
371
361
|
list(query, options) {
|
|
372
362
|
return this.do('get', '/chat/contacts', { query }, options);
|
|
373
363
|
}
|
|
@@ -382,7 +372,7 @@ class ChatContacts extends Resource {
|
|
|
382
372
|
}
|
|
383
373
|
}
|
|
384
374
|
exports.ChatContacts = ChatContacts;
|
|
385
|
-
class Chat extends
|
|
375
|
+
class Chat extends resources_js_1.ChatGenerated {
|
|
386
376
|
constructor(core) {
|
|
387
377
|
super(core);
|
|
388
378
|
this.conversations = new ChatConversations(core);
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* body and success response, so `finn.request('get', '/calls/{call_uuid}', ...)` is checked end to end.
|
|
4
4
|
*/
|
|
5
5
|
import type { components, operations, paths } from './generated/openapi.js';
|
|
6
|
+
import type { SpecHoldableRoute } from './generated/operations.js';
|
|
6
7
|
export type { components, operations, paths };
|
|
7
8
|
/** Every schema in the spec, e.g. `Schemas['Call']`. */
|
|
8
9
|
export type Schemas = components['schemas'];
|
|
@@ -142,7 +143,14 @@ export interface FinnResponse<T> {
|
|
|
142
143
|
/** True when the API replayed a saved answer for the same Idempotency-Key. */
|
|
143
144
|
idempotentReplayed: boolean;
|
|
144
145
|
}
|
|
145
|
-
/**
|
|
146
|
-
|
|
146
|
+
/**
|
|
147
|
+
* Routes whose writes the API may hold for approval (HTTP 202 `pending_approval`): the ones listed here plus the
|
|
148
|
+
* ones the spec marks (`x-finn-hold`, or a 202 answer that says `pending_approval`).
|
|
149
|
+
*/
|
|
150
|
+
export type HoldableRoute = 'post /calls' | 'post /deployments' | 'post /phone_numbers' | 'post /agents/{id}/cases' | 'post /chat/conversations' | 'post /chat/conversations/{id}/messages' | SpecHoldableRoute;
|
|
151
|
+
/** The spec's own PendingApproval schema, replaced by the SDK's `PendingApproval` in results. */
|
|
152
|
+
type SpecPendingApproval = components['schemas'] extends {
|
|
153
|
+
PendingApproval: infer X;
|
|
154
|
+
} ? X : never;
|
|
147
155
|
/** What `request()` resolves to: the spec's success body, or PendingApproval on holdable routes. */
|
|
148
|
-
export type ResultOf<P extends string, M extends HttpMethod, O> = `${M} ${P}` extends HoldableRoute ? ResponseOf<O> | PendingApproval : ResponseOf<O>;
|
|
156
|
+
export type ResultOf<P extends string, M extends HttpMethod, O> = `${M} ${P}` extends HoldableRoute ? Exclude<ResponseOf<O>, SpecPendingApproval> | PendingApproval : ResponseOf<O>;
|
package/dist/esm/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FinnCore, type FinnOptions } from './core.js';
|
|
2
|
-
import { Agents, Approvals, Audiences, Calls, Cases, Chat, Contacts, Deployments, DoNotCall, Finns, PhoneNumbers, Voices, Wallet, type WaitForApprovalOptions } from './resources.js';
|
|
2
|
+
import { Agents, Approvals, Audiences, Calls, Cases, Chat, Contacts, Crm, Deployments, Dialer, DoNotCall, Finns, Organization, PhoneNumbers, Sales, Voices, Wallet, Webhooks, type WaitForApprovalOptions } from './resources.js';
|
|
3
3
|
import type { ApprovalHold, Schemas } from './types.js';
|
|
4
4
|
/**
|
|
5
5
|
* The Finn API client.
|
|
@@ -24,6 +24,18 @@ export declare class Finn extends FinnCore {
|
|
|
24
24
|
readonly approvals: Approvals;
|
|
25
25
|
readonly agents: Agents;
|
|
26
26
|
readonly chat: Chat;
|
|
27
|
+
/** CRM: records, stages, forms, documents, follow-ups, views and imports (`/crm`). */
|
|
28
|
+
readonly crm: Crm;
|
|
29
|
+
readonly dialer: Dialer;
|
|
30
|
+
/** Webhook endpoints, deliveries and event types. */
|
|
31
|
+
readonly webhooks: Webhooks;
|
|
32
|
+
/** The organization, its members, integrations and API keys. */
|
|
33
|
+
readonly organization: Organization;
|
|
34
|
+
/**
|
|
35
|
+
* Sales plays, prospects, drafts and threads.
|
|
36
|
+
* @experimental The Sales API is switched off for every organization; calls answer an error until it is on for yours.
|
|
37
|
+
*/
|
|
38
|
+
readonly sales: Sales;
|
|
27
39
|
constructor(options?: FinnOptions);
|
|
28
40
|
/** Polls an approval until it is decided (see approvals.wait). */
|
|
29
41
|
waitForApproval(id: string, options?: WaitForApprovalOptions): Promise<ApprovalHold | Schemas['Approval']>;
|
package/dist/esm/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FinnCore } from './core.js';
|
|
2
|
-
import { Agents, Approvals, Audiences, Calls, Cases, Chat, Contacts, Deployments, DoNotCall, Finns, PhoneNumbers, Voices, Wallet, } from './resources.js';
|
|
2
|
+
import { Agents, Approvals, Audiences, Calls, Cases, Chat, Contacts, Crm, Deployments, Dialer, DoNotCall, Finns, Organization, PhoneNumbers, Sales, Voices, Wallet, Webhooks, } from './resources.js';
|
|
3
3
|
/**
|
|
4
4
|
* The Finn API client.
|
|
5
5
|
*
|
|
@@ -23,6 +23,11 @@ export class Finn extends FinnCore {
|
|
|
23
23
|
this.approvals = new Approvals(this);
|
|
24
24
|
this.agents = new Agents(this);
|
|
25
25
|
this.chat = new Chat(this);
|
|
26
|
+
this.crm = new Crm(this);
|
|
27
|
+
this.dialer = new Dialer(this);
|
|
28
|
+
this.webhooks = new Webhooks(this);
|
|
29
|
+
this.organization = new Organization(this);
|
|
30
|
+
this.sales = new Sales(this);
|
|
26
31
|
}
|
|
27
32
|
/** Polls an approval until it is decided (see approvals.wait). */
|
|
28
33
|
waitForApproval(id, options) {
|
package/dist/esm/core.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FinnResponse, HttpMethod, Operation, PathsFor, RequestArgs, RequestOptions, ResultOf } from './types.js';
|
|
2
2
|
export declare const DEFAULT_BASE_URL = "https://api.hirefinn.ai/v1";
|
|
3
|
-
export declare const SDK_VERSION = "0.
|
|
3
|
+
export declare const SDK_VERSION = "0.3.0";
|
|
4
4
|
export interface FinnOptions {
|
|
5
5
|
/** `finn_live_...` org key, `finn_test_...` test key, or an OAuth `finn_oat_...` token. Defaults to env FINN_API_KEY. */
|
|
6
6
|
apiKey?: string;
|
package/dist/esm/core.js
CHANGED
|
@@ -12,7 +12,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
12
12
|
var _FinnCore_apiKey, _FinnCore_fetch, _FinnCore_defaultHeaders, _FinnCore_sleep;
|
|
13
13
|
import { FinnConnectionError, FinnError, FinnSdkError, FinnTimeoutError } from './errors.js';
|
|
14
14
|
export const DEFAULT_BASE_URL = 'https://api.hirefinn.ai/v1';
|
|
15
|
-
export const SDK_VERSION = '0.
|
|
15
|
+
export const SDK_VERSION = '0.3.0';
|
|
16
16
|
/** Writes that get an automatic Idempotency-Key (when autoIdempotency is on). */
|
|
17
17
|
export const AUTO_IDEMPOTENCY_ROUTES = new Set([
|
|
18
18
|
'post /calls',
|
|
@@ -23,6 +23,7 @@ export const AUTO_IDEMPOTENCY_ROUTES = new Set([
|
|
|
23
23
|
'post /chat/conversations/{id}/messages',
|
|
24
24
|
'post /agents',
|
|
25
25
|
'post /agents/{id}/cases',
|
|
26
|
+
'post /webhook_endpoints',
|
|
26
27
|
]);
|
|
27
28
|
/**
|
|
28
29
|
* POST/PATCH routes where the API dedupes by Idempotency-Key (a retry with the same key and body replays the first
|
|
@@ -42,6 +43,7 @@ export const IDEMPOTENT_WRITE_ROUTES = [
|
|
|
42
43
|
'patch /crm/*',
|
|
43
44
|
'post /sales/plays/{slug}/run',
|
|
44
45
|
'post /sales/drafts/{id}/skip',
|
|
46
|
+
'post /webhook_endpoints',
|
|
45
47
|
];
|
|
46
48
|
const IDEMPOTENT_WRITE_MATCHERS = IDEMPOTENT_WRITE_ROUTES.map((route) => {
|
|
47
49
|
const [method, path] = route.split(' ');
|