@elmohq/sdk 0.0.0-stage → 0.1.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.
- package/LICENSE.md +21 -0
- package/README.md +325 -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 +1029 -0
- package/dist/index.mjs.map +1 -0
- package/dist/request-options-DWYI_Ldj.d.mts +1550 -0
- package/dist/request-options-DWYI_Ldj.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-SwP0sK8H.mjs +2458 -0
- package/dist/tools-SwP0sK8H.mjs.map +1 -0
- package/dist/types/index.d.mts +2 -0
- package/dist/types/index.mjs +1 -0
- package/package.json +67 -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 +662 -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 +227 -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/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 +556 -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 +165 -0
- package/src/internal/feature/rules.ts +54 -0
- package/src/internal/feature/timeout.ts +146 -0
- package/src/internal/feature/validate.ts +74 -0
- package/src/internal/page/page.ts +402 -0
- package/src/internal/transport/fetch.ts +82 -0
- package/src/resources/analytics.ts +363 -0
- package/src/resources/brands.ts +285 -0
- package/src/resources/competitors.ts +212 -0
- package/src/resources/identity.ts +48 -0
- package/src/resources/models.ts +32 -0
- package/src/resources/opportunities.ts +79 -0
- package/src/resources/organizations.ts +181 -0
- package/src/resources/prompts.ts +292 -0
- package/src/resources/reports.ts +211 -0
- package/src/resources/runs.ts +123 -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 +68 -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,363 @@
|
|
|
1
|
+
import { apiKeyRequirements } from './shared/auth';
|
|
2
|
+
import type { RequestOptions } from './shared/request-options';
|
|
3
|
+
import { ElmoResource } from './shared/resource';
|
|
4
|
+
import { callPromise, RestCallPromise } from '../internal/core/call-promise';
|
|
5
|
+
import { callable } from '../internal/core/callable';
|
|
6
|
+
import { mergeParams, placeParams } from '../internal/core/params';
|
|
7
|
+
import { decoded, reviving } from '../internal/feature/validate';
|
|
8
|
+
import type {
|
|
9
|
+
BrandAnalytics,
|
|
10
|
+
BrandQueryFanout,
|
|
11
|
+
CitationDomain,
|
|
12
|
+
CitationDomainList,
|
|
13
|
+
CitationURL,
|
|
14
|
+
CitationURLList,
|
|
15
|
+
DateRange,
|
|
16
|
+
FanoutQuery,
|
|
17
|
+
GetBrandAnalyticsErrors,
|
|
18
|
+
GetBrandAnalyticsParams,
|
|
19
|
+
GetBrandAnalyticsResponses,
|
|
20
|
+
GetBrandQueryFanoutErrors,
|
|
21
|
+
GetBrandQueryFanoutParams,
|
|
22
|
+
GetBrandQueryFanoutResponses,
|
|
23
|
+
ListBrandCitationDomainsErrors,
|
|
24
|
+
ListBrandCitationDomainsParams,
|
|
25
|
+
ListBrandCitationDomainsResponses,
|
|
26
|
+
ListBrandCitationURLsErrors,
|
|
27
|
+
ListBrandCitationURLsParams,
|
|
28
|
+
ListBrandCitationURLsResponses,
|
|
29
|
+
ListBrandPromptPerformanceErrors,
|
|
30
|
+
ListBrandPromptPerformanceParams,
|
|
31
|
+
ListBrandPromptPerformanceResponses,
|
|
32
|
+
ModelVisibility,
|
|
33
|
+
PromptPerformanceList,
|
|
34
|
+
PromptPerformance as PromptPerformanceSchema,
|
|
35
|
+
ShareOfVoiceEntry,
|
|
36
|
+
ShareOfVoicePoint,
|
|
37
|
+
VisibilityPoint,
|
|
38
|
+
} from '../types/analytics';
|
|
39
|
+
import type { BrandIdPath } from '../types/shared/brand-id-path';
|
|
40
|
+
|
|
41
|
+
export const getBrandAnalyticsFields = { path: ['brandId'] };
|
|
42
|
+
|
|
43
|
+
function reviveDateRange(value: DateRange): void {
|
|
44
|
+
if (value.start != null) {
|
|
45
|
+
value.start = decoded('DateRange.start', value.start, (raw) => new Date(raw));
|
|
46
|
+
}
|
|
47
|
+
if (value.end != null) {
|
|
48
|
+
value.end = decoded('DateRange.end', value.end, (raw) => new Date(raw));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function reviveBrandAnalytics(value: BrandAnalytics): void {
|
|
53
|
+
if (value.range != null) {
|
|
54
|
+
reviveDateRange(value.range);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const getBrandAnalyticsDescriptor = /* @__PURE__ */ callable({
|
|
59
|
+
address: '/brands/{brandId}/analytics',
|
|
60
|
+
auth: apiKeyRequirements,
|
|
61
|
+
method: 'get',
|
|
62
|
+
returns: 'json',
|
|
63
|
+
validators: { response: /* @__PURE__ */ reviving(reviveBrandAnalytics) },
|
|
64
|
+
} as const);
|
|
65
|
+
|
|
66
|
+
export const listBrandCitationDomainsFields = { path: ['brandId'] };
|
|
67
|
+
|
|
68
|
+
function reviveCitationDomainList(value: CitationDomainList): void {
|
|
69
|
+
if (value.range != null) {
|
|
70
|
+
reviveDateRange(value.range);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export const listBrandCitationDomainsDescriptor = /* @__PURE__ */ callable({
|
|
75
|
+
address: '/brands/{brandId}/citations/domains',
|
|
76
|
+
auth: apiKeyRequirements,
|
|
77
|
+
method: 'get',
|
|
78
|
+
returns: 'json',
|
|
79
|
+
validators: { response: /* @__PURE__ */ reviving(reviveCitationDomainList) },
|
|
80
|
+
} as const);
|
|
81
|
+
|
|
82
|
+
export const listBrandCitationUrlsFields = { path: ['brandId'] };
|
|
83
|
+
|
|
84
|
+
function reviveCitationUrlList(value: CitationURLList): void {
|
|
85
|
+
if (value.range != null) {
|
|
86
|
+
reviveDateRange(value.range);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export const listBrandCitationURLsDescriptor = /* @__PURE__ */ callable({
|
|
91
|
+
address: '/brands/{brandId}/citations/urls',
|
|
92
|
+
auth: apiKeyRequirements,
|
|
93
|
+
method: 'get',
|
|
94
|
+
returns: 'json',
|
|
95
|
+
validators: { response: /* @__PURE__ */ reviving(reviveCitationUrlList) },
|
|
96
|
+
} as const);
|
|
97
|
+
|
|
98
|
+
export const listBrandPromptPerformanceFields = { path: ['brandId'] };
|
|
99
|
+
|
|
100
|
+
function revivePromptPerformance(value: PromptPerformanceSchema): void {
|
|
101
|
+
if (value.lastRunAt != null) {
|
|
102
|
+
value.lastRunAt = decoded(
|
|
103
|
+
'PromptPerformance.lastRunAt',
|
|
104
|
+
value.lastRunAt,
|
|
105
|
+
(raw) => new Date(raw),
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
if (value.firstEvaluatedAt != null) {
|
|
109
|
+
value.firstEvaluatedAt = decoded(
|
|
110
|
+
'PromptPerformance.firstEvaluatedAt',
|
|
111
|
+
value.firstEvaluatedAt,
|
|
112
|
+
(raw) => new Date(raw),
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function revivePromptPerformanceList(value: PromptPerformanceList): void {
|
|
118
|
+
if (value.range != null) {
|
|
119
|
+
reviveDateRange(value.range);
|
|
120
|
+
}
|
|
121
|
+
if (value.data != null) {
|
|
122
|
+
value.data.forEach((item) => {
|
|
123
|
+
revivePromptPerformance(item);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export const listBrandPromptPerformanceDescriptor = /* @__PURE__ */ callable({
|
|
129
|
+
address: '/brands/{brandId}/prompt-performance',
|
|
130
|
+
auth: apiKeyRequirements,
|
|
131
|
+
method: 'get',
|
|
132
|
+
returns: 'json',
|
|
133
|
+
validators: { response: /* @__PURE__ */ reviving(revivePromptPerformanceList) },
|
|
134
|
+
} as const);
|
|
135
|
+
|
|
136
|
+
export const getBrandQueryFanoutFields = { path: ['brandId'] };
|
|
137
|
+
|
|
138
|
+
function reviveBrandQueryFanout(value: BrandQueryFanout): void {
|
|
139
|
+
if (value.range != null) {
|
|
140
|
+
reviveDateRange(value.range);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export const getBrandQueryFanoutDescriptor = /* @__PURE__ */ callable({
|
|
145
|
+
address: '/brands/{brandId}/query-fanout',
|
|
146
|
+
auth: apiKeyRequirements,
|
|
147
|
+
method: 'get',
|
|
148
|
+
returns: 'json',
|
|
149
|
+
validators: { response: /* @__PURE__ */ reviving(reviveBrandQueryFanout) },
|
|
150
|
+
} as const);
|
|
151
|
+
|
|
152
|
+
/** Aggregated visibility, share of voice, citations, and query fan-out for a brand */
|
|
153
|
+
export class Analytics extends ElmoResource {
|
|
154
|
+
/**
|
|
155
|
+
* Get a brand's analytics
|
|
156
|
+
*
|
|
157
|
+
* Visibility, share of voice, the per-model breakdown and the citation totals for one window, in
|
|
158
|
+
* one request.
|
|
159
|
+
*
|
|
160
|
+
* The long lists — cited domains and URLs, sub-queries, per-prompt results — are endpoints of
|
|
161
|
+
* their own. Everything else is always included.
|
|
162
|
+
*
|
|
163
|
+
* @param brandId Brand identifier.
|
|
164
|
+
*/
|
|
165
|
+
public get(
|
|
166
|
+
brandId: BrandIdPath,
|
|
167
|
+
params: GetBrandAnalyticsParams,
|
|
168
|
+
options?: RequestOptions,
|
|
169
|
+
): RestCallPromise<GetBrandAnalyticsResponses, GetBrandAnalyticsErrors> {
|
|
170
|
+
return callPromise(
|
|
171
|
+
options?.client ?? this.client,
|
|
172
|
+
getBrandAnalyticsDescriptor,
|
|
173
|
+
mergeParams(placeParams({ ...params, brandId }, getBrandAnalyticsFields, 'query'), options),
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** Aggregated visibility, share of voice, citations, and query fan-out for a brand */
|
|
179
|
+
export class Domains extends ElmoResource {
|
|
180
|
+
/**
|
|
181
|
+
* List cited domains
|
|
182
|
+
*
|
|
183
|
+
* Domains the engines cited when answering this brand's prompts, categorized and compared against
|
|
184
|
+
* the equal-length window immediately before this one.
|
|
185
|
+
*
|
|
186
|
+
* @param brandId Brand identifier.
|
|
187
|
+
*/
|
|
188
|
+
public list(
|
|
189
|
+
brandId: BrandIdPath,
|
|
190
|
+
params: ListBrandCitationDomainsParams,
|
|
191
|
+
options?: RequestOptions,
|
|
192
|
+
): RestCallPromise<ListBrandCitationDomainsResponses, ListBrandCitationDomainsErrors> {
|
|
193
|
+
return callPromise(
|
|
194
|
+
options?.client ?? this.client,
|
|
195
|
+
listBrandCitationDomainsDescriptor,
|
|
196
|
+
mergeParams(
|
|
197
|
+
placeParams({ ...params, brandId }, listBrandCitationDomainsFields, 'query'),
|
|
198
|
+
options,
|
|
199
|
+
),
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** Aggregated visibility, share of voice, citations, and query fan-out for a brand */
|
|
205
|
+
export class URLs extends ElmoResource {
|
|
206
|
+
/**
|
|
207
|
+
* List cited URLs
|
|
208
|
+
*
|
|
209
|
+
* Individual pages the engines cited, with their category and page type.
|
|
210
|
+
*
|
|
211
|
+
* @param brandId Brand identifier.
|
|
212
|
+
*/
|
|
213
|
+
public list(
|
|
214
|
+
brandId: BrandIdPath,
|
|
215
|
+
params: ListBrandCitationURLsParams,
|
|
216
|
+
options?: RequestOptions,
|
|
217
|
+
): RestCallPromise<ListBrandCitationURLsResponses, ListBrandCitationURLsErrors> {
|
|
218
|
+
return callPromise(
|
|
219
|
+
options?.client ?? this.client,
|
|
220
|
+
listBrandCitationURLsDescriptor,
|
|
221
|
+
mergeParams(
|
|
222
|
+
placeParams({ ...params, brandId }, listBrandCitationUrlsFields, 'query'),
|
|
223
|
+
options,
|
|
224
|
+
),
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export class Citations extends ElmoResource {
|
|
230
|
+
private _domains?: Domains;
|
|
231
|
+
/** Aggregated visibility, share of voice, citations, and query fan-out for a brand */
|
|
232
|
+
get domains(): Domains {
|
|
233
|
+
return (this._domains ??= new Domains(this.client));
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
private _urls?: URLs;
|
|
237
|
+
/** Aggregated visibility, share of voice, citations, and query fan-out for a brand */
|
|
238
|
+
get urls(): URLs {
|
|
239
|
+
return (this._urls ??= new URLs(this.client));
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** Aggregated visibility, share of voice, citations, and query fan-out for a brand */
|
|
244
|
+
export class PromptPerformance extends ElmoResource {
|
|
245
|
+
/**
|
|
246
|
+
* List prompt performance
|
|
247
|
+
*
|
|
248
|
+
* Per-prompt mention rates over the window. The analytics counterpart to `GET /prompts?brandId=`,
|
|
249
|
+
* which returns prompt configuration rather than results.
|
|
250
|
+
*
|
|
251
|
+
* A prompt the brand stopped tracking is not sampled, so it has no results over the window and
|
|
252
|
+
* does not appear here.
|
|
253
|
+
*
|
|
254
|
+
* @param brandId Brand identifier.
|
|
255
|
+
*/
|
|
256
|
+
public list(
|
|
257
|
+
brandId: BrandIdPath,
|
|
258
|
+
params: ListBrandPromptPerformanceParams,
|
|
259
|
+
options?: RequestOptions,
|
|
260
|
+
): RestCallPromise<ListBrandPromptPerformanceResponses, ListBrandPromptPerformanceErrors> {
|
|
261
|
+
return callPromise(
|
|
262
|
+
options?.client ?? this.client,
|
|
263
|
+
listBrandPromptPerformanceDescriptor,
|
|
264
|
+
mergeParams(
|
|
265
|
+
placeParams({ ...params, brandId }, listBrandPromptPerformanceFields, 'query'),
|
|
266
|
+
options,
|
|
267
|
+
),
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/** Aggregated visibility, share of voice, citations, and query fan-out for a brand */
|
|
273
|
+
export class QueryFanout extends ElmoResource {
|
|
274
|
+
/**
|
|
275
|
+
* Get query fan-out
|
|
276
|
+
*
|
|
277
|
+
* The searches engines ran while answering this brand's prompts. Engines that don't expose their
|
|
278
|
+
* searches still contribute runs, so `coverageRate` is the honest denominator.
|
|
279
|
+
*
|
|
280
|
+
* @param brandId Brand identifier.
|
|
281
|
+
*/
|
|
282
|
+
public get(
|
|
283
|
+
brandId: BrandIdPath,
|
|
284
|
+
params: GetBrandQueryFanoutParams,
|
|
285
|
+
options?: RequestOptions,
|
|
286
|
+
): RestCallPromise<GetBrandQueryFanoutResponses, GetBrandQueryFanoutErrors> {
|
|
287
|
+
return callPromise(
|
|
288
|
+
options?.client ?? this.client,
|
|
289
|
+
getBrandQueryFanoutDescriptor,
|
|
290
|
+
mergeParams(placeParams({ ...params, brandId }, getBrandQueryFanoutFields, 'query'), options),
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export declare namespace Analytics {
|
|
296
|
+
export type {
|
|
297
|
+
BrandAnalytics,
|
|
298
|
+
GetBrandAnalyticsErrors,
|
|
299
|
+
GetBrandAnalyticsParams,
|
|
300
|
+
GetBrandAnalyticsResponses,
|
|
301
|
+
ModelVisibility,
|
|
302
|
+
ShareOfVoiceEntry,
|
|
303
|
+
ShareOfVoicePoint,
|
|
304
|
+
VisibilityPoint,
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export declare namespace Domains {
|
|
309
|
+
export type {
|
|
310
|
+
CitationDomain,
|
|
311
|
+
CitationDomainList,
|
|
312
|
+
ListBrandCitationDomainsErrors,
|
|
313
|
+
ListBrandCitationDomainsParams,
|
|
314
|
+
ListBrandCitationDomainsResponses,
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export declare namespace URLs {
|
|
319
|
+
export type {
|
|
320
|
+
CitationURL,
|
|
321
|
+
CitationURLList,
|
|
322
|
+
ListBrandCitationURLsErrors,
|
|
323
|
+
ListBrandCitationURLsParams,
|
|
324
|
+
ListBrandCitationURLsResponses,
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
export declare namespace Citations {
|
|
329
|
+
export type {
|
|
330
|
+
CitationDomain,
|
|
331
|
+
CitationDomainList,
|
|
332
|
+
CitationURL,
|
|
333
|
+
CitationURLList,
|
|
334
|
+
Domains,
|
|
335
|
+
ListBrandCitationDomainsErrors,
|
|
336
|
+
ListBrandCitationDomainsParams,
|
|
337
|
+
ListBrandCitationDomainsResponses,
|
|
338
|
+
ListBrandCitationURLsErrors,
|
|
339
|
+
ListBrandCitationURLsParams,
|
|
340
|
+
ListBrandCitationURLsResponses,
|
|
341
|
+
URLs,
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export declare namespace PromptPerformance {
|
|
346
|
+
export type {
|
|
347
|
+
ListBrandPromptPerformanceErrors,
|
|
348
|
+
ListBrandPromptPerformanceParams,
|
|
349
|
+
ListBrandPromptPerformanceResponses,
|
|
350
|
+
PromptPerformanceSchema as PromptPerformance,
|
|
351
|
+
PromptPerformanceList,
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
export declare namespace QueryFanout {
|
|
356
|
+
export type {
|
|
357
|
+
BrandQueryFanout,
|
|
358
|
+
FanoutQuery,
|
|
359
|
+
GetBrandQueryFanoutErrors,
|
|
360
|
+
GetBrandQueryFanoutParams,
|
|
361
|
+
GetBrandQueryFanoutResponses,
|
|
362
|
+
};
|
|
363
|
+
}
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { Analytics, Citations, PromptPerformance, QueryFanout } from './analytics';
|
|
2
|
+
import { Opportunities } from './opportunities';
|
|
3
|
+
import { apiKeyRequirements } from './shared/auth';
|
|
4
|
+
import type { RequestOptions } from './shared/request-options';
|
|
5
|
+
import { ElmoResource } from './shared/resource';
|
|
6
|
+
import { brandNameRule, domainsRule, nameRule } from './shared/rule';
|
|
7
|
+
import { Tags } from './tags';
|
|
8
|
+
import { callPromise, RestCallPromise } from '../internal/core/call-promise';
|
|
9
|
+
import { callable } from '../internal/core/callable';
|
|
10
|
+
import { groupParams, mergeParams, placeParams } from '../internal/core/params';
|
|
11
|
+
import { decoded, reviving } from '../internal/feature/validate';
|
|
12
|
+
import { PagePromise, pages } from '../internal/page/page';
|
|
13
|
+
import type {
|
|
14
|
+
BrandAnalytics,
|
|
15
|
+
BrandQueryFanout,
|
|
16
|
+
DateRange,
|
|
17
|
+
FanoutQuery,
|
|
18
|
+
GetBrandAnalyticsErrors,
|
|
19
|
+
GetBrandAnalyticsParams,
|
|
20
|
+
GetBrandAnalyticsResponses,
|
|
21
|
+
GetBrandQueryFanoutErrors,
|
|
22
|
+
GetBrandQueryFanoutParams,
|
|
23
|
+
GetBrandQueryFanoutResponses,
|
|
24
|
+
ListBrandPromptPerformanceErrors,
|
|
25
|
+
ListBrandPromptPerformanceParams,
|
|
26
|
+
ListBrandPromptPerformanceResponses,
|
|
27
|
+
ModelVisibility,
|
|
28
|
+
PromptPerformanceList,
|
|
29
|
+
ShareOfVoiceEntry,
|
|
30
|
+
ShareOfVoicePoint,
|
|
31
|
+
TagsFilter,
|
|
32
|
+
VisibilityPoint,
|
|
33
|
+
} from '../types/analytics';
|
|
34
|
+
import type {
|
|
35
|
+
Brand,
|
|
36
|
+
BrandsList,
|
|
37
|
+
CreateBrandErrors,
|
|
38
|
+
CreateBrandParams,
|
|
39
|
+
CreateBrandResponses,
|
|
40
|
+
GetBrandErrors,
|
|
41
|
+
GetBrandResponses,
|
|
42
|
+
ListBrandsErrors,
|
|
43
|
+
ListBrandsParams,
|
|
44
|
+
ListBrandsResponses,
|
|
45
|
+
UpdateBrandErrors,
|
|
46
|
+
UpdateBrandParams,
|
|
47
|
+
UpdateBrandResponses,
|
|
48
|
+
} from '../types/brands';
|
|
49
|
+
import type {
|
|
50
|
+
BrandOpportunities,
|
|
51
|
+
CitedPage,
|
|
52
|
+
GetBrandOpportunitiesErrors,
|
|
53
|
+
GetBrandOpportunitiesResponses,
|
|
54
|
+
Opportunity,
|
|
55
|
+
OpportunityPrompt,
|
|
56
|
+
} from '../types/opportunities';
|
|
57
|
+
import type { BrandIdPath } from '../types/shared/brand-id-path';
|
|
58
|
+
import type { ListBrandTagsErrors, ListBrandTagsResponses, Tag, TagList } from '../types/tags';
|
|
59
|
+
|
|
60
|
+
function reviveBrand(value: Brand): void {
|
|
61
|
+
if (value.createdAt != null) {
|
|
62
|
+
value.createdAt = decoded('Brand.createdAt', value.createdAt, (raw) => new Date(raw));
|
|
63
|
+
}
|
|
64
|
+
if (value.updatedAt != null) {
|
|
65
|
+
value.updatedAt = decoded('Brand.updatedAt', value.updatedAt, (raw) => new Date(raw));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function reviveBrandsList(value: BrandsList): void {
|
|
70
|
+
if (value.data != null) {
|
|
71
|
+
value.data.forEach((item) => {
|
|
72
|
+
reviveBrand(item);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
if (value.brands != null) {
|
|
76
|
+
value.brands.forEach((item) => {
|
|
77
|
+
reviveBrand(item);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export const listBrandsDescriptor = /* @__PURE__ */ callable({
|
|
83
|
+
address: '/brands',
|
|
84
|
+
auth: apiKeyRequirements,
|
|
85
|
+
method: 'get',
|
|
86
|
+
pagination: {
|
|
87
|
+
items: 'data',
|
|
88
|
+
limitParam: 'limit',
|
|
89
|
+
pages: 'pagination.totalPages',
|
|
90
|
+
param: 'page',
|
|
91
|
+
size: 'pagination.limit',
|
|
92
|
+
style: 'page',
|
|
93
|
+
total: 'pagination.total',
|
|
94
|
+
},
|
|
95
|
+
returns: 'json',
|
|
96
|
+
validators: { response: /* @__PURE__ */ reviving(reviveBrandsList) },
|
|
97
|
+
} as const);
|
|
98
|
+
|
|
99
|
+
export const createBrandDescriptor = /* @__PURE__ */ callable({
|
|
100
|
+
address: '/brands',
|
|
101
|
+
auth: apiKeyRequirements,
|
|
102
|
+
mediaType: 'application/json',
|
|
103
|
+
method: 'post',
|
|
104
|
+
returns: 'json',
|
|
105
|
+
rules: [
|
|
106
|
+
{
|
|
107
|
+
min: 1,
|
|
108
|
+
name: 'id',
|
|
109
|
+
of: 'characters',
|
|
110
|
+
},
|
|
111
|
+
nameRule,
|
|
112
|
+
domainsRule,
|
|
113
|
+
],
|
|
114
|
+
validators: { response: /* @__PURE__ */ reviving(reviveBrand) },
|
|
115
|
+
} as const);
|
|
116
|
+
|
|
117
|
+
export const getBrandFields = { path: ['brandId'] };
|
|
118
|
+
|
|
119
|
+
export const getBrandDescriptor = /* @__PURE__ */ callable({
|
|
120
|
+
address: '/brands/{brandId}',
|
|
121
|
+
auth: apiKeyRequirements,
|
|
122
|
+
method: 'get',
|
|
123
|
+
returns: 'json',
|
|
124
|
+
validators: { response: /* @__PURE__ */ reviving(reviveBrand) },
|
|
125
|
+
} as const);
|
|
126
|
+
|
|
127
|
+
export const updateBrandFields = { path: ['brandId'] };
|
|
128
|
+
|
|
129
|
+
export const updateBrandDescriptor = /* @__PURE__ */ callable({
|
|
130
|
+
address: '/brands/{brandId}',
|
|
131
|
+
auth: apiKeyRequirements,
|
|
132
|
+
mediaType: 'application/json',
|
|
133
|
+
method: 'patch',
|
|
134
|
+
returns: 'json',
|
|
135
|
+
rules: [brandNameRule, domainsRule],
|
|
136
|
+
validators: { response: /* @__PURE__ */ reviving(reviveBrand) },
|
|
137
|
+
} as const);
|
|
138
|
+
|
|
139
|
+
/** Manage brand records */
|
|
140
|
+
export class Brands extends ElmoResource {
|
|
141
|
+
/** Create a brand */
|
|
142
|
+
public create(
|
|
143
|
+
params: CreateBrandParams,
|
|
144
|
+
options?: RequestOptions,
|
|
145
|
+
): RestCallPromise<CreateBrandResponses, CreateBrandErrors> {
|
|
146
|
+
return callPromise(
|
|
147
|
+
options?.client ?? this.client,
|
|
148
|
+
createBrandDescriptor,
|
|
149
|
+
mergeParams(groupParams(params, 'body'), options),
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Get a brand
|
|
155
|
+
*
|
|
156
|
+
* @param brandId Brand identifier
|
|
157
|
+
*/
|
|
158
|
+
public get(
|
|
159
|
+
brandId: string,
|
|
160
|
+
options?: RequestOptions,
|
|
161
|
+
): RestCallPromise<GetBrandResponses, GetBrandErrors> {
|
|
162
|
+
return callPromise(
|
|
163
|
+
options?.client ?? this.client,
|
|
164
|
+
getBrandDescriptor,
|
|
165
|
+
mergeParams(placeParams({ brandId }, getBrandFields, 'query'), options),
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
public list(
|
|
170
|
+
params?: ListBrandsParams,
|
|
171
|
+
options?: RequestOptions,
|
|
172
|
+
): PagePromise<Brand, BrandsList, ListBrandsErrors> {
|
|
173
|
+
return pages(
|
|
174
|
+
options?.client ?? this.client,
|
|
175
|
+
listBrandsDescriptor,
|
|
176
|
+
mergeParams(groupParams(params, 'query'), options),
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Update a brand
|
|
182
|
+
*
|
|
183
|
+
* @param brandId Brand identifier
|
|
184
|
+
*/
|
|
185
|
+
public update(
|
|
186
|
+
brandId: string,
|
|
187
|
+
params: UpdateBrandParams,
|
|
188
|
+
options?: RequestOptions,
|
|
189
|
+
): RestCallPromise<UpdateBrandResponses, UpdateBrandErrors> {
|
|
190
|
+
return callPromise(
|
|
191
|
+
options?.client ?? this.client,
|
|
192
|
+
updateBrandDescriptor,
|
|
193
|
+
mergeParams(placeParams({ ...params, brandId }, updateBrandFields, 'body'), options),
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
private _analytics?: Analytics;
|
|
198
|
+
/** Aggregated visibility, share of voice, citations, and query fan-out for a brand */
|
|
199
|
+
get analytics(): Analytics {
|
|
200
|
+
return (this._analytics ??= new Analytics(this.client));
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
private _citations?: Citations;
|
|
204
|
+
get citations(): Citations {
|
|
205
|
+
return (this._citations ??= new Citations(this.client));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
private _opportunities?: Opportunities;
|
|
209
|
+
/** Where a brand could win more citations, and why */
|
|
210
|
+
get opportunities(): Opportunities {
|
|
211
|
+
return (this._opportunities ??= new Opportunities(this.client));
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
private _promptPerformance?: PromptPerformance;
|
|
215
|
+
/** Aggregated visibility, share of voice, citations, and query fan-out for a brand */
|
|
216
|
+
get promptPerformance(): PromptPerformance {
|
|
217
|
+
return (this._promptPerformance ??= new PromptPerformance(this.client));
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
private _queryFanout?: QueryFanout;
|
|
221
|
+
/** Aggregated visibility, share of voice, citations, and query fan-out for a brand */
|
|
222
|
+
get queryFanout(): QueryFanout {
|
|
223
|
+
return (this._queryFanout ??= new QueryFanout(this.client));
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
private _tags?: Tags;
|
|
227
|
+
/** The tags in use on a brand's prompts */
|
|
228
|
+
get tags(): Tags {
|
|
229
|
+
return (this._tags ??= new Tags(this.client));
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export declare namespace Brands {
|
|
234
|
+
export type {
|
|
235
|
+
Analytics,
|
|
236
|
+
Brand,
|
|
237
|
+
BrandAnalytics,
|
|
238
|
+
BrandIdPath,
|
|
239
|
+
BrandOpportunities,
|
|
240
|
+
BrandQueryFanout,
|
|
241
|
+
BrandsList,
|
|
242
|
+
Citations,
|
|
243
|
+
CitedPage,
|
|
244
|
+
CreateBrandErrors,
|
|
245
|
+
CreateBrandParams,
|
|
246
|
+
CreateBrandResponses,
|
|
247
|
+
DateRange,
|
|
248
|
+
FanoutQuery,
|
|
249
|
+
GetBrandAnalyticsErrors,
|
|
250
|
+
GetBrandAnalyticsParams,
|
|
251
|
+
GetBrandAnalyticsResponses,
|
|
252
|
+
GetBrandErrors,
|
|
253
|
+
GetBrandOpportunitiesErrors,
|
|
254
|
+
GetBrandOpportunitiesResponses,
|
|
255
|
+
GetBrandQueryFanoutErrors,
|
|
256
|
+
GetBrandQueryFanoutParams,
|
|
257
|
+
GetBrandQueryFanoutResponses,
|
|
258
|
+
GetBrandResponses,
|
|
259
|
+
ListBrandPromptPerformanceErrors,
|
|
260
|
+
ListBrandPromptPerformanceParams,
|
|
261
|
+
ListBrandPromptPerformanceResponses,
|
|
262
|
+
ListBrandsErrors,
|
|
263
|
+
ListBrandsParams,
|
|
264
|
+
ListBrandsResponses,
|
|
265
|
+
ListBrandTagsErrors,
|
|
266
|
+
ListBrandTagsResponses,
|
|
267
|
+
ModelVisibility,
|
|
268
|
+
Opportunities,
|
|
269
|
+
Opportunity,
|
|
270
|
+
OpportunityPrompt,
|
|
271
|
+
PromptPerformance,
|
|
272
|
+
PromptPerformanceList,
|
|
273
|
+
QueryFanout,
|
|
274
|
+
ShareOfVoiceEntry,
|
|
275
|
+
ShareOfVoicePoint,
|
|
276
|
+
Tag,
|
|
277
|
+
TagList,
|
|
278
|
+
Tags,
|
|
279
|
+
TagsFilter,
|
|
280
|
+
UpdateBrandErrors,
|
|
281
|
+
UpdateBrandParams,
|
|
282
|
+
UpdateBrandResponses,
|
|
283
|
+
VisibilityPoint,
|
|
284
|
+
};
|
|
285
|
+
}
|