@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
package/src/client.ts ADDED
@@ -0,0 +1,649 @@
1
+ import { createRestBinding } from './internal/binding/rest/binding';
2
+ import {
3
+ AuthenticationError,
4
+ BadRequestError,
5
+ ConflictError,
6
+ InternalServerError,
7
+ NotFoundError,
8
+ PaymentRequiredError,
9
+ PermissionDeniedError,
10
+ RateLimitError,
11
+ UnprocessableEntityError,
12
+ } from './internal/binding/rest/errors';
13
+ import { simpleURL } from './internal/binding/rest/url';
14
+ import { jsonCodec } from './internal/codec/json';
15
+ import type { BackoffOptions, Jitter, RetryAfterHeader } from './internal/core/backoff';
16
+ import { refuseBrowser } from './internal/core/browser';
17
+ import type { WithResponse } from './internal/core/call-promise';
18
+ import { RestCallPromise } from './internal/core/call-promise';
19
+ import type { Client } from './internal/core/client';
20
+ import { clientFor, createClient } from './internal/core/client';
21
+ import { createConfig } from './internal/core/config';
22
+ import type { FailureBody, TransportErrorKind, TransportFailure } from './internal/core/errors';
23
+ import {
24
+ AbortError,
25
+ APIError,
26
+ DecodeError,
27
+ ElmoError,
28
+ MissingCredentialError,
29
+ TimeoutError,
30
+ TransportError,
31
+ } from './internal/core/errors';
32
+ import type { Page } from './internal/core/page';
33
+ import { PagePromise } from './internal/core/page';
34
+ import type {
35
+ AuthResolver,
36
+ AuthScheme,
37
+ AuthToken,
38
+ AuthValue,
39
+ BodyInput,
40
+ BodyPayload,
41
+ BodySerializerOptions,
42
+ CallResult,
43
+ CallTimeout,
44
+ CredentialOptions,
45
+ CredentialValue,
46
+ MetadataInput,
47
+ MetadataOptions,
48
+ PageEnvelope,
49
+ PageResult,
50
+ PreparedRequest,
51
+ Result,
52
+ ResultEnvelope,
53
+ RetryRules,
54
+ Transport,
55
+ TransportInteraction,
56
+ } from './internal/core/types';
57
+ import { authFeature } from './internal/feature/auth';
58
+ import type { Interceptors } from './internal/feature/interceptors';
59
+ import { interceptorsFeature } from './internal/feature/interceptors';
60
+ import type { LogFn, Logger, LogLevel } from './internal/feature/logger';
61
+ import { loggerFeature } from './internal/feature/logger';
62
+ import type { RetryOptions } from './internal/feature/retry';
63
+ import { retryFeature } from './internal/feature/retry';
64
+ import { rulesFeature } from './internal/feature/rules';
65
+ import type { TimeoutPolicy, TimeoutValue } from './internal/feature/timeout';
66
+ import { timeoutFeature } from './internal/feature/timeout';
67
+ import { validateFeature } from './internal/feature/validate';
68
+ import type { Fetch, FetchOptions } from './internal/transport/fetch';
69
+ import { createFetchTransport } from './internal/transport/fetch';
70
+ import { Brands } from './resources/brands';
71
+ import { Competitors } from './resources/competitors';
72
+ import { Me } from './resources/identity';
73
+ import { Models } from './resources/models';
74
+ import { Organizations } from './resources/organizations';
75
+ import { Prompts } from './resources/prompts';
76
+ import { Reports } from './resources/reports';
77
+ import type { RequestOptions } from './resources/shared/request-options';
78
+ import { ElmoResource } from './resources/shared/resource';
79
+ import { Tools } from './resources/tools';
80
+ import type { DateRange, TagsFilter } from './types/analytics';
81
+ import type {
82
+ Brand,
83
+ BrandsList,
84
+ CreateBrandErrors,
85
+ CreateBrandParams,
86
+ CreateBrandResponses,
87
+ GetBrandErrors,
88
+ GetBrandResponses,
89
+ ListBrandsErrors,
90
+ ListBrandsParams,
91
+ ListBrandsResponses,
92
+ UpdateBrandErrors,
93
+ UpdateBrandParams,
94
+ UpdateBrandResponses,
95
+ } from './types/brands';
96
+ import type {
97
+ Competitor,
98
+ CompetitorsList,
99
+ CreateCompetitorErrors,
100
+ CreateCompetitorParams,
101
+ CreateCompetitorResponses,
102
+ DeleteCompetitorErrors,
103
+ DeleteCompetitorResponses,
104
+ GetCompetitorErrors,
105
+ GetCompetitorResponses,
106
+ ListCompetitorsErrors,
107
+ ListCompetitorsParams,
108
+ ListCompetitorsResponses,
109
+ UpdateCompetitorErrors,
110
+ UpdateCompetitorParams,
111
+ UpdateCompetitorResponses,
112
+ } from './types/competitors';
113
+ import type { APIKeyIdentity, GetMeErrors, GetMeResponses } from './types/identity';
114
+ import type { ListModelsErrors, ListModelsResponses, Model, ModelList } from './types/models';
115
+ import type {
116
+ GetOrganizationErrors,
117
+ GetOrganizationResponses,
118
+ ListOrganizationsErrors,
119
+ ListOrganizationsParams,
120
+ ListOrganizationsResponses,
121
+ Organization,
122
+ OrganizationList,
123
+ } from './types/organizations';
124
+ import type {
125
+ CreatePromptErrors,
126
+ CreatePromptParams,
127
+ CreatePromptResponses,
128
+ DeletePromptErrors,
129
+ DeletePromptResponse,
130
+ DeletePromptResponses,
131
+ GetPromptErrors,
132
+ GetPromptResponses,
133
+ ListPromptsErrors,
134
+ ListPromptsParams,
135
+ ListPromptsResponse,
136
+ ListPromptsResponses,
137
+ Prompt,
138
+ UpdatePromptErrors,
139
+ UpdatePromptParams,
140
+ UpdatePromptResponses,
141
+ } from './types/prompts';
142
+ import type {
143
+ CreateReportErrors,
144
+ CreateReportParams,
145
+ CreateReportResponse,
146
+ CreateReportResponses,
147
+ GetReportErrors,
148
+ GetReportParams,
149
+ GetReportResponse,
150
+ GetReportResponses,
151
+ ListReportsErrors,
152
+ ListReportsParams,
153
+ ListReportsResponse,
154
+ ListReportsResponses,
155
+ ReportPromptSnapshot,
156
+ ReportSummary,
157
+ } from './types/reports';
158
+ import type { BrandIdPath } from './types/shared/brand-id-path';
159
+ import type {
160
+ ConflictError as ConflictErrorResponse,
161
+ PaymentRequiredError as PaymentRequiredErrorResponse,
162
+ } from './types/shared/conflict-error';
163
+ import type {
164
+ Error,
165
+ ForbiddenError,
166
+ InternalServerError as InternalServerErrorResponse,
167
+ RateLimitError as RateLimitErrorResponse,
168
+ UnauthorizedError,
169
+ } from './types/shared/error';
170
+ import type { Limit } from './types/shared/limit';
171
+ import type { MentionEntry, MentionsSummary } from './types/shared/mention-entry';
172
+ import type { ModelFilter, WindowEnd, WindowStart } from './types/shared/model-filter';
173
+ import type { NotFoundError as NotFoundErrorResponse } from './types/shared/not-found-error';
174
+ import type { Page as PageParameter } from './types/shared/page';
175
+ import type { Pagination } from './types/shared/pagination';
176
+ import type { ValidationError } from './types/shared/validation-error';
177
+ import type {
178
+ AnalyzeBrandErrors,
179
+ AnalyzeBrandParams,
180
+ AnalyzeBrandResponses,
181
+ OnboardingSuggestion,
182
+ } from './types/tools';
183
+
184
+ /** The version of this package. */
185
+ export const VERSION = '0.1.1';
186
+
187
+ /** The address calls are sent to: a URL with its scheme. */
188
+ export type BaseURL = `${string}://${string}/api/v1` | (string & {});
189
+
190
+ /**
191
+ * How this client sends calls. Set on the client, or on one call to
192
+ * override it there.
193
+ */
194
+ export type BehaviorOptions = {
195
+ /**
196
+ * Specify a custom `fetch` implementation.
197
+ *
198
+ * Defaults to the global `fetch`, read for each request.
199
+ */
200
+ fetch?: Fetch;
201
+ /**
202
+ * Additional `RequestInit` options passed to `fetch` calls.
203
+ *
204
+ * A call that sets this replaces the whole block the client set.
205
+ */
206
+ fetchOptions?: FetchOptions;
207
+ /**
208
+ * Run your own hooks around every call. Each is an array of functions, which
209
+ * may be async.
210
+ *
211
+ * `request` reads the request after the credentials are on it and before it is
212
+ * sent. `response` and `error` each return what the caller reads, so a hook
213
+ * that only observes returns what it was given.
214
+ */
215
+ interceptors?: Interceptors;
216
+ /**
217
+ * Set the log level. Raise it to see what each call sent and what came back.
218
+ * `'debug'` adds headers, with credentials hidden.
219
+ *
220
+ * Read from the `ELMO_LOG` environment variable when unset.
221
+ *
222
+ * @default 'off'
223
+ */
224
+ logLevel?: LogLevel;
225
+ /**
226
+ * Set the logger. Anything with `debug`, `error`, `info` and `warn` methods.
227
+ * Defaults to `globalThis.console`.
228
+ */
229
+ logger?: Logger;
230
+ /**
231
+ * The most pages one walk fetches before it stops. Stepping through
232
+ * `getNextPage()` by hand is not capped.
233
+ *
234
+ * @default 1000
235
+ */
236
+ maxPages?: number;
237
+ /**
238
+ * The maximum number of times a failed call is sent again.
239
+ *
240
+ * The same count as `retry.maxRetries`, which wins where both are set. It
241
+ * counts retries and nothing else: `retry` decides which failures are retried.
242
+ *
243
+ * @default 2
244
+ */
245
+ maxRetries?: number;
246
+ /**
247
+ * How a failed call is retried, or `false` to send it once.
248
+ *
249
+ * @default { maxRetries: 2 }
250
+ */
251
+ retry?: RetryOptions | boolean;
252
+ /**
253
+ * The maximum time one attempt may run.
254
+ *
255
+ * Set `false` or `0` for no limit, or a function that returns the limit of one
256
+ * call. It is given the operation as `METHOD /path` and the limit the call
257
+ * would otherwise get.
258
+ *
259
+ * @default 60_000
260
+ *
261
+ * @unit milliseconds
262
+ */
263
+ timeout?: TimeoutValue;
264
+ /**
265
+ * Send calls through a transport of your own, for an HTTP library
266
+ * this client does not use.
267
+ *
268
+ * To swap the `fetch` it calls, use `fetch` or `fetchOptions`.
269
+ */
270
+ transport?: Transport<string, 'unary'>;
271
+ };
272
+
273
+ /**
274
+ * The credentials this API takes, each under its own name.
275
+ *
276
+ * Given to the constructor, one is sent with every call. Given to a call,
277
+ * it is sent with that call alone.
278
+ */
279
+ export type ClientCredentials = {
280
+ /**
281
+ * An instance admin key from `ADMIN_API_KEYS`, or an organization key
282
+ * (`elmo_…`) issued from the dashboard. Its value starts with `elmo_`.
283
+ *
284
+ * Read from the `ELMO_API_KEY` environment variable when unset.
285
+ */
286
+ apiKey?: CredentialValue;
287
+ };
288
+
289
+ /** The options particular to this API. */
290
+ export type ClientNarrowing = {
291
+ /**
292
+ * Override the base URL calls are sent to.
293
+ *
294
+ * Read from the `ELMO_BASE_URL` environment variable when unset.
295
+ *
296
+ * @default 'https://app.elmohq.com/api/v1'
297
+ */
298
+ baseURL?: BaseURL;
299
+ /**
300
+ * Build the client in a browser, where every visitor to the page can read
301
+ * the credential it sends. Pass `true` only where the credential is meant
302
+ * to be public, or a proxy adds it.
303
+ */
304
+ dangerouslyAllowBrowser?: boolean;
305
+ /**
306
+ * Headers to send with every call.
307
+ *
308
+ * Merged per name with whatever a call sets, and `null` drops one.
309
+ */
310
+ defaultHeaders?: MetadataOptions['headers'];
311
+ /**
312
+ * Path parameters every call starts from.
313
+ *
314
+ * Merged per name with whatever a call sets.
315
+ */
316
+ defaultPath?: MetadataOptions['path'];
317
+ /**
318
+ * Query parameters to add to every call.
319
+ *
320
+ * Merged per name with whatever a call sets, and `null` drops one.
321
+ */
322
+ defaultQuery?: MetadataOptions['query'];
323
+ };
324
+
325
+ /** Everything a client can be built with, and the defaults every call starts from. */
326
+ export type ClientOptions = BehaviorOptions &
327
+ BodySerializerOptions &
328
+ ClientCredentials &
329
+ ClientNarrowing &
330
+ CredentialOptions;
331
+
332
+ const declaredCredentials = { apiKey: { variable: 'ELMO_API_KEY' } };
333
+
334
+ let fetchTransportInstance: ReturnType<typeof createFetchTransport> | undefined;
335
+
336
+ export function fetchTransport() {
337
+ return (fetchTransportInstance ??= createFetchTransport());
338
+ }
339
+
340
+ let clientInstance: ReturnType<typeof createClient> | undefined;
341
+
342
+ export function client() {
343
+ return (clientInstance ??= createClient({
344
+ codecs: [jsonCodec],
345
+ credentials: declaredCredentials,
346
+ defaults: createConfig({
347
+ baseURL: 'https://app.elmohq.com/api/v1',
348
+ headers: { 'user-agent': `elmo-sdk/${VERSION} (typescript)` },
349
+ }),
350
+ env: { baseURL: 'ELMO_BASE_URL', logLevel: 'ELMO_LOG' },
351
+ features: [
352
+ rulesFeature(),
353
+ authFeature({ schemes: declaredCredentials }),
354
+ retryFeature(),
355
+ loggerFeature(),
356
+ timeoutFeature(),
357
+ interceptorsFeature(),
358
+ validateFeature(),
359
+ ],
360
+ guard: refuseBrowser,
361
+ protocols: {
362
+ rest: { binding: createRestBinding(simpleURL), transport: fetchTransport() },
363
+ },
364
+ }));
365
+ }
366
+
367
+ /**
368
+ * A client for this API. Options given here apply to every call made
369
+ * through it. Pass it to a call, or to an SDK, in place of the default one.
370
+ *
371
+ * @example
372
+ * const elmo = createElmoClient({ apiKey: '…' });
373
+ */
374
+ export function createElmoClient(options?: ClientOptions): Client {
375
+ return clientFor(options, client());
376
+ }
377
+
378
+ /**
379
+ * The Elmo API, as one object to call through.
380
+ *
381
+ * Pass `apiKey`, or set `ELMO_API_KEY` and pass nothing.
382
+ *
383
+ * Options given here apply to every call it makes.
384
+ *
385
+ * @example
386
+ * const elmo = new Elmo();
387
+ * await elmo.brands.list();
388
+ */
389
+ export class Elmo extends ElmoResource {
390
+ constructor(
391
+ args?:
392
+ | (ClientOptions & {
393
+ client?: never;
394
+ })
395
+ | {
396
+ /**
397
+ * A client to dispatch through, in place of one built from options.
398
+ *
399
+ * For sharing one configured client across several SDKs, or for
400
+ * one built with `createElmoClient`.
401
+ */
402
+ client: Client;
403
+ },
404
+ ) {
405
+ super(clientFor(args, client()));
406
+ }
407
+
408
+ private _brands?: Brands;
409
+ /** Manage brand records */
410
+ get brands(): Brands {
411
+ return (this._brands ??= new Brands(this.client));
412
+ }
413
+
414
+ private _competitors?: Competitors;
415
+ /** Manage brand competitors */
416
+ get competitors(): Competitors {
417
+ return (this._competitors ??= new Competitors(this.client));
418
+ }
419
+
420
+ private _me?: Me;
421
+ /** What the calling key is and what it may reach */
422
+ get me(): Me {
423
+ return (this._me ??= new Me(this.client));
424
+ }
425
+
426
+ private _models?: Models;
427
+ /** The answer engines this deployment can track */
428
+ get models(): Models {
429
+ return (this._models ??= new Models(this.client));
430
+ }
431
+
432
+ private _organizations?: Organizations;
433
+ /** Organizations, their plan limits, and their usage */
434
+ get organizations(): Organizations {
435
+ return (this._organizations ??= new Organizations(this.client));
436
+ }
437
+
438
+ private _prompts?: Prompts;
439
+ /** Manage brand prompts */
440
+ get prompts(): Prompts {
441
+ return (this._prompts ??= new Prompts(this.client));
442
+ }
443
+
444
+ private _reports?: Reports;
445
+ /** Generate and retrieve AI Share of Voice reports */
446
+ get reports(): Reports {
447
+ return (this._reports ??= new Reports(this.client));
448
+ }
449
+
450
+ private _tools?: Tools;
451
+ /** One-shot helpers (e.g. brand analysis) that don't persist anything */
452
+ get tools(): Tools {
453
+ return (this._tools ??= new Tools(this.client));
454
+ }
455
+
456
+ /** A failure the API answered with, so there is a status and a reply to read. */
457
+ static APIError = APIError;
458
+ /**
459
+ * Thrown when the caller called the request off before the API answered.
460
+ *
461
+ * Not a {@link TransportError}, so code that retries or reports a failed
462
+ * connection leaves a call the caller cancelled alone.
463
+ */
464
+ static AbortError = AbortError;
465
+ /** No usable credential reached the API: it was missing, unreadable, or rejected. */
466
+ static AuthenticationError = AuthenticationError;
467
+ /** The API could not read the request, so it did not act on it. */
468
+ static BadRequestError = BadRequestError;
469
+ /** The call collided with the resource's current state: a duplicate, or a concurrent change. */
470
+ static ConflictError = ConflictError;
471
+ /** A reply from the API that this SDK could not read, whatever its status. */
472
+ static DecodeError = DecodeError;
473
+ /** The base of every error this SDK throws, including one from a call that never arrived. */
474
+ static ElmoError = ElmoError;
475
+ /** The API failed after accepting the call. Every status from 500 up arrives as this. */
476
+ static InternalServerError = InternalServerError;
477
+ /** Thrown before the request goes out, when no credential satisfied the call. */
478
+ static MissingCredentialError = MissingCredentialError;
479
+ /** Nothing is at this address, or the credential may not see what is. */
480
+ static NotFoundError = NotFoundError;
481
+ /** The plan or the quota on this account does not cover the call. */
482
+ static PaymentRequiredError = PaymentRequiredError;
483
+ /** The credential was accepted, but it does not grant this call. */
484
+ static PermissionDeniedError = PermissionDeniedError;
485
+ /** Too many calls. {@link APIError.retryAfterMs} carries how long the API asked to wait. */
486
+ static RateLimitError = RateLimitError;
487
+ /**
488
+ * Thrown when a call waited on the API for as long as it allowed, from sending
489
+ * the request to the last byte of the reply.
490
+ *
491
+ * A reply with status 408 is an {@link APIError}, not one of these.
492
+ */
493
+ static TimeoutError = TimeoutError;
494
+ /** Thrown when no whole answer arrived, so there is no reply to go on. */
495
+ static TransportError = TransportError;
496
+ /** The request was read, and its contents were rejected. */
497
+ static UnprocessableEntityError = UnprocessableEntityError;
498
+ }
499
+
500
+ export declare namespace Elmo {
501
+ export type {
502
+ AnalyzeBrandErrors,
503
+ AnalyzeBrandParams,
504
+ AnalyzeBrandResponses,
505
+ APIKeyIdentity,
506
+ AuthResolver,
507
+ AuthScheme,
508
+ AuthToken,
509
+ AuthValue,
510
+ BackoffOptions,
511
+ BaseURL,
512
+ BodyInput,
513
+ BodyPayload,
514
+ Brand,
515
+ BrandIdPath,
516
+ Brands,
517
+ BrandsList,
518
+ CallResult,
519
+ CallTimeout,
520
+ Client,
521
+ ClientOptions,
522
+ Competitor,
523
+ Competitors,
524
+ CompetitorsList,
525
+ ConflictErrorResponse,
526
+ CreateBrandErrors,
527
+ CreateBrandParams,
528
+ CreateBrandResponses,
529
+ CreateCompetitorErrors,
530
+ CreateCompetitorParams,
531
+ CreateCompetitorResponses,
532
+ CreatePromptErrors,
533
+ CreatePromptParams,
534
+ CreatePromptResponses,
535
+ CreateReportErrors,
536
+ CreateReportParams,
537
+ CreateReportResponse,
538
+ CreateReportResponses,
539
+ CredentialValue,
540
+ DateRange,
541
+ DeleteCompetitorErrors,
542
+ DeleteCompetitorResponses,
543
+ DeletePromptErrors,
544
+ DeletePromptResponse,
545
+ DeletePromptResponses,
546
+ Error,
547
+ FailureBody,
548
+ Fetch,
549
+ FetchOptions,
550
+ ForbiddenError,
551
+ GetBrandErrors,
552
+ GetBrandResponses,
553
+ GetCompetitorErrors,
554
+ GetCompetitorResponses,
555
+ GetMeErrors,
556
+ GetMeResponses,
557
+ GetOrganizationErrors,
558
+ GetOrganizationResponses,
559
+ GetPromptErrors,
560
+ GetPromptResponses,
561
+ GetReportErrors,
562
+ GetReportParams,
563
+ GetReportResponse,
564
+ GetReportResponses,
565
+ Interceptors,
566
+ InternalServerErrorResponse,
567
+ Jitter,
568
+ Limit,
569
+ ListBrandsErrors,
570
+ ListBrandsParams,
571
+ ListBrandsResponses,
572
+ ListCompetitorsErrors,
573
+ ListCompetitorsParams,
574
+ ListCompetitorsResponses,
575
+ ListModelsErrors,
576
+ ListModelsResponses,
577
+ ListOrganizationsErrors,
578
+ ListOrganizationsParams,
579
+ ListOrganizationsResponses,
580
+ ListPromptsErrors,
581
+ ListPromptsParams,
582
+ ListPromptsResponse,
583
+ ListPromptsResponses,
584
+ ListReportsErrors,
585
+ ListReportsParams,
586
+ ListReportsResponse,
587
+ ListReportsResponses,
588
+ LogFn,
589
+ Logger,
590
+ LogLevel,
591
+ Me,
592
+ MentionEntry,
593
+ MentionsSummary,
594
+ MetadataInput,
595
+ MetadataOptions,
596
+ Model,
597
+ ModelFilter,
598
+ ModelList,
599
+ Models,
600
+ NotFoundErrorResponse,
601
+ OnboardingSuggestion,
602
+ Organization,
603
+ OrganizationList,
604
+ Organizations,
605
+ Page,
606
+ PageEnvelope,
607
+ PageParameter,
608
+ PagePromise,
609
+ PageResult,
610
+ Pagination,
611
+ PaymentRequiredErrorResponse,
612
+ PreparedRequest,
613
+ Prompt,
614
+ Prompts,
615
+ RateLimitErrorResponse,
616
+ ReportPromptSnapshot,
617
+ Reports,
618
+ ReportSummary,
619
+ RequestOptions,
620
+ RestCallPromise,
621
+ Result,
622
+ ResultEnvelope,
623
+ RetryAfterHeader,
624
+ RetryOptions,
625
+ RetryRules,
626
+ TagsFilter,
627
+ TimeoutPolicy,
628
+ TimeoutValue,
629
+ Tools,
630
+ Transport,
631
+ TransportErrorKind,
632
+ TransportFailure,
633
+ TransportInteraction,
634
+ UnauthorizedError,
635
+ UpdateBrandErrors,
636
+ UpdateBrandParams,
637
+ UpdateBrandResponses,
638
+ UpdateCompetitorErrors,
639
+ UpdateCompetitorParams,
640
+ UpdateCompetitorResponses,
641
+ UpdatePromptErrors,
642
+ UpdatePromptParams,
643
+ UpdatePromptResponses,
644
+ ValidationError,
645
+ WindowEnd,
646
+ WindowStart,
647
+ WithResponse,
648
+ };
649
+ }
package/src/index.ts ADDED
@@ -0,0 +1,21 @@
1
+ export { createElmoClient, Elmo, VERSION } from './client';
2
+ export {
3
+ AuthenticationError,
4
+ BadRequestError,
5
+ ConflictError,
6
+ InternalServerError,
7
+ NotFoundError,
8
+ PaymentRequiredError,
9
+ PermissionDeniedError,
10
+ RateLimitError,
11
+ UnprocessableEntityError,
12
+ } from './internal/binding/rest/errors';
13
+ export {
14
+ AbortError,
15
+ APIError,
16
+ DecodeError,
17
+ ElmoError,
18
+ MissingCredentialError,
19
+ TimeoutError,
20
+ TransportError,
21
+ } from './internal/core/errors';