@elmohq/sdk 0.0.0-stage → 0.1.1

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 (129) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +326 -2
  3. package/dist/calls/index.d.mts +288 -0
  4. package/dist/calls/index.d.mts.map +1 -0
  5. package/dist/calls/index.mjs +390 -0
  6. package/dist/calls/index.mjs.map +1 -0
  7. package/dist/index.d.mts +2 -0
  8. package/dist/index.mjs +1031 -0
  9. package/dist/index.mjs.map +1 -0
  10. package/dist/request-options-B9S9d24M.d.mts +1549 -0
  11. package/dist/request-options-B9S9d24M.d.mts.map +1 -0
  12. package/dist/tools-7Hs5J2xb.d.mts +1945 -0
  13. package/dist/tools-7Hs5J2xb.d.mts.map +1 -0
  14. package/dist/tools-B1lVtYAr.mjs +2459 -0
  15. package/dist/tools-B1lVtYAr.mjs.map +1 -0
  16. package/dist/types/index.d.mts +2 -0
  17. package/dist/types/index.mjs +1 -0
  18. package/package.json +68 -4
  19. package/src/calls/brands-analytics-get.ts +33 -0
  20. package/src/calls/brands-citations-domains-list.ts +36 -0
  21. package/src/calls/brands-citations-urls-list.ts +32 -0
  22. package/src/calls/brands-create.ts +19 -0
  23. package/src/calls/brands-get.ts +19 -0
  24. package/src/calls/brands-list.ts +18 -0
  25. package/src/calls/brands-opportunities-get.ts +42 -0
  26. package/src/calls/brands-prompt-performance-list.ts +39 -0
  27. package/src/calls/brands-query-fanout-get.ts +30 -0
  28. package/src/calls/brands-tags-list.ts +28 -0
  29. package/src/calls/brands-update.ts +20 -0
  30. package/src/calls/competitors-create.ts +23 -0
  31. package/src/calls/competitors-delete.ts +19 -0
  32. package/src/calls/competitors-get.ts +19 -0
  33. package/src/calls/competitors-list.ts +23 -0
  34. package/src/calls/competitors-update.ts +24 -0
  35. package/src/calls/index.ts +33 -0
  36. package/src/calls/me-get.ts +18 -0
  37. package/src/calls/models-list.ts +20 -0
  38. package/src/calls/organizations-billing-get.ts +37 -0
  39. package/src/calls/organizations-get.ts +24 -0
  40. package/src/calls/organizations-list.ts +27 -0
  41. package/src/calls/prompts-create.ts +27 -0
  42. package/src/calls/prompts-delete.ts +28 -0
  43. package/src/calls/prompts-get.ts +23 -0
  44. package/src/calls/prompts-list.ts +28 -0
  45. package/src/calls/prompts-runs-get.ts +27 -0
  46. package/src/calls/prompts-runs-list.ts +30 -0
  47. package/src/calls/prompts-snapshot-get.ts +28 -0
  48. package/src/calls/prompts-update.ts +29 -0
  49. package/src/calls/reports-create.ts +31 -0
  50. package/src/calls/reports-get.ts +27 -0
  51. package/src/calls/reports-list.ts +28 -0
  52. package/src/calls/tools-analyze.ts +26 -0
  53. package/src/client.ts +649 -0
  54. package/src/index.ts +21 -0
  55. package/src/internal/binding/rest/binding.ts +127 -0
  56. package/src/internal/binding/rest/errors.ts +107 -0
  57. package/src/internal/binding/rest/path.ts +9 -0
  58. package/src/internal/binding/rest/url.ts +97 -0
  59. package/src/internal/codec/json.ts +66 -0
  60. package/src/internal/codec/registry.ts +55 -0
  61. package/src/internal/core/backoff.ts +170 -0
  62. package/src/internal/core/body.ts +54 -0
  63. package/src/internal/core/browser.ts +11 -0
  64. package/src/internal/core/call-promise.ts +145 -0
  65. package/src/internal/core/callable.ts +11 -0
  66. package/src/internal/core/client.ts +89 -0
  67. package/src/internal/core/config.ts +84 -0
  68. package/src/internal/core/credentials.ts +40 -0
  69. package/src/internal/core/dispatch.ts +225 -0
  70. package/src/internal/core/env.ts +68 -0
  71. package/src/internal/core/errors.ts +431 -0
  72. package/src/internal/core/features.ts +60 -0
  73. package/src/internal/core/lazy-promise.ts +39 -0
  74. package/src/internal/core/metadata.ts +79 -0
  75. package/src/internal/core/page.ts +402 -0
  76. package/src/internal/core/params.ts +98 -0
  77. package/src/internal/core/protocol.ts +17 -0
  78. package/src/internal/core/read-reply.ts +7 -0
  79. package/src/internal/core/text.ts +7 -0
  80. package/src/internal/core/types.ts +554 -0
  81. package/src/internal/feature/auth.ts +201 -0
  82. package/src/internal/feature/interceptors.ts +36 -0
  83. package/src/internal/feature/logger.ts +222 -0
  84. package/src/internal/feature/retry.ts +168 -0
  85. package/src/internal/feature/rules.ts +54 -0
  86. package/src/internal/feature/timeout.ts +146 -0
  87. package/src/internal/feature/validate.ts +82 -0
  88. package/src/internal/transport/fetch.ts +82 -0
  89. package/src/resources/analytics.ts +364 -0
  90. package/src/resources/brands.ts +288 -0
  91. package/src/resources/competitors.ts +213 -0
  92. package/src/resources/identity.ts +49 -0
  93. package/src/resources/models.ts +32 -0
  94. package/src/resources/opportunities.ts +81 -0
  95. package/src/resources/organizations.ts +182 -0
  96. package/src/resources/prompts.ts +293 -0
  97. package/src/resources/reports.ts +212 -0
  98. package/src/resources/runs.ts +124 -0
  99. package/src/resources/shared/auth.ts +13 -0
  100. package/src/resources/shared/request-options.ts +26 -0
  101. package/src/resources/shared/resource.ts +23 -0
  102. package/src/resources/shared/rule.ts +25 -0
  103. package/src/resources/snapshots.ts +54 -0
  104. package/src/resources/tags.ts +46 -0
  105. package/src/resources/tools.ts +69 -0
  106. package/src/types/analytics.ts +497 -0
  107. package/src/types/brands.ts +228 -0
  108. package/src/types/competitors.ts +196 -0
  109. package/src/types/identity.ts +55 -0
  110. package/src/types/index.ts +163 -0
  111. package/src/types/models.ts +40 -0
  112. package/src/types/opportunities.ts +84 -0
  113. package/src/types/organizations.ts +157 -0
  114. package/src/types/prompts.ts +231 -0
  115. package/src/types/reports.ts +266 -0
  116. package/src/types/runs.ts +131 -0
  117. package/src/types/shared/brand-id-path.ts +2 -0
  118. package/src/types/shared/conflict-error.ts +7 -0
  119. package/src/types/shared/error.ts +29 -0
  120. package/src/types/shared/limit.ts +8 -0
  121. package/src/types/shared/mention-entry.ts +21 -0
  122. package/src/types/shared/model-filter.ts +15 -0
  123. package/src/types/shared/not-found-error.ts +4 -0
  124. package/src/types/shared/page.ts +7 -0
  125. package/src/types/shared/pagination.ts +7 -0
  126. package/src/types/shared/validation-error.ts +4 -0
  127. package/src/types/snapshots.ts +88 -0
  128. package/src/types/tags.ts +47 -0
  129. package/src/types/tools.ts +78 -0
@@ -0,0 +1,497 @@
1
+ import type {
2
+ ForbiddenError,
3
+ InternalServerError,
4
+ RateLimitError,
5
+ UnauthorizedError,
6
+ } from './shared/error';
7
+ import type { ModelFilter, WindowEnd, WindowStart } from './shared/model-filter';
8
+ import type { NotFoundError } from './shared/not-found-error';
9
+ import type { ValidationError } from './shared/validation-error';
10
+
11
+ /**
12
+ * The window the response was computed over, echoed back as the half-open instants it resolved to.
13
+ */
14
+ export type DateRange = {
15
+ /** Exclusive upper bound, in UTC. */
16
+ end: Date;
17
+ /** Inclusive lower bound, in UTC. */
18
+ start: Date;
19
+ };
20
+
21
+ export type VisibilityPoint = {
22
+ date: string;
23
+ /**
24
+ * Null on days with no runs to plot; the series is not gap-filled with zeros. Ratio 0–1; multiply
25
+ * by 100 for a percentage.
26
+ *
27
+ * @minimum 0
28
+ * @maximum 1
29
+ */
30
+ visibility: number | null;
31
+ };
32
+
33
+ export type ShareOfVoiceEntry = {
34
+ /** True for the tracked brand's own row. */
35
+ isBrand: boolean;
36
+ mentions: number;
37
+ /** Brand or competitor name. */
38
+ name: string;
39
+ /** Distinct prompts this entity appeared in. */
40
+ prompts: number;
41
+ /**
42
+ * This entity's share of all brand and competitor mentions. Ratio 0–1; multiply by 100 for a
43
+ * percentage.
44
+ *
45
+ * @minimum 0
46
+ * @maximum 1
47
+ */
48
+ share: number;
49
+ };
50
+
51
+ export type ShareOfVoicePoint = {
52
+ date: string;
53
+ /**
54
+ * The brand's share on this day. Null on days with no runs. Ratio 0–1; multiply by 100 for a
55
+ * percentage.
56
+ *
57
+ * @minimum 0
58
+ * @maximum 1
59
+ */
60
+ share: number | null;
61
+ };
62
+
63
+ export type CitationDomain = {
64
+ /** Which side of the citation landscape the domain sits on. */
65
+ category:
66
+ | 'brand'
67
+ | 'competitor'
68
+ | 'editorial'
69
+ | 'reviews'
70
+ | 'ecommerce'
71
+ | 'social'
72
+ | 'developer'
73
+ | 'pr'
74
+ | 'reference'
75
+ | 'institutional'
76
+ | 'other';
77
+ /**
78
+ * How this window compares with the equal-length window before it, as a multiplier of the
79
+ * previous count: 2 means twice as many citations, 0.5 means half, 1 means unchanged. Not a
80
+ * percentage change — 1.5 is "1.5x", which is a 50% increase. Null when the domain had no
81
+ * citations in the previous window, so there is nothing to divide by.
82
+ *
83
+ * @minimum 0
84
+ */
85
+ changeFactor: number | null;
86
+ /** Citations to this domain in the window. */
87
+ count: number;
88
+ domain: string;
89
+ /** Citations in the equal-length window immediately before this one. */
90
+ previousCount: number;
91
+ /** Distinct prompts whose answers cited this domain. */
92
+ promptCount: number;
93
+ /**
94
+ * Share of all citations in the window. Ratio 0–1; multiply by 100 for a percentage.
95
+ *
96
+ * @minimum 0
97
+ * @maximum 1
98
+ */
99
+ share: number;
100
+ };
101
+
102
+ export type CitationDomainList = {
103
+ brandId: string;
104
+ /** Every domain cited over the window, ordered by citation count. */
105
+ data: Array<CitationDomain>;
106
+ range: DateRange;
107
+ totals: {
108
+ citations: number;
109
+ uniqueDomains: number;
110
+ uniqueUrls: number;
111
+ };
112
+ };
113
+
114
+ export type CitationURL = {
115
+ /** Which side of the citation landscape the domain sits on. */
116
+ category:
117
+ | 'brand'
118
+ | 'competitor'
119
+ | 'editorial'
120
+ | 'reviews'
121
+ | 'ecommerce'
122
+ | 'social'
123
+ | 'developer'
124
+ | 'pr'
125
+ | 'reference'
126
+ | 'institutional'
127
+ | 'other';
128
+ count: number;
129
+ domain: string;
130
+ /** Not cited in the equal-length window immediately before this one. */
131
+ isNew: boolean;
132
+ /** What kind of page was cited. */
133
+ pageType:
134
+ | 'homepage'
135
+ | 'article'
136
+ | 'listicle'
137
+ | 'howto'
138
+ | 'comparison'
139
+ | 'review'
140
+ | 'forum'
141
+ | 'video'
142
+ | 'doc'
143
+ | 'product'
144
+ | 'info'
145
+ | 'search'
146
+ | 'shopping'
147
+ | 'other';
148
+ promptCount: number;
149
+ title: string | null;
150
+ url: string;
151
+ };
152
+
153
+ export type CitationURLList = {
154
+ brandId: string;
155
+ /** Every URL cited over the window, ordered by citation count. */
156
+ data: Array<CitationURL>;
157
+ range: DateRange;
158
+ totals: {
159
+ citations: number;
160
+ uniqueDomains: number;
161
+ uniqueUrls: number;
162
+ };
163
+ };
164
+
165
+ export type FanoutQuery = {
166
+ promptCount: number;
167
+ /** A search the engine ran while answering. */
168
+ query: string;
169
+ runs: number;
170
+ };
171
+
172
+ export type BrandQueryFanout = {
173
+ avgQueriesPerRun: number;
174
+ brandId: string;
175
+ /**
176
+ * Share of fan-out query instances whose answer mentioned the brand. Ratio 0–1; multiply by 100
177
+ * for a percentage.
178
+ *
179
+ * @minimum 0
180
+ * @maximum 1
181
+ */
182
+ coverageRate: number;
183
+ /** Every distinct sub-query over the window, ordered by the runs that ran it. */
184
+ data: Array<FanoutQuery>;
185
+ /**
186
+ * Runs that searched at all. Engines that don't expose their searches contribute runs but no
187
+ * queries.
188
+ */
189
+ fanoutRuns: number;
190
+ range: DateRange;
191
+ totalQueries: number;
192
+ totalRuns: number;
193
+ uniqueQueries: number;
194
+ };
195
+
196
+ export type PromptPerformance = {
197
+ /**
198
+ * Share of this prompt's runs mentioning the brand. Ratio 0–1; multiply by 100 for a percentage.
199
+ *
200
+ * @minimum 0
201
+ * @maximum 1
202
+ */
203
+ brandMentionRate: number;
204
+ /**
205
+ * Share of this prompt's runs mentioning any tracked competitor. Ratio 0–1; multiply by 100 for a
206
+ * percentage.
207
+ *
208
+ * @minimum 0
209
+ * @maximum 1
210
+ */
211
+ competitorMentionRate: number;
212
+ firstEvaluatedAt: Date | null;
213
+ lastRunAt: Date | null;
214
+ promptId: string;
215
+ tags: Array<string>;
216
+ totalRuns: number;
217
+ value: string;
218
+ };
219
+
220
+ export type PromptPerformanceList = {
221
+ brandId: string;
222
+ /** Every prompt sampled over the window, with its results. */
223
+ data: Array<PromptPerformance>;
224
+ range: DateRange;
225
+ };
226
+
227
+ export type ModelVisibility = {
228
+ brandMentions: number;
229
+ citations: number;
230
+ label: string;
231
+ model: string;
232
+ runs: number;
233
+ /**
234
+ * Share of this model's runs that mentioned the brand. Ratio 0–1; multiply by 100 for a
235
+ * percentage.
236
+ *
237
+ * @minimum 0
238
+ * @maximum 1
239
+ */
240
+ visibility: number | null;
241
+ };
242
+
243
+ /**
244
+ * Every non-paginated figure for a brand over one window. There is no parameter for selecting a
245
+ * subset: the four computations behind this share one scope resolution and run concurrently, so a
246
+ * subset would save a caller a fraction of one request and cost everyone a parameter to reason
247
+ * about.
248
+ */
249
+ export type BrandAnalytics = {
250
+ brandId: string;
251
+ brandName: string;
252
+ /** Per-model visibility and run counts. Only models that produced a run in the window appear. */
253
+ models: Array<ModelVisibility>;
254
+ range: DateRange;
255
+ /** The brand against its tracked competitors. */
256
+ shareOfVoice: {
257
+ /**
258
+ * The brand's own share at the end of the window. Ratio 0–1; multiply by 100 for a percentage.
259
+ *
260
+ * @minimum 0
261
+ * @maximum 1
262
+ */
263
+ brand: number | null;
264
+ /** Leaderboard, highest share first. */
265
+ entries: Array<ShareOfVoiceEntry>;
266
+ /** The brand's share over time. */
267
+ series: Array<ShareOfVoicePoint>;
268
+ };
269
+ totals: {
270
+ citations: number;
271
+ /** Enabled prompts counted in the window. */
272
+ prompts: number;
273
+ runs: number;
274
+ uniqueDomains: number;
275
+ uniqueUrls: number;
276
+ };
277
+ /** How often the brand is mentioned at all. */
278
+ visibility: {
279
+ /**
280
+ * The last plotted point — the number the dashboard hero shows. Ratio 0–1; multiply by 100 for
281
+ * a percentage.
282
+ *
283
+ * @minimum 0
284
+ * @maximum 1
285
+ */
286
+ current: number | null;
287
+ series: Array<VisibilityPoint>;
288
+ };
289
+ };
290
+
291
+ /** Comma-separated prompt tags. Only prompts carrying at least one of them are counted. */
292
+ export type TagsFilter = string;
293
+
294
+ export type GetBrandAnalyticsErrors = {
295
+ /** Invalid request data */
296
+ 400: ValidationError;
297
+ /** Authentication required */
298
+ 401: UnauthorizedError;
299
+ /**
300
+ * The key is valid but not permitted: a missing scope, an admin-only endpoint, or a write in
301
+ * read-only (demo) mode.
302
+ */
303
+ 403: ForbiddenError;
304
+ /** Resource not found */
305
+ 404: NotFoundError;
306
+ /** Per-key rate limit exceeded. */
307
+ 429: RateLimitError;
308
+ /** Internal server error */
309
+ 500: InternalServerError;
310
+ };
311
+
312
+ export type GetBrandAnalyticsResponses = {
313
+ /** Get a brand's analytics */
314
+ 200: BrandAnalytics;
315
+ };
316
+
317
+ export type ListBrandCitationDomainsErrors = {
318
+ /** Invalid request data */
319
+ 400: ValidationError;
320
+ /** Authentication required */
321
+ 401: UnauthorizedError;
322
+ /**
323
+ * The key is valid but not permitted: a missing scope, an admin-only endpoint, or a write in
324
+ * read-only (demo) mode.
325
+ */
326
+ 403: ForbiddenError;
327
+ /** Resource not found */
328
+ 404: NotFoundError;
329
+ /** Per-key rate limit exceeded. */
330
+ 429: RateLimitError;
331
+ /** Internal server error */
332
+ 500: InternalServerError;
333
+ };
334
+
335
+ export type ListBrandCitationDomainsResponses = {
336
+ /** List cited domains */
337
+ 200: CitationDomainList;
338
+ };
339
+
340
+ export type ListBrandCitationURLsErrors = {
341
+ /** Invalid request data */
342
+ 400: ValidationError;
343
+ /** Authentication required */
344
+ 401: UnauthorizedError;
345
+ /**
346
+ * The key is valid but not permitted: a missing scope, an admin-only endpoint, or a write in
347
+ * read-only (demo) mode.
348
+ */
349
+ 403: ForbiddenError;
350
+ /** Resource not found */
351
+ 404: NotFoundError;
352
+ /** Per-key rate limit exceeded. */
353
+ 429: RateLimitError;
354
+ /** Internal server error */
355
+ 500: InternalServerError;
356
+ };
357
+
358
+ export type ListBrandCitationURLsResponses = {
359
+ /** List cited URLs */
360
+ 200: CitationURLList;
361
+ };
362
+
363
+ export type ListBrandPromptPerformanceErrors = {
364
+ /** Invalid request data */
365
+ 400: ValidationError;
366
+ /** Authentication required */
367
+ 401: UnauthorizedError;
368
+ /**
369
+ * The key is valid but not permitted: a missing scope, an admin-only endpoint, or a write in
370
+ * read-only (demo) mode.
371
+ */
372
+ 403: ForbiddenError;
373
+ /** Resource not found */
374
+ 404: NotFoundError;
375
+ /** Per-key rate limit exceeded. */
376
+ 429: RateLimitError;
377
+ /** Internal server error */
378
+ 500: InternalServerError;
379
+ };
380
+
381
+ export type ListBrandPromptPerformanceResponses = {
382
+ /** List prompt performance */
383
+ 200: PromptPerformanceList;
384
+ };
385
+
386
+ export type GetBrandQueryFanoutErrors = {
387
+ /** Invalid request data */
388
+ 400: ValidationError;
389
+ /** Authentication required */
390
+ 401: UnauthorizedError;
391
+ /**
392
+ * The key is valid but not permitted: a missing scope, an admin-only endpoint, or a write in
393
+ * read-only (demo) mode.
394
+ */
395
+ 403: ForbiddenError;
396
+ /** Resource not found */
397
+ 404: NotFoundError;
398
+ /** Per-key rate limit exceeded. */
399
+ 429: RateLimitError;
400
+ /** Internal server error */
401
+ 500: InternalServerError;
402
+ };
403
+
404
+ export type GetBrandQueryFanoutResponses = {
405
+ /** Get query fan-out */
406
+ 200: BrandQueryFanout;
407
+ };
408
+
409
+ export type GetBrandAnalyticsParams = {
410
+ /**
411
+ * Inclusive lower bound of the window, an ISO 8601 timestamp such as `2026-01-01T00:00:00Z`. A
412
+ * bare `YYYY-MM-DD` is rejected: that is `/prompts/{promptId}/snapshot`'s spelling and means a
413
+ * local calendar day there.
414
+ */
415
+ start: WindowStart;
416
+ /**
417
+ * Exclusive upper bound of the window, an ISO 8601 timestamp. The window is half-open: a run at
418
+ * exactly `end` is outside it.
419
+ */
420
+ end: WindowEnd;
421
+ /** Restrict to one model, e.g. `chatgpt`. See `models.list()`. */
422
+ model?: ModelFilter;
423
+ /** Comma-separated prompt tags. Only prompts carrying at least one of them are counted. */
424
+ tags?: TagsFilter;
425
+ };
426
+
427
+ export type ListBrandCitationDomainsParams = {
428
+ /**
429
+ * Inclusive lower bound of the window, an ISO 8601 timestamp such as `2026-01-01T00:00:00Z`. A
430
+ * bare `YYYY-MM-DD` is rejected: that is `/prompts/{promptId}/snapshot`'s spelling and means a
431
+ * local calendar day there.
432
+ */
433
+ start: WindowStart;
434
+ /**
435
+ * Exclusive upper bound of the window, an ISO 8601 timestamp. The window is half-open: a run at
436
+ * exactly `end` is outside it.
437
+ */
438
+ end: WindowEnd;
439
+ /** Restrict to one model, e.g. `chatgpt`. See `models.list()`. */
440
+ model?: ModelFilter;
441
+ /** Comma-separated prompt tags. Only prompts carrying at least one of them are counted. */
442
+ tags?: TagsFilter;
443
+ };
444
+
445
+ export type ListBrandCitationURLsParams = {
446
+ /**
447
+ * Inclusive lower bound of the window, an ISO 8601 timestamp such as `2026-01-01T00:00:00Z`. A
448
+ * bare `YYYY-MM-DD` is rejected: that is `/prompts/{promptId}/snapshot`'s spelling and means a
449
+ * local calendar day there.
450
+ */
451
+ start: WindowStart;
452
+ /**
453
+ * Exclusive upper bound of the window, an ISO 8601 timestamp. The window is half-open: a run at
454
+ * exactly `end` is outside it.
455
+ */
456
+ end: WindowEnd;
457
+ /** Restrict to one model, e.g. `chatgpt`. See `models.list()`. */
458
+ model?: ModelFilter;
459
+ /** Comma-separated prompt tags. Only prompts carrying at least one of them are counted. */
460
+ tags?: TagsFilter;
461
+ };
462
+
463
+ export type ListBrandPromptPerformanceParams = {
464
+ /**
465
+ * Inclusive lower bound of the window, an ISO 8601 timestamp such as `2026-01-01T00:00:00Z`. A
466
+ * bare `YYYY-MM-DD` is rejected: that is `/prompts/{promptId}/snapshot`'s spelling and means a
467
+ * local calendar day there.
468
+ */
469
+ start: WindowStart;
470
+ /**
471
+ * Exclusive upper bound of the window, an ISO 8601 timestamp. The window is half-open: a run at
472
+ * exactly `end` is outside it.
473
+ */
474
+ end: WindowEnd;
475
+ /** Restrict to one model, e.g. `chatgpt`. See `models.list()`. */
476
+ model?: ModelFilter;
477
+ /** Comma-separated prompt tags. Only prompts carrying at least one of them are counted. */
478
+ tags?: TagsFilter;
479
+ };
480
+
481
+ export type GetBrandQueryFanoutParams = {
482
+ /**
483
+ * Inclusive lower bound of the window, an ISO 8601 timestamp such as `2026-01-01T00:00:00Z`. A
484
+ * bare `YYYY-MM-DD` is rejected: that is `/prompts/{promptId}/snapshot`'s spelling and means a
485
+ * local calendar day there.
486
+ */
487
+ start: WindowStart;
488
+ /**
489
+ * Exclusive upper bound of the window, an ISO 8601 timestamp. The window is half-open: a run at
490
+ * exactly `end` is outside it.
491
+ */
492
+ end: WindowEnd;
493
+ /** Restrict to one model, e.g. `chatgpt`. See `models.list()`. */
494
+ model?: ModelFilter;
495
+ /** Comma-separated prompt tags. Only prompts carrying at least one of them are counted. */
496
+ tags?: TagsFilter;
497
+ };
@@ -0,0 +1,228 @@
1
+ import type { ConflictError, PaymentRequiredError } from './shared/conflict-error';
2
+ import type {
3
+ ForbiddenError,
4
+ InternalServerError,
5
+ RateLimitError,
6
+ UnauthorizedError,
7
+ } from './shared/error';
8
+ import type { Limit } from './shared/limit';
9
+ import type { NotFoundError } from './shared/not-found-error';
10
+ import type { Page } from './shared/page';
11
+ import type { Pagination } from './shared/pagination';
12
+ import type { ValidationError } from './shared/validation-error';
13
+
14
+ export type Brand = {
15
+ aliases: Array<string>;
16
+ createdAt: Date;
17
+ /** Sampling cadence override in hours. Null means the plan cadence. */
18
+ delayOverrideHours: number | null;
19
+ /**
20
+ * Brand domains. The first entry is the primary website; remaining entries are additional
21
+ * domains.
22
+ */
23
+ domains: Array<string>;
24
+ enabled: boolean;
25
+ /** Models this brand is tracked on. Null means the deployment default. */
26
+ enabledModels: Array<string> | null;
27
+ /** User-supplied brand identifier (e.g. "acme") */
28
+ id: string;
29
+ name: string;
30
+ onboarded: boolean;
31
+ /** The organization that owns this brand and is billed for it. */
32
+ organizationId: string;
33
+ updatedAt: Date;
34
+ };
35
+
36
+ export type BrandsList = {
37
+ /**
38
+ * Deprecated: read `data` instead. Kept while the one known consumer migrates, and removed in a
39
+ * future release.
40
+ *
41
+ * @deprecated
42
+ */
43
+ brands: Array<Brand>;
44
+ /** The items on this page. Read this rather than the named key below. */
45
+ data: Array<Brand>;
46
+ pagination: Pagination;
47
+ };
48
+
49
+ export type ListBrandsErrors = {
50
+ /** Authentication required */
51
+ 401: UnauthorizedError;
52
+ /**
53
+ * The key is valid but not permitted: a missing scope, an admin-only endpoint, or a write in
54
+ * read-only (demo) mode.
55
+ */
56
+ 403: ForbiddenError;
57
+ /** Per-key rate limit exceeded. */
58
+ 429: RateLimitError;
59
+ /** Internal server error */
60
+ 500: InternalServerError;
61
+ };
62
+
63
+ export type ListBrandsResponses = {
64
+ /** Paginated list of brands */
65
+ 200: BrandsList;
66
+ };
67
+
68
+ export type CreateBrandErrors = {
69
+ /** Invalid request data */
70
+ 400: ValidationError;
71
+ /** Authentication required */
72
+ 401: UnauthorizedError;
73
+ /** The organization has no active subscription. Cloud deployments only. */
74
+ 402: PaymentRequiredError;
75
+ /**
76
+ * The key is valid but not permitted: a missing scope, an admin-only endpoint, or a write in
77
+ * read-only (demo) mode.
78
+ */
79
+ 403: ForbiddenError;
80
+ /** Resource not found */
81
+ 404: NotFoundError;
82
+ /** Resource already exists */
83
+ 409: ConflictError;
84
+ /** Per-key rate limit exceeded. */
85
+ 429: RateLimitError;
86
+ /** Internal server error */
87
+ 500: InternalServerError;
88
+ };
89
+
90
+ export type CreateBrandResponses = {
91
+ /** Brand created */
92
+ 201: Brand;
93
+ };
94
+
95
+ export type GetBrandErrors = {
96
+ /** Authentication required */
97
+ 401: UnauthorizedError;
98
+ /**
99
+ * The key is valid but not permitted: a missing scope, an admin-only endpoint, or a write in
100
+ * read-only (demo) mode.
101
+ */
102
+ 403: ForbiddenError;
103
+ /** Resource not found */
104
+ 404: NotFoundError;
105
+ /** Per-key rate limit exceeded. */
106
+ 429: RateLimitError;
107
+ /** Internal server error */
108
+ 500: InternalServerError;
109
+ };
110
+
111
+ export type GetBrandResponses = {
112
+ /** Brand */
113
+ 200: Brand;
114
+ };
115
+
116
+ export type UpdateBrandErrors = {
117
+ /** Invalid request data */
118
+ 400: ValidationError;
119
+ /** Authentication required */
120
+ 401: UnauthorizedError;
121
+ /** The organization has no active subscription. Cloud deployments only. */
122
+ 402: PaymentRequiredError;
123
+ /**
124
+ * The key is valid but not permitted: a missing scope, an admin-only endpoint, or a write in
125
+ * read-only (demo) mode.
126
+ */
127
+ 403: ForbiddenError;
128
+ /** Resource not found */
129
+ 404: NotFoundError;
130
+ /** Resource already exists */
131
+ 409: ConflictError;
132
+ /** Per-key rate limit exceeded. */
133
+ 429: RateLimitError;
134
+ /** Internal server error */
135
+ 500: InternalServerError;
136
+ };
137
+
138
+ export type UpdateBrandResponses = {
139
+ /** Brand updated */
140
+ 200: Brand;
141
+ };
142
+
143
+ export type ListBrandsParams = {
144
+ /**
145
+ * Page number, 1-based.
146
+ *
147
+ * @default 1
148
+ * @minimum 1
149
+ */
150
+ page?: Page;
151
+ /**
152
+ * Items per page. Values above the maximum are clamped, not rejected.
153
+ *
154
+ * @default 20
155
+ * @minimum 1
156
+ * @maximum 100
157
+ */
158
+ limit?: Limit;
159
+ };
160
+
161
+ /**
162
+ * Create a brand. Skips onboarding. The first entry in `domains` is treated as the brand's primary
163
+ * website; the rest are stored as additional domains.
164
+ */
165
+ export type CreateBrandParams = {
166
+ /** @minLength 1 */
167
+ id: string;
168
+ /** @minLength 1 */
169
+ name: string;
170
+ /**
171
+ * Brand domains. The first entry is the primary website; remaining entries are additional
172
+ * domains.
173
+ *
174
+ * @minItems 1
175
+ */
176
+ domains: Array<string>;
177
+ aliases?: Array<string>;
178
+ competitors?: Array<{
179
+ aliases?: Array<string>;
180
+ domains?: Array<string>;
181
+ /** @minLength 1 */
182
+ name: string;
183
+ }>;
184
+ prompts?: Array<{
185
+ /** @default true */
186
+ enabled?: boolean;
187
+ tags?: Array<string>;
188
+ /** @minLength 1 */
189
+ value: string;
190
+ }>;
191
+ /**
192
+ * Organization to create the brand in.
193
+ *
194
+ * | | Omitted | Present |
195
+ * | --- | --- | --- |
196
+ * | **Organization key** | creates in the key's own organization | must name the key's own organization; any other value is a `400` |
197
+ * | **Admin key** | provisions a new organization named after the brand id | creates in the named organization, which must already exist — `404` if it does not |
198
+ *
199
+ * An admin key omitting this field is currently the only way to create an organization over the
200
+ * API.
201
+ */
202
+ organizationId?: string;
203
+ };
204
+
205
+ /**
206
+ * Update brand-level fields. At least one field must be provided. Provided arrays replace the
207
+ * stored values verbatim. When `domains` is provided, the first entry becomes the primary website
208
+ * and the rest become additional domains. Prompts and competitors are managed via /prompts and
209
+ * /competitors.
210
+ */
211
+ export type UpdateBrandParams = {
212
+ /** @minLength 1 */
213
+ brandName?: string;
214
+ /**
215
+ * Brand domains. The first entry is the primary website; remaining entries are additional
216
+ * domains.
217
+ *
218
+ * @minItems 1
219
+ */
220
+ domains?: Array<string>;
221
+ aliases?: Array<string>;
222
+ /**
223
+ * Whether the brand is sampled at all. **Modifiable only with an instance admin key**: setting it
224
+ * with an organization key is a `403`, because disabling ends tracking silently while the plan
225
+ * keeps being billed and no dashboard control does it at any role.
226
+ */
227
+ enabled?: boolean;
228
+ };