@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.
Files changed (129) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +325 -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 +1029 -0
  9. package/dist/index.mjs.map +1 -0
  10. package/dist/request-options-DWYI_Ldj.d.mts +1550 -0
  11. package/dist/request-options-DWYI_Ldj.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-SwP0sK8H.mjs +2458 -0
  15. package/dist/tools-SwP0sK8H.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 +67 -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 +662 -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 +227 -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/params.ts +98 -0
  76. package/src/internal/core/protocol.ts +17 -0
  77. package/src/internal/core/read-reply.ts +7 -0
  78. package/src/internal/core/text.ts +7 -0
  79. package/src/internal/core/types.ts +556 -0
  80. package/src/internal/feature/auth.ts +201 -0
  81. package/src/internal/feature/interceptors.ts +36 -0
  82. package/src/internal/feature/logger.ts +222 -0
  83. package/src/internal/feature/retry.ts +165 -0
  84. package/src/internal/feature/rules.ts +54 -0
  85. package/src/internal/feature/timeout.ts +146 -0
  86. package/src/internal/feature/validate.ts +74 -0
  87. package/src/internal/page/page.ts +402 -0
  88. package/src/internal/transport/fetch.ts +82 -0
  89. package/src/resources/analytics.ts +363 -0
  90. package/src/resources/brands.ts +285 -0
  91. package/src/resources/competitors.ts +212 -0
  92. package/src/resources/identity.ts +48 -0
  93. package/src/resources/models.ts +32 -0
  94. package/src/resources/opportunities.ts +79 -0
  95. package/src/resources/organizations.ts +181 -0
  96. package/src/resources/prompts.ts +292 -0
  97. package/src/resources/reports.ts +211 -0
  98. package/src/resources/runs.ts +123 -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 +68 -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,1550 @@
1
+ import { $ as GetOrganizationBillingResponses, $t as BrandOpportunities, A as ListPromptsResponses, An as PromptPerformance$1, At as UpdateCompetitorResponses, B as MentionEntry, Bn as WindowStart, Bt as ListBrandsResponses, C as DeletePromptResponse, Cn as ListBrandCitationURLsErrors, Ct as GetCompetitorErrors, D as ListPromptsErrors, Dn as ListBrandPromptPerformanceParams, Dt as ListCompetitorsResponses, E as GetPromptResponses, En as ListBrandPromptPerformanceErrors, Et as ListCompetitorsParams, F as CitedURLEntry, Fn as VisibilityPoint, Ft as CreateBrandResponses, G as ListPromptRunsParams, Gn as UnauthorizedError, Gt as Page$1, H as GetRunErrors, Hn as ForbiddenError, Ht as UpdateBrandParams, I as GetPromptSnapshotErrors, In as ValidationError, It as GetBrandErrors, J as RunCitation, Jt as PaymentRequiredError$1, K as ListPromptRunsResponses, Kt as Limit, L as GetPromptSnapshotParams, Ln as NotFoundError$1, Lt as GetBrandResponses, M as UpdatePromptErrors, Mn as ShareOfVoiceEntry, Mt as BrandsList, N as UpdatePromptParams, Nn as ShareOfVoicePoint, Nt as CreateBrandErrors, O as ListPromptsParams, On as ListBrandPromptPerformanceResponses, Ot as UpdateCompetitorErrors, P as UpdatePromptResponses, Pn as TagsFilter, Pt as CreateBrandParams, Q as GetOrganizationBillingErrors, Qt as TagList, R as GetPromptSnapshotResponses, Rn as ModelFilter, Rt as ListBrandsErrors, S as DeletePromptErrors, Sn as ListBrandCitationDomainsResponses, St as DeleteCompetitorResponses, T as GetPromptErrors, Tn as ListBrandCitationURLsResponses, Tt as ListCompetitorsErrors, U as GetRunResponses, Un as InternalServerError$1, Ut as UpdateBrandResponses, V as MentionsSummary, Vn as Error$1, Vt as UpdateBrandErrors, W as ListPromptRunsErrors, Wn as RateLimitError$1, Wt as Pagination, X as RunSummary, Xt as ListBrandTagsResponses, Y as RunList, Yt as ListBrandTagsErrors, Z as BillingPlan, Zt as Tag, _ as ReportPromptSnapshot, _n as GetBrandQueryFanoutErrors, _t as CompetitorsList, a as CreateReportErrors, an as BrandIdPath, at as Organization, b as CreatePromptParams, bn as ListBrandCitationDomainsErrors, bt as CreateCompetitorResponses, c as CreateReportResponses, cn as CitationDomain, ct as PlanLimits, d as GetReportResponse, dn as CitationURLList, dt as Model, en as CitedPage, et as GetOrganizationErrors, f as GetReportResponses, fn as DateRange, ft as ModelList, g as ListReportsResponses, gn as GetBrandAnalyticsResponses, gt as Competitor, h as ListReportsResponse, hn as GetBrandAnalyticsParams, ht as GetMeResponses, i as OnboardingSuggestion, in as OpportunityPrompt, it as ListOrganizationsResponses, j as Prompt, jn as PromptPerformanceList, jt as Brand, k as ListPromptsResponse, kn as ModelVisibility, kt as UpdateCompetitorParams, l as GetReportErrors, ln as CitationDomainList, lt as ListModelsErrors, m as ListReportsParams, mn as GetBrandAnalyticsErrors, mt as GetMeErrors, n as AnalyzeBrandParams, nn as GetBrandOpportunitiesResponses, nt as ListOrganizationsErrors, o as CreateReportParams, on as BrandAnalytics, ot as OrganizationBilling, p as ListReportsErrors, pn as FanoutQuery, pt as APIKeyIdentity, q as Run, qt as ConflictError$1, r as AnalyzeBrandResponses, rn as Opportunity, rt as ListOrganizationsParams, s as CreateReportResponse, sn as BrandQueryFanout, st as OrganizationList, t as AnalyzeBrandErrors, tn as GetBrandOpportunitiesErrors, tt as GetOrganizationResponses, u as GetReportParams, un as CitationURL, ut as ListModelsResponses, v as ReportSummary, vn as GetBrandQueryFanoutParams, vt as CreateCompetitorErrors, w as DeletePromptResponses, wn as ListBrandCitationURLsParams, wt as GetCompetitorResponses, x as CreatePromptResponses, xn as ListBrandCitationDomainsParams, xt as DeleteCompetitorErrors, y as CreatePromptErrors, yn as GetBrandQueryFanoutResponses, yt as CreateCompetitorParams, z as PromptSnapshot, zn as WindowEnd, zt as ListBrandsParams } from "./tools-7Hs5J2xb.mjs";
2
+ //#region src/internal/core/backoff.d.ts
3
+ /**
4
+ * How much of each wait is random, so callers that failed together do not all
5
+ * come back at once.
6
+ *
7
+ * A number from 0 to 1 is the random share: `0.25` waits between three
8
+ * quarters of the computed wait and all of it. `'full'` is 1, `'equal'` is 0.5
9
+ * and `'none'` is 0. `true` is `'full'` and `false` is `'none'`.
10
+ */
11
+ type Jitter = boolean | number | 'equal' | 'full' | 'none';
12
+ /** How long the wait before each retry is. */
13
+ interface BackoffOptions {
14
+ /**
15
+ * Base delay in milliseconds.
16
+ *
17
+ * @default 500
18
+ */
19
+ delay?: number;
20
+ /**
21
+ * The share of each delay that is random.
22
+ *
23
+ * @default 'full'
24
+ */
25
+ jitter?: Jitter;
26
+ /**
27
+ * Upper bound on any single delay, in milliseconds.
28
+ *
29
+ * @default 30_000
30
+ */
31
+ maxDelay?: number;
32
+ /**
33
+ * How the wait grows. `'exponential'` doubles the base delay each time, up
34
+ * to `maxDelay`. `'constant'` waits the base delay every time.
35
+ *
36
+ * @default 'exponential'
37
+ */
38
+ strategy?: 'constant' | 'exponential';
39
+ }
40
+ /** A header the API may name its own wait in, and how to read its value. */
41
+ interface RetryAfterHeader {
42
+ /**
43
+ * Whether a number counts forward from now, or names a moment.
44
+ *
45
+ * @default 'duration'
46
+ */
47
+ readonly kind?: 'duration' | 'moment';
48
+ /** Header name, matched case-insensitively. */
49
+ readonly name: string;
50
+ /**
51
+ * What a number in this header counts in.
52
+ *
53
+ * @default 'second'
54
+ */
55
+ readonly unit?: 'millisecond' | 'second';
56
+ }
57
+ //#endregion
58
+ //#region src/internal/core/errors.d.ts
59
+ /** The base of every error this SDK throws, including one from a call that never arrived. */
60
+ declare class ElmoError extends Error {
61
+ /** The class's name. Compare it where `instanceof` fails, such as across two copies of this SDK. */
62
+ name: string;
63
+ }
64
+ /** Thrown before the request goes out, when no credential satisfied the call. */
65
+ declare class MissingCredentialError extends ElmoError {
66
+ readonly name = "MissingCredentialError";
67
+ /** Credential options that would have satisfied the call. */
68
+ readonly schemes: ReadonlyArray<string>;
69
+ constructor(message: string, schemes?: ReadonlyArray<string>);
70
+ }
71
+ /**
72
+ * Thrown when the caller called the request off before the API answered.
73
+ *
74
+ * Not a {@link TransportError}, so code that retries or reports a failed
75
+ * connection leaves a call the caller cancelled alone.
76
+ */
77
+ declare class AbortError extends ElmoError {
78
+ constructor(cause?: unknown);
79
+ }
80
+ /** Which way a {@link TransportError} failed. `connect` and `other` have no class of their own. */
81
+ type TransportErrorKind = 'connect' | 'other' | 'timeout';
82
+ /**
83
+ * A request that got no whole reply, as its transport states it.
84
+ *
85
+ * A transport rejects with one, or with a {@link TransportError} built from
86
+ * one. Any other rejection is read by its name and code.
87
+ */
88
+ interface TransportFailure {
89
+ /** `true` where the request was called off, not lost. */
90
+ aborted: boolean;
91
+ /** What the library underneath threw. */
92
+ cause?: unknown;
93
+ /**
94
+ * Whether the API can have acted on the request. After `'no'`, the call is
95
+ * safe to send again, whatever its method.
96
+ */
97
+ reachedServer: 'maybe' | 'no' | 'yes';
98
+ /** How far the request got. */
99
+ stage: 'connect' | 'receive' | 'resolve' | 'send' | 'tls';
100
+ }
101
+ /** Thrown when no whole answer arrived, so there is no reply to go on. */
102
+ declare class TransportError extends ElmoError {
103
+ readonly kind: TransportErrorKind;
104
+ /**
105
+ * Whether the API can have acted on the request. After `'no'`, the call is
106
+ * safe to send again, whatever its method.
107
+ */
108
+ readonly reachedServer: TransportFailure['reachedServer'];
109
+ /** How far the request got. */
110
+ readonly stage: TransportFailure['stage'];
111
+ constructor(failure: TransportErrorKind | TransportFailure, cause?: unknown, message?: string);
112
+ }
113
+ /**
114
+ * Thrown when a call waited on the API for as long as it allowed, from sending
115
+ * the request to the last byte of the reply.
116
+ *
117
+ * A reply with status 408 is an {@link APIError}, not one of these.
118
+ */
119
+ declare class TimeoutError extends TransportError {
120
+ /** Milliseconds the call was allowed to wait on the API. */
121
+ readonly timeoutMs: number | undefined;
122
+ constructor(timeout?: number, cause?: unknown, target?: string);
123
+ }
124
+ /** The body of a failure, as the API description declares it. */
125
+ type FailureBody = Error$1;
126
+ /** A failure the API answered with, so there is a status and a reply to read. */
127
+ declare class APIError<TBody = FailureBody> extends ElmoError {
128
+ /**
129
+ * The decoded failure body. `undefined` where the reply carried none, or
130
+ * carried text such as a proxy's page, which is in {@link APIError.text}.
131
+ */
132
+ readonly body: TBody | undefined;
133
+ /** The API's own error code, read from the failure body. `undefined` where it carried none. */
134
+ readonly code: string | number | undefined;
135
+ readonly headers: Headers;
136
+ /** The request id to quote when reporting this failure. */
137
+ readonly requestId: string | undefined;
138
+ /**
139
+ * The reply that carried this failure. Its body is already read, so take it
140
+ * from {@link APIError.body} or {@link APIError.text}.
141
+ */
142
+ readonly response: Response;
143
+ /** Milliseconds the API asked to wait before trying again. */
144
+ readonly retryAfterMs: number | undefined;
145
+ readonly status: number;
146
+ /**
147
+ * The failure body where the API sent text rather than JSON, such as a
148
+ * proxy's page. The message holds only its start.
149
+ */
150
+ readonly text: string | undefined;
151
+ constructor(status: number, body: unknown, response: Response, note?: string);
152
+ }
153
+ /** A reply from the API that this SDK could not read, whatever its status. */
154
+ declare class DecodeError extends ElmoError {
155
+ /** Where the value sat, or absent where the whole reply failed. */
156
+ readonly at: string | undefined;
157
+ /** The request id to quote when reporting this failure. */
158
+ readonly requestId: string | undefined;
159
+ /** The reply. Its body is already read. */
160
+ readonly response: Response | undefined;
161
+ /** The reply's status. `undefined` where there is no {@link DecodeError.response}. */
162
+ readonly status: number | undefined;
163
+ /** What the API sent. The message holds only a short form of it. */
164
+ readonly value: unknown;
165
+ constructor(message: string, options?: {
166
+ at?: string | undefined;
167
+ cause?: unknown;
168
+ response?: Response | undefined;
169
+ value?: unknown;
170
+ });
171
+ }
172
+ //#endregion
173
+ //#region src/internal/core/types.d.ts
174
+ /** A request body in a form `fetch` sends as it is. */
175
+ type BodyInput = NonNullable<RequestInit['body']>;
176
+ /** An encoded request body, or `null` for a request that sends none. */
177
+ type BodyPayload = BodyInput | null;
178
+ /**
179
+ * One reply, as far as it has been read. Until its body is read, only `ok`,
180
+ * `response` and `status` are set.
181
+ */
182
+ interface Result<TData = unknown, TError = unknown> {
183
+ /** The decoded body of a 2xx reply. */
184
+ data?: TData;
185
+ /** The decoded body of a reply that failed. */
186
+ error?: TError;
187
+ /** `true` for a 2xx status. */
188
+ ok?: boolean;
189
+ /** The reply itself, where one arrived. */
190
+ response?: Response;
191
+ status?: number;
192
+ }
193
+ interface CallLog {
194
+ ended(error?: unknown): void;
195
+ failed(error: unknown): void;
196
+ replied(response: Response | undefined): void;
197
+ retrying(wait: number, retry: number, retries: number, after?: Result): void;
198
+ sending(): void;
199
+ }
200
+ /** One way the API takes a credential, as the API description declares it. */
201
+ interface AuthScheme {
202
+ /**
203
+ * Where the credential is sent.
204
+ *
205
+ * @default 'header'
206
+ */
207
+ readonly in?: 'cookie' | 'header' | 'query';
208
+ /** Which credential this is. Its option, where it has one, has the same name. */
209
+ readonly key?: string;
210
+ /** The header, query parameter or cookie the credential is sent in. */
211
+ readonly name?: string;
212
+ /** How an `http` credential is written in the `Authorization` header. */
213
+ readonly scheme?: 'basic' | 'bearer';
214
+ /**
215
+ * `'apiKey'` sends the credential as it is, where `in` and `name` say.
216
+ * `'http'` sends it in the `Authorization` header, written as `scheme` says.
217
+ */
218
+ readonly type: 'apiKey' | 'http';
219
+ }
220
+ type AuthRequirement = AuthScheme | ReadonlyArray<AuthScheme>;
221
+ /** A time limit in milliseconds, or `false` for none. */
222
+ type CallTimeout = number | false;
223
+ interface InputRule {
224
+ readonly above?: number;
225
+ readonly below?: number;
226
+ readonly max?: number;
227
+ readonly min?: number;
228
+ readonly name?: string;
229
+ readonly of?: 'characters' | 'entries' | 'items';
230
+ }
231
+ type Interaction = 'unary';
232
+ type PaginationStyle = 'cursor' | 'link' | 'offset' | 'page';
233
+ interface PaginationDescriptor {
234
+ readonly cursor?: string;
235
+ readonly in?: 'body' | 'query';
236
+ readonly items?: string;
237
+ readonly limitParam?: string;
238
+ readonly link?: string;
239
+ readonly more?: string;
240
+ readonly pages?: string;
241
+ readonly param?: string;
242
+ readonly size?: string;
243
+ readonly start?: number;
244
+ readonly style: PaginationStyle;
245
+ readonly total?: string;
246
+ }
247
+ /** How a failed call is sent again. Anything left out keeps the client's rule. */
248
+ interface RetryRules extends BackoffOptions {
249
+ /**
250
+ * How long a call may keep trying, in milliseconds, counted from the first
251
+ * attempt with the waits included. A retry that would start past it is not
252
+ * sent, and the last reply or error stands. An attempt that is running is
253
+ * not cut short: `timeout` limits each one.
254
+ *
255
+ * @default no limit
256
+ */
257
+ budget?: number;
258
+ /**
259
+ * How many times a failed call is sent again, after the first attempt.
260
+ *
261
+ * @default 2
262
+ */
263
+ maxRetries?: number;
264
+ /**
265
+ * The longest wait the API may ask for, in milliseconds. Past it, the call
266
+ * gives up and returns the reply as it is.
267
+ *
268
+ * @default 60_000
269
+ */
270
+ maxRetryAfter?: number;
271
+ /**
272
+ * Methods that may be sent again. A failure that never reached the server,
273
+ * a call carrying its API's idempotency key, and 408, 425 and 429 are sent
274
+ * again whatever this says.
275
+ *
276
+ * @default idempotent methods
277
+ */
278
+ methods?: ReadonlyArray<string>;
279
+ /**
280
+ * Headers the API may name its own wait in, read before the backoff
281
+ * applies. `false` reads none.
282
+ *
283
+ * @default `retry-after-ms`, `retry-after`, `x-ratelimit-reset-after`,
284
+ * `x-ratelimit-reset` and `x-rate-limit-reset`, in that order
285
+ */
286
+ retryAfter?: ReadonlyArray<RetryAfterHeader> | boolean;
287
+ /**
288
+ * Send the request again when an attempt runs past its deadline.
289
+ *
290
+ * @default false
291
+ */
292
+ retryOnTimeout?: boolean;
293
+ /**
294
+ * Statuses worth another attempt. A reply with `x-should-retry: false` is
295
+ * never retried.
296
+ */
297
+ statuses?: ReadonlyArray<number>;
298
+ }
299
+ interface ParameterSerialization {
300
+ readonly allowReserved?: boolean;
301
+ readonly array?: {
302
+ readonly explode?: boolean;
303
+ readonly style?: string;
304
+ };
305
+ readonly mediaType?: string;
306
+ readonly object?: {
307
+ readonly explode?: boolean;
308
+ readonly style?: string;
309
+ };
310
+ }
311
+ interface SerializationDescriptor {
312
+ readonly query?: Readonly<Record<string, ParameterSerialization>>;
313
+ }
314
+ interface CallableDescriptor {
315
+ readonly accept?: string;
316
+ readonly address: string;
317
+ readonly auth?: ReadonlyArray<AuthRequirement>;
318
+ readonly authOptional?: boolean;
319
+ readonly baseURL?: string;
320
+ readonly deprecated?: boolean;
321
+ readonly idempotency?: string;
322
+ readonly interaction?: Interaction;
323
+ readonly mediaType?: string;
324
+ readonly method?: string;
325
+ readonly pagination?: PaginationDescriptor;
326
+ readonly retry?: RetryRules | false;
327
+ /** `'json'` where every success is declared as a JSON object or list. */
328
+ readonly returns?: 'json';
329
+ readonly rules?: ReadonlyArray<InputRule>;
330
+ readonly serialization?: SerializationDescriptor;
331
+ readonly timeout?: CallTimeout;
332
+ readonly validators?: unknown;
333
+ }
334
+ type MetadataValue = string | Array<string> | undefined;
335
+ type Metadata = Record<string, MetadataValue>;
336
+ interface Credential {
337
+ in: 'cookie' | 'header' | 'query';
338
+ name: string;
339
+ value: string;
340
+ }
341
+ interface PlacedCredential {
342
+ readonly credential: Credential;
343
+ readonly scheme: AuthScheme;
344
+ }
345
+ type BodyOptions = {
346
+ /** The request body, before it is encoded. */
347
+ body?: unknown;
348
+ };
349
+ type SignalOptions = {
350
+ /** Cancels this call when it fires, retries included. */
351
+ signal?: AbortSignal;
352
+ };
353
+ type ExchangeOptions = BodyOptions & SignalOptions;
354
+ /** A credential as a string, before it is written into the request. `undefined` sends none. */
355
+ type AuthToken = string | undefined;
356
+ /**
357
+ * Returns the credential to send for `scheme`, given the value its option
358
+ * holds. `undefined` sends none for that scheme.
359
+ */
360
+ type AuthResolver = (scheme: AuthScheme, value: AuthToken) => Promise<AuthToken> | AuthToken;
361
+ /** What the `auth` option takes: an {@link AuthResolver}, or `null` to send none. */
362
+ type AuthValue = AuthResolver | null;
363
+ type BodySerializerOptions = {
364
+ /**
365
+ * Encodes the request body, in place of the default for its content type.
366
+ * `null` sends the body as given.
367
+ */
368
+ bodySerializer?: ((body: unknown) => BodyPayload) | null;
369
+ };
370
+ type BaseURLOptions<TBaseURL = string> = {
371
+ /** The base URL for this call, in place of the client's. */
372
+ baseURL?: TBaseURL;
373
+ };
374
+ type CredentialOptions<TAuth = AuthValue> = {
375
+ /**
376
+ * Decides each credential a call sends, given the scheme and the value its
377
+ * option holds. What it returns is sent, so return the value to keep it.
378
+ * `null` sends no credential.
379
+ */
380
+ auth?: TAuth;
381
+ };
382
+ type EnvironmentOptions<TEnvironment = string> = {
383
+ /** Which environment to send to. `baseURL` wins over this. */
384
+ environment?: TEnvironment;
385
+ };
386
+ type ConnectionOptions<TBaseURL = string, TAuth = AuthValue, TEnvironment = string> = BaseURLOptions<TBaseURL> & CredentialOptions<TAuth> & ([TEnvironment] extends [never] ? unknown : EnvironmentOptions<TEnvironment>);
387
+ /**
388
+ * How a failure reaches the caller.
389
+ *
390
+ * - `'throw'` resolves to the payload and throws the failure.
391
+ * - `'return'` resolves to the result envelope and throws no failure of the
392
+ * call. What one of your own functions throws is still thrown.
393
+ */
394
+ type ErrorMode = 'return' | 'throw';
395
+ type ErrorOptions = {
396
+ /**
397
+ * Whether a failure is thrown or handed back beside the data. Set on a
398
+ * client's defaults, not per call.
399
+ *
400
+ * @default 'throw'
401
+ */
402
+ errors?: ErrorMode;
403
+ };
404
+ /** Headers as a `Headers`, as pairs of name and value, or as an object. */
405
+ type MetadataInput = Headers | Iterable<readonly [string, string]> | Record<string, unknown>;
406
+ /** What a call sends beside its body. Each member is merged per name. */
407
+ type MetadataOptions = {
408
+ /** Headers to send. Merged per name, and `null` drops one. */
409
+ headers?: MetadataInput;
410
+ /** Path parameters. Merged per name. */
411
+ path?: Record<string, unknown>;
412
+ /** Query parameters to add. Merged per name, and `null` drops one. */
413
+ query?: Record<string, unknown>;
414
+ };
415
+ type SharedOptions<TAddress = string, TAuth = AuthValue, TEnvironment = string> = BodySerializerOptions & ConnectionOptions<TAddress, TAuth, TEnvironment> & ErrorOptions & MetadataOptions;
416
+ type CallOptions = ExchangeOptions & SharedOptions;
417
+ interface ResolvedOptions extends CallOptions {
418
+ [key: string]: unknown;
419
+ envelope?: boolean;
420
+ path?: Record<string, unknown>;
421
+ query?: Record<string, unknown>;
422
+ raw?: boolean;
423
+ unread?: boolean;
424
+ }
425
+ /** A request about to be sent, which a `request` hook reads and may change. */
426
+ interface PreparedRequest<TAddress = unknown> {
427
+ /** Where the request goes. Over HTTP, the whole URL, query string included. */
428
+ address: TAddress;
429
+ /** How many times this request was sent before. Unset on the first attempt. */
430
+ attempt?: number;
431
+ /** The request body, already encoded. */
432
+ body: BodyPayload | undefined;
433
+ /** The operation this request calls, as declared, `method` included. */
434
+ callable: CallableDescriptor;
435
+ /** How the call exchanges messages, such as one request for one reply. */
436
+ interaction: Interaction;
437
+ /** Where this call writes its log lines. Unset where the client does not log. */
438
+ log?: CallLog;
439
+ /** The headers to send, by lowercase name. */
440
+ meta: Metadata;
441
+ /** The options this call resolved to: the client's, with the call's own on top. */
442
+ options: ResolvedOptions;
443
+ /** Each credential put on the request, with the scheme it answers. */
444
+ placed?: ReadonlyArray<PlacedCredential>;
445
+ /**
446
+ * Set to `manual` by a feature that follows redirects itself. A transport
447
+ * that honors it hands back the redirect rather than following it.
448
+ */
449
+ redirect?: 'manual';
450
+ /** Calls the request off when it aborts. */
451
+ signal?: AbortSignal | undefined;
452
+ /** What to tell the caller where the API refuses a call sent with no credential. */
453
+ unauthenticated?: () => string;
454
+ }
455
+ /** The kinds of exchange a transport carries. `unary` is one request and one reply. */
456
+ type TransportInteraction = 'unary';
457
+ interface UnaryTransport<TAddress> {
458
+ /**
459
+ * Sends one request and resolves to the reply, whatever its status, with the
460
+ * body unread. Rejects only when no reply arrived.
461
+ */
462
+ unary(request: PreparedRequest<TAddress>): Promise<Response>;
463
+ }
464
+ type TransportMethods<TAddress> = UnaryTransport<TAddress>;
465
+ /** What carries a request to the API and hands back what the API sends. */
466
+ type Transport<TAddress, TInteraction extends TransportInteraction> = {
467
+ /** The transport's name, as an error message shows it. */
468
+ readonly name: string;
469
+ } & Pick<TransportMethods<TAddress>, TInteraction>;
470
+ /** A credential, or a function that returns one when a call needs it. */
471
+ type CredentialValue = AuthToken | (() => Promise<AuthToken> | AuthToken);
472
+ interface Codec {
473
+ readonly contentType: string | undefined;
474
+ decode?(raw: Response): Promise<unknown>;
475
+ encode(value: unknown): BodyPayload;
476
+ readonly mediaTypes: ReadonlyArray<string>;
477
+ readonly name: string;
478
+ }
479
+ type AnyTransport<TAddress = unknown> = {
480
+ readonly name: string;
481
+ } & Partial<TransportMethods<TAddress>>;
482
+ interface Binding<TAddress = unknown> {
483
+ /** What a request asks for where neither its call nor its client says. */
484
+ readonly accept?: string;
485
+ applyAuth(credential: Credential, request: PreparedRequest<TAddress>): void;
486
+ readonly name: string;
487
+ readError?(result: Result, request: PreparedRequest<TAddress>): unknown;
488
+ readResult?(raw: Response, request: PreparedRequest<TAddress>, codecs: ReadonlyArray<Codec>): Promise<Result>;
489
+ resolveAddress(callable: CallableDescriptor, options: ResolvedOptions): TAddress;
490
+ }
491
+ interface FeatureContext {
492
+ binding: Binding;
493
+ transport: AnyTransport;
494
+ }
495
+ type Send = (request: PreparedRequest) => Promise<Result>;
496
+ interface Feature {
497
+ readonly name: string;
498
+ onError?(error: unknown, request: PreparedRequest, ctx: FeatureContext): unknown;
499
+ onOpen?(request: PreparedRequest, next: Send, ctx: FeatureContext): Promise<Result>;
500
+ onOptions?(options: ResolvedOptions, callable: CallableDescriptor, ctx: FeatureContext): Promise<void> | void;
501
+ onPrepare?(request: PreparedRequest, ctx: FeatureContext): Promise<void> | void;
502
+ onRequest?(request: PreparedRequest, ctx: FeatureContext): Promise<void> | void;
503
+ onResult?(result: Result, request: PreparedRequest, ctx: FeatureContext): Promise<Result> | Result;
504
+ onSend?(request: PreparedRequest, next: Send, ctx: FeatureContext): Promise<Result>;
505
+ }
506
+ type CredentialSpec = {
507
+ readonly option?: false;
508
+ readonly prefix?: string;
509
+ readonly variable?: string;
510
+ };
511
+ type Hundred = 3 | 4 | 5;
512
+ type Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
513
+ type NumberOf<T> = T extends `${infer N extends number}` ? N : never;
514
+ type Tens = { [H in Hundred]: { [T in Digit]: NumberOf<`${H}${T}${Digit}`>; }; };
515
+ type Block = { [H in Hundred]: Tens[H][Digit]; };
516
+ type SplitDigits<TText> = TText extends `${infer H}${infer T}${string}` ? [NumberOf<H>, NumberOf<T>] : never;
517
+ type DigitsOf<TStatus> = TStatus extends number ? SplitDigits<`${TStatus}`> : never;
518
+ type LeftIn<H extends Hundred, TExact> = H extends DigitsOf<TExact>[0] ? { [T in Digit]: [H, T] extends DigitsOf<TExact> ? Exclude<Tens[H][T], TExact> : Tens[H][T]; }[Digit] : Block[H];
519
+ type Left<THundreds, TExact> = THundreds extends Hundred ? LeftIn<THundreds, TExact> : never;
520
+ type RangeDigit<TKey> = TKey extends `${infer D extends number}${'X' | 'x'}${'X' | 'x'}` ? D & Hundred : never;
521
+ type Open<TErrors> = Exclude<Hundred, RangeDigit<keyof TErrors>>;
522
+ type StatusKey<TKey> = TKey extends number ? TKey : NumberOf<TKey>;
523
+ type DefaultStatus<TErrors> = Left<Open<TErrors>, StatusKey<keyof TErrors>> & number;
524
+ type RangeStatus<TErrors, TKey> = Left<RangeDigit<TKey>, StatusKey<keyof TErrors>> & number;
525
+ type FailureStatusOf<TErrors, TKey> = TKey extends number ? TKey : TKey extends `${infer N extends number}` ? N : Lowercase<TKey & string> extends 'default' ? DefaultStatus<TErrors> : RangeStatus<TErrors, TKey>;
526
+ type UndeclaredStatus<TErrors> = ('default' extends Lowercase<Extract<keyof TErrors, string>> ? 0 : 0 | Left<Open<TErrors>, StatusKey<keyof TErrors>>) & number;
527
+ type ErrorOf<TErrors> = (TErrors extends object ? { [K in keyof TErrors]: {
528
+ data?: never;
529
+ error: APIError<TErrors[K]>;
530
+ ok: false;
531
+ status: FailureStatusOf<TErrors, K>;
532
+ }; }[keyof TErrors] : never) | {
533
+ data?: never;
534
+ error: APIError;
535
+ ok: false;
536
+ status: UndeclaredStatus<TErrors>;
537
+ };
538
+ type StatusOf<TKey> = TKey extends number ? TKey : number;
539
+ type OutputOf<TResponses> = TResponses extends object ? { [K in keyof TResponses]: {
540
+ data: TResponses[K];
541
+ error?: never;
542
+ ok: true;
543
+ status: StatusOf<K>;
544
+ }; }[keyof TResponses] : Result;
545
+ type UnansweredOf = {
546
+ data?: never;
547
+ error: ElmoError;
548
+ ok: false;
549
+ status?: undefined;
550
+ };
551
+ /**
552
+ * What awaiting a call gives back: the payload, or the whole result where the
553
+ * client returns a failure in place of throwing it.
554
+ */
555
+ type CallResult<TResponses = unknown, TErrors = unknown, TMode extends ErrorMode = 'throw'> = TMode extends 'return' ? ErrorOf<TErrors> | OutputOf<TResponses> | UnansweredOf : TResponses extends object ? TResponses[keyof TResponses] : unknown;
556
+ type PageOptions = {
557
+ /**
558
+ * Where to start reading, from an earlier page's `nextPageParam`. Unset, the
559
+ * walk starts at the page the call's own arguments name.
560
+ */
561
+ pageParam?: unknown;
562
+ };
563
+ /** What `result()` gives back: the payload, or the failure as a value. */
564
+ type ResultEnvelope<TResponses = unknown, TErrors = unknown> = CallResult<TResponses, TErrors, 'return'>;
565
+ /** What a paged call hands back when its failure is read rather than thrown. */
566
+ type PageEnvelope<TAwaited = unknown, TErrors = unknown> = ErrorOf<TErrors> | UnansweredOf | {
567
+ data: TAwaited;
568
+ error?: never;
569
+ ok: true;
570
+ status: number;
571
+ };
572
+ /**
573
+ * What awaiting a paged call gives back: the page, or the whole result where
574
+ * the client returns a failure in place of throwing it.
575
+ */
576
+ type PageResult<TAwaited = unknown, TErrors = unknown, TMode extends ErrorMode = 'throw'> = TMode extends 'return' ? PageEnvelope<TAwaited, TErrors> : TAwaited;
577
+ //#endregion
578
+ //#region src/internal/core/protocol.d.ts
579
+ type Protocol = 'channel' | 'rest' | 'websocket';
580
+ interface ProtocolSetup {
581
+ binding: Binding;
582
+ transport: AnyTransport;
583
+ }
584
+ type Protocols = Partial<Record<Protocol, ProtocolSetup>>;
585
+ //#endregion
586
+ //#region src/internal/core/dispatch.d.ts
587
+ interface DispatchSetup {
588
+ accept?: string;
589
+ aliases?: Readonly<Record<string, string>>;
590
+ codecs: ReadonlyArray<Codec>;
591
+ credentials?: Readonly<Record<string, CredentialSpec>>;
592
+ defaults: ResolvedOptions;
593
+ env?: Readonly<Record<string, string>>;
594
+ features?: ReadonlyArray<Feature>;
595
+ guard?: (options: ResolvedOptions) => void;
596
+ protocols: Protocols;
597
+ transports?: (name: string) => AnyTransport;
598
+ }
599
+ interface Exchange {
600
+ read(from?: Response): Promise<unknown>;
601
+ requestId(): string | undefined;
602
+ readonly response: Response | undefined;
603
+ }
604
+ //#endregion
605
+ //#region src/internal/core/client.d.ts
606
+ /** What every call is sent through. It holds the options all calls share. */
607
+ interface Client {
608
+ /** @internal */
609
+ call<TData = unknown, TError = unknown, TMode extends ErrorMode = 'throw'>(callable: CallableDescriptor, options?: ResolvedOptions): Promise<CallResult<TData, TError, TMode>>;
610
+ /** @internal */
611
+ exchange(callable: CallableDescriptor, options?: ResolvedOptions): Promise<Exchange>;
612
+ /** @internal */
613
+ prepare<TAddress = unknown>(callable: CallableDescriptor, options?: ResolvedOptions): Promise<PreparedRequest<TAddress>>;
614
+ /** @internal */
615
+ resolveAddress<TAddress = unknown>(callable: CallableDescriptor, options?: ResolvedOptions): TAddress;
616
+ /** @internal */
617
+ readonly setup: DispatchSetup;
618
+ }
619
+ //#endregion
620
+ //#region src/internal/core/lazy-promise.d.ts
621
+ declare abstract class LazyPromise<T> extends Promise<T> {
622
+ private answer;
623
+ constructor();
624
+ protected abstract settle(): Promise<T>;
625
+ private answered;
626
+ then<TResolved = T, TCaught = never>(onFulfilled?: ((value: T) => PromiseLike<TResolved> | TResolved) | null, onRejected?: ((reason: unknown) => PromiseLike<TCaught> | TCaught) | null): Promise<TCaught | TResolved>;
627
+ catch<TCaught = never>(onRejected?: ((reason: unknown) => PromiseLike<TCaught> | TCaught) | null): Promise<T | TCaught>;
628
+ finally(onFinally?: (() => void) | null): Promise<T>;
629
+ static get [Symbol.species](): PromiseConstructor;
630
+ }
631
+ //#endregion
632
+ //#region src/internal/core/call-promise.d.ts
633
+ /** A call already sent, whose reply is not yet read. */
634
+ declare class CallPromise<TResponses = unknown, TErrors = unknown, TMode extends ErrorMode = 'throw'> extends LazyPromise<CallResult<TResponses, TErrors, TMode>> {
635
+ protected readonly client: Client;
636
+ protected readonly exchange: Promise<Exchange>;
637
+ protected readonly options: ResolvedOptions;
638
+ private envelope;
639
+ constructor(client: Client, callable: CallableDescriptor, options?: ResolvedOptions);
640
+ /**
641
+ * The whole result envelope. A failure of the call is returned on it, not
642
+ * thrown. What one of your own functions throws, such as a hook, is thrown
643
+ * as it is.
644
+ */
645
+ result(): Promise<ResultEnvelope<TResponses, TErrors>>;
646
+ /** The payload alone, with a failure thrown rather than handed back. */
647
+ unwrap(): Promise<CallResult<TResponses, TErrors, 'throw'>>;
648
+ private read;
649
+ protected settle(): Promise<CallResult<TResponses, TErrors, TMode>>;
650
+ protected decode(): Promise<ResultEnvelope<TResponses, TErrors>>;
651
+ }
652
+ /** What a call resolves with where its `Response` is asked for as well. */
653
+ interface WithResponse<TData> {
654
+ /** What the call resolves with on its own. */
655
+ data: TData;
656
+ /** The request id to quote when reporting a problem with the call. */
657
+ requestId: string | undefined;
658
+ /** The `Response` that carried `data`. Its body is already read. */
659
+ response: Response;
660
+ }
661
+ /** A call already sent, whose `Response` can be read as well as its payload. */
662
+ declare class RestCallPromise<TResponses = unknown, TErrors = unknown, TMode extends ErrorMode = 'throw'> extends CallPromise<TResponses, TErrors, TMode> {
663
+ private claimed;
664
+ private unread;
665
+ /**
666
+ * The `Response` itself, with its body unread and yours to read once. An
667
+ * error status does not throw here. A call that got no response does.
668
+ */
669
+ asResponse(): Promise<Response>;
670
+ /** The decoded body, the `Response` that carried it, and the request id. */
671
+ withResponse(): Promise<WithResponse<CallResult<TResponses, TErrors, TMode>>>;
672
+ protected decode(): Promise<ResultEnvelope<TResponses, TErrors>>;
673
+ private claim;
674
+ }
675
+ //#endregion
676
+ //#region src/internal/binding/rest/errors.d.ts
677
+ /** The API could not read the request, so it did not act on it. */
678
+ declare class BadRequestError extends APIError {
679
+ readonly name = "BadRequestError";
680
+ readonly status: 400;
681
+ }
682
+ /** No usable credential reached the API: it was missing, unreadable, or rejected. */
683
+ declare class AuthenticationError extends APIError {
684
+ readonly name = "AuthenticationError";
685
+ readonly status: 401;
686
+ }
687
+ /** The plan or the quota on this account does not cover the call. */
688
+ declare class PaymentRequiredError extends APIError {
689
+ readonly name = "PaymentRequiredError";
690
+ readonly status: 402;
691
+ }
692
+ /** The credential was accepted, but it does not grant this call. */
693
+ declare class PermissionDeniedError extends APIError {
694
+ readonly name = "PermissionDeniedError";
695
+ readonly status: 403;
696
+ }
697
+ /** Nothing is at this address, or the credential may not see what is. */
698
+ declare class NotFoundError extends APIError {
699
+ readonly name = "NotFoundError";
700
+ readonly status: 404;
701
+ }
702
+ /** The call collided with the resource's current state: a duplicate, or a concurrent change. */
703
+ declare class ConflictError extends APIError {
704
+ readonly name = "ConflictError";
705
+ readonly status: 409;
706
+ }
707
+ /** The request was read, and its contents were rejected. */
708
+ declare class UnprocessableEntityError extends APIError {
709
+ readonly name = "UnprocessableEntityError";
710
+ readonly status: 422;
711
+ }
712
+ /** Too many calls. {@link APIError.retryAfterMs} carries how long the API asked to wait. */
713
+ declare class RateLimitError extends APIError {
714
+ readonly name = "RateLimitError";
715
+ readonly status: 429;
716
+ }
717
+ /** The API failed after accepting the call. Every status from 500 up arrives as this. */
718
+ declare class InternalServerError extends APIError {
719
+ readonly name = "InternalServerError";
720
+ }
721
+ //#endregion
722
+ //#region src/internal/feature/interceptors.d.ts
723
+ /** Hooks of your own, run in order at three points in every call. */
724
+ interface Interceptors {
725
+ /** Runs when a call fails. Return the error to raise, which may be another. */
726
+ error?: ReadonlyArray<(error: unknown, request: PreparedRequest) => unknown>;
727
+ /** Runs on the built request, last before it is sent. */
728
+ request?: ReadonlyArray<(request: PreparedRequest) => Promise<void> | void>;
729
+ /** Runs on the reply. Return the result to read, which may be another. */
730
+ response?: ReadonlyArray<(result: Result, request: PreparedRequest) => Promise<Result> | Result>;
731
+ }
732
+ //#endregion
733
+ //#region src/internal/feature/logger.d.ts
734
+ /** One method of a {@link Logger}: a message, then the values logged with it. */
735
+ type LogFn = (message: string, ...rest: ReadonlyArray<unknown>) => void;
736
+ /** Where log lines go, such as `console`. */
737
+ interface Logger {
738
+ debug: LogFn;
739
+ error: LogFn;
740
+ info: LogFn;
741
+ warn: LogFn;
742
+ }
743
+ /**
744
+ * How much a client logs. `'error'` writes failed calls. `'warn'` adds a retry
745
+ * or a redirect. `'info'` adds a line per attempt, with its status and time.
746
+ * `'debug'` adds headers, with credentials hidden.
747
+ */
748
+ type LogLevel = 'debug' | 'error' | 'info' | 'off' | 'warn';
749
+ //#endregion
750
+ //#region src/internal/feature/retry.d.ts
751
+ /** Which failed calls are sent again, how many times, and how long each waits first. */
752
+ interface RetryOptions extends RetryRules {
753
+ /**
754
+ * How long to wait before the next attempt, in milliseconds, in place of the
755
+ * API's retry headers and the backoff. `undefined` keeps the usual wait.
756
+ * After a failure that got no reply, `result` holds only the `error`.
757
+ * **{@link maxRetryAfter} does not limit what this returns.**
758
+ */
759
+ retryDelay?(result: Result, request: PreparedRequest, attempt: number): number | undefined;
760
+ /**
761
+ * Whether to retry, in place of `statuses`, `x-should-retry` and
762
+ * `retryOnTimeout`. After a reply, the body is unread: read it from
763
+ * `response.clone()`. After a failure that got no reply, `result` holds only
764
+ * the `error`. A call the API may have acted on is never asked about: a
765
+ * method outside `methods` is sent again only after 408, 425 or 429, or when
766
+ * the request never reached the API.
767
+ */
768
+ retryOn?(result: Result, request: PreparedRequest): boolean;
769
+ }
770
+ //#endregion
771
+ //#region src/internal/feature/timeout.d.ts
772
+ /**
773
+ * Chooses the limit of one call, given the operation as `METHOD /path` and the
774
+ * limit it would otherwise get. `undefined` keeps that limit.
775
+ */
776
+ type TimeoutPolicy = (operation: string, timeout: CallTimeout) => CallTimeout | undefined;
777
+ /** A limit in milliseconds, `false` for none, or a policy choosing one per call. */
778
+ type TimeoutValue = CallTimeout | TimeoutPolicy;
779
+ //#endregion
780
+ //#region src/internal/page/page.d.ts
781
+ /**
782
+ * One page of a paginated call. Iterating a page walks from it to the end of
783
+ * the collection.
784
+ */
785
+ interface Page<TItem = unknown, TBody = unknown> extends AsyncIterable<TItem> {
786
+ /** The whole reply body, counts and all. */
787
+ readonly body: TBody;
788
+ /** The items on this page. */
789
+ readonly data: ReadonlyArray<TItem>;
790
+ /** The next page. Throws if `hasNextPage()` is `false`. */
791
+ getNextPage(): Promise<Page<TItem, TBody>>;
792
+ /** Whether a page follows this one. It sends no request. */
793
+ hasNextPage(): boolean;
794
+ /**
795
+ * Where the page after this one begins, or `undefined` when none follows.
796
+ * Pass it back as `pageParam` to resume from here.
797
+ */
798
+ readonly nextPageParam: unknown;
799
+ /** The HTTP status of the reply that carried this page. */
800
+ readonly status: number;
801
+ }
802
+ /**
803
+ * A paginated call. Awaiting it gives the first page, or its result envelope
804
+ * under the `'return'` error mode. Iterating it gives every item on every page,
805
+ * and throws on a failed page under either mode.
806
+ */
807
+ declare class PagePromise<TItem = unknown, TBody = unknown, TErrors = unknown, TAwaited = Page<TItem, TBody>, TMode extends ErrorMode = 'throw'> extends LazyPromise<PageResult<TAwaited, TErrors, TMode>> implements AsyncIterable<TItem> {
808
+ private envelope;
809
+ private readonly callable;
810
+ private readonly client;
811
+ private readonly limit;
812
+ private readonly maxPages;
813
+ private readonly options;
814
+ private readonly pagination;
815
+ private readonly project;
816
+ private readonly first;
817
+ constructor(client: Client, callable: CallableDescriptor, options: ResolvedOptions, project: (page: Page<TItem, TBody>) => TAwaited);
818
+ /** Every item, page after page, up to `maxPages`. */
819
+ [Symbol.asyncIterator](): AsyncGenerator<TItem>;
820
+ /** Every page, up to `maxPages`. */
821
+ iterPages(): AsyncIterable<Page<TItem, TBody>>;
822
+ /**
823
+ * The whole result envelope. A failure of the call is returned on it, not
824
+ * thrown. What one of your own functions throws, such as a hook, is thrown
825
+ * as it is.
826
+ */
827
+ result(): Promise<PageEnvelope<TAwaited, TErrors>>;
828
+ /** The page alone, with a failure thrown rather than handed back. */
829
+ unwrap(): Promise<TAwaited>;
830
+ private read;
831
+ protected settle(): Promise<PageResult<TAwaited, TErrors, TMode>>;
832
+ }
833
+ //#endregion
834
+ //#region src/internal/transport/fetch.d.ts
835
+ /** A `fetch` function, called with the full address and a built `RequestInit`. */
836
+ type Fetch = (input: string, init: RequestInit) => Promise<Response>;
837
+ /** What `fetch` takes, less what the client sets itself. */
838
+ interface FetchOptions extends RequestInit {
839
+ /** Set by the client. */
840
+ body?: never;
841
+ /** Set by the client. Pass `headers` to the call. */
842
+ headers?: never;
843
+ /** Set by the client. */
844
+ method?: never;
845
+ /** Set by the client. Pass `signal` to the call. */
846
+ signal?: never;
847
+ }
848
+ //#endregion
849
+ //#region src/resources/shared/resource.d.ts
850
+ declare class ElmoResource {
851
+ /** The client every call on this SDK dispatches through. */
852
+ readonly client: Client;
853
+ constructor(client: Client);
854
+ /**
855
+ * The same calls, with different options.
856
+ *
857
+ * Options given here layer over the ones already in force. Headers, path
858
+ * parameters and query parameters merge per name. Everything else replaces.
859
+ * What this was called on does not change.
860
+ */
861
+ withOptions(options: ClientOptions): this;
862
+ }
863
+ //#endregion
864
+ //#region src/resources/analytics.d.ts
865
+ /** Aggregated visibility, share of voice, citations, and query fan-out for a brand */
866
+ declare class Analytics extends ElmoResource {
867
+ /**
868
+ * Get a brand's analytics
869
+ *
870
+ * Visibility, share of voice, the per-model breakdown and the citation totals for one window, in
871
+ * one request.
872
+ *
873
+ * The long lists — cited domains and URLs, sub-queries, per-prompt results — are endpoints of
874
+ * their own. Everything else is always included.
875
+ *
876
+ * @param brandId Brand identifier.
877
+ */
878
+ get(brandId: BrandIdPath, params: GetBrandAnalyticsParams, options?: RequestOptions): RestCallPromise<GetBrandAnalyticsResponses, GetBrandAnalyticsErrors>;
879
+ }
880
+ /** Aggregated visibility, share of voice, citations, and query fan-out for a brand */
881
+ declare class Domains extends ElmoResource {
882
+ /**
883
+ * List cited domains
884
+ *
885
+ * Domains the engines cited when answering this brand's prompts, categorized and compared against
886
+ * the equal-length window immediately before this one.
887
+ *
888
+ * @param brandId Brand identifier.
889
+ */
890
+ list(brandId: BrandIdPath, params: ListBrandCitationDomainsParams, options?: RequestOptions): RestCallPromise<ListBrandCitationDomainsResponses, ListBrandCitationDomainsErrors>;
891
+ }
892
+ /** Aggregated visibility, share of voice, citations, and query fan-out for a brand */
893
+ declare class URLs extends ElmoResource {
894
+ /**
895
+ * List cited URLs
896
+ *
897
+ * Individual pages the engines cited, with their category and page type.
898
+ *
899
+ * @param brandId Brand identifier.
900
+ */
901
+ list(brandId: BrandIdPath, params: ListBrandCitationURLsParams, options?: RequestOptions): RestCallPromise<ListBrandCitationURLsResponses, ListBrandCitationURLsErrors>;
902
+ }
903
+ declare class Citations extends ElmoResource {
904
+ private _domains?;
905
+ /** Aggregated visibility, share of voice, citations, and query fan-out for a brand */
906
+ get domains(): Domains;
907
+ private _urls?;
908
+ /** Aggregated visibility, share of voice, citations, and query fan-out for a brand */
909
+ get urls(): URLs;
910
+ }
911
+ /** Aggregated visibility, share of voice, citations, and query fan-out for a brand */
912
+ declare class PromptPerformance extends ElmoResource {
913
+ /**
914
+ * List prompt performance
915
+ *
916
+ * Per-prompt mention rates over the window. The analytics counterpart to `GET /prompts?brandId=`,
917
+ * which returns prompt configuration rather than results.
918
+ *
919
+ * A prompt the brand stopped tracking is not sampled, so it has no results over the window and
920
+ * does not appear here.
921
+ *
922
+ * @param brandId Brand identifier.
923
+ */
924
+ list(brandId: BrandIdPath, params: ListBrandPromptPerformanceParams, options?: RequestOptions): RestCallPromise<ListBrandPromptPerformanceResponses, ListBrandPromptPerformanceErrors>;
925
+ }
926
+ /** Aggregated visibility, share of voice, citations, and query fan-out for a brand */
927
+ declare class QueryFanout extends ElmoResource {
928
+ /**
929
+ * Get query fan-out
930
+ *
931
+ * The searches engines ran while answering this brand's prompts. Engines that don't expose their
932
+ * searches still contribute runs, so `coverageRate` is the honest denominator.
933
+ *
934
+ * @param brandId Brand identifier.
935
+ */
936
+ get(brandId: BrandIdPath, params: GetBrandQueryFanoutParams, options?: RequestOptions): RestCallPromise<GetBrandQueryFanoutResponses, GetBrandQueryFanoutErrors>;
937
+ }
938
+ declare namespace Analytics {
939
+ export type { BrandAnalytics, GetBrandAnalyticsErrors, GetBrandAnalyticsParams, GetBrandAnalyticsResponses, ModelVisibility, ShareOfVoiceEntry, ShareOfVoicePoint, VisibilityPoint };
940
+ }
941
+ declare namespace Domains {
942
+ export type { CitationDomain, CitationDomainList, ListBrandCitationDomainsErrors, ListBrandCitationDomainsParams, ListBrandCitationDomainsResponses };
943
+ }
944
+ declare namespace URLs {
945
+ export type { CitationURL, CitationURLList, ListBrandCitationURLsErrors, ListBrandCitationURLsParams, ListBrandCitationURLsResponses };
946
+ }
947
+ declare namespace Citations {
948
+ export type { CitationDomain, CitationDomainList, CitationURL, CitationURLList, Domains, ListBrandCitationDomainsErrors, ListBrandCitationDomainsParams, ListBrandCitationDomainsResponses, ListBrandCitationURLsErrors, ListBrandCitationURLsParams, ListBrandCitationURLsResponses, URLs };
949
+ }
950
+ declare namespace PromptPerformance {
951
+ export type { ListBrandPromptPerformanceErrors, ListBrandPromptPerformanceParams, ListBrandPromptPerformanceResponses, PromptPerformance$1 as PromptPerformance, PromptPerformanceList };
952
+ }
953
+ declare namespace QueryFanout {
954
+ export type { BrandQueryFanout, FanoutQuery, GetBrandQueryFanoutErrors, GetBrandQueryFanoutParams, GetBrandQueryFanoutResponses };
955
+ }
956
+ //#endregion
957
+ //#region src/resources/opportunities.d.ts
958
+ /** Where a brand could win more citations, and why */
959
+ declare class Opportunities extends ElmoResource {
960
+ /**
961
+ * Get the latest opportunities report
962
+ *
963
+ * **Experimental — the response shape may still change.**
964
+ *
965
+ * The brand's Opportunities report: a prioritized set of ways to get cited more often, with the
966
+ * tracked prompts and cited pages behind each one. The same analysis the dashboard shows, from
967
+ * the same code.
968
+ *
969
+ * Generation is inline and synchronous. A stored report is served while it is fresh and
970
+ * regenerated when it is not, so there is nothing to poll for and no way to be handed a stale one
971
+ * — but a request that triggers a generation waits for it. The freshness window bounds the cost:
972
+ * however many callers ask, one generation per brand per window. There is deliberately no `POST`,
973
+ * which would spend provider budget with nothing metering it per call.
974
+ *
975
+ * @experimental
976
+ * @param brandId Brand identifier.
977
+ */
978
+ get(brandId: BrandIdPath, options?: RequestOptions): RestCallPromise<GetBrandOpportunitiesResponses, GetBrandOpportunitiesErrors>;
979
+ }
980
+ declare namespace Opportunities {
981
+ export type { BrandOpportunities, CitedPage, GetBrandOpportunitiesErrors, GetBrandOpportunitiesResponses, Opportunity, OpportunityPrompt };
982
+ }
983
+ //#endregion
984
+ //#region src/resources/tags.d.ts
985
+ /** The tags in use on a brand's prompts */
986
+ declare class Tags extends ElmoResource {
987
+ /**
988
+ * List a brand's tags
989
+ *
990
+ * Every tag in use on the brand's prompts, with how many carry each — enough to build the same
991
+ * filter the dashboard shows without paging the whole prompt list to derive it.
992
+ *
993
+ * Tags are not a resource of their own: a tag exists exactly as long as some prompt carries it.
994
+ * `branded` and `unbranded` are computed by Elmo and always listed.
995
+ *
996
+ * @param brandId Brand identifier.
997
+ */
998
+ list(brandId: BrandIdPath, options?: RequestOptions): RestCallPromise<ListBrandTagsResponses, ListBrandTagsErrors>;
999
+ }
1000
+ declare namespace Tags {
1001
+ export type { ListBrandTagsErrors, ListBrandTagsResponses, Tag, TagList };
1002
+ }
1003
+ //#endregion
1004
+ //#region src/resources/brands.d.ts
1005
+ /** Manage brand records */
1006
+ declare class Brands extends ElmoResource {
1007
+ /** Create a brand */
1008
+ create(params: CreateBrandParams, options?: RequestOptions): RestCallPromise<CreateBrandResponses, CreateBrandErrors>;
1009
+ /**
1010
+ * Get a brand
1011
+ *
1012
+ * @param brandId Brand identifier
1013
+ */
1014
+ get(brandId: string, options?: RequestOptions): RestCallPromise<GetBrandResponses, GetBrandErrors>;
1015
+ list(params?: ListBrandsParams, options?: RequestOptions): PagePromise<Brand, BrandsList, ListBrandsErrors>;
1016
+ /**
1017
+ * Update a brand
1018
+ *
1019
+ * @param brandId Brand identifier
1020
+ */
1021
+ update(brandId: string, params: UpdateBrandParams, options?: RequestOptions): RestCallPromise<UpdateBrandResponses, UpdateBrandErrors>;
1022
+ private _analytics?;
1023
+ /** Aggregated visibility, share of voice, citations, and query fan-out for a brand */
1024
+ get analytics(): Analytics;
1025
+ private _citations?;
1026
+ get citations(): Citations;
1027
+ private _opportunities?;
1028
+ /** Where a brand could win more citations, and why */
1029
+ get opportunities(): Opportunities;
1030
+ private _promptPerformance?;
1031
+ /** Aggregated visibility, share of voice, citations, and query fan-out for a brand */
1032
+ get promptPerformance(): PromptPerformance;
1033
+ private _queryFanout?;
1034
+ /** Aggregated visibility, share of voice, citations, and query fan-out for a brand */
1035
+ get queryFanout(): QueryFanout;
1036
+ private _tags?;
1037
+ /** The tags in use on a brand's prompts */
1038
+ get tags(): Tags;
1039
+ }
1040
+ declare namespace Brands {
1041
+ export type { Analytics, Brand, BrandAnalytics, BrandIdPath, BrandOpportunities, BrandQueryFanout, BrandsList, Citations, CitedPage, CreateBrandErrors, CreateBrandParams, CreateBrandResponses, DateRange, FanoutQuery, GetBrandAnalyticsErrors, GetBrandAnalyticsParams, GetBrandAnalyticsResponses, GetBrandErrors, GetBrandOpportunitiesErrors, GetBrandOpportunitiesResponses, GetBrandQueryFanoutErrors, GetBrandQueryFanoutParams, GetBrandQueryFanoutResponses, GetBrandResponses, ListBrandPromptPerformanceErrors, ListBrandPromptPerformanceParams, ListBrandPromptPerformanceResponses, ListBrandsErrors, ListBrandsParams, ListBrandsResponses, ListBrandTagsErrors, ListBrandTagsResponses, ModelVisibility, Opportunities, Opportunity, OpportunityPrompt, PromptPerformance, PromptPerformanceList, QueryFanout, ShareOfVoiceEntry, ShareOfVoicePoint, Tag, TagList, Tags, TagsFilter, UpdateBrandErrors, UpdateBrandParams, UpdateBrandResponses, VisibilityPoint };
1042
+ }
1043
+ //#endregion
1044
+ //#region src/resources/competitors.d.ts
1045
+ /** Manage brand competitors */
1046
+ declare class Competitors extends ElmoResource {
1047
+ /** Add a competitor */
1048
+ create(params: CreateCompetitorParams, options?: RequestOptions): RestCallPromise<CreateCompetitorResponses, CreateCompetitorErrors>;
1049
+ /**
1050
+ * Delete a competitor
1051
+ *
1052
+ * @param competitorId Competitor identifier (UUID)
1053
+ */
1054
+ delete(competitorId: string, options?: RequestOptions): RestCallPromise<DeleteCompetitorResponses, DeleteCompetitorErrors>;
1055
+ /**
1056
+ * Get a competitor
1057
+ *
1058
+ * @param competitorId Competitor identifier (UUID)
1059
+ */
1060
+ get(competitorId: string, options?: RequestOptions): RestCallPromise<GetCompetitorResponses, GetCompetitorErrors>;
1061
+ list(params?: ListCompetitorsParams, options?: RequestOptions): PagePromise<Competitor, CompetitorsList, ListCompetitorsErrors>;
1062
+ /**
1063
+ * Update a competitor
1064
+ *
1065
+ * @param competitorId Competitor identifier (UUID)
1066
+ */
1067
+ update(competitorId: string, params: UpdateCompetitorParams, options?: RequestOptions): RestCallPromise<UpdateCompetitorResponses, UpdateCompetitorErrors>;
1068
+ }
1069
+ declare namespace Competitors {
1070
+ export type { Competitor, CompetitorsList, CreateCompetitorErrors, CreateCompetitorParams, CreateCompetitorResponses, DeleteCompetitorErrors, DeleteCompetitorResponses, GetCompetitorErrors, GetCompetitorResponses, ListCompetitorsErrors, ListCompetitorsParams, ListCompetitorsResponses, UpdateCompetitorErrors, UpdateCompetitorParams, UpdateCompetitorResponses };
1071
+ }
1072
+ //#endregion
1073
+ //#region src/resources/identity.d.ts
1074
+ /** What the calling key is and what it may reach */
1075
+ declare class Me extends ElmoResource {
1076
+ /**
1077
+ * Describe the calling key
1078
+ *
1079
+ * What this key is, which organization and brands it reaches, and which scopes it holds. Requires
1080
+ * no scope, so it is always safe to call first when wiring up an integration.
1081
+ */
1082
+ get(options?: RequestOptions): RestCallPromise<GetMeResponses, GetMeErrors>;
1083
+ }
1084
+ declare namespace Me {
1085
+ export type { APIKeyIdentity, GetMeErrors, GetMeResponses };
1086
+ }
1087
+ //#endregion
1088
+ //#region src/resources/models.d.ts
1089
+ /** The answer engines this deployment can track */
1090
+ declare class Models extends ElmoResource {
1091
+ /**
1092
+ * List trackable models
1093
+ *
1094
+ * The answer engines this deployment can track, so a client can build a model filter without
1095
+ * hardcoding ids that differ between deployments.
1096
+ *
1097
+ * Requires no scope.
1098
+ */
1099
+ list(options?: RequestOptions): RestCallPromise<ListModelsResponses, ListModelsErrors>;
1100
+ }
1101
+ declare namespace Models {
1102
+ export type { ListModelsErrors, ListModelsResponses, Model, ModelList };
1103
+ }
1104
+ //#endregion
1105
+ //#region src/resources/organizations.d.ts
1106
+ /** Organizations, their plan limits, and their usage */
1107
+ declare class Billing extends ElmoResource {
1108
+ /**
1109
+ * Get billing state
1110
+ *
1111
+ * The organization's plan, its limits, and how much of each limit is already spent — enough for
1112
+ * an integration to know a write will be rejected before attempting it.
1113
+ *
1114
+ * This endpoint is read-only by construction. No API key of any kind can change a subscription,
1115
+ * an add-on quantity, or a payment method; there is no billing write endpoint and no billing
1116
+ * write scope. Stripe identifiers, invoices, and payment methods are never returned.
1117
+ *
1118
+ * Deployments without billing answer `200` with `billingEnabled: false`, a null plan, and null
1119
+ * limits, so callers need no special case.
1120
+ */
1121
+ get(organizationId: string, options?: RequestOptions): RestCallPromise<GetOrganizationBillingResponses, GetOrganizationBillingErrors>;
1122
+ }
1123
+ /** Organizations, their plan limits, and their usage */
1124
+ declare class Organizations extends ElmoResource {
1125
+ /**
1126
+ * Get an organization
1127
+ *
1128
+ * No scope required. An organization outside the key's reach answers `404`, identically to one
1129
+ * that does not exist.
1130
+ */
1131
+ get(organizationId: string, options?: RequestOptions): RestCallPromise<GetOrganizationResponses, GetOrganizationErrors>;
1132
+ /**
1133
+ * One entry for an organization key — the one it acts inside. Every organization for an instance
1134
+ * admin key. No scope required: a key can only ever see the organization it is already bound to.
1135
+ */
1136
+ list(params?: ListOrganizationsParams, options?: RequestOptions): PagePromise<Organization, OrganizationList, ListOrganizationsErrors>;
1137
+ private _billing?;
1138
+ /** Organizations, their plan limits, and their usage */
1139
+ get billing(): Billing;
1140
+ }
1141
+ declare namespace Billing {
1142
+ export type { BillingPlan, GetOrganizationBillingErrors, GetOrganizationBillingResponses, OrganizationBilling, PlanLimits };
1143
+ }
1144
+ declare namespace Organizations {
1145
+ export type { Billing, BillingPlan, GetOrganizationBillingErrors, GetOrganizationBillingResponses, GetOrganizationErrors, GetOrganizationResponses, ListOrganizationsErrors, ListOrganizationsParams, ListOrganizationsResponses, Organization, OrganizationBilling, OrganizationList, PlanLimits };
1146
+ }
1147
+ //#endregion
1148
+ //#region src/resources/runs.d.ts
1149
+ /** Individual model answers behind the aggregates */
1150
+ declare class Runs extends ElmoResource {
1151
+ /**
1152
+ * Get a run
1153
+ *
1154
+ * One model answer, with its text normalized out of the provider’s response and its citations in
1155
+ * the order the engine listed them. A run belonging to some other prompt answers `404`. The
1156
+ * provider’s raw payload is deliberately not exposed — its shape belongs to the provider, not to
1157
+ * this API.
1158
+ */
1159
+ get(promptId: string, runId: string, options?: RequestOptions): RestCallPromise<GetRunResponses, GetRunErrors>;
1160
+ /**
1161
+ * List runs for a prompt
1162
+ *
1163
+ * Individual model answers behind the aggregates, newest first, without their text — the list
1164
+ * stays small enough to page through. Fetch `prompts.runs.get()` for the answer itself.
1165
+ */
1166
+ list(promptId: string, params: ListPromptRunsParams, options?: RequestOptions): PagePromise<RunSummary, RunList, ListPromptRunsErrors>;
1167
+ }
1168
+ declare namespace Runs {
1169
+ export type { GetRunErrors, GetRunResponses, ListPromptRunsErrors, ListPromptRunsParams, ListPromptRunsResponses, Run, RunCitation, RunList, RunSummary };
1170
+ }
1171
+ //#endregion
1172
+ //#region src/resources/snapshots.d.ts
1173
+ /** Aggregated analytics snapshots for prompts */
1174
+ declare class Snapshot extends ElmoResource {
1175
+ /**
1176
+ * Get an aggregated snapshot of mention and citation analytics for a specific prompt over a date
1177
+ * range. Use this to identify competitive gaps, track brand visibility trends, and discover top
1178
+ * cited URLs.
1179
+ *
1180
+ * @param promptId The ID of the prompt
1181
+ */
1182
+ get(promptId: string, params: GetPromptSnapshotParams, options?: RequestOptions): RestCallPromise<GetPromptSnapshotResponses, GetPromptSnapshotErrors>;
1183
+ }
1184
+ declare namespace Snapshot {
1185
+ export type { CitedURLEntry, GetPromptSnapshotErrors, GetPromptSnapshotParams, GetPromptSnapshotResponses, PromptSnapshot };
1186
+ }
1187
+ //#endregion
1188
+ //#region src/resources/prompts.d.ts
1189
+ /** Manage brand prompts */
1190
+ declare class Prompts extends ElmoResource {
1191
+ /**
1192
+ * Create a new prompt
1193
+ *
1194
+ * Create a new prompt for a brand. This will automatically schedule the prompt for execution.
1195
+ */
1196
+ create(params: CreatePromptParams, options?: RequestOptions): RestCallPromise<CreatePromptResponses, CreatePromptErrors>;
1197
+ /**
1198
+ * Delete a prompt
1199
+ *
1200
+ * Permanently delete a prompt and cancel all related scheduled jobs. This will also cascade
1201
+ * delete all associated prompt runs.
1202
+ *
1203
+ * Requires an instance admin key; organization keys receive `403`. The dashboard has no delete
1204
+ * either — stop tracking a prompt with `prompts.update()` and `enabled: false`, which keeps its
1205
+ * history and frees the plan slot.
1206
+ *
1207
+ * @param promptId The ID of the prompt to delete
1208
+ */
1209
+ delete(promptId: string, options?: RequestOptions): RestCallPromise<DeletePromptResponses, DeletePromptErrors>;
1210
+ /**
1211
+ * Get a prompt
1212
+ *
1213
+ * Retrieve a specific prompt by ID
1214
+ *
1215
+ * @param promptId The ID of the prompt
1216
+ */
1217
+ get(promptId: string, options?: RequestOptions): RestCallPromise<GetPromptResponses, GetPromptErrors>;
1218
+ /**
1219
+ * List all prompts
1220
+ *
1221
+ * Retrieve a paginated list of all prompts across all brands
1222
+ */
1223
+ list(params?: ListPromptsParams, options?: RequestOptions): PagePromise<Prompt, ListPromptsResponse, ListPromptsErrors>;
1224
+ /**
1225
+ * Update a prompt
1226
+ *
1227
+ * Update a prompt's properties. Only provided fields will be updated. Toggling `enabled`
1228
+ * schedules or unschedules the recurring run job.
1229
+ *
1230
+ * @param promptId The ID of the prompt to update
1231
+ */
1232
+ update(promptId: string, params: UpdatePromptParams, options?: RequestOptions): RestCallPromise<UpdatePromptResponses, UpdatePromptErrors>;
1233
+ private _runs?;
1234
+ /** Individual model answers behind the aggregates */
1235
+ get runs(): Runs;
1236
+ private _snapshot?;
1237
+ /** Aggregated analytics snapshots for prompts */
1238
+ get snapshot(): Snapshot;
1239
+ }
1240
+ declare namespace Prompts {
1241
+ export type { CitedURLEntry, CreatePromptErrors, CreatePromptParams, CreatePromptResponses, DeletePromptErrors, DeletePromptResponse, DeletePromptResponses, GetPromptErrors, GetPromptResponses, GetPromptSnapshotErrors, GetPromptSnapshotParams, GetPromptSnapshotResponses, GetRunErrors, GetRunResponses, ListPromptRunsErrors, ListPromptRunsParams, ListPromptRunsResponses, ListPromptsErrors, ListPromptsParams, ListPromptsResponse, ListPromptsResponses, Prompt, PromptSnapshot, Run, RunCitation, RunList, Runs, RunSummary, Snapshot, UpdatePromptErrors, UpdatePromptParams, UpdatePromptResponses };
1242
+ }
1243
+ //#endregion
1244
+ //#region src/resources/reports.d.ts
1245
+ /** Generate and retrieve AI Share of Voice reports */
1246
+ declare class Reports extends ElmoResource {
1247
+ /**
1248
+ * Create a report
1249
+ *
1250
+ * Create a new AI Share of Voice report and queue it for generation. The report will evaluate the
1251
+ * brand across multiple AI engines (ChatGPT, Claude, Google AI) using generated and optional
1252
+ * custom prompts.
1253
+ *
1254
+ * Requires an instance admin key; organization keys receive `403`.
1255
+ */
1256
+ create(params: CreateReportParams, options?: RequestOptions): RestCallPromise<CreateReportResponses, CreateReportErrors>;
1257
+ /**
1258
+ * Get report status and data
1259
+ *
1260
+ * Poll a report's status. When completed, returns per-prompt snapshot data with raw mention
1261
+ * counts. Consumers are responsible for computing SoV and other derived metrics from the raw
1262
+ * data.
1263
+ *
1264
+ * Requires an instance admin key; organization keys receive `403`.
1265
+ *
1266
+ * @param reportId The ID of the report
1267
+ */
1268
+ get(reportId: string, params?: GetReportParams, options?: RequestOptions): RestCallPromise<GetReportResponses, GetReportErrors>;
1269
+ /**
1270
+ * Retrieve a paginated list of all reports, ordered by creation date (newest first).
1271
+ *
1272
+ * Requires an instance admin key; organization keys receive `403`.
1273
+ */
1274
+ list(params?: ListReportsParams, options?: RequestOptions): PagePromise<ReportSummary, ListReportsResponse, ListReportsErrors>;
1275
+ }
1276
+ declare namespace Reports {
1277
+ export type { CreateReportErrors, CreateReportParams, CreateReportResponse, CreateReportResponses, GetReportErrors, GetReportParams, GetReportResponse, GetReportResponses, ListReportsErrors, ListReportsParams, ListReportsResponse, ListReportsResponses, ReportPromptSnapshot, ReportSummary };
1278
+ }
1279
+ //#endregion
1280
+ //#region src/resources/tools.d.ts
1281
+ /** One-shot helpers (e.g. brand analysis) that don't persist anything */
1282
+ declare class Tools extends ElmoResource {
1283
+ /**
1284
+ * Analyze a website
1285
+ *
1286
+ * Run brand analysis without persisting anything. Returns suggested additional domains, aliases,
1287
+ * competitors, and prompts.
1288
+ *
1289
+ * Requires an instance admin key; organization keys receive `403`.
1290
+ */
1291
+ analyze(params: AnalyzeBrandParams, options?: RequestOptions): RestCallPromise<AnalyzeBrandResponses, AnalyzeBrandErrors>;
1292
+ }
1293
+ declare namespace Tools {
1294
+ export type { AnalyzeBrandErrors, AnalyzeBrandParams, AnalyzeBrandResponses, OnboardingSuggestion };
1295
+ }
1296
+ //#endregion
1297
+ //#region src/client.d.ts
1298
+ /** The version of this package. */
1299
+ declare const VERSION = "0.1.0";
1300
+ /** The address calls are sent to: a URL with its scheme. */
1301
+ type BaseURL = `${string}://${string}/api/v1` | (string & {});
1302
+ /**
1303
+ * How this client sends calls. Set on the client, or on one call to
1304
+ * override it there.
1305
+ */
1306
+ type BehaviorOptions = {
1307
+ /**
1308
+ * Specify a custom `fetch` implementation.
1309
+ *
1310
+ * Defaults to the global `fetch`, read for each request.
1311
+ */
1312
+ fetch?: Fetch;
1313
+ /**
1314
+ * Additional `RequestInit` options passed to `fetch` calls.
1315
+ *
1316
+ * A call that sets this replaces the whole block the client set.
1317
+ */
1318
+ fetchOptions?: FetchOptions;
1319
+ /**
1320
+ * Run your own hooks around every call. Each is an array of functions, which
1321
+ * may be async.
1322
+ *
1323
+ * `request` reads the request after the credentials are on it and before it is
1324
+ * sent. `response` and `error` each return what the caller reads, so a hook
1325
+ * that only observes returns what it was given.
1326
+ */
1327
+ interceptors?: Interceptors;
1328
+ /**
1329
+ * Set the log level. Raise it to see what each call sent and what came back.
1330
+ * `'debug'` adds headers, with credentials hidden.
1331
+ *
1332
+ * Read from the `ELMO_LOG` environment variable when unset.
1333
+ *
1334
+ * @default 'off'
1335
+ */
1336
+ logLevel?: LogLevel;
1337
+ /**
1338
+ * Set the logger. Anything with `debug`, `error`, `info` and `warn` methods.
1339
+ * Defaults to `globalThis.console`.
1340
+ */
1341
+ logger?: Logger;
1342
+ /**
1343
+ * The most pages one walk fetches before it stops. Stepping through
1344
+ * `getNextPage()` by hand is not capped.
1345
+ *
1346
+ * @default 1000
1347
+ */
1348
+ maxPages?: number;
1349
+ /**
1350
+ * The maximum number of times a failed call is sent again.
1351
+ *
1352
+ * The same count as `retry.maxRetries`, which wins where both are set. It
1353
+ * counts retries and nothing else: `retry` decides which failures are retried.
1354
+ *
1355
+ * @default 2
1356
+ */
1357
+ maxRetries?: number;
1358
+ /**
1359
+ * How a failed call is retried, or `false` to send it once.
1360
+ *
1361
+ * @default { maxRetries: 2 }
1362
+ */
1363
+ retry?: RetryOptions | boolean;
1364
+ /**
1365
+ * The maximum time one attempt may run.
1366
+ *
1367
+ * Set `false` or `0` for no limit, or a function that returns the limit of one
1368
+ * call. It is given the operation as `METHOD /path` and the limit the call
1369
+ * would otherwise get.
1370
+ *
1371
+ * @default 60_000
1372
+ *
1373
+ * @unit milliseconds
1374
+ */
1375
+ timeout?: TimeoutValue;
1376
+ /**
1377
+ * Send calls through a transport of your own, for an HTTP library
1378
+ * this client does not use.
1379
+ *
1380
+ * To swap the `fetch` it calls, use `fetch` or `fetchOptions`.
1381
+ */
1382
+ transport?: Transport<string, 'unary'>;
1383
+ };
1384
+ /**
1385
+ * The credentials this API takes, each under its own name.
1386
+ *
1387
+ * Given to the constructor, one is sent with every call. Given to a call,
1388
+ * it is sent with that call alone.
1389
+ */
1390
+ type ClientCredentials = {
1391
+ /**
1392
+ * An instance admin key from `ADMIN_API_KEYS`, or an organization key
1393
+ * (`elmo_…`) issued from the dashboard.
1394
+ *
1395
+ * Read from the `ELMO_API_KEY` environment variable when unset.
1396
+ */
1397
+ apiKey?: CredentialValue;
1398
+ };
1399
+ /** The options particular to this API. */
1400
+ type ClientNarrowing = {
1401
+ /**
1402
+ * Override the base URL calls are sent to.
1403
+ *
1404
+ * Read from the `ELMO_BASE_URL` environment variable when unset.
1405
+ *
1406
+ * @default '/api/v1'
1407
+ */
1408
+ baseURL?: BaseURL;
1409
+ /**
1410
+ * Build the client in a browser, where every visitor to the page can read
1411
+ * the credential it sends. Pass `true` only where the credential is meant
1412
+ * to be public, or a proxy adds it.
1413
+ */
1414
+ dangerouslyAllowBrowser?: boolean;
1415
+ /**
1416
+ * Headers to send with every call.
1417
+ *
1418
+ * Merged per name with whatever a call sets, and `null` drops one.
1419
+ */
1420
+ defaultHeaders?: MetadataOptions['headers'];
1421
+ /**
1422
+ * Path parameters every call starts from.
1423
+ *
1424
+ * Merged per name with whatever a call sets.
1425
+ */
1426
+ defaultPath?: MetadataOptions['path'];
1427
+ /**
1428
+ * Query parameters to add to every call.
1429
+ *
1430
+ * Merged per name with whatever a call sets, and `null` drops one.
1431
+ */
1432
+ defaultQuery?: MetadataOptions['query'];
1433
+ };
1434
+ /** Everything a client can be built with, and the defaults every call starts from. */
1435
+ type ClientOptions = BehaviorOptions & BodySerializerOptions & ClientCredentials & ClientNarrowing & CredentialOptions;
1436
+ /**
1437
+ * A client for this API. Options given here apply to every call made
1438
+ * through it. Pass it to a call, or to an SDK, in place of the default one.
1439
+ *
1440
+ * @example
1441
+ * const elmo = createElmoClient({ apiKey: '…' });
1442
+ */
1443
+ declare function createElmoClient(options?: ClientOptions): Client;
1444
+ /**
1445
+ * The Elmo API, as one object to call through.
1446
+ *
1447
+ * Pass `apiKey`, or set `ELMO_API_KEY` and pass nothing.
1448
+ *
1449
+ * Options given here apply to every call it makes.
1450
+ *
1451
+ * @example
1452
+ * const elmo = new Elmo();
1453
+ * await elmo.brands.list();
1454
+ */
1455
+ declare class Elmo extends ElmoResource {
1456
+ constructor(args?: (ClientOptions & {
1457
+ client?: never;
1458
+ }) | {
1459
+ /**
1460
+ * A client to dispatch through, in place of one built from options.
1461
+ *
1462
+ * For sharing one configured client across several SDKs, or for
1463
+ * one built with `createElmoClient`.
1464
+ */
1465
+ client: Client;
1466
+ });
1467
+ private _brands?;
1468
+ /** Manage brand records */
1469
+ get brands(): Brands;
1470
+ private _competitors?;
1471
+ /** Manage brand competitors */
1472
+ get competitors(): Competitors;
1473
+ private _me?;
1474
+ /** What the calling key is and what it may reach */
1475
+ get me(): Me;
1476
+ private _models?;
1477
+ /** The answer engines this deployment can track */
1478
+ get models(): Models;
1479
+ private _organizations?;
1480
+ /** Organizations, their plan limits, and their usage */
1481
+ get organizations(): Organizations;
1482
+ private _prompts?;
1483
+ /** Manage brand prompts */
1484
+ get prompts(): Prompts;
1485
+ private _reports?;
1486
+ /** Generate and retrieve AI Share of Voice reports */
1487
+ get reports(): Reports;
1488
+ private _tools?;
1489
+ /** One-shot helpers (e.g. brand analysis) that don't persist anything */
1490
+ get tools(): Tools;
1491
+ /** A failure the API answered with, so there is a status and a reply to read. */
1492
+ static APIError: typeof APIError;
1493
+ /**
1494
+ * Thrown when the caller called the request off before the API answered.
1495
+ *
1496
+ * Not a {@link TransportError}, so code that retries or reports a failed
1497
+ * connection leaves a call the caller cancelled alone.
1498
+ */
1499
+ static AbortError: typeof AbortError;
1500
+ /** No usable credential reached the API: it was missing, unreadable, or rejected. */
1501
+ static AuthenticationError: typeof AuthenticationError;
1502
+ /** The API could not read the request, so it did not act on it. */
1503
+ static BadRequestError: typeof BadRequestError;
1504
+ /** The call collided with the resource's current state: a duplicate, or a concurrent change. */
1505
+ static ConflictError: typeof ConflictError;
1506
+ /** A reply from the API that this SDK could not read, whatever its status. */
1507
+ static DecodeError: typeof DecodeError;
1508
+ /** The base of every error this SDK throws, including one from a call that never arrived. */
1509
+ static ElmoError: typeof ElmoError;
1510
+ /** The API failed after accepting the call. Every status from 500 up arrives as this. */
1511
+ static InternalServerError: typeof InternalServerError;
1512
+ /** Thrown before the request goes out, when no credential satisfied the call. */
1513
+ static MissingCredentialError: typeof MissingCredentialError;
1514
+ /** Nothing is at this address, or the credential may not see what is. */
1515
+ static NotFoundError: typeof NotFoundError;
1516
+ /** The plan or the quota on this account does not cover the call. */
1517
+ static PaymentRequiredError: typeof PaymentRequiredError;
1518
+ /** The credential was accepted, but it does not grant this call. */
1519
+ static PermissionDeniedError: typeof PermissionDeniedError;
1520
+ /** Too many calls. {@link APIError.retryAfterMs} carries how long the API asked to wait. */
1521
+ static RateLimitError: typeof RateLimitError;
1522
+ /**
1523
+ * Thrown when a call waited on the API for as long as it allowed, from sending
1524
+ * the request to the last byte of the reply.
1525
+ *
1526
+ * A reply with status 408 is an {@link APIError}, not one of these.
1527
+ */
1528
+ static TimeoutError: typeof TimeoutError;
1529
+ /** Thrown when no whole answer arrived, so there is no reply to go on. */
1530
+ static TransportError: typeof TransportError;
1531
+ /** The request was read, and its contents were rejected. */
1532
+ static UnprocessableEntityError: typeof UnprocessableEntityError;
1533
+ }
1534
+ declare namespace Elmo {
1535
+ export type { AnalyzeBrandErrors, AnalyzeBrandParams, AnalyzeBrandResponses, APIKeyIdentity, AuthResolver, AuthScheme, AuthToken, AuthValue, BackoffOptions, BaseURL, BodyInput, BodyPayload, Brand, BrandIdPath, Brands, BrandsList, CallResult, CallTimeout, Client, ClientOptions, Competitor, Competitors, CompetitorsList, ConflictError$1 as ConflictErrorResponse, CreateBrandErrors, CreateBrandParams, CreateBrandResponses, CreateCompetitorErrors, CreateCompetitorParams, CreateCompetitorResponses, CreatePromptErrors, CreatePromptParams, CreatePromptResponses, CreateReportErrors, CreateReportParams, CreateReportResponse, CreateReportResponses, CredentialValue, DateRange, DeleteCompetitorErrors, DeleteCompetitorResponses, DeletePromptErrors, DeletePromptResponse, DeletePromptResponses, Error$1 as Error, FailureBody, Fetch, FetchOptions, ForbiddenError, GetBrandErrors, GetBrandResponses, GetCompetitorErrors, GetCompetitorResponses, GetMeErrors, GetMeResponses, GetOrganizationErrors, GetOrganizationResponses, GetPromptErrors, GetPromptResponses, GetReportErrors, GetReportParams, GetReportResponse, GetReportResponses, Interceptors, InternalServerError$1 as InternalServerErrorResponse, Jitter, Limit, ListBrandsErrors, ListBrandsParams, ListBrandsResponses, ListCompetitorsErrors, ListCompetitorsParams, ListCompetitorsResponses, ListModelsErrors, ListModelsResponses, ListOrganizationsErrors, ListOrganizationsParams, ListOrganizationsResponses, ListPromptsErrors, ListPromptsParams, ListPromptsResponse, ListPromptsResponses, ListReportsErrors, ListReportsParams, ListReportsResponse, ListReportsResponses, LogFn, Logger, LogLevel, Me, MentionEntry, MentionsSummary, MetadataInput, MetadataOptions, Model, ModelFilter, ModelList, Models, NotFoundError$1 as NotFoundErrorResponse, OnboardingSuggestion, Organization, OrganizationList, Organizations, Page, PageEnvelope, Page$1 as PageParameter, PagePromise, PageResult, Pagination, PaymentRequiredError$1 as PaymentRequiredErrorResponse, PreparedRequest, Prompt, Prompts, RateLimitError$1 as RateLimitErrorResponse, ReportPromptSnapshot, Reports, ReportSummary, RequestOptions, RestCallPromise, Result, ResultEnvelope, RetryAfterHeader, RetryOptions, RetryRules, TagsFilter, TimeoutPolicy, TimeoutValue, Tools, Transport, TransportErrorKind, TransportFailure, TransportInteraction, UnauthorizedError, UpdateBrandErrors, UpdateBrandParams, UpdateBrandResponses, UpdateCompetitorErrors, UpdateCompetitorParams, UpdateCompetitorResponses, UpdatePromptErrors, UpdatePromptParams, UpdatePromptResponses, ValidationError, WindowEnd, WindowStart, WithResponse };
1536
+ }
1537
+ //#endregion
1538
+ //#region src/resources/shared/request-options.d.ts
1539
+ /** What one call may set for itself, overriding the client it goes through. */
1540
+ type RequestOptions = BehaviorOptions & BodySerializerOptions & ClientCredentials & ConnectionOptions<BaseURL, AuthValue, never> & MetadataOptions & PageOptions & SignalOptions & {
1541
+ /**
1542
+ * The client that sends this call, in place of the one this SDK uses.
1543
+ *
1544
+ * Build one with `createElmoClient`.
1545
+ */
1546
+ client?: Client;
1547
+ };
1548
+ //#endregion
1549
+ export { TransportError as C, TimeoutError as S, APIError as _, PagePromise as a, ElmoError as b, ConflictError as c, PaymentRequiredError as d, PermissionDeniedError as f, Client as g, RestCallPromise as h, createElmoClient as i, InternalServerError as l, UnprocessableEntityError as m, Elmo as n, AuthenticationError as o, RateLimitError as p, VERSION as r, BadRequestError as s, RequestOptions as t, NotFoundError as u, AbortError as v, MissingCredentialError as x, DecodeError as y };
1550
+ //# sourceMappingURL=request-options-DWYI_Ldj.d.mts.map