@telemai/sdk 0.3.1 → 0.3.2

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.cjs CHANGED
@@ -60,7 +60,7 @@ var TimeoutError = class extends TelemError {
60
60
  };
61
61
 
62
62
  // src/version.ts
63
- var VERSION = "0.3.1";
63
+ var VERSION = "0.3.2";
64
64
 
65
65
  // src/config.ts
66
66
  var DEFAULT_BASE_URL = "https://router.telem.ai";
@@ -588,6 +588,7 @@ function searchBlock(defaults, options) {
588
588
  if (topic !== void 0) block.topic = topic;
589
589
  if (options.publishedAfter !== void 0) block.published_after = isoDate(options.publishedAfter);
590
590
  if (options.publishedBefore !== void 0) block.published_before = isoDate(options.publishedBefore);
591
+ if (options.includeDomains !== void 0) block.include_domains = options.includeDomains;
591
592
  return block;
592
593
  }
593
594
  function isoDate(value) {
@@ -720,8 +721,14 @@ function createMonitors(config) {
720
721
  };
721
722
  return {
722
723
  /** Create a monitor. Telem runs `query` on the schedule. */
723
- async create(query, options) {
724
- const body = { query, options: { frequency: options.frequency } };
724
+ async create(query, options = {}) {
725
+ const monitorOptions = {};
726
+ if (options.frequency !== void 0) monitorOptions.frequency = options.frequency;
727
+ if (options.includeDomains !== void 0) {
728
+ monitorOptions.include_domains = options.includeDomains;
729
+ }
730
+ if (options.search !== void 0) monitorOptions.search = searchBlock({}, options.search);
731
+ const body = { query, options: monitorOptions };
725
732
  if (options.metadata !== void 0) body.metadata = options.metadata;
726
733
  if (options.webhookUrl !== void 0) body.webhook_url = options.webhookUrl;
727
734
  if (options.ttl !== void 0) body.ttl = options.ttl;
@@ -747,7 +754,7 @@ function createMonitors(config) {
747
754
  const route = path(monitorId);
748
755
  return monitorFrom(await request(config, "PATCH", route, body, options.signal));
749
756
  },
750
- /** Get the results that are new since the last poll, one entry per provider. */
757
+ /** Get the results that are new since the last poll. */
751
758
  async poll(monitorId, options = {}) {
752
759
  const body = {};
753
760
  if (options.session !== void 0) body.session_id = options.session;
package/dist/index.d.cts CHANGED
@@ -72,6 +72,9 @@ type SearchOptions = {
72
72
  * includes that whole day. A `Date` is an exact instant; pass a "YYYY-MM-DD"
73
73
  * string to include the whole day. */
74
74
  publishedBefore?: string | Date;
75
+ /** Only results from these domains: at most 20 hostnames such as `"linkedin.com"`.
76
+ * A subdomain such as `"uk.linkedin.com"` matches its domain. Per-call only. */
77
+ includeDomains?: string[];
75
78
  /** Opt this request into the server's rerank stage. It is the only path where
76
79
  * `context`, the reasoning on the last assistant entry of the lineage history
77
80
  * (that entry only), and `goal` change result ORDER (in that precedence) —
@@ -222,10 +225,18 @@ type SessionsResource = {
222
225
  list(): Promise<SessionSummary[]>;
223
226
  results(sessionId: string): Promise<SessionResults>;
224
227
  };
228
+ /** The search options a monitor can run on its schedule (`MonitorCreateOptions.search`). */
229
+ type MonitorSearchOptions = Pick<SearchOptions, "tier" | "numResults">;
225
230
  /** Options for `monitors.create`. */
226
231
  type MonitorCreateOptions = {
227
- /** `"1h"`, `"6h"`, `"1d"` or `"7d"`. */
228
- frequency: string;
232
+ /** `"1h"`, `"6h"`, `"12h"`, `"1d"` or `"7d"`. If you leave it out, the monitor runs once a day. */
233
+ frequency?: string;
234
+ /** Also run a web search for the query on the schedule, with these options. `{}`
235
+ * uses the defaults. Client search defaults do not apply. */
236
+ search?: MonitorSearchOptions;
237
+ /** Only results from these sites and their subdomains, such as `["sec.gov"]`,
238
+ * from every source of the monitor. */
239
+ includeDomains?: string[];
229
240
  /** Request metadata (query lineage keys), sent as given. */
230
241
  metadata?: Json;
231
242
  /** An `https` URL that receives the new results. */
@@ -270,7 +281,7 @@ type Monitor = {
270
281
  };
271
282
  /** The `telem.monitors` namespace. */
272
283
  type MonitorsResource = {
273
- create(query: string, options: MonitorCreateOptions): Promise<Monitor>;
284
+ create(query: string, options?: MonitorCreateOptions): Promise<Monitor>;
274
285
  list(options?: {
275
286
  limit?: number;
276
287
  signal?: AbortSignal;
package/dist/index.d.ts CHANGED
@@ -72,6 +72,9 @@ type SearchOptions = {
72
72
  * includes that whole day. A `Date` is an exact instant; pass a "YYYY-MM-DD"
73
73
  * string to include the whole day. */
74
74
  publishedBefore?: string | Date;
75
+ /** Only results from these domains: at most 20 hostnames such as `"linkedin.com"`.
76
+ * A subdomain such as `"uk.linkedin.com"` matches its domain. Per-call only. */
77
+ includeDomains?: string[];
75
78
  /** Opt this request into the server's rerank stage. It is the only path where
76
79
  * `context`, the reasoning on the last assistant entry of the lineage history
77
80
  * (that entry only), and `goal` change result ORDER (in that precedence) —
@@ -222,10 +225,18 @@ type SessionsResource = {
222
225
  list(): Promise<SessionSummary[]>;
223
226
  results(sessionId: string): Promise<SessionResults>;
224
227
  };
228
+ /** The search options a monitor can run on its schedule (`MonitorCreateOptions.search`). */
229
+ type MonitorSearchOptions = Pick<SearchOptions, "tier" | "numResults">;
225
230
  /** Options for `monitors.create`. */
226
231
  type MonitorCreateOptions = {
227
- /** `"1h"`, `"6h"`, `"1d"` or `"7d"`. */
228
- frequency: string;
232
+ /** `"1h"`, `"6h"`, `"12h"`, `"1d"` or `"7d"`. If you leave it out, the monitor runs once a day. */
233
+ frequency?: string;
234
+ /** Also run a web search for the query on the schedule, with these options. `{}`
235
+ * uses the defaults. Client search defaults do not apply. */
236
+ search?: MonitorSearchOptions;
237
+ /** Only results from these sites and their subdomains, such as `["sec.gov"]`,
238
+ * from every source of the monitor. */
239
+ includeDomains?: string[];
229
240
  /** Request metadata (query lineage keys), sent as given. */
230
241
  metadata?: Json;
231
242
  /** An `https` URL that receives the new results. */
@@ -270,7 +281,7 @@ type Monitor = {
270
281
  };
271
282
  /** The `telem.monitors` namespace. */
272
283
  type MonitorsResource = {
273
- create(query: string, options: MonitorCreateOptions): Promise<Monitor>;
284
+ create(query: string, options?: MonitorCreateOptions): Promise<Monitor>;
274
285
  list(options?: {
275
286
  limit?: number;
276
287
  signal?: AbortSignal;
package/dist/index.js CHANGED
@@ -22,7 +22,7 @@ import {
22
22
  } from "./chunk-DKTEG7EY.js";
23
23
 
24
24
  // src/version.ts
25
- var VERSION = "0.3.1";
25
+ var VERSION = "0.3.2";
26
26
 
27
27
  // src/config.ts
28
28
  var DEFAULT_BASE_URL = "https://router.telem.ai";
@@ -221,6 +221,7 @@ function searchBlock(defaults, options) {
221
221
  if (topic !== void 0) block.topic = topic;
222
222
  if (options.publishedAfter !== void 0) block.published_after = isoDate(options.publishedAfter);
223
223
  if (options.publishedBefore !== void 0) block.published_before = isoDate(options.publishedBefore);
224
+ if (options.includeDomains !== void 0) block.include_domains = options.includeDomains;
224
225
  return block;
225
226
  }
226
227
  function isoDate(value) {
@@ -353,8 +354,14 @@ function createMonitors(config) {
353
354
  };
354
355
  return {
355
356
  /** Create a monitor. Telem runs `query` on the schedule. */
356
- async create(query, options) {
357
- const body = { query, options: { frequency: options.frequency } };
357
+ async create(query, options = {}) {
358
+ const monitorOptions = {};
359
+ if (options.frequency !== void 0) monitorOptions.frequency = options.frequency;
360
+ if (options.includeDomains !== void 0) {
361
+ monitorOptions.include_domains = options.includeDomains;
362
+ }
363
+ if (options.search !== void 0) monitorOptions.search = searchBlock({}, options.search);
364
+ const body = { query, options: monitorOptions };
358
365
  if (options.metadata !== void 0) body.metadata = options.metadata;
359
366
  if (options.webhookUrl !== void 0) body.webhook_url = options.webhookUrl;
360
367
  if (options.ttl !== void 0) body.ttl = options.ttl;
@@ -380,7 +387,7 @@ function createMonitors(config) {
380
387
  const route = path(monitorId);
381
388
  return monitorFrom(await request(config, "PATCH", route, body, options.signal));
382
389
  },
383
- /** Get the results that are new since the last poll, one entry per provider. */
390
+ /** Get the results that are new since the last poll. */
384
391
  async poll(monitorId, options = {}) {
385
392
  const body = {};
386
393
  if (options.session !== void 0) body.session_id = options.session;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telemai/sdk",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Telem web search and fetch for JavaScript and TypeScript.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",