@microsoft/webiq 0.1.7 → 1.0.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/dist/index.d.ts CHANGED
@@ -89,21 +89,45 @@ declare enum SafeSearch {
89
89
  STRICT = "strict"
90
90
  }
91
91
 
92
+ declare enum RiskLevel {
93
+ LOW = "low",
94
+ MODERATE = "moderate",
95
+ HIGH = "high",
96
+ VERY_HIGH = "veryHigh"
97
+ }
98
+
99
+ type WebQuerySignals = {
100
+ /**
101
+ * Indicates whether fresh documents should be prioritized over other documents for this query.
102
+ */
103
+ freshness?: boolean | null;
104
+ };
105
+
92
106
  declare enum ContentTier {
93
107
  STANDARD = "standard",
94
108
  ENTITLED = "entitled",
95
109
  PREMIUM = "premium"
96
110
  }
97
111
 
112
+ declare enum SourceQuality {
113
+ INSUFFICIENT = "insufficient",
114
+ ADEQUATE = "adequate",
115
+ PREFERRED = "preferred"
116
+ }
117
+
98
118
  type WebResult = {
99
119
  /**
100
120
  * The title of the webpage.
101
121
  */
102
122
  title?: string | null;
103
123
  /**
104
- * The source URL of the webpage.
124
+ * The source URL of the webpage. For China users with URL redirection enabled, this field instead contains the same redirect URL as clickUrl.
105
125
  */
106
126
  url?: string | null;
127
+ /**
128
+ * The destination host for the result. Returned only for China users with URL redirection enabled.
129
+ */
130
+ domain?: string | null;
107
131
  /**
108
132
  * The detailed content of the webpage.
109
133
  */
@@ -125,6 +149,7 @@ type WebResult = {
125
149
  */
126
150
  isAdult?: boolean;
127
151
  contentTier?: ContentTier;
152
+ sourceQuality?: SourceQuality;
128
153
  /**
129
154
  * Redirect URL that proxies through Bing. Only present when redirect is enabled.
130
155
  */
@@ -140,6 +165,7 @@ type WebResponse = {
140
165
  * List of web page results.
141
166
  */
142
167
  webResults?: Array<WebResult> | null;
168
+ querySignals?: WebQuerySignals;
143
169
  /**
144
170
  * Base URL for click ping requests. Append an instrumentationSuffix value from a result item to form the full ping URL.
145
171
  */
@@ -152,6 +178,7 @@ type WebResponse = {
152
178
  * Trace ID for debugging and tracking.
153
179
  */
154
180
  traceId?: string | null;
181
+ riskLevel?: RiskLevel;
155
182
  };
156
183
 
157
184
  /**
@@ -228,9 +255,13 @@ type NewsItem = {
228
255
  */
229
256
  title?: string | null;
230
257
  /**
231
- * The source URL of the news.
258
+ * The source URL of the news article. For China users with URL redirection enabled, this field instead contains the same redirect URL as clickUrl.
232
259
  */
233
260
  url?: string | null;
261
+ /**
262
+ * The destination host for the result. Returned only for China users with URL redirection enabled.
263
+ */
264
+ domain?: string | null;
234
265
  /**
235
266
  * The detailed content of the news.
236
267
  */
@@ -244,6 +275,10 @@ type NewsItem = {
244
275
  * The last crawled date of the news, follows ISO8601 format.
245
276
  */
246
277
  crawledAt?: string | null;
278
+ /**
279
+ * The language of the news article, uses ISO 639-1 language code.
280
+ */
281
+ language?: string | null;
247
282
  /**
248
283
  * Publisher name, such as 'USA TODAY | MSN', 'CNN', etc.
249
284
  */
@@ -398,9 +433,13 @@ type VideoItem = {
398
433
  */
399
434
  title?: string | null;
400
435
  /**
401
- * The video source URL.
436
+ * The source URL of the video. For China users with URL redirection enabled, this field instead contains the same redirect URL as clickUrl.
402
437
  */
403
438
  url?: string | null;
439
+ /**
440
+ * The destination host for the result. Returned only for China users with URL redirection enabled.
441
+ */
442
+ domain?: string | null;
404
443
  /**
405
444
  * Description of the video content. This is either given by video uploader or generated by LLM
406
445
  */
@@ -569,9 +608,13 @@ type ImageItem = {
569
608
  */
570
609
  title?: string | null;
571
610
  /**
572
- * The source URL of the image.
611
+ * The source URL of the image. For China users with URL redirection enabled, this field instead contains the same redirect URL as clickUrl.
573
612
  */
574
613
  url?: string | null;
614
+ /**
615
+ * The destination host for the result. Returned only for China users with URL redirection enabled.
616
+ */
617
+ domain?: string | null;
575
618
  /**
576
619
  * The host page URL of the image.
577
620
  */
@@ -700,7 +743,7 @@ declare enum LiveCrawlMode {
700
743
 
701
744
  type BrowseResponse = {
702
745
  /**
703
- * The URL of the web page.
746
+ * The URL of the web page, or the URL to retry when a crawl is pending.
704
747
  */
705
748
  url?: string | null;
706
749
  /**
@@ -724,13 +767,21 @@ type BrowseResponse = {
724
767
  */
725
768
  crawledAt?: string | null;
726
769
  /**
727
- * Retry after value when on-demand crawl is in progress. Only present when the page needs to be crawled.
770
+ * Upstream ISO8601 UTC timestamp indicating when to retry a pending crawl. Only present on accepted (202) responses when supplied by the service.
728
771
  */
729
772
  retryAfter?: string | null;
730
773
  /**
731
774
  * Trace ID for debugging and tracking.
732
775
  */
733
776
  traceId?: string | null;
777
+ /**
778
+ * Only present as false when an auto or force live-crawl response returns a stale page. Omitted otherwise.
779
+ */
780
+ liveCrawlSucceeded?: boolean | null;
781
+ /**
782
+ * Reason partial content was returned, such as encumbrance. Omitted when not supplied by the service; partial content remains a successful (200) response.
783
+ */
784
+ truncationReason?: string | null;
734
785
  };
735
786
 
736
787
  /**
@@ -790,10 +841,11 @@ interface RetryPolicyOptions {
790
841
  maxRetries?: number;
791
842
  /** Base delay in seconds for exponential backoff (default: 0.25) */
792
843
  baseDelaySeconds?: number;
793
- /** Maximum delay in seconds (default: 4.0) */
844
+ /** Maximum generated backoff in seconds (default: 4.0); server hints are not capped. */
794
845
  maxDelaySeconds?: number;
795
846
  /**
796
- * HTTP status codes that trigger a retry. 429 and 430 (rate-limit /
847
+ * HTTP status codes that trigger a retry. Explicit 400/404 selections are
848
+ * honored, although excluded by default. 429 and 430 (rate-limit /
797
849
  * concurrency-limit) are intentionally excluded: the transport throws
798
850
  * `RateLimitError` immediately so the caller can inspect `error.retryAfter`
799
851
  * and decide whether to back off.
@@ -848,6 +900,8 @@ interface TelemetryEvent {
848
900
  retryAfter?: string;
849
901
  /** Request duration in milliseconds */
850
902
  elapsedMs?: number;
903
+ /** Size of the response body in bytes (if a response was received) */
904
+ responseSizeBytes?: number;
851
905
  /** Exception (if request failed) */
852
906
  error?: Error;
853
907
  /** Error response body (if status >= 400) */
@@ -866,6 +920,138 @@ declare function safeCall(hook: TelemetryHook | undefined, event: TelemetryEvent
866
920
  */
867
921
  declare function createTelemetryEvent(method: string, path: string, transport: string, attempt: number, options?: Partial<Omit<TelemetryEvent, 'method' | 'path' | 'transport' | 'attempt'>>): TelemetryEvent;
868
922
 
923
+ interface FeedbackResponse {
924
+ instrumentationClickBase?: string | null;
925
+ instrumentationCitationBase?: string | null;
926
+ }
927
+ interface FeedbackResult {
928
+ url?: string | null;
929
+ clickUrl?: string | null;
930
+ instrumentationSuffix?: string | null;
931
+ }
932
+ type ClickKind = 'redirect' | 'ping' | 'untracked';
933
+ interface PreparedClick {
934
+ kind: ClickKind;
935
+ navigationUrl: string;
936
+ pingUrl: string | null;
937
+ }
938
+ type FeedbackErrorCode = 'missing_navigation_url' | 'missing_citation_base' | 'empty_citation_results' | 'missing_instrumentation_suffix' | 'malformed_instrumentation_suffix' | 'invalid_feedback_input' | 'feedback_connection' | 'feedback_timeout' | 'feedback_cancelled' | 'feedback_http' | 'feedback_navigation';
939
+ declare class FeedbackError extends Error {
940
+ readonly code: FeedbackErrorCode;
941
+ readonly statusCode?: number | undefined;
942
+ constructor(code: FeedbackErrorCode, message: string, statusCode?: number | undefined);
943
+ }
944
+ declare class InvalidFeedbackInputError extends FeedbackError {
945
+ constructor(message?: string, code?: FeedbackErrorCode);
946
+ }
947
+ declare class MissingInstrumentationError extends FeedbackError {
948
+ constructor();
949
+ }
950
+ declare class InvalidInstrumentationSuffixError extends FeedbackError {
951
+ constructor(code?: FeedbackErrorCode);
952
+ }
953
+ declare class FeedbackConnectionError extends FeedbackError {
954
+ constructor();
955
+ }
956
+ declare class FeedbackTimeoutError extends FeedbackError {
957
+ constructor();
958
+ }
959
+ declare class FeedbackCancelledError extends FeedbackError {
960
+ constructor();
961
+ }
962
+ declare class FeedbackHttpError extends FeedbackError {
963
+ constructor(statusCode: number);
964
+ }
965
+ declare class FeedbackNavigationError extends FeedbackError {
966
+ constructor();
967
+ }
968
+ declare function buildClickPingUrl(response: FeedbackResponse, result: FeedbackResult): string | null;
969
+ declare function prepareClick(response: FeedbackResponse, result: FeedbackResult): PreparedClick;
970
+ declare function buildCitationPingUrl(response: FeedbackResponse, results: readonly FeedbackResult[]): string;
971
+
972
+ type InstrumentationContext = FeedbackResponse;
973
+ type InstrumentedResult = FeedbackResult;
974
+ interface FeedbackHttpResponse {
975
+ status: number;
976
+ }
977
+ interface FeedbackSender {
978
+ send(url: string, options?: {
979
+ signal?: AbortSignal;
980
+ timeout?: number;
981
+ }): Promise<FeedbackHttpResponse>;
982
+ }
983
+ interface NavigationHandler {
984
+ navigate(url: string): void | Promise<void>;
985
+ }
986
+ interface FeedbackClientOptions {
987
+ sender?: FeedbackSender;
988
+ navigationHandler?: NavigationHandler;
989
+ }
990
+ interface CitationFeedbackEvent {
991
+ results: readonly InstrumentedResult[];
992
+ }
993
+ interface ClickFeedbackEvent {
994
+ result: InstrumentedResult;
995
+ }
996
+ interface CommonPushEventsOptions {
997
+ response: InstrumentationContext;
998
+ navigation?: 'auto' | 'manual';
999
+ navigationPolicy?: 'always' | 'on-feedback-success';
1000
+ failureMode?: 'collect' | 'throw';
1001
+ signal?: AbortSignal;
1002
+ /**
1003
+ * Feedback timeout in milliseconds, greater than 0 and at most 2_147_483_647.
1004
+ * Independent of Search configuration.
1005
+ */
1006
+ timeout?: number;
1007
+ }
1008
+ interface CitationPushEventsOptions extends CommonPushEventsOptions {
1009
+ type: 'citation';
1010
+ events: readonly [CitationFeedbackEvent, ...CitationFeedbackEvent[]];
1011
+ }
1012
+ interface ClickPushEventsOptions extends CommonPushEventsOptions {
1013
+ type: 'click';
1014
+ events: readonly [ClickFeedbackEvent];
1015
+ }
1016
+ type PushEventsOptions = CitationPushEventsOptions | ClickPushEventsOptions;
1017
+ type ClickFeedbackStatus = 'submitted' | 'dispatched' | 'pending-navigation' | 'not-instrumented' | 'failed';
1018
+ type ClickNavigationStatus = 'navigated' | 'required' | 'blocked' | 'failed';
1019
+ type FeedbackOutcome = {
1020
+ type: 'citation';
1021
+ feedbackStatus: 'submitted' | 'failed';
1022
+ navigationStatus: 'not-applicable';
1023
+ resultCount: number;
1024
+ feedbackError?: FeedbackError;
1025
+ } | {
1026
+ type: 'click';
1027
+ clickMode: ClickKind;
1028
+ feedbackStatus: ClickFeedbackStatus;
1029
+ navigationStatus: ClickNavigationStatus;
1030
+ navigationUrl: string;
1031
+ feedbackError?: FeedbackError;
1032
+ navigationError?: FeedbackError;
1033
+ };
1034
+ interface PushEventsResult {
1035
+ outcomes: readonly FeedbackOutcome[];
1036
+ submittedEventCount: number;
1037
+ dispatchedEventCount: number;
1038
+ requestCount: number;
1039
+ navigated: boolean;
1040
+ }
1041
+ /** Uses only global fetch, never the authenticated Search transport or its custom fetch. */
1042
+ declare class DefaultFeedbackSender implements FeedbackSender {
1043
+ send(url: string, options?: {
1044
+ signal?: AbortSignal;
1045
+ }): Promise<FeedbackHttpResponse>;
1046
+ }
1047
+ declare class FeedbackClient {
1048
+ private readonly sender;
1049
+ private readonly navigator?;
1050
+ constructor(options?: FeedbackClientOptions);
1051
+ pushEvents(options: PushEventsOptions): Promise<PushEventsResult>;
1052
+ private send;
1053
+ }
1054
+
869
1055
  /**
870
1056
  * Web IQ SDK for the Web IQ API.
871
1057
  */
@@ -874,6 +1060,8 @@ declare function createTelemetryEvent(method: string, path: string, transport: s
874
1060
  * Options for creating a Web IQ client.
875
1061
  */
876
1062
  interface WebIQClientOptions {
1063
+ /** Isolated feedback sender and optional application navigation handler. */
1064
+ feedback?: FeedbackClientOptions;
877
1065
  /** Your Web IQ API key (use this OR credential/auth) */
878
1066
  apiKey?: string;
879
1067
  /** An `azure-identity` `TokenCredential`. */
@@ -884,6 +1072,8 @@ interface WebIQClientOptions {
884
1072
  auth?: AuthProvider;
885
1073
  /** Base URL for the API (default: https://api.microsoft.ai/v3) */
886
1074
  baseUrl?: string;
1075
+ /** Target application for identities mapped to multiple apps; unset/empty omits `appid`. */
1076
+ appId?: string | null;
887
1077
  /** Optional callback for telemetry events */
888
1078
  telemetryHook?: TelemetryHook;
889
1079
  /**
@@ -942,6 +1132,7 @@ interface WebIQClientOptions {
942
1132
  * ```
943
1133
  */
944
1134
  declare class WebIQClient {
1135
+ readonly feedback: FeedbackClient;
945
1136
  /** Web search resource */
946
1137
  readonly web: WebResource;
947
1138
  /** News search resource */
@@ -995,10 +1186,15 @@ declare class APIStatusError extends WebIQError {
995
1186
  requestId?: string;
996
1187
  traceId?: string;
997
1188
  });
1189
+ private stringField;
1190
+ get errorCode(): string | undefined;
1191
+ get errorCategory(): string | undefined;
1192
+ get userMessage(): string | undefined;
1193
+ get technicalDetails(): string | undefined;
1194
+ get retryAfter(): string | undefined;
998
1195
  }
999
1196
  /**
1000
- * Raised when the API rate limit is exceeded (429 standard rate-limit, or 430
1001
- * for /browse-specific concurrency limit).
1197
+ * Raised when the API rate limit (429) or Browse crawl limit (430) is exceeded.
1002
1198
  */
1003
1199
  declare class RateLimitError extends APIStatusError {
1004
1200
  constructor(statusCode: number, message: string, options?: {
@@ -1009,6 +1205,22 @@ declare class RateLimitError extends APIStatusError {
1009
1205
  /** The retry-after value from the API response body, if available. */
1010
1206
  get retryAfter(): string | undefined;
1011
1207
  }
1208
+ /** Raised when the API rejects an invalid request (400). */
1209
+ declare class BadRequestError extends APIStatusError {
1210
+ constructor(statusCode: number, message: string, options?: {
1211
+ body?: unknown;
1212
+ requestId?: string;
1213
+ traceId?: string;
1214
+ });
1215
+ }
1216
+ /** Raised when the requested resource or Browse document is not found (404). */
1217
+ declare class NotFoundError extends APIStatusError {
1218
+ constructor(statusCode: number, message: string, options?: {
1219
+ body?: unknown;
1220
+ requestId?: string;
1221
+ traceId?: string;
1222
+ });
1223
+ }
1012
1224
  /**
1013
1225
  * Raised when authentication fails (401).
1014
1226
  */
@@ -1020,11 +1232,11 @@ declare class AuthenticationError extends APIStatusError {
1020
1232
  });
1021
1233
  }
1022
1234
  /**
1023
- * Raised when the request is rejected with HTTP 403 (e.g. content filtering,
1024
- * URL excluded, or service not enabled for the API key).
1235
+ * Raised when an authenticated caller cannot access an endpoint, feature, or
1236
+ * content (403).
1025
1237
  *
1026
1238
  * The credentials are valid; the operation itself is not permitted.
1027
- * Inspect `error.body.errorCode` to distinguish the exact reason.
1239
+ * Inspect `error.errorCode` to distinguish the exact reason.
1028
1240
  */
1029
1241
  declare class PermissionDeniedError extends APIStatusError {
1030
1242
  constructor(statusCode: number, message: string, options?: {
@@ -1221,6 +1433,8 @@ type WebRequest = {
1221
1433
  interface HttpTransportOptions {
1222
1434
  /** Base URL for the API */
1223
1435
  baseUrl: string;
1436
+ /** Optional target application; unset/empty omits the query parameter. */
1437
+ appId?: string | null;
1224
1438
  /** Authentication provider */
1225
1439
  auth: AuthProvider;
1226
1440
  /** Optional telemetry hook */
@@ -1241,16 +1455,18 @@ interface HttpTransportOptions {
1241
1455
  */
1242
1456
  declare class HttpTransport implements Transport {
1243
1457
  private readonly baseUrl;
1458
+ private readonly appId?;
1244
1459
  private readonly auth;
1245
1460
  private readonly telemetry?;
1246
1461
  private readonly retry;
1247
1462
  private readonly timeout;
1248
1463
  private readonly fetchFn;
1249
1464
  private readonly activeControllers;
1465
+ private readonly closeController;
1250
1466
  private closed;
1251
1467
  constructor(options: HttpTransportOptions);
1252
1468
  request<T = unknown>(options: TransportRequestOptions): Promise<T>;
1253
1469
  close(): Promise<void>;
1254
1470
  }
1255
1471
 
1256
- export { APIConnectionError, APIStatusError, type ApiErrorResponse, ApiKeyAuth, type AuthProvider, AuthenticationError, BrowseContentFormat, type BrowseFetchOptions, type BrowseParams, type BrowseRequest, BrowseResource, type BrowseResponse, ContentFormat, ContentTier, DEFAULT_SCOPE, DEFAULT_TIMEOUT, EntraIDAuth, type FetchFunction, HttpTransport, type HttpTransportOptions, ImageAspectRatio, ImageColor, type ImageItem, type ImageSearchOptions, ImageSize, type ImagesRequest, ImagesResource, type ImagesResponse, type ImagesSearchParams, LiveCrawlMode, type NewsItem, type NewsRequest, NewsResource, type NewsResponse, type NewsSearchOptions, type NewsSearchParams, type NewsThumbnail, PermissionDeniedError, type PlaylistItem, type PlaylistVideo, RateLimitError, RetryPolicy, type RetryPolicyOptions, SafeSearch, type TelemetryEvent, type TelemetryHook, type TokenCredential, type Transport, type TransportRequestOptions, VideoDuration, type VideoItem, type VideoMoment, VideoResolution, type VideoSearchOptions, type VideosRequest, VideosResource, type VideosResponse, type VideosSearchParams, WebIQClient, type WebIQClientOptions, WebIQError, type WebRequest, WebResource, type WebResponse, type WebResult, type WebSearchOptions, type WebSearchParams, createAuth, createClient, createTelemetryEvent, safeCall };
1472
+ export { APIConnectionError, APIStatusError, type ApiErrorResponse, ApiKeyAuth, type AuthProvider, AuthenticationError, BadRequestError, BrowseContentFormat, type BrowseFetchOptions, type BrowseParams, type BrowseRequest, BrowseResource, type BrowseResponse, type CitationFeedbackEvent, type CitationPushEventsOptions, type ClickFeedbackEvent, type ClickFeedbackStatus, type ClickKind, type ClickNavigationStatus, type ClickPushEventsOptions, type CommonPushEventsOptions, ContentFormat, ContentTier, DEFAULT_SCOPE, DEFAULT_TIMEOUT, DefaultFeedbackSender, EntraIDAuth, FeedbackCancelledError, FeedbackClient, type FeedbackClientOptions, FeedbackConnectionError, FeedbackError, type FeedbackErrorCode, FeedbackHttpError, type FeedbackHttpResponse, FeedbackNavigationError, type FeedbackOutcome, type FeedbackResponse, type FeedbackResult, type FeedbackSender, FeedbackTimeoutError, type FetchFunction, HttpTransport, type HttpTransportOptions, ImageAspectRatio, ImageColor, type ImageItem, type ImageSearchOptions, ImageSize, type ImagesRequest, ImagesResource, type ImagesResponse, type ImagesSearchParams, type InstrumentationContext, type InstrumentedResult, InvalidFeedbackInputError, InvalidInstrumentationSuffixError, LiveCrawlMode, MissingInstrumentationError, type NavigationHandler, type NewsItem, type NewsRequest, NewsResource, type NewsResponse, type NewsSearchOptions, type NewsSearchParams, type NewsThumbnail, NotFoundError, PermissionDeniedError, type PlaylistItem, type PlaylistVideo, type PreparedClick, type PushEventsOptions, type PushEventsResult, RateLimitError, RetryPolicy, type RetryPolicyOptions, RiskLevel, SafeSearch, SourceQuality, type TelemetryEvent, type TelemetryHook, type TokenCredential, type Transport, type TransportRequestOptions, VideoDuration, type VideoItem, type VideoMoment, VideoResolution, type VideoSearchOptions, type VideosRequest, VideosResource, type VideosResponse, type VideosSearchParams, WebIQClient, type WebIQClientOptions, WebIQError, type WebQuerySignals, type WebRequest, WebResource, type WebResponse, type WebResult, type WebSearchOptions, type WebSearchParams, buildCitationPingUrl, buildClickPingUrl, createAuth, createClient, createTelemetryEvent, prepareClick, safeCall };