@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.
- package/LICENSE.md +21 -0
- package/README.md +326 -2
- package/dist/calls/index.d.mts +288 -0
- package/dist/calls/index.d.mts.map +1 -0
- package/dist/calls/index.mjs +390 -0
- package/dist/calls/index.mjs.map +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +1031 -0
- package/dist/index.mjs.map +1 -0
- package/dist/request-options-B9S9d24M.d.mts +1549 -0
- package/dist/request-options-B9S9d24M.d.mts.map +1 -0
- package/dist/tools-7Hs5J2xb.d.mts +1945 -0
- package/dist/tools-7Hs5J2xb.d.mts.map +1 -0
- package/dist/tools-B1lVtYAr.mjs +2459 -0
- package/dist/tools-B1lVtYAr.mjs.map +1 -0
- package/dist/types/index.d.mts +2 -0
- package/dist/types/index.mjs +1 -0
- package/package.json +68 -4
- package/src/calls/brands-analytics-get.ts +33 -0
- package/src/calls/brands-citations-domains-list.ts +36 -0
- package/src/calls/brands-citations-urls-list.ts +32 -0
- package/src/calls/brands-create.ts +19 -0
- package/src/calls/brands-get.ts +19 -0
- package/src/calls/brands-list.ts +18 -0
- package/src/calls/brands-opportunities-get.ts +42 -0
- package/src/calls/brands-prompt-performance-list.ts +39 -0
- package/src/calls/brands-query-fanout-get.ts +30 -0
- package/src/calls/brands-tags-list.ts +28 -0
- package/src/calls/brands-update.ts +20 -0
- package/src/calls/competitors-create.ts +23 -0
- package/src/calls/competitors-delete.ts +19 -0
- package/src/calls/competitors-get.ts +19 -0
- package/src/calls/competitors-list.ts +23 -0
- package/src/calls/competitors-update.ts +24 -0
- package/src/calls/index.ts +33 -0
- package/src/calls/me-get.ts +18 -0
- package/src/calls/models-list.ts +20 -0
- package/src/calls/organizations-billing-get.ts +37 -0
- package/src/calls/organizations-get.ts +24 -0
- package/src/calls/organizations-list.ts +27 -0
- package/src/calls/prompts-create.ts +27 -0
- package/src/calls/prompts-delete.ts +28 -0
- package/src/calls/prompts-get.ts +23 -0
- package/src/calls/prompts-list.ts +28 -0
- package/src/calls/prompts-runs-get.ts +27 -0
- package/src/calls/prompts-runs-list.ts +30 -0
- package/src/calls/prompts-snapshot-get.ts +28 -0
- package/src/calls/prompts-update.ts +29 -0
- package/src/calls/reports-create.ts +31 -0
- package/src/calls/reports-get.ts +27 -0
- package/src/calls/reports-list.ts +28 -0
- package/src/calls/tools-analyze.ts +26 -0
- package/src/client.ts +649 -0
- package/src/index.ts +21 -0
- package/src/internal/binding/rest/binding.ts +127 -0
- package/src/internal/binding/rest/errors.ts +107 -0
- package/src/internal/binding/rest/path.ts +9 -0
- package/src/internal/binding/rest/url.ts +97 -0
- package/src/internal/codec/json.ts +66 -0
- package/src/internal/codec/registry.ts +55 -0
- package/src/internal/core/backoff.ts +170 -0
- package/src/internal/core/body.ts +54 -0
- package/src/internal/core/browser.ts +11 -0
- package/src/internal/core/call-promise.ts +145 -0
- package/src/internal/core/callable.ts +11 -0
- package/src/internal/core/client.ts +89 -0
- package/src/internal/core/config.ts +84 -0
- package/src/internal/core/credentials.ts +40 -0
- package/src/internal/core/dispatch.ts +225 -0
- package/src/internal/core/env.ts +68 -0
- package/src/internal/core/errors.ts +431 -0
- package/src/internal/core/features.ts +60 -0
- package/src/internal/core/lazy-promise.ts +39 -0
- package/src/internal/core/metadata.ts +79 -0
- package/src/internal/core/page.ts +402 -0
- package/src/internal/core/params.ts +98 -0
- package/src/internal/core/protocol.ts +17 -0
- package/src/internal/core/read-reply.ts +7 -0
- package/src/internal/core/text.ts +7 -0
- package/src/internal/core/types.ts +554 -0
- package/src/internal/feature/auth.ts +201 -0
- package/src/internal/feature/interceptors.ts +36 -0
- package/src/internal/feature/logger.ts +222 -0
- package/src/internal/feature/retry.ts +168 -0
- package/src/internal/feature/rules.ts +54 -0
- package/src/internal/feature/timeout.ts +146 -0
- package/src/internal/feature/validate.ts +82 -0
- package/src/internal/transport/fetch.ts +82 -0
- package/src/resources/analytics.ts +364 -0
- package/src/resources/brands.ts +288 -0
- package/src/resources/competitors.ts +213 -0
- package/src/resources/identity.ts +49 -0
- package/src/resources/models.ts +32 -0
- package/src/resources/opportunities.ts +81 -0
- package/src/resources/organizations.ts +182 -0
- package/src/resources/prompts.ts +293 -0
- package/src/resources/reports.ts +212 -0
- package/src/resources/runs.ts +124 -0
- package/src/resources/shared/auth.ts +13 -0
- package/src/resources/shared/request-options.ts +26 -0
- package/src/resources/shared/resource.ts +23 -0
- package/src/resources/shared/rule.ts +25 -0
- package/src/resources/snapshots.ts +54 -0
- package/src/resources/tags.ts +46 -0
- package/src/resources/tools.ts +69 -0
- package/src/types/analytics.ts +497 -0
- package/src/types/brands.ts +228 -0
- package/src/types/competitors.ts +196 -0
- package/src/types/identity.ts +55 -0
- package/src/types/index.ts +163 -0
- package/src/types/models.ts +40 -0
- package/src/types/opportunities.ts +84 -0
- package/src/types/organizations.ts +157 -0
- package/src/types/prompts.ts +231 -0
- package/src/types/reports.ts +266 -0
- package/src/types/runs.ts +131 -0
- package/src/types/shared/brand-id-path.ts +2 -0
- package/src/types/shared/conflict-error.ts +7 -0
- package/src/types/shared/error.ts +29 -0
- package/src/types/shared/limit.ts +8 -0
- package/src/types/shared/mention-entry.ts +21 -0
- package/src/types/shared/model-filter.ts +15 -0
- package/src/types/shared/not-found-error.ts +4 -0
- package/src/types/shared/page.ts +7 -0
- package/src/types/shared/pagination.ts +7 -0
- package/src/types/shared/validation-error.ts +4 -0
- package/src/types/snapshots.ts +88 -0
- package/src/types/tags.ts +47 -0
- package/src/types/tools.ts +78 -0
|
@@ -0,0 +1,231 @@
|
|
|
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 { NotFoundError } from './shared/not-found-error';
|
|
9
|
+
import type { Page } from './shared/page';
|
|
10
|
+
import type { ValidationError } from './shared/validation-error';
|
|
11
|
+
|
|
12
|
+
export type Prompt = {
|
|
13
|
+
/** Brand identifier this prompt belongs to */
|
|
14
|
+
brandId: string;
|
|
15
|
+
/** Timestamp when the prompt was created */
|
|
16
|
+
createdAt: Date;
|
|
17
|
+
/** Whether the prompt is currently enabled */
|
|
18
|
+
enabled: boolean;
|
|
19
|
+
/** Unique identifier for the prompt */
|
|
20
|
+
id: string;
|
|
21
|
+
/** Models this prompt is tracked on grounded. Each entry spends one premium pairing. */
|
|
22
|
+
premiumModels: Array<string>;
|
|
23
|
+
/** Auto-computed system tags (e.g., 'branded', 'unbranded'). Read-only. */
|
|
24
|
+
systemTags: Array<string>;
|
|
25
|
+
/** User-defined tags for categorizing this prompt */
|
|
26
|
+
tags: Array<string>;
|
|
27
|
+
/** Timestamp when the prompt was last updated */
|
|
28
|
+
updatedAt: Date;
|
|
29
|
+
/** The actual prompt text */
|
|
30
|
+
value: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type ListPromptsErrors = {
|
|
34
|
+
/** Authentication required */
|
|
35
|
+
401: UnauthorizedError;
|
|
36
|
+
/**
|
|
37
|
+
* The key is valid but not permitted: a missing scope, an admin-only endpoint, or a write in
|
|
38
|
+
* read-only (demo) mode.
|
|
39
|
+
*/
|
|
40
|
+
403: ForbiddenError;
|
|
41
|
+
/** Per-key rate limit exceeded. */
|
|
42
|
+
429: RateLimitError;
|
|
43
|
+
/** Internal server error */
|
|
44
|
+
500: InternalServerError;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type ListPromptsResponses = {
|
|
48
|
+
/** List of prompts */
|
|
49
|
+
200: {
|
|
50
|
+
/** The items on this page. Read this rather than the named key below. */
|
|
51
|
+
data: Array<Prompt>;
|
|
52
|
+
pagination: {
|
|
53
|
+
limit: number;
|
|
54
|
+
page: number;
|
|
55
|
+
total: number;
|
|
56
|
+
totalPages: number;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Deprecated: read `data` instead. Kept while the one known consumer migrates, and removed in a
|
|
60
|
+
* future release.
|
|
61
|
+
*
|
|
62
|
+
* @deprecated
|
|
63
|
+
*/
|
|
64
|
+
prompts: Array<Prompt>;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export type ListPromptsResponse = ListPromptsResponses[keyof ListPromptsResponses];
|
|
69
|
+
|
|
70
|
+
export type CreatePromptErrors = {
|
|
71
|
+
/** Invalid request data */
|
|
72
|
+
400: ValidationError;
|
|
73
|
+
/** Authentication required */
|
|
74
|
+
401: UnauthorizedError;
|
|
75
|
+
/** The organization has no active subscription. Cloud deployments only. */
|
|
76
|
+
402: PaymentRequiredError;
|
|
77
|
+
/**
|
|
78
|
+
* The key is valid but not permitted: a missing scope, an admin-only endpoint, or a write in
|
|
79
|
+
* read-only (demo) mode.
|
|
80
|
+
*/
|
|
81
|
+
403: ForbiddenError;
|
|
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 CreatePromptResponses = {
|
|
91
|
+
/** Prompt created successfully */
|
|
92
|
+
201: Prompt;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export type DeletePromptErrors = {
|
|
96
|
+
/** Invalid request data */
|
|
97
|
+
400: ValidationError;
|
|
98
|
+
/** Authentication required */
|
|
99
|
+
401: UnauthorizedError;
|
|
100
|
+
/** The organization has no active subscription. Cloud deployments only. */
|
|
101
|
+
402: PaymentRequiredError;
|
|
102
|
+
/**
|
|
103
|
+
* The key is valid but not permitted: a missing scope, an admin-only endpoint, or a write in
|
|
104
|
+
* read-only (demo) mode.
|
|
105
|
+
*/
|
|
106
|
+
403: ForbiddenError;
|
|
107
|
+
/** Resource not found */
|
|
108
|
+
404: NotFoundError;
|
|
109
|
+
/** Resource already exists */
|
|
110
|
+
409: ConflictError;
|
|
111
|
+
/** Per-key rate limit exceeded. */
|
|
112
|
+
429: RateLimitError;
|
|
113
|
+
/** Internal server error */
|
|
114
|
+
500: InternalServerError;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export type DeletePromptResponses = {
|
|
118
|
+
/** Prompt deleted (returns the deleted prompt) */
|
|
119
|
+
200: Prompt & {
|
|
120
|
+
/** Number of related prompt_runs rows deleted by the cascade. */
|
|
121
|
+
deletedRunsCount: number;
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export type DeletePromptResponse = DeletePromptResponses[keyof DeletePromptResponses];
|
|
126
|
+
|
|
127
|
+
export type GetPromptErrors = {
|
|
128
|
+
/** Invalid request data */
|
|
129
|
+
400: ValidationError;
|
|
130
|
+
/** Authentication required */
|
|
131
|
+
401: UnauthorizedError;
|
|
132
|
+
/**
|
|
133
|
+
* The key is valid but not permitted: a missing scope, an admin-only endpoint, or a write in
|
|
134
|
+
* read-only (demo) mode.
|
|
135
|
+
*/
|
|
136
|
+
403: ForbiddenError;
|
|
137
|
+
/** Resource not found */
|
|
138
|
+
404: NotFoundError;
|
|
139
|
+
/** Per-key rate limit exceeded. */
|
|
140
|
+
429: RateLimitError;
|
|
141
|
+
/** Internal server error */
|
|
142
|
+
500: InternalServerError;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export type GetPromptResponses = {
|
|
146
|
+
/** Prompt details */
|
|
147
|
+
200: Prompt;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export type UpdatePromptErrors = {
|
|
151
|
+
/** Invalid request data */
|
|
152
|
+
400: ValidationError;
|
|
153
|
+
/** Authentication required */
|
|
154
|
+
401: UnauthorizedError;
|
|
155
|
+
/** The organization has no active subscription. Cloud deployments only. */
|
|
156
|
+
402: PaymentRequiredError;
|
|
157
|
+
/**
|
|
158
|
+
* The key is valid but not permitted: a missing scope, an admin-only endpoint, or a write in
|
|
159
|
+
* read-only (demo) mode.
|
|
160
|
+
*/
|
|
161
|
+
403: ForbiddenError;
|
|
162
|
+
/** Resource not found */
|
|
163
|
+
404: NotFoundError;
|
|
164
|
+
/** Resource already exists */
|
|
165
|
+
409: ConflictError;
|
|
166
|
+
/** Per-key rate limit exceeded. */
|
|
167
|
+
429: RateLimitError;
|
|
168
|
+
/** Internal server error */
|
|
169
|
+
500: InternalServerError;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export type UpdatePromptResponses = {
|
|
173
|
+
/** Prompt updated successfully */
|
|
174
|
+
200: Prompt;
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export type ListPromptsParams = {
|
|
178
|
+
/** Filter prompts by brand ID */
|
|
179
|
+
brandId?: string;
|
|
180
|
+
/**
|
|
181
|
+
* Page number, 1-based.
|
|
182
|
+
*
|
|
183
|
+
* @default 1
|
|
184
|
+
* @minimum 1
|
|
185
|
+
*/
|
|
186
|
+
page?: Page;
|
|
187
|
+
/**
|
|
188
|
+
* Items per page. Values above the maximum are clamped, not rejected. This list had no ceiling
|
|
189
|
+
* before, so the maximum is set to bound a runaway query rather than to change what an existing
|
|
190
|
+
* caller gets back.
|
|
191
|
+
*
|
|
192
|
+
* @default 20
|
|
193
|
+
* @minimum 1
|
|
194
|
+
* @maximum 1000
|
|
195
|
+
*/
|
|
196
|
+
limit?: number;
|
|
197
|
+
/** Only prompts with this tracking state. */
|
|
198
|
+
enabled?: boolean;
|
|
199
|
+
/** Comma-separated tags. A prompt matches if it carries any of them. */
|
|
200
|
+
tags?: string;
|
|
201
|
+
/** Case-insensitive substring match on prompt text. */
|
|
202
|
+
q?: string;
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
export type CreatePromptParams = {
|
|
206
|
+
/** Brand identifier this prompt belongs to */
|
|
207
|
+
brandId: string;
|
|
208
|
+
/**
|
|
209
|
+
* The prompt text
|
|
210
|
+
*
|
|
211
|
+
* @minLength 1
|
|
212
|
+
*/
|
|
213
|
+
value: string;
|
|
214
|
+
/** User-defined tags for categorizing this prompt */
|
|
215
|
+
tags?: Array<string>;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
export type UpdatePromptParams = {
|
|
219
|
+
/**
|
|
220
|
+
* The prompt text
|
|
221
|
+
*
|
|
222
|
+
* @minLength 1
|
|
223
|
+
*/
|
|
224
|
+
value?: string;
|
|
225
|
+
/** Whether the prompt is enabled */
|
|
226
|
+
enabled?: boolean;
|
|
227
|
+
/** User-defined tags for categorizing this prompt */
|
|
228
|
+
tags?: Array<string>;
|
|
229
|
+
/** Replaces the prompt's grounded models. Checked against the organization's premium pool. */
|
|
230
|
+
premiumModels?: Array<string>;
|
|
231
|
+
};
|
|
@@ -0,0 +1,266 @@
|
|
|
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 { MentionsSummary } from './shared/mention-entry';
|
|
10
|
+
import type { NotFoundError } from './shared/not-found-error';
|
|
11
|
+
import type { Page } from './shared/page';
|
|
12
|
+
import type { ValidationError } from './shared/validation-error';
|
|
13
|
+
|
|
14
|
+
export type ReportSummary = {
|
|
15
|
+
/** Other names counted as brand mentions */
|
|
16
|
+
brandAliases: Array<string>;
|
|
17
|
+
/** Brand name analyzed */
|
|
18
|
+
brandName: string;
|
|
19
|
+
/** Brand website URL */
|
|
20
|
+
brandWebsite: string;
|
|
21
|
+
/** Timestamp when the report completed */
|
|
22
|
+
completedAt: Date | null;
|
|
23
|
+
/** Timestamp when the report was created */
|
|
24
|
+
createdAt: Date;
|
|
25
|
+
/** Unique identifier for the report */
|
|
26
|
+
id: string;
|
|
27
|
+
/** Current report status */
|
|
28
|
+
status: 'pending' | 'processing' | 'completed' | 'failed';
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Per-prompt snapshot of raw mention data from a report. Consumers compute SoV and other derived
|
|
33
|
+
* metrics.
|
|
34
|
+
*/
|
|
35
|
+
export type ReportPromptSnapshot = {
|
|
36
|
+
mentions: MentionsSummary;
|
|
37
|
+
/** The prompt text that was evaluated */
|
|
38
|
+
promptValue: string;
|
|
39
|
+
/** Number of evaluation runs for this prompt */
|
|
40
|
+
totalRuns: number;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type ListReportsErrors = {
|
|
44
|
+
/** Authentication required */
|
|
45
|
+
401: UnauthorizedError;
|
|
46
|
+
/**
|
|
47
|
+
* The key is valid but not permitted: a missing scope, an admin-only endpoint, or a write in
|
|
48
|
+
* read-only (demo) mode.
|
|
49
|
+
*/
|
|
50
|
+
403: ForbiddenError;
|
|
51
|
+
/** Per-key rate limit exceeded. */
|
|
52
|
+
429: RateLimitError;
|
|
53
|
+
/** Internal server error */
|
|
54
|
+
500: InternalServerError;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export type ListReportsResponses = {
|
|
58
|
+
/** Paginated list of reports */
|
|
59
|
+
200: {
|
|
60
|
+
/** The items on this page. Read this rather than the named key below. */
|
|
61
|
+
data: Array<ReportSummary>;
|
|
62
|
+
pagination: {
|
|
63
|
+
limit: number;
|
|
64
|
+
page: number;
|
|
65
|
+
total: number;
|
|
66
|
+
totalPages: number;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Deprecated: read `data` instead. Kept while the one known consumer migrates, and removed in a
|
|
70
|
+
* future release.
|
|
71
|
+
*
|
|
72
|
+
* @deprecated
|
|
73
|
+
*/
|
|
74
|
+
reports: Array<ReportSummary>;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export type ListReportsResponse = ListReportsResponses[keyof ListReportsResponses];
|
|
79
|
+
|
|
80
|
+
export type CreateReportErrors = {
|
|
81
|
+
/** Invalid request data */
|
|
82
|
+
400: ValidationError;
|
|
83
|
+
/** Authentication required */
|
|
84
|
+
401: UnauthorizedError;
|
|
85
|
+
/** The organization has no active subscription. Cloud deployments only. */
|
|
86
|
+
402: PaymentRequiredError;
|
|
87
|
+
/**
|
|
88
|
+
* The key is valid but not permitted: a missing scope, an admin-only endpoint, or a write in
|
|
89
|
+
* read-only (demo) mode.
|
|
90
|
+
*/
|
|
91
|
+
403: ForbiddenError;
|
|
92
|
+
/** Resource already exists */
|
|
93
|
+
409: ConflictError;
|
|
94
|
+
/** Per-key rate limit exceeded. */
|
|
95
|
+
429: RateLimitError;
|
|
96
|
+
/** Internal server error */
|
|
97
|
+
500: InternalServerError;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export type CreateReportResponses = {
|
|
101
|
+
/** Report created and queued for generation */
|
|
102
|
+
201: {
|
|
103
|
+
brandAliases: Array<string>;
|
|
104
|
+
brandName: string;
|
|
105
|
+
brandWebsite: string;
|
|
106
|
+
createdAt: Date;
|
|
107
|
+
/** Unique identifier for the created report */
|
|
108
|
+
reportId: string;
|
|
109
|
+
/** Initial report status */
|
|
110
|
+
status: 'pending';
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export type CreateReportResponse = CreateReportResponses[keyof CreateReportResponses];
|
|
115
|
+
|
|
116
|
+
export type GetReportErrors = {
|
|
117
|
+
/** Invalid request data */
|
|
118
|
+
400: ValidationError;
|
|
119
|
+
/** Authentication required */
|
|
120
|
+
401: UnauthorizedError;
|
|
121
|
+
/**
|
|
122
|
+
* The key is valid but not permitted: a missing scope, an admin-only endpoint, or a write in
|
|
123
|
+
* read-only (demo) mode.
|
|
124
|
+
*/
|
|
125
|
+
403: ForbiddenError;
|
|
126
|
+
/** Resource not found */
|
|
127
|
+
404: NotFoundError;
|
|
128
|
+
/** Per-key rate limit exceeded. */
|
|
129
|
+
429: RateLimitError;
|
|
130
|
+
/** Internal server error */
|
|
131
|
+
500: InternalServerError;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export type GetReportResponses = {
|
|
135
|
+
/**
|
|
136
|
+
* Report status and data. When status is 'completed', includes per-prompt snapshot data with raw
|
|
137
|
+
* mention counts.
|
|
138
|
+
*/
|
|
139
|
+
200: {
|
|
140
|
+
brandAliases: Array<string>;
|
|
141
|
+
brandName: string;
|
|
142
|
+
brandWebsite: string;
|
|
143
|
+
completedAt: Date | null;
|
|
144
|
+
createdAt: Date;
|
|
145
|
+
/** Generation progress percentage (0-100). Available while processing. */
|
|
146
|
+
progress?: number;
|
|
147
|
+
/** Per-prompt snapshot data. Only present when status is 'completed'. */
|
|
148
|
+
prompts?: Array<ReportPromptSnapshot>;
|
|
149
|
+
reportId: string;
|
|
150
|
+
status: 'pending' | 'processing' | 'completed' | 'failed';
|
|
151
|
+
/**
|
|
152
|
+
* Derived stats (SoV, visibility, etc.). Format may change between versions. Only present when
|
|
153
|
+
* status is 'completed'.
|
|
154
|
+
*/
|
|
155
|
+
unstable?: {
|
|
156
|
+
/** Per-competitor SoV breakdown, sorted by SoV descending */
|
|
157
|
+
competitors?: Array<{
|
|
158
|
+
/** Competitor name */
|
|
159
|
+
name: string;
|
|
160
|
+
/** Number of individual prompt runs where this competitor was mentioned */
|
|
161
|
+
promptRunsWithMentions: number;
|
|
162
|
+
/** Number of prompts where this competitor was mentioned in at least one run */
|
|
163
|
+
promptsWithMentions: number;
|
|
164
|
+
/**
|
|
165
|
+
* Share of voice (0-1): this competitor's mentions / total mentions (brand + all
|
|
166
|
+
* competitors)
|
|
167
|
+
*
|
|
168
|
+
* @minimum 0
|
|
169
|
+
* @maximum 1
|
|
170
|
+
*/
|
|
171
|
+
sov: number;
|
|
172
|
+
/**
|
|
173
|
+
* Visibility (0-1): prompt runs mentioning this competitor / total prompt runs
|
|
174
|
+
*
|
|
175
|
+
* @minimum 0
|
|
176
|
+
* @maximum 1
|
|
177
|
+
*/
|
|
178
|
+
visibility: number;
|
|
179
|
+
}>;
|
|
180
|
+
/** Number of individual prompt runs where the brand was mentioned */
|
|
181
|
+
promptRunsWithBrandMentions?: number;
|
|
182
|
+
/** Number of prompts where the brand was mentioned in at least one prompt run */
|
|
183
|
+
promptsWithBrandMentions?: number;
|
|
184
|
+
/**
|
|
185
|
+
* Overall share of voice (0-1): brand_mentions / (brand_mentions + competitor_mentions). Null
|
|
186
|
+
* when no mentions at all.
|
|
187
|
+
*
|
|
188
|
+
* @minimum 0
|
|
189
|
+
* @maximum 1
|
|
190
|
+
*/
|
|
191
|
+
sov?: number | null;
|
|
192
|
+
/**
|
|
193
|
+
* Total number of prompt runs across all prompts (each prompt is executed multiple times
|
|
194
|
+
* across different AI engines)
|
|
195
|
+
*/
|
|
196
|
+
totalPromptRuns?: number;
|
|
197
|
+
/** Total number of prompts evaluated */
|
|
198
|
+
totalPrompts?: number;
|
|
199
|
+
/**
|
|
200
|
+
* Brand visibility (0-1): brand_mentions / total_prompt_runs (how often the brand appears at
|
|
201
|
+
* all across all prompt runs)
|
|
202
|
+
*
|
|
203
|
+
* @minimum 0
|
|
204
|
+
* @maximum 1
|
|
205
|
+
*/
|
|
206
|
+
visibility?: number;
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
export type GetReportResponse = GetReportResponses[keyof GetReportResponses];
|
|
212
|
+
|
|
213
|
+
export type ListReportsParams = {
|
|
214
|
+
/**
|
|
215
|
+
* Page number, 1-based.
|
|
216
|
+
*
|
|
217
|
+
* @default 1
|
|
218
|
+
* @minimum 1
|
|
219
|
+
*/
|
|
220
|
+
page?: Page;
|
|
221
|
+
/**
|
|
222
|
+
* Items per page. Values above the maximum are clamped, not rejected.
|
|
223
|
+
*
|
|
224
|
+
* @default 20
|
|
225
|
+
* @minimum 1
|
|
226
|
+
* @maximum 100
|
|
227
|
+
*/
|
|
228
|
+
limit?: Limit;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
export type CreateReportParams = {
|
|
232
|
+
/**
|
|
233
|
+
* The brand name to analyze
|
|
234
|
+
*
|
|
235
|
+
* @minLength 1
|
|
236
|
+
*/
|
|
237
|
+
brandName: string;
|
|
238
|
+
/**
|
|
239
|
+
* Other names the brand goes by (spellings, abbreviations, product names). A mention of any of
|
|
240
|
+
* them counts as a brand mention.
|
|
241
|
+
*
|
|
242
|
+
* @maxItems 10
|
|
243
|
+
*/
|
|
244
|
+
brandAliases?: Array<string>;
|
|
245
|
+
/**
|
|
246
|
+
* The brand's website — a domain (nike.com) or a full URL. A URL with a path (e.g.
|
|
247
|
+
* https://www.nike.com/golf) scopes the analysis to that page; mentions are tracked against its
|
|
248
|
+
* domain either way.
|
|
249
|
+
*
|
|
250
|
+
* @minLength 1
|
|
251
|
+
*/
|
|
252
|
+
brandWebsite: string;
|
|
253
|
+
/** Optional list of custom prompts to include in the report */
|
|
254
|
+
manualPrompts?: Array<string>;
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
export type GetReportParams = {
|
|
258
|
+
/**
|
|
259
|
+
* Number of top competitor entities to return in each prompt's mentionsTopK
|
|
260
|
+
*
|
|
261
|
+
* @default 5
|
|
262
|
+
* @minimum 1
|
|
263
|
+
* @maximum 50
|
|
264
|
+
*/
|
|
265
|
+
kMentions?: number;
|
|
266
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ForbiddenError,
|
|
3
|
+
InternalServerError,
|
|
4
|
+
RateLimitError,
|
|
5
|
+
UnauthorizedError,
|
|
6
|
+
} from './shared/error';
|
|
7
|
+
import type { Limit } from './shared/limit';
|
|
8
|
+
import type { ModelFilter, WindowEnd, WindowStart } from './shared/model-filter';
|
|
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
|
+
/** A single model answer, without its text. Fetch `prompts.runs.get()` for the answer itself. */
|
|
15
|
+
export type RunSummary = {
|
|
16
|
+
brandId: string;
|
|
17
|
+
brandMentioned: boolean;
|
|
18
|
+
citationCount: number;
|
|
19
|
+
competitorsMentioned: Array<string>;
|
|
20
|
+
createdAt: Date;
|
|
21
|
+
id: string;
|
|
22
|
+
model: string;
|
|
23
|
+
promptId: string;
|
|
24
|
+
/** How the answer was obtained. Informational; not a stable enum. */
|
|
25
|
+
provider: string | null;
|
|
26
|
+
/** Searches the engine ran, where it exposes them. */
|
|
27
|
+
webQueries: Array<string>;
|
|
28
|
+
/** Whether the engine answered with its own web search on. */
|
|
29
|
+
webSearchEnabled: boolean;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type RunCitation = {
|
|
33
|
+
/** Position within the answer's citation list. */
|
|
34
|
+
citationIndex: number;
|
|
35
|
+
domain: string;
|
|
36
|
+
title: string | null;
|
|
37
|
+
url: string;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** One model answer with its normalized text and citations. */
|
|
41
|
+
export type Run = RunSummary & {
|
|
42
|
+
answer: {
|
|
43
|
+
/**
|
|
44
|
+
* The answer, normalized out of the provider's response. Null when nothing could be extracted.
|
|
45
|
+
*/
|
|
46
|
+
text: string | null;
|
|
47
|
+
};
|
|
48
|
+
citations: Array<RunCitation>;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export type RunList = {
|
|
52
|
+
data: Array<RunSummary>;
|
|
53
|
+
pagination: Pagination;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export type ListPromptRunsErrors = {
|
|
57
|
+
/** Invalid request data */
|
|
58
|
+
400: ValidationError;
|
|
59
|
+
/** Authentication required */
|
|
60
|
+
401: UnauthorizedError;
|
|
61
|
+
/**
|
|
62
|
+
* The key is valid but not permitted: a missing scope, an admin-only endpoint, or a write in
|
|
63
|
+
* read-only (demo) mode.
|
|
64
|
+
*/
|
|
65
|
+
403: ForbiddenError;
|
|
66
|
+
/** Resource not found */
|
|
67
|
+
404: NotFoundError;
|
|
68
|
+
/** Per-key rate limit exceeded. */
|
|
69
|
+
429: RateLimitError;
|
|
70
|
+
/** Internal server error */
|
|
71
|
+
500: InternalServerError;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export type ListPromptRunsResponses = {
|
|
75
|
+
/** List runs for a prompt */
|
|
76
|
+
200: RunList;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export type GetRunErrors = {
|
|
80
|
+
/** Invalid request data */
|
|
81
|
+
400: ValidationError;
|
|
82
|
+
/** Authentication required */
|
|
83
|
+
401: UnauthorizedError;
|
|
84
|
+
/**
|
|
85
|
+
* The key is valid but not permitted: a missing scope, an admin-only endpoint, or a write in
|
|
86
|
+
* read-only (demo) mode.
|
|
87
|
+
*/
|
|
88
|
+
403: ForbiddenError;
|
|
89
|
+
/** Resource not found */
|
|
90
|
+
404: NotFoundError;
|
|
91
|
+
/** Per-key rate limit exceeded. */
|
|
92
|
+
429: RateLimitError;
|
|
93
|
+
/** Internal server error */
|
|
94
|
+
500: InternalServerError;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export type GetRunResponses = {
|
|
98
|
+
/** Get a run */
|
|
99
|
+
200: Run;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export type ListPromptRunsParams = {
|
|
103
|
+
/**
|
|
104
|
+
* Inclusive lower bound of the window, an ISO 8601 timestamp such as `2026-01-01T00:00:00Z`. A
|
|
105
|
+
* bare `YYYY-MM-DD` is rejected: that is `/prompts/{promptId}/snapshot`'s spelling and means a
|
|
106
|
+
* local calendar day there.
|
|
107
|
+
*/
|
|
108
|
+
start: WindowStart;
|
|
109
|
+
/**
|
|
110
|
+
* Exclusive upper bound of the window, an ISO 8601 timestamp. The window is half-open: a run at
|
|
111
|
+
* exactly `end` is outside it.
|
|
112
|
+
*/
|
|
113
|
+
end: WindowEnd;
|
|
114
|
+
/** Restrict to one model, e.g. `chatgpt`. See `models.list()`. */
|
|
115
|
+
model?: ModelFilter;
|
|
116
|
+
/**
|
|
117
|
+
* Page number, 1-based.
|
|
118
|
+
*
|
|
119
|
+
* @default 1
|
|
120
|
+
* @minimum 1
|
|
121
|
+
*/
|
|
122
|
+
page?: Page;
|
|
123
|
+
/**
|
|
124
|
+
* Items per page. Values above the maximum are clamped, not rejected.
|
|
125
|
+
*
|
|
126
|
+
* @default 20
|
|
127
|
+
* @minimum 1
|
|
128
|
+
* @maximum 100
|
|
129
|
+
*/
|
|
130
|
+
limit?: Limit;
|
|
131
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type Error = {
|
|
2
|
+
/**
|
|
3
|
+
* Stable machine-readable code. Deliberately not an enum: new values are added without a version
|
|
4
|
+
* bump, so treat an unrecognized one as its HTTP status implies. Currently: `unauthorized`,
|
|
5
|
+
* `insufficient_scope`, `forbidden`, `not_found`, `validation_error`, `conflict`, `rate_limited`,
|
|
6
|
+
* `method_not_allowed`, `read_only`, `no_active_plan`, `brand_limit`, `prompt_limit`,
|
|
7
|
+
* `model_not_in_plan`, `model_picks_exceeded`, `premium_not_in_plan`, `premium_pool_exhausted`,
|
|
8
|
+
* `cadence_faster_than_plan`, `internal_error`.
|
|
9
|
+
*/
|
|
10
|
+
code?: string;
|
|
11
|
+
/** Error type */
|
|
12
|
+
error: string;
|
|
13
|
+
/** Detailed error message */
|
|
14
|
+
message?: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** Authentication required */
|
|
18
|
+
export type UnauthorizedError = Error;
|
|
19
|
+
|
|
20
|
+
export type InternalServerError = Error;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The key is valid but not permitted: a missing scope, an admin-only endpoint, or a write in
|
|
24
|
+
* read-only (demo) mode.
|
|
25
|
+
*/
|
|
26
|
+
export type ForbiddenError = Error;
|
|
27
|
+
|
|
28
|
+
/** Per-key rate limit exceeded. */
|
|
29
|
+
export type RateLimitError = Error;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Aggregated mention counts for a prompt across its evaluation runs. */
|
|
2
|
+
export type MentionsSummary = {
|
|
3
|
+
/** Number of runs where the brand was mentioned */
|
|
4
|
+
brandMentionsTotal: number;
|
|
5
|
+
/**
|
|
6
|
+
* Total count of individual competitor mentions across all runs (a single run mentioning 3
|
|
7
|
+
* competitors counts as 3)
|
|
8
|
+
*/
|
|
9
|
+
competitorMentionsTotal: number;
|
|
10
|
+
/** Top-K competitor entities ranked by mention count */
|
|
11
|
+
mentionsTopK: Array<MentionEntry>;
|
|
12
|
+
/** Total brand + competitor mentions across all runs */
|
|
13
|
+
mentionsTotal: number;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type MentionEntry = {
|
|
17
|
+
/** Number of runs where this entity was mentioned */
|
|
18
|
+
count: number;
|
|
19
|
+
/** Competitor entity name */
|
|
20
|
+
entity: string;
|
|
21
|
+
};
|