@microsoft/webiq 0.0.1-alpha.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +422 -2
- package/dist/index.d.mts +1103 -0
- package/dist/index.d.ts +1103 -1
- package/dist/index.js +825 -2
- package/dist/index.mjs +792 -0
- package/package.json +51 -9
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1103 @@
|
|
|
1
|
+
/** Authentication providers for Web IQ SDK. */
|
|
2
|
+
/** Default OAuth scope for the Web IQ API. */
|
|
3
|
+
declare const DEFAULT_SCOPE = "https://api.microsoft.ai/.default";
|
|
4
|
+
/** Minimal `TokenCredential` shape compatible with `@azure/identity`. */
|
|
5
|
+
interface TokenCredential {
|
|
6
|
+
getToken(scopes: string | string[], options?: Record<string, unknown>): Promise<{
|
|
7
|
+
token: string;
|
|
8
|
+
expiresOnTimestamp?: number;
|
|
9
|
+
} | null>;
|
|
10
|
+
}
|
|
11
|
+
/** Base interface for authentication providers. */
|
|
12
|
+
interface AuthProvider {
|
|
13
|
+
getHeaders(): Promise<Record<string, string>>;
|
|
14
|
+
}
|
|
15
|
+
/** API key authentication via the `x-apikey` header. */
|
|
16
|
+
declare class ApiKeyAuth implements AuthProvider {
|
|
17
|
+
private readonly apiKey;
|
|
18
|
+
constructor(apiKey: string);
|
|
19
|
+
getHeaders(): Promise<Record<string, string>>;
|
|
20
|
+
}
|
|
21
|
+
/** Bearer-token authentication via an azure-identity `TokenCredential`. */
|
|
22
|
+
declare class EntraIDAuth implements AuthProvider {
|
|
23
|
+
private readonly credential;
|
|
24
|
+
private readonly scope;
|
|
25
|
+
constructor(credential: TokenCredential, options?: {
|
|
26
|
+
scope?: string;
|
|
27
|
+
});
|
|
28
|
+
getHeaders(): Promise<Record<string, string>>;
|
|
29
|
+
}
|
|
30
|
+
/** Create an `AuthProvider` from an API key or a `TokenCredential`. */
|
|
31
|
+
declare function createAuth(options: {
|
|
32
|
+
apiKey?: string;
|
|
33
|
+
credential?: TokenCredential;
|
|
34
|
+
scope?: string;
|
|
35
|
+
}): AuthProvider;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Base transport interfaces.
|
|
39
|
+
*/
|
|
40
|
+
/** Default request timeout in milliseconds. */
|
|
41
|
+
declare const DEFAULT_TIMEOUT = 10000;
|
|
42
|
+
/**
|
|
43
|
+
* Custom fetch function type.
|
|
44
|
+
*
|
|
45
|
+
* Defined as a structural call signature rather than `typeof fetch` so that
|
|
46
|
+
* consumers are not required to have `lib.dom` or a specific global `fetch`
|
|
47
|
+
* typing in their `tsconfig`. The loose `Record<string, unknown>` on the
|
|
48
|
+
* init parameter allows runtime-specific extensions (e.g. undici's
|
|
49
|
+
* `dispatcher` option) without requiring a type assertion.
|
|
50
|
+
*/
|
|
51
|
+
type FetchFunction = (input: string | URL | Request, init?: RequestInit & Record<string, unknown>) => Promise<Response>;
|
|
52
|
+
/**
|
|
53
|
+
* Request options for transport layer.
|
|
54
|
+
*/
|
|
55
|
+
interface TransportRequestOptions {
|
|
56
|
+
method: string;
|
|
57
|
+
path: string;
|
|
58
|
+
json?: Record<string, unknown>;
|
|
59
|
+
/** Per-request timeout override in milliseconds. */
|
|
60
|
+
timeout?: number;
|
|
61
|
+
/**
|
|
62
|
+
* Caller-provided cancellation signal. When the signal aborts, the in-flight
|
|
63
|
+
* request is cancelled and the signal's `reason` is re-thrown (no retry, no
|
|
64
|
+
* `APIConnectionError` wrapping). Combine with `AbortSignal.timeout(ms)` for
|
|
65
|
+
* a wall-clock cap, or pass `req.signal` from an HTTP framework to propagate
|
|
66
|
+
* client disconnects.
|
|
67
|
+
*/
|
|
68
|
+
signal?: AbortSignal;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Base interface for transports.
|
|
72
|
+
*/
|
|
73
|
+
interface Transport {
|
|
74
|
+
/** Make an API request. */
|
|
75
|
+
request<T = unknown>(options: TransportRequestOptions): Promise<T>;
|
|
76
|
+
/** Close the transport and release resources. */
|
|
77
|
+
close(): Promise<void>;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
declare enum ContentFormat {
|
|
81
|
+
PASSAGE = "passage",
|
|
82
|
+
TEXT = "text",
|
|
83
|
+
HTML = "html",
|
|
84
|
+
MARKDOWN = "markdown"
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
type WebResult = {
|
|
88
|
+
/**
|
|
89
|
+
* The title of the webpage.
|
|
90
|
+
*/
|
|
91
|
+
title?: string | null;
|
|
92
|
+
/**
|
|
93
|
+
* The source URL of the webpage.
|
|
94
|
+
*/
|
|
95
|
+
url?: string | null;
|
|
96
|
+
/**
|
|
97
|
+
* The detailed content of the webpage.
|
|
98
|
+
*/
|
|
99
|
+
content?: string | null;
|
|
100
|
+
/**
|
|
101
|
+
* The last updated date of the webpage, follows ISO8601 format.
|
|
102
|
+
*/
|
|
103
|
+
lastUpdatedAt?: string | null;
|
|
104
|
+
/**
|
|
105
|
+
* The last crawled date of the webpage, follows ISO8601 format.
|
|
106
|
+
*/
|
|
107
|
+
crawledAt?: string | null;
|
|
108
|
+
/**
|
|
109
|
+
* The language of the webpage, uses ISO 639-1 language code.
|
|
110
|
+
*/
|
|
111
|
+
language?: string | null;
|
|
112
|
+
/**
|
|
113
|
+
* Indicates whether the result includes adult content.
|
|
114
|
+
*/
|
|
115
|
+
isAdult?: boolean;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
type WebResponse = {
|
|
119
|
+
/**
|
|
120
|
+
* List of web page results.
|
|
121
|
+
*/
|
|
122
|
+
webResults?: Array<WebResult> | null;
|
|
123
|
+
/**
|
|
124
|
+
* Trace ID for debugging and tracking.
|
|
125
|
+
*/
|
|
126
|
+
traceId?: string | null;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Web search resource.
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Web search request parameters.
|
|
135
|
+
*/
|
|
136
|
+
interface WebSearchParams {
|
|
137
|
+
/** Search query string (1-1000 chars). */
|
|
138
|
+
query: string;
|
|
139
|
+
/** Max results to return (1-50, default 10). */
|
|
140
|
+
maxResults?: number;
|
|
141
|
+
/** 2-letter ISO 639-1 language code. */
|
|
142
|
+
language?: string;
|
|
143
|
+
/** 2-letter country/region code. */
|
|
144
|
+
region?: string;
|
|
145
|
+
/** Location in format 'lat:<float>;long:<float>'. */
|
|
146
|
+
location?: string;
|
|
147
|
+
/** Content format: use ContentFormat.PASSAGE, .TEXT, .HTML, or .MARKDOWN. */
|
|
148
|
+
contentFormat?: ContentFormat;
|
|
149
|
+
/** Max characters in content (1-500000, default 10000). */
|
|
150
|
+
maxLength?: number;
|
|
151
|
+
/** Per-request timeout in milliseconds (overrides client default). */
|
|
152
|
+
timeout?: number;
|
|
153
|
+
/**
|
|
154
|
+
* Caller-provided cancellation signal. Aborts the in-flight request when
|
|
155
|
+
* fired; the signal's `reason` is re-thrown unchanged. Combine with
|
|
156
|
+
* `AbortSignal.timeout(ms)` for a wall-clock budget that includes retries,
|
|
157
|
+
* or pass `req.signal` from your HTTP framework to propagate client
|
|
158
|
+
* disconnects.
|
|
159
|
+
*/
|
|
160
|
+
signal?: AbortSignal;
|
|
161
|
+
}
|
|
162
|
+
/** Web search options (query is passed separately). */
|
|
163
|
+
type WebSearchOptions = Omit<WebSearchParams, 'query'>;
|
|
164
|
+
/**
|
|
165
|
+
* Web search resource for the Web IQ API.
|
|
166
|
+
*/
|
|
167
|
+
declare class WebResource {
|
|
168
|
+
private readonly transport;
|
|
169
|
+
constructor(transport: Transport);
|
|
170
|
+
/**
|
|
171
|
+
* Search the web for relevant content.
|
|
172
|
+
*
|
|
173
|
+
* @param query - Search query string (1-1000 chars)
|
|
174
|
+
* @param options - Search options
|
|
175
|
+
* @returns WebResponse with webResults list and traceId
|
|
176
|
+
*/
|
|
177
|
+
search(query: string, options?: WebSearchOptions): Promise<WebResponse>;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
type NewsThumbnail = {
|
|
181
|
+
/**
|
|
182
|
+
* The URL of the thumbnail.
|
|
183
|
+
*/
|
|
184
|
+
url?: string | null;
|
|
185
|
+
/**
|
|
186
|
+
* Width of the thumbnail, in pixels.
|
|
187
|
+
*/
|
|
188
|
+
width?: number;
|
|
189
|
+
/**
|
|
190
|
+
* Height of the thumbnail, in pixels.
|
|
191
|
+
*/
|
|
192
|
+
height?: number;
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
type NewsItem = {
|
|
196
|
+
/**
|
|
197
|
+
* The title of the news.
|
|
198
|
+
*/
|
|
199
|
+
title?: string | null;
|
|
200
|
+
/**
|
|
201
|
+
* The source URL of the news.
|
|
202
|
+
*/
|
|
203
|
+
url?: string | null;
|
|
204
|
+
/**
|
|
205
|
+
* The detailed content of the news.
|
|
206
|
+
*/
|
|
207
|
+
content?: string | null;
|
|
208
|
+
/**
|
|
209
|
+
* A snippet from the news content.
|
|
210
|
+
*/
|
|
211
|
+
snippet?: string | null;
|
|
212
|
+
thumbnail?: NewsThumbnail;
|
|
213
|
+
/**
|
|
214
|
+
* The last updated date of the news, in UTC ISO8601 format.
|
|
215
|
+
*/
|
|
216
|
+
lastUpdatedAt?: string | null;
|
|
217
|
+
/**
|
|
218
|
+
* Publisher name, such as 'USA TODAY | MSN', 'CNN', etc.
|
|
219
|
+
*/
|
|
220
|
+
source?: string | null;
|
|
221
|
+
/**
|
|
222
|
+
* Indicates if the content is adult content.
|
|
223
|
+
*/
|
|
224
|
+
isAdult?: boolean;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
type NewsResponse = {
|
|
228
|
+
/**
|
|
229
|
+
* List of news article results.
|
|
230
|
+
*/
|
|
231
|
+
newsResults?: Array<NewsItem> | null;
|
|
232
|
+
/**
|
|
233
|
+
* Trace ID for debugging and tracking.
|
|
234
|
+
*/
|
|
235
|
+
traceId?: string | null;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* News search resource.
|
|
240
|
+
*/
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* News search request parameters.
|
|
244
|
+
*/
|
|
245
|
+
interface NewsSearchParams {
|
|
246
|
+
/** Search query string (1-1000 chars). */
|
|
247
|
+
query: string;
|
|
248
|
+
/** Max results to return (1-20, default 10). */
|
|
249
|
+
maxResults?: number;
|
|
250
|
+
/** 2-letter ISO 639-1 language code. */
|
|
251
|
+
language?: string;
|
|
252
|
+
/** 2-letter country/region code. */
|
|
253
|
+
region?: string;
|
|
254
|
+
/** Location in format 'lat:<float>;long:<float>'. */
|
|
255
|
+
location?: string;
|
|
256
|
+
/** Content format: use ContentFormat.PASSAGE, .TEXT, .HTML, or .MARKDOWN. */
|
|
257
|
+
contentFormat?: ContentFormat;
|
|
258
|
+
/** Max characters in content (1-500000, default 10000). */
|
|
259
|
+
maxLength?: number;
|
|
260
|
+
/** Per-request timeout in milliseconds (overrides client default). */
|
|
261
|
+
timeout?: number;
|
|
262
|
+
/** Caller-provided cancellation signal (see `WebSearchParams.signal`). */
|
|
263
|
+
signal?: AbortSignal;
|
|
264
|
+
}
|
|
265
|
+
/** News search options (query is passed separately). */
|
|
266
|
+
type NewsSearchOptions = Omit<NewsSearchParams, 'query'>;
|
|
267
|
+
/**
|
|
268
|
+
* News search resource for the Web IQ API.
|
|
269
|
+
*/
|
|
270
|
+
declare class NewsResource {
|
|
271
|
+
private readonly transport;
|
|
272
|
+
constructor(transport: Transport);
|
|
273
|
+
/**
|
|
274
|
+
* Search for news articles.
|
|
275
|
+
*
|
|
276
|
+
* @param query - Search query string (1-1000 chars)
|
|
277
|
+
* @param options - Search options
|
|
278
|
+
* @returns NewsResponse with newsResults list and traceId
|
|
279
|
+
*/
|
|
280
|
+
search(query: string, options?: NewsSearchOptions): Promise<NewsResponse>;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
declare enum SafeSearch {
|
|
284
|
+
OFF = "off",
|
|
285
|
+
STRICT = "strict"
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
declare enum VideoDuration {
|
|
289
|
+
SHORT = "short",
|
|
290
|
+
MEDIUM = "medium",
|
|
291
|
+
LONG = "long"
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
declare enum VideoResolution {
|
|
295
|
+
_360P = "360p",
|
|
296
|
+
_480P = "480p",
|
|
297
|
+
_720P = "720p",
|
|
298
|
+
_1080P = "1080p"
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
type PlaylistVideo = {
|
|
302
|
+
/**
|
|
303
|
+
* Title of the video.
|
|
304
|
+
*/
|
|
305
|
+
title?: string | null;
|
|
306
|
+
/**
|
|
307
|
+
* Description of the video.
|
|
308
|
+
*/
|
|
309
|
+
description?: string | null;
|
|
310
|
+
/**
|
|
311
|
+
* URL of the video.
|
|
312
|
+
*/
|
|
313
|
+
url?: string | null;
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
type PlaylistItem = {
|
|
317
|
+
/**
|
|
318
|
+
* Title of the playlist.
|
|
319
|
+
*/
|
|
320
|
+
title?: string | null;
|
|
321
|
+
/**
|
|
322
|
+
* Description of the playlist.
|
|
323
|
+
*/
|
|
324
|
+
description?: string | null;
|
|
325
|
+
/**
|
|
326
|
+
* Array of videos in the playlist.
|
|
327
|
+
*/
|
|
328
|
+
videos?: Array<PlaylistVideo> | null;
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
type VideoMoment = {
|
|
332
|
+
/**
|
|
333
|
+
* Title of the moment segment.
|
|
334
|
+
*/
|
|
335
|
+
title?: string | null;
|
|
336
|
+
/**
|
|
337
|
+
* Description of what happens in this moment.
|
|
338
|
+
*/
|
|
339
|
+
description?: string | null;
|
|
340
|
+
/**
|
|
341
|
+
* Start time of the moment in format 'd.hh:mm:ss'.
|
|
342
|
+
*/
|
|
343
|
+
startTime?: string | null;
|
|
344
|
+
/**
|
|
345
|
+
* End time of the moment in format 'd.hh:mm:ss'.
|
|
346
|
+
*/
|
|
347
|
+
endTime?: string | null;
|
|
348
|
+
/**
|
|
349
|
+
* Direct URL to this specific moment in the video.
|
|
350
|
+
*/
|
|
351
|
+
momentUrl?: string | null;
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
type VideoItem = {
|
|
355
|
+
/**
|
|
356
|
+
* The title or name of the video.
|
|
357
|
+
*/
|
|
358
|
+
title?: string | null;
|
|
359
|
+
/**
|
|
360
|
+
* The video source URL.
|
|
361
|
+
*/
|
|
362
|
+
url?: string | null;
|
|
363
|
+
/**
|
|
364
|
+
* Description of the video content. This is either given by video uploader or generated by LLM
|
|
365
|
+
*/
|
|
366
|
+
description?: string | null;
|
|
367
|
+
/**
|
|
368
|
+
* Uploader or publisher of the video.
|
|
369
|
+
*/
|
|
370
|
+
publishedBy?: string | null;
|
|
371
|
+
/**
|
|
372
|
+
* The number of views the video has.
|
|
373
|
+
*/
|
|
374
|
+
viewCount?: number;
|
|
375
|
+
/**
|
|
376
|
+
* Short summary or highlight of the video.
|
|
377
|
+
*/
|
|
378
|
+
summary?: string | null;
|
|
379
|
+
/**
|
|
380
|
+
* The length of the video in HH:MM:SS format.
|
|
381
|
+
*/
|
|
382
|
+
length?: string | null;
|
|
383
|
+
/**
|
|
384
|
+
* Whether HTTPS embedding is allowed.
|
|
385
|
+
*/
|
|
386
|
+
allowHttpsEmbedding?: boolean;
|
|
387
|
+
/**
|
|
388
|
+
* Whether mobile embedding is allowed.
|
|
389
|
+
*/
|
|
390
|
+
allowMobileEmbedding?: boolean;
|
|
391
|
+
/**
|
|
392
|
+
* URL for embedding the video.
|
|
393
|
+
*/
|
|
394
|
+
embeddingUrl?: string | null;
|
|
395
|
+
/**
|
|
396
|
+
* The last updated date as a formatted string.
|
|
397
|
+
*/
|
|
398
|
+
lastUpdatedAt?: string | null;
|
|
399
|
+
/**
|
|
400
|
+
* Index of the best moment or highlight in the video.
|
|
401
|
+
*/
|
|
402
|
+
bestMomentIndex?: number | null;
|
|
403
|
+
/**
|
|
404
|
+
* Array of video segments/moments.
|
|
405
|
+
*/
|
|
406
|
+
moments?: Array<VideoMoment> | null;
|
|
407
|
+
/**
|
|
408
|
+
* Thumbnail URL of the video.
|
|
409
|
+
*/
|
|
410
|
+
thumbnailUrl?: string | null;
|
|
411
|
+
/**
|
|
412
|
+
* The width of the video in pixels.
|
|
413
|
+
*/
|
|
414
|
+
width?: number | null;
|
|
415
|
+
/**
|
|
416
|
+
* The height of the video in pixels.
|
|
417
|
+
*/
|
|
418
|
+
height?: number | null;
|
|
419
|
+
/**
|
|
420
|
+
* Indicates whether the result includes adult content.
|
|
421
|
+
*/
|
|
422
|
+
isAdult?: boolean;
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
type VideosResponse = {
|
|
426
|
+
/**
|
|
427
|
+
* List of video results.
|
|
428
|
+
*/
|
|
429
|
+
videoResults?: Array<VideoItem> | null;
|
|
430
|
+
/**
|
|
431
|
+
* List of playlist results.
|
|
432
|
+
*/
|
|
433
|
+
playlists?: Array<PlaylistItem> | null;
|
|
434
|
+
/**
|
|
435
|
+
* Trace ID for debugging and tracking.
|
|
436
|
+
*/
|
|
437
|
+
traceId?: string | null;
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Videos search resource.
|
|
442
|
+
*/
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Videos search request parameters.
|
|
446
|
+
*/
|
|
447
|
+
interface VideosSearchParams {
|
|
448
|
+
/** Search query string (1-1000 chars). */
|
|
449
|
+
query: string;
|
|
450
|
+
/** Max results to return (1-30, default 30). */
|
|
451
|
+
maxResults?: number;
|
|
452
|
+
/** 2-letter ISO 639-1 language code. */
|
|
453
|
+
language?: string;
|
|
454
|
+
/** 2-letter country/region code. */
|
|
455
|
+
region?: string;
|
|
456
|
+
/** Whether to include playlist results (default false). */
|
|
457
|
+
enablePlaylist?: boolean;
|
|
458
|
+
/** Time range filter ('day', 'week', 'month', 'year', or date range). */
|
|
459
|
+
freshness?: string;
|
|
460
|
+
/** Filter videos by embedding capabilities (e.g. ['player']). */
|
|
461
|
+
embeddable?: string[];
|
|
462
|
+
/** Filter by minimum resolution ('360p', '480p', '720p', '1080p'). */
|
|
463
|
+
resolution?: VideoResolution;
|
|
464
|
+
/** Safe search filter level. */
|
|
465
|
+
safeSearch?: SafeSearch;
|
|
466
|
+
/** Filter by duration ('short' < 5min, 'medium' 5-20min, 'long' > 20min). */
|
|
467
|
+
duration?: VideoDuration;
|
|
468
|
+
/** Per-request timeout in milliseconds (overrides client default). */
|
|
469
|
+
timeout?: number;
|
|
470
|
+
/** Caller-provided cancellation signal (see `WebSearchParams.signal`). */
|
|
471
|
+
signal?: AbortSignal;
|
|
472
|
+
}
|
|
473
|
+
/** Videos search options (query is passed separately). */
|
|
474
|
+
type VideoSearchOptions = Omit<VideosSearchParams, 'query'>;
|
|
475
|
+
/**
|
|
476
|
+
* Videos search resource for the Web IQ API.
|
|
477
|
+
*/
|
|
478
|
+
declare class VideosResource {
|
|
479
|
+
private readonly transport;
|
|
480
|
+
constructor(transport: Transport);
|
|
481
|
+
/**
|
|
482
|
+
* Search for videos.
|
|
483
|
+
*
|
|
484
|
+
* @param query - Search query string (1-1000 chars)
|
|
485
|
+
* @param options - Search options
|
|
486
|
+
* @returns VideosResponse with videoResults, playlists, and traceId
|
|
487
|
+
*/
|
|
488
|
+
search(query: string, options?: VideoSearchOptions): Promise<VideosResponse>;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
declare enum ImageAspectRatio {
|
|
492
|
+
SQUARE = "square",
|
|
493
|
+
WIDE = "wide",
|
|
494
|
+
TALL = "tall"
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
declare enum ImageColor {
|
|
498
|
+
COLOR_ONLY = "colorOnly",
|
|
499
|
+
MONOCHROME = "monochrome"
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
declare enum ImageSize {
|
|
503
|
+
SMALL = "small",
|
|
504
|
+
MEDIUM = "medium",
|
|
505
|
+
LARGE = "large",
|
|
506
|
+
EXTRA_LARGE = "extraLarge"
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
type ImageItem = {
|
|
510
|
+
/**
|
|
511
|
+
* The title of the image.
|
|
512
|
+
*/
|
|
513
|
+
title?: string | null;
|
|
514
|
+
/**
|
|
515
|
+
* The source URL of the image.
|
|
516
|
+
*/
|
|
517
|
+
url?: string | null;
|
|
518
|
+
/**
|
|
519
|
+
* The host page URL of the image.
|
|
520
|
+
*/
|
|
521
|
+
hostPageUrl?: string | null;
|
|
522
|
+
/**
|
|
523
|
+
* Generated description of the image.
|
|
524
|
+
*/
|
|
525
|
+
caption?: string | null;
|
|
526
|
+
/**
|
|
527
|
+
* The width of the image, in pixels.
|
|
528
|
+
*/
|
|
529
|
+
width?: number;
|
|
530
|
+
/**
|
|
531
|
+
* The height of the image, in pixels.
|
|
532
|
+
*/
|
|
533
|
+
height?: number;
|
|
534
|
+
/**
|
|
535
|
+
* The thumbnail source URL of the image.
|
|
536
|
+
*/
|
|
537
|
+
thumbnailUrl?: string | null;
|
|
538
|
+
/**
|
|
539
|
+
* The last updated date of the image, follows ISO8601 format.
|
|
540
|
+
*/
|
|
541
|
+
lastUpdatedAt?: string | null;
|
|
542
|
+
/**
|
|
543
|
+
* Indicates whether the content is adult content.
|
|
544
|
+
*/
|
|
545
|
+
isAdult?: boolean;
|
|
546
|
+
};
|
|
547
|
+
|
|
548
|
+
type ImagesResponse = {
|
|
549
|
+
/**
|
|
550
|
+
* List of image results.
|
|
551
|
+
*/
|
|
552
|
+
imageResults?: Array<ImageItem> | null;
|
|
553
|
+
/**
|
|
554
|
+
* Trace ID for debugging and tracking.
|
|
555
|
+
*/
|
|
556
|
+
traceId?: string | null;
|
|
557
|
+
};
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Images search resource.
|
|
561
|
+
*/
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Images search request parameters.
|
|
565
|
+
*/
|
|
566
|
+
interface ImagesSearchParams {
|
|
567
|
+
/** Search query string (1-1000 chars). */
|
|
568
|
+
query: string;
|
|
569
|
+
/** Max results to return (1-30, default 30). */
|
|
570
|
+
maxResults?: number;
|
|
571
|
+
/** 2-letter ISO 639-1 language code. */
|
|
572
|
+
language?: string;
|
|
573
|
+
/** 2-letter country/region code. */
|
|
574
|
+
region?: string;
|
|
575
|
+
/** Filter by image aspect ratio. */
|
|
576
|
+
aspectRatio?: ImageAspectRatio;
|
|
577
|
+
/** Filter by image color type. */
|
|
578
|
+
color?: ImageColor;
|
|
579
|
+
/** Safe search filter level. */
|
|
580
|
+
safeSearch?: SafeSearch;
|
|
581
|
+
/** Filter by image size. */
|
|
582
|
+
imageSize?: ImageSize;
|
|
583
|
+
/** Whether to filter out watermarked images (default false). */
|
|
584
|
+
watermarkFree?: boolean;
|
|
585
|
+
/** Maximum height of the image in pixels. */
|
|
586
|
+
maxHeight?: number;
|
|
587
|
+
/** Minimum height of the image in pixels. */
|
|
588
|
+
minHeight?: number;
|
|
589
|
+
/** Maximum width of the image in pixels. */
|
|
590
|
+
maxWidth?: number;
|
|
591
|
+
/** Minimum width of the image in pixels. */
|
|
592
|
+
minWidth?: number;
|
|
593
|
+
/** Per-request timeout in milliseconds (overrides client default). */
|
|
594
|
+
timeout?: number;
|
|
595
|
+
/** Caller-provided cancellation signal (see `WebSearchParams.signal`). */
|
|
596
|
+
signal?: AbortSignal;
|
|
597
|
+
}
|
|
598
|
+
/** Images search options (query is passed separately). */
|
|
599
|
+
type ImageSearchOptions = Omit<ImagesSearchParams, 'query'>;
|
|
600
|
+
/**
|
|
601
|
+
* Images search resource for the Web IQ API.
|
|
602
|
+
*/
|
|
603
|
+
declare class ImagesResource {
|
|
604
|
+
private readonly transport;
|
|
605
|
+
constructor(transport: Transport);
|
|
606
|
+
/**
|
|
607
|
+
* Search for images.
|
|
608
|
+
*
|
|
609
|
+
* @param query - Search query string (1-1000 chars)
|
|
610
|
+
* @param options - Search options
|
|
611
|
+
* @returns ImagesResponse with imageResults and traceId
|
|
612
|
+
*/
|
|
613
|
+
search(query: string, options?: ImageSearchOptions): Promise<ImagesResponse>;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
declare enum BrowseContentFormat {
|
|
617
|
+
TEXT = "text",
|
|
618
|
+
HTML = "html",
|
|
619
|
+
MARKDOWN = "markdown"
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
type BrowseResponse = {
|
|
623
|
+
/**
|
|
624
|
+
* The URL of the web page.
|
|
625
|
+
*/
|
|
626
|
+
url?: string | null;
|
|
627
|
+
/**
|
|
628
|
+
* The title of the web page.
|
|
629
|
+
*/
|
|
630
|
+
title?: string | null;
|
|
631
|
+
/**
|
|
632
|
+
* The extracted content of the web page.
|
|
633
|
+
*/
|
|
634
|
+
content?: string | null;
|
|
635
|
+
/**
|
|
636
|
+
* Indicates if the content is adult content.
|
|
637
|
+
*/
|
|
638
|
+
isAdult?: boolean | null;
|
|
639
|
+
/**
|
|
640
|
+
* The last updated date of the webpage, follows ISO8601 format.
|
|
641
|
+
*/
|
|
642
|
+
lastUpdatedAt?: string | null;
|
|
643
|
+
/**
|
|
644
|
+
* The last crawled date of the webpage, follows ISO8601 format.
|
|
645
|
+
*/
|
|
646
|
+
crawledAt?: string | null;
|
|
647
|
+
/**
|
|
648
|
+
* Retry after value when on-demand crawl is in progress. Only present when the page needs to be crawled.
|
|
649
|
+
*/
|
|
650
|
+
retryAfter?: string | null;
|
|
651
|
+
/**
|
|
652
|
+
* Trace ID for debugging and tracking.
|
|
653
|
+
*/
|
|
654
|
+
traceId?: string | null;
|
|
655
|
+
};
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* Browse resource for fetching web page content.
|
|
659
|
+
*/
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* Browse request parameters.
|
|
663
|
+
*/
|
|
664
|
+
interface BrowseParams {
|
|
665
|
+
/** The URL of the web page to browse. */
|
|
666
|
+
url: string;
|
|
667
|
+
/** Max characters in content (1-500000, default 10000). */
|
|
668
|
+
maxLength?: number;
|
|
669
|
+
/** Crawl behavior ('none', 'fallback', or 'force', default 'none'). */
|
|
670
|
+
liveCrawl?: 'none' | 'fallback' | 'force';
|
|
671
|
+
/** Include outbound hyperlinks (default false). */
|
|
672
|
+
includeWebLinks?: boolean;
|
|
673
|
+
/** Enable JS rendering for dynamic content (default false). */
|
|
674
|
+
renderDynamicPages?: boolean;
|
|
675
|
+
/** Include image URLs (default false). */
|
|
676
|
+
includeImageLinks?: boolean;
|
|
677
|
+
/** 2-letter ISO 639-1 language code. */
|
|
678
|
+
language?: string;
|
|
679
|
+
/** 2-letter country/region code. */
|
|
680
|
+
region?: string;
|
|
681
|
+
/** Content format: use BrowseContentFormat.TEXT, .HTML, or .MARKDOWN. */
|
|
682
|
+
contentFormat?: BrowseContentFormat;
|
|
683
|
+
/** Per-request timeout in milliseconds (overrides client default). */
|
|
684
|
+
timeout?: number;
|
|
685
|
+
/** Caller-provided cancellation signal (see `WebSearchParams.signal`). */
|
|
686
|
+
signal?: AbortSignal;
|
|
687
|
+
}
|
|
688
|
+
/** Browse fetch options (url is passed separately). */
|
|
689
|
+
type BrowseFetchOptions = Omit<BrowseParams, 'url'>;
|
|
690
|
+
/**
|
|
691
|
+
* Browse resource for the Web IQ API.
|
|
692
|
+
*/
|
|
693
|
+
declare class BrowseResource {
|
|
694
|
+
private readonly transport;
|
|
695
|
+
constructor(transport: Transport);
|
|
696
|
+
/**
|
|
697
|
+
* Fetch and extract content from a web page.
|
|
698
|
+
*
|
|
699
|
+
* @param url - The URL of the web page to browse
|
|
700
|
+
* @param options - Fetch options
|
|
701
|
+
* @returns BrowseResponse with url, content, traceId, and optional retryAfter
|
|
702
|
+
*/
|
|
703
|
+
fetch(url: string, options?: BrowseFetchOptions): Promise<BrowseResponse>;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
declare enum SafeSearchMode {
|
|
707
|
+
OFF = "off",
|
|
708
|
+
MODERATE = "moderate",
|
|
709
|
+
STRICT = "strict"
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
type QuerySignals = {
|
|
713
|
+
/**
|
|
714
|
+
* The original user query as received by the system.
|
|
715
|
+
*/
|
|
716
|
+
originalQuery?: string | null;
|
|
717
|
+
/**
|
|
718
|
+
* The normalized version of the user query after processing (e.g., lowercasing, removing stop words).
|
|
719
|
+
*/
|
|
720
|
+
normalizedQuery?: string | null;
|
|
721
|
+
/**
|
|
722
|
+
* Indicates whether the query is defensive
|
|
723
|
+
*/
|
|
724
|
+
isDefensive?: boolean | null;
|
|
725
|
+
/**
|
|
726
|
+
* Indicates whether the query is flagged as adult query
|
|
727
|
+
*/
|
|
728
|
+
isAdult?: boolean | null;
|
|
729
|
+
/**
|
|
730
|
+
* Indicates whether the query is navigational
|
|
731
|
+
*/
|
|
732
|
+
isNav?: boolean | null;
|
|
733
|
+
/**
|
|
734
|
+
* Indicates whether the query is fresh
|
|
735
|
+
*/
|
|
736
|
+
isFresh?: boolean | null;
|
|
737
|
+
};
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* Response for the classic search endpoint. The spec defines this as an
|
|
741
|
+
* open object (additionalProperties: {}) — keep the typed fields the spec
|
|
742
|
+
* lists but allow arbitrary extra keys (webResults, imageResults, etc.)
|
|
743
|
+
* so callers can read what the server actually returns.
|
|
744
|
+
*/
|
|
745
|
+
type SearchClassicResponse = {
|
|
746
|
+
querySignals?: QuerySignals;
|
|
747
|
+
/** Trace ID for debugging and tracking. */
|
|
748
|
+
traceId?: string;
|
|
749
|
+
[key: string]: any;
|
|
750
|
+
};
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* Classic search resource.
|
|
754
|
+
*/
|
|
755
|
+
|
|
756
|
+
/**
|
|
757
|
+
* Classic search request parameters.
|
|
758
|
+
*/
|
|
759
|
+
interface ClassicSearchParams {
|
|
760
|
+
/** Search query string (1-1000 chars). */
|
|
761
|
+
query: string;
|
|
762
|
+
/** Max answer types to return (1-6, default 6). */
|
|
763
|
+
maxAnswerTypes?: number;
|
|
764
|
+
/** Language code (ISO 639-1/2 or BCP 47). */
|
|
765
|
+
language?: string;
|
|
766
|
+
/** 2-letter country/region code. */
|
|
767
|
+
region?: string;
|
|
768
|
+
/** Location in format 'lat:<float>;long:<float>'. */
|
|
769
|
+
location?: string;
|
|
770
|
+
/** Max web results to return (1-50, default 10). */
|
|
771
|
+
maxResultsWeb?: number;
|
|
772
|
+
/** Max characters in content (1-500000, default 10000). */
|
|
773
|
+
maxLength?: number;
|
|
774
|
+
/** Content format: use ContentFormat.PASSAGE, .TEXT, .HTML, or .MARKDOWN. */
|
|
775
|
+
contentFormat?: ContentFormat;
|
|
776
|
+
/** Time range filter ('day', 'week', 'month', 'year', or date range). */
|
|
777
|
+
freshness?: string;
|
|
778
|
+
/** List of answer types to include in response. */
|
|
779
|
+
responseFilter?: string[];
|
|
780
|
+
/** Safe search mode: use SafeSearchMode.OFF, .MODERATE, or .STRICT. */
|
|
781
|
+
safeSearch?: SafeSearchMode;
|
|
782
|
+
/** Per-request timeout in milliseconds (overrides client default). */
|
|
783
|
+
timeout?: number;
|
|
784
|
+
/** Caller-provided cancellation signal (see `WebSearchParams.signal`). */
|
|
785
|
+
signal?: AbortSignal;
|
|
786
|
+
}
|
|
787
|
+
/** Classic search options (query is passed separately). */
|
|
788
|
+
type ClassicSearchOptions = Omit<ClassicSearchParams, 'query'>;
|
|
789
|
+
/**
|
|
790
|
+
* Classic search resource for the Web IQ API.
|
|
791
|
+
* Given a query, searches and retrieves content from webpages, images, videos,
|
|
792
|
+
* news, weather, sports, etc.
|
|
793
|
+
*/
|
|
794
|
+
declare class ClassicResource {
|
|
795
|
+
private readonly transport;
|
|
796
|
+
constructor(transport: Transport);
|
|
797
|
+
/**
|
|
798
|
+
* Perform a classic search returning grouped results across multiple answer types.
|
|
799
|
+
*
|
|
800
|
+
* @param query - Search query string (1-1000 chars)
|
|
801
|
+
* @param options - Search options
|
|
802
|
+
* @returns SearchClassicResponse with querySignals, traceId, and additional answer types
|
|
803
|
+
*/
|
|
804
|
+
search(query: string, options?: ClassicSearchOptions): Promise<SearchClassicResponse>;
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
/**
|
|
808
|
+
* Configuration for request retry behavior.
|
|
809
|
+
*/
|
|
810
|
+
interface RetryPolicyOptions {
|
|
811
|
+
/** Maximum number of retry attempts (default: 2) */
|
|
812
|
+
maxRetries?: number;
|
|
813
|
+
/** Base delay in seconds for exponential backoff (default: 0.25) */
|
|
814
|
+
baseDelaySeconds?: number;
|
|
815
|
+
/** Maximum delay in seconds (default: 4.0) */
|
|
816
|
+
maxDelaySeconds?: number;
|
|
817
|
+
/**
|
|
818
|
+
* HTTP status codes that trigger a retry. 429 and 430 (rate-limit /
|
|
819
|
+
* concurrency-limit) are intentionally excluded: the transport throws
|
|
820
|
+
* `RateLimitError` immediately so the caller can inspect `error.retryAfter`
|
|
821
|
+
* and decide whether to back off.
|
|
822
|
+
*/
|
|
823
|
+
retryOnStatus?: number[];
|
|
824
|
+
}
|
|
825
|
+
/**
|
|
826
|
+
* Retry policy with exponential backoff.
|
|
827
|
+
*/
|
|
828
|
+
declare class RetryPolicy {
|
|
829
|
+
readonly maxRetries: number;
|
|
830
|
+
readonly baseDelaySeconds: number;
|
|
831
|
+
readonly maxDelaySeconds: number;
|
|
832
|
+
readonly retryOnStatus: Set<number>;
|
|
833
|
+
constructor(options?: RetryPolicyOptions);
|
|
834
|
+
/**
|
|
835
|
+
* Compute the delay before the next retry attempt.
|
|
836
|
+
*
|
|
837
|
+
* @param attempt - Current attempt number (1-based)
|
|
838
|
+
* @param retryAfter - Server-specified retry-after value (if any)
|
|
839
|
+
* @returns Delay in seconds before next attempt
|
|
840
|
+
*/
|
|
841
|
+
computeDelay(attempt: number, retryAfter?: number): number;
|
|
842
|
+
/**
|
|
843
|
+
* Check if a status code should trigger a retry.
|
|
844
|
+
*/
|
|
845
|
+
shouldRetry(statusCode: number): boolean;
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
/**
|
|
849
|
+
* Telemetry support for tracking API requests.
|
|
850
|
+
*/
|
|
851
|
+
/**
|
|
852
|
+
* Event emitted for each API request attempt.
|
|
853
|
+
*/
|
|
854
|
+
interface TelemetryEvent {
|
|
855
|
+
/** HTTP method (GET, POST, etc.) */
|
|
856
|
+
method: string;
|
|
857
|
+
/** API path */
|
|
858
|
+
path: string;
|
|
859
|
+
/** Transport type (e.g. 'http') */
|
|
860
|
+
transport: string;
|
|
861
|
+
/** Attempt number (1-based) */
|
|
862
|
+
attempt: number;
|
|
863
|
+
/** HTTP status code (if available) */
|
|
864
|
+
statusCode?: number;
|
|
865
|
+
/** Request ID from response headers */
|
|
866
|
+
requestId?: string;
|
|
867
|
+
/** Trace ID from response body */
|
|
868
|
+
traceId?: string;
|
|
869
|
+
/** Retry-after value (if rate limited) */
|
|
870
|
+
retryAfter?: string;
|
|
871
|
+
/** Request duration in milliseconds */
|
|
872
|
+
elapsedMs?: number;
|
|
873
|
+
/** Exception (if request failed) */
|
|
874
|
+
error?: Error;
|
|
875
|
+
/** Error response body (if status >= 400) */
|
|
876
|
+
errorBody?: unknown;
|
|
877
|
+
}
|
|
878
|
+
/**
|
|
879
|
+
* Callback function for telemetry events.
|
|
880
|
+
*/
|
|
881
|
+
type TelemetryHook = (event: TelemetryEvent) => void;
|
|
882
|
+
/**
|
|
883
|
+
* Safely invoke a telemetry hook, ignoring any exceptions.
|
|
884
|
+
*/
|
|
885
|
+
declare function safeCall(hook: TelemetryHook | undefined, event: TelemetryEvent): void;
|
|
886
|
+
/**
|
|
887
|
+
* Create a telemetry event.
|
|
888
|
+
*/
|
|
889
|
+
declare function createTelemetryEvent(method: string, path: string, transport: string, attempt: number, options?: Partial<Omit<TelemetryEvent, 'method' | 'path' | 'transport' | 'attempt'>>): TelemetryEvent;
|
|
890
|
+
|
|
891
|
+
/**
|
|
892
|
+
* Web IQ SDK for the Web IQ API.
|
|
893
|
+
*/
|
|
894
|
+
|
|
895
|
+
/**
|
|
896
|
+
* Options for creating a Web IQ client.
|
|
897
|
+
*/
|
|
898
|
+
interface WebIQClientOptions {
|
|
899
|
+
/** Your Web IQ API key (use this OR credential/auth) */
|
|
900
|
+
apiKey?: string;
|
|
901
|
+
/** An `azure-identity` `TokenCredential`. */
|
|
902
|
+
credential?: TokenCredential;
|
|
903
|
+
/** Optional OAuth scope. Defaults to {@link DEFAULT_SCOPE}. */
|
|
904
|
+
scope?: string;
|
|
905
|
+
/** Custom AuthProvider instance */
|
|
906
|
+
auth?: AuthProvider;
|
|
907
|
+
/** Base URL for the API (default: https://api.microsoft.ai/v3) */
|
|
908
|
+
baseUrl?: string;
|
|
909
|
+
/** Optional callback for telemetry events */
|
|
910
|
+
telemetryHook?: TelemetryHook;
|
|
911
|
+
/**
|
|
912
|
+
* Default per-request timeout in milliseconds. Individual calls can
|
|
913
|
+
* override this with their own `timeout` option.
|
|
914
|
+
*/
|
|
915
|
+
timeout?: number;
|
|
916
|
+
/** Retry policy (or options) applied to every request. */
|
|
917
|
+
retry?: RetryPolicy | RetryPolicyOptions;
|
|
918
|
+
/**
|
|
919
|
+
* Custom fetch function for advanced networking (e.g., proxy support, custom TLS).
|
|
920
|
+
* Must be compatible with the global `fetch` signature.
|
|
921
|
+
* If not provided, the global `fetch` is used.
|
|
922
|
+
*
|
|
923
|
+
* @example
|
|
924
|
+
* ```typescript
|
|
925
|
+
* import { ProxyAgent } from "undici";
|
|
926
|
+
*
|
|
927
|
+
* const proxyAgent = new ProxyAgent("http://my-proxy:8080");
|
|
928
|
+
* const client = new WebIQClient({
|
|
929
|
+
* apiKey: "key",
|
|
930
|
+
* // `dispatcher` is a Node/undici-specific option; the FetchFunction
|
|
931
|
+
* // type accepts extra init fields so no type assertion is needed.
|
|
932
|
+
* fetchFn: (url, init) => fetch(url, { ...init, dispatcher: proxyAgent }),
|
|
933
|
+
* });
|
|
934
|
+
* ```
|
|
935
|
+
*/
|
|
936
|
+
fetchFn?: FetchFunction;
|
|
937
|
+
}
|
|
938
|
+
/**
|
|
939
|
+
* Web IQ client for the Web IQ API.
|
|
940
|
+
*
|
|
941
|
+
* @example
|
|
942
|
+
* ```typescript
|
|
943
|
+
* // Using API key
|
|
944
|
+
* const client = new WebIQClient({ apiKey: "your-api-key" });
|
|
945
|
+
*
|
|
946
|
+
* // Search the web
|
|
947
|
+
* const results = await client.web.search("Python programming");
|
|
948
|
+
* for (const result of results.webResults ?? []) {
|
|
949
|
+
* console.log(result.title, result.url);
|
|
950
|
+
* }
|
|
951
|
+
*
|
|
952
|
+
* // Close when done
|
|
953
|
+
* await client.close();
|
|
954
|
+
* ```
|
|
955
|
+
*
|
|
956
|
+
* @example
|
|
957
|
+
* ```typescript
|
|
958
|
+
* // Using EntraID via any azure-identity credential
|
|
959
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
960
|
+
*
|
|
961
|
+
* const client = new WebIQClient({
|
|
962
|
+
* credential: new DefaultAzureCredential(),
|
|
963
|
+
* });
|
|
964
|
+
* ```
|
|
965
|
+
*/
|
|
966
|
+
declare class WebIQClient {
|
|
967
|
+
/** Web search resource */
|
|
968
|
+
readonly web: WebResource;
|
|
969
|
+
/** News search resource */
|
|
970
|
+
readonly news: NewsResource;
|
|
971
|
+
/** Videos search resource */
|
|
972
|
+
readonly videos: VideosResource;
|
|
973
|
+
/** Images search resource */
|
|
974
|
+
readonly images: ImagesResource;
|
|
975
|
+
/** Browse resource */
|
|
976
|
+
readonly browse: BrowseResource;
|
|
977
|
+
/** Classic search resource */
|
|
978
|
+
readonly classic: ClassicResource;
|
|
979
|
+
private readonly _transport;
|
|
980
|
+
private readonly _auth;
|
|
981
|
+
constructor(options: WebIQClientOptions);
|
|
982
|
+
/**
|
|
983
|
+
* Close the client and release resources.
|
|
984
|
+
*/
|
|
985
|
+
close(): Promise<void>;
|
|
986
|
+
}
|
|
987
|
+
/**
|
|
988
|
+
* Create a Web IQ client using the provided options.
|
|
989
|
+
*
|
|
990
|
+
* This is an alternative to using `new WebIQClient(options)`.
|
|
991
|
+
*/
|
|
992
|
+
declare function createClient(options: WebIQClientOptions): WebIQClient;
|
|
993
|
+
|
|
994
|
+
/**
|
|
995
|
+
* Web IQ SDK error classes.
|
|
996
|
+
*/
|
|
997
|
+
/**
|
|
998
|
+
* Base exception for all Web IQ SDK errors.
|
|
999
|
+
*/
|
|
1000
|
+
declare class WebIQError extends Error {
|
|
1001
|
+
constructor(message: string, options?: ErrorOptions);
|
|
1002
|
+
}
|
|
1003
|
+
/**
|
|
1004
|
+
* Raised when the SDK cannot connect to the API.
|
|
1005
|
+
*/
|
|
1006
|
+
declare class APIConnectionError extends WebIQError {
|
|
1007
|
+
constructor(message: string, options?: ErrorOptions);
|
|
1008
|
+
}
|
|
1009
|
+
/**
|
|
1010
|
+
* Raised when the API returns an error status code.
|
|
1011
|
+
*/
|
|
1012
|
+
declare class APIStatusError extends WebIQError {
|
|
1013
|
+
readonly statusCode: number;
|
|
1014
|
+
readonly body?: unknown;
|
|
1015
|
+
readonly requestId?: string;
|
|
1016
|
+
readonly traceId?: string;
|
|
1017
|
+
constructor(statusCode: number, message: string, options?: {
|
|
1018
|
+
body?: unknown;
|
|
1019
|
+
requestId?: string;
|
|
1020
|
+
traceId?: string;
|
|
1021
|
+
});
|
|
1022
|
+
}
|
|
1023
|
+
/**
|
|
1024
|
+
* Raised when the API rate limit is exceeded (429 standard rate-limit, or 430
|
|
1025
|
+
* for /browse-specific concurrency limit).
|
|
1026
|
+
*/
|
|
1027
|
+
declare class RateLimitError extends APIStatusError {
|
|
1028
|
+
constructor(statusCode: number, message: string, options?: {
|
|
1029
|
+
body?: unknown;
|
|
1030
|
+
requestId?: string;
|
|
1031
|
+
traceId?: string;
|
|
1032
|
+
});
|
|
1033
|
+
/** The retry-after value from the API response body, if available. */
|
|
1034
|
+
get retryAfter(): string | undefined;
|
|
1035
|
+
}
|
|
1036
|
+
/**
|
|
1037
|
+
* Raised when authentication fails (401).
|
|
1038
|
+
*/
|
|
1039
|
+
declare class AuthenticationError extends APIStatusError {
|
|
1040
|
+
constructor(statusCode: number, message: string, options?: {
|
|
1041
|
+
body?: unknown;
|
|
1042
|
+
requestId?: string;
|
|
1043
|
+
traceId?: string;
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
/**
|
|
1047
|
+
* Raised when the request is rejected with HTTP 403 (e.g. content filtering,
|
|
1048
|
+
* URL excluded, or service not enabled for the API key).
|
|
1049
|
+
*
|
|
1050
|
+
* The credentials are valid; the operation itself is not permitted.
|
|
1051
|
+
* Inspect `error.body.errorCode` to distinguish the exact reason.
|
|
1052
|
+
*/
|
|
1053
|
+
declare class PermissionDeniedError extends APIStatusError {
|
|
1054
|
+
constructor(statusCode: number, message: string, options?: {
|
|
1055
|
+
body?: unknown;
|
|
1056
|
+
requestId?: string;
|
|
1057
|
+
traceId?: string;
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
/**
|
|
1062
|
+
* HTTP transport implementation.
|
|
1063
|
+
*/
|
|
1064
|
+
|
|
1065
|
+
/**
|
|
1066
|
+
* HTTP transport options.
|
|
1067
|
+
*/
|
|
1068
|
+
interface HttpTransportOptions {
|
|
1069
|
+
/** Base URL for the API */
|
|
1070
|
+
baseUrl: string;
|
|
1071
|
+
/** Authentication provider */
|
|
1072
|
+
auth: AuthProvider;
|
|
1073
|
+
/** Optional telemetry hook */
|
|
1074
|
+
telemetryHook?: TelemetryHook;
|
|
1075
|
+
/** Optional retry policy */
|
|
1076
|
+
retry?: RetryPolicy;
|
|
1077
|
+
/** Request timeout in milliseconds (default: 10000) */
|
|
1078
|
+
timeout?: number;
|
|
1079
|
+
/**
|
|
1080
|
+
* Custom fetch function for advanced networking (e.g., proxy support, custom TLS).
|
|
1081
|
+
* Must be compatible with the global `fetch` signature.
|
|
1082
|
+
* If not provided, the global `fetch` is used.
|
|
1083
|
+
*/
|
|
1084
|
+
fetchFn?: FetchFunction;
|
|
1085
|
+
}
|
|
1086
|
+
/**
|
|
1087
|
+
* HTTP transport using native fetch.
|
|
1088
|
+
*/
|
|
1089
|
+
declare class HttpTransport implements Transport {
|
|
1090
|
+
private readonly baseUrl;
|
|
1091
|
+
private readonly auth;
|
|
1092
|
+
private readonly telemetry?;
|
|
1093
|
+
private readonly retry;
|
|
1094
|
+
private readonly timeout;
|
|
1095
|
+
private readonly fetchFn;
|
|
1096
|
+
private readonly activeControllers;
|
|
1097
|
+
private closed;
|
|
1098
|
+
constructor(options: HttpTransportOptions);
|
|
1099
|
+
request<T = unknown>(options: TransportRequestOptions): Promise<T>;
|
|
1100
|
+
close(): Promise<void>;
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
export { APIConnectionError, APIStatusError, ApiKeyAuth, type AuthProvider, AuthenticationError, BrowseContentFormat, type BrowseFetchOptions, type BrowseParams, BrowseResource, type BrowseResponse, ClassicResource, type ClassicSearchOptions, type ClassicSearchParams, ContentFormat, DEFAULT_SCOPE, DEFAULT_TIMEOUT, EntraIDAuth, type FetchFunction, HttpTransport, type HttpTransportOptions, ImageAspectRatio, ImageColor, type ImageItem, type ImageSearchOptions, ImageSize, ImagesResource, type ImagesResponse, type ImagesSearchParams, type NewsItem, NewsResource, type NewsResponse, type NewsSearchOptions, type NewsSearchParams, type NewsThumbnail, PermissionDeniedError, type PlaylistItem, type PlaylistVideo, type QuerySignals, RateLimitError, RetryPolicy, type RetryPolicyOptions, SafeSearch, SafeSearchMode, type SearchClassicResponse, type TelemetryEvent, type TelemetryHook, type TokenCredential, type Transport, type TransportRequestOptions, VideoDuration, type VideoItem, type VideoMoment, VideoResolution, type VideoSearchOptions, VideosResource, type VideosResponse, type VideosSearchParams, WebIQClient, type WebIQClientOptions, WebIQError, WebResource, type WebResponse, type WebResult, type WebSearchOptions, type WebSearchParams, createAuth, createClient, createTelemetryEvent, safeCall };
|