@refactorlabs/recount 0.11.0 → 0.11.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.
@@ -1,4 +1,4 @@
1
- import { getActiveTrace, getNextSpanName } from '../chunk-XKR3GXTH.js';
1
+ import { getActiveTrace, getNextSpanName } from '../chunk-GLYQDK5L.js';
2
2
 
3
3
  // src/integrations/anthropic.ts
4
4
  function wrapAnthropic(client, options = {}) {
@@ -1,4 +1,4 @@
1
- import { getNextSpanName, getActiveTrace } from '../chunk-XKR3GXTH.js';
1
+ import { getNextSpanName, getActiveTrace } from '../chunk-GLYQDK5L.js';
2
2
 
3
3
  // src/integrations/mongodb.ts
4
4
  function wrapCollection(collection, options = {}) {
@@ -1,4 +1,4 @@
1
- import { getActiveTrace, getNextSpanName } from '../chunk-XKR3GXTH.js';
1
+ import { getActiveTrace, getNextSpanName } from '../chunk-GLYQDK5L.js';
2
2
 
3
3
  // src/integrations/openai.ts
4
4
  function wrapOpenAI(client, options = {}) {
package/llms.md CHANGED
@@ -64,7 +64,9 @@ Spans with no `input` and no `output` are silently dropped at ingest. Groups wit
64
64
  | ------------------------------------------------------ | ---------------------------- |
65
65
  | `json`, `table`, `chart`, `http`, `llm`, `image`, `db` | No `input` and no `output` |
66
66
  | `group` | All child spans were dropped |
67
- | `message` | Never dropped |
67
+ | `message` | Only by the limits below |
68
+
69
+ Any span except a group is also dropped past the first 500 in a trace (ingest refuses more), or when it can't be sent as JSON, such as a cycle in its input. A BigInt is sent as its digits. Dropping one span never loses the rest of the trace.
68
70
 
69
71
  Enable `debug: true` in `recount.init()` to log dropped spans to stdout.
70
72
 
@@ -259,7 +261,8 @@ const estimate = calculation('estimate', {
259
261
 
260
262
  recount.addCalculation('#1 Plan A', estimate, { public: true }); // one table span
261
263
  // trace.calculation(name, calcs, opts) and g.calculation(...) inside addGroup work the same.
262
- // Pass an array for several calculations in one span (up to 20); opts.side: 'input' for the input side.
264
+ // Pass an array (or any iterable) for several calculations in one span (up to 20); opts.side: 'input' for the input side.
265
+ // g.calculation() sends a calculation as it is when attached: lines added to the builder afterwards aren't sent.
263
266
 
264
267
  // Workings as steps: step(key, label, formula, value?, opts?)
265
268
  const usage = calculation('usage', { layout: 'steps', currency: 'AUD' })
@@ -272,9 +275,9 @@ const usage = calculation('usage', { layout: 'steps', currency: 'AUD' })
272
275
  - If the engine rounds, say so in the formula: `round(..., 2)`. Display rounding is Recount's.
273
276
  - Leave `value` out when the engine has no figure of its own; Recount works it out (`computed`).
274
277
  - Other helpers: `working(key, label, formula)` (muted, not summed), `subtotal`/`info(key, label, formula | null, opts)`, `line({...})` for any raw line.
275
- - Line options: `value`, `unit`, `places`, `primary`, `tags`, `taxFree`, `highlight`, `detail`, `explain`, `source`, `sourceSpan`, `expected` (`{ value, source, tolerance, level, reason }`), `tolerance`, `alerts`, `redact`.
278
+ - Line options: `value`, `unit`, `places`, `primary`, `tags`, `taxFree`, `highlight`, `detail`, `explain`, `source`, `sourceSpan`, `expected` (`{ value, source, tolerance, level, reason }`), `tolerance`, `alerts`, `redact` (hides the value and its `expected` value, and every band of `tiers()`; quantity and rate are still sent, so redact the inputs they come from too).
276
279
  - Key `undefined` makes one from the label. The builder never throws: bad keys, units and formulas are repaired or reported in `c.problems` (and debug logs), so check `expect(c.problems).toEqual([])` in a unit test.
277
- - `NaN` is sent as `null` (not calculated); `Infinity` too, so send text like `'Unlimited'`. Decimal strings (`'0.0316'`) and decimal.js / big.js values keep their precision.
280
+ - `NaN` is sent as `null` (not calculated); `Infinity` too, so send text like `'Unlimited'`. A number is sent without float noise past 15 significant digits (`2.95 * 1.1` is sent as `3.245`, not `3.2450000000000006`); whole numbers are sent as they are. Decimal strings (`'0.0316'`) and decimal.js / big.js values keep their precision.
278
281
  - Checks always run; alerts only when the calculation opts in with `alerts: 'warn' | 'error'`.
279
282
 
280
283
  ```ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@refactorlabs/recount",
3
- "version": "0.11.0",
3
+ "version": "0.11.2",
4
4
  "description": "Node.js SDK for Recount",
5
5
  "homepage": "https://recount.refactor.gg",
6
6
  "license": "MIT",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/context.ts"],"names":[],"mappings":";;;;;;;;;;AAKA,IAAM,IAAA,mBAAO,MAAA,CAAO,GAAA,CAAI,+BAA+B,CAAA;AACvD,IAAM,QAAA,mBAAW,MAAA,CAAO,GAAA,CAAI,gCAAgC,CAAA;AAC5D,IAAM,EAAA,GAAK,UAAA;AACX,IAAI,CAAC,GAAG,IAAI,CAAA,KAAM,IAAI,CAAA,GAAI,IAAI,iBAAA,EAAyB;AACvD,IAAI,CAAC,GAAG,QAAQ,CAAA,KAAM,QAAQ,CAAA,GAAI,IAAI,iBAAA,EAA0B;AAChE,IAAM,OAAA,GAAU,GAAG,IAAI,CAAA;AACvB,IAAM,WAAA,GAAc,GAAG,QAAQ,CAAA;AAExB,SAAS,cAAA,GAAoC;AAClD,EAAA,OAAO,QAAQ,QAAA,EAAS;AAC1B;AAEO,SAAS,YAAA,CACd,OACA,EAAA,EACY;AACZ,EAAA,OAAO,OAAA,CAAQ,GAAA,CAAI,KAAA,EAAO,EAAE,CAAA;AAC9B;AAEO,SAAS,eAAA,GAAsC;AACpD,EAAA,OAAO,YAAY,QAAA,EAAS;AAC9B;AAEO,SAAS,eAAA,CACd,MACA,EAAA,EACY;AACZ,EAAA,OAAO,WAAA,CAAY,GAAA,CAAI,IAAA,EAAM,EAAE,CAAA;AACjC","file":"chunk-XKR3GXTH.js","sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks';\n\nimport type { Trace } from '../trace.ts';\n\n// Global singleton ensures all CJS entry points share one AsyncLocalStorage instance.\nconst _key = Symbol.for('@refactorlabs/recount.storage');\nconst _nameKey = Symbol.for('@refactorlabs/recount.spanName');\nconst _g = globalThis as Record<symbol, AsyncLocalStorage<unknown>>;\nif (!_g[_key]) _g[_key] = new AsyncLocalStorage<Trace>();\nif (!_g[_nameKey]) _g[_nameKey] = new AsyncLocalStorage<string>();\nconst storage = _g[_key] as AsyncLocalStorage<Trace>;\nconst nameStorage = _g[_nameKey] as AsyncLocalStorage<string>;\n\nexport function getActiveTrace(): Trace | undefined {\n return storage.getStore();\n}\n\nexport function runWithTrace<T>(\n trace: Trace,\n fn: () => Promise<T>\n): Promise<T> {\n return storage.run(trace, fn);\n}\n\nexport function getNextSpanName(): string | undefined {\n return nameStorage.getStore();\n}\n\nexport function runWithSpanName<T>(\n name: string,\n fn: () => Promise<T>\n): Promise<T> {\n return nameStorage.run(name, fn);\n}\n"]}