@roarkanalytics/sdk 0.328.0 → 0.330.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.
@@ -1,5 +1,42 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
  import { APIResource } from "../resource.mjs";
3
3
  export class Integrations extends APIResource {
4
+ /**
5
+ * Process and upload a Retell call to Roark evaluation
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * const response = await client.integrations.createRetellCall(
10
+ * { retellCallEndedPayload: { event: 'bar', call: 'bar' } },
11
+ * );
12
+ * ```
13
+ */
14
+ createRetellCall(body, options) {
15
+ return this._client.post('/v1/retell/call', { body, ...options });
16
+ }
17
+ /**
18
+ * Process and upload a VAPI call to Roark evaluation
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * const response = await client.integrations.createVapiCall({
23
+ * vapiEndOfCallReportPayload: {
24
+ * call: 'bar',
25
+ * type: 'bar',
26
+ * status: 'bar',
27
+ * assistant: 'bar',
28
+ * customer: 'bar',
29
+ * phoneNumber: 'bar',
30
+ * artifact: 'bar',
31
+ * startedAt: 'bar',
32
+ * endedAt: 'bar',
33
+ * endedReason: 'bar',
34
+ * },
35
+ * });
36
+ * ```
37
+ */
38
+ createVapiCall(body, options) {
39
+ return this._client.post('/v1/vapi/call', { body, ...options });
40
+ }
4
41
  }
5
42
  //# sourceMappingURL=integrations.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"integrations.mjs","sourceRoot":"","sources":["../src/resources/integrations.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;AAEtB,MAAM,OAAO,YAAa,SAAQ,WAAW;CAAG"}
1
+ {"version":3,"file":"integrations.mjs","sourceRoot":"","sources":["../src/resources/integrations.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;AAGtB,MAAM,OAAO,YAAa,SAAQ,WAAW;IAC3C;;;;;;;;;OASG;IACH,gBAAgB,CACd,IAAuC,EACvC,OAA6B;QAE7B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACpE,CAAC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,cAAc,CACZ,IAAqC,EACrC,OAA6B;QAE7B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAClE,CAAC;CACF"}
package/src/core.ts CHANGED
@@ -170,6 +170,7 @@ export class APIPromise<T> extends Promise<T> {
170
170
 
171
171
  export abstract class APIClient {
172
172
  baseURL: string;
173
+ #baseURLOverridden: boolean;
173
174
  maxRetries: number;
174
175
  timeout: number;
175
176
  httpAgent: Agent | undefined;
@@ -179,18 +180,21 @@ export abstract class APIClient {
179
180
 
180
181
  constructor({
181
182
  baseURL,
183
+ baseURLOverridden,
182
184
  maxRetries = 2,
183
185
  timeout = 60000, // 1 minute
184
186
  httpAgent,
185
187
  fetch: overriddenFetch,
186
188
  }: {
187
189
  baseURL: string;
190
+ baseURLOverridden: boolean;
188
191
  maxRetries?: number | undefined;
189
192
  timeout: number | undefined;
190
193
  httpAgent: Agent | undefined;
191
194
  fetch: Fetch | undefined;
192
195
  }) {
193
196
  this.baseURL = baseURL;
197
+ this.#baseURLOverridden = baseURLOverridden;
194
198
  this.maxRetries = validatePositiveInteger('maxRetries', maxRetries);
195
199
  this.timeout = validatePositiveInteger('timeout', timeout);
196
200
  this.httpAgent = httpAgent;
@@ -300,7 +304,7 @@ export abstract class APIClient {
300
304
  { retryCount = 0 }: { retryCount?: number } = {},
301
305
  ): { req: RequestInit; url: string; timeout: number } {
302
306
  const options = { ...inputOptions };
303
- const { method, path, query, headers: headers = {} } = options;
307
+ const { method, path, query, defaultBaseURL, headers: headers = {} } = options;
304
308
 
305
309
  const body =
306
310
  ArrayBuffer.isView(options.body) || (options.__binaryRequest && typeof options.body === 'string') ?
@@ -310,7 +314,7 @@ export abstract class APIClient {
310
314
  : null;
311
315
  const contentLength = this.calculateContentLength(body);
312
316
 
313
- const url = this.buildURL(path!, query);
317
+ const url = this.buildURL(path!, query, defaultBaseURL);
314
318
  if ('timeout' in options) validatePositiveInteger('timeout', options.timeout);
315
319
  options.timeout = options.timeout ?? this.timeout;
316
320
  const httpAgent = options.httpAgent ?? this.httpAgent ?? getDefaultAgent(url);
@@ -503,11 +507,12 @@ export abstract class APIClient {
503
507
  return new PagePromise<PageClass, Item>(this, request, Page);
504
508
  }
505
509
 
506
- buildURL<Req>(path: string, query: Req | null | undefined): string {
510
+ buildURL<Req>(path: string, query: Req | null | undefined, defaultBaseURL?: string | undefined): string {
511
+ const baseURL = (!this.#baseURLOverridden && defaultBaseURL) || this.baseURL;
507
512
  const url =
508
513
  isAbsoluteURL(path) ?
509
514
  new URL(path)
510
- : new URL(this.baseURL + (this.baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
515
+ : new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
511
516
 
512
517
  const defaultQuery = this.defaultQuery();
513
518
  if (!isEmptyObj(defaultQuery)) {
@@ -792,6 +797,7 @@ export type RequestOptions<
792
797
  query?: Req | undefined;
793
798
  body?: Req | null | undefined;
794
799
  headers?: Headers | undefined;
800
+ defaultBaseURL?: string | undefined;
795
801
 
796
802
  maxRetries?: number;
797
803
  stream?: boolean | undefined;
@@ -813,6 +819,7 @@ const requestOptionsKeys: KeysEnum<RequestOptions> = {
813
819
  query: true,
814
820
  body: true,
815
821
  headers: true,
822
+ defaultBaseURL: true,
816
823
 
817
824
  maxRetries: true,
818
825
  stream: true,
package/src/index.ts CHANGED
@@ -15,7 +15,13 @@ import {
15
15
  EvaluationGetJobRunsResponse,
16
16
  } from './resources/evaluation';
17
17
  import { Health, HealthGetResponse } from './resources/health';
18
- import { Integrations } from './resources/integrations';
18
+ import {
19
+ IntegrationCreateRetellCallParams,
20
+ IntegrationCreateRetellCallResponse,
21
+ IntegrationCreateVapiCallParams,
22
+ IntegrationCreateVapiCallResponse,
23
+ Integrations,
24
+ } from './resources/integrations';
19
25
 
20
26
  export interface ClientOptions {
21
27
  /**
@@ -119,6 +125,7 @@ export class Roark extends Core.APIClient {
119
125
 
120
126
  super({
121
127
  baseURL: options.baseURL!,
128
+ baseURLOverridden: baseURL ? baseURL !== 'https://api.roark.ai' : false,
122
129
  timeout: options.timeout ?? 60000 /* 1 minute */,
123
130
  httpAgent: options.httpAgent,
124
131
  maxRetries: options.maxRetries,
@@ -135,6 +142,13 @@ export class Roark extends Core.APIClient {
135
142
  call: API.Call = new API.Call(this);
136
143
  integrations: API.Integrations = new API.Integrations(this);
137
144
 
145
+ /**
146
+ * Check whether the base URL is set to its default.
147
+ */
148
+ #baseURLOverridden(): boolean {
149
+ return this.baseURL !== 'https://api.roark.ai';
150
+ }
151
+
138
152
  protected override defaultQuery(): Core.DefaultQuery | undefined {
139
153
  return this._options.defaultQuery;
140
154
  }
@@ -191,7 +205,13 @@ export declare namespace Roark {
191
205
 
192
206
  export { Call as Call };
193
207
 
194
- export { Integrations as Integrations };
208
+ export {
209
+ Integrations as Integrations,
210
+ type IntegrationCreateRetellCallResponse as IntegrationCreateRetellCallResponse,
211
+ type IntegrationCreateVapiCallResponse as IntegrationCreateVapiCallResponse,
212
+ type IntegrationCreateRetellCallParams as IntegrationCreateRetellCallParams,
213
+ type IntegrationCreateVapiCallParams as IntegrationCreateVapiCallParams,
214
+ };
195
215
  }
196
216
 
197
217
  export { toFile, fileFromPath } from './uploads';
package/src/resource.ts CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  import type { Roark } from './index';
4
4
 
5
- export class APIResource {
5
+ export abstract class APIResource {
6
6
  protected _client: Roark;
7
7
 
8
8
  constructor(client: Roark) {
@@ -18,7 +18,7 @@ export class Evaluation extends APIResource {
18
18
  /**
19
19
  * Retrieve details of a specific evaluation job
20
20
  */
21
- getJob(jobId: string, options?: Core.RequestOptions): Core.APIPromise<unknown> {
21
+ getJob(jobId: string, options?: Core.RequestOptions): Core.APIPromise<EvaluationGetJobResponse> {
22
22
  return this._client.get(`/v1/evaluation/job/${jobId}`, options);
23
23
  }
24
24
 
@@ -29,13 +29,13 @@ export class Evaluation extends APIResource {
29
29
  jobId: string,
30
30
  query?: EvaluationGetJobRunsParams,
31
31
  options?: Core.RequestOptions,
32
- ): Core.APIPromise<unknown>;
33
- getJobRuns(jobId: string, options?: Core.RequestOptions): Core.APIPromise<unknown>;
32
+ ): Core.APIPromise<EvaluationGetJobRunsResponse>;
33
+ getJobRuns(jobId: string, options?: Core.RequestOptions): Core.APIPromise<EvaluationGetJobRunsResponse>;
34
34
  getJobRuns(
35
35
  jobId: string,
36
36
  query: EvaluationGetJobRunsParams | Core.RequestOptions = {},
37
37
  options?: Core.RequestOptions,
38
- ): Core.APIPromise<unknown> {
38
+ ): Core.APIPromise<EvaluationGetJobRunsResponse> {
39
39
  if (isRequestOptions(query)) {
40
40
  return this.getJobRuns(jobId, {}, query);
41
41
  }
@@ -61,9 +61,259 @@ export namespace EvaluationCreateJobResponse {
61
61
  }
62
62
  }
63
63
 
64
- export type EvaluationGetJobResponse = unknown;
64
+ export interface EvaluationGetJobResponse {
65
+ /**
66
+ * Evaluation job response payload
67
+ */
68
+ data: EvaluationGetJobResponse.Data;
69
+ }
70
+
71
+ export namespace EvaluationGetJobResponse {
72
+ /**
73
+ * Evaluation job response payload
74
+ */
75
+ export interface Data {
76
+ /**
77
+ * ID of the evaluation job
78
+ */
79
+ id: string;
80
+
81
+ /**
82
+ * Status of the evaluation job
83
+ */
84
+ status: 'PENDING' | 'PROCESSING' | 'SUCCESS' | 'FAILURE';
85
+
86
+ /**
87
+ * Call being evaluated
88
+ */
89
+ call?: Data.Call;
90
+
91
+ /**
92
+ * Dataset being evaluated
93
+ */
94
+ dataset?: Data.Dataset;
95
+ }
96
+
97
+ export namespace Data {
98
+ /**
99
+ * Call being evaluated
100
+ */
101
+ export interface Call {
102
+ /**
103
+ * ID of the call being evaluated
104
+ */
105
+ id: string | null;
106
+ }
107
+
108
+ /**
109
+ * Dataset being evaluated
110
+ */
111
+ export interface Dataset {
112
+ /**
113
+ * ID of the dataset
114
+ */
115
+ id: string | null;
116
+
117
+ /**
118
+ * Calls in the dataset
119
+ */
120
+ calls: Array<Dataset.Call>;
121
+ }
122
+
123
+ export namespace Dataset {
124
+ export interface Call {
125
+ /**
126
+ * ID of the call
127
+ */
128
+ id: string | null;
129
+ }
130
+ }
131
+ }
132
+ }
133
+
134
+ export interface EvaluationGetJobRunsResponse {
135
+ /**
136
+ * Evaluation job runs response payload
137
+ */
138
+ data: EvaluationGetJobRunsResponse.Data;
139
+ }
140
+
141
+ export namespace EvaluationGetJobRunsResponse {
142
+ /**
143
+ * Evaluation job runs response payload
144
+ */
145
+ export interface Data {
146
+ /**
147
+ * Evaluator runs of the evaluation job
148
+ */
149
+ data: Array<Data.Data> | null;
150
+
151
+ /**
152
+ * Pagination information
153
+ */
154
+ pagination: Data.Pagination | null;
155
+ }
156
+
157
+ export namespace Data {
158
+ export interface Data {
159
+ /**
160
+ * ID of the evaluator run
161
+ */
162
+ id: string;
163
+
164
+ /**
165
+ * When the evaluator run completed
166
+ */
167
+ completedAt: string | null;
168
+
169
+ /**
170
+ * Evaluator of the evaluator run
171
+ */
172
+ evaluator: Data.Evaluator | null;
173
+
174
+ /**
175
+ * Evidence of the evaluator run
176
+ */
177
+ evidence: Array<Data.Evidence> | null;
178
+
179
+ /**
180
+ * Metrics of the evaluator run
181
+ */
182
+ metrics: Array<Data.Metric> | null;
183
+
184
+ /**
185
+ * Score of the evaluator run
186
+ */
187
+ score: number | null;
65
188
 
66
- export type EvaluationGetJobRunsResponse = unknown;
189
+ /**
190
+ * Score classification of the evaluator run
191
+ */
192
+ scoreClassification: 'SUCCESS' | 'FAILURE' | 'IRRELEVANT' | null;
193
+
194
+ /**
195
+ * When the evaluator run started
196
+ */
197
+ startedAt: string | null;
198
+
199
+ /**
200
+ * Status of the evaluator run
201
+ */
202
+ status: 'PENDING' | 'IN_PROGRESS' | 'COMPLETED' | 'FAILED';
203
+
204
+ /**
205
+ * Summary of the evaluator run
206
+ */
207
+ summary: string | null;
208
+ }
209
+
210
+ export namespace Data {
211
+ /**
212
+ * Evaluator of the evaluator run
213
+ */
214
+ export interface Evaluator {
215
+ /**
216
+ * ID of the evaluator
217
+ */
218
+ id: string | null;
219
+
220
+ /**
221
+ * Name of the evaluator
222
+ */
223
+ name: string | null;
224
+ }
225
+
226
+ export interface Evidence {
227
+ /**
228
+ * ID of the evidence
229
+ */
230
+ id: string | null;
231
+
232
+ /**
233
+ * Comment on the evidence
234
+ */
235
+ commentText: string | null;
236
+
237
+ /**
238
+ * Whether this is a positive example of the metric
239
+ */
240
+ isPositive: boolean | null;
241
+
242
+ /**
243
+ * Snippet of the evidence
244
+ */
245
+ snippetText: string | null;
246
+ }
247
+
248
+ export interface Metric {
249
+ /**
250
+ * ID of the metric
251
+ */
252
+ id: string | null;
253
+
254
+ /**
255
+ * Boolean value of the metric
256
+ */
257
+ booleanValue: boolean | null;
258
+
259
+ /**
260
+ * Confidence of the metric
261
+ */
262
+ confidence: number | null;
263
+
264
+ /**
265
+ * Name of the metric
266
+ */
267
+ name: string | null;
268
+
269
+ /**
270
+ * Numeric value of the metric
271
+ */
272
+ numericValue: number | null;
273
+
274
+ /**
275
+ * Reasoning for the metric
276
+ */
277
+ reasoning: string | null;
278
+
279
+ /**
280
+ * Role of the metric
281
+ */
282
+ role: 'PRIMARY' | 'SECONDARY' | null;
283
+
284
+ /**
285
+ * Text value of the metric
286
+ */
287
+ textValue: string | null;
288
+
289
+ /**
290
+ * Value type of the metric
291
+ */
292
+ valueType: 'NUMERIC' | 'BOOLEAN' | 'TEXT' | null;
293
+ }
294
+ }
295
+
296
+ /**
297
+ * Pagination information
298
+ */
299
+ export interface Pagination {
300
+ /**
301
+ * Whether there are more items to fetch
302
+ */
303
+ hasMore: boolean;
304
+
305
+ /**
306
+ * Cursor for the next page of items
307
+ */
308
+ nextCursor: string | null;
309
+
310
+ /**
311
+ * Total number of items
312
+ */
313
+ total: number;
314
+ }
315
+ }
316
+ }
67
317
 
68
318
  export interface EvaluationCreateJobParams {
69
319
  /**
@@ -10,4 +10,10 @@ export {
10
10
  type EvaluationGetJobRunsParams,
11
11
  } from './evaluation';
12
12
  export { Health, type HealthGetResponse } from './health';
13
- export { Integrations } from './integrations';
13
+ export {
14
+ Integrations,
15
+ type IntegrationCreateRetellCallResponse,
16
+ type IntegrationCreateVapiCallResponse,
17
+ type IntegrationCreateRetellCallParams,
18
+ type IntegrationCreateVapiCallParams,
19
+ } from './integrations';
@@ -1,5 +1,134 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  import { APIResource } from '../resource';
4
+ import * as Core from '../core';
4
5
 
5
- export class Integrations extends APIResource {}
6
+ export class Integrations extends APIResource {
7
+ /**
8
+ * Process and upload a Retell call to Roark evaluation
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * const response = await client.integrations.createRetellCall(
13
+ * { retellCallEndedPayload: { event: 'bar', call: 'bar' } },
14
+ * );
15
+ * ```
16
+ */
17
+ createRetellCall(
18
+ body: IntegrationCreateRetellCallParams,
19
+ options?: Core.RequestOptions,
20
+ ): Core.APIPromise<IntegrationCreateRetellCallResponse> {
21
+ return this._client.post('/v1/retell/call', { body, ...options });
22
+ }
23
+
24
+ /**
25
+ * Process and upload a VAPI call to Roark evaluation
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * const response = await client.integrations.createVapiCall({
30
+ * vapiEndOfCallReportPayload: {
31
+ * call: 'bar',
32
+ * type: 'bar',
33
+ * status: 'bar',
34
+ * assistant: 'bar',
35
+ * customer: 'bar',
36
+ * phoneNumber: 'bar',
37
+ * artifact: 'bar',
38
+ * startedAt: 'bar',
39
+ * endedAt: 'bar',
40
+ * endedReason: 'bar',
41
+ * },
42
+ * });
43
+ * ```
44
+ */
45
+ createVapiCall(
46
+ body: IntegrationCreateVapiCallParams,
47
+ options?: Core.RequestOptions,
48
+ ): Core.APIPromise<IntegrationCreateVapiCallResponse> {
49
+ return this._client.post('/v1/vapi/call', { body, ...options });
50
+ }
51
+ }
52
+
53
+ export interface IntegrationCreateRetellCallResponse {
54
+ /**
55
+ * Retell call upload response
56
+ */
57
+ data: IntegrationCreateRetellCallResponse.Data;
58
+ }
59
+
60
+ export namespace IntegrationCreateRetellCallResponse {
61
+ /**
62
+ * Retell call upload response
63
+ */
64
+ export interface Data {
65
+ /**
66
+ * ID of the uploaded call
67
+ */
68
+ callId: string;
69
+ }
70
+ }
71
+
72
+ export interface IntegrationCreateVapiCallResponse {
73
+ /**
74
+ * Vapi call upload response
75
+ */
76
+ data: IntegrationCreateVapiCallResponse.Data;
77
+ }
78
+
79
+ export namespace IntegrationCreateVapiCallResponse {
80
+ /**
81
+ * Vapi call upload response
82
+ */
83
+ export interface Data {
84
+ /**
85
+ * ID of the uploaded call
86
+ */
87
+ callId: string;
88
+ }
89
+ }
90
+
91
+ export interface IntegrationCreateRetellCallParams {
92
+ /**
93
+ * Raw Retell data forwarded directly from the Retell call_ended webhook
94
+ */
95
+ retellCallEndedPayload: Record<string, unknown>;
96
+
97
+ /**
98
+ * Optional metadata (key-value pairs) to include with the call. Useful for
99
+ * filtering and display in call details.
100
+ */
101
+ properties?: Record<string, unknown>;
102
+
103
+ /**
104
+ * Skip already imported Retell calls with the same Retell call id.
105
+ */
106
+ skipAlreadyImported?: boolean;
107
+ }
108
+
109
+ export interface IntegrationCreateVapiCallParams {
110
+ /**
111
+ * Raw Vapi data forwarded directly from the Vapi end-of-call-report webhook
112
+ */
113
+ vapiEndOfCallReportPayload: Record<string, unknown>;
114
+
115
+ /**
116
+ * Optional metadata (key-value pairs) to include with the call. Useful for
117
+ * filtering and display in call details.
118
+ */
119
+ properties?: Record<string, unknown>;
120
+
121
+ /**
122
+ * Skip already imported Vapi calls with the same Vapi call id.
123
+ */
124
+ skipAlreadyImported?: boolean;
125
+ }
126
+
127
+ export declare namespace Integrations {
128
+ export {
129
+ type IntegrationCreateRetellCallResponse as IntegrationCreateRetellCallResponse,
130
+ type IntegrationCreateVapiCallResponse as IntegrationCreateVapiCallResponse,
131
+ type IntegrationCreateRetellCallParams as IntegrationCreateRetellCallParams,
132
+ type IntegrationCreateVapiCallParams as IntegrationCreateVapiCallParams,
133
+ };
134
+ }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.328.0'; // x-release-please-version
1
+ export const VERSION = '0.330.0'; // x-release-please-version
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.328.0";
1
+ export declare const VERSION = "0.330.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '0.328.0'; // x-release-please-version
4
+ exports.VERSION = '0.330.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.328.0'; // x-release-please-version
1
+ export const VERSION = '0.330.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map