@roarkanalytics/sdk 5.8.0 → 5.10.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 (79) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/client.d.mts +13 -4
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +13 -4
  5. package/client.d.ts.map +1 -1
  6. package/client.js +9 -0
  7. package/client.js.map +1 -1
  8. package/client.mjs +9 -0
  9. package/client.mjs.map +1 -1
  10. package/package.json +1 -1
  11. package/resources/analytics.d.mts +354 -0
  12. package/resources/analytics.d.mts.map +1 -0
  13. package/resources/analytics.d.ts +354 -0
  14. package/resources/analytics.d.ts.map +1 -0
  15. package/resources/analytics.js +55 -0
  16. package/resources/analytics.js.map +1 -0
  17. package/resources/analytics.mjs +51 -0
  18. package/resources/analytics.mjs.map +1 -0
  19. package/resources/call.d.mts +90 -1
  20. package/resources/call.d.mts.map +1 -1
  21. package/resources/call.d.ts +90 -1
  22. package/resources/call.d.ts.map +1 -1
  23. package/resources/call.js +17 -0
  24. package/resources/call.js.map +1 -1
  25. package/resources/call.mjs +17 -0
  26. package/resources/call.mjs.map +1 -1
  27. package/resources/config.d.mts +578 -8
  28. package/resources/config.d.mts.map +1 -1
  29. package/resources/config.d.ts +578 -8
  30. package/resources/config.d.ts.map +1 -1
  31. package/resources/dashboard.d.mts +2280 -0
  32. package/resources/dashboard.d.mts.map +1 -0
  33. package/resources/dashboard.d.ts +2280 -0
  34. package/resources/dashboard.d.ts.map +1 -0
  35. package/resources/dashboard.js +170 -0
  36. package/resources/dashboard.js.map +1 -0
  37. package/resources/dashboard.mjs +166 -0
  38. package/resources/dashboard.mjs.map +1 -0
  39. package/resources/index.d.mts +5 -2
  40. package/resources/index.d.mts.map +1 -1
  41. package/resources/index.d.ts +5 -2
  42. package/resources/index.d.ts.map +1 -1
  43. package/resources/index.js +7 -1
  44. package/resources/index.js.map +1 -1
  45. package/resources/index.mjs +3 -0
  46. package/resources/index.mjs.map +1 -1
  47. package/resources/simulation-run-plan-job.d.mts +98 -1
  48. package/resources/simulation-run-plan-job.d.mts.map +1 -1
  49. package/resources/simulation-run-plan-job.d.ts +98 -1
  50. package/resources/simulation-run-plan-job.d.ts.map +1 -1
  51. package/resources/simulation-run-plan-job.js +17 -0
  52. package/resources/simulation-run-plan-job.js.map +1 -1
  53. package/resources/simulation-run-plan-job.mjs +17 -0
  54. package/resources/simulation-run-plan-job.mjs.map +1 -1
  55. package/resources/usage.d.mts +116 -0
  56. package/resources/usage.d.mts.map +1 -0
  57. package/resources/usage.d.ts +116 -0
  58. package/resources/usage.d.ts.map +1 -0
  59. package/resources/usage.js +29 -0
  60. package/resources/usage.js.map +1 -0
  61. package/resources/usage.mjs +25 -0
  62. package/resources/usage.mjs.map +1 -0
  63. package/src/client.ts +67 -0
  64. package/src/resources/analytics.ts +573 -0
  65. package/src/resources/call.ts +136 -0
  66. package/src/resources/config.ts +1441 -41
  67. package/src/resources/dashboard.ts +3752 -0
  68. package/src/resources/index.ts +29 -0
  69. package/src/resources/simulation-run-plan-job.ts +141 -0
  70. package/src/resources/usage.ts +149 -0
  71. package/src/version.ts +1 -1
  72. package/version.d.mts +1 -1
  73. package/version.d.mts.map +1 -1
  74. package/version.d.ts +1 -1
  75. package/version.d.ts.map +1 -1
  76. package/version.js +1 -1
  77. package/version.js.map +1 -1
  78. package/version.mjs +1 -1
  79. package/version.mjs.map +1 -1
@@ -0,0 +1,573 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import { APIPromise } from '../core/api-promise';
5
+ import { RequestOptions } from '../internal/request-options';
6
+
7
+ export class Analytics extends APIResource {
8
+ /**
9
+ * Lists what can go into an analytics query for this project: every metric by slug
10
+ * with its output type, default aggregation and the aggregations it supports; the
11
+ * measure types; the filter and breakdown types with the properties each accepts;
12
+ * and the custom call properties seen in the project. Read this first when
13
+ * building a query.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const response = await client.analytics.getSchema();
18
+ * ```
19
+ */
20
+ getSchema(options?: RequestOptions): APIPromise<AnalyticsGetSchemaResponse> {
21
+ return this._client.get('/v1/analytics/schema', options);
22
+ }
23
+
24
+ /**
25
+ * Aggregates metric values and conversation counts over a time window and returns
26
+ * one series per measure, with a total for the window and per-interval buckets.
27
+ * The same query a dashboard widget runs, without saving anything.
28
+ *
29
+ * - `measures`: what to aggregate. A METRIC measure names its metric by slug;
30
+ * CONVERSATION counts conversations; UPTIME reads health checks. The aggregation
31
+ * defaults by the metric's output type.
32
+ * - `timeRange`: LAST n DAYS/WEEKS/MONTHS, a CALENDAR_ALIGNED period (TODAY,
33
+ * THIS_MONTH, ...), FIXED from/to, or SINCE. Defaults to the last 30 days; at
34
+ * most 731 days. Calendar periods and buckets align to `timezone` (IANA, default
35
+ * UTC).
36
+ * - `filters` apply to every measure; a measure's own `filters` add to them.
37
+ * - `breakdown` on a measure returns one series per value (largest 50 kept).
38
+ * - `comparisonGroups` (2 to 5) run every measure once per named filter set;
39
+ * `comparisonMode: PREVIOUS_PERIOD` adds the preceding window's values.
40
+ *
41
+ * Values are in the metric's display units. A PASS_RATE is a 0 to 1 share;
42
+ * `sampleSize` 0 means no data. A query the analytics store cannot answer returns
43
+ * 400 naming the unsupported part.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * const response = await client.analytics.query({
48
+ * measures: [{}],
49
+ * });
50
+ * ```
51
+ */
52
+ query(body: AnalyticsQueryParams, options?: RequestOptions): APIPromise<AnalyticsQueryResponse> {
53
+ return this._client.post('/v1/analytics/query', { body, ...options });
54
+ }
55
+ }
56
+
57
+ export interface AnalyticsGetSchemaResponse {
58
+ /**
59
+ * What can be queried in this project: metrics (by slug), measure types, filters,
60
+ * breakdowns.
61
+ */
62
+ data: AnalyticsGetSchemaResponse.Data;
63
+ }
64
+
65
+ export namespace AnalyticsGetSchemaResponse {
66
+ /**
67
+ * What can be queried in this project: metrics (by slug), measure types, filters,
68
+ * breakdowns.
69
+ */
70
+ export interface Data {
71
+ breakdowns: Array<Data.Breakdown>;
72
+
73
+ callProperties: Array<Data.CallProperty>;
74
+
75
+ displayTypes: Array<'LINE' | 'NUMBER' | 'RADAR' | 'STACKED_BAR' | 'TABLE'>;
76
+
77
+ filters: Array<Data.Filter>;
78
+
79
+ intervals: Array<'HOUR' | 'DAY' | 'WEEK' | 'MONTH'>;
80
+
81
+ measureTypes: Array<Data.MeasureType>;
82
+
83
+ metrics: Array<Data.Metric>;
84
+
85
+ operators: Array<
86
+ | 'EQUALS'
87
+ | 'NOT_EQUALS'
88
+ | 'GREATER_THAN'
89
+ | 'GREATER_THAN_OR_EQUAL_TO'
90
+ | 'LESS_THAN'
91
+ | 'LESS_THAN_OR_EQUAL_TO'
92
+ | 'CONTAINS'
93
+ | 'STARTS_WITH'
94
+ >;
95
+ }
96
+
97
+ export namespace Data {
98
+ export interface Breakdown {
99
+ description: string;
100
+
101
+ type: 'METRIC_PROPERTY' | 'CALL_PROPERTY' | 'AGENT_PROPERTY' | 'DATASET';
102
+ }
103
+
104
+ export interface CallProperty {
105
+ isSystem: boolean;
106
+
107
+ name: string;
108
+
109
+ valueType: string;
110
+ }
111
+
112
+ export interface Filter {
113
+ description: string;
114
+
115
+ properties: Array<Filter.Property>;
116
+
117
+ type:
118
+ | 'METRIC_PROPERTY'
119
+ | 'CALL_PROPERTY'
120
+ | 'AGENT_PROPERTY'
121
+ | 'CALL_ID'
122
+ | 'MODALITY'
123
+ | 'DATASET'
124
+ | 'METRIC_VALUE';
125
+ }
126
+
127
+ export namespace Filter {
128
+ export interface Property {
129
+ description: string;
130
+
131
+ property: string;
132
+ }
133
+ }
134
+
135
+ export interface MeasureType {
136
+ aggregations: Array<'COUNT' | 'AVG' | 'MIN' | 'MAX' | 'SUM' | 'MEDIAN' | 'PERCENTILE' | 'PASS_RATE'>;
137
+
138
+ description: string;
139
+
140
+ type: 'METRIC' | 'CONVERSATION' | 'UPTIME';
141
+ }
142
+
143
+ export interface Metric {
144
+ id: string;
145
+
146
+ aggregations: Array<'COUNT' | 'AVG' | 'MIN' | 'MAX' | 'SUM' | 'MEDIAN' | 'PERCENTILE' | 'PASS_RATE'>;
147
+
148
+ defaultAggregation: 'COUNT' | 'AVG' | 'MIN' | 'MAX' | 'SUM' | 'MEDIAN' | 'PERCENTILE' | 'PASS_RATE';
149
+
150
+ isThreshold: boolean;
151
+
152
+ name: string;
153
+
154
+ outputType: string;
155
+
156
+ slug: string;
157
+ }
158
+ }
159
+ }
160
+
161
+ export interface AnalyticsQueryResponse {
162
+ /**
163
+ * One series per measure (or per breakdown value / comparison group). `value` is
164
+ * the aggregate over the whole window; `buckets` hold the per-interval values.
165
+ */
166
+ data: AnalyticsQueryResponse.Data;
167
+ }
168
+
169
+ export namespace AnalyticsQueryResponse {
170
+ /**
171
+ * One series per measure (or per breakdown value / comparison group). `value` is
172
+ * the aggregate over the whole window; `buckets` hold the per-interval values.
173
+ */
174
+ export interface Data {
175
+ from: string;
176
+
177
+ interval: 'HOUR' | 'DAY' | 'WEEK' | 'MONTH';
178
+
179
+ omittedSeries: number;
180
+
181
+ series: Array<Data.Sery>;
182
+
183
+ timezone: string;
184
+
185
+ to: string;
186
+ }
187
+
188
+ export namespace Data {
189
+ export interface Sery {
190
+ aggregation: 'COUNT' | 'AVG' | 'MIN' | 'MAX' | 'SUM' | 'MEDIAN' | 'PERCENTILE' | 'PASS_RATE';
191
+
192
+ breakdownValue: string | null;
193
+
194
+ buckets: Array<Sery.Bucket>;
195
+
196
+ comparisonGroup: string | null;
197
+
198
+ comparisonValue: number | null;
199
+
200
+ measureIndex: number;
201
+
202
+ metric: string | null;
203
+
204
+ percentageOfBaseline: number | null;
205
+
206
+ sampleSize: number | null;
207
+
208
+ type: 'METRIC' | 'CONVERSATION' | 'UPTIME';
209
+
210
+ value: number;
211
+ }
212
+
213
+ export namespace Sery {
214
+ export interface Bucket {
215
+ date: string;
216
+
217
+ value: number;
218
+
219
+ comparisonDate?: string;
220
+
221
+ comparisonValue?: number;
222
+
223
+ passed?: number;
224
+
225
+ percentageOfBaseline?: number;
226
+
227
+ sampleSize?: number;
228
+ }
229
+ }
230
+ }
231
+ }
232
+
233
+ export interface AnalyticsQueryParams {
234
+ /**
235
+ * What to aggregate: 1 to 10 measures.
236
+ */
237
+ measures: Array<AnalyticsQueryParams.Measure>;
238
+
239
+ /**
240
+ * Run every measure once per named filter set, e.g. one group per agent.
241
+ */
242
+ comparisonGroups?: Array<AnalyticsQueryParams.ComparisonGroup>;
243
+
244
+ /**
245
+ * PREVIOUS_PERIOD adds the preceding window of the same length to every series.
246
+ */
247
+ comparisonMode?: 'NONE' | 'PREVIOUS_PERIOD';
248
+
249
+ /**
250
+ * Applied to every measure, on top of each measure's own filters.
251
+ */
252
+ filters?: Array<AnalyticsQueryParams.Filter>;
253
+
254
+ /**
255
+ * Set false to return only the window totals.
256
+ */
257
+ includeBuckets?: boolean;
258
+
259
+ /**
260
+ * Bucket size. Defaults from the window's length and steps coarser when the window
261
+ * would exceed 500 buckets.
262
+ */
263
+ interval?: 'HOUR' | 'DAY' | 'WEEK' | 'MONTH';
264
+
265
+ /**
266
+ * Defaults to the last 30 days.
267
+ */
268
+ timeRange?:
269
+ | AnalyticsQueryParams.UnionMember0
270
+ | AnalyticsQueryParams.UnionMember1
271
+ | AnalyticsQueryParams.UnionMember2
272
+ | AnalyticsQueryParams.UnionMember3;
273
+
274
+ /**
275
+ * IANA zone that buckets and calendar periods align to, e.g. America/New_York.
276
+ * Defaults to UTC.
277
+ */
278
+ timezone?: string;
279
+ }
280
+
281
+ export namespace AnalyticsQueryParams {
282
+ export interface Measure {
283
+ /**
284
+ * Defaults by output type: AVG for numeric metrics, COUNT (split by value) for
285
+ * classification and text, PASS_RATE for thresholds and uptime, COUNT for
286
+ * conversations.
287
+ */
288
+ aggregation?: 'COUNT' | 'AVG' | 'MIN' | 'MAX' | 'SUM' | 'MEDIAN' | 'PERCENTILE' | 'PASS_RATE';
289
+
290
+ /**
291
+ * Split the measure into one series per value of this dimension (the largest 50
292
+ * are returned). Ignored while comparisonGroups are set: each group is then one
293
+ * series.
294
+ */
295
+ breakdown?: Measure.Breakdown;
296
+
297
+ /**
298
+ * Chart color on a dashboard.
299
+ */
300
+ color?:
301
+ | 'GREEN'
302
+ | 'RED'
303
+ | 'ORANGE'
304
+ | 'PURPLE'
305
+ | 'GREY'
306
+ | 'BLUE'
307
+ | 'PEACH'
308
+ | 'TEAL'
309
+ | 'INDIGO'
310
+ | 'AMBER'
311
+ | 'ROSE'
312
+ | 'CYAN';
313
+
314
+ /**
315
+ * CALL (default for metrics) folds each conversation to one value first, so a long
316
+ * call does not outweigh a short one. NONE aggregates every value.
317
+ */
318
+ distinctBy?: 'NONE' | 'CALL';
319
+
320
+ /**
321
+ * Filters for this measure only, on top of the query's filters.
322
+ */
323
+ filters?: Array<Measure.Filter>;
324
+
325
+ /**
326
+ * Mark one measure as the baseline: every series also reports its value as a
327
+ * percentage of it.
328
+ */
329
+ isBaseline?: boolean;
330
+
331
+ /**
332
+ * The metric's slug (e.g. `task_completion`) or id. Required for METRIC.
333
+ */
334
+ metric?: string;
335
+
336
+ /**
337
+ * How each conversation is folded when distinctBy is CALL. Defaults to SUM under
338
+ * SUM, else AVG.
339
+ */
340
+ nestedAggregation?: 'COUNT' | 'AVG' | 'MIN' | 'MAX' | 'SUM' | 'MEDIAN' | 'PERCENTILE' | 'PASS_RATE';
341
+
342
+ nestedAggregationPercentile?: number;
343
+
344
+ /**
345
+ * PASS_RATE condition operator. Omit for a threshold metric: its own condition is
346
+ * used.
347
+ */
348
+ passOperator?:
349
+ | 'EQUALS'
350
+ | 'NOT_EQUALS'
351
+ | 'GREATER_THAN'
352
+ | 'GREATER_THAN_OR_EQUAL_TO'
353
+ | 'LESS_THAN'
354
+ | 'LESS_THAN_OR_EQUAL_TO'
355
+ | 'CONTAINS'
356
+ | 'STARTS_WITH';
357
+
358
+ /**
359
+ * PASS_RATE condition value, e.g. 4 or "resolved".
360
+ */
361
+ passValue?: string | number | boolean;
362
+
363
+ /**
364
+ * Required with PERCENTILE, e.g. 95.
365
+ */
366
+ percentile?: number;
367
+
368
+ /**
369
+ * METRIC (default): a metric's values. CONVERSATION: conversation counts. UPTIME:
370
+ * health-check outcomes.
371
+ */
372
+ type?: 'METRIC' | 'CONVERSATION' | 'UPTIME';
373
+ }
374
+
375
+ export namespace Measure {
376
+ /**
377
+ * Split the measure into one series per value of this dimension (the largest 50
378
+ * are returned). Ignored while comparisonGroups are set: each group is then one
379
+ * series.
380
+ */
381
+ export interface Breakdown {
382
+ type: 'METRIC_PROPERTY' | 'CALL_PROPERTY' | 'AGENT_PROPERTY' | 'DATASET';
383
+
384
+ /**
385
+ * The property to split by. Required for CALL_PROPERTY and METRIC_PROPERTY.
386
+ */
387
+ property?: string;
388
+ }
389
+
390
+ export interface Filter {
391
+ /**
392
+ * What the filter narrows on. GET /v1/analytics/schema lists each type.
393
+ */
394
+ type:
395
+ | 'METRIC_PROPERTY'
396
+ | 'CALL_PROPERTY'
397
+ | 'AGENT_PROPERTY'
398
+ | 'CALL_ID'
399
+ | 'MODALITY'
400
+ | 'DATASET'
401
+ | 'METRIC_VALUE';
402
+
403
+ /**
404
+ * The value to compare against (an agent id, "call" / "chat", a property value).
405
+ */
406
+ value: string | number | boolean;
407
+
408
+ /**
409
+ * Defaults to EQUALS.
410
+ */
411
+ operator?:
412
+ | 'EQUALS'
413
+ | 'NOT_EQUALS'
414
+ | 'GREATER_THAN'
415
+ | 'GREATER_THAN_OR_EQUAL_TO'
416
+ | 'LESS_THAN'
417
+ | 'LESS_THAN_OR_EQUAL_TO'
418
+ | 'CONTAINS'
419
+ | 'STARTS_WITH';
420
+
421
+ /**
422
+ * The property to compare. Required for CALL_PROPERTY and METRIC_PROPERTY; may be
423
+ * omitted for AGENT_PROPERTY, DATASET, MODALITY and CALL_ID.
424
+ */
425
+ property?: string;
426
+ }
427
+ }
428
+
429
+ export interface ComparisonGroup {
430
+ filters: Array<ComparisonGroup.Filter>;
431
+
432
+ /**
433
+ * The series label; unique within the query.
434
+ */
435
+ name: string;
436
+
437
+ color?:
438
+ | 'GREEN'
439
+ | 'RED'
440
+ | 'ORANGE'
441
+ | 'PURPLE'
442
+ | 'GREY'
443
+ | 'BLUE'
444
+ | 'PEACH'
445
+ | 'TEAL'
446
+ | 'INDIGO'
447
+ | 'AMBER'
448
+ | 'ROSE'
449
+ | 'CYAN';
450
+ }
451
+
452
+ export namespace ComparisonGroup {
453
+ export interface Filter {
454
+ /**
455
+ * What the filter narrows on. GET /v1/analytics/schema lists each type.
456
+ */
457
+ type:
458
+ | 'METRIC_PROPERTY'
459
+ | 'CALL_PROPERTY'
460
+ | 'AGENT_PROPERTY'
461
+ | 'CALL_ID'
462
+ | 'MODALITY'
463
+ | 'DATASET'
464
+ | 'METRIC_VALUE';
465
+
466
+ /**
467
+ * The value to compare against (an agent id, "call" / "chat", a property value).
468
+ */
469
+ value: string | number | boolean;
470
+
471
+ /**
472
+ * Defaults to EQUALS.
473
+ */
474
+ operator?:
475
+ | 'EQUALS'
476
+ | 'NOT_EQUALS'
477
+ | 'GREATER_THAN'
478
+ | 'GREATER_THAN_OR_EQUAL_TO'
479
+ | 'LESS_THAN'
480
+ | 'LESS_THAN_OR_EQUAL_TO'
481
+ | 'CONTAINS'
482
+ | 'STARTS_WITH';
483
+
484
+ /**
485
+ * The property to compare. Required for CALL_PROPERTY and METRIC_PROPERTY; may be
486
+ * omitted for AGENT_PROPERTY, DATASET, MODALITY and CALL_ID.
487
+ */
488
+ property?: string;
489
+ }
490
+ }
491
+
492
+ export interface Filter {
493
+ /**
494
+ * What the filter narrows on. GET /v1/analytics/schema lists each type.
495
+ */
496
+ type:
497
+ | 'METRIC_PROPERTY'
498
+ | 'CALL_PROPERTY'
499
+ | 'AGENT_PROPERTY'
500
+ | 'CALL_ID'
501
+ | 'MODALITY'
502
+ | 'DATASET'
503
+ | 'METRIC_VALUE';
504
+
505
+ /**
506
+ * The value to compare against (an agent id, "call" / "chat", a property value).
507
+ */
508
+ value: string | number | boolean;
509
+
510
+ /**
511
+ * Defaults to EQUALS.
512
+ */
513
+ operator?:
514
+ | 'EQUALS'
515
+ | 'NOT_EQUALS'
516
+ | 'GREATER_THAN'
517
+ | 'GREATER_THAN_OR_EQUAL_TO'
518
+ | 'LESS_THAN'
519
+ | 'LESS_THAN_OR_EQUAL_TO'
520
+ | 'CONTAINS'
521
+ | 'STARTS_WITH';
522
+
523
+ /**
524
+ * The property to compare. Required for CALL_PROPERTY and METRIC_PROPERTY; may be
525
+ * omitted for AGENT_PROPERTY, DATASET, MODALITY and CALL_ID.
526
+ */
527
+ property?: string;
528
+ }
529
+
530
+ export interface UnionMember0 {
531
+ type: 'LAST';
532
+
533
+ unit: 'DAYS' | 'WEEKS' | 'MONTHS';
534
+
535
+ value: number;
536
+ }
537
+
538
+ export interface UnionMember1 {
539
+ period:
540
+ | 'TODAY'
541
+ | 'YESTERDAY'
542
+ | 'THIS_WEEK'
543
+ | 'LAST_WEEK'
544
+ | 'THIS_MONTH'
545
+ | 'LAST_MONTH'
546
+ | 'THIS_YEAR'
547
+ | 'LAST_YEAR';
548
+
549
+ type: 'CALENDAR_ALIGNED';
550
+ }
551
+
552
+ export interface UnionMember2 {
553
+ from: string;
554
+
555
+ to: string;
556
+
557
+ type: 'FIXED';
558
+ }
559
+
560
+ export interface UnionMember3 {
561
+ from: string;
562
+
563
+ type: 'SINCE';
564
+ }
565
+ }
566
+
567
+ export declare namespace Analytics {
568
+ export {
569
+ type AnalyticsGetSchemaResponse as AnalyticsGetSchemaResponse,
570
+ type AnalyticsQueryResponse as AnalyticsQueryResponse,
571
+ type AnalyticsQueryParams as AnalyticsQueryParams,
572
+ };
573
+ }