@hirefinn/sdk 0.2.0 → 0.4.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.
Files changed (44) hide show
  1. package/README.md +63 -13
  2. package/dist/cjs/client.d.ts +13 -1
  3. package/dist/cjs/client.js +5 -0
  4. package/dist/cjs/core.d.ts +16 -3
  5. package/dist/cjs/core.js +25 -6
  6. package/dist/cjs/errors.d.ts +1 -1
  7. package/dist/cjs/errors.js +11 -0
  8. package/dist/cjs/generated/openapi.d.ts +19867 -5738
  9. package/dist/cjs/generated/operations.d.ts +26 -0
  10. package/dist/cjs/generated/operations.js +176 -0
  11. package/dist/cjs/generated/resources.d.ts +1050 -0
  12. package/dist/cjs/generated/resources.js +816 -0
  13. package/dist/cjs/index.d.ts +2 -2
  14. package/dist/cjs/index.js +4 -1
  15. package/dist/cjs/pagination.d.ts +3 -0
  16. package/dist/cjs/pagination.js +26 -5
  17. package/dist/cjs/resource.d.ts +30 -0
  18. package/dist/cjs/resource.js +23 -0
  19. package/dist/cjs/resources.d.ts +64 -57
  20. package/dist/cjs/resources.js +31 -36
  21. package/dist/cjs/types.d.ts +11 -3
  22. package/dist/cjs/webhooks.d.ts +11 -1
  23. package/dist/esm/client.d.ts +13 -1
  24. package/dist/esm/client.js +6 -1
  25. package/dist/esm/core.d.ts +16 -3
  26. package/dist/esm/core.js +24 -5
  27. package/dist/esm/errors.d.ts +1 -1
  28. package/dist/esm/errors.js +11 -0
  29. package/dist/esm/generated/openapi.d.ts +19867 -5738
  30. package/dist/esm/generated/operations.d.ts +26 -0
  31. package/dist/esm/generated/operations.js +173 -0
  32. package/dist/esm/generated/resources.d.ts +1050 -0
  33. package/dist/esm/generated/resources.js +795 -0
  34. package/dist/esm/index.d.ts +2 -2
  35. package/dist/esm/index.js +2 -2
  36. package/dist/esm/pagination.d.ts +3 -0
  37. package/dist/esm/pagination.js +25 -5
  38. package/dist/esm/resource.d.ts +30 -0
  39. package/dist/esm/resource.js +19 -0
  40. package/dist/esm/resources.d.ts +64 -57
  41. package/dist/esm/resources.js +24 -34
  42. package/dist/esm/types.d.ts +11 -3
  43. package/dist/esm/webhooks.d.ts +11 -1
  44. package/package.json +2 -1
@@ -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';
@@ -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 {};
@@ -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
- const count = __classPrivateFieldGet(this, _Paginator_strategy, "f").items(res).length;
40
- query = count === 0 ? null : __classPrivateFieldGet(this, _Paginator_strategy, "f").next(res, query, count);
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
+ }
@@ -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,19 @@
1
+ import { Paginator } from './pagination.js';
2
+ export class Resource {
3
+ constructor(core) {
4
+ this.core = core;
5
+ }
6
+ async do(method, path, params = {}, options) {
7
+ const res = await this.core.rawRequest({
8
+ method,
9
+ path,
10
+ pathParams: params.path,
11
+ query: params.query,
12
+ body: params.body,
13
+ }, options);
14
+ return res.data;
15
+ }
16
+ pager(path, strategy, query, pathParams, options) {
17
+ return new Paginator(async (q) => (await this.core.rawRequest({ method: 'get', path, pathParams, query: q }, options)).data, strategy, (query ?? {}));
18
+ }
19
+ }
@@ -1,27 +1,15 @@
1
1
  /**
2
- * Resource classes: one typed method per operation in the spec, grouped the way the API reference groups them.
3
- * Every method takes an optional last `options` argument (RequestOptions): idempotencyKey, org, version,
4
- * maxRetries, timeoutMs, signal, headers.
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 { Paginator, cursorStrategy } from './pagination.js';
8
- import type { ApprovalHold, BodyOf, HttpMethod, Operation, PathsFor, QueryOf, RequestOptions, ResultOf, Schemas, paths } from './types.js';
9
- type Q<P extends keyof paths, M extends HttpMethod> = QueryOf<Operation<P, M>>;
10
- type B<P extends keyof paths, M extends HttpMethod> = BodyOf<Operation<P, M>>;
11
- type R<P extends keyof paths, M extends HttpMethod> = ResultOf<P & string, M, Operation<P, M>>;
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 Resource {
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 Resource {
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 Resource {
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 Resource {
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 Resource {
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;
@@ -269,7 +257,7 @@ export declare class Deployments extends Resource {
269
257
  createInbound(body: B<'/deployments/inbound', 'post'>, options?: RequestOptions): Promise<{
270
258
  success: true;
271
259
  data: import("./types.js").components["schemas"]["Deployment"];
272
- }>;
260
+ } | import("./types.js").PendingApproval>;
273
261
  retrieve(id: Id, options?: RequestOptions): Promise<{
274
262
  success: true;
275
263
  data: import("./types.js").components["schemas"]["Deployment"];
@@ -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 Resource {
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 Resource {
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 Resource {
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 Resource {
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;
@@ -487,10 +475,24 @@ export declare class Cases extends Resource {
487
475
  } & {
488
476
  [key: string]: unknown;
489
477
  }>;
490
- listEvents(id: Id, options?: RequestOptions): Promise<{
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<{
491
480
  events: import("./types.js").components["schemas"]["CaseEvent"][];
492
481
  next_after: number;
493
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>;
494
496
  /** Start a case on an agent. Gets an automatic Idempotency-Key. May answer `pending_approval` (see isPendingApproval). */
495
497
  start(agentId: Id, body?: B<'/agents/{id}/cases', 'post'>, options?: RequestOptions): Promise<{
496
498
  case_id: string;
@@ -510,12 +512,12 @@ export interface WaitForApprovalOptions {
510
512
  /** Replaces the wait between polls (for tests). */
511
513
  sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
512
514
  }
513
- export declare class Approvals extends Resource {
515
+ export declare class Approvals extends ApprovalsGenerated {
514
516
  list(query?: Q<'/approvals', 'get'>, options?: RequestOptions): Promise<{
515
- approvals: import("./types.js").components["schemas"]["Approval"][];
517
+ approvals: (import("./types.js").components["schemas"]["Approval"] | import("./types.js").components["schemas"]["ApiHold"])[];
516
518
  next_cursor: string | null;
517
519
  }>;
518
- listAll(query?: Q<'/approvals', 'get'>, options?: RequestOptions): Paginator<{
520
+ listAll(query?: Q<'/approvals', 'get'>, options?: RequestOptions): import("./pagination.js").Paginator<{
519
521
  id: string;
520
522
  case_id: string;
521
523
  case_title?: string | null;
@@ -648,13 +650,13 @@ export declare class Approvals extends Resource {
648
650
  */
649
651
  wait(id: Id, opts?: WaitForApprovalOptions): Promise<ApprovalHold | Schemas['Approval']>;
650
652
  }
651
- export declare class Agents extends Resource {
653
+ export declare class Agents extends AgentsGenerated {
652
654
  list(query?: Q<'/agents', 'get'>, options?: RequestOptions): Promise<{
653
655
  data: import("./types.js").components["schemas"]["AgentSummary"][];
654
656
  next_cursor: string | null;
655
657
  has_more: boolean;
656
658
  }>;
657
- listAll(query?: Q<'/agents', 'get'>, options?: RequestOptions): Paginator<{
659
+ listAll(query?: Q<'/agents', 'get'>, options?: RequestOptions): import("./pagination.js").Paginator<{
658
660
  id: string;
659
661
  name: string;
660
662
  status: "draft" | "live" | "paused" | "archived";
@@ -785,7 +787,7 @@ export declare class ChatConversations extends Resource {
785
787
  next_cursor: string | null;
786
788
  has_more: boolean;
787
789
  }>;
788
- listAll(query?: Q<'/chat/conversations', 'get'>, options?: RequestOptions): Paginator<ChatItem, unknown>;
790
+ listAll(query?: Q<'/chat/conversations', 'get'>, options?: RequestOptions): import("./pagination.js").Paginator<ChatItem, unknown>;
789
791
  /** Start a conversation (sends the first message). Gets an automatic Idempotency-Key (the API requires one). May answer `pending_approval`. */
790
792
  start(body: B<'/chat/conversations', 'post'>, options?: RequestOptions): Promise<{
791
793
  [key: string]: unknown;
@@ -806,11 +808,17 @@ export declare class ChatConversations extends Resource {
806
808
  next_cursor: string | null;
807
809
  has_more: boolean;
808
810
  }>;
809
- listAllMessages(id: Id, query?: Q<'/chat/conversations/{id}/messages', 'get'>, options?: RequestOptions): Paginator<ChatItem, unknown>;
811
+ listAllMessages(id: Id, query?: Q<'/chat/conversations/{id}/messages', 'get'>, options?: RequestOptions): import("./pagination.js").Paginator<ChatItem, unknown>;
810
812
  /** 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<{
813
+ send(id: Id, body: B<'/chat/conversations/{id}/messages', 'post'>, options?: RequestOptions): Promise<({
814
+ message?: {
815
+ [key: string]: unknown;
816
+ };
817
+ ai_paused?: boolean;
818
+ notice?: string;
819
+ } & {
812
820
  [key: string]: unknown;
813
- } | import("./types.js").PendingApproval>;
821
+ }) | import("./types.js").PendingApproval>;
814
822
  }
815
823
  export declare class ChatContacts extends Resource {
816
824
  list(query?: Q<'/chat/contacts', 'get'>, options?: RequestOptions): Promise<{
@@ -822,15 +830,15 @@ export declare class ChatContacts extends Resource {
822
830
  } & {
823
831
  total?: number | null;
824
832
  }>;
825
- listAll(query?: Q<'/chat/contacts', 'get'>, options?: RequestOptions): Paginator<ChatItem, unknown>;
833
+ listAll(query?: Q<'/chat/contacts', 'get'>, options?: RequestOptions): import("./pagination.js").Paginator<ChatItem, unknown>;
826
834
  retrieve(id: Id, options?: RequestOptions): Promise<{
827
835
  [key: string]: unknown;
828
836
  }>;
829
837
  update(id: Id, body: B<'/chat/contacts/{id}', 'patch'>, options?: RequestOptions): Promise<{
830
838
  [key: string]: unknown;
831
- }>;
839
+ } | import("./types.js").PendingApproval>;
832
840
  }
833
- export declare class Chat extends Resource {
841
+ export declare class Chat extends ChatGenerated {
834
842
  readonly conversations: ChatConversations;
835
843
  readonly contacts: ChatContacts;
836
844
  constructor(core: FinnCore);
@@ -842,4 +850,3 @@ export declare class Chat extends Resource {
842
850
  has_more: boolean;
843
851
  }>;
844
852
  }
845
- export {};