exa-js 2.5.1-beta.1 → 2.5.1-beta.3

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.mts CHANGED
@@ -3286,6 +3286,8 @@ interface AnswerResponse$1 {
3286
3286
  };
3287
3287
  };
3288
3288
  }
3289
+ type CompanyEntity$1 = unknown;
3290
+ type PersonEntity$1 = unknown;
3289
3291
  type WebsetStatus = "idle" | "pending" | "running" | "paused";
3290
3292
  declare const WebsetStatus: {
3291
3293
  idle: "idle";
@@ -11173,6 +11175,18 @@ declare class EventsClient extends WebsetsBaseClient {
11173
11175
  createdAfter?: string;
11174
11176
  }): Promise<ListEventsResponse>;
11175
11177
  get(id: string): Promise<Event>;
11178
+ /** Iterate through all events, handling pagination automatically. */
11179
+ listAll(options?: PaginationParams & {
11180
+ types?: Array<"webset.created" | "webset.deleted" | "webset.paused" | "webset.idle" | "webset.search.created" | "webset.search.canceled" | "webset.search.completed" | "webset.search.updated" | "import.created" | "import.completed" | "webset.item.created" | "webset.item.enriched" | "monitor.created" | "monitor.updated" | "monitor.deleted" | "monitor.run.created" | "monitor.run.completed" | "webset.export.created" | "webset.export.completed">;
11181
+ createdBefore?: string;
11182
+ createdAfter?: string;
11183
+ }): AsyncGenerator<Event>;
11184
+ /** Collect all events into an array. */
11185
+ getAll(options?: PaginationParams & {
11186
+ types?: Array<"webset.created" | "webset.deleted" | "webset.paused" | "webset.idle" | "webset.search.created" | "webset.search.canceled" | "webset.search.completed" | "webset.search.updated" | "import.created" | "import.completed" | "webset.item.created" | "webset.item.enriched" | "monitor.created" | "monitor.updated" | "monitor.deleted" | "monitor.run.created" | "monitor.run.completed" | "webset.export.created" | "webset.export.completed">;
11187
+ createdBefore?: string;
11188
+ createdAfter?: string;
11189
+ }): Promise<Event[]>;
11176
11190
  }
11177
11191
  /** Client for managing Monitor Runs. */
11178
11192
  declare class WebsetMonitorRunsClient extends WebsetsBaseClient {
@@ -11210,6 +11224,20 @@ declare class WebsetWebhooksClient extends WebsetsBaseClient {
11210
11224
  eventType?: string;
11211
11225
  successful?: boolean;
11212
11226
  }): Promise<ListWebhookAttemptsResponse>;
11227
+ /** Iterate through all webhooks, handling pagination automatically. */
11228
+ listAll(options?: PaginationParams): AsyncGenerator<Webhook>;
11229
+ /** Collect all webhooks into an array. */
11230
+ getAll(options?: PaginationParams): Promise<Webhook[]>;
11231
+ /** Iterate through all webhook attempts, handling pagination automatically. */
11232
+ listAllAttempts(id: string, options?: PaginationParams & {
11233
+ eventType?: string;
11234
+ successful?: boolean;
11235
+ }): AsyncGenerator<ListWebhookAttemptsResponse["data"][number]>;
11236
+ /** Collect all webhook attempts into an array. */
11237
+ getAllAttempts(id: string, options?: PaginationParams & {
11238
+ eventType?: string;
11239
+ successful?: boolean;
11240
+ }): Promise<ListWebhookAttemptsResponse["data"]>;
11213
11241
  }
11214
11242
  /** Client for managing Imports. */
11215
11243
  declare class ImportsClient extends WebsetsBaseClient {
@@ -11218,6 +11246,16 @@ declare class ImportsClient extends WebsetsBaseClient {
11218
11246
  get(id: string): Promise<Import>;
11219
11247
  update(id: string, params: UpdateImport): Promise<Import>;
11220
11248
  delete(id: string): Promise<Import>;
11249
+ /** Wait for an import to reach a terminal status. */
11250
+ waitUntilCompleted(id: string, options?: {
11251
+ timeout?: number;
11252
+ pollInterval?: number;
11253
+ onPoll?: (status: Import["status"]) => void;
11254
+ }): Promise<Import>;
11255
+ /** Iterate through all imports, handling pagination automatically. */
11256
+ listAll(options?: PaginationParams): AsyncGenerator<Import>;
11257
+ /** Collect all imports into an array. */
11258
+ getAll(options?: PaginationParams): Promise<Import[]>;
11221
11259
  }
11222
11260
  /** Main client for managing Websets, with sub-clients for each resource. */
11223
11261
  declare class WebsetsClient extends WebsetsBaseClient {
@@ -11282,9 +11320,15 @@ declare class ResearchClient extends ResearchBaseClient {
11282
11320
  outputSchema?: Record<string, unknown> | ZodSchema<any>;
11283
11321
  }): Promise<ResearchDtoClass>;
11284
11322
  /** Get a research request by ID. */
11285
- get(researchId: string, options?: {
11323
+ get(researchId: string): Promise<ResearchDtoClass>;
11324
+ get(researchId: string, options: {
11325
+ stream?: false;
11286
11326
  events?: boolean;
11287
11327
  }): Promise<ResearchDtoClass>;
11328
+ get(researchId: string, options: {
11329
+ stream: true;
11330
+ events?: boolean;
11331
+ }): Promise<AsyncGenerator<Record<string, unknown>>>;
11288
11332
  /** Poll a research request until it reaches a terminal state (completed, failed, or canceled). */
11289
11333
  pollUntilFinished(researchId: string, options?: {
11290
11334
  pollInterval?: number;
@@ -11323,6 +11367,22 @@ type CompanySearchOptions = Omit<SearchCommonOptions, "category" | "type" | "exc
11323
11367
  category: "company";
11324
11368
  type?: "neural" | "auto" | "fast" | "hybrid" | null;
11325
11369
  };
11370
+ type TweetSearchResult = SearchResult$1;
11371
+ type TweetSearchResponse = Omit<SearchResponse$1, "results"> & {
11372
+ results: TweetSearchResult[];
11373
+ };
11374
+ type PeopleSearchResult = SearchResult$1 & {
11375
+ entities?: PersonEntity$1[];
11376
+ };
11377
+ type PeopleSearchResponse = Omit<SearchResponse$1, "results"> & {
11378
+ results: PeopleSearchResult[];
11379
+ };
11380
+ type CompanySearchResult = SearchResult$1 & {
11381
+ entities?: CompanyEntity$1[];
11382
+ };
11383
+ type CompanySearchResponse = Omit<SearchResponse$1, "results"> & {
11384
+ results: CompanySearchResult[];
11385
+ };
11326
11386
  type SearchOptions = BaseSearchOptions$1 | DeepSearchOptions$1 | TweetSearchOptions | PeopleSearchOptions | CompanySearchOptions;
11327
11387
  type FindSimilarOptions$1 = Omit<FindSimilarRequest, "url">;
11328
11388
  type GetContentsOptions = Omit<ContentsRequest, "urls">;
@@ -11332,6 +11392,19 @@ type AnswerStreamChunk$1 = {
11332
11392
  content?: string;
11333
11393
  citations?: AnswerStreamCitation[];
11334
11394
  };
11395
+ type AnswerOptionsTyped$1<T> = Omit<AnswerOptions$1, "outputSchema"> & {
11396
+ outputSchema: T;
11397
+ };
11398
+ type AnswerResponseTyped$1<T> = Omit<AnswerResponse$1, "answer"> & {
11399
+ answer: T;
11400
+ };
11401
+ declare class ExaError extends Error {
11402
+ statusCode: number;
11403
+ timestamp?: string;
11404
+ path?: string;
11405
+ details?: unknown;
11406
+ constructor(message: string, statusCode: number, timestamp?: string, path?: string, details?: unknown);
11407
+ }
11335
11408
  /**
11336
11409
  * Exa API client. Each method corresponds to an Exa API endpoint
11337
11410
  * with positional args extracted and the remaining fields as options.
@@ -11356,14 +11429,25 @@ declare class Exa$1 {
11356
11429
  private parseAnswerStreamLine;
11357
11430
  /** Separate content-specific options from search/filter options. */
11358
11431
  private extractContentsOptions;
11432
+ search(query: string, options: PeopleSearchOptions & {
11433
+ contents?: Record<string, unknown> | false | null;
11434
+ }): Promise<PeopleSearchResponse>;
11435
+ search(query: string, options: CompanySearchOptions & {
11436
+ contents?: Record<string, unknown> | false | null;
11437
+ }): Promise<CompanySearchResponse>;
11438
+ search(query: string, options: TweetSearchOptions & {
11439
+ contents?: Record<string, unknown> | false | null;
11440
+ }): Promise<TweetSearchResponse>;
11359
11441
  search(query: string, options?: SearchOptions & {
11360
11442
  contents?: Record<string, unknown> | false | null;
11361
11443
  }): Promise<SearchResponse$1>;
11362
11444
  findSimilar(url: string, options?: FindSimilarOptions$1 & {
11363
11445
  contents?: Record<string, unknown> | false | null;
11364
11446
  }): Promise<FindSimilarResponse>;
11365
- getContents(urls?: string | string[], options?: GetContentsOptions): Promise<ContentsResponse>;
11447
+ getContents(urls: string | string[] | SearchResult$1[], options?: GetContentsOptions): Promise<ContentsResponse>;
11448
+ answer<T>(query: string, options: AnswerOptionsTyped$1<ZodSchema<T>>): Promise<AnswerResponseTyped$1<T>>;
11366
11449
  answer(query: string, options?: AnswerOptions$1): Promise<AnswerResponse$1>;
11450
+ streamAnswer<T>(query: string, options: Omit<AnswerOptionsTyped$1<ZodSchema<T>>, "stream">): AsyncGenerator<AnswerStreamChunk$1>;
11367
11451
  streamAnswer(query: string, options?: Omit<AnswerOptions$1, "stream">): AsyncGenerator<AnswerStreamChunk$1>;
11368
11452
  /**
11369
11453
  * @deprecated Use `search()` instead. The search method now returns text contents by default.
@@ -11390,31 +11474,6 @@ declare enum HttpStatusCode {
11390
11474
  InternalServerError = 500,
11391
11475
  ServiceUnavailable = 503
11392
11476
  }
11393
- /**
11394
- * Base error class for all Exa API errors
11395
- */
11396
- declare class ExaError extends Error {
11397
- /**
11398
- * HTTP status code
11399
- */
11400
- statusCode: number;
11401
- /**
11402
- * ISO timestamp from API
11403
- */
11404
- timestamp?: string;
11405
- /**
11406
- * Path that caused the error (may be undefined for client-side errors)
11407
- */
11408
- path?: string;
11409
- /**
11410
- * Create a new ExaError
11411
- * @param message Error message
11412
- * @param statusCode HTTP status code
11413
- * @param timestamp ISO timestamp from API
11414
- * @param path Path that caused the error
11415
- */
11416
- constructor(message: string, statusCode: number, timestamp?: string, path?: string);
11417
- }
11418
11477
 
11419
11478
  /**
11420
11479
  * Options for retrieving page contents
package/dist/index.d.ts CHANGED
@@ -3286,6 +3286,8 @@ interface AnswerResponse$1 {
3286
3286
  };
3287
3287
  };
3288
3288
  }
3289
+ type CompanyEntity$1 = unknown;
3290
+ type PersonEntity$1 = unknown;
3289
3291
  type WebsetStatus = "idle" | "pending" | "running" | "paused";
3290
3292
  declare const WebsetStatus: {
3291
3293
  idle: "idle";
@@ -11173,6 +11175,18 @@ declare class EventsClient extends WebsetsBaseClient {
11173
11175
  createdAfter?: string;
11174
11176
  }): Promise<ListEventsResponse>;
11175
11177
  get(id: string): Promise<Event>;
11178
+ /** Iterate through all events, handling pagination automatically. */
11179
+ listAll(options?: PaginationParams & {
11180
+ types?: Array<"webset.created" | "webset.deleted" | "webset.paused" | "webset.idle" | "webset.search.created" | "webset.search.canceled" | "webset.search.completed" | "webset.search.updated" | "import.created" | "import.completed" | "webset.item.created" | "webset.item.enriched" | "monitor.created" | "monitor.updated" | "monitor.deleted" | "monitor.run.created" | "monitor.run.completed" | "webset.export.created" | "webset.export.completed">;
11181
+ createdBefore?: string;
11182
+ createdAfter?: string;
11183
+ }): AsyncGenerator<Event>;
11184
+ /** Collect all events into an array. */
11185
+ getAll(options?: PaginationParams & {
11186
+ types?: Array<"webset.created" | "webset.deleted" | "webset.paused" | "webset.idle" | "webset.search.created" | "webset.search.canceled" | "webset.search.completed" | "webset.search.updated" | "import.created" | "import.completed" | "webset.item.created" | "webset.item.enriched" | "monitor.created" | "monitor.updated" | "monitor.deleted" | "monitor.run.created" | "monitor.run.completed" | "webset.export.created" | "webset.export.completed">;
11187
+ createdBefore?: string;
11188
+ createdAfter?: string;
11189
+ }): Promise<Event[]>;
11176
11190
  }
11177
11191
  /** Client for managing Monitor Runs. */
11178
11192
  declare class WebsetMonitorRunsClient extends WebsetsBaseClient {
@@ -11210,6 +11224,20 @@ declare class WebsetWebhooksClient extends WebsetsBaseClient {
11210
11224
  eventType?: string;
11211
11225
  successful?: boolean;
11212
11226
  }): Promise<ListWebhookAttemptsResponse>;
11227
+ /** Iterate through all webhooks, handling pagination automatically. */
11228
+ listAll(options?: PaginationParams): AsyncGenerator<Webhook>;
11229
+ /** Collect all webhooks into an array. */
11230
+ getAll(options?: PaginationParams): Promise<Webhook[]>;
11231
+ /** Iterate through all webhook attempts, handling pagination automatically. */
11232
+ listAllAttempts(id: string, options?: PaginationParams & {
11233
+ eventType?: string;
11234
+ successful?: boolean;
11235
+ }): AsyncGenerator<ListWebhookAttemptsResponse["data"][number]>;
11236
+ /** Collect all webhook attempts into an array. */
11237
+ getAllAttempts(id: string, options?: PaginationParams & {
11238
+ eventType?: string;
11239
+ successful?: boolean;
11240
+ }): Promise<ListWebhookAttemptsResponse["data"]>;
11213
11241
  }
11214
11242
  /** Client for managing Imports. */
11215
11243
  declare class ImportsClient extends WebsetsBaseClient {
@@ -11218,6 +11246,16 @@ declare class ImportsClient extends WebsetsBaseClient {
11218
11246
  get(id: string): Promise<Import>;
11219
11247
  update(id: string, params: UpdateImport): Promise<Import>;
11220
11248
  delete(id: string): Promise<Import>;
11249
+ /** Wait for an import to reach a terminal status. */
11250
+ waitUntilCompleted(id: string, options?: {
11251
+ timeout?: number;
11252
+ pollInterval?: number;
11253
+ onPoll?: (status: Import["status"]) => void;
11254
+ }): Promise<Import>;
11255
+ /** Iterate through all imports, handling pagination automatically. */
11256
+ listAll(options?: PaginationParams): AsyncGenerator<Import>;
11257
+ /** Collect all imports into an array. */
11258
+ getAll(options?: PaginationParams): Promise<Import[]>;
11221
11259
  }
11222
11260
  /** Main client for managing Websets, with sub-clients for each resource. */
11223
11261
  declare class WebsetsClient extends WebsetsBaseClient {
@@ -11282,9 +11320,15 @@ declare class ResearchClient extends ResearchBaseClient {
11282
11320
  outputSchema?: Record<string, unknown> | ZodSchema<any>;
11283
11321
  }): Promise<ResearchDtoClass>;
11284
11322
  /** Get a research request by ID. */
11285
- get(researchId: string, options?: {
11323
+ get(researchId: string): Promise<ResearchDtoClass>;
11324
+ get(researchId: string, options: {
11325
+ stream?: false;
11286
11326
  events?: boolean;
11287
11327
  }): Promise<ResearchDtoClass>;
11328
+ get(researchId: string, options: {
11329
+ stream: true;
11330
+ events?: boolean;
11331
+ }): Promise<AsyncGenerator<Record<string, unknown>>>;
11288
11332
  /** Poll a research request until it reaches a terminal state (completed, failed, or canceled). */
11289
11333
  pollUntilFinished(researchId: string, options?: {
11290
11334
  pollInterval?: number;
@@ -11323,6 +11367,22 @@ type CompanySearchOptions = Omit<SearchCommonOptions, "category" | "type" | "exc
11323
11367
  category: "company";
11324
11368
  type?: "neural" | "auto" | "fast" | "hybrid" | null;
11325
11369
  };
11370
+ type TweetSearchResult = SearchResult$1;
11371
+ type TweetSearchResponse = Omit<SearchResponse$1, "results"> & {
11372
+ results: TweetSearchResult[];
11373
+ };
11374
+ type PeopleSearchResult = SearchResult$1 & {
11375
+ entities?: PersonEntity$1[];
11376
+ };
11377
+ type PeopleSearchResponse = Omit<SearchResponse$1, "results"> & {
11378
+ results: PeopleSearchResult[];
11379
+ };
11380
+ type CompanySearchResult = SearchResult$1 & {
11381
+ entities?: CompanyEntity$1[];
11382
+ };
11383
+ type CompanySearchResponse = Omit<SearchResponse$1, "results"> & {
11384
+ results: CompanySearchResult[];
11385
+ };
11326
11386
  type SearchOptions = BaseSearchOptions$1 | DeepSearchOptions$1 | TweetSearchOptions | PeopleSearchOptions | CompanySearchOptions;
11327
11387
  type FindSimilarOptions$1 = Omit<FindSimilarRequest, "url">;
11328
11388
  type GetContentsOptions = Omit<ContentsRequest, "urls">;
@@ -11332,6 +11392,19 @@ type AnswerStreamChunk$1 = {
11332
11392
  content?: string;
11333
11393
  citations?: AnswerStreamCitation[];
11334
11394
  };
11395
+ type AnswerOptionsTyped$1<T> = Omit<AnswerOptions$1, "outputSchema"> & {
11396
+ outputSchema: T;
11397
+ };
11398
+ type AnswerResponseTyped$1<T> = Omit<AnswerResponse$1, "answer"> & {
11399
+ answer: T;
11400
+ };
11401
+ declare class ExaError extends Error {
11402
+ statusCode: number;
11403
+ timestamp?: string;
11404
+ path?: string;
11405
+ details?: unknown;
11406
+ constructor(message: string, statusCode: number, timestamp?: string, path?: string, details?: unknown);
11407
+ }
11335
11408
  /**
11336
11409
  * Exa API client. Each method corresponds to an Exa API endpoint
11337
11410
  * with positional args extracted and the remaining fields as options.
@@ -11356,14 +11429,25 @@ declare class Exa$1 {
11356
11429
  private parseAnswerStreamLine;
11357
11430
  /** Separate content-specific options from search/filter options. */
11358
11431
  private extractContentsOptions;
11432
+ search(query: string, options: PeopleSearchOptions & {
11433
+ contents?: Record<string, unknown> | false | null;
11434
+ }): Promise<PeopleSearchResponse>;
11435
+ search(query: string, options: CompanySearchOptions & {
11436
+ contents?: Record<string, unknown> | false | null;
11437
+ }): Promise<CompanySearchResponse>;
11438
+ search(query: string, options: TweetSearchOptions & {
11439
+ contents?: Record<string, unknown> | false | null;
11440
+ }): Promise<TweetSearchResponse>;
11359
11441
  search(query: string, options?: SearchOptions & {
11360
11442
  contents?: Record<string, unknown> | false | null;
11361
11443
  }): Promise<SearchResponse$1>;
11362
11444
  findSimilar(url: string, options?: FindSimilarOptions$1 & {
11363
11445
  contents?: Record<string, unknown> | false | null;
11364
11446
  }): Promise<FindSimilarResponse>;
11365
- getContents(urls?: string | string[], options?: GetContentsOptions): Promise<ContentsResponse>;
11447
+ getContents(urls: string | string[] | SearchResult$1[], options?: GetContentsOptions): Promise<ContentsResponse>;
11448
+ answer<T>(query: string, options: AnswerOptionsTyped$1<ZodSchema<T>>): Promise<AnswerResponseTyped$1<T>>;
11366
11449
  answer(query: string, options?: AnswerOptions$1): Promise<AnswerResponse$1>;
11450
+ streamAnswer<T>(query: string, options: Omit<AnswerOptionsTyped$1<ZodSchema<T>>, "stream">): AsyncGenerator<AnswerStreamChunk$1>;
11367
11451
  streamAnswer(query: string, options?: Omit<AnswerOptions$1, "stream">): AsyncGenerator<AnswerStreamChunk$1>;
11368
11452
  /**
11369
11453
  * @deprecated Use `search()` instead. The search method now returns text contents by default.
@@ -11390,31 +11474,6 @@ declare enum HttpStatusCode {
11390
11474
  InternalServerError = 500,
11391
11475
  ServiceUnavailable = 503
11392
11476
  }
11393
- /**
11394
- * Base error class for all Exa API errors
11395
- */
11396
- declare class ExaError extends Error {
11397
- /**
11398
- * HTTP status code
11399
- */
11400
- statusCode: number;
11401
- /**
11402
- * ISO timestamp from API
11403
- */
11404
- timestamp?: string;
11405
- /**
11406
- * Path that caused the error (may be undefined for client-side errors)
11407
- */
11408
- path?: string;
11409
- /**
11410
- * Create a new ExaError
11411
- * @param message Error message
11412
- * @param statusCode HTTP status code
11413
- * @param timestamp ISO timestamp from API
11414
- * @param path Path that caused the error
11415
- */
11416
- constructor(message: string, statusCode: number, timestamp?: string, path?: string);
11417
- }
11418
11477
 
11419
11478
  /**
11420
11479
  * Options for retrieving page contents