@microsoft/webiq 0.1.8 → 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/README.md +180 -62
- package/dist/index.d.mts +191 -10
- package/dist/index.d.ts +191 -10
- package/dist/index.js +395 -10
- package/dist/index.mjs +379 -11
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -89,6 +89,13 @@ 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
|
+
|
|
92
99
|
type WebQuerySignals = {
|
|
93
100
|
/**
|
|
94
101
|
* Indicates whether fresh documents should be prioritized over other documents for this query.
|
|
@@ -171,6 +178,7 @@ type WebResponse = {
|
|
|
171
178
|
* Trace ID for debugging and tracking.
|
|
172
179
|
*/
|
|
173
180
|
traceId?: string | null;
|
|
181
|
+
riskLevel?: RiskLevel;
|
|
174
182
|
};
|
|
175
183
|
|
|
176
184
|
/**
|
|
@@ -735,7 +743,7 @@ declare enum LiveCrawlMode {
|
|
|
735
743
|
|
|
736
744
|
type BrowseResponse = {
|
|
737
745
|
/**
|
|
738
|
-
* The URL of the web page.
|
|
746
|
+
* The URL of the web page, or the URL to retry when a crawl is pending.
|
|
739
747
|
*/
|
|
740
748
|
url?: string | null;
|
|
741
749
|
/**
|
|
@@ -759,13 +767,21 @@ type BrowseResponse = {
|
|
|
759
767
|
*/
|
|
760
768
|
crawledAt?: string | null;
|
|
761
769
|
/**
|
|
762
|
-
*
|
|
770
|
+
* Upstream ISO8601 UTC timestamp indicating when to retry a pending crawl. Only present on accepted (202) responses when supplied by the service.
|
|
763
771
|
*/
|
|
764
772
|
retryAfter?: string | null;
|
|
765
773
|
/**
|
|
766
774
|
* Trace ID for debugging and tracking.
|
|
767
775
|
*/
|
|
768
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;
|
|
769
785
|
};
|
|
770
786
|
|
|
771
787
|
/**
|
|
@@ -825,10 +841,11 @@ interface RetryPolicyOptions {
|
|
|
825
841
|
maxRetries?: number;
|
|
826
842
|
/** Base delay in seconds for exponential backoff (default: 0.25) */
|
|
827
843
|
baseDelaySeconds?: number;
|
|
828
|
-
/** Maximum
|
|
844
|
+
/** Maximum generated backoff in seconds (default: 4.0); server hints are not capped. */
|
|
829
845
|
maxDelaySeconds?: number;
|
|
830
846
|
/**
|
|
831
|
-
* HTTP status codes that trigger a retry.
|
|
847
|
+
* HTTP status codes that trigger a retry. Explicit 400/404 selections are
|
|
848
|
+
* honored, although excluded by default. 429 and 430 (rate-limit /
|
|
832
849
|
* concurrency-limit) are intentionally excluded: the transport throws
|
|
833
850
|
* `RateLimitError` immediately so the caller can inspect `error.retryAfter`
|
|
834
851
|
* and decide whether to back off.
|
|
@@ -883,6 +900,8 @@ interface TelemetryEvent {
|
|
|
883
900
|
retryAfter?: string;
|
|
884
901
|
/** Request duration in milliseconds */
|
|
885
902
|
elapsedMs?: number;
|
|
903
|
+
/** Size of the response body in bytes (if a response was received) */
|
|
904
|
+
responseSizeBytes?: number;
|
|
886
905
|
/** Exception (if request failed) */
|
|
887
906
|
error?: Error;
|
|
888
907
|
/** Error response body (if status >= 400) */
|
|
@@ -901,6 +920,138 @@ declare function safeCall(hook: TelemetryHook | undefined, event: TelemetryEvent
|
|
|
901
920
|
*/
|
|
902
921
|
declare function createTelemetryEvent(method: string, path: string, transport: string, attempt: number, options?: Partial<Omit<TelemetryEvent, 'method' | 'path' | 'transport' | 'attempt'>>): TelemetryEvent;
|
|
903
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
|
+
|
|
904
1055
|
/**
|
|
905
1056
|
* Web IQ SDK for the Web IQ API.
|
|
906
1057
|
*/
|
|
@@ -909,6 +1060,8 @@ declare function createTelemetryEvent(method: string, path: string, transport: s
|
|
|
909
1060
|
* Options for creating a Web IQ client.
|
|
910
1061
|
*/
|
|
911
1062
|
interface WebIQClientOptions {
|
|
1063
|
+
/** Isolated feedback sender and optional application navigation handler. */
|
|
1064
|
+
feedback?: FeedbackClientOptions;
|
|
912
1065
|
/** Your Web IQ API key (use this OR credential/auth) */
|
|
913
1066
|
apiKey?: string;
|
|
914
1067
|
/** An `azure-identity` `TokenCredential`. */
|
|
@@ -919,6 +1072,8 @@ interface WebIQClientOptions {
|
|
|
919
1072
|
auth?: AuthProvider;
|
|
920
1073
|
/** Base URL for the API (default: https://api.microsoft.ai/v3) */
|
|
921
1074
|
baseUrl?: string;
|
|
1075
|
+
/** Target application for identities mapped to multiple apps; unset/empty omits `appid`. */
|
|
1076
|
+
appId?: string | null;
|
|
922
1077
|
/** Optional callback for telemetry events */
|
|
923
1078
|
telemetryHook?: TelemetryHook;
|
|
924
1079
|
/**
|
|
@@ -977,6 +1132,7 @@ interface WebIQClientOptions {
|
|
|
977
1132
|
* ```
|
|
978
1133
|
*/
|
|
979
1134
|
declare class WebIQClient {
|
|
1135
|
+
readonly feedback: FeedbackClient;
|
|
980
1136
|
/** Web search resource */
|
|
981
1137
|
readonly web: WebResource;
|
|
982
1138
|
/** News search resource */
|
|
@@ -1030,10 +1186,15 @@ declare class APIStatusError extends WebIQError {
|
|
|
1030
1186
|
requestId?: string;
|
|
1031
1187
|
traceId?: string;
|
|
1032
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;
|
|
1033
1195
|
}
|
|
1034
1196
|
/**
|
|
1035
|
-
* Raised when the API rate limit
|
|
1036
|
-
* for /browse-specific concurrency limit).
|
|
1197
|
+
* Raised when the API rate limit (429) or Browse crawl limit (430) is exceeded.
|
|
1037
1198
|
*/
|
|
1038
1199
|
declare class RateLimitError extends APIStatusError {
|
|
1039
1200
|
constructor(statusCode: number, message: string, options?: {
|
|
@@ -1044,6 +1205,22 @@ declare class RateLimitError extends APIStatusError {
|
|
|
1044
1205
|
/** The retry-after value from the API response body, if available. */
|
|
1045
1206
|
get retryAfter(): string | undefined;
|
|
1046
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
|
+
}
|
|
1047
1224
|
/**
|
|
1048
1225
|
* Raised when authentication fails (401).
|
|
1049
1226
|
*/
|
|
@@ -1055,11 +1232,11 @@ declare class AuthenticationError extends APIStatusError {
|
|
|
1055
1232
|
});
|
|
1056
1233
|
}
|
|
1057
1234
|
/**
|
|
1058
|
-
* Raised when
|
|
1059
|
-
*
|
|
1235
|
+
* Raised when an authenticated caller cannot access an endpoint, feature, or
|
|
1236
|
+
* content (403).
|
|
1060
1237
|
*
|
|
1061
1238
|
* The credentials are valid; the operation itself is not permitted.
|
|
1062
|
-
* Inspect `error.
|
|
1239
|
+
* Inspect `error.errorCode` to distinguish the exact reason.
|
|
1063
1240
|
*/
|
|
1064
1241
|
declare class PermissionDeniedError extends APIStatusError {
|
|
1065
1242
|
constructor(statusCode: number, message: string, options?: {
|
|
@@ -1256,6 +1433,8 @@ type WebRequest = {
|
|
|
1256
1433
|
interface HttpTransportOptions {
|
|
1257
1434
|
/** Base URL for the API */
|
|
1258
1435
|
baseUrl: string;
|
|
1436
|
+
/** Optional target application; unset/empty omits the query parameter. */
|
|
1437
|
+
appId?: string | null;
|
|
1259
1438
|
/** Authentication provider */
|
|
1260
1439
|
auth: AuthProvider;
|
|
1261
1440
|
/** Optional telemetry hook */
|
|
@@ -1276,16 +1455,18 @@ interface HttpTransportOptions {
|
|
|
1276
1455
|
*/
|
|
1277
1456
|
declare class HttpTransport implements Transport {
|
|
1278
1457
|
private readonly baseUrl;
|
|
1458
|
+
private readonly appId?;
|
|
1279
1459
|
private readonly auth;
|
|
1280
1460
|
private readonly telemetry?;
|
|
1281
1461
|
private readonly retry;
|
|
1282
1462
|
private readonly timeout;
|
|
1283
1463
|
private readonly fetchFn;
|
|
1284
1464
|
private readonly activeControllers;
|
|
1465
|
+
private readonly closeController;
|
|
1285
1466
|
private closed;
|
|
1286
1467
|
constructor(options: HttpTransportOptions);
|
|
1287
1468
|
request<T = unknown>(options: TransportRequestOptions): Promise<T>;
|
|
1288
1469
|
close(): Promise<void>;
|
|
1289
1470
|
}
|
|
1290
1471
|
|
|
1291
|
-
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, 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, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -89,6 +89,13 @@ 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
|
+
|
|
92
99
|
type WebQuerySignals = {
|
|
93
100
|
/**
|
|
94
101
|
* Indicates whether fresh documents should be prioritized over other documents for this query.
|
|
@@ -171,6 +178,7 @@ type WebResponse = {
|
|
|
171
178
|
* Trace ID for debugging and tracking.
|
|
172
179
|
*/
|
|
173
180
|
traceId?: string | null;
|
|
181
|
+
riskLevel?: RiskLevel;
|
|
174
182
|
};
|
|
175
183
|
|
|
176
184
|
/**
|
|
@@ -735,7 +743,7 @@ declare enum LiveCrawlMode {
|
|
|
735
743
|
|
|
736
744
|
type BrowseResponse = {
|
|
737
745
|
/**
|
|
738
|
-
* The URL of the web page.
|
|
746
|
+
* The URL of the web page, or the URL to retry when a crawl is pending.
|
|
739
747
|
*/
|
|
740
748
|
url?: string | null;
|
|
741
749
|
/**
|
|
@@ -759,13 +767,21 @@ type BrowseResponse = {
|
|
|
759
767
|
*/
|
|
760
768
|
crawledAt?: string | null;
|
|
761
769
|
/**
|
|
762
|
-
*
|
|
770
|
+
* Upstream ISO8601 UTC timestamp indicating when to retry a pending crawl. Only present on accepted (202) responses when supplied by the service.
|
|
763
771
|
*/
|
|
764
772
|
retryAfter?: string | null;
|
|
765
773
|
/**
|
|
766
774
|
* Trace ID for debugging and tracking.
|
|
767
775
|
*/
|
|
768
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;
|
|
769
785
|
};
|
|
770
786
|
|
|
771
787
|
/**
|
|
@@ -825,10 +841,11 @@ interface RetryPolicyOptions {
|
|
|
825
841
|
maxRetries?: number;
|
|
826
842
|
/** Base delay in seconds for exponential backoff (default: 0.25) */
|
|
827
843
|
baseDelaySeconds?: number;
|
|
828
|
-
/** Maximum
|
|
844
|
+
/** Maximum generated backoff in seconds (default: 4.0); server hints are not capped. */
|
|
829
845
|
maxDelaySeconds?: number;
|
|
830
846
|
/**
|
|
831
|
-
* HTTP status codes that trigger a retry.
|
|
847
|
+
* HTTP status codes that trigger a retry. Explicit 400/404 selections are
|
|
848
|
+
* honored, although excluded by default. 429 and 430 (rate-limit /
|
|
832
849
|
* concurrency-limit) are intentionally excluded: the transport throws
|
|
833
850
|
* `RateLimitError` immediately so the caller can inspect `error.retryAfter`
|
|
834
851
|
* and decide whether to back off.
|
|
@@ -883,6 +900,8 @@ interface TelemetryEvent {
|
|
|
883
900
|
retryAfter?: string;
|
|
884
901
|
/** Request duration in milliseconds */
|
|
885
902
|
elapsedMs?: number;
|
|
903
|
+
/** Size of the response body in bytes (if a response was received) */
|
|
904
|
+
responseSizeBytes?: number;
|
|
886
905
|
/** Exception (if request failed) */
|
|
887
906
|
error?: Error;
|
|
888
907
|
/** Error response body (if status >= 400) */
|
|
@@ -901,6 +920,138 @@ declare function safeCall(hook: TelemetryHook | undefined, event: TelemetryEvent
|
|
|
901
920
|
*/
|
|
902
921
|
declare function createTelemetryEvent(method: string, path: string, transport: string, attempt: number, options?: Partial<Omit<TelemetryEvent, 'method' | 'path' | 'transport' | 'attempt'>>): TelemetryEvent;
|
|
903
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
|
+
|
|
904
1055
|
/**
|
|
905
1056
|
* Web IQ SDK for the Web IQ API.
|
|
906
1057
|
*/
|
|
@@ -909,6 +1060,8 @@ declare function createTelemetryEvent(method: string, path: string, transport: s
|
|
|
909
1060
|
* Options for creating a Web IQ client.
|
|
910
1061
|
*/
|
|
911
1062
|
interface WebIQClientOptions {
|
|
1063
|
+
/** Isolated feedback sender and optional application navigation handler. */
|
|
1064
|
+
feedback?: FeedbackClientOptions;
|
|
912
1065
|
/** Your Web IQ API key (use this OR credential/auth) */
|
|
913
1066
|
apiKey?: string;
|
|
914
1067
|
/** An `azure-identity` `TokenCredential`. */
|
|
@@ -919,6 +1072,8 @@ interface WebIQClientOptions {
|
|
|
919
1072
|
auth?: AuthProvider;
|
|
920
1073
|
/** Base URL for the API (default: https://api.microsoft.ai/v3) */
|
|
921
1074
|
baseUrl?: string;
|
|
1075
|
+
/** Target application for identities mapped to multiple apps; unset/empty omits `appid`. */
|
|
1076
|
+
appId?: string | null;
|
|
922
1077
|
/** Optional callback for telemetry events */
|
|
923
1078
|
telemetryHook?: TelemetryHook;
|
|
924
1079
|
/**
|
|
@@ -977,6 +1132,7 @@ interface WebIQClientOptions {
|
|
|
977
1132
|
* ```
|
|
978
1133
|
*/
|
|
979
1134
|
declare class WebIQClient {
|
|
1135
|
+
readonly feedback: FeedbackClient;
|
|
980
1136
|
/** Web search resource */
|
|
981
1137
|
readonly web: WebResource;
|
|
982
1138
|
/** News search resource */
|
|
@@ -1030,10 +1186,15 @@ declare class APIStatusError extends WebIQError {
|
|
|
1030
1186
|
requestId?: string;
|
|
1031
1187
|
traceId?: string;
|
|
1032
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;
|
|
1033
1195
|
}
|
|
1034
1196
|
/**
|
|
1035
|
-
* Raised when the API rate limit
|
|
1036
|
-
* for /browse-specific concurrency limit).
|
|
1197
|
+
* Raised when the API rate limit (429) or Browse crawl limit (430) is exceeded.
|
|
1037
1198
|
*/
|
|
1038
1199
|
declare class RateLimitError extends APIStatusError {
|
|
1039
1200
|
constructor(statusCode: number, message: string, options?: {
|
|
@@ -1044,6 +1205,22 @@ declare class RateLimitError extends APIStatusError {
|
|
|
1044
1205
|
/** The retry-after value from the API response body, if available. */
|
|
1045
1206
|
get retryAfter(): string | undefined;
|
|
1046
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
|
+
}
|
|
1047
1224
|
/**
|
|
1048
1225
|
* Raised when authentication fails (401).
|
|
1049
1226
|
*/
|
|
@@ -1055,11 +1232,11 @@ declare class AuthenticationError extends APIStatusError {
|
|
|
1055
1232
|
});
|
|
1056
1233
|
}
|
|
1057
1234
|
/**
|
|
1058
|
-
* Raised when
|
|
1059
|
-
*
|
|
1235
|
+
* Raised when an authenticated caller cannot access an endpoint, feature, or
|
|
1236
|
+
* content (403).
|
|
1060
1237
|
*
|
|
1061
1238
|
* The credentials are valid; the operation itself is not permitted.
|
|
1062
|
-
* Inspect `error.
|
|
1239
|
+
* Inspect `error.errorCode` to distinguish the exact reason.
|
|
1063
1240
|
*/
|
|
1064
1241
|
declare class PermissionDeniedError extends APIStatusError {
|
|
1065
1242
|
constructor(statusCode: number, message: string, options?: {
|
|
@@ -1256,6 +1433,8 @@ type WebRequest = {
|
|
|
1256
1433
|
interface HttpTransportOptions {
|
|
1257
1434
|
/** Base URL for the API */
|
|
1258
1435
|
baseUrl: string;
|
|
1436
|
+
/** Optional target application; unset/empty omits the query parameter. */
|
|
1437
|
+
appId?: string | null;
|
|
1259
1438
|
/** Authentication provider */
|
|
1260
1439
|
auth: AuthProvider;
|
|
1261
1440
|
/** Optional telemetry hook */
|
|
@@ -1276,16 +1455,18 @@ interface HttpTransportOptions {
|
|
|
1276
1455
|
*/
|
|
1277
1456
|
declare class HttpTransport implements Transport {
|
|
1278
1457
|
private readonly baseUrl;
|
|
1458
|
+
private readonly appId?;
|
|
1279
1459
|
private readonly auth;
|
|
1280
1460
|
private readonly telemetry?;
|
|
1281
1461
|
private readonly retry;
|
|
1282
1462
|
private readonly timeout;
|
|
1283
1463
|
private readonly fetchFn;
|
|
1284
1464
|
private readonly activeControllers;
|
|
1465
|
+
private readonly closeController;
|
|
1285
1466
|
private closed;
|
|
1286
1467
|
constructor(options: HttpTransportOptions);
|
|
1287
1468
|
request<T = unknown>(options: TransportRequestOptions): Promise<T>;
|
|
1288
1469
|
close(): Promise<void>;
|
|
1289
1470
|
}
|
|
1290
1471
|
|
|
1291
|
-
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, 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, 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 };
|