@hirefinn/sdk 0.5.1 → 0.5.2
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 +22 -11
- package/dist/cjs/client.d.ts +16 -6
- package/dist/cjs/client.js +9 -6
- package/dist/cjs/core.d.ts +18 -6
- package/dist/cjs/core.js +23 -7
- package/dist/cjs/errors.d.ts +40 -2
- package/dist/cjs/errors.js +44 -1
- package/dist/cjs/generated/openapi.d.ts +6259 -6222
- package/dist/cjs/generated/operations.d.ts +1 -1
- package/dist/cjs/generated/operations.js +23 -23
- package/dist/cjs/generated/resources.d.ts +47 -47
- package/dist/cjs/generated/resources.js +48 -48
- package/dist/cjs/index.d.ts +7 -7
- package/dist/cjs/index.js +13 -1
- package/dist/cjs/resources.d.ts +25 -17
- package/dist/cjs/resources.js +23 -18
- package/dist/cjs/types.d.ts +2 -2
- package/dist/cjs/webhooks.d.ts +20 -2
- package/dist/cjs/webhooks.js +3 -1
- package/dist/esm/client.d.ts +16 -6
- package/dist/esm/client.js +9 -6
- package/dist/esm/core.d.ts +18 -6
- package/dist/esm/core.js +22 -6
- package/dist/esm/errors.d.ts +40 -2
- package/dist/esm/errors.js +41 -0
- package/dist/esm/generated/openapi.d.ts +6259 -6222
- package/dist/esm/generated/operations.d.ts +1 -1
- package/dist/esm/generated/operations.js +23 -23
- package/dist/esm/generated/resources.d.ts +47 -47
- package/dist/esm/generated/resources.js +46 -46
- package/dist/esm/index.d.ts +7 -7
- package/dist/esm/index.js +4 -4
- package/dist/esm/resources.d.ts +25 -17
- package/dist/esm/resources.js +22 -17
- package/dist/esm/types.d.ts +2 -2
- package/dist/esm/webhooks.d.ts +20 -2
- package/dist/esm/webhooks.js +2 -0
- package/package.json +1 -1
package/dist/esm/resources.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FinnApprovalTimeoutError } from './errors.js';
|
|
2
2
|
import { afterStrategy, beforeStrategy, cursorStrategy, offsetStrategy, pageStrategy } from './pagination.js';
|
|
3
3
|
import { Resource } from './resource.js';
|
|
4
|
-
import { AgentsGenerated, ApprovalsGenerated, AudiencesGenerated, CallsGenerated, CasesGenerated, ChatGenerated, ContactsGenerated, DeploymentsGenerated, DoNotCallGenerated,
|
|
4
|
+
import { AgentsGenerated, ApprovalsGenerated, AssistantsGenerated, AudiencesGenerated, CallsGenerated, CasesGenerated, ChatGenerated, ContactsGenerated, DeploymentsGenerated, DoNotCallGenerated, PhoneNumbersGenerated, VoicesGenerated, WalletGenerated, } from './generated/resources.js';
|
|
5
5
|
export { Crm, Dialer, Organization, Sales, Webhooks } from './generated/resources.js';
|
|
6
6
|
// ---------------------------------------------------------------- Voice
|
|
7
7
|
export class Calls extends CallsGenerated {
|
|
@@ -20,36 +20,41 @@ export class Calls extends CallsGenerated {
|
|
|
20
20
|
return this.do('get', '/calls/{call_uuid}', { path: { call_uuid: callUuid } }, options);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
/** Assistants (voice agents): `/assistants`. Reached as `client.assistants` (and, deprecated, `client.finns`). */
|
|
24
|
+
export class Assistants extends AssistantsGenerated {
|
|
24
25
|
list(query, options) {
|
|
25
|
-
return this.do('get', '/
|
|
26
|
+
return this.do('get', '/assistants', { query }, options);
|
|
26
27
|
}
|
|
27
28
|
listAll(query, options) {
|
|
28
|
-
return this.pager('/
|
|
29
|
+
return this.pager('/assistants', offsetStrategy(), query, undefined, options);
|
|
29
30
|
}
|
|
30
31
|
create(body, options) {
|
|
31
|
-
return this.do('post', '/
|
|
32
|
+
return this.do('post', '/assistants', { body }, options);
|
|
32
33
|
}
|
|
33
|
-
retrieve(
|
|
34
|
-
return this.do('get', '/
|
|
34
|
+
retrieve(assistantId, options) {
|
|
35
|
+
return this.do('get', '/assistants/{assistant_id}', { path: { assistant_id: assistantId } }, options);
|
|
35
36
|
}
|
|
36
|
-
update(
|
|
37
|
-
return this.do('patch', '/
|
|
37
|
+
update(assistantId, body, options) {
|
|
38
|
+
return this.do('patch', '/assistants/{assistant_id}', { path: { assistant_id: assistantId }, body }, options);
|
|
38
39
|
}
|
|
39
|
-
delete(
|
|
40
|
-
return this.do('delete', '/
|
|
40
|
+
delete(assistantId, options) {
|
|
41
|
+
return this.do('delete', '/assistants/{assistant_id}', { path: { assistant_id: assistantId } }, options);
|
|
41
42
|
}
|
|
42
|
-
listKnowledgeBase(
|
|
43
|
-
return this.do('get', '/
|
|
43
|
+
listKnowledgeBase(assistantId, options) {
|
|
44
|
+
return this.do('get', '/assistants/{assistant_id}/knowledge_base', { path: { assistant_id: assistantId } }, options);
|
|
44
45
|
}
|
|
45
46
|
/** JSON body, or a FormData with the file for multipart upload. */
|
|
46
|
-
addKnowledgeBaseDocument(
|
|
47
|
-
return this.do('post', '/
|
|
47
|
+
addKnowledgeBaseDocument(assistantId, body, options) {
|
|
48
|
+
return this.do('post', '/assistants/{assistant_id}/knowledge_base', { path: { assistant_id: assistantId }, body }, options);
|
|
48
49
|
}
|
|
49
|
-
postCallAnalysis(
|
|
50
|
-
return this.do('get', '/
|
|
50
|
+
postCallAnalysis(assistantId, query, options) {
|
|
51
|
+
return this.do('get', '/assistants/{assistant_id}/post_call_analysis', { path: { assistant_id: assistantId }, query }, options);
|
|
51
52
|
}
|
|
52
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* @deprecated Renamed to {@link Assistants}; `Finns` is the same class and will be removed in a future major version.
|
|
56
|
+
*/
|
|
57
|
+
export const Finns = Assistants;
|
|
53
58
|
export class Voices extends VoicesGenerated {
|
|
54
59
|
list(query, options) {
|
|
55
60
|
return this.do('get', '/voices', { query }, options);
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -81,9 +81,9 @@ export interface RequestOptions {
|
|
|
81
81
|
* Pass `false` to send none, even on an endpoint where the SDK would make one up.
|
|
82
82
|
*/
|
|
83
83
|
idempotencyKey?: string | false;
|
|
84
|
-
/** Org to act in (
|
|
84
|
+
/** Org to act in (X-Org-Id header, formerly Finn-Org), for tokens that can use more than one org. */
|
|
85
85
|
org?: string;
|
|
86
|
-
/** API version date (
|
|
86
|
+
/** API version date (Api-Version header, formerly Finn-Version), e.g. `2026-11-01`. */
|
|
87
87
|
version?: string;
|
|
88
88
|
/** Retries after the first attempt. */
|
|
89
89
|
maxRetries?: number;
|
package/dist/esm/webhooks.d.ts
CHANGED
|
@@ -39,7 +39,22 @@ export declare const DEFAULT_WEBHOOK_TOLERANCE_SECONDS = 300;
|
|
|
39
39
|
* The body of a webhook delivery (the Finn envelope). Endpoints imported from Finn Chat with the `chat` envelope get
|
|
40
40
|
* Finn Chat's own body instead: `{ id, event, createdAt, orgId, data }`.
|
|
41
41
|
*/
|
|
42
|
-
|
|
42
|
+
/**
|
|
43
|
+
* The fields a call webhook's `data` uses to name the agent (`call.completed`, `call.analyzed`, transcript events).
|
|
44
|
+
* `agent_id` / `agent_name` are the current names; servers before the rename send only `finn_id` / `finn_name`, and
|
|
45
|
+
* newer servers send both with the same values until the old names retire. Read `agent_id ?? finn_id`.
|
|
46
|
+
*/
|
|
47
|
+
export interface WebhookAgentFields {
|
|
48
|
+
/** The agent (assistant) that handled the call. */
|
|
49
|
+
agent_id?: string | null;
|
|
50
|
+
/** The agent's name, where the event carries one. */
|
|
51
|
+
agent_name?: string | null;
|
|
52
|
+
/** @deprecated Old name of `agent_id`, same value. */
|
|
53
|
+
finn_id?: string | null;
|
|
54
|
+
/** @deprecated Old name of `agent_name`, same value. */
|
|
55
|
+
finn_name?: string | null;
|
|
56
|
+
}
|
|
57
|
+
export interface WebhookEvent<T = Record<string, unknown> & WebhookAgentFields> {
|
|
43
58
|
/** e.g. `call.completed`, `contact.created`, `case.completed`. */
|
|
44
59
|
event: string;
|
|
45
60
|
/** Unique per event, and the same on every retry or redelivery of it: dedupe on it. */
|
|
@@ -56,6 +71,9 @@ export interface WebhookEvent<T = Record<string, unknown>> {
|
|
|
56
71
|
export declare class FinnWebhookVerificationError extends FinnSdkError {
|
|
57
72
|
constructor(message: string);
|
|
58
73
|
}
|
|
74
|
+
/** The neutral name of {@link FinnWebhookVerificationError}: the same class, so `instanceof` works with either name. */
|
|
75
|
+
export declare const WebhookVerificationError: typeof FinnWebhookVerificationError;
|
|
76
|
+
export type WebhookVerificationError = FinnWebhookVerificationError;
|
|
59
77
|
export interface VerifyWebhookOptions {
|
|
60
78
|
/** The raw request body, exactly as received (not re-serialised JSON). */
|
|
61
79
|
payload: string | Uint8Array;
|
|
@@ -94,4 +112,4 @@ export declare function signWebhookPayload(secret: string, timestamp: number | s
|
|
|
94
112
|
* ...
|
|
95
113
|
* });
|
|
96
114
|
*/
|
|
97
|
-
export declare function verifyWebhook<T = Record<string, unknown
|
|
115
|
+
export declare function verifyWebhook<T = Record<string, unknown> & WebhookAgentFields>(options: VerifyWebhookOptions): Promise<WebhookEvent<T>>;
|
package/dist/esm/webhooks.js
CHANGED
|
@@ -41,6 +41,8 @@ export class FinnWebhookVerificationError extends FinnSdkError {
|
|
|
41
41
|
this.name = 'FinnWebhookVerificationError';
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
+
/** The neutral name of {@link FinnWebhookVerificationError}: the same class, so `instanceof` works with either name. */
|
|
45
|
+
export const WebhookVerificationError = FinnWebhookVerificationError;
|
|
44
46
|
/** Splits `t=...,v1=...` into its timestamp and v1 signatures. */
|
|
45
47
|
export function parseSignatureHeader(header) {
|
|
46
48
|
let timestamp = NaN;
|