@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,288 @@
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 { PagePromise, pages } from '../internal/core/page';
11
+ import { groupParams, mergeParams, placeParams } from '../internal/core/params';
12
+ import type { Mutable } from '../internal/feature/validate';
13
+ import { decoded, reviving } from '../internal/feature/validate';
14
+ import type {
15
+ BrandAnalytics,
16
+ BrandQueryFanout,
17
+ DateRange,
18
+ FanoutQuery,
19
+ GetBrandAnalyticsErrors,
20
+ GetBrandAnalyticsParams,
21
+ GetBrandAnalyticsResponses,
22
+ GetBrandQueryFanoutErrors,
23
+ GetBrandQueryFanoutParams,
24
+ GetBrandQueryFanoutResponses,
25
+ ListBrandPromptPerformanceErrors,
26
+ ListBrandPromptPerformanceParams,
27
+ ListBrandPromptPerformanceResponses,
28
+ ModelVisibility,
29
+ PromptPerformanceList,
30
+ PromptPerformance as PromptPerformanceSchema,
31
+ ShareOfVoiceEntry,
32
+ ShareOfVoicePoint,
33
+ TagsFilter,
34
+ VisibilityPoint,
35
+ } from '../types/analytics';
36
+ import type {
37
+ Brand,
38
+ BrandsList,
39
+ CreateBrandErrors,
40
+ CreateBrandParams,
41
+ CreateBrandResponses,
42
+ GetBrandErrors,
43
+ GetBrandResponses,
44
+ ListBrandsErrors,
45
+ ListBrandsParams,
46
+ ListBrandsResponses,
47
+ UpdateBrandErrors,
48
+ UpdateBrandParams,
49
+ UpdateBrandResponses,
50
+ } from '../types/brands';
51
+ import type {
52
+ BrandOpportunities,
53
+ CitedPage,
54
+ GetBrandOpportunitiesErrors,
55
+ GetBrandOpportunitiesResponses,
56
+ Opportunity,
57
+ OpportunityPrompt,
58
+ } from '../types/opportunities';
59
+ import type { BrandIdPath } from '../types/shared/brand-id-path';
60
+ import type { ListBrandTagsErrors, ListBrandTagsResponses, Tag, TagList } from '../types/tags';
61
+
62
+ function reviveBrand(value: Mutable<Brand>): void {
63
+ if (value.createdAt != null) {
64
+ value.createdAt = decoded('Brand.createdAt', value.createdAt, (raw) => new Date(raw));
65
+ }
66
+ if (value.updatedAt != null) {
67
+ value.updatedAt = decoded('Brand.updatedAt', value.updatedAt, (raw) => new Date(raw));
68
+ }
69
+ }
70
+
71
+ function reviveBrandsList(value: Mutable<BrandsList>): void {
72
+ if (value.data != null) {
73
+ value.data.forEach((item) => {
74
+ reviveBrand(item);
75
+ });
76
+ }
77
+ if (value.brands != null) {
78
+ value.brands.forEach((item) => {
79
+ reviveBrand(item);
80
+ });
81
+ }
82
+ }
83
+
84
+ export const listBrandsDescriptor = /* @__PURE__ */ callable({
85
+ address: '/brands',
86
+ auth: apiKeyRequirements,
87
+ method: 'get',
88
+ pagination: {
89
+ items: 'data',
90
+ limitParam: 'limit',
91
+ pages: 'pagination.totalPages',
92
+ param: 'page',
93
+ size: 'pagination.limit',
94
+ style: 'page',
95
+ total: 'pagination.total',
96
+ },
97
+ returns: 'json',
98
+ validators: { response: /* @__PURE__ */ reviving(reviveBrandsList) },
99
+ } as const);
100
+
101
+ export const createBrandDescriptor = /* @__PURE__ */ callable({
102
+ address: '/brands',
103
+ auth: apiKeyRequirements,
104
+ mediaType: 'application/json',
105
+ method: 'post',
106
+ returns: 'json',
107
+ rules: [
108
+ {
109
+ min: 1,
110
+ name: 'id',
111
+ of: 'characters',
112
+ },
113
+ nameRule,
114
+ domainsRule,
115
+ ],
116
+ validators: { response: /* @__PURE__ */ reviving(reviveBrand) },
117
+ } as const);
118
+
119
+ export const getBrandFields = { path: ['brandId'] };
120
+
121
+ export const getBrandDescriptor = /* @__PURE__ */ callable({
122
+ address: '/brands/{brandId}',
123
+ auth: apiKeyRequirements,
124
+ method: 'get',
125
+ returns: 'json',
126
+ validators: { response: /* @__PURE__ */ reviving(reviveBrand) },
127
+ } as const);
128
+
129
+ export const updateBrandFields = { path: ['brandId'] };
130
+
131
+ export const updateBrandDescriptor = /* @__PURE__ */ callable({
132
+ address: '/brands/{brandId}',
133
+ auth: apiKeyRequirements,
134
+ mediaType: 'application/json',
135
+ method: 'patch',
136
+ returns: 'json',
137
+ rules: [brandNameRule, domainsRule],
138
+ validators: { response: /* @__PURE__ */ reviving(reviveBrand) },
139
+ } as const);
140
+
141
+ /** Manage brand records */
142
+ export class Brands extends ElmoResource {
143
+ /** Create a brand */
144
+ public create(
145
+ params: CreateBrandParams,
146
+ options?: RequestOptions,
147
+ ): RestCallPromise<CreateBrandResponses, CreateBrandErrors> {
148
+ return callPromise(
149
+ options?.client ?? this.client,
150
+ createBrandDescriptor,
151
+ mergeParams(groupParams(params, 'body'), options),
152
+ );
153
+ }
154
+
155
+ /**
156
+ * Get a brand
157
+ *
158
+ * @param brandId Brand identifier
159
+ */
160
+ public get(
161
+ brandId: string,
162
+ options?: RequestOptions,
163
+ ): RestCallPromise<GetBrandResponses, GetBrandErrors> {
164
+ return callPromise(
165
+ options?.client ?? this.client,
166
+ getBrandDescriptor,
167
+ mergeParams(placeParams({ brandId }, getBrandFields, 'query'), options),
168
+ );
169
+ }
170
+
171
+ public list(
172
+ params?: ListBrandsParams,
173
+ options?: RequestOptions,
174
+ ): PagePromise<Brand, BrandsList, ListBrandsErrors> {
175
+ return pages(
176
+ options?.client ?? this.client,
177
+ listBrandsDescriptor,
178
+ mergeParams(groupParams(params, 'query'), options),
179
+ );
180
+ }
181
+
182
+ /**
183
+ * Update a brand
184
+ *
185
+ * @param brandId Brand identifier
186
+ */
187
+ public update(
188
+ brandId: string,
189
+ params: UpdateBrandParams,
190
+ options?: RequestOptions,
191
+ ): RestCallPromise<UpdateBrandResponses, UpdateBrandErrors> {
192
+ return callPromise(
193
+ options?.client ?? this.client,
194
+ updateBrandDescriptor,
195
+ mergeParams(placeParams({ ...params, brandId }, updateBrandFields, 'body'), options),
196
+ );
197
+ }
198
+
199
+ private _analytics?: Analytics;
200
+ /** Aggregated visibility, share of voice, citations, and query fan-out for a brand */
201
+ get analytics(): Analytics {
202
+ return (this._analytics ??= new Analytics(this.client));
203
+ }
204
+
205
+ private _citations?: Citations;
206
+ get citations(): Citations {
207
+ return (this._citations ??= new Citations(this.client));
208
+ }
209
+
210
+ private _opportunities?: Opportunities;
211
+ /** Where a brand could win more citations, and why */
212
+ get opportunities(): Opportunities {
213
+ return (this._opportunities ??= new Opportunities(this.client));
214
+ }
215
+
216
+ private _promptPerformance?: PromptPerformance;
217
+ /** Aggregated visibility, share of voice, citations, and query fan-out for a brand */
218
+ get promptPerformance(): PromptPerformance {
219
+ return (this._promptPerformance ??= new PromptPerformance(this.client));
220
+ }
221
+
222
+ private _queryFanout?: QueryFanout;
223
+ /** Aggregated visibility, share of voice, citations, and query fan-out for a brand */
224
+ get queryFanout(): QueryFanout {
225
+ return (this._queryFanout ??= new QueryFanout(this.client));
226
+ }
227
+
228
+ private _tags?: Tags;
229
+ /** The tags in use on a brand's prompts */
230
+ get tags(): Tags {
231
+ return (this._tags ??= new Tags(this.client));
232
+ }
233
+ }
234
+
235
+ export declare namespace Brands {
236
+ export type {
237
+ Analytics,
238
+ Brand,
239
+ BrandAnalytics,
240
+ BrandIdPath,
241
+ BrandOpportunities,
242
+ BrandQueryFanout,
243
+ BrandsList,
244
+ Citations,
245
+ CitedPage,
246
+ CreateBrandErrors,
247
+ CreateBrandParams,
248
+ CreateBrandResponses,
249
+ DateRange,
250
+ FanoutQuery,
251
+ GetBrandAnalyticsErrors,
252
+ GetBrandAnalyticsParams,
253
+ GetBrandAnalyticsResponses,
254
+ GetBrandErrors,
255
+ GetBrandOpportunitiesErrors,
256
+ GetBrandOpportunitiesResponses,
257
+ GetBrandQueryFanoutErrors,
258
+ GetBrandQueryFanoutParams,
259
+ GetBrandQueryFanoutResponses,
260
+ GetBrandResponses,
261
+ ListBrandPromptPerformanceErrors,
262
+ ListBrandPromptPerformanceParams,
263
+ ListBrandPromptPerformanceResponses,
264
+ ListBrandsErrors,
265
+ ListBrandsParams,
266
+ ListBrandsResponses,
267
+ ListBrandTagsErrors,
268
+ ListBrandTagsResponses,
269
+ ModelVisibility,
270
+ Opportunities,
271
+ Opportunity,
272
+ OpportunityPrompt,
273
+ PromptPerformanceSchema as PromptPerformance,
274
+ PromptPerformanceList,
275
+ PromptPerformance as PromptPerformanceResource,
276
+ QueryFanout,
277
+ ShareOfVoiceEntry,
278
+ ShareOfVoicePoint,
279
+ Tag,
280
+ TagList,
281
+ Tags,
282
+ TagsFilter,
283
+ UpdateBrandErrors,
284
+ UpdateBrandParams,
285
+ UpdateBrandResponses,
286
+ VisibilityPoint,
287
+ };
288
+ }
@@ -0,0 +1,213 @@
1
+ import { apiKeyRequirements } from './shared/auth';
2
+ import type { RequestOptions } from './shared/request-options';
3
+ import { ElmoResource } from './shared/resource';
4
+ import { nameRule } from './shared/rule';
5
+ import { callPromise, RestCallPromise } from '../internal/core/call-promise';
6
+ import { callable } from '../internal/core/callable';
7
+ import { PagePromise, pages } from '../internal/core/page';
8
+ import { groupParams, mergeParams, placeParams } from '../internal/core/params';
9
+ import type { Mutable } from '../internal/feature/validate';
10
+ import { decoded, reviving } from '../internal/feature/validate';
11
+ import type {
12
+ Competitor,
13
+ CompetitorsList,
14
+ CreateCompetitorErrors,
15
+ CreateCompetitorParams,
16
+ CreateCompetitorResponses,
17
+ DeleteCompetitorErrors,
18
+ DeleteCompetitorResponses,
19
+ GetCompetitorErrors,
20
+ GetCompetitorResponses,
21
+ ListCompetitorsErrors,
22
+ ListCompetitorsParams,
23
+ ListCompetitorsResponses,
24
+ UpdateCompetitorErrors,
25
+ UpdateCompetitorParams,
26
+ UpdateCompetitorResponses,
27
+ } from '../types/competitors';
28
+
29
+ function reviveCompetitor(value: Mutable<Competitor>): void {
30
+ if (value.createdAt != null) {
31
+ value.createdAt = decoded('Competitor.createdAt', value.createdAt, (raw) => new Date(raw));
32
+ }
33
+ if (value.updatedAt != null) {
34
+ value.updatedAt = decoded('Competitor.updatedAt', value.updatedAt, (raw) => new Date(raw));
35
+ }
36
+ }
37
+
38
+ function reviveCompetitorsList(value: Mutable<CompetitorsList>): void {
39
+ if (value.data != null) {
40
+ value.data.forEach((item) => {
41
+ reviveCompetitor(item);
42
+ });
43
+ }
44
+ if (value.competitors != null) {
45
+ value.competitors.forEach((item) => {
46
+ reviveCompetitor(item);
47
+ });
48
+ }
49
+ }
50
+
51
+ export const listCompetitorsDescriptor = /* @__PURE__ */ callable({
52
+ address: '/competitors',
53
+ auth: apiKeyRequirements,
54
+ method: 'get',
55
+ pagination: {
56
+ items: 'data',
57
+ limitParam: 'limit',
58
+ pages: 'pagination.totalPages',
59
+ param: 'page',
60
+ size: 'pagination.limit',
61
+ style: 'page',
62
+ total: 'pagination.total',
63
+ },
64
+ returns: 'json',
65
+ validators: { response: /* @__PURE__ */ reviving(reviveCompetitorsList) },
66
+ } as const);
67
+
68
+ export const createCompetitorDescriptor = /* @__PURE__ */ callable({
69
+ address: '/competitors',
70
+ auth: apiKeyRequirements,
71
+ mediaType: 'application/json',
72
+ method: 'post',
73
+ returns: 'json',
74
+ rules: [
75
+ {
76
+ min: 1,
77
+ name: 'brandId',
78
+ of: 'characters',
79
+ },
80
+ nameRule,
81
+ ],
82
+ validators: { response: /* @__PURE__ */ reviving(reviveCompetitor) },
83
+ } as const);
84
+
85
+ export const deleteCompetitorFields = { path: ['competitorId'] };
86
+
87
+ export const deleteCompetitorDescriptor = /* @__PURE__ */ callable({
88
+ address: '/competitors/{competitorId}',
89
+ auth: apiKeyRequirements,
90
+ method: 'delete',
91
+ returns: 'json',
92
+ validators: { response: /* @__PURE__ */ reviving(reviveCompetitor) },
93
+ } as const);
94
+
95
+ export const getCompetitorFields = { path: ['competitorId'] };
96
+
97
+ export const getCompetitorDescriptor = /* @__PURE__ */ callable({
98
+ address: '/competitors/{competitorId}',
99
+ auth: apiKeyRequirements,
100
+ method: 'get',
101
+ returns: 'json',
102
+ validators: { response: /* @__PURE__ */ reviving(reviveCompetitor) },
103
+ } as const);
104
+
105
+ export const updateCompetitorFields = { path: ['competitorId'] };
106
+
107
+ export const updateCompetitorDescriptor = /* @__PURE__ */ callable({
108
+ address: '/competitors/{competitorId}',
109
+ auth: apiKeyRequirements,
110
+ mediaType: 'application/json',
111
+ method: 'patch',
112
+ returns: 'json',
113
+ rules: [nameRule],
114
+ validators: { response: /* @__PURE__ */ reviving(reviveCompetitor) },
115
+ } as const);
116
+
117
+ /** Manage brand competitors */
118
+ export class Competitors extends ElmoResource {
119
+ /** Add a competitor */
120
+ public create(
121
+ params: CreateCompetitorParams,
122
+ options?: RequestOptions,
123
+ ): RestCallPromise<CreateCompetitorResponses, CreateCompetitorErrors> {
124
+ return callPromise(
125
+ options?.client ?? this.client,
126
+ createCompetitorDescriptor,
127
+ mergeParams(groupParams(params, 'body'), options),
128
+ );
129
+ }
130
+
131
+ /**
132
+ * Delete a competitor
133
+ *
134
+ * @param competitorId Competitor identifier (UUID)
135
+ */
136
+ public delete(
137
+ competitorId: string,
138
+ options?: RequestOptions,
139
+ ): RestCallPromise<DeleteCompetitorResponses, DeleteCompetitorErrors> {
140
+ return callPromise(
141
+ options?.client ?? this.client,
142
+ deleteCompetitorDescriptor,
143
+ mergeParams(placeParams({ competitorId }, deleteCompetitorFields, 'query'), options),
144
+ );
145
+ }
146
+
147
+ /**
148
+ * Get a competitor
149
+ *
150
+ * @param competitorId Competitor identifier (UUID)
151
+ */
152
+ public get(
153
+ competitorId: string,
154
+ options?: RequestOptions,
155
+ ): RestCallPromise<GetCompetitorResponses, GetCompetitorErrors> {
156
+ return callPromise(
157
+ options?.client ?? this.client,
158
+ getCompetitorDescriptor,
159
+ mergeParams(placeParams({ competitorId }, getCompetitorFields, 'query'), options),
160
+ );
161
+ }
162
+
163
+ public list(
164
+ params?: ListCompetitorsParams,
165
+ options?: RequestOptions,
166
+ ): PagePromise<Competitor, CompetitorsList, ListCompetitorsErrors> {
167
+ return pages(
168
+ options?.client ?? this.client,
169
+ listCompetitorsDescriptor,
170
+ mergeParams(groupParams(params, 'query'), options),
171
+ );
172
+ }
173
+
174
+ /**
175
+ * Update a competitor
176
+ *
177
+ * @param competitorId Competitor identifier (UUID)
178
+ */
179
+ public update(
180
+ competitorId: string,
181
+ params: UpdateCompetitorParams,
182
+ options?: RequestOptions,
183
+ ): RestCallPromise<UpdateCompetitorResponses, UpdateCompetitorErrors> {
184
+ return callPromise(
185
+ options?.client ?? this.client,
186
+ updateCompetitorDescriptor,
187
+ mergeParams(
188
+ placeParams({ ...params, competitorId }, updateCompetitorFields, 'body'),
189
+ options,
190
+ ),
191
+ );
192
+ }
193
+ }
194
+
195
+ export declare namespace Competitors {
196
+ export type {
197
+ Competitor,
198
+ CompetitorsList,
199
+ CreateCompetitorErrors,
200
+ CreateCompetitorParams,
201
+ CreateCompetitorResponses,
202
+ DeleteCompetitorErrors,
203
+ DeleteCompetitorResponses,
204
+ GetCompetitorErrors,
205
+ GetCompetitorResponses,
206
+ ListCompetitorsErrors,
207
+ ListCompetitorsParams,
208
+ ListCompetitorsResponses,
209
+ UpdateCompetitorErrors,
210
+ UpdateCompetitorParams,
211
+ UpdateCompetitorResponses,
212
+ };
213
+ }
@@ -0,0 +1,49 @@
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 type { Mutable } from '../internal/feature/validate';
7
+ import { decoded, reviving } from '../internal/feature/validate';
8
+ import type { APIKeyIdentity, GetMeErrors, GetMeResponses } from '../types/identity';
9
+
10
+ function reviveApiKeyIdentity(value: Mutable<APIKeyIdentity>): void {
11
+ if (value.createdAt != null) {
12
+ value.createdAt = decoded('ApiKeyIdentity.createdAt', value.createdAt, (raw) => new Date(raw));
13
+ }
14
+ if (value.expiresAt != null) {
15
+ value.expiresAt = decoded('ApiKeyIdentity.expiresAt', value.expiresAt, (raw) => new Date(raw));
16
+ }
17
+ if (value.lastUsedAt != null) {
18
+ value.lastUsedAt = decoded(
19
+ 'ApiKeyIdentity.lastUsedAt',
20
+ value.lastUsedAt,
21
+ (raw) => new Date(raw),
22
+ );
23
+ }
24
+ }
25
+
26
+ export const getMeDescriptor = /* @__PURE__ */ callable({
27
+ address: '/me',
28
+ auth: apiKeyRequirements,
29
+ method: 'get',
30
+ returns: 'json',
31
+ validators: { response: /* @__PURE__ */ reviving(reviveApiKeyIdentity) },
32
+ } as const);
33
+
34
+ /** What the calling key is and what it may reach */
35
+ export class Me extends ElmoResource {
36
+ /**
37
+ * Describe the calling key
38
+ *
39
+ * What this key is, which organization and brands it reaches, and which scopes it holds. Requires
40
+ * no scope, so it is always safe to call first when wiring up an integration.
41
+ */
42
+ public get(options?: RequestOptions): RestCallPromise<GetMeResponses, GetMeErrors> {
43
+ return callPromise(options?.client ?? this.client, getMeDescriptor, options);
44
+ }
45
+ }
46
+
47
+ export declare namespace Me {
48
+ export type { APIKeyIdentity, GetMeErrors, GetMeResponses };
49
+ }
@@ -0,0 +1,32 @@
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 type { ListModelsErrors, ListModelsResponses, Model, ModelList } from '../types/models';
7
+
8
+ export const listModelsDescriptor = /* @__PURE__ */ callable({
9
+ address: '/models',
10
+ auth: apiKeyRequirements,
11
+ method: 'get',
12
+ returns: 'json',
13
+ } as const);
14
+
15
+ /** The answer engines this deployment can track */
16
+ export class Models extends ElmoResource {
17
+ /**
18
+ * List trackable models
19
+ *
20
+ * The answer engines this deployment can track, so a client can build a model filter without
21
+ * hardcoding ids that differ between deployments.
22
+ *
23
+ * Requires no scope.
24
+ */
25
+ public list(options?: RequestOptions): RestCallPromise<ListModelsResponses, ListModelsErrors> {
26
+ return callPromise(options?.client ?? this.client, listModelsDescriptor, options);
27
+ }
28
+ }
29
+
30
+ export declare namespace Models {
31
+ export type { ListModelsErrors, ListModelsResponses, Model, ModelList };
32
+ }
@@ -0,0 +1,81 @@
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 type { Mutable } from '../internal/feature/validate';
8
+ import { decoded, reviving } from '../internal/feature/validate';
9
+ import type {
10
+ BrandOpportunities,
11
+ CitedPage,
12
+ GetBrandOpportunitiesErrors,
13
+ GetBrandOpportunitiesResponses,
14
+ Opportunity,
15
+ OpportunityPrompt,
16
+ } from '../types/opportunities';
17
+ import type { BrandIdPath } from '../types/shared/brand-id-path';
18
+
19
+ export const getBrandOpportunitiesFields = { path: ['brandId'] };
20
+
21
+ function reviveBrandOpportunities(value: Mutable<BrandOpportunities>): void {
22
+ if (value.generatedAt != null) {
23
+ value.generatedAt = decoded(
24
+ 'BrandOpportunities.generatedAt',
25
+ value.generatedAt,
26
+ (raw) => new Date(raw),
27
+ );
28
+ }
29
+ }
30
+
31
+ export const getBrandOpportunitiesDescriptor = /* @__PURE__ */ callable({
32
+ address: '/brands/{brandId}/opportunities',
33
+ auth: apiKeyRequirements,
34
+ method: 'get',
35
+ returns: 'json',
36
+ timeout: 600000,
37
+ validators: { response: /* @__PURE__ */ reviving(reviveBrandOpportunities) },
38
+ } as const);
39
+
40
+ /** Where a brand could win more citations, and why */
41
+ export class Opportunities extends ElmoResource {
42
+ /**
43
+ * Get the latest opportunities report
44
+ *
45
+ * **Experimental — the response shape may still change.**
46
+ *
47
+ * The brand's Opportunities report: a prioritized set of ways to get cited more often, with the
48
+ * tracked prompts and cited pages behind each one. The same analysis the dashboard shows, from
49
+ * the same code.
50
+ *
51
+ * Generation is inline and synchronous. A stored report is served while it is fresh and
52
+ * regenerated when it is not, so there is nothing to poll for and no way to be handed a stale one
53
+ * — but a request that triggers a generation waits for it. The freshness window bounds the cost:
54
+ * however many callers ask, one generation per brand per window. There is deliberately no `POST`,
55
+ * which would spend provider budget with nothing metering it per call.
56
+ *
57
+ * @experimental
58
+ * @param brandId Brand identifier.
59
+ */
60
+ public get(
61
+ brandId: BrandIdPath,
62
+ options?: RequestOptions,
63
+ ): RestCallPromise<GetBrandOpportunitiesResponses, GetBrandOpportunitiesErrors> {
64
+ return callPromise(
65
+ options?.client ?? this.client,
66
+ getBrandOpportunitiesDescriptor,
67
+ mergeParams(placeParams({ brandId }, getBrandOpportunitiesFields, 'query'), options),
68
+ );
69
+ }
70
+ }
71
+
72
+ export declare namespace Opportunities {
73
+ export type {
74
+ BrandOpportunities,
75
+ CitedPage,
76
+ GetBrandOpportunitiesErrors,
77
+ GetBrandOpportunitiesResponses,
78
+ Opportunity,
79
+ OpportunityPrompt,
80
+ };
81
+ }