sentisense 0.28.0 → 0.30.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 CHANGED
@@ -36,13 +36,8 @@ const flows = await client.institutional.getFlows();
36
36
 
37
37
  ## Response shapes
38
38
 
39
- Most methods resolve to the payload directly, but two families wrap it.
40
-
41
- > **Known issue: some declared return types describe the inner payload rather than the
42
- > wrapper.** For the methods listed below, the runtime value is the wrapper, so reading the
43
- > declared shape gives you `undefined` even though it compiles. Cast to the wrapper type
44
- > (each is exported) until the declarations are corrected in a future release. The runtime
45
- > behavior is stable and is what is documented here.
39
+ Most methods resolve to the payload directly, but two families wrap it. The return types
40
+ describe the wrapper, so `.data` / `.documents` type-check natively, no cast.
46
41
 
47
42
  **1. Tier-gated endpoints return a preview envelope.** The payload is in `data`, and
48
43
  `isPreview` tells you whether it was truncated for your tier. On a truncated response
@@ -52,11 +47,7 @@ Affected: `institutional.getFlows` / `getHolders` / `getActivists`, and all five
52
47
  `insights` methods.
53
48
 
54
49
  ```typescript
55
- import type { InstitutionalFlows, PreviewResponse, TickerHolders } from "sentisense";
56
-
57
- const flows = (await client.institutional.getFlows()) as unknown as
58
- PreviewResponse<InstitutionalFlows>;
59
-
50
+ const flows = await client.institutional.getFlows();
60
51
  if (flows.isPreview) {
61
52
  console.log(`Preview: ${flows.data.inflows.length} of ${flows.totalCount}`);
62
53
  }
@@ -65,10 +56,15 @@ for (const flow of flows.data.inflows) {
65
56
  }
66
57
 
67
58
  // holders nest one level deeper: ticker-level totals plus the rows
68
- const holders = (await client.institutional.getHolders("AAPL", "2026-06-30")) as unknown as
69
- PreviewResponse<TickerHolders>;
59
+ const holders = await client.institutional.getHolders("AAPL", "2026-06-30");
70
60
  console.log(`${holders.data.holderCount} holders`);
71
61
  const newPositions = holders.data.holders.filter((h) => h.changeType === "NEW");
62
+
63
+ // insights use the same envelope, wrapping a plain array
64
+ const insights = await client.insights.stock("AAPL");
65
+ for (const insight of insights.data) {
66
+ console.log(insight.insightText);
67
+ }
72
68
  ```
73
69
 
74
70
  **2. Document endpoints return a search wrapper.** This is not the preview envelope:
@@ -78,11 +74,7 @@ Affected: `documents.getByTicker` / `getByTickerRange` / `getByEntity` / `search
78
74
  `getBySource`. Also `stocks.getFundamentalsPeriods`, whose periods are in `periods`.
79
75
 
80
76
  ```typescript
81
- import type { DocumentSearchResponse } from "sentisense";
82
-
83
- const results = (await client.documents.search("NVDA earnings", { days: 7 })) as unknown as
84
- DocumentSearchResponse;
85
-
77
+ const results = await client.documents.search("NVDA earnings", { days: 7 });
86
78
  console.log(`${results.totalCount} matches`);
87
79
  for (const doc of results.documents) {
88
80
  console.log(doc.url, doc.averageSentiment);
@@ -91,7 +83,12 @@ for (const doc of results.documents) {
91
83
 
92
84
  Everything else, including `stocks.getPrice()`, `documents.getStories()`,
93
85
  `insights.types()` and `institutional.getQuarters()`, resolves to the value itself with no
94
- wrapper and needs no cast.
86
+ wrapper.
87
+
88
+ > **Upgrading from 0.28.x or earlier?** These return types were corrected in 0.29.0. If your
89
+ > code read the flat shape (`flows.inflows`, `holders.filter(...)`), it was returning
90
+ > `undefined` / throwing at runtime already; switch to `flows.data.inflows` /
91
+ > `holders.data.holders`. See [CHANGELOG.md](./CHANGELOG.md) for the full mapping.
95
92
 
96
93
  ## API Reference
97
94
 
@@ -151,7 +148,6 @@ Available metric types: `mentions`, `sentiment`, `sentisense`, `social_dominance
151
148
 
152
149
  ```typescript
153
150
  client.kb.getPopularEntities()
154
- client.kb.getEntity("entity-id")
155
151
  client.kb.getAllEntities()
156
152
  ```
157
153
 
package/dist/index.cjs CHANGED
@@ -131,29 +131,29 @@ var Documents = class {
131
131
  constructor(client) {
132
132
  this.client = client;
133
133
  }
134
- /** Get document metrics for a stock. */
134
+ /** Get document metrics for a stock. The rows are in `documents`. */
135
135
  async getByTicker(ticker, options) {
136
136
  return this.client.get(`/api/v1/documents/ticker/${encodeURIComponent(ticker)}`, options);
137
137
  }
138
- /** Get document metrics for a stock within a date range. */
138
+ /** Get document metrics for a stock within a date range. The rows are in `documents`. */
139
139
  async getByTickerRange(ticker, options) {
140
140
  return this.client.get(
141
141
  `/api/v1/documents/ticker/${encodeURIComponent(ticker)}/range`,
142
142
  options
143
143
  );
144
144
  }
145
- /** Get document metrics for a KB entity. */
145
+ /** Get document metrics for a KB entity. The rows are in `documents`. */
146
146
  async getByEntity(entityId, options) {
147
147
  return this.client.get(
148
148
  `/api/v1/documents/entity/${encodeURIComponent(entityId)}`,
149
149
  options
150
150
  );
151
151
  }
152
- /** Smart search with natural language query parsing. */
152
+ /** Smart search with natural language query parsing. The rows are in `documents`. */
153
153
  async search(query, options) {
154
154
  return this.client.get("/api/v1/documents/search", { query, ...options });
155
155
  }
156
- /** Get latest document metrics from a source type. */
156
+ /** Get latest document metrics from a source type. The rows are in `documents`. */
157
157
  async getBySource(source, options) {
158
158
  return this.client.get(
159
159
  `/api/v1/documents/source/${encodeURIComponent(source)}`,
@@ -182,7 +182,6 @@ var EntityMetrics = class {
182
182
  constructor(client) {
183
183
  this.client = client;
184
184
  }
185
- // ── v2 API methods ──────────────────────────────────────────
186
185
  /**
187
186
  * Get time-series metric data for an entity using the v2 Serving Metrics API.
188
187
  *
@@ -214,61 +213,6 @@ var EntityMetrics = class {
214
213
  { dimension }
215
214
  );
216
215
  }
217
- // ── Deprecated v1 methods (kept for backward compatibility) ─
218
- /**
219
- * @deprecated Use `getMetrics(symbol, { metricType: "mentions" })` instead.
220
- */
221
- async getMentions(symbol, options) {
222
- return this.client.get(
223
- `/api/v1/entity-metrics/stocks/${encodeURIComponent(symbol)}/mentions`,
224
- options
225
- );
226
- }
227
- /**
228
- * @deprecated Use `getDistribution(symbol, "mentions", { dimension: "source" })` instead.
229
- */
230
- async getMentionCountBySource(symbol, options) {
231
- return this.client.get(
232
- `/api/v1/entity-metrics/stocks/${encodeURIComponent(symbol)}/mentions/count/by-source`,
233
- options
234
- );
235
- }
236
- /**
237
- * @deprecated Use `getMetrics(symbol, { metricType: "mentions" })` instead.
238
- */
239
- async getMentionCount(symbol, options) {
240
- return this.client.get(
241
- `/api/v1/entity-metrics/stocks/${encodeURIComponent(symbol)}/mentions/count`,
242
- options
243
- );
244
- }
245
- /**
246
- * @deprecated Use `getMetrics(symbol, { metricType: "sentiment" })` instead.
247
- */
248
- async getSentiment(symbol, options) {
249
- return this.client.get(
250
- `/api/v1/entity-metrics/stocks/${encodeURIComponent(symbol)}/sentiment`,
251
- options
252
- );
253
- }
254
- /**
255
- * @deprecated Use `getDistribution(symbol, "sentiment", { dimension: "source" })` instead.
256
- */
257
- async getSentimentBySource(symbol, options) {
258
- return this.client.get(
259
- `/api/v1/entity-metrics/stocks/${encodeURIComponent(symbol)}/sentiment/by-source`,
260
- options
261
- );
262
- }
263
- /**
264
- * @deprecated Use `getMetrics(symbol, { metricType: "sentiment" })` instead.
265
- */
266
- async getAverageSentiment(symbol, options) {
267
- return this.client.get(
268
- `/api/v1/entity-metrics/stocks/${encodeURIComponent(symbol)}/sentiment/average`,
269
- options
270
- );
271
- }
272
216
  };
273
217
 
274
218
  // src/resources/etfs.ts
@@ -412,10 +356,9 @@ var Insights = class {
412
356
  /**
413
357
  * Get AI-generated insights for a specific stock, sorted by urgency then confidence.
414
358
  *
415
- * PRO users receive a flat array of Insight objects.
416
- * Free/unauthenticated users receive a preview with `isPreview: true`,
417
- * the top 3 insights in full, and a `locked` array with metadata-only entries
418
- * (type, urgency, timestamp) showing what additional signals exist.
359
+ * Returns the preview envelope: read the insights as `.data`. PRO callers get the
360
+ * full list with `isPreview: false`; free callers get the top 3 with `isPreview: true`
361
+ * and `totalCount` carrying the untruncated size.
419
362
  */
420
363
  async stock(ticker, options) {
421
364
  return this.client.get(
@@ -426,8 +369,9 @@ var Insights = class {
426
369
  /**
427
370
  * Get AI insights for a stock within a date range.
428
371
  *
429
- * Free users receive the top 3; PRO users receive the full list.
430
- * The server returns 400 if `startDate` is after `endDate`.
372
+ * Returns the preview envelope: read the insights as `.data`. Free callers receive
373
+ * the top 3, PRO callers the full list. The server returns 400 if `startDate` is
374
+ * after `endDate`.
431
375
  */
432
376
  async stockRange(ticker, options) {
433
377
  return this.client.get(
@@ -438,9 +382,9 @@ var Insights = class {
438
382
  /**
439
383
  * Get AI-generated market-level insights, sorted by urgency then confidence.
440
384
  *
441
- * PRO users receive a flat array of Insight objects.
442
- * Free/unauthenticated users receive a preview with `isPreview: true`,
443
- * the top 5 insights in full, and a `locked` array with metadata-only entries.
385
+ * Returns the preview envelope: read the insights as `.data`. PRO callers get the
386
+ * full list with `isPreview: false`; free callers get the top 5 with `isPreview: true`
387
+ * and `totalCount` carrying the untruncated size.
444
388
  */
445
389
  async market() {
446
390
  return this.client.get("/api/v1/insights/market");
@@ -448,7 +392,8 @@ var Insights = class {
448
392
  /**
449
393
  * Get the latest AI insights across all tracked stocks, newest first.
450
394
  *
451
- * Free users receive the top 5; PRO users receive up to `limit` (clamped to 1-200).
395
+ * Returns the preview envelope: read the insights as `.data`. Free callers receive
396
+ * the top 5, PRO callers up to `limit` (clamped to 1-200).
452
397
  */
453
398
  async latest(options) {
454
399
  return this.client.get("/api/v1/insights/latest", options);
@@ -458,6 +403,7 @@ var Insights = class {
458
403
  *
459
404
  * Biased toward the user's watchlist and portfolio when available; falls back
460
405
  * to market-level insights otherwise. API key authentication required.
406
+ * Returns the preview envelope: read the insights as `.data`.
461
407
  */
462
408
  async user(options) {
463
409
  return this.client.get("/api/v1/insights/user", options);
@@ -490,6 +436,9 @@ var Institutional = class {
490
436
  * `reportDate` is optional: omit it to get the latest available quarter, which may be
491
437
  * a still-open one holding only early filers. The response then carries `reportDate`
492
438
  * plus `isPending` and filer coverage counts so a partial quarter is clearly labeled.
439
+ *
440
+ * Returns the preview envelope, so the flows are one level down:
441
+ * `const { data } = await client.institutional.getFlows(); data.inflows`.
493
442
  */
494
443
  async getFlows(reportDate, options) {
495
444
  return this.client.get("/api/v1/institutional/flows", {
@@ -497,14 +446,25 @@ var Institutional = class {
497
446
  ...options
498
447
  });
499
448
  }
500
- /** Get institutional holders for a specific stock. */
449
+ /**
450
+ * Get institutional holders for a specific stock.
451
+ *
452
+ * Returns the preview envelope wrapping a {@link TickerHolders} object, so the rows
453
+ * are two levels down: `(await getHolders(t, d)).data.holders`, alongside ticker-level
454
+ * totals like `holderCount`. Free callers get a truncated `holders` array with
455
+ * `isPreview: true`.
456
+ */
501
457
  async getHolders(ticker, reportDate) {
502
458
  return this.client.get(
503
459
  `/api/v1/institutional/holders/${encodeURIComponent(ticker)}`,
504
460
  { reportDate }
505
461
  );
506
462
  }
507
- /** Get activist investor positions (NEW or INCREASED). */
463
+ /**
464
+ * Get activist investor positions (NEW or INCREASED).
465
+ *
466
+ * Returns the preview envelope, so read the rows as `.data`.
467
+ */
508
468
  async getActivists(reportDate) {
509
469
  return this.client.get("/api/v1/institutional/activist", { reportDate });
510
470
  }
@@ -550,10 +510,6 @@ var KB = class {
550
510
  async getPopularEntities() {
551
511
  return this.client.get("/api/v1/kb/entities/popular");
552
512
  }
553
- /** Get entity detail with metrics and relationships. */
554
- async getEntity(entityId) {
555
- return this.client.get(`/api/v1/kb/entities/${encodeURIComponent(entityId)}`);
556
- }
557
513
  /** Get all tracked entities. */
558
514
  async getAllEntities() {
559
515
  return this.client.get("/api/v1/kb/entities/all");
@@ -682,11 +638,14 @@ var Stocks = class {
682
638
  async getFundamentals(ticker, options) {
683
639
  return this.client.get("/api/v1/stocks/fundamentals", { ticker, ...options });
684
640
  }
685
- /** Get available fiscal periods. */
641
+ /** Get available fiscal periods. The periods are in `periods`. */
686
642
  async getFundamentalsPeriods(ticker) {
687
643
  return this.client.get("/api/v1/stocks/fundamentals/periods", { ticker });
688
644
  }
689
- /** Get most recent fundamentals snapshot. */
645
+ /**
646
+ * Get the trailing-twelve-month fundamentals snapshot: TTM ratios, a different
647
+ * shape from the per-period statement data `getFundamentals()` returns.
648
+ */
690
649
  async getCurrentFundamentals(ticker) {
691
650
  return this.client.get("/api/v1/stocks/fundamentals/current", { ticker });
692
651
  }
@@ -777,7 +736,7 @@ var Trackers = class {
777
736
  };
778
737
 
779
738
  // src/version.ts
780
- var VERSION = "0.28.0";
739
+ var VERSION = "0.30.0";
781
740
 
782
741
  // src/client.ts
783
742
  var DEFAULT_BASE_URL = "https://app.sentisense.ai";